mic_virtio.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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_device.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 = 100, i;
  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 (i = retry; i--;) {
  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 void mic_notify(struct virtqueue *vq)
  165. {
  166. struct mic_vdev *mvdev = vq->priv;
  167. mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
  168. }
  169. static void mic_del_vq(struct virtqueue *vq, int n)
  170. {
  171. struct mic_vdev *mvdev = to_micvdev(vq->vdev);
  172. struct vring *vr = (struct vring *) (vq + 1);
  173. free_pages((unsigned long) vr->used,
  174. 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(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, 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,
  223. config.num, MIC_VIRTIO_RING_ALIGN, vdev,
  224. false,
  225. va, mic_notify, callback, 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) * config.num);
  239. used = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
  240. get_order(mvdev->used_size[index]));
  241. if (!used) {
  242. err = -ENOMEM;
  243. dev_err(mic_dev(mvdev), "%s %d err %d\n",
  244. __func__, __LINE__, err);
  245. goto del_vq;
  246. }
  247. iowrite64(virt_to_phys(used), &vqconfig->used_address);
  248. /*
  249. * To reassign the used ring here we are directly accessing
  250. * struct vring_virtqueue which is a private data structure
  251. * in virtio_ring.c. At the minimum, a BUILD_BUG_ON() in
  252. * vring_new_virtqueue() would ensure that
  253. * (&vq->vring == (struct vring *) (&vq->vq + 1));
  254. */
  255. vr = (struct vring *) (vq + 1);
  256. vr->used = used;
  257. vq->priv = mvdev;
  258. return vq;
  259. del_vq:
  260. vring_del_virtqueue(vq);
  261. unmap:
  262. mic_card_unmap(mvdev->mdev, mvdev->vr[index]);
  263. return ERR_PTR(err);
  264. }
  265. static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs,
  266. struct virtqueue *vqs[],
  267. vq_callback_t *callbacks[],
  268. const char *names[])
  269. {
  270. struct mic_vdev *mvdev = to_micvdev(vdev);
  271. struct mic_device_ctrl __iomem *dc = mvdev->dc;
  272. int i, err, retry = 100;
  273. /* We must have this many virtqueues. */
  274. if (nvqs > ioread8(&mvdev->desc->num_vq))
  275. return -ENOENT;
  276. for (i = 0; i < nvqs; ++i) {
  277. dev_dbg(mic_dev(mvdev), "%s: %d: %s\n",
  278. __func__, i, names[i]);
  279. vqs[i] = mic_find_vq(vdev, i, callbacks[i], names[i]);
  280. if (IS_ERR(vqs[i])) {
  281. err = PTR_ERR(vqs[i]);
  282. goto error;
  283. }
  284. }
  285. iowrite8(1, &dc->used_address_updated);
  286. /*
  287. * Send an interrupt to the host to inform it that used
  288. * rings have been re-assigned.
  289. */
  290. mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
  291. for (i = retry; i--;) {
  292. if (!ioread8(&dc->used_address_updated))
  293. break;
  294. msleep(100);
  295. };
  296. dev_dbg(mic_dev(mvdev), "%s: retry: %d\n", __func__, retry);
  297. if (!retry) {
  298. err = -ENODEV;
  299. goto error;
  300. }
  301. return 0;
  302. error:
  303. mic_del_vqs(vdev);
  304. return err;
  305. }
  306. /*
  307. * The config ops structure as defined by virtio config
  308. */
  309. static struct virtio_config_ops mic_vq_config_ops = {
  310. .get_features = mic_get_features,
  311. .finalize_features = mic_finalize_features,
  312. .get = mic_get,
  313. .set = mic_set,
  314. .get_status = mic_get_status,
  315. .set_status = mic_set_status,
  316. .reset = mic_reset,
  317. .find_vqs = mic_find_vqs,
  318. .del_vqs = mic_del_vqs,
  319. };
  320. static irqreturn_t
  321. mic_virtio_intr_handler(int irq, void *data)
  322. {
  323. struct mic_vdev *mvdev = data;
  324. struct virtqueue *vq;
  325. mic_ack_interrupt(mvdev->mdev);
  326. list_for_each_entry(vq, &mvdev->vdev.vqs, list)
  327. vring_interrupt(0, vq);
  328. return IRQ_HANDLED;
  329. }
  330. static void mic_virtio_release_dev(struct device *_d)
  331. {
  332. /*
  333. * No need for a release method similar to virtio PCI.
  334. * Provide an empty one to avoid getting a warning from core.
  335. */
  336. }
  337. /*
  338. * adds a new device and register it with virtio
  339. * appropriate drivers are loaded by the device model
  340. */
  341. static int mic_add_device(struct mic_device_desc __iomem *d,
  342. unsigned int offset, struct mic_driver *mdrv)
  343. {
  344. struct mic_vdev *mvdev;
  345. int ret;
  346. int virtio_db;
  347. u8 type = ioread8(&d->type);
  348. mvdev = kzalloc(sizeof(*mvdev), GFP_KERNEL);
  349. if (!mvdev) {
  350. dev_err(mdrv->dev, "Cannot allocate mic dev %u type %u\n",
  351. offset, type);
  352. return -ENOMEM;
  353. }
  354. mvdev->mdev = &mdrv->mdev;
  355. mvdev->vdev.dev.parent = mdrv->dev;
  356. mvdev->vdev.dev.release = mic_virtio_release_dev;
  357. mvdev->vdev.id.device = type;
  358. mvdev->vdev.config = &mic_vq_config_ops;
  359. mvdev->desc = d;
  360. mvdev->dc = (void __iomem *)d + mic_aligned_desc_size(d);
  361. init_completion(&mvdev->reset_done);
  362. virtio_db = mic_next_card_db();
  363. mvdev->virtio_cookie = mic_request_card_irq(mic_virtio_intr_handler,
  364. "virtio intr", mvdev, virtio_db);
  365. if (IS_ERR(mvdev->virtio_cookie)) {
  366. ret = PTR_ERR(mvdev->virtio_cookie);
  367. goto kfree;
  368. }
  369. iowrite8((u8)virtio_db, &mvdev->dc->h2c_vdev_db);
  370. mvdev->c2h_vdev_db = ioread8(&mvdev->dc->c2h_vdev_db);
  371. ret = register_virtio_device(&mvdev->vdev);
  372. if (ret) {
  373. dev_err(mic_dev(mvdev),
  374. "Failed to register mic device %u type %u\n",
  375. offset, type);
  376. goto free_irq;
  377. }
  378. iowrite64((u64)mvdev, &mvdev->dc->vdev);
  379. dev_dbg(mic_dev(mvdev), "%s: registered mic device %u type %u mvdev %p\n",
  380. __func__, offset, type, mvdev);
  381. return 0;
  382. free_irq:
  383. mic_free_card_irq(mvdev->virtio_cookie, mvdev);
  384. kfree:
  385. kfree(mvdev);
  386. return ret;
  387. }
  388. /*
  389. * match for a mic device with a specific desc pointer
  390. */
  391. static int mic_match_desc(struct device *dev, void *data)
  392. {
  393. struct virtio_device *vdev = dev_to_virtio(dev);
  394. struct mic_vdev *mvdev = to_micvdev(vdev);
  395. return mvdev->desc == (void __iomem *)data;
  396. }
  397. static void mic_handle_config_change(struct mic_device_desc __iomem *d,
  398. unsigned int offset, struct mic_driver *mdrv)
  399. {
  400. struct mic_device_ctrl __iomem *dc
  401. = (void __iomem *)d + mic_aligned_desc_size(d);
  402. struct mic_vdev *mvdev = (struct mic_vdev *)ioread64(&dc->vdev);
  403. struct virtio_driver *drv;
  404. if (ioread8(&dc->config_change) != MIC_VIRTIO_PARAM_CONFIG_CHANGED)
  405. return;
  406. dev_dbg(mdrv->dev, "%s %d\n", __func__, __LINE__);
  407. drv = container_of(mvdev->vdev.dev.driver,
  408. struct virtio_driver, driver);
  409. if (drv->config_changed)
  410. drv->config_changed(&mvdev->vdev);
  411. iowrite8(1, &dc->guest_ack);
  412. }
  413. /*
  414. * removes a virtio device if a hot remove event has been
  415. * requested by the host.
  416. */
  417. static int mic_remove_device(struct mic_device_desc __iomem *d,
  418. unsigned int offset, struct mic_driver *mdrv)
  419. {
  420. struct mic_device_ctrl __iomem *dc
  421. = (void __iomem *)d + mic_aligned_desc_size(d);
  422. struct mic_vdev *mvdev = (struct mic_vdev *)ioread64(&dc->vdev);
  423. u8 status;
  424. int ret = -1;
  425. if (ioread8(&dc->config_change) == MIC_VIRTIO_PARAM_DEV_REMOVE) {
  426. dev_dbg(mdrv->dev,
  427. "%s %d config_change %d type %d mvdev %p\n",
  428. __func__, __LINE__,
  429. ioread8(&dc->config_change), ioread8(&d->type), mvdev);
  430. status = ioread8(&d->status);
  431. INIT_COMPLETION(mvdev->reset_done);
  432. unregister_virtio_device(&mvdev->vdev);
  433. mic_free_card_irq(mvdev->virtio_cookie, mvdev);
  434. if (status & VIRTIO_CONFIG_S_DRIVER_OK)
  435. wait_for_completion(&mvdev->reset_done);
  436. kfree(mvdev);
  437. iowrite8(1, &dc->guest_ack);
  438. dev_dbg(mdrv->dev, "%s %d guest_ack %d\n",
  439. __func__, __LINE__, ioread8(&dc->guest_ack));
  440. ret = 0;
  441. }
  442. return ret;
  443. }
  444. #define REMOVE_DEVICES true
  445. static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
  446. {
  447. s8 type;
  448. unsigned int i;
  449. struct mic_device_desc __iomem *d;
  450. struct mic_device_ctrl __iomem *dc;
  451. struct device *dev;
  452. int ret;
  453. for (i = mic_aligned_size(struct mic_bootparam);
  454. i < MIC_DP_SIZE; i += mic_total_desc_size(d)) {
  455. d = mdrv->dp + i;
  456. dc = (void __iomem *)d + mic_aligned_desc_size(d);
  457. /*
  458. * This read barrier is paired with the corresponding write
  459. * barrier on the host which is inserted before adding or
  460. * removing a virtio device descriptor, by updating the type.
  461. */
  462. rmb();
  463. type = ioread8(&d->type);
  464. /* end of list */
  465. if (type == 0)
  466. break;
  467. if (type == -1)
  468. continue;
  469. /* device already exists */
  470. dev = device_find_child(mdrv->dev, d, mic_match_desc);
  471. if (dev) {
  472. if (remove)
  473. iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
  474. &dc->config_change);
  475. put_device(dev);
  476. mic_handle_config_change(d, i, mdrv);
  477. ret = mic_remove_device(d, i, mdrv);
  478. if (!ret && !remove)
  479. iowrite8(-1, &d->type);
  480. if (remove) {
  481. iowrite8(0, &dc->config_change);
  482. iowrite8(0, &dc->guest_ack);
  483. }
  484. continue;
  485. }
  486. /* new device */
  487. dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n",
  488. __func__, __LINE__, d);
  489. if (!remove)
  490. mic_add_device(d, i, mdrv);
  491. }
  492. }
  493. /*
  494. * mic_hotplug_device tries to find changes in the device page.
  495. */
  496. static void mic_hotplug_devices(struct work_struct *work)
  497. {
  498. struct mic_driver *mdrv = container_of(work,
  499. struct mic_driver, hotplug_work);
  500. mic_scan_devices(mdrv, !REMOVE_DEVICES);
  501. }
  502. /*
  503. * Interrupt handler for hot plug/config changes etc.
  504. */
  505. static irqreturn_t
  506. mic_extint_handler(int irq, void *data)
  507. {
  508. struct mic_driver *mdrv = (struct mic_driver *)data;
  509. dev_dbg(mdrv->dev, "%s %d hotplug work\n",
  510. __func__, __LINE__);
  511. mic_ack_interrupt(&mdrv->mdev);
  512. schedule_work(&mdrv->hotplug_work);
  513. return IRQ_HANDLED;
  514. }
  515. /*
  516. * Init function for virtio
  517. */
  518. int mic_devices_init(struct mic_driver *mdrv)
  519. {
  520. int rc;
  521. struct mic_bootparam __iomem *bootparam;
  522. int config_db;
  523. INIT_WORK(&mdrv->hotplug_work, mic_hotplug_devices);
  524. mic_scan_devices(mdrv, !REMOVE_DEVICES);
  525. config_db = mic_next_card_db();
  526. virtio_config_cookie = mic_request_card_irq(mic_extint_handler,
  527. "virtio_config_intr", mdrv, config_db);
  528. if (IS_ERR(virtio_config_cookie)) {
  529. rc = PTR_ERR(virtio_config_cookie);
  530. goto exit;
  531. }
  532. bootparam = mdrv->dp;
  533. iowrite8(config_db, &bootparam->h2c_config_db);
  534. return 0;
  535. exit:
  536. return rc;
  537. }
  538. /*
  539. * Uninit function for virtio
  540. */
  541. void mic_devices_uninit(struct mic_driver *mdrv)
  542. {
  543. struct mic_bootparam __iomem *bootparam = mdrv->dp;
  544. iowrite8(-1, &bootparam->h2c_config_db);
  545. mic_free_card_irq(virtio_config_cookie, mdrv);
  546. flush_work(&mdrv->hotplug_work);
  547. mic_scan_devices(mdrv, REMOVE_DEVICES);
  548. }