2022-07-27 07:23:31

by Jinyoung Choi

[permalink] [raw]
Subject: [PATCH v4 1/7] scsi: ufs: wb: Move ufshcd_is_wb_allowed() to callee

The condition test is performed for each function calling
__ufshcd_wb_toggle().
By modifying the position, it removes the code redundancy and prevents
the test from being missing in the caller function.

Reviewed-by: Avri Altman <[email protected]>
Signed-off-by: Jinyoung Choi <[email protected]>
---
drivers/ufs/core/ufshcd.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 8f11f118c30e..a3bdf9986511 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5722,6 +5722,9 @@ static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn)
enum query_opcode opcode = set ? UPIU_QUERY_OPCODE_SET_FLAG :
UPIU_QUERY_OPCODE_CLEAR_FLAG;

+ if (!ufshcd_is_wb_allowed(hba))
+ return -EPERM;
+
index = ufshcd_wb_get_query_index(hba);
return ufshcd_query_flag_retry(hba, opcode, idn, index, NULL);
}
@@ -5730,9 +5733,6 @@ int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable)
{
int ret;

- if (!ufshcd_is_wb_allowed(hba))
- return 0;
-
if (!(enable ^ hba->dev_info.wb_enabled))
return 0;

@@ -5769,8 +5769,7 @@ static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
{
int ret;

- if (!ufshcd_is_wb_allowed(hba) ||
- hba->dev_info.wb_buf_flush_enabled == enable)
+ if (hba->dev_info.wb_buf_flush_enabled == enable)
return;

ret = __ufshcd_wb_toggle(hba, enable, QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN);
--
2.25.1


2022-07-27 07:24:38

by Jinyoung Choi

[permalink] [raw]
Subject: [PATCH v4 2/7] scsi: ufs: wb: Change wb_enabled condition test

Changed to improve readability.
As implemented in ufshcd_wb_togle_flush(), the conditional test is
modified in the same way.

Reviewed-by: Avri Altman <[email protected]>
Signed-off-by: Jinyoung Choi <[email protected]>
---
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index a3bdf9986511..48ba109e29f7 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5733,7 +5733,7 @@ int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable)
{
int ret;

- if (!(enable ^ hba->dev_info.wb_enabled))
+ if (hba->dev_info.wb_enabled == enable)
return 0;

ret = __ufshcd_wb_toggle(hba, enable, QUERY_FLAG_IDN_WB_EN);
--
2.25.1

2022-07-27 13:45:57

by Bean Huo

[permalink] [raw]
Subject: Re: [PATCH v4 1/7] scsi: ufs: wb: Move ufshcd_is_wb_allowed() to callee

On Wed, 2022-07-27 at 16:04 +0900, Jinyoung CHOI wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 8f11f118c30e..a3bdf9986511 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -5722,6 +5722,9 @@ static int __ufshcd_wb_toggle(struct ufs_hba
> *hba, bool set, enum flag_idn idn)
>         enum query_opcode opcode = set ? UPIU_QUERY_OPCODE_SET_FLAG :
>                                    UPIU_QUERY_OPCODE_CLEAR_FLAG;
>  
> +       if (!ufshcd_is_wb_allowed(hba))
> +               return -EPERM;
> +
Hi J-young,

here you should change its return, Otherwise, there will be an fake
error printing:

dev_err(hba->dev, "%s Write Booster %s failed %d\n",
__func__, enable ? "enable" : "disable", ret);


Kind regards,
Bean

2022-07-27 14:12:00

by Bean Huo

[permalink] [raw]
Subject: Re: [PATCH v4 2/7] scsi: ufs: wb: Change wb_enabled condition test

On Wed, 2022-07-27 at 16:05 +0900, Jinyoung CHOI wrote:
> Changed to improve readability.
> As implemented in ufshcd_wb_togle_flush(), the conditional test is
> modified in the same way.
>
> Reviewed-by: Avri Altman <[email protected]>
> Signed-off-by: Jinyoung Choi <[email protected]>

Reviewed-by: Bean Huo <[email protected]>

2022-07-28 06:22:50

by Jinyoung Choi

[permalink] [raw]
Subject: RE:(2) [PATCH v4 1/7] scsi: ufs: wb: Move ufshcd_is_wb_allowed() to callee

>On Wed, 2022-07-27 at 16:04 +0900, Jinyoung CHOI wrote:
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>> index 8f11f118c30e..a3bdf9986511 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -5722,6 +5722,9 @@ static int __ufshcd_wb_toggle(struct ufs_hba
>> *hba, bool set, enum flag_idn idn)
>>         enum query_opcode opcode = set ? UPIU_QUERY_OPCODE_SET_FLAG :
>>                                    UPIU_QUERY_OPCODE_CLEAR_FLAG;
>>  
>> +       if (!ufshcd_is_wb_allowed(hba))
>> +               return -EPERM;
>> +
>Hi J-young,
>
>here you should change its return, Otherwise, there will be an fake
>error printing:
>
>        dev_err(hba->dev, "%s Write Booster %s failed %d\n",          
>                        __func__, enable ? "enable" : "disable", ret);
>
>
>Kind regards,
>Bean

You are right!
Rather than changing the return value, this patch is likely to be excluded
because caller can continue unnecessary work.

Thanks, Jinyoung.