xen/virtio: Handle PCI devices which Host controller is described in DT
authorOleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Tue, 25 Oct 2022 16:20:04 +0000 (19:20 +0300)
committerJuergen Gross <jgross@suse.com>
Mon, 5 Dec 2022 11:59:49 +0000 (12:59 +0100)
commitef8ae384b4c9ccefecf4754f34644bd9fb0105b7
tree600d4e8c4aff4670482177e63077d43834c09d7a
parent035e3a4321f73c352b6408ec2153fa5bc3feb459
xen/virtio: Handle PCI devices which Host controller is described in DT

Use the same "xen-grant-dma" device concept for the PCI devices
behind device-tree based PCI Host controller, but with one modification.
Unlike for platform devices, we cannot use generic IOMMU bindings
(iommus property), as we need to support more flexible configuration.
The problem is that PCI devices under the single PCI Host controller
may have the backends running in different Xen domains and thus have
different endpoints ID (backend domains ID).

Add ability to deal with generic PCI-IOMMU bindings (iommu-map/
iommu-map-mask properties) which allows us to describe relationship
between PCI devices and backend domains ID properly.

To avoid having to look up for the PCI Host bridge twice and reduce
the amount of checks pass an extra struct device_node *np to
xen_dt_grant_init_backend_domid().

So with current patch the code expects iommus property for the platform
devices and iommu-map/iommu-map-mask properties for PCI devices.

The example of generated by the toolstack iommu-map property
for two PCI devices 0000:00:01.0 and 0000:00:02.0 whose
backends are running in different Xen domains with IDs 1 and 2
respectively:
iommu-map = <0x08 0xfde9 0x01 0x08 0x10 0xfde9 0x02 0x08>;

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Link: https://lore.kernel.org/r/20221025162004.8501-3-olekstysh@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/xen/grant-dma-ops.c