RE: [RFC 10/12] vfio: Add cdev for vfio_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> Sent: Monday, December 19, 2022 4:47 PM
> @@ -156,7 +159,7 @@ static void vfio_device_release(struct device *dev)
>  			container_of(dev, struct vfio_device, device);
> 
>  	vfio_release_device_set(device);
> -	ida_free(&vfio.device_ida, device->index);
> +	ida_free(&vfio.device_ida, MINOR(device->device.devt));

device->index is required if !CONFIG_IOMMUFD.

> @@ -234,11 +238,18 @@ int vfio_init_device(struct vfio_device *device,
> struct device *dev,
>  	device->device.release = vfio_device_release;
>  	device->device.class = vfio.device_class;
>  	device->device.parent = device->dev;
> +#if IS_ENABLED(CONFIG_IOMMUFD)
> +	device->device.devt = MKDEV(MAJOR(vfio.device_devt), minor);
> +	cdev_init(&device->cdev, &vfio_device_fops);
> +	device->cdev.owner = THIS_MODULE;
> +#else
> +	device->index = ret;

this should be 'minor' since 'ret' has been overwritten by ops->init().

> +	/*
> +	 * vfio device open is done in BIND_IOMMUFD for cdev, before
> +	 * that, device access is blocked for this cdev open.
> +	 */

/* device access is blocked until .open_device() is called in BIND_IOMMUFD */





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux