linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bean Huo <huobean@gmail.com>
To: "Asutosh Das (asd)" <asutoshd@codeaurora.org>,
	alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, stanley.chu@mediatek.com,
	beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com,
	cang@codeaurora.org
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] scsi: ufs: Add "wb_on" sysfs node to control WB on/off
Date: Wed, 02 Dec 2020 17:20:45 +0100	[thread overview]
Message-ID: <30767ee7973670b86bff61d1d7b2044f17640b75.camel@gmail.com> (raw)
In-Reply-To: <2a380908-3eb4-2cdc-4156-03e8946ffd88@codeaurora.org>

On Mon, 2020-11-30 at 15:19 -0800, Asutosh Das (asd) wrote:
> > +             return -EINVAL;
> > +
> > +     pm_runtime_get_sync(hba->dev);
> > +     res = ufshcd_wb_ctrl(hba, wb_enable);
> 
> Say, a platform supports clock-scaling and this bit is toggled.
> The control goes into ufshcd_wb_ctrl for both this sysfs and 
> clock-scaling contexts. The clock-scaling context passes all checks
> and 
> blocks on waiting for this wb control to be disabled and then tries
> to 
> enable wb when it's already disabled. Perhaps that's a race there?

Hi Asutosh
Appreciate your review.
There is only inconsistent problem between clock-scaling and sysfs,
since hba->dev_cmd.lock can garantee there is only one can change
fWriteBoosterEn. But this is only happening on user willfully wants to
control WB through sysfs even they know the platform supports clock-
scaling.

Since this is for the platform which doesn't support clock-scaling, I
think based on your comments, it should be acceptable for you like
this: 


+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)) {
+          dev_err(dev, "supports dynamic clk scaling, control WB
+                       through sysfs is not allowed!");
+          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);
+       pm_runtime_put_sync(hba->dev);
+
+       return res < 0 ? res : count;
+}

thanks,
Bean



  reply	other threads:[~2020-12-02 16:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 18:11 [PATCH 0/3] Three changes for UFS WriteBooster Bean Huo
2020-11-30 18:11 ` [PATCH 1/3] scsi: ufs: Add "wb_on" sysfs node to control WB on/off Bean Huo
2020-11-30 23:19   ` Asutosh Das (asd)
2020-12-02 16:20     ` Bean Huo [this message]
2020-12-02 17:58       ` Asutosh Das (asd)
2020-11-30 18:11 ` [PATCH 2/3] scsi: ufs: Keep device power on only fWriteBoosterBufferFlushDuringHibernate == 1 Bean Huo
     [not found]   ` <BY5PR04MB6599826730BD3FB0E547E60587F30@BY5PR04MB6599.namprd04.prod.outlook.com>
2020-12-03  7:27     ` Avri Altman
2020-12-03  9:36       ` Bean Huo
2020-12-03  9:40       ` Bean Huo
2020-12-03 10:46         ` Avri Altman
2020-12-03 11:45           ` Bean Huo
2020-12-03 12:15             ` Avri Altman
2020-12-03 12:31               ` Bean Huo
2020-12-04  3:26   ` Can Guo
2020-12-04  8:28     ` Bean Huo
2020-11-30 18:11 ` [PATCH 3/3] scsi: ufs: Changes comment in the function ufshcd_wb_probe() Bean Huo
2020-12-04  3:27   ` Can Guo

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=30767ee7973670b86bff61d1d7b2044f17640b75.camel@gmail.com \
    --to=huobean@gmail.com \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stanley.chu@mediatek.com \
    --cc=tomas.winkler@intel.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;
as well as URLs for NNTP newsgroup(s).