[PATCH 01/19] iommu/arm-smmu-v3: Add a type for the STE
Will Deacon
will at kernel.org
Fri Oct 13 03:37:35 PDT 2023
On Tue, Oct 10, 2023 at 09:33:07PM -0300, Jason Gunthorpe wrote:
> Instead of passing a naked __le16 * around to represent a STE wrap it in a
> "struct arm_smmu_ste" with an array of the correct size. This makes it
> much clearer which functions will comprise the "STE API".
>
> Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 54 ++++++++++-----------
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 7 ++-
> 2 files changed, 32 insertions(+), 29 deletions(-)
[...]
> @@ -2209,26 +2210,22 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
> return 0;
> }
>
> -static __le64 *arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid)
> +static struct arm_smmu_ste *
> +arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid)
> {
> - __le64 *step;
> struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
>
> if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) {
> - struct arm_smmu_strtab_l1_desc *l1_desc;
> int idx;
>
> /* Two-level walk */
> idx = (sid >> STRTAB_SPLIT) * STRTAB_L1_DESC_DWORDS;
> - l1_desc = &cfg->l1_desc[idx];
> - idx = (sid & ((1 << STRTAB_SPLIT) - 1)) * STRTAB_STE_DWORDS;
> - step = &l1_desc->l2ptr[idx];
> + return &cfg->l1_desc[idx].l2ptr[sid & ((1 << STRTAB_SPLIT) - 1)];
> } else {
> /* Simple linear lookup */
> - step = &cfg->strtab[sid * STRTAB_STE_DWORDS];
> + return (struct arm_smmu_ste *)&cfg
> + ->strtab[sid * STRTAB_STE_DWORDS];
Why not change the type of 'struct arm_smmu_strtab_cfg::strtab' at the same
time?
Will
More information about the linux-arm-kernel
mailing list