dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 02/10] driver core: Better distinguish probe errors in really_probe
       [not found] ` <20210615133519.754763-3-hch@lst.de>
@ 2021-06-15 13:53   ` Cornelia Huck
  2021-06-15 14:09     ` Greg Kroah-Hartman
  2021-06-15 14:09   ` Greg Kroah-Hartman
  2021-06-16 20:20   ` Kirti Wankhede
  2 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2021-06-15 13:53 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe,
	Alex Williamson, Kirti Wankhede
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, linux-doc, dri-devel,
	Halil Pasic, Christian Borntraeger, Rodrigo Vivi,
	Rafael J. Wysocki, intel-gfx

On Tue, Jun 15 2021, Christoph Hellwig <hch@lst.de> wrote:

> really_probe tries to special case errors from ->probe, but due to all
> other initialization added to the function over time now a lot of
> internal errors hit that code path as well.  Untangle that by adding
> a new probe_err local variable and apply the special casing only to
> that.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/base/dd.c | 72 +++++++++++++++++++++++++++--------------------
>  1 file changed, 42 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 7477d3322b3a..fd83817240e6 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -513,12 +513,44 @@ static ssize_t state_synced_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(state_synced);
>  
> +
> +static int call_driver_probe(struct device *dev, struct device_driver *drv)
> +{
> +	int ret = 0;
> +
> +	if (dev->bus->probe)
> +		ret = dev->bus->probe(dev);
> +	else if (drv->probe)
> +		ret = drv->probe(dev);
> +
> +	switch (ret) {
> +	case 0:
> +		break;
> +	case -EPROBE_DEFER:
> +		/* Driver requested deferred probing */
> +		dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
> +		break;
> +	case -ENODEV:
> +	case -ENXIO:
> +		pr_debug("%s: probe of %s rejects match %d\n",
> +			 drv->name, dev_name(dev), ret);
> +		break;
> +	default:
> +		/* driver matched but the probe failed */
> +		pr_warn("%s: probe of %s failed with error %d\n",
> +			drv->name, dev_name(dev), ret);

Convert these two pr_* to dev_* when touching the code anyway?

> +		break;
> +	}
> +
> +	return ret;
> +}

(...)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 04/10] driver core: Don't return EPROBE_DEFER to userspace during sysfs bind
       [not found] ` <20210615133519.754763-5-hch@lst.de>
@ 2021-06-15 14:03   ` Cornelia Huck
  2021-06-15 19:36   ` Alex Williamson
  1 sibling, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2021-06-15 14:03 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe,
	Alex Williamson, Kirti Wankhede
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, linux-doc, dri-devel,
	Halil Pasic, Christian Borntraeger, Rodrigo Vivi,
	Rafael J. Wysocki, intel-gfx

On Tue, Jun 15 2021, Christoph Hellwig <hch@lst.de> wrote:

> EPROBE_DEFER is an internal kernel error code and it should not be leaked
> to userspace via the bind_store() sysfs. Userspace doesn't have this
> constant and cannot understand it.
>
> Further, it doesn't really make sense to have userspace trigger a deferred
> probe via bind_store(), which could eventually succeed, while
> simultaneously returning an error back.
>
> Resolve this by splitting driver_probe_device so that the version used
> by the sysfs binding that turns EPROBE_DEFER into -EAGAIN, while the one
> used for internally binding keeps the error code, and calls
> driver_deferred_probe_add where needed.  This also allows to nicely split
> out the defer_all_probes / probe_count checks so that they actually allow
> for full device_{block,unblock}_probing protection while not bothering
> the sysfs bind case.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/base/dd.c | 78 +++++++++++++++++++++++++----------------------
>  1 file changed, 42 insertions(+), 36 deletions(-)
>

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind
       [not found] ` <20210615133519.754763-8-hch@lst.de>
@ 2021-06-15 14:06   ` Cornelia Huck
  2021-06-15 14:11   ` Greg Kroah-Hartman
  2021-06-16 20:20   ` Kirti Wankhede
  2 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2021-06-15 14:06 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe,
	Alex Williamson, Kirti Wankhede
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, linux-doc, dri-devel,
	Halil Pasic, Christian Borntraeger, Rodrigo Vivi,
	Rafael J. Wysocki, intel-gfx

On Tue, Jun 15 2021, Christoph Hellwig <hch@lst.de> wrote:

