mic_virtio.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2013 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License, version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Disclaimer: The codes contained in these modules may be specific to
  19. * the Intel Software Development Platform codenamed: Knights Ferry, and
  20. * the Intel product codenamed: Knights Corner, and are not backward
  21. * compatible with other Intel products. Additionally, Intel will NOT
  22. * support the codes or instruction set in future products.
  23. *
  24. * Adapted from:
  25. *
  26. * virtio for kvm on s390
  27. *
  28. * Copyright IBM Corp. 2008
  29. *
  30. * This program is free software; you can redistribute it and/or modify
  31. * it under the terms of the GNU General Public License (version 2 only)
  32. * as published by the Free Software Foundation.
  33. *
  34. * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
  35. *
  36. * Intel MIC Card driver.
  37. *
  38. */
  39. #include <linux/delay.h>
  40. #include <linux/slab.h>
  41. #include <linux/virtio_config.h>
  42. #include "../common/mic_dev.h"
  43. #include "mic_virtio.h"
  44. #define VIRTIO_SUBCODE_64 0x0D00
  45. #define MIC_MAX_VRINGS 4
  46. struct mic_vdev {
  47. struct virtio_device vdev;
  48. struct mic_device_desc __iomem *desc;
  49. struct mic_device_ctrl __iomem *dc;
  50. struct mic_device *mdev;
  51. void __iomem *vr[MIC_MAX_VRINGS];
  52. int used_size[MIC_MAX_VRINGS];
  53. struct completion reset_done;
  54. struct mic_irq *virtio_cookie;
  55. int c2h_vdev_db;
  56. };
  57. static struct mic_irq *virtio_config_cookie;
  58. #define to_micvdev(vd) container_of(vd, struct mic_vdev, vdev)
  59. /* Helper API to obtain the parent of the virtio device */
  60. static inline struct device *mic_dev(struct mic_vdev *mvdev)
  61. {
  62. return mvdev->vdev.dev.parent;
  63. }
  64. /* This gets the device's feature bits. */
  65. static u32 mic_get_features(struct virtio_device *vdev)
  66. {
  67. unsigned int i, bits;
  68. u32 features = 0;
  69. struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc;
  70. u8 __iomem *in_features = mic_vq_features(desc);
  71. int feature_len = ioread8(&desc->feature_len);
  72. bits = min_t(unsigned, feature_len,
  73. sizeof(vdev->features)) * 8;
  74. for (i = 0; i < bits; i++)
  75. if (ioread8(&in_features[i / 8]) & (BIT(i % 8)))
  76. features |= BIT(i);
  77. return features;
  78. }
  79. static void mic_finalize_features(struct virtio_device *vdev)
  80. {
  81. unsigned int i, bits;
  82. struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc;
  83. u8 feature_len = ioread8(&desc->feature_len);
  84. /* Second half of bitmap is features we accept. */
  85. u8 __iomem *out_features =
  86. mic_vq_features(desc) + feature_len;
  87. /* Give virtio_ring a chance to accept features. */
  88. vring_transport_features(vdev);
  89. memset_io(out_features, 0, feature_len);
  90. bits = min_t(unsigned, feature_len,
  91. sizeof(vdev->features)) * 8;
  92. for (i = 0; i < bits; i++) {
  93. if (test_bit(i, vdev->features))
  94. iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
  95. &out_features[i / 8]);
  96. }
  97. }
  98. /*
  99. * Reading and writing elements in config space
  100. */
  101. static void mic_get(struct virtio_device *vdev, unsigned int offset,
  102. void *buf, unsigned len)
  103. {
  104. struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc;
  105. if (offset + len > ioread8(&desc->config_len))
  106. return;
  107. memcpy_fromio(buf, mic_vq_configspace(desc) + offset, len);
  108. }
  109. static void mic_set(struct virtio_device *vdev, unsigned int offset,
  110. const void *buf, unsigned len)
  111. {
  112. struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc;
  113. if (offset + len > ioread8(&desc->config_len))
  114. return;
  115. memcpy_toio(mic_vq_configspace(desc) + offset, buf, len);
  116. }
  117. /*
  118. * The operations to get and set the status word just access the status
  119. * field of the device descriptor. set_status also interrupts the host
  120. * to tell about status changes.
  121. */
  122. static u8 mic_get_status(struct virtio_device *vdev)
  123. {
  124. return ioread8(&to_micvdev(vdev)->desc->status);
  125. }
  126. static void mic_set_status(struct virtio_device *vdev, u8 status)
  127. {
  128. struct mic_vdev *mvdev = to_micvdev(vdev);
  129. if (!status)
  130. return;
  131. iowrite8(status, &mvdev->desc->status);
  132. mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
  133. }
  134. /* Inform host on a virtio device reset and wait for ack from host */
  135. static void mic_reset_inform_host(struct virtio_device *vdev)
  136. {
  137. struct mic_vdev *mvdev = to_micvdev(vdev);
  138. struct mic_device_ctrl __iomem *dc = mvdev->dc;
  139. int retry;
  140. iowrite8(0, &dc->host_ack);
  141. iowrite8(1, &dc->vdev_reset);
  142. mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
  143. /* Wait till host completes all card accesses and acks the reset */
  144. for (retry = 100; retry--;) {
  145. if (ioread8(&dc->host_ack))
  146. break;
  147. msleep(100);
  148. };
  149. dev_dbg(mic_dev(mvdev), "%s: retry: %d\n", __func__, retry);
  150. /* Reset status to 0 in case we timed out */
  151. iowrite8(0, &mvdev->desc->status);
  152. }
  153. static void mic_reset(struct virtio_device *vdev)
  154. {
  155. struct mic_vdev *mvdev = to_micvdev(vdev);
  156. dev_dbg(mic_dev(mvdev), "%s: virtio id %d\n",
  157. __func__, vdev->id.device);
  158. mic_reset_inform_host(vdev);
  159. complete_all(&mvdev->reset_done);
  160. }
  161. /*
  162. * The virtio_ring code calls this API when it wants to notify the Host.
  163. */
  164. static bool mic_notify(struct virtqueue *vq)
  165. {
  166. struct mic_vdev *mvdev = vq->priv;
  167. mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
  168. return true;
  169. }
  170. static void mic_del_vq(struct virtqueue *vq, int n)
  171. {
  172. struct mic_vdev *mvdev = to_micvdev(vq->vdev);
  173. struct vring *vr = (struct vring *)(vq + 1);
  174. free_pages((unsigned long) vr->used, get_order(mvdev->used_size[n]));
  175. vring_del_virtqueue(vq);
  176. mic_card_unmap(mvdev->mdev, mvdev->vr[n]);
  177. mvdev->vr[n] = NULL;
  178. }
  179. static void mic_del_vqs(struct virtio_device *vdev)
  180. {
  181. struct mic_vdev *mvdev = to_micvdev(vdev);
  182. struct virtqueue *vq, *n;
  183. int idx = 0;
  184. dev_dbg(mic_dev(mvdev), "%s\n", __func__);
  185. list_for_each_entry_safe(vq, n, &vdev->vqs, list)
  186. mic_del_vq(vq, idx++);
  187. }
  188. /*
  189. * This routine will assign vring's allocated in host/io memory. Code in
  190. * virtio_ring.c however continues to access this io memory as if it were local
  191. * memory without io accessors.
  192. */
  193. static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
  194. unsigned index,
  195. void (*callback)(struct virtqueue *vq),
  196. const char *name)
  197. {
  198. struct mic_vdev *mvdev = to_micvdev(vdev);
  199. struct mic_vqconfig __iomem *vqconfig;
  200. struct mic_vqconfig config;
  201. struct virtqueue *vq;
  202. void __iomem *va;
  203. struct _mic_vring_info __iomem *info;
  204. void *used;
  205. int vr_size, _vr_size, err, magic;
  206. struct vring *vr;
  207. u8 type = ioread8(&mvdev->desc->type);
  208. if (index >= ioread8(&mvdev->desc->num_vq))
  209. return ERR_PTR(-ENOENT);
  210. if (!name)
  211. return ERR_PTR(-ENOENT);
  212. /* First assign the vring's allocated in host memory */
  213. vqconfig = mic_vq_config(mvdev->desc) + index;
  214. memcpy_fromio(&config, vqconfig, sizeof(config));
  215. _vr_size = vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN);
  216. vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info));
  217. va = mic_card_map(mvdev->mdev, le64_to_cpu(config.address), vr_size);
  218. if (!va)
  219. return ERR_PTR(-ENOMEM);
  220. mvdev->vr[index] = va;
  221. memset_io(va, 0x0, _vr_size);
  222. vq = vring_new_virtqueue(index, le16_to_cpu(config.num),
  223. MIC_VIRTIO_RING_ALIGN, vdev, false,
  224. (void __force *)va, mic_notify, callback,
  225. name);
  226. if (!vq) {
  227. err = -ENOMEM;
  228. goto unmap;
  229. }
  230. info = va + _vr_size;
  231. magic = ioread32(&info->magic);
  232. if (WARN(magic != MIC_MAGIC + type + index, "magic mismatch")) {
  233. err = -EIO;
  234. goto unmap;
  235. }
  236. /* Allocate and reassign used ring now */
  237. mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
  238. sizeof(struct vring_used_elem) *
  239. le16_to_cpu(config.num));
  240. used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
  241. get_order(mvdev->used_size[index]));
  242. if (!used) {
  243. err = -ENOMEM;
  244. dev_err(mic_dev(mvdev), "%s %d err %d\n",
  245. __func__, __LINE__, err);
  246. goto del_vq;
  247. }
  248. iowrite64(virt_to_phys(used), &vqconfig->used_address);
  249. /*
  250. * To reassign the used ring here we are directly accessing
  251. * struct vring_virtqueue which is a private data structure
  252. * in virtio_ring.c. At the minimum, a BUILD_BUG_ON() in
  253. * vring_new_virtqueue() would ensure that
  254. * (&vq->vring == (struct vring *) (&vq->vq + 1));
  255. */
  256. vr = (struct vring *)(vq + 1);
  257. vr->used = used;
  258. vq->priv = mvdev;
  259. return vq;
  260. del_vq:
  261. vring_del_virtqueue(vq);
  262. unmap:
  263. mic_card_unmap(mvdev->mdev, mvdev->vr[index]);
  264. return ERR_PTR(err);
  265. }
  266. static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs,
  267. struct virtqueue *vqs[],
  268. vq_callback_t *callbacks[],
  269. const char *names[])
  270. {
  271. struct mic_vdev *mvdev = to_micvdev(vdev);
  272. struct mic_device_ctrl __iomem *dc = mvdev->dc;
  273. int i, err, retry;
  274. /* We must have this many virtqueues. */
  275. if (nvqs > ioread8(&mvdev->desc->num_vq))
  276. return -ENOENT;
  277. for (i = 0; i < nvqs; ++i) {
  278. dev_dbg(mic_dev(mvdev), "%s: %d: %s\n",
  279. __func__, i, names[i]);
  280. vqs[i] = mic_find_vq(vdev, i, callbacks[i], names[i]);
  281. if (IS_ERR(vqs[i])) {
  282. err = PTR_ERR(vqs[i]);
  283. goto error;
  284. }
  285. }
  286. iowrite8(1, &dc->used_address_updated);
  287. /*
  288. * Send an interrupt to the host to inform it that used
  289. * rings have been re-assigned.
  290. */
  291. mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
  292. for (retry = 100; retry--;) {
  293. if (!ioread8(&dc->used_address_updated))
  294. break;
  295. msleep(100);
  296. };
  297. dev_dbg(mic_dev(mvdev), "%s: retry: %d\n", __func__, retry);
  298. if (!retry) {
  299. err = -ENODEV;
  300. goto error;
  301. }
  302. return 0;
  303. error:
  304. mic_del_vqs(vdev);
  305. return err;
  306. }
  307. /*
  308. * The config ops structure as defined by virtio config
  309. */
  310. static struct virtio_config_ops mic_vq_config_ops = {
  311. .get_features = mic_get_features,
  312. .finalize_features = mic_finalize_features,
  313. .get = mic_get,
  314. .set = mic_set,
  315. .get_status = mic_get_status,
  316. .set_status = mic_set_status,
  317. .reset = mic_reset,
  318. .find_vqs = mic_find_vqs,
  319. .del_vqs = mic_del_vqs,
  320. };
  321. static irqreturn_t
  322. mic_virtio_intr_handler(int irq, void *data)
  323. {
  324. struct mic_vdev *mvdev = data;
  325. struct virtqueue *vq;
  326. mic_ack_interrupt(mvdev->mdev);
  327. list_for_each_entry(vq, &mvdev->vdev.vqs, list)
  328. vring_interrupt(0, vq);
  329. return IRQ_HANDLED;
  330. }
  331. static void mic_virtio_release_dev(struct device *_d)
  332. {
  333. /*
  334. * No need for a release method similar to virtio PCI.
  335. * Provide an empty one to avoid getting a warning from core.
  336. */
  337. }
  338. /*
  339. * adds a new device and register it with virtio
  340. * appropriate drivers are loaded by the device model
  341. */
  342. static int mic_add_device(struct mic_device_desc __iomem *d,
  343. unsigned int offset, struct mic_driver *mdrv)
  344. {
  345. struct mic_vdev *mvdev;
  346. int ret;
  347. int virtio_db;
  348. u8 type = ioread8(&d->type);
  349. mvdev = kzalloc(sizeof(*mvdev), GFP_KERNEL);
  350. if (!mvdev) {
  351. dev_err(mdrv->dev, "Cannot allocate mic dev %u type %u\n",
  352. offset, type);
  353. return -ENOMEM;
  354. }
  355. mvdev->mdev = &mdrv->mdev;
  356. mvdev->vdev.dev.parent = mdrv->dev;
  357. mvdev->vdev.dev.release = mic_virtio_release_dev;
  358. mvdev->vdev.id.device = type;
  359. mvdev->vdev.config = &mic_vq_config_ops;
  360. mvdev->desc = d;
  361. mvdev->dc = (void __iomem *)d + mic_aligned_desc_size(d);
  362. init_completion(&mvdev->reset_done);
  363. virtio_db = mic_next_card_db();
  364. mvdev->virtio_cookie = mic_request_card_irq(mic_virtio_intr_handler,
  365. "virtio intr", mvdev, virtio_db);
  366. if (IS_ERR(mvdev->virtio_cookie)) {
  367. ret = PTR_ERR(mvdev->virtio_cookie);
  368. goto kfree;
  369. }
  370. iowrite8((u8)virtio_db, &mvdev->dc->h2c_vdev_db);
  371. mvdev->c2h_vdev_db = ioread8(&mvdev->dc->c2h_vdev_db);
  372. ret = register_virtio_device(&mvdev->vdev);
  373. if (ret) {
  374. dev_err(mic_dev(mvdev),
  375. "Failed to register mic device %u type %u\n",
  376. offset, type);
  377. goto free_irq;
  378. }
  379. iowrite64((u64)mvdev, &mvdev->dc->vdev);
  380. dev_dbg(mic_dev(mvdev), "%s: registered mic device %u type %u mvdev %p\n",
  381. __func__, offset, type, mvdev);
  382. return 0;
  383. free_irq:
  384. mic_free_card_irq(mvdev->virtio_cookie, mvdev);
  385. kfree:
  386. kfree(mvdev);
  387. return ret;
  388. }
  389. /*
  390. * match for a mic device with a specific desc pointer
  391. */
  392. static int mic_match_desc(struct device *dev, void *data)
  393. {
  394. struct virtio_device *vdev = dev_to_virtio(dev);
  395. struct mic_vdev *mvdev = to_micvdev(vdev);
  396. return mvdev->desc == (void __iomem *)data;
  397. }
  398. static void mic_handle_config_change(struct mic_device_desc __iomem *d,
  399. unsigned int offset, struct mic_driver *mdrv)
  400. {
  401. struct mic_device_ctrl __iomem *dc
  402. = (void __iomem *)d + mic_aligned_desc_size(d);
  403. struct mic_vdev *mvdev = (struct mic_vdev *)ioread64(&dc->vdev);
  404. struct virtio_driver *drv;
  405. if (ioread8(&dc->config_change) != MIC_VIRTIO_PARAM_CONFIG_CHANGED)
  406. return;
  407. dev_dbg(mdrv->dev, "%s %d\n", __func__, __LINE__);
  408. drv = container_of(mvdev->vdev.dev.driver,
  409. struct virtio_driver, driver);
  410. if (drv->config_changed)
  411. drv->config_changed(&mvdev->vdev);
  412. iowrite8(1, &dc->guest_ack);
  413. }
  414. /*
  415. * removes a virtio device if a hot remove event has been
  416. * requested by the host.
  417. */
  418. static int mic_remove_device(struct mic_device_desc __iomem *d,
  419. unsigned int offset, struct mic_driver *mdrv)
  420. {
  421. struct mic_device_ctrl __iomem *dc
  422. = (void __iomem *)d + mic_aligned_desc_size(d);
  423. struct mic_vdev *mvdev = (struct mic_vdev *)ioread64(&dc->vdev);
  424. u8 status;
  425. int ret = -1;
  426. if (ioread8(&dc->config_change) == MIC_VIRTIO_PARAM_DEV_REMOVE) {
  427. dev_dbg(mdrv->dev,
  428. "%s %d config_change %d type %d mvdev %p\n",
  429. __func__, __LINE__,
  430. ioread8(&dc->config_change), ioread8(&d->type), mvdev);
  431. status = ioread8(&d->status);
  432. reinit_completion(&mvdev->reset_done);
  433. unregister_virtio_device(&mvdev->vdev);
  434. mic_free_card_irq(mvdev->virtio_cookie, mvdev);
  435. if (status & VIRTIO_CONFIG_S_DRIVER_OK)
  436. wait_for_completion(&mvdev->reset_done);
  437. kfree(mvdev);
  438. iowrite8(1, &dc->guest_ack);
  439. dev_dbg(mdrv->dev, "%s %d guest_ack %d\n",
  440. __func__, __LINE__, ioread8(&dc->guest_ack));
  441. ret = 0;
  442. }
  443. return ret;
  444. }
  445. #define REMOVE_DEVICES true
  446. static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
  447. {
  448. s8 type;
  449. unsigned int i;
  450. struct mic_device_desc __iomem *d;
  451. struct mic_device_ctrl __iomem *dc;
  452. struct device *dev;
  453. int ret;
  454. for (i = sizeof(struct mic_bootparam); i < MIC_DP_SIZE;
  455. i += mic_total_desc_size(d)) {
  456. d = mdrv->dp + i;
  457. dc = (void __iomem *)d + mic_aligned_desc_size(d);
  458. /*
  459. * This read barrier is paired with the corresponding write
  460. * barrier on the host which is inserted before adding or
  461. * removing a virtio device descriptor, by updating the type.
  462. */
  463. rmb();
  464. type = ioread8(&d->type);
  465. /* end of list */
  466. if (type == 0)
  467. break;
  468. if (type == -1)
  469. continue;
  470. /* device already exists */
  471. dev = device_find_child(mdrv->dev, (void __force *)d,
  472. mic_match_desc);
  473. if (dev) {
  474. if (remove)
  475. iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
  476. &dc->config_change);
  477. put_device(dev);
  478. mic_handle_config_change(d, i, mdrv);
  479. ret = mic_remove_device(d, i, mdrv);
  480. if (!ret && !remove)
  481. iowrite8(-1, &d->type);
  482. if (remove) {
  483. iowrite8(0, &dc->config_change);
  484. iowrite8(0, &dc->guest_ack);
  485. }
  486. continue;
  487. }
  488. /* new device */
  489. dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n",
  490. __func__, __LINE__, d);
  491. if (!remove)
  492. mic_add_device(d, i, mdrv);
  493. }
  494. }
  495. /*
  496. * mic_hotplug_device tries to find changes in the device page.
  497. */
  498. static void mic_hotplug_devices(struct work_struct *work)
  499. {
  500. struct mic_driver *mdrv = container_of(work,
  501. struct mic_driver, hotplug_work);
  502. mic_scan_devices(mdrv, !REMOVE_DEVICES);
  503. }
  504. /*
  505. * Interrupt handler for hot plug/config changes etc.
  506. */
  507. static irqreturn_t
  508. mic_extint_handler(int irq, void *data)
  509. {
  510. struct mic_driver *mdrv = (struct mic_driver *)data;
  511. dev_dbg(mdrv->dev, "%s %d hotplug work\n",
  512. __func__, __LINE__);
  513. mic_ack_interrupt(&mdrv->mdev);
  514. schedule_work(&mdrv->hotplug_work);
  515. return IRQ_HANDLED;
  516. }
  517. /*
  518. * Init function for virtio
  519. */
  520. int mic_devices_init(struct mic_driver *mdrv)
  521. {
  522. int rc;
  523. struct mic_bootparam __iomem *bootparam;
  524. int config_db;
  525. INIT_WORK(&mdrv->hotplug_work, mic_hotplug_devices);
  526. mic_scan_devices(mdrv, !REMOVE_DEVICES);
  527. config_db = mic_next_card_db();
  528. virtio_config_cookie = mic_request_card_irq(mic_extint_handler,
  529. "virtio_config_intr", mdrv, config_db);
  530. if (IS_ERR(virtio_config_cookie)) {
  531. rc = PTR_ERR(virtio_config_cookie);
  532. goto exit;
  533. }
  534. bootparam = mdrv->dp;
  535. iowrite8(config_db, &bootparam->h2c_config_db);
  536. return 0;
  537. exit:
  538. return rc;
  539. }
  540. /*
  541. * Uninit function for virtio
  542. */
  543. void mic_devices_uninit(struct mic_driver *mdrv)
  544. {
  545. struct mic_bootparam __iomem *bootparam = mdrv->dp;
  546. iowrite8(-1, &bootparam->h2c_config_db);
  547. mic_free_card_irq(virtio_config_cookie, mdrv);
  548. flush_work(&mdrv->hotplug_work);
  549. mic_scan_devices(mdrv, REMOVE_DEVICES);
  550. }