* [PATCH v6 2/8] ufs: ufs-qcom: Fix race conditions caused by func ufs_qcom_testbus_config
[not found] <1595504787-19429-1-git-send-email-cang@codeaurora.org>
@ 2020-07-23 11:46 ` Can Guo
2020-07-27 12:52 ` Avri Altman
2020-07-23 11:46 ` [PATCH v6 3/8] scsi: ufs-qcom: Fix schedule while atomic error in ufs_qcom_dump_dbg_regs Can Guo
1 sibling, 1 reply; 5+ messages in thread
From: Can Guo @ 2020-07-23 11:46 UTC (permalink / raw)
To: asutoshd, nguyenb, hongwus, rnayak, sh425.lee, linux-scsi,
kernel-team, saravanak, salyzyn, cang
Cc: Andy Gross, Bjorn Andersson, Alim Akhtar, Avri Altman,
James E.J. Bottomley, Martin K. Petersen,
open list:ARM/QUALCOMM SUPPORT, open list
If ufs_qcom_dump_dbg_regs() calls ufs_qcom_testbus_config() from
ufshcd_suspend/resume and/or clk gate/ungate context, pm_runtime_get_sync()
and ufshcd_hold() will cause racing problems. Fix this by removing the
unnecessary calls of pm_runtime_get_sync() and ufshcd_hold().
Signed-off-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
---
drivers/scsi/ufs/ufs-qcom.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 2e6ddb5..7da27ee 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1604,9 +1604,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
*/
}
mask <<= offset;
-
- pm_runtime_get_sync(host->hba->dev);
- ufshcd_hold(host->hba, false);
ufshcd_rmwl(host->hba, TEST_BUS_SEL,
(u32)host->testbus.select_major << 19,
REG_UFS_CFG1);
@@ -1619,8 +1616,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
* committed before returning.
*/
mb();
- ufshcd_release(host->hba);
- pm_runtime_put_sync(host->hba->dev);
return 0;
}
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v6 3/8] scsi: ufs-qcom: Fix schedule while atomic error in ufs_qcom_dump_dbg_regs
[not found] <1595504787-19429-1-git-send-email-cang@codeaurora.org>
2020-07-23 11:46 ` [PATCH v6 2/8] ufs: ufs-qcom: Fix race conditions caused by func ufs_qcom_testbus_config Can Guo
@ 2020-07-23 11:46 ` Can Guo
2020-07-27 13:05 ` Avri Altman
1 sibling, 1 reply; 5+ messages in thread
From: Can Guo @ 2020-07-23 11:46 UTC (permalink / raw)
To: asutoshd, nguyenb, hongwus, rnayak, sh425.lee, linux-scsi,
kernel-team, saravanak, salyzyn, cang
Cc: Andy Gross, Bjorn Andersson, Alim Akhtar, Avri Altman,
James E.J. Bottomley, Martin K. Petersen,
open list:ARM/QUALCOMM SUPPORT, open list
Dumping testbus registers needs to sleep a bit intermittently as there are
too many of them. Skip them for those contexts where sleep is not allowed.
Signed-off-by: Can Guo <cang@codeaurora.org>
---
drivers/scsi/ufs/ufs-qcom.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 7da27ee..7831b2b 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1651,13 +1651,16 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)
ufshcd_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16 * 4,
"HCI Vendor Specific Registers ");
- /* sleep a bit intermittently as we are dumping too much data */
ufs_qcom_print_hw_debug_reg_all(hba, NULL, ufs_qcom_dump_regs_wrapper);
- udelay(1000);
- ufs_qcom_testbus_read(hba);
- udelay(1000);
- ufs_qcom_print_unipro_testbus(hba);
- udelay(1000);
+
+ if (in_task()) {
+ /* sleep a bit intermittently as we are dumping too much data */
+ usleep_range(1000, 1100);
+ ufs_qcom_testbus_read(hba);
+ usleep_range(1000, 1100);
+ ufs_qcom_print_unipro_testbus(hba);
+ usleep_range(1000, 1100);
+ }
}
/**
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH v6 2/8] ufs: ufs-qcom: Fix race conditions caused by func ufs_qcom_testbus_config
2020-07-23 11:46 ` [PATCH v6 2/8] ufs: ufs-qcom: Fix race conditions caused by func ufs_qcom_testbus_config Can Guo
@ 2020-07-27 12:52 ` Avri Altman
0 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2020-07-27 12:52 UTC (permalink / raw)
To: Can Guo, asutoshd, nguyenb, hongwus, rnayak, sh425.lee,
linux-scsi, kernel-team, saravanak, salyzyn
Cc: Andy Gross, Bjorn Andersson, Alim Akhtar, James E.J. Bottomley,
Martin K. Petersen, open list:ARM/QUALCOMM SUPPORT, open list
>
> If ufs_qcom_dump_dbg_regs() calls ufs_qcom_testbus_config() from
> ufshcd_suspend/resume and/or clk gate/ungate context,
> pm_runtime_get_sync()
> and ufshcd_hold() will cause racing problems. Fix this by removing the
> unnecessary calls of pm_runtime_get_sync() and ufshcd_hold().
>
> Signed-off-by: Can Guo <cang@codeaurora.org>
> Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v6 3/8] scsi: ufs-qcom: Fix schedule while atomic error in ufs_qcom_dump_dbg_regs
2020-07-23 11:46 ` [PATCH v6 3/8] scsi: ufs-qcom: Fix schedule while atomic error in ufs_qcom_dump_dbg_regs Can Guo
@ 2020-07-27 13:05 ` Avri Altman
2020-07-28 2:21 ` Can Guo
0 siblings, 1 reply; 5+ messages in thread
From: Avri Altman @ 2020-07-27 13:05 UTC (permalink / raw)
To: Can Guo, asutoshd, nguyenb, hongwus, rnayak, sh425.lee,
linux-scsi, kernel-team, saravanak, salyzyn
Cc: Andy Gross, Bjorn Andersson, Alim Akhtar, James E.J. Bottomley,
Martin K. Petersen, open list:ARM/QUALCOMM SUPPORT, open list
> Dumping testbus registers needs to sleep a bit intermittently as there are
> too many of them. Skip them for those contexts where sleep is not allowed.
>
> Signed-off-by: Can Guo <cang@codeaurora.org>
> ---
> drivers/scsi/ufs/ufs-qcom.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index 7da27ee..7831b2b 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -1651,13 +1651,16 @@ static void ufs_qcom_dump_dbg_regs(struct
> ufs_hba *hba)
> ufshcd_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16 * 4,
> "HCI Vendor Specific Registers ");
>
> - /* sleep a bit intermittently as we are dumping too much data */
> ufs_qcom_print_hw_debug_reg_all(hba, NULL,
> ufs_qcom_dump_regs_wrapper);
> - udelay(1000);
> - ufs_qcom_testbus_read(hba);
> - udelay(1000);
> - ufs_qcom_print_unipro_testbus(hba);
> - udelay(1000);
> +
> + if (in_task()) {
> + /* sleep a bit intermittently as we are dumping too much data */
> + usleep_range(1000, 1100);
> + ufs_qcom_testbus_read(hba);
> + usleep_range(1000, 1100);
> + ufs_qcom_print_unipro_testbus(hba);
> + usleep_range(1000, 1100);
> + }
> }
How about moving the intermittent sleep out of the check if preemption is disabled?
And maybe then you need to switch back to uedlay?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v6 3/8] scsi: ufs-qcom: Fix schedule while atomic error in ufs_qcom_dump_dbg_regs
2020-07-27 13:05 ` Avri Altman
@ 2020-07-28 2:21 ` Can Guo
0 siblings, 0 replies; 5+ messages in thread
From: Can Guo @ 2020-07-28 2:21 UTC (permalink / raw)
To: Avri Altman
Cc: asutoshd, nguyenb, hongwus, rnayak, sh425.lee, linux-scsi,
kernel-team, saravanak, salyzyn, Andy Gross, Bjorn Andersson,
Alim Akhtar, James E.J. Bottomley, Martin K. Petersen,
open list:ARM/QUALCOMM SUPPORT, open list
Hi Avri,
On 2020-07-27 21:05, Avri Altman wrote:
>> Dumping testbus registers needs to sleep a bit intermittently as there
>> are
>> too many of them. Skip them for those contexts where sleep is not
>> allowed.
>>
>> Signed-off-by: Can Guo <cang@codeaurora.org>
>> ---
>> drivers/scsi/ufs/ufs-qcom.c | 15 +++++++++------
>> 1 file changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
>> index 7da27ee..7831b2b 100644
>> --- a/drivers/scsi/ufs/ufs-qcom.c
>> +++ b/drivers/scsi/ufs/ufs-qcom.c
>> @@ -1651,13 +1651,16 @@ static void ufs_qcom_dump_dbg_regs(struct
>> ufs_hba *hba)
>> ufshcd_dump_regs(hba, REG_UFS_SYS1CLK_1US, 16 * 4,
>> "HCI Vendor Specific Registers ");
>>
>> - /* sleep a bit intermittently as we are dumping too much data
>> */
>> ufs_qcom_print_hw_debug_reg_all(hba, NULL,
>> ufs_qcom_dump_regs_wrapper);
>> - udelay(1000);
>> - ufs_qcom_testbus_read(hba);
>> - udelay(1000);
>> - ufs_qcom_print_unipro_testbus(hba);
>> - udelay(1000);
>> +
>> + if (in_task()) {
>> + /* sleep a bit intermittently as we are dumping too
>> much data */
>> + usleep_range(1000, 1100);
>> + ufs_qcom_testbus_read(hba);
>> + usleep_range(1000, 1100);
>> + ufs_qcom_print_unipro_testbus(hba);
>> + usleep_range(1000, 1100);
>> + }
>> }
> How about moving the intermittent sleep out of the check if preemption
> is disabled?
> And maybe then you need to switch back to uedlay?
I will just remove all the testbus prints in next version to save us
time here.
Thanks,
Can Guo.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-28 2:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1595504787-19429-1-git-send-email-cang@codeaurora.org>
2020-07-23 11:46 ` [PATCH v6 2/8] ufs: ufs-qcom: Fix race conditions caused by func ufs_qcom_testbus_config Can Guo
2020-07-27 12:52 ` Avri Altman
2020-07-23 11:46 ` [PATCH v6 3/8] scsi: ufs-qcom: Fix schedule while atomic error in ufs_qcom_dump_dbg_regs Can Guo
2020-07-27 13:05 ` Avri Altman
2020-07-28 2:21 ` Can Guo
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).