api.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * Copyright 2014 IBM Corp.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <linux/pci.h>
  10. #include <linux/slab.h>
  11. #include <linux/file.h>
  12. #include <misc/cxl.h>
  13. #include <linux/msi.h>
  14. #include <linux/module.h>
  15. #include <linux/mount.h>
  16. #include <linux/sched/mm.h>
  17. #include <linux/mmu_context.h>
  18. #include "cxl.h"
  19. /*
  20. * Since we want to track memory mappings to be able to force-unmap
  21. * when the AFU is no longer reachable, we need an inode. For devices
  22. * opened through the cxl user API, this is not a problem, but a
  23. * userland process can also get a cxl fd through the cxl_get_fd()
  24. * API, which is used by the cxlflash driver.
  25. *
  26. * Therefore we implement our own simple pseudo-filesystem and inode
  27. * allocator. We don't use the anonymous inode, as we need the
  28. * meta-data associated with it (address_space) and it is shared by
  29. * other drivers/processes, so it could lead to cxl unmapping VMAs
  30. * from random processes.
  31. */
  32. #define CXL_PSEUDO_FS_MAGIC 0x1697697f
  33. static int cxl_fs_cnt;
  34. static struct vfsmount *cxl_vfs_mount;
  35. static const struct dentry_operations cxl_fs_dops = {
  36. .d_dname = simple_dname,
  37. };
  38. static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags,
  39. const char *dev_name, void *data)
  40. {
  41. return mount_pseudo(fs_type, "cxl:", NULL, &cxl_fs_dops,
  42. CXL_PSEUDO_FS_MAGIC);
  43. }
  44. static struct file_system_type cxl_fs_type = {
  45. .name = "cxl",
  46. .owner = THIS_MODULE,
  47. .mount = cxl_fs_mount,
  48. .kill_sb = kill_anon_super,
  49. };
  50. void cxl_release_mapping(struct cxl_context *ctx)
  51. {
  52. if (ctx->kernelapi && ctx->mapping)
  53. simple_release_fs(&cxl_vfs_mount, &cxl_fs_cnt);
  54. }
  55. static struct file *cxl_getfile(const char *name,
  56. const struct file_operations *fops,
  57. void *priv, int flags)
  58. {
  59. struct qstr this;
  60. struct path path;
  61. struct file *file;
  62. struct inode *inode = NULL;
  63. int rc;
  64. /* strongly inspired by anon_inode_getfile() */
  65. if (fops->owner && !try_module_get(fops->owner))
  66. return ERR_PTR(-ENOENT);
  67. rc = simple_pin_fs(&cxl_fs_type, &cxl_vfs_mount, &cxl_fs_cnt);
  68. if (rc < 0) {
  69. pr_err("Cannot mount cxl pseudo filesystem: %d\n", rc);
  70. file = ERR_PTR(rc);
  71. goto err_module;
  72. }
  73. inode = alloc_anon_inode(cxl_vfs_mount->mnt_sb);
  74. if (IS_ERR(inode)) {
  75. file = ERR_CAST(inode);
  76. goto err_fs;
  77. }
  78. file = ERR_PTR(-ENOMEM);
  79. this.name = name;
  80. this.len = strlen(name);
  81. this.hash = 0;
  82. path.dentry = d_alloc_pseudo(cxl_vfs_mount->mnt_sb, &this);
  83. if (!path.dentry)
  84. goto err_inode;
  85. path.mnt = mntget(cxl_vfs_mount);
  86. d_instantiate(path.dentry, inode);
  87. file = alloc_file(&path, OPEN_FMODE(flags), fops);
  88. if (IS_ERR(file))
  89. goto err_dput;
  90. file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
  91. file->private_data = priv;
  92. return file;
  93. err_dput:
  94. path_put(&path);
  95. err_inode:
  96. iput(inode);
  97. err_fs:
  98. simple_release_fs(&cxl_vfs_mount, &cxl_fs_cnt);
  99. err_module:
  100. module_put(fops->owner);
  101. return file;
  102. }
  103. struct cxl_context *cxl_dev_context_init(struct pci_dev *dev)
  104. {
  105. struct cxl_afu *afu;
  106. struct cxl_context *ctx;
  107. int rc;
  108. afu = cxl_pci_to_afu(dev);
  109. if (IS_ERR(afu))
  110. return ERR_CAST(afu);
  111. ctx = cxl_context_alloc();
  112. if (!ctx)
  113. return ERR_PTR(-ENOMEM);
  114. ctx->kernelapi = true;
  115. /* Make it a slave context. We can promote it later? */
  116. rc = cxl_context_init(ctx, afu, false);
  117. if (rc)
  118. goto err_ctx;
  119. return ctx;
  120. err_ctx:
  121. kfree(ctx);
  122. return ERR_PTR(rc);
  123. }
  124. EXPORT_SYMBOL_GPL(cxl_dev_context_init);
  125. struct cxl_context *cxl_get_context(struct pci_dev *dev)
  126. {
  127. return dev->dev.archdata.cxl_ctx;
  128. }
  129. EXPORT_SYMBOL_GPL(cxl_get_context);
  130. int cxl_release_context(struct cxl_context *ctx)
  131. {
  132. if (ctx->status >= STARTED)
  133. return -EBUSY;
  134. cxl_context_free(ctx);
  135. return 0;
  136. }
  137. EXPORT_SYMBOL_GPL(cxl_release_context);
  138. static irq_hw_number_t cxl_find_afu_irq(struct cxl_context *ctx, int num)
  139. {
  140. __u16 range;
  141. int r;
  142. for (r = 0; r < CXL_IRQ_RANGES; r++) {
  143. range = ctx->irqs.range[r];
  144. if (num < range) {
  145. return ctx->irqs.offset[r] + num;
  146. }
  147. num -= range;
  148. }
  149. return 0;
  150. }
  151. int _cxl_next_msi_hwirq(struct pci_dev *pdev, struct cxl_context **ctx, int *afu_irq)
  152. {
  153. if (*ctx == NULL || *afu_irq == 0) {
  154. *afu_irq = 1;
  155. *ctx = cxl_get_context(pdev);
  156. } else {
  157. (*afu_irq)++;
  158. if (*afu_irq > cxl_get_max_irqs_per_process(pdev)) {
  159. *ctx = list_next_entry(*ctx, extra_irq_contexts);
  160. *afu_irq = 1;
  161. }
  162. }
  163. return cxl_find_afu_irq(*ctx, *afu_irq);
  164. }
  165. /* Exported via cxl_base */
  166. int cxl_set_priv(struct cxl_context *ctx, void *priv)
  167. {
  168. if (!ctx)
  169. return -EINVAL;
  170. ctx->priv = priv;
  171. return 0;
  172. }
  173. EXPORT_SYMBOL_GPL(cxl_set_priv);
  174. void *cxl_get_priv(struct cxl_context *ctx)
  175. {
  176. if (!ctx)
  177. return ERR_PTR(-EINVAL);
  178. return ctx->priv;
  179. }
  180. EXPORT_SYMBOL_GPL(cxl_get_priv);
  181. int cxl_allocate_afu_irqs(struct cxl_context *ctx, int num)
  182. {
  183. int res;
  184. irq_hw_number_t hwirq;
  185. if (num == 0)
  186. num = ctx->afu->pp_irqs;
  187. res = afu_allocate_irqs(ctx, num);
  188. if (res)
  189. return res;
  190. if (!cpu_has_feature(CPU_FTR_HVMODE)) {
  191. /* In a guest, the PSL interrupt is not multiplexed. It was
  192. * allocated above, and we need to set its handler
  193. */
  194. hwirq = cxl_find_afu_irq(ctx, 0);
  195. if (hwirq)
  196. cxl_map_irq(ctx->afu->adapter, hwirq, cxl_ops->psl_interrupt, ctx, "psl");
  197. }
  198. if (ctx->status == STARTED) {
  199. if (cxl_ops->update_ivtes)
  200. cxl_ops->update_ivtes(ctx);
  201. else WARN(1, "BUG: cxl_allocate_afu_irqs must be called prior to starting the context on this platform\n");
  202. }
  203. return res;
  204. }
  205. EXPORT_SYMBOL_GPL(cxl_allocate_afu_irqs);
  206. void cxl_free_afu_irqs(struct cxl_context *ctx)
  207. {
  208. irq_hw_number_t hwirq;
  209. unsigned int virq;
  210. if (!cpu_has_feature(CPU_FTR_HVMODE)) {
  211. hwirq = cxl_find_afu_irq(ctx, 0);
  212. if (hwirq) {
  213. virq = irq_find_mapping(NULL, hwirq);
  214. if (virq)
  215. cxl_unmap_irq(virq, ctx);
  216. }
  217. }
  218. afu_irq_name_free(ctx);
  219. cxl_ops->release_irq_ranges(&ctx->irqs, ctx->afu->adapter);
  220. }
  221. EXPORT_SYMBOL_GPL(cxl_free_afu_irqs);
  222. int cxl_map_afu_irq(struct cxl_context *ctx, int num,
  223. irq_handler_t handler, void *cookie, char *name)
  224. {
  225. irq_hw_number_t hwirq;
  226. /*
  227. * Find interrupt we are to register.
  228. */
  229. hwirq = cxl_find_afu_irq(ctx, num);
  230. if (!hwirq)
  231. return -ENOENT;
  232. return cxl_map_irq(ctx->afu->adapter, hwirq, handler, cookie, name);
  233. }
  234. EXPORT_SYMBOL_GPL(cxl_map_afu_irq);
  235. void cxl_unmap_afu_irq(struct cxl_context *ctx, int num, void *cookie)
  236. {
  237. irq_hw_number_t hwirq;
  238. unsigned int virq;
  239. hwirq = cxl_find_afu_irq(ctx, num);
  240. if (!hwirq)
  241. return;
  242. virq = irq_find_mapping(NULL, hwirq);
  243. if (virq)
  244. cxl_unmap_irq(virq, cookie);
  245. }
  246. EXPORT_SYMBOL_GPL(cxl_unmap_afu_irq);
  247. /*
  248. * Start a context
  249. * Code here similar to afu_ioctl_start_work().
  250. */
  251. int cxl_start_context(struct cxl_context *ctx, u64 wed,
  252. struct task_struct *task)
  253. {
  254. int rc = 0;
  255. bool kernel = true;
  256. pr_devel("%s: pe: %i\n", __func__, ctx->pe);
  257. mutex_lock(&ctx->status_mutex);
  258. if (ctx->status == STARTED)
  259. goto out; /* already started */
  260. /*
  261. * Increment the mapped context count for adapter. This also checks
  262. * if adapter_context_lock is taken.
  263. */
  264. rc = cxl_adapter_context_get(ctx->afu->adapter);
  265. if (rc)
  266. goto out;
  267. if (task) {
  268. ctx->pid = get_task_pid(task, PIDTYPE_PID);
  269. kernel = false;
  270. /* acquire a reference to the task's mm */
  271. ctx->mm = get_task_mm(current);
  272. /* ensure this mm_struct can't be freed */
  273. cxl_context_mm_count_get(ctx);
  274. if (ctx->mm) {
  275. /* decrement the use count from above */
  276. mmput(ctx->mm);
  277. /* make TLBIs for this context global */
  278. mm_context_add_copro(ctx->mm);
  279. }
  280. }
  281. /*
  282. * Increment driver use count. Enables global TLBIs for hash
  283. * and callbacks to handle the segment table
  284. */
  285. cxl_ctx_get();
  286. /* See the comment in afu_ioctl_start_work() */
  287. smp_mb();
  288. if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) {
  289. put_pid(ctx->pid);
  290. ctx->pid = NULL;
  291. cxl_adapter_context_put(ctx->afu->adapter);
  292. cxl_ctx_put();
  293. if (task) {
  294. cxl_context_mm_count_put(ctx);
  295. if (ctx->mm)
  296. mm_context_remove_copro(ctx->mm);
  297. }
  298. goto out;
  299. }
  300. ctx->status = STARTED;
  301. out:
  302. mutex_unlock(&ctx->status_mutex);
  303. return rc;
  304. }
  305. EXPORT_SYMBOL_GPL(cxl_start_context);
  306. int cxl_process_element(struct cxl_context *ctx)
  307. {
  308. return ctx->external_pe;
  309. }
  310. EXPORT_SYMBOL_GPL(cxl_process_element);
  311. /* Stop a context. Returns 0 on success, otherwise -Errno */
  312. int cxl_stop_context(struct cxl_context *ctx)
  313. {
  314. return __detach_context(ctx);
  315. }
  316. EXPORT_SYMBOL_GPL(cxl_stop_context);
  317. void cxl_set_master(struct cxl_context *ctx)
  318. {
  319. ctx->master = true;
  320. }
  321. EXPORT_SYMBOL_GPL(cxl_set_master);
  322. /* wrappers around afu_* file ops which are EXPORTED */
  323. int cxl_fd_open(struct inode *inode, struct file *file)
  324. {
  325. return afu_open(inode, file);
  326. }
  327. EXPORT_SYMBOL_GPL(cxl_fd_open);
  328. int cxl_fd_release(struct inode *inode, struct file *file)
  329. {
  330. return afu_release(inode, file);
  331. }
  332. EXPORT_SYMBOL_GPL(cxl_fd_release);
  333. long cxl_fd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  334. {
  335. return afu_ioctl(file, cmd, arg);
  336. }
  337. EXPORT_SYMBOL_GPL(cxl_fd_ioctl);
  338. int cxl_fd_mmap(struct file *file, struct vm_area_struct *vm)
  339. {
  340. return afu_mmap(file, vm);
  341. }
  342. EXPORT_SYMBOL_GPL(cxl_fd_mmap);
  343. __poll_t cxl_fd_poll(struct file *file, struct poll_table_struct *poll)
  344. {
  345. return afu_poll(file, poll);
  346. }
  347. EXPORT_SYMBOL_GPL(cxl_fd_poll);
  348. ssize_t cxl_fd_read(struct file *file, char __user *buf, size_t count,
  349. loff_t *off)
  350. {
  351. return afu_read(file, buf, count, off);
  352. }
  353. EXPORT_SYMBOL_GPL(cxl_fd_read);
  354. #define PATCH_FOPS(NAME) if (!fops->NAME) fops->NAME = afu_fops.NAME
  355. /* Get a struct file and fd for a context and attach the ops */
  356. struct file *cxl_get_fd(struct cxl_context *ctx, struct file_operations *fops,
  357. int *fd)
  358. {
  359. struct file *file;
  360. int rc, flags, fdtmp;
  361. char *name = NULL;
  362. /* only allow one per context */
  363. if (ctx->mapping)
  364. return ERR_PTR(-EEXIST);
  365. flags = O_RDWR | O_CLOEXEC;
  366. /* This code is similar to anon_inode_getfd() */
  367. rc = get_unused_fd_flags(flags);
  368. if (rc < 0)
  369. return ERR_PTR(rc);
  370. fdtmp = rc;
  371. /*
  372. * Patch the file ops. Needs to be careful that this is rentrant safe.
  373. */
  374. if (fops) {
  375. PATCH_FOPS(open);
  376. PATCH_FOPS(poll);
  377. PATCH_FOPS(read);
  378. PATCH_FOPS(release);
  379. PATCH_FOPS(unlocked_ioctl);
  380. PATCH_FOPS(compat_ioctl);
  381. PATCH_FOPS(mmap);
  382. } else /* use default ops */
  383. fops = (struct file_operations *)&afu_fops;
  384. name = kasprintf(GFP_KERNEL, "cxl:%d", ctx->pe);
  385. file = cxl_getfile(name, fops, ctx, flags);
  386. kfree(name);
  387. if (IS_ERR(file))
  388. goto err_fd;
  389. cxl_context_set_mapping(ctx, file->f_mapping);
  390. *fd = fdtmp;
  391. return file;
  392. err_fd:
  393. put_unused_fd(fdtmp);
  394. return NULL;
  395. }
  396. EXPORT_SYMBOL_GPL(cxl_get_fd);
  397. struct cxl_context *cxl_fops_get_context(struct file *file)
  398. {
  399. return file->private_data;
  400. }
  401. EXPORT_SYMBOL_GPL(cxl_fops_get_context);
  402. void cxl_set_driver_ops(struct cxl_context *ctx,
  403. struct cxl_afu_driver_ops *ops)
  404. {
  405. WARN_ON(!ops->fetch_event || !ops->event_delivered);
  406. atomic_set(&ctx->afu_driver_events, 0);
  407. ctx->afu_driver_ops = ops;
  408. }
  409. EXPORT_SYMBOL_GPL(cxl_set_driver_ops);
  410. void cxl_context_events_pending(struct cxl_context *ctx,
  411. unsigned int new_events)
  412. {
  413. atomic_add(new_events, &ctx->afu_driver_events);
  414. wake_up_all(&ctx->wq);
  415. }
  416. EXPORT_SYMBOL_GPL(cxl_context_events_pending);
  417. int cxl_start_work(struct cxl_context *ctx,
  418. struct cxl_ioctl_start_work *work)
  419. {
  420. int rc;
  421. /* code taken from afu_ioctl_start_work */
  422. if (!(work->flags & CXL_START_WORK_NUM_IRQS))
  423. work->num_interrupts = ctx->afu->pp_irqs;
  424. else if ((work->num_interrupts < ctx->afu->pp_irqs) ||
  425. (work->num_interrupts > ctx->afu->irqs_max)) {
  426. return -EINVAL;
  427. }
  428. rc = afu_register_irqs(ctx, work->num_interrupts);
  429. if (rc)
  430. return rc;
  431. rc = cxl_start_context(ctx, work->work_element_descriptor, current);
  432. if (rc < 0) {
  433. afu_release_irqs(ctx, ctx);
  434. return rc;
  435. }
  436. return 0;
  437. }
  438. EXPORT_SYMBOL_GPL(cxl_start_work);
  439. void __iomem *cxl_psa_map(struct cxl_context *ctx)
  440. {
  441. if (ctx->status != STARTED)
  442. return NULL;
  443. pr_devel("%s: psn_phys%llx size:%llx\n",
  444. __func__, ctx->psn_phys, ctx->psn_size);
  445. return ioremap(ctx->psn_phys, ctx->psn_size);
  446. }
  447. EXPORT_SYMBOL_GPL(cxl_psa_map);
  448. void cxl_psa_unmap(void __iomem *addr)
  449. {
  450. iounmap(addr);
  451. }
  452. EXPORT_SYMBOL_GPL(cxl_psa_unmap);
  453. int cxl_afu_reset(struct cxl_context *ctx)
  454. {
  455. struct cxl_afu *afu = ctx->afu;
  456. int rc;
  457. rc = cxl_ops->afu_reset(afu);
  458. if (rc)
  459. return rc;
  460. return cxl_ops->afu_check_and_enable(afu);
  461. }
  462. EXPORT_SYMBOL_GPL(cxl_afu_reset);
  463. void cxl_perst_reloads_same_image(struct cxl_afu *afu,
  464. bool perst_reloads_same_image)
  465. {
  466. afu->adapter->perst_same_image = perst_reloads_same_image;
  467. }
  468. EXPORT_SYMBOL_GPL(cxl_perst_reloads_same_image);
  469. ssize_t cxl_read_adapter_vpd(struct pci_dev *dev, void *buf, size_t count)
  470. {
  471. struct cxl_afu *afu = cxl_pci_to_afu(dev);
  472. if (IS_ERR(afu))
  473. return -ENODEV;
  474. return cxl_ops->read_adapter_vpd(afu->adapter, buf, count);
  475. }
  476. EXPORT_SYMBOL_GPL(cxl_read_adapter_vpd);
  477. int cxl_set_max_irqs_per_process(struct pci_dev *dev, int irqs)
  478. {
  479. struct cxl_afu *afu = cxl_pci_to_afu(dev);
  480. if (IS_ERR(afu))
  481. return -ENODEV;
  482. if (irqs > afu->adapter->user_irqs)
  483. return -EINVAL;
  484. /* Limit user_irqs to prevent the user increasing this via sysfs */
  485. afu->adapter->user_irqs = irqs;
  486. afu->irqs_max = irqs;
  487. return 0;
  488. }
  489. EXPORT_SYMBOL_GPL(cxl_set_max_irqs_per_process);
  490. int cxl_get_max_irqs_per_process(struct pci_dev *dev)
  491. {
  492. struct cxl_afu *afu = cxl_pci_to_afu(dev);
  493. if (IS_ERR(afu))
  494. return -ENODEV;
  495. return afu->irqs_max;
  496. }
  497. EXPORT_SYMBOL_GPL(cxl_get_max_irqs_per_process);
  498. /*
  499. * This is a special interrupt allocation routine called from the PHB's MSI
  500. * setup function. When capi interrupts are allocated in this manner they must
  501. * still be associated with a running context, but since the MSI APIs have no
  502. * way to specify this we use the default context associated with the device.
  503. *
  504. * The Mellanox CX4 has a hardware limitation that restricts the maximum AFU
  505. * interrupt number, so in order to overcome this their driver informs us of
  506. * the restriction by setting the maximum interrupts per context, and we
  507. * allocate additional contexts as necessary so that we can keep the AFU
  508. * interrupt number within the supported range.
  509. */
  510. int _cxl_cx4_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
  511. {
  512. struct cxl_context *ctx, *new_ctx, *default_ctx;
  513. int remaining;
  514. int rc;
  515. ctx = default_ctx = cxl_get_context(pdev);
  516. if (WARN_ON(!default_ctx))
  517. return -ENODEV;
  518. remaining = nvec;
  519. while (remaining > 0) {
  520. rc = cxl_allocate_afu_irqs(ctx, min(remaining, ctx->afu->irqs_max));
  521. if (rc) {
  522. pr_warn("%s: Failed to find enough free MSIs\n", pci_name(pdev));
  523. return rc;
  524. }
  525. remaining -= ctx->afu->irqs_max;
  526. if (ctx != default_ctx && default_ctx->status == STARTED) {
  527. WARN_ON(cxl_start_context(ctx,
  528. be64_to_cpu(default_ctx->elem->common.wed),
  529. NULL));
  530. }
  531. if (remaining > 0) {
  532. new_ctx = cxl_dev_context_init(pdev);
  533. if (IS_ERR(new_ctx)) {
  534. pr_warn("%s: Failed to allocate enough contexts for MSIs\n", pci_name(pdev));
  535. return -ENOSPC;
  536. }
  537. list_add(&new_ctx->extra_irq_contexts, &ctx->extra_irq_contexts);
  538. ctx = new_ctx;
  539. }
  540. }
  541. return 0;
  542. }
  543. /* Exported via cxl_base */
  544. void _cxl_cx4_teardown_msi_irqs(struct pci_dev *pdev)
  545. {
  546. struct cxl_context *ctx, *pos, *tmp;
  547. ctx = cxl_get_context(pdev);
  548. if (WARN_ON(!ctx))
  549. return;
  550. cxl_free_afu_irqs(ctx);
  551. list_for_each_entry_safe(pos, tmp, &ctx->extra_irq_contexts, extra_irq_contexts) {
  552. cxl_stop_context(pos);
  553. cxl_free_afu_irqs(pos);
  554. list_del(&pos->extra_irq_contexts);
  555. cxl_release_context(pos);
  556. }
  557. }
  558. /* Exported via cxl_base */