Lines Matching +full:num +full:- +full:irqs

1 // SPDX-License-Identifier: GPL-2.0-or-later
20 * Since we want to track memory mappings to be able to force-unmap
26 * Therefore we implement our own simple pseudo-filesystem and inode
28 * meta-data associated with it (address_space) and it is shared by
40 return init_pseudo(fc, CXL_PSEUDO_FS_MAGIC) ? 0 : -ENOMEM; in cxl_fs_init_fs_context()
53 if (ctx->kernelapi && ctx->mapping) in cxl_release_mapping()
67 if (fops->owner && !try_module_get(fops->owner)) in cxl_getfile()
68 return ERR_PTR(-ENOENT); in cxl_getfile()
77 inode = alloc_anon_inode(cxl_vfs_mount->mnt_sb); in cxl_getfile()
88 file->private_data = priv; in cxl_getfile()
97 module_put(fops->owner); in cxl_getfile()
113 return ERR_PTR(-ENOMEM); in cxl_dev_context_init()
115 ctx->kernelapi = true; in cxl_dev_context_init()
132 return dev->dev.archdata.cxl_ctx; in cxl_get_context()
138 if (ctx->status >= STARTED) in cxl_release_context()
139 return -EBUSY; in cxl_release_context()
147 static irq_hw_number_t cxl_find_afu_irq(struct cxl_context *ctx, int num) in cxl_find_afu_irq() argument
153 range = ctx->irqs.range[r]; in cxl_find_afu_irq()
154 if (num < range) { in cxl_find_afu_irq()
155 return ctx->irqs.offset[r] + num; in cxl_find_afu_irq()
157 num -= range; in cxl_find_afu_irq()
166 return -EINVAL; in cxl_set_priv()
168 ctx->priv = priv; in cxl_set_priv()
177 return ERR_PTR(-EINVAL); in cxl_get_priv()
179 return ctx->priv; in cxl_get_priv()
183 int cxl_allocate_afu_irqs(struct cxl_context *ctx, int num) in cxl_allocate_afu_irqs() argument
188 if (num == 0) in cxl_allocate_afu_irqs()
189 num = ctx->afu->pp_irqs; in cxl_allocate_afu_irqs()
190 res = afu_allocate_irqs(ctx, num); in cxl_allocate_afu_irqs()
200 cxl_map_irq(ctx->afu->adapter, hwirq, cxl_ops->psl_interrupt, ctx, "psl"); in cxl_allocate_afu_irqs()
203 if (ctx->status == STARTED) { in cxl_allocate_afu_irqs()
204 if (cxl_ops->update_ivtes) in cxl_allocate_afu_irqs()
205 cxl_ops->update_ivtes(ctx); in cxl_allocate_afu_irqs()
227 cxl_ops->release_irq_ranges(&ctx->irqs, ctx->afu->adapter); in cxl_free_afu_irqs()
231 int cxl_map_afu_irq(struct cxl_context *ctx, int num, in cxl_map_afu_irq() argument
239 hwirq = cxl_find_afu_irq(ctx, num); in cxl_map_afu_irq()
241 return -ENOENT; in cxl_map_afu_irq()
243 return cxl_map_irq(ctx->afu->adapter, hwirq, handler, cookie, name); in cxl_map_afu_irq()
247 void cxl_unmap_afu_irq(struct cxl_context *ctx, int num, void *cookie) in cxl_unmap_afu_irq() argument
252 hwirq = cxl_find_afu_irq(ctx, num); in cxl_unmap_afu_irq()
272 pr_devel("%s: pe: %i\n", __func__, ctx->pe); in cxl_start_context()
274 mutex_lock(&ctx->status_mutex); in cxl_start_context()
275 if (ctx->status == STARTED) in cxl_start_context()
282 rc = cxl_adapter_context_get(ctx->afu->adapter); in cxl_start_context()
287 ctx->pid = get_task_pid(task, PIDTYPE_PID); in cxl_start_context()
291 ctx->mm = get_task_mm(current); in cxl_start_context()
296 if (ctx->mm) { in cxl_start_context()
298 mmput(ctx->mm); in cxl_start_context()
300 mm_context_add_copro(ctx->mm); in cxl_start_context()
313 if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { in cxl_start_context()
314 put_pid(ctx->pid); in cxl_start_context()
315 ctx->pid = NULL; in cxl_start_context()
316 cxl_adapter_context_put(ctx->afu->adapter); in cxl_start_context()
320 if (ctx->mm) in cxl_start_context()
321 mm_context_remove_copro(ctx->mm); in cxl_start_context()
326 ctx->status = STARTED; in cxl_start_context()
328 mutex_unlock(&ctx->status_mutex); in cxl_start_context()
335 return ctx->external_pe; in cxl_process_element()
339 /* Stop a context. Returns 0 on success, otherwise -Errno */
348 ctx->master = true; in cxl_set_master()
385 #define PATCH_FOPS(NAME) if (!fops->NAME) fops->NAME = afu_fops.NAME
396 if (ctx->mapping) in cxl_get_fd()
397 return ERR_PTR(-EEXIST); in cxl_get_fd()
421 name = kasprintf(GFP_KERNEL, "cxl:%d", ctx->pe); in cxl_get_fd()
427 cxl_context_set_mapping(ctx, file->f_mapping); in cxl_get_fd()
439 return file->private_data; in cxl_fops_get_context()
446 WARN_ON(!ops->fetch_event || !ops->event_delivered); in cxl_set_driver_ops()
447 atomic_set(&ctx->afu_driver_events, 0); in cxl_set_driver_ops()
448 ctx->afu_driver_ops = ops; in cxl_set_driver_ops()
455 atomic_add(new_events, &ctx->afu_driver_events); in cxl_context_events_pending()
456 wake_up_all(&ctx->wq); in cxl_context_events_pending()
466 if (!(work->flags & CXL_START_WORK_NUM_IRQS)) in cxl_start_work()
467 work->num_interrupts = ctx->afu->pp_irqs; in cxl_start_work()
468 else if ((work->num_interrupts < ctx->afu->pp_irqs) || in cxl_start_work()
469 (work->num_interrupts > ctx->afu->irqs_max)) { in cxl_start_work()
470 return -EINVAL; in cxl_start_work()
473 rc = afu_register_irqs(ctx, work->num_interrupts); in cxl_start_work()
477 rc = cxl_start_context(ctx, work->work_element_descriptor, current); in cxl_start_work()
489 if (ctx->status != STARTED) in cxl_psa_map()
493 __func__, ctx->psn_phys, ctx->psn_size); in cxl_psa_map()
494 return ioremap(ctx->psn_phys, ctx->psn_size); in cxl_psa_map()
506 struct cxl_afu *afu = ctx->afu; in cxl_afu_reset()
509 rc = cxl_ops->afu_reset(afu); in cxl_afu_reset()
513 return cxl_ops->afu_check_and_enable(afu); in cxl_afu_reset()
520 afu->adapter->perst_same_image = perst_reloads_same_image; in cxl_perst_reloads_same_image()
528 return -ENODEV; in cxl_read_adapter_vpd()
530 return cxl_ops->read_adapter_vpd(afu->adapter, buf, count); in cxl_read_adapter_vpd()