* [PATCH 00/10] Allow mdev drivers to directly create the vfio_device
@ 2021-06-08 0:55 Jason Gunthorpe
2021-06-08 0:55 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
` (2 more replies)
0 siblings, 3 replies; 14+ 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, Greg Kroah-Hartman,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, Kirti Wankhede, linux-doc, linux-s390,
Halil Pasic, Rafael J. Wysocki, Rodrigo Vivi
Cc: Christoph Hellwig
This is a "v3" of the previous posted full conversion:
https://lore.kernel.org/r/0-v2-7667f42c9bad+935-vfio3_jgg@nvidia.com
Without the trailing patches that are running into complications:
- The CCW conversion has some complicated remarks
- AP is waiting for some locking stuff to get worked out
- No feedback on GT
- The license change topic for removing vfio_mdev.c
Getting the baseline functionality merged will allow Intel's IDXD mdev
driver to advance. It has already been RFC posted in the new format:
https://lore.kernel.org/kvm/162164243591.261970.3439987543338120797.stgit@djiang5-desk3.ch.intel.com/
This series includes base infrastructure and the sample conversions. The
remaining four issues can be sorted out one by one.
The major change in v3 is to enhance the driver core support for binding
based on the request from Christoph Hellwig and Dan Williams. Based on
some light analysis this looks broadly useful:
https://lore.kernel.org/kvm/20210428233856.GY1370958@nvidia.com/
====
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.
v3:
- Use device_driver_attach() from the driver core
- 5 new patches to make device_driver_attach() exported and usable for this
- Remove trailing patches for now
v2: https://lore.kernel.org/r/0-v2-7667f42c9bad+935-vfio3_jgg@nvidia.com
- Keep && m in samples kconfig
- Restore accidently squashed removeal of vfio_mdev.c
- Remove indirections to call bus_register()/bus_unregister()
- Reflow long doc lines
v1: https://lore.kernel.org/r/0-v1-d88406ed308e+418-vfio3_jgg@nvidia.com
Jason Gunthorpe (10):
driver core: Do not continue searching for drivers if deferred probe
is used
driver core: Pull required checks into driver_probe_device()
driver core: Flow the return code from ->probe() through to sysfs bind
driver core: Don't return EPROBE_DEFER to userspace during sysfs bind
driver core: Export device_driver_attach()
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()
Documentation/s390/vfio-ap.rst | 1 -
arch/s390/Kconfig | 2 +-
drivers/base/base.h | 1 -
drivers/base/bus.c | 6 +-
drivers/base/dd.c | 116 ++++++++++++-------
drivers/gpu/drm/i915/Kconfig | 2 +-
drivers/vfio/mdev/Kconfig | 7 --
drivers/vfio/mdev/Makefile | 3 +-
drivers/vfio/mdev/mdev_core.c | 46 ++++++--
drivers/vfio/mdev/mdev_driver.c | 10 ++
drivers/vfio/mdev/mdev_private.h | 2 +
drivers/vfio/mdev/vfio_mdev.c | 24 +---
include/linux/device.h | 2 +
include/linux/mdev.h | 2 +
samples/Kconfig | 6 +-
samples/vfio-mdev/mbochs.c | 163 +++++++++++++++------------
samples/vfio-mdev/mdpy.c | 159 ++++++++++++++------------
samples/vfio-mdev/mtty.c | 185 ++++++++++++++-----------------
18 files changed, 397 insertions(+), 340 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 14+ 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-08 6:20 ` Christoph Hellwig
2021-06-11 12:40 ` Cornelia Huck
2021-06-08 6:22 ` [PATCH 00/10] Allow mdev drivers to directly create the vfio_device Christoph Hellwig
2021-06-14 14:34 ` Kirti Wankhede
2 siblings, 2 replies; 14+ 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] 14+ 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-08 6:20 ` Christoph Hellwig
2021-06-11 12:40 ` Cornelia Huck
1 sibling, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-06-08 6:20 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: 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
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/10] Allow mdev drivers to directly create the vfio_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 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
@ 2021-06-08 6:22 ` Christoph Hellwig
2021-06-14 14:34 ` Kirti Wankhede
2 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-06-08 6:22 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: David Airlie, Tony Krowiak, Alex Williamson,
Christian Borntraeger, Cornelia Huck, Jonathan Corbet,
Daniel Vetter, dri-devel, Vasily Gorbik, Greg Kroah-Hartman,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, Kirti Wankhede, linux-doc, linux-s390,
Halil Pasic, Rafael J. Wysocki, Rodrigo Vivi, Christoph Hellwig
Btw, you list of CCs is a mess as alsmost no one is CCed on the whole
list can can thus properly review it.
^ permalink raw reply [flat|nested] 14+ 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-08 6:20 ` Christoph Hellwig
@ 2021-06-11 12:40 ` Cornelia Huck
2021-06-14 12:35 ` Jason Gunthorpe
1 sibling, 1 reply; 14+ 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] 14+ 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; 14+ messages in thread
From: Jason Gunthorpe @ 2021-06-14 12:35 UTC (permalink / raw)
To: Cornelia Huck, Christoph Hellwig
Cc: 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 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] 14+ messages in thread
* Re: [PATCH 00/10] Allow mdev drivers to directly create the vfio_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 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Jason Gunthorpe
2021-06-08 6:22 ` [PATCH 00/10] Allow mdev drivers to directly create the vfio_device Christoph Hellwig
@ 2021-06-14 14:34 ` Kirti Wankhede
2021-06-14 14:36 ` Jason Gunthorpe
2 siblings, 1 reply; 14+ messages in thread
From: Kirti Wankhede @ 2021-06-14 14:34 UTC (permalink / raw)
To: Jason Gunthorpe, David Airlie, Tony Krowiak, Alex Williamson,
Christian Borntraeger, Cornelia Huck, Jonathan Corbet,
Daniel Vetter, dri-devel, Vasily Gorbik, Greg Kroah-Hartman,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
Cc: Christoph Hellwig
Jason,
I couldn't find patch 1,2,4 and 5 of these series. Can you please keep
kvm@vger.kernel.org cc for all patches?
Also it will be helpful if you can add version prefix, eg. 'v3' for this
series, in subject line.
Thanks,
Kirti
On 6/8/2021 6:25 AM, Jason Gunthorpe wrote:
> This is a "v3" of the previous posted full conversion:
> https://lore.kernel.org/r/0-v2-7667f42c9bad+935-vfio3_jgg@nvidia.com
>
> Without the trailing patches that are running into complications:
> - The CCW conversion has some complicated remarks
> - AP is waiting for some locking stuff to get worked out
> - No feedback on GT
> - The license change topic for removing vfio_mdev.c
>
> Getting the baseline functionality merged will allow Intel's IDXD mdev
> driver to advance. It has already been RFC posted in the new format:
>
> https://lore.kernel.org/kvm/162164243591.261970.3439987543338120797.stgit@djiang5-desk3.ch.intel.com/
>
> This series includes base infrastructure and the sample conversions. The
> remaining four issues can be sorted out one by one.
>
> The major change in v3 is to enhance the driver core support for binding
> based on the request from Christoph Hellwig and Dan Williams. Based on
> some light analysis this looks broadly useful:
>
> https://lore.kernel.org/kvm/20210428233856.GY1370958@nvidia.com/
>
> ====
>
> 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.
>
> v3:
> - Use device_driver_attach() from the driver core
> - 5 new patches to make device_driver_attach() exported and usable for this
> - Remove trailing patches for now
> v2: https://lore.kernel.org/r/0-v2-7667f42c9bad+935-vfio3_jgg@nvidia.com
> - Keep && m in samples kconfig
> - Restore accidently squashed removeal of vfio_mdev.c
> - Remove indirections to call bus_register()/bus_unregister()
> - Reflow long doc lines
> v1: https://lore.kernel.org/r/0-v1-d88406ed308e+418-vfio3_jgg@nvidia.com
>
> Jason Gunthorpe (10):
> driver core: Do not continue searching for drivers if deferred probe
> is used
> driver core: Pull required checks into driver_probe_device()
> driver core: Flow the return code from ->probe() through to sysfs bind
> driver core: Don't return EPROBE_DEFER to userspace during sysfs bind
> driver core: Export device_driver_attach()
> 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()
>
> Documentation/s390/vfio-ap.rst | 1 -
> arch/s390/Kconfig | 2 +-
> drivers/base/base.h | 1 -
> drivers/base/bus.c | 6 +-
> drivers/base/dd.c | 116 ++++++++++++-------
> drivers/gpu/drm/i915/Kconfig | 2 +-
> drivers/vfio/mdev/Kconfig | 7 --
> drivers/vfio/mdev/Makefile | 3 +-
> drivers/vfio/mdev/mdev_core.c | 46 ++++++--
> drivers/vfio/mdev/mdev_driver.c | 10 ++
> drivers/vfio/mdev/mdev_private.h | 2 +
> drivers/vfio/mdev/vfio_mdev.c | 24 +---
> include/linux/device.h | 2 +
> include/linux/mdev.h | 2 +
> samples/Kconfig | 6 +-
> samples/vfio-mdev/mbochs.c | 163 +++++++++++++++------------
> samples/vfio-mdev/mdpy.c | 159 ++++++++++++++------------
> samples/vfio-mdev/mtty.c | 185 ++++++++++++++-----------------
> 18 files changed, 397 insertions(+), 340 deletions(-)
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/10] Allow mdev drivers to directly create the vfio_device
2021-06-14 14:34 ` Kirti Wankhede
@ 2021-06-14 14:36 ` Jason Gunthorpe
0 siblings, 0 replies; 14+ messages in thread
From: Jason Gunthorpe @ 2021-06-14 14:36 UTC (permalink / raw)
To: Kirti Wankhede
Cc: David Airlie, Tony Krowiak, Alex Williamson,
Christian Borntraeger, Cornelia Huck, Jonathan Corbet,
Daniel Vetter, dri-devel, Vasily Gorbik, Greg Kroah-Hartman,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi, Christoph Hellwig
On Mon, Jun 14, 2021 at 08:04:03PM +0530, Kirti Wankhede wrote:
> Jason,
>
> I couldn't find patch 1,2,4 and 5 of these series. Can you please keep
> kvm@vger.kernel.org cc for all patches?
It is an error, sorry
> Also it will be helpful if you can add version prefix, eg. 'v3' for this
> series, in subject line.
This is not v3, it is a different but related series
Jason
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
2021-06-17 14:22 Allow mdev drivers to directly create the vfio_device (v4) Christoph Hellwig
@ 2021-06-17 14:22 ` Christoph Hellwig
0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-06-17 14:22 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson, Kirti Wankhede
Cc: David Airlie, Tony Krowiak, Christian Borntraeger, Cornelia Huck,
Jonathan Corbet, Daniel Vetter, dri-devel, Vasily Gorbik,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Kirti Wankhede <kwankhede@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 e15436599086..f57ae621f33e 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 b4c7c34069f8..ea63fd22e119 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 1e1cb245fca7..53bc68631861 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -124,7 +124,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 5da27f2100f9..763c877a1318 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 101516fdf375..ff9ecd802125 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 2a85d6fcb7dd..ff8c1a845166 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 6999c89db7b1..afbad7b0a14a 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 922729071c5a..d5b4eede47c1 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 b5a1a7aa7e23..b0503ef058d3 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.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
2021-06-15 13:35 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Christoph Hellwig
2021-06-15 14:10 ` Greg Kroah-Hartman
@ 2021-06-16 20:20 ` Kirti Wankhede
1 sibling, 0 replies; 14+ 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: David Airlie, Tony Krowiak, Christian Borntraeger, Cornelia Huck,
Jonathan Corbet, Daniel Vetter, dri-devel, Vasily Gorbik,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
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] 14+ messages in thread
* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
2021-06-15 13:35 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Christoph Hellwig
@ 2021-06-15 14:10 ` Greg Kroah-Hartman
2021-06-16 20:20 ` Kirti Wankhede
1 sibling, 0 replies; 14+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-15 14:10 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Jason Gunthorpe, Alex Williamson, Kirti Wankhede, David Airlie,
Tony Krowiak, Christian Borntraeger, Cornelia Huck,
Jonathan Corbet, Daniel Vetter, dri-devel, Vasily Gorbik,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
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] 14+ messages in thread
* [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
2021-06-15 13:35 Allow mdev drivers to directly create the vfio_device (v3) Christoph Hellwig
@ 2021-06-15 13:35 ` Christoph Hellwig
2021-06-15 14:10 ` Greg Kroah-Hartman
2021-06-16 20:20 ` Kirti Wankhede
0 siblings, 2 replies; 14+ messages in thread
From: Christoph Hellwig @ 2021-06-15 13:35 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson, Kirti Wankhede
Cc: David Airlie, Tony Krowiak, Christian Borntraeger, Cornelia Huck,
Jonathan Corbet, Daniel Vetter, dri-devel, Vasily Gorbik,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
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(-)
diff --git a/Documentation/s390/vfio-ap.rst b/Documentation/s390/vfio-ap.rst
index e15436599086..f57ae621f33e 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 b4c7c34069f8..ea63fd22e119 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 1e1cb245fca7..53bc68631861 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -124,7 +124,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 5da27f2100f9..763c877a1318 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 101516fdf375..ff9ecd802125 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 2a85d6fcb7dd..ff8c1a845166 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 6999c89db7b1..afbad7b0a14a 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 922729071c5a..d5b4eede47c1 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 b5a1a7aa7e23..b0503ef058d3 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.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
2021-06-14 15:08 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Christoph Hellwig
@ 2021-06-15 10:50 ` Cornelia Huck
0 siblings, 0 replies; 14+ 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: David Airlie, Tony Krowiak, Christian Borntraeger,
Jonathan Corbet, Daniel Vetter, dri-devel, Vasily Gorbik,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
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] 14+ messages in thread
* [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE
2021-06-14 15:08 Allow mdev drivers to directly create the vfio_device (v2 / alternative) Christoph Hellwig
@ 2021-06-14 15:08 ` Christoph Hellwig
2021-06-15 10:50 ` Cornelia Huck
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2021-06-14 15:08 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jason Gunthorpe, Alex Williamson, Kirti Wankhede
Cc: David Airlie, Tony Krowiak, Christian Borntraeger, Cornelia Huck,
Jonathan Corbet, Daniel Vetter, dri-devel, Vasily Gorbik,
Heiko Carstens, intel-gfx, Jani Nikula, Jason Herne,
Joonas Lahtinen, kvm, linux-doc, linux-s390, Halil Pasic,
Rafael J. Wysocki, Rodrigo Vivi
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(-)
diff --git a/Documentation/s390/vfio-ap.rst b/Documentation/s390/vfio-ap.rst
index e15436599086..f57ae621f33e 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 b4c7c34069f8..ea63fd22e119 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 1e1cb245fca7..53bc68631861 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -124,7 +124,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 5da27f2100f9..763c877a1318 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 101516fdf375..ff9ecd802125 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 2a85d6fcb7dd..ff8c1a845166 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 6999c89db7b1..afbad7b0a14a 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 922729071c5a..d5b4eede47c1 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 b5a1a7aa7e23..b0503ef058d3 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.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-06-17 14:25 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-08 6:20 ` Christoph Hellwig
2021-06-11 12:40 ` Cornelia Huck
2021-06-14 12:35 ` Jason Gunthorpe
2021-06-08 6:22 ` [PATCH 00/10] Allow mdev drivers to directly create the vfio_device Christoph Hellwig
2021-06-14 14:34 ` Kirti Wankhede
2021-06-14 14:36 ` Jason Gunthorpe
2021-06-14 15:08 Allow mdev drivers to directly create the vfio_device (v2 / alternative) Christoph Hellwig
2021-06-14 15:08 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Christoph Hellwig
2021-06-15 10:50 ` Cornelia Huck
2021-06-15 13:35 Allow mdev drivers to directly create the vfio_device (v3) Christoph Hellwig
2021-06-15 13:35 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Christoph Hellwig
2021-06-15 14:10 ` Greg Kroah-Hartman
2021-06-16 20:20 ` Kirti Wankhede
2021-06-17 14:22 Allow mdev drivers to directly create the vfio_device (v4) Christoph Hellwig
2021-06-17 14:22 ` [PATCH 06/10] vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE Christoph Hellwig
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).