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
394394 switch (info->index) {
395395 case VFIO_CCW_IO_IRQ_INDEX:
396396 case VFIO_CCW_CRW_IRQ_INDEX:
397+ case VFIO_CCW_REQ_IRQ_INDEX:
397398 info->count = 1;
398399 info->flags = VFIO_IRQ_INFO_EVENTFD;
399400 break;
@@ -424,6 +425,9 @@ static int vfio_ccw_mdev_set_irqs(struct mdev_device *mdev, · 24 unmodified lines
424425 case VFIO_CCW_CRW_IRQ_INDEX:
425426 ctx = &private->crw_trigger;
426427 break;
428+ case VFIO_CCW_REQ_IRQ_INDEX:
429+ ctx = &private->req_trigger;
430+ break;
427431 default:
428432 return -EINVAL;
429433 }
@@ -607,6 +611,27 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, · 177 unmodified lines
607611 }
608612 }
609613
614+/* Request removal of the device*/
615+static 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+
610635 static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
611636 .owner = THIS_MODULE,
612637 .supported_type_groups = mdev_type_groups,
@@ -617,6 +642,7 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { · 4 unmodified lines
617642 .read = vfio_ccw_mdev_read,
618643 .write = vfio_ccw_mdev_write,
619644 .ioctl = vfio_ccw_mdev_ioctl,
645+ .request = vfio_ccw_mdev_request,
620646 };
621647
622648 int 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
8484 * @irb: irb info received from interrupt
8585 * @scsw: scsw info
8686 * @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
8789 * @io_work: work for deferral process of I/O handling
90+ * @crw_work: work for deferral process of CRW handling
8891 */
8992 struct vfio_ccw_private {
9093 struct subchannel *sch;
@@ -108,6 +111,7 @@ struct vfio_ccw_private { · 17 unmodified lines
108111
109112 struct eventfd_ctx *io_trigger;
110113 struct eventfd_ctx *crw_trigger;
114+ struct eventfd_ctx *req_trigger;
111115 struct work_struct io_work;
112116 struct work_struct crw_work;
113117 } __aligned(8);
include/uapi/linux/vfio.h+1−0
@@ -820,6 +820,7 @@ enum { · 819 unmodified lines
820820 enum {
821821 VFIO_CCW_IO_IRQ_INDEX,
822822 VFIO_CCW_CRW_IRQ_INDEX,
823+ VFIO_CCW_REQ_IRQ_INDEX,
823824 VFIO_CCW_NUM_IRQS
824825 };
825826

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