From: Avri Altman <Avri.Altman@wdc.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Manivannan Sadhasivam <manisadhasivam.linux@gmail.com>,
Bart Van Assche <bvanassche@acm.org>,
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH] scsi: ufs: core: Ensure clk_gating.lock is used only after initialization
Date: Thu, 23 Jan 2025 20:03:26 +0000 [thread overview]
Message-ID: <DM6PR04MB6575B668C3A5124BFDAA9B9AFCE02@DM6PR04MB6575.namprd04.prod.outlook.com> (raw)
In-Reply-To: <CAMuHMdXB2NLs0yVSf_3RpUip4pAW5kC8Y0Ow2G_GiZirZW1Yjg@mail.gmail.com>
> 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
prev parent reply other threads:[~2025-01-23 20:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 6:27 Avri Altman
2025-01-22 8:17 ` Manivannan Sadhasivam
2025-01-22 11:04 ` Avri Altman
2025-01-22 17:07 ` Manivannan Sadhasivam
2025-01-22 19:15 ` Bart Van Assche
2025-01-23 7:43 ` Avri Altman
2025-01-23 15:20 ` Geert Uytterhoeven
2025-01-23 20:03 ` Avri Altman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM6PR04MB6575B668C3A5124BFDAA9B9AFCE02@DM6PR04MB6575.namprd04.prod.outlook.com \
--to=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=manisadhasivam.linux@gmail.com \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®