merged. Bruce
In message: [linux-yocto][linux-yocto v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-soc][PATCH1/1] arm: imx: use raw_spin_lock_irqsave instead of spin_lock_irqsave on 08/12/2022 Xiaolei Wang wrote: > spin_lock_irqsave cannot appear in rtlinux in the atomic > environment, because the spin lock allows sleep under > rtlinux, otherwise the following trace will be reported: > > BUG: sleeping function called from invalid context at > kernel/locking/spinlock_rt.c:46 > in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0 > preempt_count: 1, expected: 0 > RCU nest depth: 0, expected: 0 > Preemption disabled at: > [<80bee4a0>] schedule_preempt_disabled+0x24/0x28 > CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.78-rt48-yocto-preempt-rt #1 > Hardware name: Freescale i.MX7 Dual (Device Tree) > [<80110f4c>] (unwind_backtrace) from [<8010aef8>] (show_stack+0x18/0x1c) > [<8010aef8>] (show_stack) from [<80be3f3c>] (dump_stack_lvl+0x40/0x4c) > [<80be3f3c>] (dump_stack_lvl) from [<80152954>] (__might_resched+0x16c/0x1f0) > [<80152954>] (__might_resched) from [<80bf232c>] (rt_spin_lock+0x34/0x80) > [<80bf232c>] (rt_spin_lock) from [<8011cf10>] > (imx_gpcv2_set_lpm_mode+0x1c/0xbc) > [<8011cf10>] (imx_gpcv2_set_lpm_mode) from [<8011bb24>] > (imx7d_enter_low_power_idle+0xa4/0x30c) > [<8011bb24>] (imx7d_enter_low_power_idle) from [<80897738>] > (cpuidle_enter_state+0xe8/0x2f0) > [<80897738>] (cpuidle_enter_state) from [<80897998>] (cpuidle_enter+0x3c/0x50) > [<80897998>] (cpuidle_enter) from [<8015a720>] (do_idle+0x234/0x264) > [<8015a720>] (do_idle) from [<8015aa60>] (cpu_startup_entry+0x20/0x28) > [<8015aa60>] (cpu_startup_entry) from [<81001138>] (start_kernel+0x5b8/0x69c) > [<81001138>] (start_kernel) from [<00000000>] (0x0) > > Signed-off-by: Xiaolei Wang <[email protected]> > --- > arch/arm/mach-imx/gpcv2.c | 30 +++++++++++++++--------------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/arch/arm/mach-imx/gpcv2.c b/arch/arm/mach-imx/gpcv2.c > index 3e8ab91cb97f..6ab69c7b72c7 100644 > --- a/arch/arm/mach-imx/gpcv2.c > +++ b/arch/arm/mach-imx/gpcv2.c > @@ -109,7 +109,7 @@ static u32 gpcv2_saved_imrs[IMR_NUM]; > static u32 gpcv2_saved_imrs_m4[IMR_NUM]; > static u32 gpcv2_mf_irqs[IMR_NUM]; > static u32 gpcv2_mf_request_on[IMR_NUM]; > -static DEFINE_SPINLOCK(gpcv2_lock); > +static DEFINE_RAW_SPINLOCK(gpcv2_lock); > > void imx_gpcv2_add_m4_wake_up_irq(u32 hwirq, bool enable) > { > @@ -122,10 +122,10 @@ void imx_gpcv2_add_m4_wake_up_irq(u32 hwirq, bool > enable) > return; > > mask = 1 << hwirq % 32; > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > gpcv2_wake_irqs[idx] = enable ? gpcv2_wake_irqs[idx] | mask : > gpcv2_wake_irqs[idx] & ~mask; > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > } > > static int imx_gpcv2_irq_set_wake(struct irq_data *d, unsigned int on) > @@ -137,10 +137,10 @@ static int imx_gpcv2_irq_set_wake(struct irq_data *d, > unsigned int on) > BUG_ON(idx >= IMR_NUM); > > mask = 1 << d->hwirq % 32; > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > gpcv2_wake_irqs[idx] = on ? gpcv2_wake_irqs[idx] | mask : > gpcv2_wake_irqs[idx] & ~mask; > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > > return 0; > } > @@ -226,7 +226,7 @@ void imx_gpcv2_set_lpm_mode(enum mxc_cpu_pwr_mode mode) > unsigned long flags; > u32 val1, val2; > > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > > val1 = readl_relaxed(gpc_base + GPC_LPCR_A7_BSC); > val2 = readl_relaxed(gpc_base + GPC_SLPCR); > @@ -283,7 +283,7 @@ void imx_gpcv2_set_lpm_mode(enum mxc_cpu_pwr_mode mode) > writel_relaxed(val1, gpc_base + GPC_LPCR_A7_BSC); > writel_relaxed(val2, gpc_base + GPC_SLPCR); > > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > } > > void imx_gpcv2_set_plat_power_gate_by_lpm(bool pdn) > @@ -329,7 +329,7 @@ void imx_gpcv2_set_cpu_power_gate_by_wfi(u32 cpu, bool > pdn) > unsigned long flags; > u32 val; > > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > val = readl_relaxed(gpc_base + GPC_LPCR_A7_AD); > > if (cpu == 0) { > @@ -355,7 +355,7 @@ void imx_gpcv2_set_cpu_power_gate_by_wfi(u32 cpu, bool > pdn) > } > } > writel_relaxed(val, gpc_base + GPC_LPCR_A7_AD); > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > } > > void imx_gpcv2_set_cpu_power_gate_by_lpm(u32 cpu, bool pdn) > @@ -363,7 +363,7 @@ void imx_gpcv2_set_cpu_power_gate_by_lpm(u32 cpu, bool > pdn) > unsigned long flags; > u32 val; > > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > > val = readl_relaxed(gpc_base + GPC_LPCR_A7_AD); > if (cpu == 0) { > @@ -384,7 +384,7 @@ void imx_gpcv2_set_cpu_power_gate_by_lpm(u32 cpu, bool > pdn) > } > > writel_relaxed(val, gpc_base + GPC_LPCR_A7_AD); > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > } > > void imx_gpcv2_set_cpu_power_gate_in_idle(bool pdn) > @@ -395,7 +395,7 @@ void imx_gpcv2_set_cpu_power_gate_in_idle(bool pdn) > for_each_possible_cpu(cpu) > imx_gpcv2_set_cpu_power_gate_by_lpm(cpu, pdn); > > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > > imx_gpcv2_set_m_core_pgc(pdn, GPC_PGC_C0); > if (num_online_cpus() > 1) > @@ -424,7 +424,7 @@ void imx_gpcv2_set_cpu_power_gate_in_idle(bool pdn) > gpc_base + GPC_PGC_ACK_SEL_A7); > imx_gpcv2_enable_rbc(false); > } > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > } > > void imx_gpcv2_set_mix_phy_gate_by_lpm(u32 pdn_index, u32 pup_index) > @@ -468,10 +468,10 @@ int imx_gpcv2_mf_power_on(unsigned int irq, unsigned > int on) > > BUG_ON(idx >= IMR_NUM); > > - spin_lock_irqsave(&gpcv2_lock, flags); > + raw_spin_lock_irqsave(&gpcv2_lock, flags); > gpcv2_mf_request_on[idx] = on ? gpcv2_mf_request_on[idx] | mask : > gpcv2_mf_request_on[idx] & ~mask; > - spin_unlock_irqrestore(&gpcv2_lock, flags); > + raw_spin_unlock_irqrestore(&gpcv2_lock, flags); > > return 0; > } > -- > 2.25.1 >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#12017): https://lists.yoctoproject.org/g/linux-yocto/message/12017 Mute This Topic: https://lists.yoctoproject.org/mt/95533935/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
