* [RESEND PATCH v3 0/2] change UIC command handling
[not found] <CGME20230802013848epcas2p3a896970d5bdc8e3f3e422c84c282a151@epcas2p3.samsung.com>
@ 2023-08-02 1:28 ` Kiwoong Kim
[not found] ` <CGME20230802013850epcas2p4a813b26e15c261d180ee3b46651e1534@epcas2p4.samsung.com>
[not found] ` <CGME20230802013852epcas2p2334d33036d7d1a0bdbefaf5bb844928e@epcas2p2.samsung.com>
0 siblings, 2 replies; 7+ messages in thread
From: Kiwoong Kim @ 2023-08-02 1:28 UTC (permalink / raw)
To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
jejb, martin.petersen, beanhuo, adrian.hunter, sc.suh, hy50.seo,
sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
Cc: Kiwoong Kim
v2 -> v3: rule out the change of polling w/ pmc from this thread.
(I'll post the change later)
v1 -> v2: remove an unused variable in __ufshcd_send_uic_cmd
Kiwoong Kim (2):
ufs: make __ufshcd_send_uic_cmd not wrapped by host_lock
ufs: poll HCS.UCRDY before issuing a UIC command
drivers/ufs/core/ufshcd.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RESEND PATCH v3 1/2] ufs: make __ufshcd_send_uic_cmd not wrapped by host_lock
[not found] ` <CGME20230802013850epcas2p4a813b26e15c261d180ee3b46651e1534@epcas2p4.samsung.com>
@ 2023-08-02 1:28 ` Kiwoong Kim
0 siblings, 0 replies; 7+ messages in thread
From: Kiwoong Kim @ 2023-08-02 1:28 UTC (permalink / raw)
To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
jejb, martin.petersen, beanhuo, adrian.hunter, sc.suh, hy50.seo,
sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
Cc: Kiwoong Kim
__ufshcd_send_uic_cmd is wrapped uic_cmd_mutex and
its related contexts are accessed within the period wrappted
by uic_cmd_mutex. Thus, wrapping with host_lock is
redundant.
Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufshcd.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9434328..a89d39a 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2457,7 +2457,6 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd,
bool completion)
{
lockdep_assert_held(&hba->uic_cmd_mutex);
- lockdep_assert_held(hba->host->host_lock);
if (!ufshcd_ready_for_uic_cmd(hba)) {
dev_err(hba->dev,
@@ -2484,7 +2483,6 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd,
int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
{
int ret;
- unsigned long flags;
if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD)
return 0;
@@ -2493,9 +2491,7 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
mutex_lock(&hba->uic_cmd_mutex);
ufshcd_add_delay_before_dme_cmd(hba);
- spin_lock_irqsave(hba->host->host_lock, flags);
ret = __ufshcd_send_uic_cmd(hba, uic_cmd, true);
- spin_unlock_irqrestore(hba->host->host_lock, flags);
if (!ret)
ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd);
@@ -4180,8 +4176,8 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
wmb();
reenable_intr = true;
}
- ret = __ufshcd_send_uic_cmd(hba, cmd, false);
spin_unlock_irqrestore(hba->host->host_lock, flags);
+ ret = __ufshcd_send_uic_cmd(hba, cmd, false);
if (ret) {
dev_err(hba->dev,
"pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n",
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command
[not found] ` <CGME20230802013852epcas2p2334d33036d7d1a0bdbefaf5bb844928e@epcas2p2.samsung.com>
@ 2023-08-02 1:28 ` Kiwoong Kim
2023-08-14 11:26 ` Adrian Hunter
0 siblings, 1 reply; 7+ messages in thread
From: Kiwoong Kim @ 2023-08-02 1:28 UTC (permalink / raw)
To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
jejb, martin.petersen, beanhuo, adrian.hunter, sc.suh, hy50.seo,
sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
Cc: Kiwoong Kim
With auto hibern8 enabled, UIC could be working
for a while to process a hibern8 operation and HCI
reports UIC not ready for a short term through HCS.UCRDY.
And UFS driver can't recognize the operation.
UFSHCI spec specifies UCRDY like this:
whether the host controller is ready to process UIC COMMAND
The 'ready' could be seen as many different meanings. If the meaning
includes not processing any request from HCI, processing a hibern8
operation can be 'not ready'. In this situation, the driver needs to
wait until the operations is completed.
Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
drivers/ufs/core/ufshcd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index a89d39a..10ccc85 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/sched/clock.h>
+#include <linux/iopoll.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_driver.h>
@@ -2365,7 +2366,11 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
*/
static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
{
- return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
+ u32 val;
+ int ret = read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
+ 500, UIC_CMD_TIMEOUT * 1000, false, hba,
+ REG_CONTROLLER_STATUS);
+ return ret == 0 ? true : false;
}
/**
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command
2023-08-02 1:28 ` [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command Kiwoong Kim
@ 2023-08-14 11:26 ` Adrian Hunter
2023-08-17 15:02 ` Bart Van Assche
0 siblings, 1 reply; 7+ messages in thread
From: Adrian Hunter @ 2023-08-14 11:26 UTC (permalink / raw)
To: Kiwoong Kim, linux-scsi, linux-kernel, alim.akhtar, avri.altman,
bvanassche, jejb, martin.petersen, beanhuo, sc.suh, hy50.seo,
sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
On 2/08/23 04:28, Kiwoong Kim wrote:
> With auto hibern8 enabled, UIC could be working
> for a while to process a hibern8 operation and HCI
> reports UIC not ready for a short term through HCS.UCRDY.
> And UFS driver can't recognize the operation.
> UFSHCI spec specifies UCRDY like this:
> whether the host controller is ready to process UIC COMMAND
>
> The 'ready' could be seen as many different meanings. If the meaning
> includes not processing any request from HCI, processing a hibern8
> operation can be 'not ready'. In this situation, the driver needs to
> wait until the operations is completed.
>
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
> drivers/ufs/core/ufshcd.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index a89d39a..10ccc85 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -22,6 +22,7 @@
> #include <linux/module.h>
> #include <linux/regulator/consumer.h>
> #include <linux/sched/clock.h>
> +#include <linux/iopoll.h>
> #include <scsi/scsi_cmnd.h>
> #include <scsi/scsi_dbg.h>
> #include <scsi/scsi_driver.h>
> @@ -2365,7 +2366,11 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
> */
> static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
> {
> - return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
> + u32 val;
> + int ret = read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
> + 500, UIC_CMD_TIMEOUT * 1000, false, hba,
> + REG_CONTROLLER_STATUS);
> + return ret == 0 ? true : false;
Could use a comment in the code.
And perhaps the following is neater:
u32 val;
return !read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
500, UIC_CMD_TIMEOUT * 1000, false, hba,
REG_CONTROLLER_STATUS);
> }
>
> /**
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command
2023-08-14 11:26 ` Adrian Hunter
@ 2023-08-17 15:02 ` Bart Van Assche
2023-08-17 16:16 ` Adrian Hunter
0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2023-08-17 15:02 UTC (permalink / raw)
To: Adrian Hunter, Kiwoong Kim, linux-scsi, linux-kernel,
alim.akhtar, avri.altman, jejb, martin.petersen, beanhuo, sc.suh,
hy50.seo, sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
On 8/14/23 04:26, Adrian Hunter wrote:
> And perhaps the following is neater:
>
> u32 val;
>
> return !read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
> 500, UIC_CMD_TIMEOUT * 1000, false, hba,
> REG_CONTROLLER_STATUS);
Would the above make readers of that code wonder whether read_poll_timeout()
perhaps returns a boolean? Wouldn't it be better to test the
read_poll_timeout() return value as follows?
return read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
500, UIC_CMD_TIMEOUT * 1000, false, hba,
REG_CONTROLLER_STATUS) == 0;
Thanks,
Bart.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command
2023-08-17 15:02 ` Bart Van Assche
@ 2023-08-17 16:16 ` Adrian Hunter
0 siblings, 0 replies; 7+ messages in thread
From: Adrian Hunter @ 2023-08-17 16:16 UTC (permalink / raw)
To: Bart Van Assche, Kiwoong Kim, linux-scsi, linux-kernel,
alim.akhtar, avri.altman, jejb, martin.petersen, beanhuo, sc.suh,
hy50.seo, sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
On 17/08/23 18:02, Bart Van Assche wrote:
> On 8/14/23 04:26, Adrian Hunter wrote:
>> And perhaps the following is neater:
>>
>> u32 val;
>>
>> return !read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
>> 500, UIC_CMD_TIMEOUT * 1000, false, hba,
>> REG_CONTROLLER_STATUS);
>
> Would the above make readers of that code wonder whether read_poll_timeout()
> perhaps returns a boolean? Wouldn't it be better to test the
> read_poll_timeout() return value as follows?
>
> return read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
> 500, UIC_CMD_TIMEOUT * 1000, false, hba,
> REG_CONTROLLER_STATUS) == 0;
>
Either is fine, otherwise:
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command
[not found] ` <CGME20230904014150epcas2p251f19c2220ec8938559bc2873e8e265a@epcas2p2.samsung.com>
@ 2023-09-04 1:30 ` Kiwoong Kim
0 siblings, 0 replies; 7+ messages in thread
From: Kiwoong Kim @ 2023-09-04 1:30 UTC (permalink / raw)
To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
jejb, martin.petersen, beanhuo, adrian.hunter, sc.suh, hy50.seo,
sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
Cc: Kiwoong Kim
With auto hibern8 enabled, UIC could be working
for a while to process a hibern8 operation and HCI
reports UIC not ready for a short term through HCS.UCRDY.
And UFS driver can't recognize the operation.
UFSHCI spec specifies UCRDY like this:
whether the host controller is ready to process UIC COMMAND
The 'ready' could be seen as many different meanings. If the meaning
includes not processing any request from HCI, processing a hibern8
operation can be 'not ready'. In this situation, the driver needs to
wait until the operations is completed.
Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/ufs/core/ufshcd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 6300ed6..7bc3fc4 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/sched/clock.h>
+#include <linux/iopoll.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_driver.h>
@@ -2322,7 +2323,11 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
*/
static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
{
- return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
+ u32 val;
+ int ret = read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY,
+ 500, UIC_CMD_TIMEOUT * 1000, false, hba,
+ REG_CONTROLLER_STATUS);
+ return ret == 0 ? true : false;
}
/**
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-09-04 1:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20230802013848epcas2p3a896970d5bdc8e3f3e422c84c282a151@epcas2p3.samsung.com>
2023-08-02 1:28 ` [RESEND PATCH v3 0/2] change UIC command handling Kiwoong Kim
[not found] ` <CGME20230802013850epcas2p4a813b26e15c261d180ee3b46651e1534@epcas2p4.samsung.com>
2023-08-02 1:28 ` [RESEND PATCH v3 1/2] ufs: make __ufshcd_send_uic_cmd not wrapped by host_lock Kiwoong Kim
[not found] ` <CGME20230802013852epcas2p2334d33036d7d1a0bdbefaf5bb844928e@epcas2p2.samsung.com>
2023-08-02 1:28 ` [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command Kiwoong Kim
2023-08-14 11:26 ` Adrian Hunter
2023-08-17 15:02 ` Bart Van Assche
2023-08-17 16:16 ` Adrian Hunter
2023-09-04 1:30 [RESEND PATCH v3 0/2] change UIC command handling Kiwoong Kim
[not found] ` <CGME20230904014150epcas2p251f19c2220ec8938559bc2873e8e265a@epcas2p2.samsung.com>
2023-09-04 1:30 ` [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command Kiwoong Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome