Commit db7d4d7f authored by Alex Williamson's avatar Alex Williamson

vfio: Fix runaway interruptible timeout

Commit 13060b64 ("vfio: Add and use device request op for vfio
bus drivers") incorrectly makes use of an interruptible timeout.
When interrupted, the signal remains pending resulting in subsequent
timeouts occurring instantly.  This makes the loop spin at a much
higher rate than intended.

Instead of making this completely non-interruptible, we can change
this into a sort of interruptible-once behavior and use the "once"
to log debug information.  The driver API doesn't allow us to abort
and return an error code.
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Fixes: 13060b64
Cc: stable@vger.kernel.org # v4.0
parent 5f55d2ae
...@@ -710,6 +710,8 @@ void *vfio_del_group_dev(struct device *dev) ...@@ -710,6 +710,8 @@ void *vfio_del_group_dev(struct device *dev)
void *device_data = device->device_data; void *device_data = device->device_data;
struct vfio_unbound_dev *unbound; struct vfio_unbound_dev *unbound;
unsigned int i = 0; unsigned int i = 0;
long ret;
bool interrupted = false;
/* /*
* The group exists so long as we have a device reference. Get * The group exists so long as we have a device reference. Get
...@@ -755,9 +757,22 @@ void *vfio_del_group_dev(struct device *dev) ...@@ -755,9 +757,22 @@ void *vfio_del_group_dev(struct device *dev)
vfio_device_put(device); vfio_device_put(device);
} while (wait_event_interruptible_timeout(vfio.release_q, if (interrupted) {
!vfio_dev_present(group, dev), ret = wait_event_timeout(vfio.release_q,
HZ * 10) <= 0); !vfio_dev_present(group, dev), HZ * 10);
} else {
ret = wait_event_interruptible_timeout(vfio.release_q,
!vfio_dev_present(group, dev), HZ * 10);
if (ret == -ERESTARTSYS) {
interrupted = true;
dev_warn(dev,
"Device is currently in use, task"
" \"%s\" (%d) "
"blocked until device is released",
current->comm, task_pid_nr(current));
}
}
} while (ret <= 0);
vfio_group_put(group); vfio_group_put(group);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment