Commit 6fe567df authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'vfio-v5.2-rc1' of git://github.com/awilliam/linux-vfio

Pull VFIO updates from Alex Williamson:

 - Improve dev_printk() usage (Bjorn Helgaas)

 - Fix issue with blocking in !TASK_RUNNING state while waiting for
   userspace to release devices (Farhan Ali)

 - Fix error path cleanup in nvlink setup (Greg Kurz)

 - mdev-core cleanups and fixes in preparation for more use cases (Parav
   Pandit)

 - Cornelia has volunteered as an official vfio reviewer (Cornelia Huck)

* tag 'vfio-v5.2-rc1' of git://github.com/awilliam/linux-vfio:
  vfio: Add Cornelia Huck as reviewer
  vfio/mdev: Avoid inline get and put parent helpers
  vfio/mdev: Fix aborting mdev child device removal if one fails
  vfio/mdev: Follow correct remove sequence
  vfio/mdev: Avoid masking error code to EBUSY
  vfio/mdev: Drop redundant extern for exported symbols
  vfio/mdev: Removed unused kref
  vfio/mdev: Avoid release parent reference during error path
  vfio-pci/nvlink2: Fix potential VMA leak
  vfio: Fix WARNING "do not call blocking ops when !TASK_RUNNING"
  vfio: Use dev_printk() when possible
parents c367dc8d 15c80c16
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16557,6 +16557,7 @@ F: fs/fat/

VFIO DRIVER
M:	Alex Williamson <alex.williamson@redhat.com>
R:	Cornelia Huck <cohuck@redhat.com>
L:	kvm@vger.kernel.org
T:	git git://github.com/awilliam/linux-vfio.git
S:	Maintained
+8 −10
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ static void mdev_release_parent(struct kref *kref)
	put_device(dev);
}

static inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
static struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
{
	if (parent)
		kref_get(&parent->ref);
@@ -96,7 +96,7 @@ static inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
	return parent;
}

static inline void mdev_put_parent(struct mdev_parent *parent)
static void mdev_put_parent(struct mdev_parent *parent)
{
	if (parent)
		kref_put(&parent->ref, mdev_release_parent);
@@ -141,7 +141,7 @@ static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove)
	 */
	ret = parent->ops->remove(mdev);
	if (ret && !force_remove)
		return -EBUSY;
		return ret;

	sysfs_remove_groups(&mdev->dev.kobj, parent->ops->mdev_attr_groups);
	return 0;
@@ -149,10 +149,10 @@ static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove)

static int mdev_device_remove_cb(struct device *dev, void *data)
{
	if (!dev_is_mdev(dev))
		return 0;
	if (dev_is_mdev(dev))
		mdev_device_remove(dev, true);

	return mdev_device_remove(dev, data ? *(bool *)data : true);
	return 0;
}

/*
@@ -181,6 +181,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
	/* Check for duplicate */
	parent = __find_parent_device(dev);
	if (parent) {
		parent = NULL;
		ret = -EEXIST;
		goto add_dev_err;
	}
@@ -239,7 +240,6 @@ EXPORT_SYMBOL(mdev_register_device);
void mdev_unregister_device(struct device *dev)
{
	struct mdev_parent *parent;
	bool force_remove = true;

	mutex_lock(&parent_list_lock);
	parent = __find_parent_device(dev);
@@ -253,8 +253,7 @@ void mdev_unregister_device(struct device *dev)
	list_del(&parent->next);
	class_compat_remove_link(mdev_bus_compat_class, dev, NULL);

	device_for_each_child(dev, (void *)&force_remove,
			      mdev_device_remove_cb);
	device_for_each_child(dev, NULL, mdev_device_remove_cb);

	parent_remove_sysfs_files(parent);

@@ -310,7 +309,6 @@ int mdev_device_create(struct kobject *kobj,
	mutex_unlock(&mdev_list_lock);

	mdev->parent = parent;
	kref_init(&mdev->ref);

	mdev->dev.parent  = dev;
	mdev->dev.bus     = &mdev_bus_type;
+0 −1
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ struct mdev_device {
	struct mdev_parent *parent;
	guid_t uuid;
	void *driver_data;
	struct kref ref;
	struct list_head next;
	struct kobject *type_kobj;
	bool active;
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type)

void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type)
{
	sysfs_remove_files(&dev->kobj, mdev_device_attrs);
	sysfs_remove_link(&dev->kobj, "mdev_type");
	sysfs_remove_link(type->devices_kobj, dev_name(dev));
	sysfs_remove_files(&dev->kobj, mdev_device_attrs);
}
+10 −13
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define dev_fmt pr_fmt

#include <linux/device.h>
#include <linux/eventfd.h>
@@ -287,12 +288,11 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
	pci_save_state(pdev);
	vdev->pci_saved_state = pci_store_saved_state(pdev);
	if (!vdev->pci_saved_state)
		pr_debug("%s: Couldn't store %s saved state\n",
			 __func__, dev_name(&pdev->dev));
		pci_dbg(pdev, "%s: Couldn't store saved state\n", __func__);

	if (likely(!nointxmask)) {
		if (vfio_pci_nointx(pdev)) {
			dev_info(&pdev->dev, "Masking broken INTx support\n");
			pci_info(pdev, "Masking broken INTx support\n");
			vdev->nointx = true;
			pci_intx(pdev, 0);
		} else
@@ -336,8 +336,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
	    IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
		ret = vfio_pci_igd_init(vdev);
		if (ret) {
			dev_warn(&vdev->pdev->dev,
				 "Failed to setup Intel IGD regions\n");
			pci_warn(pdev, "Failed to setup Intel IGD regions\n");
			goto disable_exit;
		}
	}
@@ -346,8 +345,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
	    IS_ENABLED(CONFIG_VFIO_PCI_NVLINK2)) {
		ret = vfio_pci_nvdia_v100_nvlink2_init(vdev);
		if (ret && ret != -ENODEV) {
			dev_warn(&vdev->pdev->dev,
				 "Failed to setup NVIDIA NV2 RAM region\n");
			pci_warn(pdev, "Failed to setup NVIDIA NV2 RAM region\n");
			goto disable_exit;
		}
	}
@@ -356,8 +354,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
	    IS_ENABLED(CONFIG_VFIO_PCI_NVLINK2)) {
		ret = vfio_pci_ibm_npu2_init(vdev);
		if (ret && ret != -ENODEV) {
			dev_warn(&vdev->pdev->dev,
					"Failed to setup NVIDIA NV2 ATSD region\n");
			pci_warn(pdev, "Failed to setup NVIDIA NV2 ATSD region\n");
			goto disable_exit;
		}
	}
@@ -429,8 +426,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
	 * is just busy work.
	 */
	if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) {
		pr_info("%s: Couldn't reload %s saved state\n",
			__func__, dev_name(&pdev->dev));
		pci_info(pdev, "%s: Couldn't reload saved state\n", __func__);

		if (!vdev->reset_works)
			goto out;
@@ -1255,17 +1251,18 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
static void vfio_pci_request(void *device_data, unsigned int count)
{
	struct vfio_pci_device *vdev = device_data;
	struct pci_dev *pdev = vdev->pdev;

	mutex_lock(&vdev->igate);

	if (vdev->req_trigger) {
		if (!(count % 10))
			dev_notice_ratelimited(&vdev->pdev->dev,
			pci_notice_ratelimited(pdev,
				"Relaying device request to user (#%u)\n",
				count);
		eventfd_signal(vdev->req_trigger, 1);
	} else if (count == 0) {
		dev_warn(&vdev->pdev->dev,
		pci_warn(pdev,
			"No device request channel registered, blocked until released by user\n");
	}

Loading