mic_virtio.c 16 KB

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