* [PATCH] iommu/tegra241-cmdqv: do not call smp_processor_id in preemptible context
@ 2024-11-19 0:19 Luis Claudio R. Goncalves
2024-11-19 7:15 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 3+ messages in thread
From: Luis Claudio R. Goncalves @ 2024-11-19 0:19 UTC (permalink / raw)
To: Thierry Reding, Krishna Reddy, Will Deacon, Robin Murphy,
Joerg Roedel, Jonathan Hunter, linux-kernel, iommu,
linux-arm-kernel, linux-tegra, Sebastian Andrzej Siewior,
Steven Rostedt, linux-rt-devel
With PREEMPT_RT enabled some of the calls to tegra241_cmdqv_get_cmdq()
during boot will happen in preemptible context. As this function calls
smp_processor_id(), these calls will trigger a "BUG: using smp_processor_id()
in preemptible" backtrace if DEBUG_PREEMPT is enabled.
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.
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
---
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
index fcd13d301fff6..3ea4369e838fe 100644
--- a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
+++ b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
@@ -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;
--
2.47.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/tegra241-cmdqv: do not call smp_processor_id in preemptible context
2024-11-19 0:19 [PATCH] iommu/tegra241-cmdqv: do not call smp_processor_id in preemptible context Luis Claudio R. Goncalves
@ 2024-11-19 7:15 ` Sebastian Andrzej Siewior
2024-11-19 16:55 ` Luis Claudio R. Goncalves
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-11-19 7:15 UTC (permalink / raw)
To: Luis Claudio R. Goncalves
Cc: Thierry Reding, Krishna Reddy, Will Deacon, Robin Murphy,
Joerg Roedel, Jonathan Hunter, linux-kernel, iommu,
linux-arm-kernel, linux-tegra, Steven Rostedt, linux-rt-devel
On 2024-11-18 21:19:28 [-0300], Luis Claudio R. Goncalves wrote:
> With PREEMPT_RT enabled some of the calls to tegra241_cmdqv_get_cmdq()
> during boot will happen in preemptible context. As this function calls
> smp_processor_id(), these calls will trigger a "BUG: using smp_processor_id()
> in preemptible" backtrace if DEBUG_PREEMPT is enabled.
If this is only on PREEMPT_RT, where is the disabled preemption coming
from on !PREEMPT_RT?
> 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.
>
> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/tegra241-cmdqv: do not call smp_processor_id in preemptible context
2024-11-19 7:15 ` Sebastian Andrzej Siewior
@ 2024-11-19 16:55 ` Luis Claudio R. Goncalves
0 siblings, 0 replies; 3+ messages in thread
From: Luis Claudio R. Goncalves @ 2024-11-19 16:55 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Thierry Reding, Krishna Reddy, Will Deacon, Robin Murphy,
Joerg Roedel, Jonathan Hunter, linux-kernel, iommu,
linux-arm-kernel, linux-tegra, Steven Rostedt, linux-rt-devel
On Tue, Nov 19, 2024 at 08:15:10AM +0100, Sebastian Andrzej Siewior wrote:
> On 2024-11-18 21:19:28 [-0300], Luis Claudio R. Goncalves wrote:
> > With PREEMPT_RT enabled some of the calls to tegra241_cmdqv_get_cmdq()
> > during boot will happen in preemptible context. As this function calls
> > smp_processor_id(), these calls will trigger a "BUG: using smp_processor_id()
> > in preemptible" backtrace if DEBUG_PREEMPT is enabled.
>
> If this is only on PREEMPT_RT, where is the disabled preemption coming
> from on !PREEMPT_RT?
You are correct. This is not exclusive to PREEMPT_RT, also happens with the
stock kernel. I ran more tests and this time I made sure DEBUG_PREEMPT was
enabled. That was enough to reproduce the problem.
> > 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.
> >
> > Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
>
> Sebastian
>
---end quoted text---
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-19 17:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-19 0:19 [PATCH] iommu/tegra241-cmdqv: do not call smp_processor_id in preemptible context Luis Claudio R. Goncalves
2024-11-19 7:15 ` Sebastian Andrzej Siewior
2024-11-19 16:55 ` Luis Claudio R. Goncalves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).