linux/drivers/pci
Jason Gunthorpe 6c17c7d593 iommu: Allow ATS to work on VFs when the PF uses IDENTITY
PCI ATS has a global Smallest Translation Unit field that is located in
the PF but shared by all of the VFs.

The expectation is that the STU will be set to the root port's global STU
capability which is driven by the IO page table configuration of the iommu
HW. Today it becomes set when the iommu driver first enables ATS.

Thus, to enable ATS on the VF, the PF must have already had the correct
STU programmed, even if ATS is off on the PF.

Unfortunately the PF only programs the STU when the PF enables ATS. The
iommu drivers tend to leave ATS disabled when IDENTITY translation is
being used.

Thus we can get into a state where the PF is setup to use IDENTITY with
the DMA API while the VF would like to use VFIO with a PAGING domain and
have ATS turned on. This fails because the PF never loaded a PAGING domain
and so it never setup the STU, and the VF can't do it.

The simplest solution is to have the iommu driver set the ATS STU when it
probes the device. This way the ATS STU is loaded immediately at boot time
to all PFs and there is no issue when a VF comes to use it.

Add a new call pci_prepare_ats() which should be called by iommu drivers
in their probe_device() op for every PCI device if the iommu driver
supports ATS. This will setup the STU based on whatever page size
capability the iommu HW has.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/0-v1-0fb4d2ab6770+7e706-ats_vf_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2024-08-30 14:29:30 +02:00
..
controller Merge branch 'pci/misc' 2024-07-19 10:10:33 -05:00
endpoint Driver core changes for 6.11-rc1 2024-07-25 10:42:22 -07:00
hotplug PCI: pciehp: Retain Power Indicator bits for userspace indicators 2024-08-01 12:58:03 -05:00
msi Switch ARM/ARM64 over to the modern per device MSI domains: 2024-07-22 14:02:19 -07:00
pcie Merge branch 'pci/misc' 2024-07-19 10:10:33 -05:00
pwrctl Kconfig: reduce the amount of power sequencing noise 2024-07-18 13:56:40 +02:00
switch PCI: switchtec: Make switchtec_class constant 2024-06-10 15:03:30 -05:00
access.c PCI: Revert the cfg_access_lock lockdep mechanism 2024-06-04 12:10:05 -05:00
ats.c iommu: Allow ATS to work on VFs when the PF uses IDENTITY 2024-08-30 14:29:30 +02:00
bus.c pci-v6.11-changes 2024-07-19 19:03:18 -07:00
devres.c PCI: Add managed pcim_iomap_range() 2024-07-11 16:20:15 -05:00
doe.c PCI/DOE: Support discovery version 2 2024-04-09 09:33:15 -05:00
ecam.c
host-bridge.c
iomap.c PCI: Document hybrid devres hazards 2024-07-10 04:20:01 +00:00
iov.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
irq.c PCI: Place interrupt related code into irq.c 2024-01-29 17:01:31 -06:00
Kconfig PCI/pwrctl: Add PCI power control core code 2024-06-12 13:20:56 +02:00
Makefile PCI/pwrctl: Add PCI power control core code 2024-06-12 13:20:56 +02:00
mmap.c PCI/sysfs: Compile pci-sysfs.c only if CONFIG_SYSFS=y 2024-03-05 16:08:43 -06:00
of_property.c PCI: of_property: Add interrupt-controller property in PCI device nodes 2024-07-08 17:40:30 -06:00
of.c pci-v6.11-changes 2024-07-19 19:03:18 -07:00
p2pdma.c PCI/P2PDMA: Fix a sleeping issue in a RCU read section 2024-02-08 15:31:43 -06:00
pci-acpi.c PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci_register_host_bridge() 2024-06-03 16:13:38 -05:00
pci-bridge-emul.c
pci-bridge-emul.h
pci-driver.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
pci-label.c
pci-mid.c PCI/PM: Switch to new Intel CPU model defines 2024-06-11 17:08:14 -05:00
pci-pf-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-sysfs.c PCI/sysfs: Demacrofy pci_dev_resource_resize_attr(n) functions 2024-03-05 16:10:17 -06:00
pci.c PCI: Fix devres regression in pci_intx() 2024-08-01 12:56:06 -05:00
pci.h Merge branch 'pci/controller/rockchip' 2024-07-19 10:10:32 -05:00
probe.c pci-v6.11-changes 2024-07-19 19:03:18 -07:00
proc.c
quirks.c PCI: Add ACS quirk for Broadcom BCM5760X NIC 2024-05-28 11:13:28 -05:00
remove.c PCI/pwrctl: Create platform devices for child OF nodes of the port node 2024-06-12 13:20:56 +02:00
rom.c
search.c PCI: Add pci_get_base_class() helper 2023-09-28 16:49:44 -05:00
setup-bus.c PCI: Relax bridge window tail sizing rules 2024-06-12 14:51:30 -05:00
setup-res.c PCI: Use resource names in PCI log messages 2023-12-15 17:28:42 -06:00
slot.c
syscall.c PCI: Use consistent put_user() pointer types 2023-08-25 08:15:13 -05:00
vc.c PCI/VC: Use FIELD_GET() 2023-10-24 16:55:45 -05:00
vgaarb.c pci-v6.7-changes 2023-11-02 14:05:18 -10:00
vpd.c PCI/VPD: Add runtime power management to sysfs interface 2023-08-11 14:19:16 -05:00
xen-pcifront.c x86: always initialize xen-swiotlb when xen-pcifront is enabling 2023-07-31 17:54:27 +02:00