Skip to content

[PW_SID:1079839] Support non-leaf and range invalidation features in RISC-V#1777

Closed
linux-riscv-bot wants to merge 8 commits into
workflowfrom
pw1079839
Closed

[PW_SID:1079839] Support non-leaf and range invalidation features in RISC-V#1777
linux-riscv-bot wants to merge 8 commits into
workflowfrom
pw1079839

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1079839 applied to workflow

Name: Support non-leaf and range invalidation features in RISC-V
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1079839
Version: 1

Linux RISC-V bot and others added 8 commits April 15, 2026 22:41
Use in-line member documentation and add some small clarifications to
the members. This is preparation to add more members.

- Note that pgsize is only used by arm-smmuv3

- Note that freelist is only used by iommupt

- Reword queued to emphasize the flush-all behavior

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add a struct to keep track of all the things that are pending to be
merged into the gather. The way gather merging works, the pending
range is checked against the current gather, and the current gather
can be flushed before the pending things are added.

Thus, if new things have to be recorded in the gather they need to be
kept in the pending struct until after the gather is optionally
flushed.

The next patch adds new items to the gather and the pending struct.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Generating the ARM SMMUv3 and RISC-V invalidation commands optimally
requires some additional details from iommupt:

- leaf_levels_bitmap is used to compute the ARM Range Invalidation
  Table Top Level hint

- leaf_levels_bitmap is also used to compute the stride when
  generating single invalidations to invalidate once per leaf

- table_levels_bitmap also computes the ARM TTL for future cases when
  there are no leaves

Put these under a feature since only two drivers need to calculate
them.

This is also useful for the coming kunit iotlb invalidation test to
know more about what invalidation is happening.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…inval

RISC-V can use the information from PT_FEAT_DETAILED_GATHER to
compute the best stride to generate the single TLB invalidations.

Pass the gather down to the lower functions and create a full-range
gather for the flush-all callback.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Replace the per-page IOTLB invalidation loop with stride-based
invalidation that uses the level bitmaps from iommu_iotlb_gather.

Pre-calculate the invalidation information before running over the
bonds loop as it is the same for every entry.

The lowest set bit in the PT_FEAT_DETAILED_GATHER bitmaps indicates
the stride. This design ignores the SVNAPOT contiguous pages on the
assumption that they still have to be individually invalidated like
ARM requires, though it is not clear from the spec.

Replace the 2M cutoff for global invalidation with a 512 command
limit. This is the same for a 4k stride and now scales with the
stride size.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Non-leaf invalidation allows the single invalidate command to also
clear the walk cache. If NL is available, set the NL bit if the
gather indicates tables have been changed. The stride is already
calculated properly.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Use the RISC-V IOMMU Address Range Invalidation extension
(capabilities.S, spec section 9.3) to invalidate an IOVA range with
a single IOTINVAL.VMA command using NAPOT-encoded addressing.

One iommu_iotlb_gather maps to one NAPOT invalidation command. The
smallest power-of-two aligned range covering the gather is used since
over-invalidation is always safe.

S and NL seem to be orthogonal in the spec, so if NL is not
supported then global invalidation is probably always going to happen
as wiping a large range without a table change is not common.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 142.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1176.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1745.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 27.33 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 28.44 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.80 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 86.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
kdoc
Desc: Detects for kdoc errors
Duration: 0.98 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[1/7] iommu: Split the kdoc comment for struct iommu_iotlb_gather"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 140.96 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1135.58 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1695.53 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.87 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.63 seconds
Result: WARNING
Output:

CHECK: Lines should not end with a '('
#97: FILE: drivers/iommu/generic_pt/iommu_pt.h:513:
+		.pending.free_list = IOMMU_PAGES_LIST_INIT(

CHECK: Lines should not end with a '('
#123: FILE: drivers/iommu/generic_pt/iommu_pt.h:536:
+			gather_range_pending(

CHECK: Lines should not end with a '('
#157: FILE: drivers/iommu/generic_pt/iommu_pt.h:1086:
+		.pending.free_list = IOMMU_PAGES_LIST_INIT(

CHECK: Lines should not end with a '('
#178: FILE: drivers/iommu/generic_pt/iommu_pt.h:1132:
+		.pending.free_list = IOMMU_PAGES_LIST_INIT(

total: 0 errors, 0 warnings, 4 checks, 160 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 12eb493e57de ("iommupt: Add struct iommupt_pending_gather") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 4 checks, 160 lines checked
CHECK: Lines should not end with a '('


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 85.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 1.07 seconds
Result: ERROR
Output:

Detected static functions without inline keyword in header files:
+
+static void gather_add_table(struct iommupt_pending_gather *pending,
+			     const struct pt_state *pts,
--
+
+static void gather_range_pending(struct iommupt_pending_gather *pending,
+				 struct pt_iommu *iommu_table, pt_vaddr_t iova,
Detected static functions without inline keyword in header files: 1


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
kdoc
Desc: Detects for kdoc errors
Duration: 0.92 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[2/7] iommupt: Add struct iommupt_pending_gather"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.96 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.98 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.97 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 6: "[6/7] iommu/riscv: Add RISCV_IOMMU_CAPABILITIES_NL"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 141.10 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1136.93 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1706.55 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.67 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.92 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 3.82 seconds
Result: WARNING
Output:

CHECK: Lines should not end with a '('
#54: FILE: drivers/iommu/riscv/iommu-bits.h:741:
+static inline void riscv_iommu_cmd_inval_set_napot(

total: 0 errors, 0 warnings, 1 checks, 110 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 878783a89f63 ("iommu/riscv: Add NAPOT range invalidation support") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 1 checks, 110 lines checked
CHECK: Lines should not end with a '('


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.42 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
kdoc
Desc: Detects for kdoc errors
Duration: 0.90 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 7: "[7/7] iommu/riscv: Add NAPOT range invalidation support"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot force-pushed the workflow branch 7 times, most recently from 6d95e82 to dd4c390 Compare April 17, 2026 23:16
@linux-riscv-bot linux-riscv-bot deleted the pw1079839 branch April 18, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants