[Intel-gfx] [PATCH v2 6/9] vfio/mdev: Add mdev available instance checking to the core

Jason Gunthorpe jgg at nvidia.com
Tue Sep 21 13:19:08 UTC 2021


On Mon, Sep 20, 2021 at 08:02:29PM +0200, Cornelia Huck wrote:
> On Thu, Sep 09 2021, Jason Gunthorpe <jgg at nvidia.com> wrote:
> 
> > Many of the mdev drivers use a simple counter for keeping track of the
> > available instances. Move this code to the core code and store the counter
> > in the mdev_type. Implement it using correct locking, fixing mdpy.
> >
> > Drivers provide a get_available() callback to set the number of available
> > instances for their mtypes which is fixed at registration time. The core
> > provides a standard sysfs attribute to return the available_instances.
> 
> So, according to the documentation, available_instances is
> mandatory. This means that drivers either need to provide get_available
> or implement their own version of the attribute. I think we want to
> update vfio-mediated-device.rst as well?

I added this, and something similar for the device_api patch too, thanks

diff --git a/Documentation/driver-api/vfio-mediated-device.rst b/Documentation/driver-api/vfio-mediated-device.rst
index 9f26079cacae35..0a130d76b33a48 100644
--- a/Documentation/driver-api/vfio-mediated-device.rst
+++ b/Documentation/driver-api/vfio-mediated-device.rst
@@ -106,6 +106,7 @@ structure to represent a mediated device's driver::
 	     int  (*probe)  (struct mdev_device *dev);
 	     void (*remove) (struct mdev_device *dev);
 	     struct device_driver    driver;
+	     unsigned int (*get_available)(struct mdev_type *mtype);
      };
 
 A mediated bus driver for mdev should use this structure in the function calls
@@ -230,7 +231,8 @@ Directories and files under the sysfs for Each Physical Device
 * available_instances
 
   This attribute should show the number of devices of type <type-id> that can be
-  created.
+  created. Drivers can supply a get_availble() function pointer to have the core
+  code create and maintain this sysfs automatically.
 
 * [device]
 


More information about the Intel-gfx mailing list