[PATCH 14/30] iommu/exynos: Move to iommu_of_xlate()

2023-11-29 Thread Jason Gunthorpe
gned-off-by: Jason Gunthorpe --- drivers/iommu/exynos-iommu.c | 79 +--- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 2c6e9094f1e979..c301aa87fe0ff0 100644 --- a/drivers/iomm

[PATCH 04/30] ACPI: IORT: Remove fwspec from the reserved region code

2023-11-29 Thread Jason Gunthorpe
iort_iommu_get_resv_regions() needs access to the parsed id array that is currently stored in the iommu_fwspec. Instead of getting this from the fwspec inside the iort code have the caller pass it in. Signed-off-by: Jason Gunthorpe --- drivers/acpi/arm64/iort.c | 88

[PATCH 15/30] iommu/msm: Move to iommu_of_xlate()

2023-11-29 Thread Jason Gunthorpe
patch. Keep things basically the same, but rely on the core code to discover the iommu_device and stop confusingly using dev_iommu_priv to join SIDs into the same master when processing the assumed-to-be-sorted iommus list. Signed-off-by: Jason Gunthorpe --- drivers/iommu/msm_iommu.c

[PATCH 05/30] iommu: Add iommu_probe_info

2023-11-29 Thread Jason Gunthorpe
. Place this in a new header "iommu-driver.h" which is intended to help isolate APIs that are only for use by the drivers away from the consumers of the IOMMU API. Signed-off-by: Jason Gunthorpe --- drivers/acpi/scan.c | 7 +- drivers/iommu/iommu.c

[PATCH 20/30] iommu/ipmmu-vmsa: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
-device data not the iommu. Signed-off-by: Jason Gunthorpe --- drivers/iommu/ipmmu-vmsa.c | 96 +- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index ace1fc4bd34b0f..ba984017065f98 100644

[PATCH 24/30] iommu/virtio: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
populate it. Convert the rest of the funcs from calling dev_iommu_fwspec_get() to using he per-device data and remove all use of fwspec. Signed-off-by: Jason Gunthorpe --- drivers/iommu/virtio-iommu.c | 67 +--- 1 file changed, 23 insertions(+), 44 deletions(-) diff

[PATCH 01/30] iommu/of: Make a of_iommu_for_each_id()

2023-11-29 Thread Jason Gunthorpe
Take the existing machinery that was wired to invoking of_xlate on each id through the various maps and aliases and allow it to call a function pointer with an opaque. Call of_iommu_xlate() using the existing of_iommu_for_each_id(). Signed-off-by: Jason Gunthorpe --- drivers/iommu/of_iommu.c

