[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220922115820.5ac023ab.alex.williamson@redhat.com>
Date: Thu, 22 Sep 2022 11:58:20 -0600
From: Alex Williamson <alex.williamson@...hat.com>
To: Kevin Tian <kevin.tian@...el.com>
Cc: Zhenyu Wang <zhenyuw@...ux.intel.com>,
Zhi Wang <zhi.a.wang@...el.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Eric Farman <farman@...ux.ibm.com>,
Matthew Rosato <mjrosato@...ux.ibm.com>,
Halil Pasic <pasic@...ux.ibm.com>,
Vineeth Vijayan <vneethv@...ux.ibm.com>,
Peter Oberparleiter <oberpar@...ux.ibm.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Tony Krowiak <akrowiak@...ux.ibm.com>,
Jason Herne <jjherne@...ux.ibm.com>,
Harald Freudenberger <freude@...ux.ibm.com>,
Diana Craciun <diana.craciun@....nxp.com>,
Cornelia Huck <cohuck@...hat.com>,
Longfang Liu <liulongfang@...wei.com>,
Shameer Kolothum <shameerali.kolothum.thodi@...wei.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Yishai Hadas <yishaih@...dia.com>,
Eric Auger <eric.auger@...hat.com>,
Kirti Wankhede <kwankhede@...dia.com>,
Leon Romanovsky <leon@...nel.org>,
Abhishek Sahu <abhsahu@...dia.com>,
Christoph Hellwig <hch@...radead.org>,
intel-gvt-dev@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org,
kvm@...r.kernel.org, Yi Liu <yi.l.liu@...el.com>
Subject: Re: [PATCH v4 00/15] Tidy up vfio_device life cycle
On Wed, 21 Sep 2022 18:43:46 +0800
Kevin Tian <kevin.tian@...el.com> wrote:
> 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 anyway. 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/
>
> v4:
> - fix use-after-free issue in @release of mtty/mbochs and also change
> mdpy/ap to free vfio-device as the last thing in @release (Alex)
> - revert the rename from 'vfio' to 'vfio_group' in procfs (Alex)
Applied to vfio next branch for v6.1. Thanks,
Alex
Powered by blists - more mailing lists