api.c 15 KB

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