History

vfio-ccw: Wire in the request callback

The device is being unplugged, so pass the request to userspace to ask for a graceful cleanup. This should free up the thread that would otherwise loop waiting for the device to be fully released.

Eric Farman committed 5 years ago

Commit bccce801 parent a15ac663 files · +31 −0Browse files

Unified · Split

3 files
  1. drivers/s390/cio/vfio_ccw_ops.c +26 −0
  2. drivers/s390/cio/vfio_ccw_private.h +4 −0
  3. include/uapi/linux/vfio.h +1 −0
drivers/s390/cio/vfio_ccw_ops.c+26−0
@@ -394,6 +394,7 @@ static int vfio_ccw_mdev_get_irq_info(struct vfio_irq_info *info) · 393 unmodified lines
394 switch (info->index) {394 switch (info->index) {
395 case VFIO_CCW_IO_IRQ_INDEX:395 case VFIO_CCW_IO_IRQ_INDEX:
396 case VFIO_CCW_CRW_IRQ_INDEX:396 case VFIO_CCW_CRW_IRQ_INDEX:
397 case VFIO_CCW_REQ_IRQ_INDEX:
397 info->count = 1;398 info->count = 1;
398 info->flags = VFIO_IRQ_INFO_EVENTFD;399 info->flags = VFIO_IRQ_INFO_EVENTFD;
399 break;400 break;
@@ -424,6 +425,9 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev, · 24 unmodified lines
424 case VFIO_CCW_CRW_IRQ_INDEX:425 case VFIO_CCW_CRW_IRQ_INDEX:
425 ctx = &private->crw_trigger;426 ctx = &private->crw_trigger;
426 break;427 break;
428 case VFIO_CCW_REQ_IRQ_INDEX:
429 ctx = &private->req_trigger;
430 break;
427 default:431 default:
428 return -EINVAL;432 return -EINVAL;
429 }433 }
@@ -607,6 +611,27 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, · 177 unmodified lines
607 }611 }
608}612}
609 613
614/* Request removal of the device*/
615static void vfio_ccw_mdev_request(struct mdev_device *mdev, unsigned int count)
616{
617 struct vfio_ccw_private *private = dev_get_drvdata(mdev_parent_dev(mdev));
618
619 if (!private)
620 return;
621
622 if (private->req_trigger) {
623 if (!(count % 10))
624 dev_notice_ratelimited(mdev_dev(private->mdev),
625 "Relaying device request to user (#%u)\n",
626 count);
627
628 eventfd_signal(private->req_trigger, 1);
629 } else if (count == 0) {
630 dev_notice(mdev_dev(private->mdev),
631 "No device request channel registered, blocked until released by user\n");
632 }
633}
634
610static const struct mdev_parent_ops vfio_ccw_mdev_ops = {635static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
611 .owner = THIS_MODULE,636 .owner = THIS_MODULE,
612 .supported_type_groups = mdev_type_groups,637 .supported_type_groups = mdev_type_groups,
@@ -617,6 +642,7 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { · 4 unmodified lines
617 .read = vfio_ccw_mdev_read,642 .read = vfio_ccw_mdev_read,
618 .write = vfio_ccw_mdev_write,643 .write = vfio_ccw_mdev_write,
619 .ioctl = vfio_ccw_mdev_ioctl,644 .ioctl = vfio_ccw_mdev_ioctl,
645 .request = vfio_ccw_mdev_request,
620};646};
621 647
622int vfio_ccw_mdev_reg(struct subchannel *sch)648int vfio_ccw_mdev_reg(struct subchannel *sch)
drivers/s390/cio/vfio_ccw_private.h+4−0
@@ -84,7 +84,10 @@ struct vfio_ccw_crw { · 83 unmodified lines
84 * @irb: irb info received from interrupt84 * @irb: irb info received from interrupt
85 * @scsw: scsw info85 * @scsw: scsw info
86 * @io_trigger: eventfd ctx for signaling userspace I/O results86 * @io_trigger: eventfd ctx for signaling userspace I/O results
87 * @crw_trigger: eventfd ctx for signaling userspace CRW information
88 * @req_trigger: eventfd ctx for signaling userspace to return device
87 * @io_work: work for deferral process of I/O handling89 * @io_work: work for deferral process of I/O handling
90 * @crw_work: work for deferral process of CRW handling
88 */91 */
89struct vfio_ccw_private {92struct vfio_ccw_private {
90 struct subchannel *sch;93 struct subchannel *sch;
@@ -108,6 +111,7 @@ struct vfio_ccw_private { · 17 unmodified lines
108 111
109 struct eventfd_ctx *io_trigger;112 struct eventfd_ctx *io_trigger;
110 struct eventfd_ctx *crw_trigger;113 struct eventfd_ctx *crw_trigger;
114 struct eventfd_ctx *req_trigger;
111 struct work_struct io_work;115 struct work_struct io_work;
112 struct work_struct crw_work;116 struct work_struct crw_work;
113} __aligned(8);117} __aligned(8);
include/uapi/linux/vfio.h+1−0
@@ -820,6 +820,7 @@ enum { · 819 unmodified lines
820enum {820enum {
821 VFIO_CCW_IO_IRQ_INDEX,821 VFIO_CCW_IO_IRQ_INDEX,
822 VFIO_CCW_CRW_IRQ_INDEX,822 VFIO_CCW_CRW_IRQ_INDEX,
823 VFIO_CCW_REQ_IRQ_INDEX,
823 VFIO_CCW_NUM_IRQS824 VFIO_CCW_NUM_IRQS
824};825};
825 826

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t