dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/15] Tidy up vfio_device life cycle
@ 2022-08-27 17:10 Kevin Tian
  2022-08-27 17:10 ` [PATCH 01/15] vfio: Add helpers for unifying " Kevin Tian
                   ` (16 more replies)
  0 siblings, 17 replies; 36+ messages in thread
From: Kevin Tian @ 2022-08-27 17:10 UTC (permalink / raw)
  To: Zhenyu Wang, Zhi Wang, Jani Nikula, Joonas Lahtinen,
	Rodrigo Vivi, Tvrtko Ursulin, David Airlie, Daniel Vetter,
	Eric Farman, Matthew Rosato, Halil Pasic, Vineeth Vijayan,
	Peter Oberparleiter, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Tony Krowiak, Jason Herne, Harald Freudenberger, Diana Craciun,
	Alex Williamson, Cornelia Huck, Longfang Liu, Shameer Kolothum,
	Jason Gunthorpe, Yishai Hadas, Kevin Tian, Eric Auger,
	Kirti Wankhede, Leon Romanovsky, Abhishek Sahu, intel-gvt-dev,
	intel-gfx, dri-devel, linux-kernel, linux-s390, kvm
  Cc: Yi Liu

The idea is to let vfio core manage the vfio_device life cycle instead
of duplicating the logic cross drivers. Besides cleaner code in driver
side this also allows adding struct device to vfio_device as the first
step toward adding cdev uAPI in the future. Another benefit is that
user can now look at sysfs to decide whether a device is bound to
vfio [1], e.g.:

	/sys/devices/pci0000\:6f/0000\:6f\:01.0/vfio-dev/vfio0

Though most drivers can fit the new model naturally:

 - vfio_alloc_device() to allocate and initialize vfio_device
 - vfio_put_device() to release vfio_device
 - dev_ops->init() for driver private initialization
 - dev_ops->release() for driver private cleanup

vfio-ccw is the only exception due to a life cycle mess that its private
structure mixes both parent and mdev info hence must be alloc/free'ed
outside of the life cycle of vfio device.

Per prior discussions this won't be fixed in short term by IBM folks [2].

Instead of waiting this series introduces a few tricks to move forward:

 - vfio_init_device() to initialize a pre-allocated device structure;

 - require *EVERY* driver to implement @release and free vfio_device
   inside. Then vfio-ccw can use a completion mechanism to delay the
   free to css driver;

The second trick is not a real burden to other drivers because they
all require a @release for private cleanup anyay. Later once the ccw
mess is fixed a simple cleanup can be done by moving free from @release
to vfio core.

Thanks
Kevin

[1] https://listman.redhat.com/archives/libvir-list/2022-August/233482.html
[2] https://lore.kernel.org/all/0ee29bd6583f17f0ee4ec0769fa50e8ea6703623.camel@linux.ibm.com/

Kevin Tian (6):
  vfio: Add helpers for unifying vfio_device life cycle
  drm/i915/gvt: Use the new device life cycle helpers
  vfio/platform: Use the new device life cycle helpers
  vfio/amba: Use the new device life cycle helpers
  vfio/ccw: Use the new device life cycle helpers
  vfio: Rename vfio_device_put() and vfio_device_try_get()

Yi Liu (9):
  vfio/pci: Use the new device life cycle helpers
  vfio/mlx5: Use the new device life cycle helpers
  vfio/hisi_acc: Use the new device life cycle helpers
  vfio/mdpy: Use the new device life cycle helpers
  vfio/mtty: Use the new device life cycle helpers
  vfio/mbochs: Use the new device life cycle helpers
  vfio/ap: Use the new device life cycle helpers
  vfio/fsl-mc: Use the new device life cycle helpers
  vfio: Add struct device to vfio_device

 drivers/gpu/drm/i915/gvt/gvt.h                |   5 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c              |  52 ++++--
 drivers/gpu/drm/i915/gvt/vgpu.c               |  31 ++--
 drivers/s390/cio/vfio_ccw_ops.c               |  52 +++++-
 drivers/s390/cio/vfio_ccw_private.h           |   3 +
 drivers/s390/crypto/vfio_ap_ops.c             |  50 +++---
 drivers/vfio/fsl-mc/vfio_fsl_mc.c             |  87 +++++----
 .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c    |  80 ++++-----
 drivers/vfio/pci/mlx5/main.c                  |  49 ++++--
 drivers/vfio/pci/vfio_pci.c                   |  20 +--
 drivers/vfio/pci/vfio_pci_core.c              |  23 ++-
 drivers/vfio/platform/vfio_amba.c             |  72 ++++++--
 drivers/vfio/platform/vfio_platform.c         |  66 +++++--
 drivers/vfio/platform/vfio_platform_common.c  |  61 +++----
 drivers/vfio/platform/vfio_platform_private.h |  18 +-
 drivers/vfio/vfio_main.c                      | 165 +++++++++++++++---
 include/linux/vfio.h                          |  29 ++-
 include/linux/vfio_pci_core.h                 |   6 +-
 samples/vfio-mdev/mbochs.c                    |  73 +++++---
 samples/vfio-mdev/mdpy.c                      |  81 +++++----
 samples/vfio-mdev/mtty.c                      |  67 ++++---
 21 files changed, 724 insertions(+), 366 deletions(-)


base-commit: 1c23f9e627a7b412978b4e852793c5e3c3efc555
-- 
2.21.3


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

end of thread, other threads:[~2022-09-01  6:25 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-27 17:10 [PATCH 00/15] Tidy up vfio_device life cycle Kevin Tian
2022-08-27 17:10 ` [PATCH 01/15] vfio: Add helpers for unifying " Kevin Tian
2022-08-30 13:42   ` Anthony Krowiak
2022-08-30 15:10     ` Jason Gunthorpe
2022-08-30 19:43       ` Anthony Krowiak
2022-08-31  6:03       ` Tian, Kevin
2022-08-27 17:10 ` [PATCH 02/15] vfio/pci: Use the new device life cycle helpers Kevin Tian
2022-08-27 17:10 ` [PATCH 03/15] vfio/mlx5: " Kevin Tian
2022-08-27 17:10 ` [PATCH 04/15] vfio/hisi_acc: " Kevin Tian
2022-08-31  7:36   ` Shameerali Kolothum Thodi
2022-08-27 17:10 ` [PATCH 05/15] vfio/mdpy: " Kevin Tian
2022-08-27 17:10 ` [PATCH 06/15] vfio/mtty: " Kevin Tian
2022-08-27 17:10 ` [PATCH 07/15] vfio/mbochs: " Kevin Tian
2022-08-27 17:10 ` [PATCH 08/15] drm/i915/gvt: " Kevin Tian
2022-08-27 17:10 ` [PATCH 09/15] vfio/ap: " Kevin Tian
2022-08-30 13:43   ` Anthony Krowiak
2022-08-27 17:10 ` [PATCH 10/15] vfio/fsl-mc: " Kevin Tian
2022-08-31  0:22   ` Jason Gunthorpe
2022-08-31  6:14     ` Tian, Kevin
2022-08-27 17:10 ` [PATCH 11/15] vfio/platform: " Kevin Tian
2022-08-27 17:10 ` [PATCH 12/15] vfio/amba: " Kevin Tian
2022-08-27 17:10 ` [PATCH 13/15] vfio/ccw: " Kevin Tian
2022-08-27 10:39   ` Tian, Kevin
2022-08-27 17:10 ` [PATCH 14/15] vfio: Rename vfio_device_put() and vfio_device_try_get() Kevin Tian
2022-08-27 17:10 ` [PATCH 15/15] vfio: Add struct device to vfio_device Kevin Tian
2022-08-30 22:18   ` Alex Williamson
2022-08-30 23:53     ` Jason Gunthorpe
2022-08-31  6:10       ` Tian, Kevin
2022-08-31 17:15         ` Alex Williamson
2022-09-01  0:46           ` Tian, Kevin
2022-09-01  2:05             ` Alex Williamson
2022-08-31  0:32   ` Jason Gunthorpe
2022-08-31  6:14     ` Tian, Kevin
2022-08-27 22:41 ` [PATCH 00/15] Tidy up vfio_device life cycle Tian, Kevin
2022-08-31  0:34 ` Jason Gunthorpe
2022-08-31  6:14   ` Tian, Kevin

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).