[PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd

Grzegorz Jaszczyk posted 1 patch 1 year ago
Failed in applying to current master (apply log)
There is a newer version of this series
drivers/vfio/pci/vfio_pci_core.c | 215 +++++++++++++++++++++++++++++++
include/linux/vfio_pci_core.h    |  11 ++
include/uapi/linux/vfio.h        |  15 +++
3 files changed, 241 insertions(+)
[PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
Posted by Grzegorz Jaszczyk 1 year ago
To allow pass-through devices receiving ACPI notifications, permit to
register ACPI notify handler (via introduced new ioctl) for a given
device. The handler role is to receive and propagate such ACPI
notifications to the user-space through the user provided eventfd. This
allows VMM to receive and propagate them further to the VM, where the
actual driver for pass-through device resides and can react to device
specific notifications accordingly.

The eventfd usage ensures VMM and device isolation: it allows to use a
dedicated channel associated with the device for such events, such that
the VMM has direct access.

Since the eventfd counter is used as ACPI notification value
placeholder, the eventfd signaling needs to be serialized in order to
not end up with notification values being coalesced. Therefore ACPI
notification values are buffered and signalized one by one, when the
previous notification value has been consumed.

Signed-off-by: Grzegorz Jaszczyk <jaz@semihalf.com>
---
Changelog v1..v2:
- The v2 implementation is actually completely different then v1:
  instead of using acpi netlink events for propagating ACPI
  notifications to the user space take advantage of eventfd, which can
  provide better VMM and device isolation: it allows to use a dedicated
  channel associated with the device for such events, such that the VMM
  has direct access.
- Using eventfd counter as notification value placeholder was suggested
  in v1 and requires additional serialization logic introduced in v2.
- Since the vfio-pci supports non-ACPI platforms address !CONFIG_ACPI
  case.
- v1 discussion: https://patchwork.kernel.org/project/kvm/patch/20230307220553.631069-1-jaz@semihalf.com/
---
 drivers/vfio/pci/vfio_pci_core.c | 215 +++++++++++++++++++++++++++++++
 include/linux/vfio_pci_core.h    |  11 ++
 include/uapi/linux/vfio.h        |  15 +++
 3 files changed, 241 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index a5ab416cf476..ba8c49217875 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -10,6 +10,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/acpi.h>
 #include <linux/aperture.h>
 #include <linux/device.h>
 #include <linux/eventfd.h>
@@ -679,6 +680,70 @@ void vfio_pci_core_disable(struct vfio_pci_core_device *vdev)
 }
 EXPORT_SYMBOL_GPL(vfio_pci_core_disable);
 
+struct notification_queue {
+	int notification_val;
+	struct list_head notify_val_next;
+};
+
+#if IS_ENABLED(CONFIG_ACPI)
+static void vfio_pci_core_acpi_notify(acpi_handle handle, u32 event, void *data)
+{
+	struct vfio_pci_core_device *vdev = (struct vfio_pci_core_device *)data;
+	struct vfio_acpi_notification *acpi_notify = vdev->acpi_notification;
+	struct notification_queue *entry;
+
+	entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+	if (!entry)
+		return;
+
+	entry->notification_val = event;
+	INIT_LIST_HEAD(&entry->notify_val_next);
+
+	mutex_lock(&acpi_notify->notification_list_lock);
+	list_add_tail(&entry->notify_val_next, &acpi_notify->notification_list);
+	mutex_unlock(&acpi_notify->notification_list_lock);
+
+	schedule_work(&acpi_notify->acpi_notification_work);
+}
+
+void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev)
+{
+	struct vfio_acpi_notification *acpi_notify = vdev->acpi_notification;
+	struct pci_dev *pdev = vdev->pdev;
+	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+	struct notification_queue *entry, *entry_tmp;
+	u64 cnt;
+
+	if (!acpi_notify || !acpi_notify->acpi_notify_trigger)
+		return;
+
+	acpi_remove_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
+				   vfio_pci_core_acpi_notify);
+
+	eventfd_ctx_remove_wait_queue(acpi_notify->acpi_notify_trigger,
+				      &acpi_notify->wait, &cnt);
+
+	flush_work(&acpi_notify->acpi_notification_work);
+
+	mutex_lock(&acpi_notify->notification_list_lock);
+	list_for_each_entry_safe(entry, entry_tmp,
+				 &acpi_notify->notification_list,
+				 notify_val_next) {
+		list_del(&entry->notify_val_next);
+		kfree(entry);
+	}
+	mutex_unlock(&acpi_notify->notification_list_lock);
+
+	eventfd_ctx_put(acpi_notify->acpi_notify_trigger);
+
+	kfree(acpi_notify);
+
+	vdev->acpi_notification = NULL;
+}
+#else
+void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev) {}
+#endif /* CONFIG_ACPI */
+
 void vfio_pci_core_close_device(struct vfio_device *core_vdev)
 {
 	struct vfio_pci_core_device *vdev =
@@ -705,6 +770,8 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev)
 		vdev->req_trigger = NULL;
 	}
 	mutex_unlock(&vdev->igate);
+
+	vfio_pci_acpi_notify_close_device(vdev);
 }
 EXPORT_SYMBOL_GPL(vfio_pci_core_close_device);
 
@@ -882,6 +949,152 @@ int vfio_pci_core_register_dev_region(struct vfio_pci_core_device *vdev,
 }
 EXPORT_SYMBOL_GPL(vfio_pci_core_register_dev_region);
 
+#if IS_ENABLED(CONFIG_ACPI)
+static int vfio_pci_eventfd_wakeup(wait_queue_entry_t *wait, unsigned int mode,
+				   int sync, void *key)
+{
+	struct vfio_acpi_notification *acpi_notify =
+		container_of(wait, struct vfio_acpi_notification, wait);
+	__poll_t flags = key_to_poll(key);
+
+	/*
+	 * eventfd_read signalize EPOLLOUT at the end of its function - this
+	 * means previous eventfd with its notification value was consumed so
+	 * the next notification can be signalized now if pending - schedule
+	 * proper work.
+	 */
+	if (flags & EPOLLOUT) {
+		mutex_unlock(&acpi_notify->notification_lock);
+		schedule_work(&acpi_notify->acpi_notification_work);
+	}
+
+	return 0;
+}
+
+static void vfio_pci_ptable_queue_proc(struct file *file,
+				       wait_queue_head_t *wqh, poll_table *pt)
+{
+	struct vfio_acpi_notification *acpi_notify =
+		container_of(pt, struct vfio_acpi_notification, pt);
+
+	add_wait_queue(wqh, &acpi_notify->wait);
+}
+
+static void acpi_notification_work_fn(struct work_struct *work)
+{
+	struct vfio_acpi_notification *acpi_notify;
+	struct notification_queue *entry;
+
+	acpi_notify = container_of(work, struct vfio_acpi_notification,
+				   acpi_notification_work);
+
+	mutex_lock(&acpi_notify->notification_list_lock);
+	if (list_empty(&acpi_notify->notification_list) || !acpi_notify->acpi_notify_trigger)
+		goto out;
+
+	/*
+	 * If the previous eventfd was not yet consumed by user-space lets hold
+	 * on and exit. The notification function will be rescheduled when
+	 * signaling eventfd will be possible (when the EPOLLOUT will be
+	 * signalized and unlocks notify_events).
+	 */
+	if (!mutex_trylock(&acpi_notify->notification_lock))
+		goto out;
+
+	entry = list_first_entry(&acpi_notify->notification_list,
+				 struct notification_queue, notify_val_next);
+
+	list_del(&entry->notify_val_next);
+	mutex_unlock(&acpi_notify->notification_list_lock);
+
+	eventfd_signal(acpi_notify->acpi_notify_trigger, entry->notification_val);
+
+	kfree(entry);
+
+	return;
+out:
+	mutex_unlock(&acpi_notify->notification_list_lock);
+}
+
+static int vfio_pci_ioctl_acpi_notify_eventfd(struct vfio_pci_core_device *vdev, struct
+				       vfio_irq_info __user *arg)
+{
+	struct file *acpi_notify_trigger_file;
+	struct vfio_acpi_notification *acpi_notify;
+	struct pci_dev *pdev = vdev->pdev;
+	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+	struct vfio_acpi_notify_eventfd entry;
+	struct eventfd_ctx *efdctx;
+	acpi_status status;
+	__poll_t events;
+
+	if (!adev)
+		return -ENODEV;
+
+	if (copy_from_user(&entry, arg, sizeof(entry)))
+		return -EFAULT;
+
+	if (entry.notify_eventfd < 0)
+		return -EINVAL;
+
+	efdctx = eventfd_ctx_fdget(entry.notify_eventfd);
+	if (IS_ERR(efdctx))
+		return PTR_ERR(efdctx);
+
+	vdev->acpi_notification = kzalloc(sizeof(*acpi_notify), GFP_KERNEL);
+	if (!vdev->acpi_notification)
+		return -ENOMEM;
+
+	acpi_notify = vdev->acpi_notification;
+
+	INIT_WORK(&acpi_notify->acpi_notification_work, acpi_notification_work_fn);
+	INIT_LIST_HEAD(&acpi_notify->notification_list);
+
+	acpi_notify->acpi_notify_trigger = efdctx;
+
+	mutex_init(&acpi_notify->notification_lock);
+
+	/*
+	 * Install custom wake-up handler to be notified whenever underlying
+	 * eventfd is consumed by the user-space.
+	 */
+	init_waitqueue_func_entry(&acpi_notify->wait, vfio_pci_eventfd_wakeup);
+	init_poll_funcptr(&acpi_notify->pt, vfio_pci_ptable_queue_proc);
+
+	acpi_notify_trigger_file = eventfd_fget(entry.notify_eventfd);
+	events = vfs_poll(acpi_notify_trigger_file, &acpi_notify->pt);
+
+	status = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
+					vfio_pci_core_acpi_notify, (void *)vdev);
+
+	if (ACPI_FAILURE(status)) {
+		u64 cnt;
+
+		pci_err(pdev, "Failed to install notify handler: %s",
+			acpi_format_exception(status));
+
+		eventfd_ctx_remove_wait_queue(acpi_notify->acpi_notify_trigger,
+					      &acpi_notify->wait, &cnt);
+
+		flush_work(&acpi_notify->acpi_notification_work);
+
+		eventfd_ctx_put(acpi_notify->acpi_notify_trigger);
+
+		kfree(acpi_notify);
+
+		return -ENODEV;
+	}
+
+	return 0;
+}
+#else
+static int vfio_pci_ioctl_acpi_notify_eventfd(struct vfio_pci_core_device *vdev, struct
+				       vfio_irq_info __user *arg)
+{
+	return -ENODEV;
+}
+#endif /* CONFIG_ACPI */
+
 static int vfio_pci_ioctl_get_info(struct vfio_pci_core_device *vdev,
 				   struct vfio_device_info __user *arg)
 {
@@ -1398,6 +1611,8 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd,
 		return vfio_pci_ioctl_reset(vdev, uarg);
 	case VFIO_DEVICE_SET_IRQS:
 		return vfio_pci_ioctl_set_irqs(vdev, uarg);
+	case VFIO_ACPI_NOTIFY_EVENTFD:
+		return vfio_pci_ioctl_acpi_notify_eventfd(vdev, uarg);
 	default:
 		return -ENOTTY;
 	}
diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
index 367fd79226a3..3711e8a1c6f0 100644
--- a/include/linux/vfio_pci_core.h
+++ b/include/linux/vfio_pci_core.h
@@ -49,6 +49,16 @@ struct vfio_pci_region {
 	u32				flags;
 };
 
+struct vfio_acpi_notification {
+	struct eventfd_ctx	*acpi_notify_trigger;
+	struct work_struct	acpi_notification_work;
+	struct list_head	notification_list;
+	struct mutex		notification_list_lock;
+	struct mutex		notification_lock;
+	poll_table		pt;
+	wait_queue_entry_t	wait;
+};
+
 struct vfio_pci_core_device {
 	struct vfio_device	vdev;
 	struct pci_dev		*pdev;
@@ -96,6 +106,7 @@ struct vfio_pci_core_device {
 	struct mutex		vma_lock;
 	struct list_head	vma_list;
 	struct rw_semaphore	memory_lock;
+	struct vfio_acpi_notification	*acpi_notification;
 };
 
 /* Will be exported for vfio pci drivers usage */
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 0552e8dcf0cb..d4b602d8f4b2 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -1622,6 +1622,21 @@ struct vfio_iommu_spapr_tce_remove {
 };
 #define VFIO_IOMMU_SPAPR_TCE_REMOVE	_IO(VFIO_TYPE, VFIO_BASE + 20)
 
+/**
+ * VFIO_ACPI_NOTIFY_EVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 21, struct vfio_acpi_notify_eventfd)
+ *
+ * Register ACPI notify handler for a given device which will allow to receive
+ * and propagate ACPI notifications to the user-space through the user provided
+ * eventfd.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_acpi_notify_eventfd {
+	__s32 notify_eventfd;
+	__u32 reserved;
+};
+#define VFIO_ACPI_NOTIFY_EVENTFD	_IO(VFIO_TYPE, VFIO_BASE + 21)
+
 /* ***************************************************************** */
 
 #endif /* _UAPIVFIO_H */
-- 
2.40.0.634.g4ca3ef3211-goog
Re: [PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
Posted by kernel test robot 1 year ago
Hi Grzegorz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on awilliam-vfio/for-linus]
[also build test WARNING on linus/master v6.3 next-20230424]
[cannot apply to awilliam-vfio/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Grzegorz-Jaszczyk/vfio-pci-Propagate-ACPI-notifications-to-user-space-via-eventfd/20230425-002935
base:   https://github.com/awilliam/linux-vfio.git for-linus
patch link:    https://lore.kernel.org/r/20230424162748.2711945-1-jaz%40semihalf.com
patch subject: [PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
config: i386-randconfig-s001 (https://download.01.org/0day-ci/archive/20230425/202304251437.hZVFw4GS-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/62d759059cd5e6dab70052027e1b69c5d5cdc0f2
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Grzegorz-Jaszczyk/vfio-pci-Propagate-ACPI-notifications-to-user-space-via-eventfd/20230425-002935
        git checkout 62d759059cd5e6dab70052027e1b69c5d5cdc0f2
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/vfio/pci/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304251437.hZVFw4GS-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   drivers/vfio/pci/vfio_pci_core.c:244:33: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:244:41: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:248:25: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:248:43: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:248:56: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:248:65: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:253:25: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:253:44: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:253:57: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:253:66: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:261:39: sparse: sparse: restricted pci_power_t degrades to integer
   drivers/vfio/pci/vfio_pci_core.c:261:58: sparse: sparse: restricted pci_power_t degrades to integer
>> drivers/vfio/pci/vfio_pci_core.c:709:6: sparse: sparse: symbol 'vfio_pci_acpi_notify_close_device' was not declared. Should it be static?

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Re: [PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
Posted by kernel test robot 1 year ago
Hi Grzegorz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on awilliam-vfio/for-linus]
[also build test WARNING on linus/master v6.3 next-20230424]
[cannot apply to awilliam-vfio/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Grzegorz-Jaszczyk/vfio-pci-Propagate-ACPI-notifications-to-user-space-via-eventfd/20230425-002935
base:   https://github.com/awilliam/linux-vfio.git for-linus
patch link:    https://lore.kernel.org/r/20230424162748.2711945-1-jaz%40semihalf.com
patch subject: [PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20230425/202304250702.Jn8hOwUl-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/62d759059cd5e6dab70052027e1b69c5d5cdc0f2
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Grzegorz-Jaszczyk/vfio-pci-Propagate-ACPI-notifications-to-user-space-via-eventfd/20230425-002935
        git checkout 62d759059cd5e6dab70052027e1b69c5d5cdc0f2
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/vfio/pci/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304250702.Jn8hOwUl-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/vfio/pci/vfio_pci_core.c:709:6: warning: no previous prototype for function 'vfio_pci_acpi_notify_close_device' [-Wmissing-prototypes]
   void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev)
        ^
   drivers/vfio/pci/vfio_pci_core.c:709:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev)
   ^
   static 
>> drivers/vfio/pci/vfio_pci_core.c:1029:11: warning: variable 'events' set but not used [-Wunused-but-set-variable]
           __poll_t events;
                    ^
   2 warnings generated.


vim +/vfio_pci_acpi_notify_close_device +709 drivers/vfio/pci/vfio_pci_core.c

   708	
 > 709	void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev)
   710	{
   711		struct vfio_acpi_notification *acpi_notify = vdev->acpi_notification;
   712		struct pci_dev *pdev = vdev->pdev;
   713		struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
   714		struct notification_queue *entry, *entry_tmp;
   715		u64 cnt;
   716	
   717		if (!acpi_notify || !acpi_notify->acpi_notify_trigger)
   718			return;
   719	
   720		acpi_remove_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
   721					   vfio_pci_core_acpi_notify);
   722	
   723		eventfd_ctx_remove_wait_queue(acpi_notify->acpi_notify_trigger,
   724					      &acpi_notify->wait, &cnt);
   725	
   726		flush_work(&acpi_notify->acpi_notification_work);
   727	
   728		mutex_lock(&acpi_notify->notification_list_lock);
   729		list_for_each_entry_safe(entry, entry_tmp,
   730					 &acpi_notify->notification_list,
   731					 notify_val_next) {
   732			list_del(&entry->notify_val_next);
   733			kfree(entry);
   734		}
   735		mutex_unlock(&acpi_notify->notification_list_lock);
   736	
   737		eventfd_ctx_put(acpi_notify->acpi_notify_trigger);
   738	
   739		kfree(acpi_notify);
   740	
   741		vdev->acpi_notification = NULL;
   742	}
   743	#else
   744	void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev) {}
   745	#endif /* CONFIG_ACPI */
   746	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Re: [PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
Posted by kernel test robot 1 year ago
Hi Grzegorz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on awilliam-vfio/for-linus]
[also build test WARNING on linus/master v6.3 next-20230421]
[cannot apply to awilliam-vfio/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Grzegorz-Jaszczyk/vfio-pci-Propagate-ACPI-notifications-to-user-space-via-eventfd/20230425-002935
base:   https://github.com/awilliam/linux-vfio.git for-linus
patch link:    https://lore.kernel.org/r/20230424162748.2711945-1-jaz%40semihalf.com
patch subject: [PATCH v2] vfio/pci: Propagate ACPI notifications to user-space via eventfd
config: ia64-allmodconfig (https://download.01.org/0day-ci/archive/20230425/202304250252.8MirvFb0-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/62d759059cd5e6dab70052027e1b69c5d5cdc0f2
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Grzegorz-Jaszczyk/vfio-pci-Propagate-ACPI-notifications-to-user-space-via-eventfd/20230425-002935
        git checkout 62d759059cd5e6dab70052027e1b69c5d5cdc0f2
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/vfio/pci/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304250252.8MirvFb0-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/vfio/pci/vfio_pci_core.c:709:6: warning: no previous prototype for 'vfio_pci_acpi_notify_close_device' [-Wmissing-prototypes]
     709 | void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vfio/pci/vfio_pci_core.c: In function 'vfio_pci_ioctl_acpi_notify_eventfd':
>> drivers/vfio/pci/vfio_pci_core.c:1029:18: warning: variable 'events' set but not used [-Wunused-but-set-variable]
    1029 |         __poll_t events;
         |                  ^~~~~~


vim +/vfio_pci_acpi_notify_close_device +709 drivers/vfio/pci/vfio_pci_core.c

   708	
 > 709	void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev)
   710	{
   711		struct vfio_acpi_notification *acpi_notify = vdev->acpi_notification;
   712		struct pci_dev *pdev = vdev->pdev;
   713		struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
   714		struct notification_queue *entry, *entry_tmp;
   715		u64 cnt;
   716	
   717		if (!acpi_notify || !acpi_notify->acpi_notify_trigger)
   718			return;
   719	
   720		acpi_remove_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
   721					   vfio_pci_core_acpi_notify);
   722	
   723		eventfd_ctx_remove_wait_queue(acpi_notify->acpi_notify_trigger,
   724					      &acpi_notify->wait, &cnt);
   725	
   726		flush_work(&acpi_notify->acpi_notification_work);
   727	
   728		mutex_lock(&acpi_notify->notification_list_lock);
   729		list_for_each_entry_safe(entry, entry_tmp,
   730					 &acpi_notify->notification_list,
   731					 notify_val_next) {
   732			list_del(&entry->notify_val_next);
   733			kfree(entry);
   734		}
   735		mutex_unlock(&acpi_notify->notification_list_lock);
   736	
   737		eventfd_ctx_put(acpi_notify->acpi_notify_trigger);
   738	
   739		kfree(acpi_notify);
   740	
   741		vdev->acpi_notification = NULL;
   742	}
   743	#else
   744	void vfio_pci_acpi_notify_close_device(struct vfio_pci_core_device *vdev) {}
   745	#endif /* CONFIG_ACPI */
   746	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests