linux/arch/powerpc/platforms/powernv
Shivaprasad G Bhat f431a8cde7 powerpc/iommu: Reimplement the iommu_table_group_ops for pSeries
PPC64 IOMMU API defines iommu_table_group_ops which handles DMA
windows for PEs, their ownership transfer, create/set/unset the TCE
tables for the Dynamic DMA wundows(DDW). VFIOS uses these APIs for
support on POWER.

The commit 9d67c94335 ("powerpc/iommu: Add "borrowing"
iommu_table_group_ops") implemented partial support for this API with
"borrow" mechanism wherein the DMA windows if created already by the
host driver, they would be available for VFIO to use. Also, it didn't
have the support to control/modify the window size or the IO page
size.

The current patch implements all the necessary iommu_table_group_ops
APIs there by avoiding the "borrrowing". So, just the way it is on the
PowerNV platform, with this patch the iommu table group ownership is
transferred to the VFIO PPC subdriver, the iommu table, DMA windows
creation/deletion all driven through the APIs.

The pSeries uses the query-pe-dma-window, create-pe-dma-window and
reset-pe-dma-window RTAS calls for DMA window creation, deletion and
reset to defaul. The RTAs calls do show some minor differences to the
way things are to be handled on the pSeries which are listed below.

* On pSeries, the default DMA window size is "fixed" cannot be custom
sized as requested by the user. For non-SRIOV VFs, It is fixed at 2GB
and for SRIOV VFs, its variable sized based on the capacity assigned
to it during the VF assignment to the LPAR. So, for the  default DMA
window alone the size if requested less than tce32_size, the smaller
size is enforced using the iommu table->it_size.

* The DMA start address for 32-bit window is 0, and for the 64-bit
window in case of PowerNV is hardcoded to TVE select (bit 59) at 512PiB
offset. This address is returned at the time of create_table() API call
(even before the window is created), the subsequent set_window() call
actually opens the DMA window. On pSeries, the DMA start address for
32-bit window is known from the 'ibm,dma-window' DT property. However,
the 64-bit window start address is not known until the create-pe-dma
RTAS call is made. So, the create_table() which returns the DMA window
start address actually opens the DMA window and returns the DMA start
address as returned by the Hypervisor for the create-pe-dma RTAS call.

* The reset-pe-dma RTAS call resets the DMA windows and restores the
default DMA window, however it does not clear the TCE table entries
if there are any. In case of ownership transfer from platform domain
which used direct mapping, the patch chooses remove-pe-dma instead of
reset-pe for the 64-bit window intentionally so that the
clear_dma_window() is called.

Other than the DMA window management changes mentioned above, the
patch also brings back the userspace view for the single level TCE
as it existed before commit 090bad39b2 ("powerpc/powernv: Add
indirect levels to it_userspace") along with the relavent
refactoring.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/171923275958.1397.907964437142542242.stgit@linux.ibm.com
2024-06-28 17:03:40 +10:00
..
copy-paste.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
eeh-powernv.c powerpc/eeh: Use pci_dev_id() to simplify the code 2023-08-25 08:39:30 +10:00
idle.c powerpc: powernv: Fix KCSAN datarace warnings on idle_state contention 2023-06-21 15:13:57 +10:00
Kconfig powerc/mm: try VMA lock-based page fault handling first 2023-04-05 20:03:02 -07:00
Makefile powerpc/kasan: Mark more real-mode code as not to be instrumented 2022-05-29 10:30:42 +10:00
memtrace.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
ocxl.c ocxl: Use pci_dev_id() to simplify the code 2023-08-16 23:54:47 +10:00
opal-async.c powerpc: Use fallthrough pseudo-keyword 2020-07-29 21:09:37 +10:00
opal-call.c powerpc/powernv/pci: Remove MVE code 2023-06-21 15:13:57 +10:00
opal-core.c crash: split vmcoreinfo exporting code out from crash_core.c 2024-02-23 17:48:22 -08:00
opal-dump.c powerpc: declare unmodified attribute_group usages const 2022-03-08 22:15:32 +11:00
opal-elog.c powerpc/opal: use default_groups in kobj_type 2022-01-05 10:59:52 +11:00
opal-fadump.c powerpc/fadump: setup additional parameters for dump capture kernel 2024-05-10 16:36:10 +10:00
opal-fadump.h powerpc/fadump: Annotate endianness cast with __force 2023-10-19 17:16:20 +11:00
opal-flash.c powerpc/powernv/flash: Check OPAL flash calls exist before using 2022-05-22 15:59:54 +10:00
opal-hmi.c powerpc/64s/powernv: Ratelimit harmless HMI error printing 2020-12-04 01:01:23 +11:00
opal-imc.c powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
opal-irqchip.c powerpc/powernv: Add a null pointer check in opal_event_init() 2023-12-13 22:19:03 +11:00
opal-kmsg.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-lpc.c powerpc: Use of_property_present() for testing DT property presence 2023-03-30 23:36:35 +11:00
opal-memory-errors.c powerpc: fix typos in comments 2022-05-05 22:12:44 +10:00
opal-msglog.c powerpc/powernv: Add __init attribute to eligible functions 2021-12-23 22:33:15 +11:00
opal-nvram.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-power.c powerpc/powernv: Add __init attribute to eligible functions 2021-12-23 22:33:15 +11:00
opal-powercap.c powerpc/powernv: Add a null pointer check in opal_powercap_init() 2023-12-13 22:19:07 +11:00
opal-prd.c powerpc: opal-prd: Convert to platform remove callback returning void 2024-02-22 21:55:32 +11:00
opal-psr.c powerpc/powernv: Add missing of_node_put()s 2022-09-05 17:30:29 +10:00
opal-rtc.c powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
opal-secvar.c powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
opal-sensor-groups.c powerpc/powernv: Add missing of_node_put()s 2022-09-05 17:30:29 +10:00
opal-sensor.c powerpc: Explicitly include correct DT includes 2023-08-02 22:22:19 +10:00
opal-sysparam.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
opal-tracepoints.c powerpc: Move C prototypes out of asm-prototypes.h 2022-03-08 22:06:25 +11:00
opal-wrappers.S powerpc/64: provide a helper macro to load r2 with the kernel TOC 2022-09-28 19:22:12 +10:00
opal-xscom.c powerpc/powernv: Add a null pointer check to scom_debug_init_one() 2023-12-13 22:18:59 +11:00
opal.c treewide: Use sysfs_bin_attr_simple_read() helper 2024-04-11 16:02:25 +02:00
pci-cxl.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
pci-ioda-tce.c KVM: PPC: Book3s: Retire H_PUT_TCE/etc real mode handlers 2022-05-19 00:44:01 +10:00
pci-ioda.c powerpc/iommu: Reimplement the iommu_table_group_ops for pSeries 2024-06-28 17:03:40 +10:00
pci-sriov.c powerpc: Fix typos 2024-05-08 00:21:30 +10:00
pci.c powerpc/powernv/pci: Remove ioda1 support 2023-06-21 15:13:56 +10:00
pci.h powerpc/powernv/pci: Remove last IODA1 defines 2023-06-21 15:13:57 +10:00
powernv.h powerpc/powernv: wire up rng during setup_arch 2022-06-22 19:47:22 +10:00
rng.c powerpc/powernv: rename remaining rng powernv_ functions to pnv_ 2022-07-28 16:22:15 +10:00
setup.c powerpc/mm: Cleanup memory block size probing 2023-08-18 17:03:15 +10:00
smp.c powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency 2024-03-17 13:34:00 +11:00
subcore-asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
subcore.c powerpc: Add PVN support for HeXin C2000 processor 2023-12-01 21:15:33 +11:00
subcore.h powerpc: remove unneeded semicolons 2021-02-09 00:10:50 +11:00
ultravisor.c powerpc/powernv: fix missing of_node_put in uv_init() 2022-05-22 15:58:30 +10:00
vas-debug.c powerpc/vas: Define and use common vas_window struct 2021-06-20 21:58:56 +10:00
vas-fault.c powerpc: Fix all occurences of duplicate words 2022-07-25 12:05:15 +10:00
vas-trace.h powerpc/vas: Define and use common vas_window struct 2021-06-20 21:58:56 +10:00
vas-window.c powerpc: Fix typos 2024-05-08 00:21:30 +10:00
vas.c powerpc/vas: Fix IRQ name allocation 2021-01-30 11:39:31 +11:00
vas.h powerpc/powernv/vas: Assign real address to rx_fifo in vas_rx_win_attr 2022-05-22 15:58:27 +10:00