Fix some undesirable behavior with the vfio device request interface:

- Increase verbosity of device request channel (Alex Williamson)
 
 - Fix runaway interruptible timeout (Alex Williamson)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVSliWAAoJECObm247sIsigC8P/1sWM0oDBqiDUILsXmTnUOcM
 I/jRX3Pao9kZmTr5g3GUPxLP/EVwMg/lWqwSu6O8X1IdgefYCXuikPSdlAY3h2g3
 AB67hv8E8F5TZlQrw9yjWl3b/ywPy+PAFrAfOreoyn7lgompWXbqmQsnLpNRCLW5
 79EPx6b0Y6xg2Gu0dROIokB0VqvfQ7k0CnJD/V6Jupk/F9VO/tuEu5ExDSKKDkCK
 Dn6iyMax496nW2R+d1unkgq5VqLWiOWguM8bbndptxc86joE/2XeiaKadqCY3HE/
 AkNvKcdz/QCBpsHIkx+JkXBBx7KRgf2NC65k2nBgCtY1D3uAsZyI91fXL42O8JYD
 +kDd4Sho63bWqH8+5F4Dz/QYMcuM042Hxv6tGto8tyUUxe5qfaGykIL77MPe/kEq
 Qi7vPaVs/MATvdPcGZrk/SWwdHqAhKriti0sK8gTZAM76+1xVK9vdg/ZImkJ6FcN
 QvkLQLCkpiNylmHU4DdReQFiXPaOEBeYRq/FHvUbdKE0l95i0YW5vNCgs/hVd/qa
 8on5TnytKXLUL/P8q1fxSmBp9nUC61ycqH6OWcNYV1uuliExPqECjIsvtavpelUR
 Uilmm7e1I5j1Oyz2OlVDnLTvszUbLkusgbiV4fL3+Y1hWSmk/NCk/9+3k45wHRYn
 F81cYKgfzrYM5M//9CUI
 =nCDk
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2015-05-07 08:18:01 -07:00
commit 7bbcd1b86d
2 changed files with 25 additions and 4 deletions

View File

@ -907,8 +907,14 @@ static void vfio_pci_request(void *device_data, unsigned int count)
mutex_lock(&vdev->igate);
if (vdev->req_trigger) {
dev_dbg(&vdev->pdev->dev, "Requesting device from user\n");
if (!(count % 10))
dev_notice_ratelimited(&vdev->pdev->dev,
"Relaying device request to user (#%u)\n",
count);
eventfd_signal(vdev->req_trigger, 1);
} else if (count == 0) {
dev_warn(&vdev->pdev->dev,
"No device request channel registered, blocked until released by user\n");
}
mutex_unlock(&vdev->igate);

View File

@ -710,6 +710,8 @@ void *vfio_del_group_dev(struct device *dev)
void *device_data = device->device_data;
struct vfio_unbound_dev *unbound;
unsigned int i = 0;
long ret;
bool interrupted = false;
/*
* The group exists so long as we have a device reference. Get
@ -755,9 +757,22 @@ void *vfio_del_group_dev(struct device *dev)
vfio_device_put(device);
} while (wait_event_interruptible_timeout(vfio.release_q,
!vfio_dev_present(group, dev),
HZ * 10) <= 0);
if (interrupted) {
ret = wait_event_timeout(vfio.release_q,
!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);