mirror-linux/drivers/uio
Yaxing Guo 3397c3cd85 uio: Add SVA support for PCI devices via uio_pci_generic_sva.c
This patch introduces a new UIO driver, uio_pci_generic_sva, which
extends the functionality of uio_pci_generic by adding support for
Shared Virtual Addressing (SVA) when IOMMU is enabled in the system.

The key enhancement allows PCI devices to directly use user-space virtual
addresses for DMA operations, eliminating the need for bounce buffers or
explicit IOVA mapping. This is achieved by leveraging the kernel's IOMMU-SVA
subsystem, including process address space attachment, page fault handling,
and shared context management between CPU and device.

With this driver, userspace applications can perform zero-copy DMA using
native pointers:

   void *addr = malloc(N);
   set_dma_addr((uint64_t)addr);  // Passing user VA directly
   start_dma();

The device can now access 'addr' through the IOMMU's PASID-based translation,
provided that the underlying IOMMU hardware (e.g., Intel VT-d 3.1+, AMD-Vi,
ARM SMMU, RISCV IOMMU) and platform support SVA.

Dependencies:
- CONFIG_IOMMU_SVA must be enabled.
- The platform must support PRI (Page Request Interface) and PASID.
- Device drivers/userspace must handle page faults if demand-paging is used.

The implementation reuses core logic from uio_pci_generic.c while adding
PASID setting, and integration with the IOMMU SVA APIs.

Also, add a read-only sysfs attribute 'pasid' to expose the Process Address
Space ID assigned by IOMMU driver when binding an SVA-enabled device.
For details, refer to the ABI documentation for uio_pci_sva driver sysfs attribute
(Documentation/ABI/testing/sysfs-driver-uio_pci_sva-pasid).

Signed-off-by: Yaxing Guo <guoyaxing@bosc.ac.cn>
Link: https://patch.msgid.link/20250926095828.506-1-guoyaxing@bosc.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-11-26 15:10:39 +01:00
..
Kconfig uio: Add SVA support for PCI devices via uio_pci_generic_sva.c 2025-11-26 15:10:39 +01:00
Makefile uio: Add SVA support for PCI devices via uio_pci_generic_sva.c 2025-11-26 15:10:39 +01:00
uio.c uio: Fix return value of poll 2025-01-10 09:52:39 +01:00
uio_aec.c uio: Constify struct pci_device_id 2025-09-06 15:57:04 +02:00
uio_cif.c uio: Constify struct pci_device_id 2025-09-06 15:57:04 +02:00
uio_dfl.c uio: dfl: add vendor-specific feature id 2023-05-31 19:00:37 +01:00
uio_dmem_genirq.c uio: uio_dmem_genirq: Remove dummy PM handling 2025-09-06 15:57:15 +02:00
uio_fsl_elbc_gpcm.c uio: uio_fsl_elbc_gpcm:: Add null pointer check to uio_fsl_elbc_gpcm_probe 2025-10-22 08:00:02 +02:00
uio_hv_generic.c uio_hv_generic: Let userspace take care of interrupt mask 2025-09-06 15:57:21 +02:00
uio_mf624.c uio: add missing MODULE_DESCRIPTION() macros 2024-06-04 17:39:12 +02:00
uio_netx.c uio: Constify struct pci_device_id 2025-09-06 15:57:04 +02:00
uio_pci_generic.c Merge 50f09a3dd5 ("Merge tag 'char-misc-5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc") into char-misc-next 2021-05-21 09:48:31 +02:00
uio_pci_generic_sva.c uio: Add SVA support for PCI devices via uio_pci_generic_sva.c 2025-11-26 15:10:39 +01:00
uio_pdrv_genirq.c uio: uio_pdrv_genirq: Remove dummy PM handling 2025-09-06 15:57:18 +02:00
uio_sercos3.c uio: Constify struct pci_device_id 2025-09-06 15:57:04 +02:00