From: Kevin Tian <kevin.tian@intel.com>
To: Zhenyu Wang <zhenyuw@linux.intel.com>,
Zhi Wang <zhi.a.wang@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Eric Farman <farman@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Vineeth Vijayan <vneethv@linux.ibm.com>,
Peter Oberparleiter <oberpar@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Tony Krowiak <akrowiak@linux.ibm.com>,
Jason Herne <jjherne@linux.ibm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Diana Craciun <diana.craciun@oss.nxp.com>,
Alex Williamson <alex.williamson@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
Longfang Liu <liulongfang@huawei.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Yishai Hadas <yishaih@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>,
Eric Auger <eric.auger@redhat.com>,
Kirti Wankhede <kwankhede@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Abhishek Sahu <abhsahu@nvidia.com>,
Christoph Hellwig <hch@infradead.org>,
intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
kvm@vger.kernel.org
Cc: Yi Liu <yi.l.liu@intel.com>
Subject: [PATCH v3 00/15] Tidy up vfio_device life cycle
Date: Fri, 9 Sep 2022 18:22:32 +0800 [thread overview]
Message-ID: <20220909102247.67324-1-kevin.tian@intel.com> (raw)
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/freed
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/
v3:
- rebase to vfio-next after resolving conflicts with Yishai's series
- add missing fixes for two checkpatch errors
- fix grammar issues (Eric Auger)
- add more r-b's
v2:
- https://lore.kernel.org/lkml/20220901143747.32858-1-kevin.tian@intel.com/
- rebase to 6.0-rc3
- fix build warnings (lkp)
- patch1: remove unnecessary forward reference (Jason)
- patch10: leave device_set released by vfio core (Jason)
- patch13: add Suggested-by
- patch15: add ABI file sysfs-devices-vfio-dev (Alex)
- patch15: rename 'vfio' to 'vfio_group' in procfs (Jason)
v1: https://lore.kernel.org/lkml/20220827171037.30297-1-kevin.tian@intel.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
.../ABI/testing/sysfs-devices-vfio-dev | 8 +
MAINTAINERS | 1 +
drivers/gpu/drm/i915/gvt/gvt.h | 5 +-
drivers/gpu/drm/i915/gvt/kvmgt.c | 52 ++++--
drivers/gpu/drm/i915/gvt/vgpu.c | 33 ++--
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 | 85 +++++----
.../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 80 ++++-----
drivers/vfio/pci/mlx5/main.c | 50 ++++--
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 | 71 +++-----
drivers/vfio/platform/vfio_platform_private.h | 18 +-
drivers/vfio/vfio_main.c | 167 +++++++++++++++---
include/linux/vfio.h | 28 ++-
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 ++++---
23 files changed, 730 insertions(+), 381 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-devices-vfio-dev
base-commit: f39856aacb078c1c93acef011a37121b17d54fe0
--
2.21.3
next reply other threads:[~2022-09-09 3:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 10:22 Kevin Tian [this message]
2022-09-09 10:22 ` [PATCH v3 01/15] vfio: Add helpers for unifying vfio_device life cycle Kevin Tian
2022-09-09 8:23 ` Ethan Zhao
2022-09-09 8:42 ` Tian, Kevin
2022-09-09 23:53 ` Jason Gunthorpe
2022-09-09 10:22 ` [PATCH v3 02/15] vfio/pci: Use the new device life cycle helpers Kevin Tian
2022-09-09 10:22 ` [PATCH v3 03/15] vfio/mlx5: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 04/15] vfio/hisi_acc: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 05/15] vfio/mdpy: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 06/15] vfio/mtty: " Kevin Tian
2022-09-20 19:17 ` Alex Williamson
2022-09-20 22:52 ` Tian, Kevin
2022-09-09 10:22 ` [PATCH v3 07/15] vfio/mbochs: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 08/15] drm/i915/gvt: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 09/15] vfio/ap: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 10/15] vfio/fsl-mc: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 11/15] vfio/platform: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 12/15] vfio/amba: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 13/15] vfio/ccw: " Kevin Tian
2022-09-09 10:22 ` [PATCH v3 14/15] vfio: Rename vfio_device_put() and vfio_device_try_get() Kevin Tian
2022-09-09 10:22 ` [PATCH v3 15/15] vfio: Add struct device to vfio_device Kevin Tian
2022-09-20 20:26 ` Alex Williamson
2022-09-20 22:55 ` Tian, Kevin
2022-09-21 16:10 ` Jason Gunthorpe
2022-09-22 5:18 ` Tian, Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220909102247.67324-1-kevin.tian@intel.com \
--to=kevin.tian@intel.com \
--cc=abhsahu@nvidia.com \
--cc=agordeev@linux.ibm.com \
--cc=airlied@linux.ie \
--cc=akrowiak@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=daniel@ffwll.ch \
--cc=diana.craciun@oss.nxp.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric.auger@redhat.com \
--cc=farman@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@infradead.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jgg@ziepe.ca \
--cc=jjherne@linux.ibm.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=mjrosato@linux.ibm.com \
--cc=oberpar@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=rodrigo.vivi@intel.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=svens@linux.ibm.com \
--cc=tvrtko.ursulin@linux.intel.com \
--cc=vneethv@linux.ibm.com \
--cc=yi.l.liu@intel.com \
--cc=yishaih@nvidia.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).