diff options
| -rw-r--r-- | drivers/vfio/vfio.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index c488da5db7c7..6d18c3cafdd4 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c | |||
| @@ -494,27 +494,6 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev) | |||
| 494 | return 0; | 494 | return 0; |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | static int vfio_group_nb_del_dev(struct vfio_group *group, struct device *dev) | ||
| 498 | { | ||
| 499 | struct vfio_device *device; | ||
| 500 | |||
| 501 | /* | ||
| 502 | * Expect to fall out here. If a device was in use, it would | ||
| 503 | * have been bound to a vfio sub-driver, which would have blocked | ||
| 504 | * in .remove at vfio_del_group_dev. Sanity check that we no | ||
| 505 | * longer track the device, so it's safe to remove. | ||
| 506 | */ | ||
| 507 | device = vfio_group_get_device(group, dev); | ||
| 508 | if (likely(!device)) | ||
| 509 | return 0; | ||
| 510 | |||
| 511 | WARN("Device %s removed from live group %d!\n", dev_name(dev), | ||
| 512 | iommu_group_id(group->iommu_group)); | ||
| 513 | |||
| 514 | vfio_device_put(device); | ||
| 515 | return 0; | ||
| 516 | } | ||
| 517 | |||
| 518 | static int vfio_group_nb_verify(struct vfio_group *group, struct device *dev) | 497 | static int vfio_group_nb_verify(struct vfio_group *group, struct device *dev) |
| 519 | { | 498 | { |
| 520 | /* We don't care what happens when the group isn't in use */ | 499 | /* We don't care what happens when the group isn't in use */ |
| @@ -545,7 +524,13 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, | |||
| 545 | vfio_group_nb_add_dev(group, dev); | 524 | vfio_group_nb_add_dev(group, dev); |
| 546 | break; | 525 | break; |
| 547 | case IOMMU_GROUP_NOTIFY_DEL_DEVICE: | 526 | case IOMMU_GROUP_NOTIFY_DEL_DEVICE: |
| 548 | vfio_group_nb_del_dev(group, dev); | 527 | /* |
| 528 | * Nothing to do here. If the device is in use, then the | ||
| 529 | * vfio sub-driver should block the remove callback until | ||
| 530 | * it is unused. If the device is unused or attached to a | ||
| 531 | * stub driver, then it should be released and we don't | ||
| 532 | * care that it will be going away. | ||
| 533 | */ | ||
| 549 | break; | 534 | break; |
| 550 | case IOMMU_GROUP_NOTIFY_BIND_DRIVER: | 535 | case IOMMU_GROUP_NOTIFY_BIND_DRIVER: |
| 551 | pr_debug("%s: Device %s, group %d binding to driver\n", | 536 | pr_debug("%s: Device %s, group %d binding to driver\n", |
