diff mbox series

[rc] iommu/tegra241-cmdqv: Fix alignment failure at max_n_shift

Message ID 20241111030226.1940737-1-nicolinc@nvidia.com
State New
Headers show
Series [rc] iommu/tegra241-cmdqv: Fix alignment failure at max_n_shift | expand

Commit Message

Nicolin Chen Nov. 11, 2024, 3:02 a.m. UTC
When configuring a kernel with PAGE_SIZE=4KB, depending on its setting of
CONFIG_CMA_ALIGNMENT, VCMDQ_LOG2SIZE_MAX=19 could fail the alignment test
and trigger a WARN_ON:
    WARNING: at drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3646
    Call trace:
     arm_smmu_init_one_queue+0x15c/0x210
     tegra241_cmdqv_init_structures+0x114/0x338
     arm_smmu_device_probe+0xb48/0x1d90

Fix it by capping max_n_shift to CMDQ_MAX_SZ_SHIFT as SMMUv3 CMDQ does.

Fixes: 918eb5c856f6 ("iommu/arm-smmu-v3: Add in-kernel support for NVIDIA Tegra241 (Grace) CMDQV")
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Will Deacon Nov. 12, 2024, 4:56 p.m. UTC | #1
On Sun, 10 Nov 2024 19:02:26 -0800, Nicolin Chen wrote:
> When configuring a kernel with PAGE_SIZE=4KB, depending on its setting of
> CONFIG_CMA_ALIGNMENT, VCMDQ_LOG2SIZE_MAX=19 could fail the alignment test
> and trigger a WARN_ON:
>     WARNING: at drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3646
>     Call trace:
>      arm_smmu_init_one_queue+0x15c/0x210
>      tegra241_cmdqv_init_structures+0x114/0x338
>      arm_smmu_device_probe+0xb48/0x1d90
> 
> [...]

Applied to iommu (arm/smmu), thanks!

[1/1] iommu/tegra241-cmdqv: Fix alignment failure at max_n_shift
      https://git.kernel.org/iommu/c/a3799717b881

Cheers,
diff mbox series

Patch

diff --git a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
index 01a6f0c61f44..8a59f3ed8dde 100644
--- a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
+++ b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
@@ -558,7 +558,8 @@  static int tegra241_vcmdq_alloc_smmu_cmdq(struct tegra241_vcmdq *vcmdq)
 
 	snprintf(name, 16, "vcmdq%u", vcmdq->idx);
 
-	q->llq.max_n_shift = VCMDQ_LOG2SIZE_MAX;
+	/* Queue size, capped to ensure natural alignment */
+	q->llq.max_n_shift = min_t(u32, CMDQ_MAX_SZ_SHIFT, VCMDQ_LOG2SIZE_MAX);
 
 	/* Use the common helper to init the VCMDQ, and then... */
 	ret = arm_smmu_init_one_queue(smmu, q, vcmdq->page0,