> From: Jason Gunthorpe <jgg@nvidia.com>
>
> This allows a mdev driver to opt out of using vfio_mdev.c, instead the
> driver will provide a 'struct mdev_driver' and register directly with the
> driver core.
>
> Much of mdev_parent_ops becomes unused in this mode:
> - create()/remove() are done via the mdev_driver probe()/remove()
> - mdev_attr_groups becomes mdev_driver driver.dev_groups
> - Wrapper function callbacks are replaced with the same ones from
>   struct vfio_device_ops
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/vfio/mdev/mdev_core.c   | 30 ++++++++++++++++++++++--------
>  drivers/vfio/mdev/mdev_driver.c | 10 ++++++++++
>  include/linux/mdev.h            |  2 ++
>  3 files changed, 34 insertions(+), 8 deletions(-)
>

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 02/10] driver core: Better distinguish probe errors in really_probe
  2021-06-15 13:53   ` [PATCH 02/10] driver core: Better distinguish probe errors in really_probe Cornelia Huck
@ 2021-06-15 14:09     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:09 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	Christoph Hellwig, linux-s390, Jonathan Corbet,
	Rafael J. Wysocki, Halil Pasic, Christian Borntraeger,
	Jason Gunthorpe, intel-gfx, Jason Herne, Vasily Gorbik,
	Heiko Carstens, Alex Williamson, Rodrigo Vivi, Tony Krowiak

On Tue, Jun 15, 2021 at 03:53:46PM +0200, Cornelia Huck wrote:
> On Tue, Jun 15 2021, Christoph Hellwig <hch@lst.de> wrote:
> 
> > really_probe tries to special case errors from ->probe, but due to all
> > other initialization added to the function over time now a lot of
> > internal errors hit that code path as well.  Untangle that by adding
> > a new probe_err local variable and apply the special casing only to
> > that.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  drivers/base/dd.c | 72 +++++++++++++++++++++++++++--------------------
> >  1 file changed, 42 insertions(+), 30 deletions(-)
> >
> > diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> > index 7477d3322b3a..fd83817240e6 100644
> > --- a/drivers/base/dd.c
> > +++ b/drivers/base/dd.c
> > @@ -513,12 +513,44 @@ static ssize_t state_synced_show(struct device *dev,
> >  }
> >  static DEVICE_ATTR_RO(state_synced);
> >  
> > +
> > +static int call_driver_probe(struct device *dev, struct device_driver *drv)
> > +{
> > +	int ret = 0;
> > +
> > +	if (dev->bus->probe)
> > +		ret = dev->bus->probe(dev);
> > +	else if (drv->probe)
> > +		ret = drv->probe(dev);
> > +
> > +	switch (ret) {
> > +	case 0:
> > +		break;
> > +	case -EPROBE_DEFER:
> > +		/* Driver requested deferred probing */
> > +		dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
> > +		break;
> > +	case -ENODEV:
> > +	case -ENXIO:
> > +		pr_debug("%s: probe of %s rejects match %d\n",
> > +			 drv->name, dev_name(dev), ret);
> > +		break;
> > +	default:
> > +		/* driver matched but the probe failed */
> > +		pr_warn("%s: probe of %s failed with error %d\n",
> > +			drv->name, dev_name(dev), ret);
> 
> Convert these two pr_* to dev_* when touching the code anyway?

It can wait, it's just moving code around for now.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 02/10] driver core: Better distinguish probe errors in really_probe
       [not found] ` <20210615133519.754763-3-hch@lst.de>
  2021-06-15 13:53   ` [PATCH 02/10] driver core: Better distinguish probe errors in really_probe Cornelia Huck
@ 2021-06-15 14:09   ` Greg Kroah-Hartman
  2021-06-16 20:20   ` Kirti Wankhede
  2 siblings, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:09 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:11PM +0200, Christoph Hellwig wrote:
> really_probe tries to special case errors from ->probe, but due to all
> other initialization added to the function over time now a lot of
> internal errors hit that code path as well.  Untangle that by adding
> a new probe_err local variable and apply the special casing only to
> that.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 05/10] driver core: Export device_driver_attach()
       [not found] ` <20210615133519.754763-6-hch@lst.de>
@ 2021-06-15 14:10   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:10 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:14PM +0200, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> This is intended as a replacement API for device_bind_driver(). It has at
> least the following benefits:
> 
> - Internal locking. Few of the users of device_bind_driver() follow the
>   locking rules
> 
> - Calls device driver probe() internally. Notably this means that devm
>   support for probe works correctly as probe() error will call
>   devres_release_all()
> 
> - struct device_driver -> dev_groups is supported
> 
> - Simplified calling convention, no need to manually call probe().
> 
> The general usage is for situations that already know what driver to bind
> and need to ensure the bind is synchronized with other logic. Call
> device_driver_attach() after device_add().
> 
> If probe() returns a failure then this will be preserved up through to the
> error return of device_driver_attach().
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> ---

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
       [not found] ` <20210615133519.754763-7-hch@lst.de>
@ 2021-06-15 14:10   ` Greg Kroah-Hartman
  2021-06-16 20:20   ` Kirti Wankhede
  1 sibling, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:10 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:15PM +0200, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> For some reason the vfio_mdev shim mdev_driver has its own module and
> kconfig. As the next patch requires access to it from mdev.ko merge the
> two modules together and remove VFIO_MDEV_DEVICE.
> 
> A later patch deletes this driver entirely.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  Documentation/s390/vfio-ap.rst   |  1 -
>  arch/s390/Kconfig                |  2 +-
>  drivers/gpu/drm/i915/Kconfig     |  2 +-
>  drivers/vfio/mdev/Kconfig        |  7 -------
>  drivers/vfio/mdev/Makefile       |  3 +--
>  drivers/vfio/mdev/mdev_core.c    | 16 ++++++++++++++--
>  drivers/vfio/mdev/mdev_private.h |  2 ++
>  drivers/vfio/mdev/vfio_mdev.c    | 24 +-----------------------
>  samples/Kconfig                  |  6 +++---
>  9 files changed, 23 insertions(+), 40 deletions(-)
> 

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind
       [not found] ` <20210615133519.754763-8-hch@lst.de>
  2021-06-15 14:06   ` [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind Cornelia Huck
@ 2021-06-15 14:11   ` Greg Kroah-Hartman
  2021-06-16  0:00     ` Jason Gunthorpe
  2021-06-16 20:20   ` Kirti Wankhede
  2 siblings, 1 reply; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:11 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:16PM +0200, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> This allows a mdev driver to opt out of using vfio_mdev.c, instead the
> driver will provide a 'struct mdev_driver' and register directly with the
> driver core.
> 
> Much of mdev_parent_ops becomes unused in this mode:
> - create()/remove() are done via the mdev_driver probe()/remove()
> - mdev_attr_groups becomes mdev_driver driver.dev_groups
> - Wrapper function callbacks are replaced with the same ones from
>   struct vfio_device_ops
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Messy, but ok...

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 08/10] vfio/mtty: Convert to use vfio_register_group_dev()
       [not found] ` <20210615133519.754763-9-hch@lst.de>
@ 2021-06-15 14:11   ` Greg Kroah-Hartman
  2021-06-16 20:20   ` Kirti Wankhede
  1 sibling, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:11 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:17PM +0200, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> This is straightforward conversion, the mdev_state is actually serving as
> the vfio_device and we can replace all the mdev_get_drvdata()'s and the
> wonky dead code with a simple container_of()
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  samples/vfio-mdev/mtty.c | 185 ++++++++++++++++++---------------------
>  1 file changed, 83 insertions(+), 102 deletions(-)


Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 09/10] vfio/mdpy: Convert to use vfio_register_group_dev()
       [not found] ` <20210615133519.754763-10-hch@lst.de>
@ 2021-06-15 14:12   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:12 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:18PM +0200, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> This is straightforward conversion, the mdev_state is actually serving as
> the vfio_device and we can replace all the mdev_get_drvdata()'s and the
> wonky dead code with a simple container_of().
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  samples/vfio-mdev/mdpy.c | 159 ++++++++++++++++++++++-----------------
>  1 file changed, 88 insertions(+), 71 deletions(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 10/10] vfio/mbochs: Convert to use vfio_register_group_dev()
       [not found] ` <20210615133519.754763-11-hch@lst.de>
@ 2021-06-15 14:12   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:12 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Alex Williamson, Rodrigo Vivi,
	Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 03:35:19PM +0200, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> This is straightforward conversion, the mdev_state is actually serving as
> the vfio_device and we can replace all the mdev_get_drvdata()'s and the
> wonky dead code with a simple container_of().
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  samples/vfio-mdev/mbochs.c | 163 +++++++++++++++++++++----------------
>  1 file changed, 91 insertions(+), 72 deletions(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Allow mdev drivers to directly create the vfio_device (v3)
       [not found] <20210615133519.754763-1-hch@lst.de>
                   ` (4 preceding siblings ...)
       [not found] ` <20210615133519.754763-11-hch@lst.de>
@ 2021-06-15 19:35 ` Alex Williamson
  2021-06-15 20:35   ` Jason Gunthorpe
       [not found] ` <20210615133519.754763-3-hch@lst.de>
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 25+ messages in thread
From: Alex Williamson @ 2021-06-15 19:35 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Rodrigo Vivi, Tony Krowiak,
	Greg Kroah-Hartman, Cornelia Huck

On Tue, 15 Jun 2021 15:35:09 +0200
Christoph Hellwig <hch@lst.de> wrote:

> This is my alternative take on this series from Jason:
> 
> https://lore.kernel.org/dri-devel/87czsszi9i.fsf@redhat.com/T/
> 
> The mdev/vfio parts are exactly the same, but this solves the driver core
> changes for the direct probing without the in/out flag that Greg hated,
> which cause a little more work, but probably make the result better.
> 
> Original decription from Jason below:
> 
> 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's struct vfio_device and the actual
> device driver.
> 
> Instead, allow mdev drivers implement an actual struct mdev_driver and
> directly call vfio_register_group_dev() in the probe() function for the
> mdev. 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.
> 
> Ultimately converting all the drivers unlocks a fair number of additional
> VFIO simplifications and cleanups.

Looks like we need an update to
Documentation/driver-api/vfio-mediated-device.rst to go along with
this.

Also, if we're preserving compatibility with the "legacy"
mdev_parent_ops callbacks without deprecating them, does it really make
sense to convert every one of the sample drivers to this new direct
registration?  Thanks,

Alex


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 04/10] driver core: Don't return EPROBE_DEFER to userspace during sysfs bind
       [not found] ` <20210615133519.754763-5-hch@lst.de>
  2021-06-15 14:03   ` [PATCH 04/10] driver core: Don't return EPROBE_DEFER to userspace during sysfs bind Cornelia Huck
@ 2021-06-15 19:36   ` Alex Williamson
  1 sibling, 0 replies; 25+ messages in thread
From: Alex Williamson @ 2021-06-15 19:36 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, Jason Gunthorpe, intel-gfx, Jason Herne,
	Vasily Gorbik, Heiko Carstens, Rodrigo Vivi, Tony Krowiak,
	Greg Kroah-Hartman, Cornelia Huck

On Tue, 15 Jun 2021 15:35:13 +0200
Christoph Hellwig <hch@lst.de> wrote:

> @@ -547,10 +538,9 @@ static int call_driver_probe(struct device *dev, struct device_driver *drv)
>  
>  static int really_probe(struct device *dev, struct device_driver *drv)
>  {
> -	int local_trigger_count = atomic_read(&deferred_trigger_count);
>  	bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
>  			   !drv->suppress_bind_attrs;
> -	int ret = -EPROBE_DEFER, probe_ret = 0;
> +	int ret, probe_ret = 0;

nit, probe_ret initialization could be removed with this patch too.

>  
>  	if (defer_all_probes) {
>  		/*
> @@ -559,17 +549,13 @@ static int really_probe(struct device *dev, struct device_driver *drv)
>  		 * wait_for_device_probe() right after that to avoid any races.
>  		 */
>  		dev_dbg(dev, "Driver %s force probe deferral\n", drv->name);
> -		driver_deferred_probe_add(dev);
> -		return ret;
> +		return -EPROBE_DEFER;
>  	}
>  
>  	ret = device_links_check_suppliers(dev);
> -	if (ret == -EPROBE_DEFER)
> -		driver_deferred_probe_add_trigger(dev, local_trigger_count);
>  	if (ret)
>  		return ret;
>  
> -	atomic_inc(&probe_count);
>  	pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
>  		 drv->bus->name, __func__, drv->name, dev_name(dev));
>  	if (!list_empty(&dev->devres_head)) {
> @@ -681,11 +667,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
>  		dev->pm_domain->dismiss(dev);
>  	pm_runtime_reinit(dev);
>  	dev_pm_set_driver_flags(dev, 0);
> -	if (probe_ret == -EPROBE_DEFER)
> -		driver_deferred_probe_add_trigger(dev, local_trigger_count);

This was the only possible uninitialized use case afaict.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Allow mdev drivers to directly create the vfio_device (v3)
  2021-06-15 19:35 ` Allow mdev drivers to directly create the vfio_device (v3) Alex Williamson
@ 2021-06-15 20:35   ` Jason Gunthorpe
       [not found]     ` <20210616031313.GA24992@lst.de>
  0 siblings, 1 reply; 25+ messages in thread
From: Jason Gunthorpe @ 2021-06-15 20:35 UTC (permalink / raw)
  To: Alex Williamson
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	Christoph Hellwig, linux-s390, Jonathan Corbet,
	Rafael J. Wysocki, Halil Pasic, Christian Borntraeger, intel-gfx,
	Jason Herne, Vasily Gorbik, Heiko Carstens, Rodrigo Vivi,
	Tony Krowiak, Greg Kroah-Hartman, Cornelia Huck

On Tue, Jun 15, 2021 at 01:35:49PM -0600, Alex Williamson wrote:
> On Tue, 15 Jun 2021 15:35:09 +0200
> Christoph Hellwig <hch@lst.de> wrote:
> 
> > This is my alternative take on this series from Jason:
> > 
> > https://lore.kernel.org/dri-devel/87czsszi9i.fsf@redhat.com/T/
> > 
> > The mdev/vfio parts are exactly the same, but this solves the driver core
> > changes for the direct probing without the in/out flag that Greg hated,
> > which cause a little more work, but probably make the result better.
> > 
> > Original decription from Jason below:
> > 
> > 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's struct vfio_device and the actual
> > device driver.
> > 
> > Instead, allow mdev drivers implement an actual struct mdev_driver and
> > directly call vfio_register_group_dev() in the probe() function for the
> > mdev. 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.
> > 
> > Ultimately converting all the drivers unlocks a fair number of additional
> > VFIO simplifications and cleanups.
> 
> Looks like we need an update to
> Documentation/driver-api/vfio-mediated-device.rst to go along with
> this.

I have those updates in the patch that removes the old way, do you
want to move them forward to here?

> Also, if we're preserving compatibility with the "legacy"
> mdev_parent_ops callbacks without deprecating them,

I view this as breaking up the work into manageable steps and patch
series. This is already at 10 patches just to provide the
infrastructure. The next steps will be to move the driver conversions
ahead.

> does it really make sense to convert every one of the sample drivers
> to this new direct registration?  

Yes, the rest of the drivers will get converted eventually too. There
is no reason to hold things back. Depending on timelines we might be
able to get AP into this cycle too...

Jason

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind
  2021-06-15 14:11   ` Greg Kroah-Hartman
@ 2021-06-16  0:00     ` Jason Gunthorpe
  2021-06-16  6:39       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 25+ messages in thread
From: Jason Gunthorpe @ 2021-06-16  0:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	Christoph Hellwig, linux-s390, Jonathan Corbet,
	Rafael J. Wysocki, Halil Pasic, Christian Borntraeger, intel-gfx,
	Jason Herne, Vasily Gorbik, Heiko Carstens, Alex Williamson,
	Rodrigo Vivi, Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 04:11:29PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Jun 15, 2021 at 03:35:16PM +0200, Christoph Hellwig wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > 
> > This allows a mdev driver to opt out of using vfio_mdev.c, instead the
> > driver will provide a 'struct mdev_driver' and register directly with the
> > driver core.
> > 
> > Much of mdev_parent_ops becomes unused in this mode:
> > - create()/remove() are done via the mdev_driver probe()/remove()
> > - mdev_attr_groups becomes mdev_driver driver.dev_groups
> > - Wrapper function callbacks are replaced with the same ones from
> >   struct vfio_device_ops
> > 
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Messy, but ok...

Is there something you'd like to see changed, eg in later patches?
This whole work still has another approx 30 patches to go and much of
this ends up being erased once the drivers are all converted.

Jason

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind
  2021-06-16  0:00     ` Jason Gunthorpe
@ 2021-06-16  6:39       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 25+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-16  6:39 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	Christoph Hellwig, linux-s390, Jonathan Corbet,
	Rafael J. Wysocki, Halil Pasic, Christian Borntraeger, intel-gfx,
	Jason Herne, Vasily Gorbik, Heiko Carstens, Alex Williamson,
	Rodrigo Vivi, Tony Krowiak, Cornelia Huck

On Tue, Jun 15, 2021 at 09:00:40PM -0300, Jason Gunthorpe wrote:
> On Tue, Jun 15, 2021 at 04:11:29PM +0200, Greg Kroah-Hartman wrote:
> > On Tue, Jun 15, 2021 at 03:35:16PM +0200, Christoph Hellwig wrote:
> > > From: Jason Gunthorpe <jgg@nvidia.com>
> > > 
> > > This allows a mdev driver to opt out of using vfio_mdev.c, instead the
> > > driver will provide a 'struct mdev_driver' and register directly with the
> > > driver core.
> > > 
> > > Much of mdev_parent_ops becomes unused in this mode:
> > > - create()/remove() are done via the mdev_driver probe()/remove()
> > > - mdev_attr_groups becomes mdev_driver driver.dev_groups
> > > - Wrapper function callbacks are replaced with the same ones from
> > >   struct vfio_device_ops
> > > 
> > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > 
> > Messy, but ok...
> 
> Is there something you'd like to see changed, eg in later patches?
> This whole work still has another approx 30 patches to go and much of
> this ends up being erased once the drivers are all converted.

If this mostly gets removed in the end, I'm happy.  Let's see how it
looks after all of that is done.  This is going forward in the right
way, so I do not object to this at all.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Allow mdev drivers to directly create the vfio_device (v3)
       [not found]     ` <20210616031313.GA24992@lst.de>
@ 2021-06-16 14:03       ` Jason Gunthorpe
  0 siblings, 0 replies; 25+ messages in thread
From: Jason Gunthorpe @ 2021-06-16 14:03 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kvm, linux-doc, David Airlie, dri-devel, Kirti Wankhede,
	linux-s390, Jonathan Corbet, Rafael J. Wysocki, Halil Pasic,
	Christian Borntraeger, intel-gfx, Jason Herne, Vasily Gorbik,
	Heiko Carstens, Alex Williamson, Rodrigo Vivi, Tony Krowiak,
	Greg Kroah-Hartman, Cornelia Huck

On Wed, Jun 16, 2021 at 05:13:13AM +0200, Christoph Hellwig wrote:
> On Tue, Jun 15, 2021 at 05:35:15PM -0300, Jason Gunthorpe wrote:
> > Yes, the rest of the drivers will get converted eventually too. There
> > is no reason to hold things back. Depending on timelines we might be
> > able to get AP into this cycle too...
> 
> And I have a WIP tree to get rid of the weird indirections in i915/gvt.
> Once I find some cycles to test that I'll also test the vfio interface
> conversion.  This will probably be for next cycle, though.

Wow, that is a major project cool

I was going to ping the gvt guys once we get this landed

Jason

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 02/10] driver core: Better distinguish probe errors in really_probe
       [not found] ` <20210615133519.754763-3-hch@lst.de>
  2021-06-15 13:53   ` [PATCH 02/10] driver core: Better distinguish probe errors in really_probe Cornelia Huck
  2021-06-15 14:09   ` Greg Kroah-Hartman
@ 2021-06-16 20:20   ` Kirti Wankhede
  2 siblings, 0 replies; 25+ messages in thread
From: Kirti Wankhede @ 2021-06-16 20:20 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, Cornelia Huck,
	linux-doc, dri-devel, Halil Pasic, Christian Borntraeger,
	Rodrigo Vivi, Rafael J. Wysocki, intel-gfx



On 6/15/2021 7:05 PM, Christoph Hellwig wrote:
> really_probe tries to special case errors from ->probe, but due to all
> other initialization added to the function over time now a lot of
> internal errors hit that code path as well.  Untangle that by adding
> a new probe_err local variable and apply the special casing only to
> that.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>


Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
       [not found] ` <20210615133519.754763-7-hch@lst.de>
  2021-06-15 14:10   ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Greg Kroah-Hartman
@ 2021-06-16 20:20   ` Kirti Wankhede
  1 sibling, 0 replies; 25+ messages in thread
From: Kirti Wankhede @ 2021-06-16 20:20 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, Cornelia Huck,
	linux-doc, dri-devel, Halil Pasic, Christian Borntraeger,
	Rodrigo Vivi, Rafael J. Wysocki, intel-gfx



On 6/15/2021 7:05 PM, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> For some reason the vfio_mdev shim mdev_driver has its own module and
> kconfig. As the next patch requires access to it from mdev.ko merge the
> two modules together and remove VFIO_MDEV_DEVICE.
> 
> A later patch deletes this driver entirely.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind
       [not found] ` <20210615133519.754763-8-hch@lst.de>
  2021-06-15 14:06   ` [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind Cornelia Huck
  2021-06-15 14:11   ` Greg Kroah-Hartman
@ 2021-06-16 20:20   ` Kirti Wankhede
  2 siblings, 0 replies; 25+ messages in thread
From: Kirti Wankhede @ 2021-06-16 20:20 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, Cornelia Huck,
	linux-doc, dri-devel, Halil Pasic, Christian Borntraeger,
	Rodrigo Vivi, Rafael J. Wysocki, intel-gfx



On 6/15/2021 7:05 PM, Christoph Hellwig wrote:
> From: Jason Gunthorpe <jgg@nvidia.com>
> 
> This allows a mdev driver to opt out of using vfio_mdev.c, instead the
> driver will provide a 'struct mdev_driver' and register directly with the
> driver core.
> 
> Much of mdev_parent_ops becomes unused in this mode:
> - create()/remove() are done via the mdev_driver probe()/remove()
> - mdev_attr_groups becomes mdev_driver driver.dev_groups
> - Wrapper function callbacks are replaced with the same ones from
>    struct vfio_device_ops
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/vfio/mdev/mdev_core.c   | 30 ++++++++++++++++++++++--------
>   drivers/vfio/mdev/mdev_driver.c | 10 ++++++++++
>   include/linux/mdev.h            |  2 ++
>   3 files changed, 34 insertions(+), 8 deletions(-)

Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 08/10] vfio/mtty: Convert to use vfio_register_group_dev()
       [not found] ` <20210615133519.754763-9-hch@lst.de>
  2021-06-15 14:11   ` [PATCH 08/10] vfio/mtty: Convert to use vfio_register_group_dev() Greg Kroah-Hartman
@ 2021-06-16 20:20   ` Kirti Wankhede
  1 sibling, 0 replies; 25+ messages in thread
From: Kirti Wankhede @ 2021-06-16 20:20 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, Cornelia Huck,
	linux-doc, dri-devel, Halil Pasic, Christian Borntraeger,
	Rodrigo Vivi, Rafael J. Wysocki, intel-gfx


> -static int mtty_reset(struct mdev_device *mdev)
> +static int mtty_reset(struct mdev_state *mdev_stte)

Nit pick:
s/mdev_stte/mdev_state


