mbox series

[v3,0/9] Tidy some minor things in the stream table/cd table area

Message ID 0-v3-9fef8cdc2ff6+150d1-smmuv3_tidy_jgg@nvidia.com (mailing list archive)
Headers show
Series Tidy some minor things in the stream table/cd table area | expand

Message

Jason Gunthorpe Aug. 6, 2024, 11:31 p.m. UTC
Will pointed out that two places referring to the CD/STE struct did not
get the new types. While auditing this code a few more oddities were
noticed. Based on a feedback from Mostafa and Nicolin a few more things
were fixed up too

- Use types for all the HW structures everywhere even for the L1
  descriptors that are just a single 8 bytes. This helps with clarity of
  what everthing is pointing at
- Use indexing helpers for the STE/CD two level calculations
- Use sizeof(struct X) instead of open coded math on constants. The sizeof
  naturally follows the type of the related variable in almost all cases
- Remove redundant dma_addr_t's and save some memory
- Remove redundant devm usage
- Use the modern rbtree API

Parts of this have been sitting in my tree for a while now, it grew a bit
since v1, but nothing is particularly profound here. Enough is merged now
that they can be cleanly based and are seperate from my other series.

v3:
 - Rebase to v6.11-rc2
 - Preserve the "2-level strtab only covers %u/%u bits of SID" without
   change
 - Vertically align some of the constants
 - Use u32 for the type of the index and sid
 - Fix missing * in le64_to_cpu() in interior patch
 - Bring back accidently lost "Use the new rb tree helpers" patch
v2: https://lore.kernel.org/r/0-v2-318ed5f6983b+198f-smmuv3_tidy_jgg@nvidia.com
 - Add a patch to add structs for the L1/L2 HW layouts and use their
   sizeof and type instead of constants and generic __le64 *.
 - Add a patch for L1/L2 indexing helpers for clarity
 - Reorder patches
 - Redo the union layout in the cfg for both cases
 - Fully remove some more defines
v1: https://lore.kernel.org/r/0-v1-1b720dce51d1+4f44-smmuv3_tidy_jgg@nvidia.com

Jason Gunthorpe (9):
  iommu/arm-smmu-v3: Use the new rb tree helpers
  iommu/arm-smmu-v3: Add arm_smmu_strtab_l1/2_idx()
  iommu/arm-smmu-v3: Add types for each level of the 2 level stream
    table
  iommu/arm-smmu-v3: Reorganize struct arm_smmu_strtab_cfg
  iommu/arm-smmu-v3: Remove strtab_base/cfg
  iommu/arm-smmu-v3: Do not use devm for the cd table allocations
  iommu/arm-smmu-v3: Shrink the cdtab l1_desc array
  iommu/arm-smmu-v3: Add types for each level of the CD table
  iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 355 +++++++++-----------
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 100 ++++--
 2 files changed, 232 insertions(+), 223 deletions(-)


base-commit: de9c2c66ad8e787abec7c9d7eff4f8c3cdd28aed

Comments

Jason Gunthorpe Sept. 5, 2024, 7:25 p.m. UTC | #1
On Tue, Aug 06, 2024 at 08:31:14PM -0300, Jason Gunthorpe wrote:

> Jason Gunthorpe (9):
>   iommu/arm-smmu-v3: Use the new rb tree helpers
>   iommu/arm-smmu-v3: Add arm_smmu_strtab_l1/2_idx()
>   iommu/arm-smmu-v3: Add types for each level of the 2 level stream
>     table
>   iommu/arm-smmu-v3: Reorganize struct arm_smmu_strtab_cfg
>   iommu/arm-smmu-v3: Remove strtab_base/cfg
>   iommu/arm-smmu-v3: Do not use devm for the cd table allocations
>   iommu/arm-smmu-v3: Shrink the cdtab l1_desc array
>   iommu/arm-smmu-v3: Add types for each level of the CD table
>   iommu/arm-smmu-v3: Reorganize struct arm_smmu_ctx_desc_cfg

Will? Is there something you are waiting on here?

Thanks,
Jason
Nicolin Chen Sept. 5, 2024, 8:10 p.m. UTC | #2
On Tue, Aug 06, 2024 at 08:31:14PM -0300, Jason Gunthorpe wrote:
> Will pointed out that two places referring to the CD/STE struct did not
> get the new types. While auditing this code a few more oddities were
> noticed. Based on a feedback from Mostafa and Nicolin a few more things
> were fixed up too
> 
> - Use types for all the HW structures everywhere even for the L1
>   descriptors that are just a single 8 bytes. This helps with clarity of
>   what everthing is pointing at
> - Use indexing helpers for the STE/CD two level calculations
> - Use sizeof(struct X) instead of open coded math on constants. The sizeof
>   naturally follows the type of the related variable in almost all cases
> - Remove redundant dma_addr_t's and save some memory
> - Remove redundant devm usage
> - Use the modern rbtree API
> 
> Parts of this have been sitting in my tree for a while now, it grew a bit
> since v1, but nothing is particularly profound here. Enough is merged now
> that they can be cleanly based and are seperate from my other series.
> 
> v3:
>  - Rebase to v6.11-rc2
>  - Preserve the "2-level strtab only covers %u/%u bits of SID" without
>    change
>  - Vertically align some of the constants
>  - Use u32 for the type of the index and sid
>  - Fix missing * in le64_to_cpu() in interior patch
>  - Bring back accidently lost "Use the new rb tree helpers" patch

I didn't exclusively test this series but it has been included in
my nesting branch for a while. Considering 2-stage configurations
and vSVA cases are involved during my testings, all my Tested-bys
still stand.

Thanks
Nicolin
Will Deacon Sept. 6, 2024, 2:35 p.m. UTC | #3
On Tue, 06 Aug 2024 20:31:14 -0300, Jason Gunthorpe wrote:
> Will pointed out that two places referring to the CD/STE struct did not
> get the new types. While auditing this code a few more oddities were
> noticed. Based on a feedback from Mostafa and Nicolin a few more things
> were fixed up too
> 
> - Use types for all the HW structures everywhere even for the L1
>   descriptors that are just a single 8 bytes. This helps with clarity of
>   what everthing is pointing at
> - Use indexing helpers for the STE/CD two level calculations
> - Use sizeof(struct X) instead of open coded math on constants. The sizeof
>   naturally follows the type of the related variable in almost all cases
> - Remove redundant dma_addr_t's and save some memory
> - Remove redundant devm usage
> - Use the modern rbtree API
> 
> [...]

Applied first change to will (for-joerg/arm-smmu/updates), thanks!

[1/9] iommu/arm-smmu-v3: Use the new rb tree helpers
      https://git.kernel.org/will/c/a2bb820e862d

Cheers,