Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/arm-smmu-v3: Use device properties for pasid-num-bits

The pasid-num-bits property shouldn't need a dedicated fwspec field,
it's a job for device properties. Add properties for IORT, and access
the number of PASID bits using device_property_read_u32().

Suggested-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Will Deacon <will@kernel.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Acked-by: Hanjun Guo <guohanjun@huawei.com>
Link: https://lore.kernel.org/r/20210401154718.307519-3-jean-philippe@linaro.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Jean-Philippe Brucker and committed by
Joerg Roedel
434b73e6 0d35309a

+9 -14
+7 -6
drivers/acpi/arm64/iort.c
··· 968 968 static void iort_named_component_init(struct device *dev, 969 969 struct acpi_iort_node *node) 970 970 { 971 + struct property_entry props[2] = {}; 971 972 struct acpi_iort_named_component *nc; 972 - struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); 973 - 974 - if (!fwspec) 975 - return; 976 973 977 974 nc = (struct acpi_iort_named_component *)node->node_data; 978 - fwspec->num_pasid_bits = FIELD_GET(ACPI_IORT_NC_PASID_BITS, 979 - nc->node_flags); 975 + props[0] = PROPERTY_ENTRY_U32("pasid-num-bits", 976 + FIELD_GET(ACPI_IORT_NC_PASID_BITS, 977 + nc->node_flags)); 978 + 979 + if (device_add_properties(dev, props)) 980 + dev_warn(dev, "Could not add device properties\n"); 980 981 } 981 982 982 983 static int iort_nc_iommu_map(struct device *dev, struct acpi_iort_node *node)
+2 -1
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
··· 2392 2392 } 2393 2393 } 2394 2394 2395 - master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits); 2395 + device_property_read_u32(dev, "pasid-num-bits", &master->ssid_bits); 2396 + master->ssid_bits = min(smmu->ssid_bits, master->ssid_bits); 2396 2397 2397 2398 /* 2398 2399 * Note that PASID must be enabled before, and disabled after ATS:
-5
drivers/iommu/of_iommu.c
··· 210 210 of_pci_iommu_init, &info); 211 211 } else { 212 212 err = of_iommu_configure_device(master_np, dev, id); 213 - 214 - fwspec = dev_iommu_fwspec_get(dev); 215 - if (!err && fwspec) 216 - of_property_read_u32(master_np, "pasid-num-bits", 217 - &fwspec->num_pasid_bits); 218 213 } 219 214 220 215 /*
-2
include/linux/iommu.h
··· 572 572 * @ops: ops for this device's IOMMU 573 573 * @iommu_fwnode: firmware handle for this device's IOMMU 574 574 * @flags: IOMMU_FWSPEC_* flags 575 - * @num_pasid_bits: number of PASID bits supported by this device 576 575 * @num_ids: number of associated device IDs 577 576 * @ids: IDs which this device may present to the IOMMU 578 577 */ ··· 579 580 const struct iommu_ops *ops; 580 581 struct fwnode_handle *iommu_fwnode; 581 582 u32 flags; 582 - u32 num_pasid_bits; 583 583 unsigned int num_ids; 584 584 u32 ids[]; 585 585 };