vfio_fsl_mc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
  2. /*
  3. * Copyright 2013-2016 Freescale Semiconductor Inc.
  4. * Copyright 2016-2017,2019-2020 NXP
  5. */
  6. #include <linux/device.h>
  7. #include <linux/iommu.h>
  8. #include <linux/module.h>
  9. #include <linux/mutex.h>
  10. #include <linux/slab.h>
  11. #include <linux/types.h>
  12. #include <linux/vfio.h>
  13. #include <linux/fsl/mc.h>
  14. #include <linux/delay.h>
  15. #include <linux/io-64-nonatomic-hi-lo.h>
  16. #include "vfio_fsl_mc_private.h"
  17. static struct fsl_mc_driver vfio_fsl_mc_driver;
  18. static int vfio_fsl_mc_open_device(struct vfio_device *core_vdev)
  19. {
  20. struct vfio_fsl_mc_device *vdev =
  21. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  22. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  23. int count = mc_dev->obj_desc.region_count;
  24. int i;
  25. vdev->regions = kcalloc(count, sizeof(struct vfio_fsl_mc_region),
  26. GFP_KERNEL);
  27. if (!vdev->regions)
  28. return -ENOMEM;
  29. for (i = 0; i < count; i++) {
  30. struct resource *res = &mc_dev->regions[i];
  31. int no_mmap = is_fsl_mc_bus_dprc(mc_dev);
  32. vdev->regions[i].addr = res->start;
  33. vdev->regions[i].size = resource_size(res);
  34. vdev->regions[i].type = mc_dev->regions[i].flags & IORESOURCE_BITS;
  35. /*
  36. * Only regions addressed with PAGE granularity may be
  37. * MMAPed securely.
  38. */
  39. if (!no_mmap && !(vdev->regions[i].addr & ~PAGE_MASK) &&
  40. !(vdev->regions[i].size & ~PAGE_MASK))
  41. vdev->regions[i].flags |=
  42. VFIO_REGION_INFO_FLAG_MMAP;
  43. vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_READ;
  44. if (!(mc_dev->regions[i].flags & IORESOURCE_READONLY))
  45. vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_WRITE;
  46. }
  47. return 0;
  48. }
  49. static void vfio_fsl_mc_regions_cleanup(struct vfio_fsl_mc_device *vdev)
  50. {
  51. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  52. int i;
  53. for (i = 0; i < mc_dev->obj_desc.region_count; i++)
  54. iounmap(vdev->regions[i].ioaddr);
  55. kfree(vdev->regions);
  56. }
  57. static int vfio_fsl_mc_reset_device(struct vfio_fsl_mc_device *vdev)
  58. {
  59. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  60. int ret = 0;
  61. if (is_fsl_mc_bus_dprc(vdev->mc_dev)) {
  62. return dprc_reset_container(mc_dev->mc_io, 0,
  63. mc_dev->mc_handle,
  64. mc_dev->obj_desc.id,
  65. DPRC_RESET_OPTION_NON_RECURSIVE);
  66. } else {
  67. u16 token;
  68. ret = fsl_mc_obj_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
  69. mc_dev->obj_desc.type,
  70. &token);
  71. if (ret)
  72. goto out;
  73. ret = fsl_mc_obj_reset(mc_dev->mc_io, 0, token);
  74. if (ret) {
  75. fsl_mc_obj_close(mc_dev->mc_io, 0, token);
  76. goto out;
  77. }
  78. ret = fsl_mc_obj_close(mc_dev->mc_io, 0, token);
  79. }
  80. out:
  81. return ret;
  82. }
  83. static void vfio_fsl_mc_close_device(struct vfio_device *core_vdev)
  84. {
  85. struct vfio_fsl_mc_device *vdev =
  86. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  87. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  88. struct device *cont_dev = fsl_mc_cont_dev(&mc_dev->dev);
  89. struct fsl_mc_device *mc_cont = to_fsl_mc_device(cont_dev);
  90. int ret;
  91. vfio_fsl_mc_regions_cleanup(vdev);
  92. /* reset the device before cleaning up the interrupts */
  93. ret = vfio_fsl_mc_reset_device(vdev);
  94. if (ret)
  95. dev_warn(&mc_cont->dev,
  96. "VFIO_FSL_MC: reset device has failed (%d)\n", ret);
  97. vfio_fsl_mc_irqs_cleanup(vdev);
  98. fsl_mc_cleanup_irq_pool(mc_cont);
  99. }
  100. static long vfio_fsl_mc_ioctl(struct vfio_device *core_vdev,
  101. unsigned int cmd, unsigned long arg)
  102. {
  103. unsigned long minsz;
  104. struct vfio_fsl_mc_device *vdev =
  105. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  106. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  107. switch (cmd) {
  108. case VFIO_DEVICE_GET_INFO:
  109. {
  110. struct vfio_device_info info;
  111. minsz = offsetofend(struct vfio_device_info, num_irqs);
  112. if (copy_from_user(&info, (void __user *)arg, minsz))
  113. return -EFAULT;
  114. if (info.argsz < minsz)
  115. return -EINVAL;
  116. info.flags = VFIO_DEVICE_FLAGS_FSL_MC;
  117. if (is_fsl_mc_bus_dprc(mc_dev))
  118. info.flags |= VFIO_DEVICE_FLAGS_RESET;
  119. info.num_regions = mc_dev->obj_desc.region_count;
  120. info.num_irqs = mc_dev->obj_desc.irq_count;
  121. return copy_to_user((void __user *)arg, &info, minsz) ?
  122. -EFAULT : 0;
  123. }
  124. case VFIO_DEVICE_GET_REGION_INFO:
  125. {
  126. struct vfio_region_info info;
  127. minsz = offsetofend(struct vfio_region_info, offset);
  128. if (copy_from_user(&info, (void __user *)arg, minsz))
  129. return -EFAULT;
  130. if (info.argsz < minsz)
  131. return -EINVAL;
  132. if (info.index >= mc_dev->obj_desc.region_count)
  133. return -EINVAL;
  134. /* map offset to the physical address */
  135. info.offset = VFIO_FSL_MC_INDEX_TO_OFFSET(info.index);
  136. info.size = vdev->regions[info.index].size;
  137. info.flags = vdev->regions[info.index].flags;
  138. if (copy_to_user((void __user *)arg, &info, minsz))
  139. return -EFAULT;
  140. return 0;
  141. }
  142. case VFIO_DEVICE_GET_IRQ_INFO:
  143. {
  144. struct vfio_irq_info info;
  145. minsz = offsetofend(struct vfio_irq_info, count);
  146. if (copy_from_user(&info, (void __user *)arg, minsz))
  147. return -EFAULT;
  148. if (info.argsz < minsz)
  149. return -EINVAL;
  150. if (info.index >= mc_dev->obj_desc.irq_count)
  151. return -EINVAL;
  152. info.flags = VFIO_IRQ_INFO_EVENTFD;
  153. info.count = 1;
  154. if (copy_to_user((void __user *)arg, &info, minsz))
  155. return -EFAULT;
  156. return 0;
  157. }
  158. case VFIO_DEVICE_SET_IRQS:
  159. {
  160. struct vfio_irq_set hdr;
  161. u8 *data = NULL;
  162. int ret = 0;
  163. size_t data_size = 0;
  164. minsz = offsetofend(struct vfio_irq_set, count);
  165. if (copy_from_user(&hdr, (void __user *)arg, minsz))
  166. return -EFAULT;
  167. ret = vfio_set_irqs_validate_and_prepare(&hdr, mc_dev->obj_desc.irq_count,
  168. mc_dev->obj_desc.irq_count, &data_size);
  169. if (ret)
  170. return ret;
  171. if (data_size) {
  172. data = memdup_user((void __user *)(arg + minsz),
  173. data_size);
  174. if (IS_ERR(data))
  175. return PTR_ERR(data);
  176. }
  177. mutex_lock(&vdev->igate);
  178. ret = vfio_fsl_mc_set_irqs_ioctl(vdev, hdr.flags,
  179. hdr.index, hdr.start,
  180. hdr.count, data);
  181. mutex_unlock(&vdev->igate);
  182. kfree(data);
  183. return ret;
  184. }
  185. case VFIO_DEVICE_RESET:
  186. {
  187. return vfio_fsl_mc_reset_device(vdev);
  188. }
  189. default:
  190. return -ENOTTY;
  191. }
  192. }
  193. static ssize_t vfio_fsl_mc_read(struct vfio_device *core_vdev, char __user *buf,
  194. size_t count, loff_t *ppos)
  195. {
  196. struct vfio_fsl_mc_device *vdev =
  197. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  198. unsigned int index = VFIO_FSL_MC_OFFSET_TO_INDEX(*ppos);
  199. loff_t off = *ppos & VFIO_FSL_MC_OFFSET_MASK;
  200. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  201. struct vfio_fsl_mc_region *region;
  202. u64 data[8];
  203. int i;
  204. if (index >= mc_dev->obj_desc.region_count)
  205. return -EINVAL;
  206. region = &vdev->regions[index];
  207. if (!(region->flags & VFIO_REGION_INFO_FLAG_READ))
  208. return -EINVAL;
  209. if (!region->ioaddr) {
  210. region->ioaddr = ioremap(region->addr, region->size);
  211. if (!region->ioaddr)
  212. return -ENOMEM;
  213. }
  214. if (count != 64 || off != 0)
  215. return -EINVAL;
  216. for (i = 7; i >= 0; i--)
  217. data[i] = readq(region->ioaddr + i * sizeof(uint64_t));
  218. if (copy_to_user(buf, data, 64))
  219. return -EFAULT;
  220. return count;
  221. }
  222. #define MC_CMD_COMPLETION_TIMEOUT_MS 5000
  223. #define MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS 500
  224. static int vfio_fsl_mc_send_command(void __iomem *ioaddr, uint64_t *cmd_data)
  225. {
  226. int i;
  227. enum mc_cmd_status status;
  228. unsigned long timeout_usecs = MC_CMD_COMPLETION_TIMEOUT_MS * 1000;
  229. /* Write at command parameter into portal */
  230. for (i = 7; i >= 1; i--)
  231. writeq_relaxed(cmd_data[i], ioaddr + i * sizeof(uint64_t));
  232. /* Write command header in the end */
  233. writeq(cmd_data[0], ioaddr);
  234. /* Wait for response before returning to user-space
  235. * This can be optimized in future to even prepare response
  236. * before returning to user-space and avoid read ioctl.
  237. */
  238. for (;;) {
  239. u64 header;
  240. struct mc_cmd_header *resp_hdr;
  241. header = cpu_to_le64(readq_relaxed(ioaddr));
  242. resp_hdr = (struct mc_cmd_header *)&header;
  243. status = (enum mc_cmd_status)resp_hdr->status;
  244. if (status != MC_CMD_STATUS_READY)
  245. break;
  246. udelay(MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS);
  247. timeout_usecs -= MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS;
  248. if (timeout_usecs == 0)
  249. return -ETIMEDOUT;
  250. }
  251. return 0;
  252. }
  253. static ssize_t vfio_fsl_mc_write(struct vfio_device *core_vdev,
  254. const char __user *buf, size_t count,
  255. loff_t *ppos)
  256. {
  257. struct vfio_fsl_mc_device *vdev =
  258. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  259. unsigned int index = VFIO_FSL_MC_OFFSET_TO_INDEX(*ppos);
  260. loff_t off = *ppos & VFIO_FSL_MC_OFFSET_MASK;
  261. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  262. struct vfio_fsl_mc_region *region;
  263. u64 data[8];
  264. int ret;
  265. if (index >= mc_dev->obj_desc.region_count)
  266. return -EINVAL;
  267. region = &vdev->regions[index];
  268. if (!(region->flags & VFIO_REGION_INFO_FLAG_WRITE))
  269. return -EINVAL;
  270. if (!region->ioaddr) {
  271. region->ioaddr = ioremap(region->addr, region->size);
  272. if (!region->ioaddr)
  273. return -ENOMEM;
  274. }
  275. if (count != 64 || off != 0)
  276. return -EINVAL;
  277. if (copy_from_user(&data, buf, 64))
  278. return -EFAULT;
  279. ret = vfio_fsl_mc_send_command(region->ioaddr, data);
  280. if (ret)
  281. return ret;
  282. return count;
  283. }
  284. static int vfio_fsl_mc_mmap_mmio(struct vfio_fsl_mc_region region,
  285. struct vm_area_struct *vma)
  286. {
  287. u64 size = vma->vm_end - vma->vm_start;
  288. u64 pgoff, base;
  289. u8 region_cacheable;
  290. pgoff = vma->vm_pgoff &
  291. ((1U << (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT)) - 1);
  292. base = pgoff << PAGE_SHIFT;
  293. if (region.size < PAGE_SIZE || base + size > region.size)
  294. return -EINVAL;
  295. region_cacheable = (region.type & FSL_MC_REGION_CACHEABLE) &&
  296. (region.type & FSL_MC_REGION_SHAREABLE);
  297. if (!region_cacheable)
  298. vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
  299. vma->vm_pgoff = (region.addr >> PAGE_SHIFT) + pgoff;
  300. return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
  301. size, vma->vm_page_prot);
  302. }
  303. static int vfio_fsl_mc_mmap(struct vfio_device *core_vdev,
  304. struct vm_area_struct *vma)
  305. {
  306. struct vfio_fsl_mc_device *vdev =
  307. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  308. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  309. unsigned int index;
  310. index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);
  311. if (vma->vm_end < vma->vm_start)
  312. return -EINVAL;
  313. if (vma->vm_start & ~PAGE_MASK)
  314. return -EINVAL;
  315. if (vma->vm_end & ~PAGE_MASK)
  316. return -EINVAL;
  317. if (!(vma->vm_flags & VM_SHARED))
  318. return -EINVAL;
  319. if (index >= mc_dev->obj_desc.region_count)
  320. return -EINVAL;
  321. if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_MMAP))
  322. return -EINVAL;
  323. if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_READ)
  324. && (vma->vm_flags & VM_READ))
  325. return -EINVAL;
  326. if (!(vdev->regions[index].flags & VFIO_REGION_INFO_FLAG_WRITE)
  327. && (vma->vm_flags & VM_WRITE))
  328. return -EINVAL;
  329. vma->vm_private_data = mc_dev;
  330. return vfio_fsl_mc_mmap_mmio(vdev->regions[index], vma);
  331. }
  332. static const struct vfio_device_ops vfio_fsl_mc_ops;
  333. static int vfio_fsl_mc_bus_notifier(struct notifier_block *nb,
  334. unsigned long action, void *data)
  335. {
  336. struct vfio_fsl_mc_device *vdev = container_of(nb,
  337. struct vfio_fsl_mc_device, nb);
  338. struct device *dev = data;
  339. struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
  340. struct fsl_mc_device *mc_cont = to_fsl_mc_device(mc_dev->dev.parent);
  341. if (action == BUS_NOTIFY_ADD_DEVICE &&
  342. vdev->mc_dev == mc_cont) {
  343. mc_dev->driver_override = kasprintf(GFP_KERNEL, "%s",
  344. vfio_fsl_mc_ops.name);
  345. if (!mc_dev->driver_override)
  346. dev_warn(dev, "VFIO_FSL_MC: Setting driver override for device in dprc %s failed\n",
  347. dev_name(&mc_cont->dev));
  348. else
  349. dev_info(dev, "VFIO_FSL_MC: Setting driver override for device in dprc %s\n",
  350. dev_name(&mc_cont->dev));
  351. } else if (action == BUS_NOTIFY_BOUND_DRIVER &&
  352. vdev->mc_dev == mc_cont) {
  353. struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
  354. if (mc_drv && mc_drv != &vfio_fsl_mc_driver)
  355. dev_warn(dev, "VFIO_FSL_MC: Object %s bound to driver %s while DPRC bound to vfio-fsl-mc\n",
  356. dev_name(dev), mc_drv->driver.name);
  357. }
  358. return 0;
  359. }
  360. static int vfio_fsl_mc_init_device(struct vfio_fsl_mc_device *vdev)
  361. {
  362. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  363. int ret;
  364. /* Non-dprc devices share mc_io from parent */
  365. if (!is_fsl_mc_bus_dprc(mc_dev)) {
  366. struct fsl_mc_device *mc_cont = to_fsl_mc_device(mc_dev->dev.parent);
  367. mc_dev->mc_io = mc_cont->mc_io;
  368. return 0;
  369. }
  370. vdev->nb.notifier_call = vfio_fsl_mc_bus_notifier;
  371. ret = bus_register_notifier(&fsl_mc_bus_type, &vdev->nb);
  372. if (ret)
  373. return ret;
  374. /* open DPRC, allocate a MC portal */
  375. ret = dprc_setup(mc_dev);
  376. if (ret) {
  377. dev_err(&mc_dev->dev, "VFIO_FSL_MC: Failed to setup DPRC (%d)\n", ret);
  378. goto out_nc_unreg;
  379. }
  380. return 0;
  381. out_nc_unreg:
  382. bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb);
  383. return ret;
  384. }
  385. static int vfio_fsl_mc_scan_container(struct fsl_mc_device *mc_dev)
  386. {
  387. int ret;
  388. /* non dprc devices do not scan for other devices */
  389. if (!is_fsl_mc_bus_dprc(mc_dev))
  390. return 0;
  391. ret = dprc_scan_container(mc_dev, false);
  392. if (ret) {
  393. dev_err(&mc_dev->dev,
  394. "VFIO_FSL_MC: Container scanning failed (%d)\n", ret);
  395. dprc_remove_devices(mc_dev, NULL, 0);
  396. return ret;
  397. }
  398. return 0;
  399. }
  400. static void vfio_fsl_uninit_device(struct vfio_fsl_mc_device *vdev)
  401. {
  402. struct fsl_mc_device *mc_dev = vdev->mc_dev;
  403. if (!is_fsl_mc_bus_dprc(mc_dev))
  404. return;
  405. dprc_cleanup(mc_dev);
  406. bus_unregister_notifier(&fsl_mc_bus_type, &vdev->nb);
  407. }
  408. static int vfio_fsl_mc_init_dev(struct vfio_device *core_vdev)
  409. {
  410. struct vfio_fsl_mc_device *vdev =
  411. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  412. struct fsl_mc_device *mc_dev = to_fsl_mc_device(core_vdev->dev);
  413. int ret;
  414. vdev->mc_dev = mc_dev;
  415. mutex_init(&vdev->igate);
  416. if (is_fsl_mc_bus_dprc(mc_dev))
  417. ret = vfio_assign_device_set(core_vdev, &mc_dev->dev);
  418. else
  419. ret = vfio_assign_device_set(core_vdev, mc_dev->dev.parent);
  420. if (ret)
  421. return ret;
  422. /* device_set is released by vfio core if @init fails */
  423. return vfio_fsl_mc_init_device(vdev);
  424. }
  425. static int vfio_fsl_mc_probe(struct fsl_mc_device *mc_dev)
  426. {
  427. struct vfio_fsl_mc_device *vdev;
  428. struct device *dev = &mc_dev->dev;
  429. int ret;
  430. vdev = vfio_alloc_device(vfio_fsl_mc_device, vdev, dev,
  431. &vfio_fsl_mc_ops);
  432. if (IS_ERR(vdev))
  433. return PTR_ERR(vdev);
  434. ret = vfio_register_group_dev(&vdev->vdev);
  435. if (ret) {
  436. dev_err(dev, "VFIO_FSL_MC: Failed to add to vfio group\n");
  437. goto out_put_vdev;
  438. }
  439. ret = vfio_fsl_mc_scan_container(mc_dev);
  440. if (ret)
  441. goto out_group_dev;
  442. dev_set_drvdata(dev, vdev);
  443. return 0;
  444. out_group_dev:
  445. vfio_unregister_group_dev(&vdev->vdev);
  446. out_put_vdev:
  447. vfio_put_device(&vdev->vdev);
  448. return ret;
  449. }
  450. static void vfio_fsl_mc_release_dev(struct vfio_device *core_vdev)
  451. {
  452. struct vfio_fsl_mc_device *vdev =
  453. container_of(core_vdev, struct vfio_fsl_mc_device, vdev);
  454. vfio_fsl_uninit_device(vdev);
  455. mutex_destroy(&vdev->igate);
  456. vfio_free_device(core_vdev);
  457. }
  458. static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
  459. {
  460. struct device *dev = &mc_dev->dev;
  461. struct vfio_fsl_mc_device *vdev = dev_get_drvdata(dev);
  462. vfio_unregister_group_dev(&vdev->vdev);
  463. dprc_remove_devices(mc_dev, NULL, 0);
  464. vfio_put_device(&vdev->vdev);
  465. return 0;
  466. }
  467. static const struct vfio_device_ops vfio_fsl_mc_ops = {
  468. .name = "vfio-fsl-mc",
  469. .init = vfio_fsl_mc_init_dev,
  470. .release = vfio_fsl_mc_release_dev,
  471. .open_device = vfio_fsl_mc_open_device,
  472. .close_device = vfio_fsl_mc_close_device,
  473. .ioctl = vfio_fsl_mc_ioctl,
  474. .read = vfio_fsl_mc_read,
  475. .write = vfio_fsl_mc_write,
  476. .mmap = vfio_fsl_mc_mmap,
  477. };
  478. static struct fsl_mc_driver vfio_fsl_mc_driver = {
  479. .probe = vfio_fsl_mc_probe,
  480. .remove = vfio_fsl_mc_remove,
  481. .driver = {
  482. .name = "vfio-fsl-mc",
  483. .owner = THIS_MODULE,
  484. },
  485. .driver_managed_dma = true,
  486. };
  487. static int __init vfio_fsl_mc_driver_init(void)
  488. {
  489. return fsl_mc_driver_register(&vfio_fsl_mc_driver);
  490. }
  491. static void __exit vfio_fsl_mc_driver_exit(void)
  492. {
  493. fsl_mc_driver_unregister(&vfio_fsl_mc_driver);
  494. }
  495. module_init(vfio_fsl_mc_driver_init);
  496. module_exit(vfio_fsl_mc_driver_exit);
  497. MODULE_LICENSE("Dual BSD/GPL");
  498. MODULE_DESCRIPTION("VFIO for FSL-MC devices - User Level meta-driver");