>   
> +static const struct vfio_device_ops mtty_dev_ops = {
> +	.name = "vfio-mdev",

I think name should be different that 'vfio-mdev', probably
'vfio-mdev-mtty' or 'vfio-mtty'

Rest looks fine to me.

Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
       [not found] ` <20210614150846.4111871-7-hch@lst.de>
@ 2021-06-15 10:50   ` Cornelia Huck
  0 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2021-06-15 10:50 UTC (permalink / raw)
  To: Christoph Hellwig, Greg Kroah-Hartman, Jason Gunthorpe,
	Alex Williamson, Kirti Wankhede
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, linux-doc, dri-devel,
	Halil Pasic, Christian Borntraeger, Rodrigo Vivi,
	Rafael J. Wysocki, intel-gfx

On Mon, Jun 14 2021, Christoph Hellwig <hch@lst.de> wrote:

> From: Jason Gunthorpe <jgg@nvidia.com>
>
> For some reason the vfio_mdev shim mdev_driver has its own module and
> kconfig. As the next patch requires access to it from mdev.ko merge the
> two modules together and remove VFIO_MDEV_DEVICE.
>
> A later patch deletes this driver entirely.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  Documentation/s390/vfio-ap.rst   |  1 -
>  arch/s390/Kconfig                |  2 +-
>  drivers/gpu/drm/i915/Kconfig     |  2 +-
>  drivers/vfio/mdev/Kconfig        |  7 -------
>  drivers/vfio/mdev/Makefile       |  3 +--
>  drivers/vfio/mdev/mdev_core.c    | 16 ++++++++++++++--
>  drivers/vfio/mdev/mdev_private.h |  2 ++
>  drivers/vfio/mdev/vfio_mdev.c    | 24 +-----------------------
>  samples/Kconfig                  |  6 +++---
>  9 files changed, 23 insertions(+), 40 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
  2021-06-11 12:40   ` Cornelia Huck
@ 2021-06-14 12:35     ` Jason Gunthorpe
  0 siblings, 0 replies; 25+ messages in thread
From: Jason Gunthorpe @ 2021-06-14 12:35 UTC (permalink / raw)
  To: Cornelia Huck, Christoph Hellwig
  Cc: Tony Krowiak, Jason Herne, kvm, Vasily Gorbik, Jonathan Corbet,
	David Airlie, linux-s390, Heiko Carstens, linux-doc,
	Kirti Wankhede, dri-devel, Halil Pasic, Christian Borntraeger,
	Alex Williamson, Rodrigo Vivi, intel-gfx

On Fri, Jun 11, 2021 at 02:40:41PM +0200, Cornelia Huck wrote:
> On Mon, Jun 07 2021, Jason Gunthorpe <jgg@nvidia.com> wrote:
> 
> > For some reason the vfio_mdev shim mdev_driver has its own module and
> > kconfig. As the next patch requires access to it from mdev.ko merge the
> > two modules together and remove VFIO_MDEV_DEVICE.
> >
> > A later patch deletes this driver entirely.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> >  Documentation/s390/vfio-ap.rst   |  1 -
> >  arch/s390/Kconfig                |  2 +-
> >  drivers/gpu/drm/i915/Kconfig     |  2 +-
> >  drivers/vfio/mdev/Kconfig        |  7 -------
> >  drivers/vfio/mdev/Makefile       |  3 +--
> >  drivers/vfio/mdev/mdev_core.c    | 16 ++++++++++++++--
> >  drivers/vfio/mdev/mdev_private.h |  2 ++
> >  drivers/vfio/mdev/vfio_mdev.c    | 24 +-----------------------
> >  samples/Kconfig                  |  6 +++---
> >  9 files changed, 23 insertions(+), 40 deletions(-)
> 
> I think you missed my earlier
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Yes, my mistake, I didn't think there were any tags in the v1 posting

Thanks,
Jason

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
  2021-06-08  0:55 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
@ 2021-06-11 12:40   ` Cornelia Huck
  2021-06-14 12:35     ` Jason Gunthorpe
  0 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2021-06-11 12:40 UTC (permalink / raw)
  To: Jason Gunthorpe, David Airlie, Tony Krowiak, Alex Williamson,
	Christian Borntraeger, Jonathan Corbet, Daniel Vetter, dri-devel,
	Vasily Gorbik, Heiko Carstens, intel-gfx, Jani Nikula,
	Jason Herne, Joonas Lahtinen, kvm, Kirti Wankhede, linux-doc,
	linux-s390, Halil Pasic, Rodrigo Vivi

On Mon, Jun 07 2021, Jason Gunthorpe <jgg@nvidia.com> wrote:

> For some reason the vfio_mdev shim mdev_driver has its own module and
> kconfig. As the next patch requires access to it from mdev.ko merge the
> two modules together and remove VFIO_MDEV_DEVICE.
>
> A later patch deletes this driver entirely.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  Documentation/s390/vfio-ap.rst   |  1 -
>  arch/s390/Kconfig                |  2 +-
>  drivers/gpu/drm/i915/Kconfig     |  2 +-
>  drivers/vfio/mdev/Kconfig        |  7 -------
>  drivers/vfio/mdev/Makefile       |  3 +--
>  drivers/vfio/mdev/mdev_core.c    | 16 ++++++++++++++--
>  drivers/vfio/mdev/mdev_private.h |  2 ++
>  drivers/vfio/mdev/vfio_mdev.c    | 24 +-----------------------
>  samples/Kconfig                  |  6 +++---
>  9 files changed, 23 insertions(+), 40 deletions(-)

I think you missed my earlier

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
  2021-06-08  0:55 [PATCH 00/10] Allow mdev drivers to directly create the vfio_device Jason Gunthorpe
@ 2021-06-08  0:55 ` Jason Gunthorpe
  2021-06-11 12:40   ` Cornelia Huck
  0 siblings, 1 reply; 25+ messages in thread
From: Jason Gunthorpe @ 2021-06-08  0:55 UTC (permalink / raw)
  To: David Airlie, Tony Krowiak, Alex Williamson,
	Christian Borntraeger, Cornelia Huck, Jonathan Corbet,
	Daniel Vetter, dri-devel, Vasily Gorbik, Heiko Carstens,
	intel-gfx, Jani Nikula, Jason Herne, Joonas Lahtinen, kvm,
	Kirti Wankhede, linux-doc, linux-s390, Halil Pasic, Rodrigo Vivi

For some reason the vfio_mdev shim mdev_driver has its own module and
kconfig. As the next patch requires access to it from mdev.ko merge the
two modules together and remove VFIO_MDEV_DEVICE.

A later patch deletes this driver entirely.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 Documentation/s390/vfio-ap.rst   |  1 -
 arch/s390/Kconfig                |  2 +-
 drivers/gpu/drm/i915/Kconfig     |  2 +-
 drivers/vfio/mdev/Kconfig        |  7 -------
 drivers/vfio/mdev/Makefile       |  3 +--
 drivers/vfio/mdev/mdev_core.c    | 16 ++++++++++++++--
 drivers/vfio/mdev/mdev_private.h |  2 ++
 drivers/vfio/mdev/vfio_mdev.c    | 24 +-----------------------
 samples/Kconfig                  |  6 +++---
 9 files changed, 23 insertions(+), 40 deletions(-)

diff --git a/Documentation/s390/vfio-ap.rst b/Documentation/s390/vfio-ap.rst
index e15436599086b7..f57ae621f33e89 100644
--- a/Documentation/s390/vfio-ap.rst
+++ b/Documentation/s390/vfio-ap.rst
@@ -514,7 +514,6 @@ These are the steps:
    * S390_AP_IOMMU
    * VFIO
    * VFIO_MDEV
-   * VFIO_MDEV_DEVICE
    * KVM
 
    If using make menuconfig select the following to build the vfio_ap module::
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index b4c7c34069f81a..ea63fd22e1198a 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -768,7 +768,7 @@ config VFIO_CCW
 config VFIO_AP
 	def_tristate n
 	prompt "VFIO support for AP devices"
-	depends on S390_AP_IOMMU && VFIO_MDEV_DEVICE && KVM
+	depends on S390_AP_IOMMU && VFIO_MDEV && KVM
 	depends on ZCRYPT
 	help
 		This driver grants access to Adjunct Processor (AP) devices
diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 69f57ca9c68d73..9ab1cecd69b2a0 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -126,7 +126,7 @@ config DRM_I915_GVT_KVMGT
 	tristate "Enable KVM/VFIO support for Intel GVT-g"
 	depends on DRM_I915_GVT
 	depends on KVM
-	depends on VFIO_MDEV && VFIO_MDEV_DEVICE
+	depends on VFIO_MDEV
 	default n
 	help
 	  Choose this option if you want to enable KVMGT support for
diff --git a/drivers/vfio/mdev/Kconfig b/drivers/vfio/mdev/Kconfig
index 5da27f2100f9bd..763c877a1318bc 100644
--- a/drivers/vfio/mdev/Kconfig
+++ b/drivers/vfio/mdev/Kconfig
@@ -9,10 +9,3 @@ config VFIO_MDEV
 	  See Documentation/driver-api/vfio-mediated-device.rst for more details.
 
 	  If you don't know what do here, say N.
-
-config VFIO_MDEV_DEVICE
-	tristate "VFIO driver for Mediated devices"
-	depends on VFIO && VFIO_MDEV
-	default n
-	help
-	  VFIO based driver for Mediated devices.
diff --git a/drivers/vfio/mdev/Makefile b/drivers/vfio/mdev/Makefile
index 101516fdf3753e..ff9ecd80212503 100644
--- a/drivers/vfio/mdev/Makefile
+++ b/drivers/vfio/mdev/Makefile
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o
+mdev-y := mdev_core.o mdev_sysfs.o mdev_driver.o vfio_mdev.o
 
 obj-$(CONFIG_VFIO_MDEV) += mdev.o
-obj-$(CONFIG_VFIO_MDEV_DEVICE) += vfio_mdev.o
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index 2a85d6fcb7ddd0..ff8c1a84516698 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -360,11 +360,24 @@ int mdev_device_remove(struct mdev_device *mdev)
 
 static int __init mdev_init(void)
 {
-	return mdev_bus_register();
+	int rc;
+
+	rc = mdev_bus_register();
+	if (rc)
+		return rc;
+	rc = mdev_register_driver(&vfio_mdev_driver);
+	if (rc)
+		goto err_bus;
+	return 0;
+err_bus:
+	mdev_bus_unregister();
+	return rc;
 }
 
 static void __exit mdev_exit(void)
 {
+	mdev_unregister_driver(&vfio_mdev_driver);
+
 	if (mdev_bus_compat_class)
 		class_compat_unregister(mdev_bus_compat_class);
 
@@ -378,4 +391,3 @@ MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_SOFTDEP("post: vfio_mdev");
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index 6999c89db7b162..afbad7b0a14a17 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -37,6 +37,8 @@ struct mdev_type {
 #define to_mdev_type(_kobj)		\
 	container_of(_kobj, struct mdev_type, kobj)
 
+extern struct mdev_driver vfio_mdev_driver;
+
 int  parent_create_sysfs_files(struct mdev_parent *parent);
 void parent_remove_sysfs_files(struct mdev_parent *parent);
 
diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
index 922729071c5a8e..d5b4eede47c1a5 100644
--- a/drivers/vfio/mdev/vfio_mdev.c
+++ b/drivers/vfio/mdev/vfio_mdev.c
@@ -17,10 +17,6 @@
 
 #include "mdev_private.h"
 
-#define DRIVER_VERSION  "0.1"
-#define DRIVER_AUTHOR   "NVIDIA Corporation"
-#define DRIVER_DESC     "VFIO based driver for Mediated device"
-
 static int vfio_mdev_open(struct vfio_device *core_vdev)
 {
 	struct mdev_device *mdev = to_mdev_device(core_vdev->dev);
@@ -151,7 +147,7 @@ static void vfio_mdev_remove(struct mdev_device *mdev)
 	kfree(vdev);
 }
 
-static struct mdev_driver vfio_mdev_driver = {
+struct mdev_driver vfio_mdev_driver = {
 	.driver = {
 		.name = "vfio_mdev",
 		.owner = THIS_MODULE,
@@ -160,21 +156,3 @@ static struct mdev_driver vfio_mdev_driver = {
 	.probe	= vfio_mdev_probe,
 	.remove	= vfio_mdev_remove,
 };
-
-static int __init vfio_mdev_init(void)
-{
-	return mdev_register_driver(&vfio_mdev_driver);
-}
-
-static void __exit vfio_mdev_exit(void)
-{
-	mdev_unregister_driver(&vfio_mdev_driver);
-}
-
-module_init(vfio_mdev_init)
-module_exit(vfio_mdev_exit)
-
-MODULE_VERSION(DRIVER_VERSION);
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/samples/Kconfig b/samples/Kconfig
index b5a1a7aa7e23ab..b0503ef058d334 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -154,14 +154,14 @@ config SAMPLE_UHID
 
 config SAMPLE_VFIO_MDEV_MTTY
 	tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
-	depends on VFIO_MDEV_DEVICE && m
+	depends on VFIO_MDEV && m
 	help
 	  Build a virtual tty sample driver for use as a VFIO
 	  mediated device
 
 config SAMPLE_VFIO_MDEV_MDPY
 	tristate "Build VFIO mdpy example mediated device sample code -- loadable modules only"
-	depends on VFIO_MDEV_DEVICE && m
+	depends on VFIO_MDEV && m
 	help
 	  Build a virtual display sample driver for use as a VFIO
 	  mediated device.  It is a simple framebuffer and supports
@@ -178,7 +178,7 @@ config SAMPLE_VFIO_MDEV_MDPY_FB
 
 config SAMPLE_VFIO_MDEV_MBOCHS
 	tristate "Build VFIO mdpy example mediated device sample code -- loadable modules only"
-	depends on VFIO_MDEV_DEVICE && m
+	depends on VFIO_MDEV && m
 	select DMA_SHARED_BUFFER
 	help
 	  Build a virtual display sample driver for use as a VFIO
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-06-16 20:21 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210615133519.754763-1-hch@lst.de>
     [not found] ` <20210615133519.754763-5-hch@lst.de>
2021-06-15 14:03   ` [PATCH 04/10] driver core: Don't return EPROBE_DEFER to userspace during sysfs bind Cornelia Huck
2021-06-15 19:36   ` Alex Williamson
     [not found] ` <20210615133519.754763-8-hch@lst.de>
2021-06-15 14:06   ` [PATCH 07/10] vfio/mdev: Allow the mdev_parent_ops to specify the device driver to bind Cornelia Huck
2021-06-15 14:11   ` Greg Kroah-Hartman
2021-06-16  0:00     ` Jason Gunthorpe
2021-06-16  6:39       ` Greg Kroah-Hartman
2021-06-16 20:20   ` Kirti Wankhede
     [not found] ` <20210615133519.754763-6-hch@lst.de>
2021-06-15 14:10   ` [PATCH 05/10] driver core: Export device_driver_attach() Greg Kroah-Hartman
     [not found] ` <20210615133519.754763-10-hch@lst.de>
2021-06-15 14:12   ` [PATCH 09/10] vfio/mdpy: Convert to use vfio_register_group_dev() Greg Kroah-Hartman
     [not found] ` <20210615133519.754763-11-hch@lst.de>
2021-06-15 14:12   ` [PATCH 10/10] vfio/mbochs: " Greg Kroah-Hartman
2021-06-15 19:35 ` Allow mdev drivers to directly create the vfio_device (v3) Alex Williamson
2021-06-15 20:35   ` Jason Gunthorpe
     [not found]     ` <20210616031313.GA24992@lst.de>
2021-06-16 14:03       ` Jason Gunthorpe
     [not found] ` <20210615133519.754763-3-hch@lst.de>
2021-06-15 13:53   ` [PATCH 02/10] driver core: Better distinguish probe errors in really_probe Cornelia Huck
2021-06-15 14:09     ` Greg Kroah-Hartman
2021-06-15 14:09   ` Greg Kroah-Hartman
2021-06-16 20:20   ` Kirti Wankhede
     [not found] ` <20210615133519.754763-7-hch@lst.de>
2021-06-15 14:10   ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Greg Kroah-Hartman
2021-06-16 20:20   ` Kirti Wankhede
     [not found] ` <20210615133519.754763-9-hch@lst.de>
2021-06-15 14:11   ` [PATCH 08/10] vfio/mtty: Convert to use vfio_register_group_dev() Greg Kroah-Hartman
2021-06-16 20:20   ` Kirti Wankhede
     [not found] <20210614150846.4111871-1-hch@lst.de>
     [not found] ` <20210614150846.4111871-7-hch@lst.de>
2021-06-15 10:50   ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Cornelia Huck
2021-06-08  0:55 [PATCH 00/10] Allow mdev drivers to directly create the vfio_device Jason Gunthorpe
2021-06-08  0:55 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
2021-06-11 12:40   ` Cornelia Huck
2021-06-14 12:35     ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).