RE: [PATCH] scsi: ufs: core: Ensure clk_gating.lock is used only after initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I just ran into the same issue on R-Car S4 (S4 Starter Kit).
> 
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -9142,7 +9142,7 @@ static int ufshcd_setup_clocks(struct ufs_hba *hba,
> bool on)
> >                         if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled)
> >                                 clk_disable_unprepare(clki->clk);
> >                 }
> > -       } else if (!ret && on) {
> > +       } else if (!ret && on && hba->clk_gating.is_initialized) {
> >                 scoped_guard(spinlock_irqsave, &hba->clk_gating.lock)
> >                         hba->clk_gating.state = CLKS_ON;
> >                 trace_ufshcd_clk_gating(dev_name(hba->dev),
> 
> This looks like a very fragile solution to me...
> 
> In addition, while this change does fix this particular spinlock warning, it just
> BUGs in a different place later:
> 
>   do_raw_spin_lock+0x34/0xb4
>   _raw_spin_lock_irqsave+0x1c/0x30
>   class_spinlock_irqsave_constructor+0x18/0x30
> - ufshcd_setup_clocks+0x98/0x23c
> - ufshcd_init+0x268/0xd2c
> + ufshcd_release+0x30/0x74
> + ufshcd_send_uic_cmd+0x70/0x90
> + ufshcd_link_startup.constprop.0+0x70/0x258
> + ufshcd_init+0xa38/0xd2c
>   ufshcd_pltfrm_init+0x618/0x738
>   ufs_renesas_probe+0x18/0x24
>   platform_probe+0x68/0xb8
I don't understand how it is possible that `ufshcd_init_clk_gating(hba)` is called after `ufshcd_link_startup(hba)` in 'ufshcd_init'.
Nor how concurrency could take place in this init flow.
Evidently, this is happening.

> 
> I think you should initialize all your spinlocks (and mutexes) early in
> ufshcd_init(), instead of sprinkled across various helper functions.
This is the case today.  Let me suggest a different fix.

Thanks,
Avri

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But when
> I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux