mbox series

[v11,0/3] Three changes related with UFS clock scaling

Message ID 1611137065-14266-1-git-send-email-cang@codeaurora.org
Headers show
Series Three changes related with UFS clock scaling | expand

Message

Can Guo Jan. 20, 2021, 10:04 a.m. UTC
This series is made based on 5.12/scsi-queue branch.

Current devfreq framework allows sysfs nodes like governor, min_freq and max_freq to be changed even after devfreq device is suspended.
Meanwhile, devfreq_suspend_device() cannot/wouldn't synchronize clock scaling which has already been invoked through devfreq sysfs nodes menitioned above.
It means that clock scaling invoked through these devfreq sysfs nodes can happen at any time regardless of the state of UFS host and/or device.
We need to control and synchronize clock scaling in this scenario.

The 1st change allows contexts to prevent clock scaling from being invoked through devfreq sysfs nodes.
The 2nd change is just a code cleanup for clk_scaling/gating initialization routine.
The 3rd change reverts one old change which can be covered by the 1st change. For branches which do not have this change yet, it can be ignored.

Change since v10:
- Incorporated Stanley's comment.

Change since v9:
- Minor update in the 1st change.

Change since v8:
- Rebased on 5.12/scsi-queue

Change since v7:
- Slightly updated the 1st change: changed the up_write() before ufshcd_wb_ctrl() to downgrade_write() in ufshcd_devfreq_scale(),
  so that ufshcd_wb_ctrl() is called with clk_scale_lock held, this is to make sure race condition won't happen to ufshcd_wb_ctrl().

Change since v6:
- Updated the 2nd change

Change since v5:
- Reomved the code change in ufshcd_shutdown() since it is not quite relevant with this fix

Change since v4:
- Updated some comment lines as requested by Stanley

Change since v3:
- Slightly updated the 1st change

Change since v2:
- Split the 1st change to two changes, which become the 1st change and the 3rd change

Change since v1:
- Updated the 2nd change

Can Guo (3):
  scsi: ufs: Protect some contexts from unexpected clock scaling
  scsi: ufs: Refactor ufshcd_init/exit_clk_scaling/gating()
  scsi: ufs: Revert "Make sure clk scaling happens only when HBA is
    runtime ACTIVE"

 drivers/scsi/ufs/ufshcd.c | 211 +++++++++++++++++++++++++---------------------
 drivers/scsi/ufs/ufshcd.h |  10 ++-
 2 files changed, 125 insertions(+), 96 deletions(-)

Comments

Martin K. Petersen Jan. 21, 2021, 3:28 a.m. UTC | #1
Can,

> This series is made based on 5.12/scsi-queue branch.

>

> Current devfreq framework allows sysfs nodes like governor, min_freq

> and max_freq to be changed even after devfreq device is suspended.

> Meanwhile, devfreq_suspend_device() cannot/wouldn't synchronize clock

> scaling which has already been invoked through devfreq sysfs nodes

> menitioned above.  It means that clock scaling invoked through these

> devfreq sysfs nodes can happen at any time regardless of the state of

> UFS host and/or device.  We need to control and synchronize clock

> scaling in this scenario.


Applied to 5.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering
Martin K. Petersen Jan. 23, 2021, 4:22 a.m. UTC | #2
On Wed, 20 Jan 2021 02:04:20 -0800, Can Guo wrote:

> This series is made based on 5.12/scsi-queue branch.

> 

> Current devfreq framework allows sysfs nodes like governor, min_freq and max_freq to be changed even after devfreq device is suspended.

> Meanwhile, devfreq_suspend_device() cannot/wouldn't synchronize clock scaling which has already been invoked through devfreq sysfs nodes menitioned above.

> It means that clock scaling invoked through these devfreq sysfs nodes can happen at any time regardless of the state of UFS host and/or device.

> We need to control and synchronize clock scaling in this scenario.

> 

> [...]


Applied to 5.12/scsi-queue, thanks!

[1/3] scsi: ufs: Protect some contexts from unexpected clock scaling
      https://git.kernel.org/mkp/scsi/c/0e9d4ca43ba8
[2/3] scsi: ufs: Refactor ufshcd_init/exit_clk_scaling/gating()
      https://git.kernel.org/mkp/scsi/c/4543d9d78227
[3/3] scsi: ufs: Revert "Make sure clk scaling happens only when HBA is runtime ACTIVE"
      https://git.kernel.org/mkp/scsi/c/b02d51afca00

-- 
Martin K. Petersen	Oracle Linux Engineering