Message ID | 0-v2-fd9627d27b2b+26c-vfio_group_cdev_jgg@nvidia.com (mailing list archive) |
---|---|
Headers | show |
Series | Update vfio_group to use the modern cdev lifecycle | expand |
> From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Wednesday, October 13, 2021 10:28 PM > > These days drivers with state should use cdev_device_add() and > cdev_device_del() to manage the cdev and sysfs lifetime. This simple > pattern ties all the state (vfio, dev, and cdev) together in one memory > structure and uses container_of() to navigate between the layers. > > This is a followup to the discussion here: > > https://lore.kernel.org/kvm/20210921155705.GN327412@nvidia.com/ > > This builds on Christoph's work to revise how the vfio_group works and is > against the latest VFIO tree. Jason, do you have a github branch includes these changes and also Christoph's revise work. I would like to rebase the iommufd things on top of it. Also, want to have a try to see if any regression. Thanks, Yi Liu > v2: > - Remove comment before iommu_group_unregister_notifier() > - Add comment explaining what the WARN_ONs vfio_group_put() do > - Fix error logic around vfio_create_group() in patch 3 > - Add horizontal whitespace > - Clarify comment is refering to group->users > v1: https://lore.kernel.org/r/0-v1-fba989159158+2f9b- > vfio_group_cdev_jgg@nvidia.com > > Cc: Liu Yi L <yi.l.liu@intel.com> > Cc: "Tian, Kevin" <kevin.tian@intel.com> > Cc: Christoph Hellwig <hch@lst.de> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > > Jason Gunthorpe (5): > vfio: Delete vfio_get/put_group from vfio_iommu_group_notifier() > vfio: Do not open code the group list search in vfio_create_group() > vfio: Don't leak a group reference if the group already exists > vfio: Use a refcount_t instead of a kref in the vfio_group > vfio: Use cdev_device_add() instead of device_create() > > drivers/vfio/vfio.c | 372 ++++++++++++++++++-------------------------- > 1 file changed, 148 insertions(+), 224 deletions(-) > > > base-commit: d9a0cd510c3383b61db6f70a84e0c3487f836a63 > -- > 2.33.0
On Fri, Oct 15, 2021 at 06:03:18AM +0000, Liu, Yi L wrote: > > From: Jason Gunthorpe <jgg@nvidia.com> > > Sent: Wednesday, October 13, 2021 10:28 PM > > > > These days drivers with state should use cdev_device_add() and > > cdev_device_del() to manage the cdev and sysfs lifetime. This simple > > pattern ties all the state (vfio, dev, and cdev) together in one memory > > structure and uses container_of() to navigate between the layers. > > > > This is a followup to the discussion here: > > > > https://lore.kernel.org/kvm/20210921155705.GN327412@nvidia.com/ > > > > This builds on Christoph's work to revise how the vfio_group works and is > > against the latest VFIO tree. > > Jason, do you have a github branch includes these changes and also > Christoph's revise work. I would like to rebase the iommufd things on > top of it. Also, want to have a try to see if any regression. https://github.com/jgunthorpe/linux/commits/vfio_group_cdev Jason
> From: Jason Gunthorpe <jgg@nvidia.com> > Sent: Friday, October 15, 2021 7:41 PM > > On Fri, Oct 15, 2021 at 06:03:18AM +0000, Liu, Yi L wrote: > > > From: Jason Gunthorpe <jgg@nvidia.com> > > > Sent: Wednesday, October 13, 2021 10:28 PM > > > > > > These days drivers with state should use cdev_device_add() and > > > cdev_device_del() to manage the cdev and sysfs lifetime. This simple > > > pattern ties all the state (vfio, dev, and cdev) together in one memory > > > structure and uses container_of() to navigate between the layers. > > > > > > This is a followup to the discussion here: > > > > > > https://lore.kernel.org/kvm/20210921155705.GN327412@nvidia.com/ > > > > > > This builds on Christoph's work to revise how the vfio_group works and is > > > against the latest VFIO tree. > > > > Jason, do you have a github branch includes these changes and also > > Christoph's revise work. I would like to rebase the iommufd things on > > top of it. Also, want to have a try to see if any regression. > > https://github.com/jgunthorpe/linux/commits/vfio_group_cdev thanks. Regards, Yi Liu
These days drivers with state should use cdev_device_add() and cdev_device_del() to manage the cdev and sysfs lifetime. This simple pattern ties all the state (vfio, dev, and cdev) together in one memory structure and uses container_of() to navigate between the layers. This is a followup to the discussion here: https://lore.kernel.org/kvm/20210921155705.GN327412@nvidia.com/ This builds on Christoph's work to revise how the vfio_group works and is against the latest VFIO tree. v2: - Remove comment before iommu_group_unregister_notifier() - Add comment explaining what the WARN_ONs vfio_group_put() do - Fix error logic around vfio_create_group() in patch 3 - Add horizontal whitespace - Clarify comment is refering to group->users v1: https://lore.kernel.org/r/0-v1-fba989159158+2f9b-vfio_group_cdev_jgg@nvidia.com Cc: Liu Yi L <yi.l.liu@intel.com> Cc: "Tian, Kevin" <kevin.tian@intel.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Jason Gunthorpe (5): vfio: Delete vfio_get/put_group from vfio_iommu_group_notifier() vfio: Do not open code the group list search in vfio_create_group() vfio: Don't leak a group reference if the group already exists vfio: Use a refcount_t instead of a kref in the vfio_group vfio: Use cdev_device_add() instead of device_create() drivers/vfio/vfio.c | 372 ++++++++++++++++++-------------------------- 1 file changed, 148 insertions(+), 224 deletions(-) base-commit: d9a0cd510c3383b61db6f70a84e0c3487f836a63