[PATCH 18/30] iommu/tegra: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
dev_iommu_priv_get() to use the per-device data not the iommu. Signed-off-by: Jason Gunthorpe --- drivers/iommu/tegra-smmu.c | 154 +++-- 1 file changed, 47 insertions(+), 107 deletions(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index

[PATCH 07/30] iommu/of: Call of_iommu_get_resv_regions() directly

2023-11-29 Thread Jason Gunthorpe
() instead. Move the declaration of of_iommu_get_resv_regions() to iommu-driver.h since it is now intended to be called by drivers. Signed-off-by: Jason Gunthorpe --- drivers/iommu/apple-dart.c | 5 ++--- drivers/iommu/dma-iommu.c| 5 ++--- drivers/iommu/of_iommu.c | 3 +++ drivers

[PATCH 26/30] iommu/arm-smmu-v3: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
populate it. Convert the rest of the funcs from calling dev_iommu_fwspec_get() to using the per-device data and remove all use of fwspec. Directly call iort_iommu_get_resv_regions() and pass in the internal id array instead of getting it from the fwspec. Signed-off-by: Jason Gunthorpe --- drivers

[PATCH 23/30] iommu/viot: Add iommu_viot_get_single_iommu()

2023-11-29 Thread Jason Gunthorpe
the cache. Signed-off-by: Jason Gunthorpe --- drivers/acpi/scan.c | 1 + drivers/iommu/Makefile | 1 + drivers/iommu/viot_iommu.c | 70 include/linux/iommu-driver.h | 25 + 4 files changed, 97 insertions(+) create mode 100644

[PATCH 30/30] iommu: Remove fwspec and related

2023-11-29 Thread Jason Gunthorpe
() rely on iommu_find_init_device() for everything. Signed-off-by: Jason Gunthorpe --- drivers/acpi/arm64/iort.c | 76 drivers/acpi/scan.c | 52 +-- drivers/acpi/viot.c | 32 --- drivers/iommu/apple

[PATCH 09/30] iommu/rockchip: Move to iommu_of_get_single_iommu()

2023-11-29 Thread Jason Gunthorpe
ch_device unless dev->iommu is set and has an ops. This can only happen if probe_device was done. Remove the checks. Signed-off-by: Jason Gunthorpe --- drivers/iommu/rockchip-iommu.c | 74 +++--- 1 file changed, 24 insertions(+), 50 deletions(-) diff --git a/drivers/i

[PATCH 25/30] iommu/iort: Add iommu_iort_get_single_iommu()

2023-11-29 Thread Jason Gunthorpe
This API is basically the same as iommu_of_get_single_iommu(), except that it will try to parse the ACPI IORT table if it is available. The ACPI IORT table can return a flags value to indicate IOMMU_FWSPEC_PCI_RC_ATS, return this through an output flags pointer. Signed-off-by: Jason Gunthorpe

[PATCH 10/30] iommu/sprd: Move to iommu_of_get_single_iommu()

2023-11-29 Thread Jason Gunthorpe
sprd suports a single iommu instance and only a single id. Parse it directly using iommu_of_get_single_iommu() and remove sprd_iommu_of_xlate(). It stores the iommu, not a per-driver struct in the dev_iommu_priv(), keep it that way for now. Signed-off-by: Jason Gunthorpe --- drivers/iommu/sprd

[PATCH 17/30] iommu: Add iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
)) return ERR_CAST(smmu_device); [..] dev_iommu_priv_set(dev, data); return &iommu->iommu; Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommu.c| 21 ++ drivers/iommu/of_iommu.c | 21 +- include/linux/iom

[PATCH 12/30] iommu/of: Add iommu_of_xlate()

2023-11-29 Thread Jason Gunthorpe
ERR_PTR(-ENOMEM); ret = iommu_of_xlate(pinf, &apple_dart_iommu_ops, 1, &apple_dart_of_xlate, cfg); if (ret) goto err_free; dev_iommu_priv_set(dev, cfg); return &??->iommu; // The first iommu_device parsed Signed-off-by:

[PATCH 03/30] ACPI: IORT: Make a iort_iommu_for_each_id()

2023-11-29 Thread Jason Gunthorpe
Similar to of_iommu_for_each_id() this parses the IORT ACPI description and invokes a function over each entry in the table. Have iort_iommu_configure_id() use the new function to call iort_iommu_xlate(). Signed-off-by: Jason Gunthorpe --- drivers/acpi/arm64/iort.c | 118

[PATCH 00/30] Make a new API for drivers to use to get their FW

2023-11-29 Thread Jason Gunthorpe
mmu probe info' that will do this step and then we can fully execute probe outside the *_dma_configure() context. The big win here is the extensive cleaning of the driver's probe paths. There is alot of "creative" stuff there, this cleans almost all of it away. This is on g

[PATCH 19/30] iommu/mtk: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
v_get() to use the per-device data not the iommu. Signed-off-by: Jason Gunthorpe --- drivers/iommu/mtk_iommu.c | 116 -- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 7abe9e85a

[PATCH 22/30] iommu/qcom: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
the iommu. Remove to_iommu(). Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 161 1 file changed, 81 insertions(+), 80 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index

[PATCH 13/30] iommu/dart: Move to iommu_of_xlate()

2023-11-29 Thread Jason Gunthorpe
ossible error flows. Signed-off-by: Jason Gunthorpe --- drivers/iommu/apple-dart.c | 58 +- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index bb0e5a4577fc03..b796c68ae45ad8 100644 --- a/

[PATCH 11/30] iommu/sun50i: Move to iommu_of_get_single_iommu()

2023-11-29 Thread Jason Gunthorpe
with generic_single_device_group(). Since there is a single translation the ID presumably doesn't matter. Allocate a sun50i_iommu_device struct during probe to be like all the other drivers. Signed-off-by: Jason Gunthorpe --- drivers/iommu/sun50i-iommu.c | 60 +--- 1 file c

[PATCH 16/30] iommu/tegra: Route tegra_dev_iommu_get_stream_id() through an op

2023-11-29 Thread Jason Gunthorpe
ion only supports tegra-smmu and arm-smmu, so implement the function there. This makes way to moving the id list into the private memory of the driver. Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 11 +++ drivers/iommu/of_iommu.c |

[PATCH 21/30] iommu/mtk_v1: Move to iommu_fw_alloc_per_device_ids()

2023-11-29 Thread Jason Gunthorpe
f the funcs from calling dev_iommu_fwspec_get() to using the per-device data and remove all use of fwspec. Convert the places using dev_iommu_priv_get() to use the per-device data not the iommu. Signed-off-by: Jason Gunthorpe --- drivers/iommu/mtk_iommu_v1.c | 162 +++--

[PATCH 27/30] iommu/arm-smmu: Move to iommu_of_xlate()

2023-11-29 Thread Jason Gunthorpe
from the other places in the driver. Directly call iort_iommu_get_resv_regions() and pass in the internal id array instead of getting it from the fwspec. Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 6 +- drivers/iommu/arm/arm-smmu/arm-smmu.c

[PATCH 02/30] ACPI: VIOT: Make a viot_iommu_for_each_id()

2023-11-29 Thread Jason Gunthorpe
Similar to of_iommu_for_each_id() this parses the VIOT ACPI description and invokes a function over each entry in the table. Have viot_iommu_configure() use the new function to call viot_dev_iommu_init(). Signed-off-by: Jason Gunthorpe --- drivers/acpi/viot.c | 54

[PATCH 06/30] iommu: Make iommu_ops_from_fwnode() return the iommu_device

2023-11-29 Thread Jason Gunthorpe
pointless. Remove it. Signed-off-by: Jason Gunthorpe --- drivers/acpi/arm64/iort.c| 12 +++- drivers/acpi/viot.c | 9 + drivers/iommu/iommu.c| 20 +--- drivers/iommu/of_iommu.c | 16 ++-- include/linux/iommu-driver.h | 3

[PATCH 08/30] iommu/of: Add iommu_of_get_single_iommu()

2023-11-29 Thread Jason Gunthorpe
R(-ENOMEM); [..] dev_iommu_priv_set(dev, data); return &iommu->iommu; Signed-off-by: Jason Gunthorpe --- drivers/acpi/scan.c | 1 + drivers/iommu/iommu.c| 52 ++ drivers/iommu/of_iommu.c | 59 + include/linu

[PATCH 28/30] iommu: Call all drivers if there is no fwspec

2023-11-29 Thread Jason Gunthorpe
ingle op in the system to probe each device. If there are multiple ops we invoke each one once, and drivers that don't understand the struct device should return -ENODEV. Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommu.c | 59 +++ 1 file changed,

[PATCH 29/30] iommu: Check for EPROBE_DEFER using the new FW parsers

2023-11-29 Thread Jason Gunthorpe
NODEV and we are under a dma_configure then ensure that all the applicable FW parsers are given a chance to run. Keep track of any parsers that may have run during the probe ops call and don't do them again. Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommu.c

Re: [PATCH] RDMA/uverbs: Remove flexible arrays from struct *_filter

2024-02-12 Thread Jason Gunthorpe
On Mon, Feb 12, 2024 at 10:30:17AM -0800, Kees Cook wrote: > I might suggest doing a binary difference comparison[1], as it's possible > that "real_sz" is being used to try to avoid trailing padding on > structs. I wasn't able to trivially construct an example, so maybe I'm > not understanding its

Re: [PATCH v2] RDMA/uverbs: Remove flexible arrays from struct *_filter

2024-02-21 Thread Jason Gunthorpe
On Sat, Feb 17, 2024 at 03:29:13PM +0100, Erick Archer wrote: > When a struct containing a flexible array is included in another struct, > and there is a member after the struct-with-flex-array, there is a > possibility of memory overlap. These cases must be audited [1]. See: > > struct inner { >

Re: [PATCH][next] RDMA/cm: Avoid -Wflex-array-member-not-at-end warning

2024-03-25 Thread Jason Gunthorpe
On Mon, Mar 25, 2024 at 02:24:07PM -0600, Gustavo A. R. Silva wrote: > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > Use the `struct_group_tagged()` helper to separate the flexible array > from the rest of the members in flexible `struct