[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1fa9d66079d34768f16fb0ef8d8c46ceead7bff6.camel@gmail.com>
Date: Wed, 23 Dec 2020 22:52:07 +0100
From: Bean Huo <huobean@...il.com>
To: Stanley Chu <stanley.chu@...iatek.com>
Cc: alim.akhtar@...sung.com, avri.altman@....com,
asutoshd@...eaurora.org, jejb@...ux.ibm.com,
martin.petersen@...cle.com, beanhuo@...ron.com, bvanassche@....org,
tomas.winkler@...el.com, cang@...eaurora.org,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 1/7] scsi: ufs: Add "wb_on" sysfs node to control WB
on/off
On Tue, 2020-12-22 at 14:08 +0800, Stanley Chu wrote:
> Hi Bean,
>
> On Wed, 2020-12-16 at 00:05 +0100, Bean Huo wrote:
> > From: Bean Huo <beanhuo@...ron.com>
> >
> > Currently UFS WriteBooster driver uses clock scaling up/down to set
> > WB on/off, for the platform which doesn't support
> > UFSHCD_CAP_CLK_SCALING,
> > WB will be always on. Provide a sysfs attribute to enable/disable
> > WB
> > during runtime. Write 1/0 to "wb_on" sysfs node to enable/disable
> > UFS WB.
> >
> > Reviewed-by: Avri Altman <avri.altman@....com>
> > Reviewed-by: Stanley Chu <stanley.chu@...iatek.com>
> > Signed-off-by: Bean Huo <beanhuo@...ron.com>
> > ---
> > drivers/scsi/ufs/ufs-sysfs.c | 41
> > ++++++++++++++++++++++++++++++++++++
> > drivers/scsi/ufs/ufshcd.c | 3 +--
> > drivers/scsi/ufs/ufshcd.h | 2 ++
> > 3 files changed, 44 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-
> > sysfs.c
> > index 08e72b7eef6a..f3ca3d6b82c4 100644
> > --- a/drivers/scsi/ufs/ufs-sysfs.c
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -189,6 +189,45 @@ static ssize_t auto_hibern8_store(struct
> > device *dev,
> > return count;
> > }
> >
> > +static ssize_t wb_on_show(struct device *dev, struct
> > device_attribute *attr,
> > + char *buf)
> > +{
> > + struct ufs_hba *hba = dev_get_drvdata(dev);
> > +
> > + return sysfs_emit(buf, "%d\n", hba->wb_enabled);
> > +}
> > +
> > +static ssize_t wb_on_store(struct device *dev, struct
> > device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + struct ufs_hba *hba = dev_get_drvdata(dev);
> > + unsigned int wb_enable;
> > + ssize_t res;
> > +
> > + if (ufshcd_is_clkscaling_supported(hba)) {
> > + /*
> > + * If the platform supports UFSHCD_CAP_CLK_SCALING,
> > turn WB
> > + * on/off will be done while clock scaling up/down.
> > + */
> > + dev_warn(dev, "To control WB through wb_on is not
> > allowed!\n");
> > + return -EOPNOTSUPP;
> > + }
> > + if (!ufshcd_is_wb_allowed(hba))
> > + return -EOPNOTSUPP;
> > +
> > + if (kstrtouint(buf, 0, &wb_enable))
> > + return -EINVAL;
> > +
> > + if (wb_enable != 0 && wb_enable != 1)
> > + return -EINVAL;
> > +
> > + pm_runtime_get_sync(hba->dev);
> > + res = ufshcd_wb_ctrl(hba, wb_enable);
>
> May this operation race with UFS shutdown flow?
>
> To be more clear, ufshcd_wb_ctrl() here may be executed after host
> clock
> is disabled by shutdown flow?
>
> If yes, we need to avoid it.
>
> Thanks,
> Stanley Chu
>
Hi Stanley and Can
I just sent a new patch to address this issue, let's discusss in that
patch set, I added PM maintainer in the mail as well to help us address
concern about pm_runtime_get_sync and shutdown flow. If that way can
fix this issue, then I will update this patch again.
one note:
I didn't add "if (!ufshcd_is_ufs_dev_active(hba) ||
!ufshcd_is_link_active(hba))" checkup, since sysfs node access is a
normal request as well, UFS driver should give correct response as
possbile as it can, even if device/link is lower power mode.
Thanks,
Bean
Powered by blists - more mailing lists