lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <DM6PR04MB65754AAF1FD62DC4ECF32A69FC222@DM6PR04MB6575.namprd04.prod.outlook.com>
Date: Thu, 21 Nov 2024 21:06:50 +0000
From: Avri Altman <Avri.Altman@....com>
To: Bart Van Assche <bvanassche@....org>, "Martin K . Petersen"
	<martin.petersen@...cle.com>
CC: "linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Bean Huo
	<beanhuo@...ron.com>
Subject: RE: [PATCH v4 2/3] scsi: ufs: core: Introduce a new clock_gating lock

> On 11/18/24 6:41 AM, Avri Altman wrote:
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index be5fe2407382..638d9c0e2603 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -1816,19 +1816,17 @@ static void ufshcd_exit_clk_scaling(struct
> ufs_hba *hba)
> >   static void ufshcd_ungate_work(struct work_struct *work)
> >   {
> >       int ret;
> > -     unsigned long flags;
> >       struct ufs_hba *hba = container_of(work, struct ufs_hba,
> >                       clk_gating.ungate_work);
> >
> >       cancel_delayed_work_sync(&hba->clk_gating.gate_work);
> >
> > -     spin_lock_irqsave(hba->host->host_lock, flags);
> > -     if (hba->clk_gating.state == CLKS_ON) {
> > -             spin_unlock_irqrestore(hba->host->host_lock, flags);
> > -             return;
> > +     scoped_guard(spinlock_irqsave, &hba->clk_gating.lock)
> > +     {
> > +             if (hba->clk_gating.state == CLKS_ON)
> > +                     return;
> >       }
> 
> Here and elsewhere, please move "{" to the end of the "scoped_guard()"
> line since that is the style used in all other Linux kernel code (I know that
> clang-format gets this wrong).
Yeah - I was running clang-format.
Done.

Thanks,
Avri

> 
> >   /* host lock must be held before calling this variant */
> 
> Please remove this comment since your patch makes it incorrect and replace
> it with a lockdep_assert_held() call.
Done.

> 
> > +     spin_lock_irqsave(hba->host->host_lock, flags);
> > +     if (ufshcd_has_pending_tasks(hba) ||
> > +         hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) {
> > +             spin_unlock_irqrestore(hba->host->host_lock, flags);
> > +             return;
> > +     }
> > +     spin_unlock_irqrestore(hba->host->host_lock, flags);
> 
> Why explicit lock/unlock calls instead of using scoped_guard()?
Should I apply those to host_lock as well?
I find it a bit confusing because in this change using guard et al. is limited to the new locks only. 

> 
> > diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index
> > d7aca9e61684..8f9997b0dbf9 100644
> > --- a/include/ufs/ufshcd.h
> > +++ b/include/ufs/ufshcd.h
> > @@ -403,6 +403,8 @@ enum clk_gating_state {
> >    * delay_ms
> >    * @ungate_work: worker to turn on clocks that will be used in case of
> >    * interrupt context
> > + * @clk_gating_workq: workqueue for clock gating work.
> > + * @lock: serialize access to some struct ufs_clk_gating members
> 
> Please document that @lock is the outer lock relative to the host lock.
Not sure what you mean?
host_lock is nested in one place only, should this goes to the @lock documentation?

Thanks,
Avri
> 
> Thanks,
> 
> Bart.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