mbox series

[00/12] Remove vfio_mdev.c, mdev_parent_ops and more

Message ID 0-v1-d88406ed308e+418-vfio3_jgg@nvidia.com (mailing list archive)
Headers show
Series Remove vfio_mdev.c, mdev_parent_ops and more | expand

Message

Jason Gunthorpe April 23, 2021, 11:02 p.m. UTC
Prologue
========

This is series #3 in part of a larger work that arose from the minor
remark that the mdev_parent_ops indirection shim is useless and
complicates things.

It applies on top of Alex's current tree and requires the prior two
series.

This series achieves the removal of vfio_mdev.c. The future patches are all
focused on leveraging the changes made in the prior series to simplify the
API and device operation.

A preview of the future series's is here:
  https://github.com/jgunthorpe/linux/pull/3/commits

========

The mdev bus's core part for managing the lifecycle of devices is mostly
as one would expect for a driver core bus subsystem.

However instead of having a normal 'struct device_driver' and binding the
actual mdev drivers through the standard driver core mechanisms it open
codes this with the struct mdev_parent_ops and provides a single driver
that shims between the VFIO core and the actual device driver.

Make every one of the mdev drivers implement an actual struct mdev_driver
and directly call vfio_register_group_dev() in the probe() function for
the mdev.

Squash what is left of the mdev_parent_ops into the mdev_driver and remap
create(), remove() and mdev_attr_groups to their driver core
equivalents. Arrange to bind the created mdev_device to the mdev_driver
that is provided by the end driver.

The actual execution flow doesn't change much, eg what was
parent_ops->create is now device_driver->probe and it is called at almost
the exact same time - except under the normal control of the driver core.

This allows deleting the entire mdev_drvdata, and tidying some of the
sysfs. Many places in the drivers start using container_of()

This cleanly splits the mdev sysfs GUID lifecycle management stuff from
the vfio_device implementation part, the only VFIO special part of mdev
that remains is the mdev specific iommu intervention.

Thanks,
Jason

Jason Gunthorpe (12):
  vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
  vfio/mdev: Allow the mdev_parent_ops to specify the device driver to
    bind
  vfio/mtty: Convert to use vfio_register_group_dev()
  vfio/mdpy: Convert to use vfio_register_group_dev()
  vfio/mbochs: Convert to use vfio_register_group_dev()
  vfio/ap_ops: Convert to use vfio_register_group_dev()
  vfio/ccw: Convert to use vfio_register_group_dev()
  vfio/gvt: Convert to use vfio_register_group_dev()
  vfio/mdev: Remove mdev_parent_ops dev_attr_groups
  vfio/mdev: Remove mdev_parent_ops
  vfio/mdev: Use the driver core to create the 'remove' file
  vfio/mdev: Remove mdev drvdata

 .../driver-api/vfio-mediated-device.rst       |  55 ++---
 Documentation/s390/vfio-ap.rst                |   1 -
 arch/s390/Kconfig                             |   2 +-
 drivers/gpu/drm/i915/Kconfig                  |   2 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c              | 210 +++++++++--------
 drivers/s390/cio/vfio_ccw_drv.c               |  21 +-
 drivers/s390/cio/vfio_ccw_ops.c               | 136 ++++++-----
 drivers/s390/cio/vfio_ccw_private.h           |   5 +
 drivers/s390/crypto/vfio_ap_ops.c             | 138 ++++++-----
 drivers/s390/crypto/vfio_ap_private.h         |   2 +
 drivers/vfio/mdev/Kconfig                     |   7 -
 drivers/vfio/mdev/Makefile                    |   1 -
 drivers/vfio/mdev/mdev_core.c                 |  65 ++++--
 drivers/vfio/mdev/mdev_driver.c               |  10 +-
 drivers/vfio/mdev/mdev_private.h              |   4 +-
 drivers/vfio/mdev/mdev_sysfs.c                |  37 ++-
 drivers/vfio/mdev/vfio_mdev.c                 | 180 ---------------
 drivers/vfio/vfio.c                           |   6 +-
 include/linux/mdev.h                          |  86 +------
 include/linux/vfio.h                          |   4 +
 samples/Kconfig                               |   6 +-
 samples/vfio-mdev/mbochs.c                    | 166 +++++++------
 samples/vfio-mdev/mdpy.c                      | 162 +++++++------
 samples/vfio-mdev/mtty.c                      | 218 +++++++-----------
 24 files changed, 649 insertions(+), 875 deletions(-)
 delete mode 100644 drivers/vfio/mdev/vfio_mdev.c

Comments

Christian Borntraeger April 26, 2021, 4:43 p.m. UTC | #1
On 24.04.21 01:02, Jason Gunthorpe wrote:
> Prologue
> ========
> 
> This is series #3 in part of a larger work that arose from the minor
> remark that the mdev_parent_ops indirection shim is useless and
> complicates things.
> 
> It applies on top of Alex's current tree and requires the prior two
> series.

Do you have a tree somewhere?
Jason Gunthorpe April 26, 2021, 5:42 p.m. UTC | #2
On Mon, Apr 26, 2021 at 06:43:14PM +0200, Christian Borntraeger wrote:
> On 24.04.21 01:02, Jason Gunthorpe wrote:
> > Prologue
> > ========
> > 
> > This is series #3 in part of a larger work that arose from the minor
> > remark that the mdev_parent_ops indirection shim is useless and
> > complicates things.
> > 
> > It applies on top of Alex's current tree and requires the prior two
> > series.
> 
> Do you have a tree somewhere?

[..]
> > A preview of the future series's is here:
> >    https://github.com/jgunthorpe/linux/pull/3/commits

Has everything, you'll want to go to:
  cover-letter: Remove vfio_mdev.c, mdev_parent_ops and more

As there are additional WIPs in that tree.

Jason
Christian Borntraeger April 27, 2021, 7:33 a.m. UTC | #3
On 26.04.21 19:42, Jason Gunthorpe wrote:
> On Mon, Apr 26, 2021 at 06:43:14PM +0200, Christian Borntraeger wrote:
>> On 24.04.21 01:02, Jason Gunthorpe wrote:
>>> Prologue
>>> ========
>>>
>>> This is series #3 in part of a larger work that arose from the minor
>>> remark that the mdev_parent_ops indirection shim is useless and
>>> complicates things.
>>>
>>> It applies on top of Alex's current tree and requires the prior two
>>> series.
>>
>> Do you have a tree somewhere?
> 
> [..]
>>> A preview of the future series's is here:
>>>     https://github.com/jgunthorpe/linux/pull/3/commits
> 
> Has everything, you'll want to go to:
>    cover-letter: Remove vfio_mdev.c, mdev_parent_ops and more
> 
> As there are additional WIPs in that tree.

I gave this a quick spin on s390x vfio-ap and it seems to work ok.
This is really just a quick test, but no obvious problem.
Jason Gunthorpe April 27, 2021, 11:21 p.m. UTC | #4
On Tue, Apr 27, 2021 at 09:33:56AM +0200, Christian Borntraeger wrote:
> On 26.04.21 19:42, Jason Gunthorpe wrote:
> > On Mon, Apr 26, 2021 at 06:43:14PM +0200, Christian Borntraeger wrote:
> > > On 24.04.21 01:02, Jason Gunthorpe wrote:
> > > > Prologue
> > > > ========
> > > > 
> > > > This is series #3 in part of a larger work that arose from the minor
> > > > remark that the mdev_parent_ops indirection shim is useless and
> > > > complicates things.
> > > > 
> > > > It applies on top of Alex's current tree and requires the prior two
> > > > series.
> > > 
> > > Do you have a tree somewhere?
> > 
> > [..]
> > > > A preview of the future series's is here:
> > > >     https://github.com/jgunthorpe/linux/pull/3/commits
> > 
> > Has everything, you'll want to go to:
> >    cover-letter: Remove vfio_mdev.c, mdev_parent_ops and more
> > 
> > As there are additional WIPs in that tree.
> 
> I gave this a quick spin on s390x vfio-ap and it seems to work ok.
> This is really just a quick test, but no obvious problem.

Great! Thanks

Jason