OrangePi_CM5/Documentation/driver-api
Jason Gunthorpe a2fbf4acd2 vfio: Split creation of a vfio_device into init and register ops
[ Upstream commit 0bfc6a4ea63c2adac71a824397ef48f28dbc5e47 ]

This makes the struct vfio_device part of the public interface so it
can be used with container_of and so forth, as is typical for a Linux
subystem.

This is the first step to bring some type-safety to the vfio interface by
allowing the replacement of 'void *' and 'struct device *' inputs with a
simple and clear 'struct vfio_device *'

For now the self-allocating vfio_add_group_dev() interface is kept so each
user can be updated as a separate patch.

The expected usage pattern is

  driver core probe() function:
     my_device = kzalloc(sizeof(*mydevice));
     vfio_init_group_dev(&my_device->vdev, dev, ops, mydevice);
     /* other driver specific prep */
     vfio_register_group_dev(&my_device->vdev);
     dev_set_drvdata(dev, my_device);

  driver core remove() function:
     my_device = dev_get_drvdata(dev);
     vfio_unregister_group_dev(&my_device->vdev);
     /* other driver specific tear down */
     kfree(my_device);

Allowing the driver to be able to use the drvdata and vfio_device to go
to/from its own data.

The pattern also makes it clear that vfio_register_group_dev() must be
last in the sequence, as once it is called the core code can immediately
start calling ops. The init/register gap is provided to allow for the
driver to do setup before ops can be called and thus avoid races.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Liu Yi L <yi.l.liu@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <3-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-21 15:16:07 +02:00
..
80211 docs: net: 80211: reduce docs build time 2020-10-08 10:41:49 +02:00
acpi
…
backlight
…
dmaengine Documentation: dmaengine: Correctly describe dmatest with channel unset 2022-01-27 10:54:29 +01:00
driver-model drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
early-userspace Documentation: Fix intiramfs script name 2021-07-28 14:35:47 +02:00
firmware docs: driver-api: firmware: fallback-mechanisms: Fix rendering of bullet point 2020-09-08 13:32:06 +02:00
fpga docs: fpga: replace :c:member: macros 2020-10-15 07:49:43 +02:00
gpio gpiolib: Update indentation in driver.rst for code excerpts 2020-10-12 13:15:34 -06:00
i3c
…
iio docs: get rid of :c:type explicit declarations for structs 2020-10-15 07:49:40 +02:00
md
…
media media: vidtv.rst: add kernel-doc markups 2020-11-26 08:05:24 +01:00
mei docs updates for v5.10-rc1 2020-10-16 15:02:21 -07:00
memory-devices
…
mmc
…
mtd
…
nfc
…
nvdimm docs: add some new files to their respective index.rst files 2020-09-10 10:48:20 -06:00
pci
…
phy
…
pldmfw Add pldmfw library for PLDM firmware update 2020-07-28 17:07:06 -07:00
pm docs: devices.rst: fix a C reference markup 2020-10-15 07:49:44 +02:00
rapidio
…
serial tty: vt: Replace HTTP links with HTTPS ones 2020-07-21 20:04:54 +02:00
soundwire docs: soundwire: fix some identation at stream.rst 2020-09-10 10:49:29 -06:00
thermal
…
usb usb: docs: document altmode register/unregister functions 2020-10-15 07:49:48 +02:00
xilinx firmware: xilinx: Remove zynqmp_pm_get_eemi_ops() in IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE) 2021-05-14 09:50:05 +02:00
basics.rst docs: basics.rst: avoid duplicated C function declaration 2020-10-15 07:49:45 +02:00
clk.rst
…
component.rst
…
connector.rst Documentation: driver-api: update kernel connector 2020-07-23 14:06:06 -06:00
console.rst
…
dcdbas.rst
…
devfreq.rst
…
device-io.rst
…
device_link.rst docs: device_link.rst: remove duplicated kernel-doc include 2020-10-15 07:49:42 +02:00
dma-buf.rst As hoped, things calmed down for docs this cycle; fewer changes and almost 2020-10-12 16:21:29 -07:00
edac.rst
…
eisa.rst
…
firewire.rst Documentation: fix firewire.rst ABI file path error 2022-01-27 10:54:29 +01:00
frame-buffer.rst
…
generic-counter.rst
…
hsi.rst
…
i2c.rst
…
index.rst A handful of late-arriving documentation fixes. 2020-10-23 17:13:53 -07:00
infiniband.rst
…
infrastructure.rst docs: infrastructure.rst: exclude device_link_state from device.h 2020-10-15 07:49:46 +02:00
input.rst
…
interconnect.rst
…
io-mapping.rst
…
io_ordering.rst
…
ioctl.rst
…
ipmb.rst
…
ipmi.rst Minor cleanups to the IPMI driver for 5.9 2020-08-08 09:32:18 -07:00
isa.rst
…
isapnp.rst
…
libata.rst docs: libata.rst: fix a wrong usage of :c:type: tag 2020-10-15 07:49:44 +02:00
lightnvm-pblk.rst
…
mailbox.rst
…
men-chameleon-bus.rst
…
message-based.rst
…
misc_devices.rst
…
miscellaneous.rst
…
mtdnand.rst
…
ntb.rst
…
nvmem.rst
…
parport-lowlevel.rst
…
pinctl.rst
…
pps.rst
…
pti_intel_mid.rst
…
ptp.rst
…
pwm.rst
…
regulator.rst docs: get rid of :c:type explicit declarations for structs 2020-10-15 07:49:40 +02:00
rfkill.rst
…
s390-drivers.rst
…
scsi.rst
…
slimbus.rst
…
sm501.rst
…
spi.rst
…
switchtec.rst
…
sync_file.rst
…
target.rst docs: scsi: target.rst: remove iSCSI transport class kernel-doc markup 2020-10-15 07:49:42 +02:00
uio-howto.rst
…
vfio-mediated-device.rst
…
vfio.rst vfio: Split creation of a vfio_device into init and register ops 2022-08-21 15:16:07 +02:00
vme.rst
…
w1.rst
…
xillybus.rst
…
zorro.rst
…