Skip to contentSkip to conversation

iommu/tegra241-cmdqv: do not use smp_processor_id in preemptible context

PATCH Applied Luis Claudio R. Goncalves 4 participants 4 messages Dec 6, 2024 – Dec 10, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iommu/tegra241-cmdqv: do not use smp_processor_id in preemptible context

During boot some of the calls to tegra241_cmdqv_get_cmdq() will happen in preemptible context. As this function calls smp_processor_id(), if CONFIG_DEBUG_PREEMPT is enabled, these calls will trigger a series of "BUG: using smp_processor_id() in preemptible" backtraces.

As tegra241_cmdqv_get_cmdq() only calls smp_processor_id() to use the CPU number as a factor to balance out traffic on cmdq usage, it is safe to use raw_smp_processor_id() here.

v2: Sebastian helped identify that the problem was not exclusive to kernels
with PREEMPT_RT enabled. The delta between v1 and v2 is the description.

---
 drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c +1 -1
index fcd13d301fff6..3ea4369e838fe 100644
@@ -339,7 +339,7 @@ tegra241_cmdqv_get_cmdq(struct arm_smmu_device *smmu,
 	 * one CPU at a time can enter the process, while the others
 	 * will be spinning at the same lock.
 	 */
-	lidx = smp_processor_id() % cmdqv->num_lvcmdqs_per_vintf;
+	lidx = raw_smp_processor_id() % cmdqv->num_lvcmdqs_per_vintf;
 	vcmdq = vintf->lvcmdqs[lidx];
 	if (!vcmdq || !READ_ONCE(vcmdq->enabled))
 		return NULL;
Signature · 1 line
2.47.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Luis Claudio R. Goncalves

During boot some of the calls to tegra241_cmdqv_get_cmdq() will happen in preemptible context. As this function calls smp_processor_id(), if CONFIG_DEBUG_PREEMPT is enabled, these calls will trigger a series of "BUG: using smp_processor_id() in preemptible" backtraces.

As tegra241_cmdqv_get_cmdq() only calls smp_processor_id() to use the CPU number as a factor to balance out traffic on cmdq usage, it is safe to use raw_smp_processor_id() here.

Quoted 7 lines

v2: Sebastian helped identify that the problem was not exclusive to kernels
with PREEMPT_RT enabled. The delta between v1 and v2 is the description.

---
 drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Makes sense

Jason

Reviewed-by Tested-by on v2 1/1
#2 lore raw
In reply to Luis Claudio R. Goncalves
Quoted 4 lines · Luis Claudio R. Goncalves

During boot some of the calls to tegra241_cmdqv_get_cmdq() will happen in preemptible context. As this function calls smp_processor_id(), if CONFIG_DEBUG_PREEMPT is enabled, these calls will trigger a series of "BUG: using smp_processor_id() in preemptible" backtraces.

Confirmed the BUG prints. Should we CC stable tree?

Quoted 8 lines

As tegra241_cmdqv_get_cmdq() only calls smp_processor_id() to use the CPU number as a factor to balance out traffic on cmdq usage, it is safe to use raw_smp_processor_id() here.

v2: Sebastian helped identify that the problem was not exclusive to kernels
with PREEMPT_RT enabled. The delta between v1 and v2 is the description.

Thanks
Nicolin

maintainer Applied
#3 lore raw
In reply to Luis Claudio R. Goncalves
Quoted 10 lines · Luis Claudio R. Goncalves

During boot some of the calls to tegra241_cmdqv_get_cmdq() will happen in preemptible context. As this function calls smp_processor_id(), if CONFIG_DEBUG_PREEMPT is enabled, these calls will trigger a series of "BUG: using smp_processor_id() in preemptible" backtraces.

As tegra241_cmdqv_get_cmdq() only calls smp_processor_id() to use the CPU number as a factor to balance out traffic on cmdq usage, it is safe to use raw_smp_processor_id() here.

[...]

Applied to will (for-joerg/arm-smmu/fixes), thanks!

[1/1] iommu/tegra241-cmdqv: do not use smp_processor_id in preemptible context

      https://git.kernel.org/will/c/1f806218164d

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev