Skip to content

Commit 7bbcd1b

Browse files
committed
Merge tag 'vfio-v4.1-rc3' of git://github.com/awilliam/linux-vfio
Pull vfio fixes from Alex Williamson: "Fix some undesirable behavior with the vfio device request interface: - increase verbosity of device request channel (Alex Williamson) - fix runaway interruptible timeout (Alex Williamson)" * tag 'vfio-v4.1-rc3' of git://github.com/awilliam/linux-vfio: vfio: Fix runaway interruptible timeout vfio-pci: Log device requests more verbosely
2 parents 8cb7c15 + db7d4d7 commit 7bbcd1b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,14 @@ static void vfio_pci_request(void *device_data, unsigned int count)
907907
mutex_lock(&vdev->igate);
908908

909909
if (vdev->req_trigger) {
910-
dev_dbg(&vdev->pdev->dev, "Requesting device from user\n");
910+
if (!(count % 10))
911+
dev_notice_ratelimited(&vdev->pdev->dev,
912+
"Relaying device request to user (#%u)\n",
913+
count);
911914
eventfd_signal(vdev->req_trigger, 1);
915+
} else if (count == 0) {
916+
dev_warn(&vdev->pdev->dev,
917+
"No device request channel registered, blocked until released by user\n");
912918
}
913919

914920
mutex_unlock(&vdev->igate);

drivers/vfio/vfio.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,8 @@ void *vfio_del_group_dev(struct device *dev)
710710
void *device_data = device->device_data;
711711
struct vfio_unbound_dev *unbound;
712712
unsigned int i = 0;
713+
long ret;
714+
bool interrupted = false;
713715

714716
/*
715717
* The group exists so long as we have a device reference. Get
@@ -755,9 +757,22 @@ void *vfio_del_group_dev(struct device *dev)
755757

756758
vfio_device_put(device);
757759

758-
} while (wait_event_interruptible_timeout(vfio.release_q,
759-
!vfio_dev_present(group, dev),
760-
HZ * 10) <= 0);
760+
if (interrupted) {
761+
ret = wait_event_timeout(vfio.release_q,
762+
!vfio_dev_present(group, dev), HZ * 10);
763+
} else {
764+
ret = wait_event_interruptible_timeout(vfio.release_q,
765+
!vfio_dev_present(group, dev), HZ * 10);
766+
if (ret == -ERESTARTSYS) {
767+
interrupted = true;
768+
dev_warn(dev,
769+
"Device is currently in use, task"
770+
" \"%s\" (%d) "
771+
"blocked until device is released",
772+
current->comm, task_pid_nr(current));
773+
}
774+
}
775+
} while (ret <= 0);
761776

762777
vfio_group_put(group);
763778

0 commit comments

Comments
 (0)