linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
       [not found] <CGME20220205074128epcas2p40901c37a7328e825d8697f8d3269edba@epcas2p4.samsung.com>
@ 2022-02-05  7:39 ` Kiwoong Kim
  2022-02-06  8:20   ` Avri Altman
  2022-02-14 19:29   ` Bart Van Assche
  0 siblings, 2 replies; 14+ messages in thread
From: Kiwoong Kim @ 2022-02-05  7:39 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
	martin.petersen, beanhuo, cang, adrian.hunter, sc.suh, hy50.seo,
	sh425.lee, bhoon95.kim, vkumar.1997
  Cc: Kiwoong Kim

clk_scaling_lock is to prevent from running clkscaling related operations
with others which might be affected by the operations concurrently.
I think it looks hardware specific.
If the feature isn't supported, I think there is no reasonto prevent from
running other functions, such as ufshcd_queuecommand and
ufshcd_exec_dev_cmd, concurrently.

So I add a condition at some points protecting with clk_scaling_lock.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 460d2b4..8471c90 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2980,7 +2980,8 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
 	/* Protects use of hba->reserved_slot. */
 	lockdep_assert_held(&hba->dev_cmd.lock);
 
-	down_read(&hba->clk_scaling_lock);
+	if (ufshcd_is_clkscaling_supported(hba))
+		down_read(&hba->clk_scaling_lock);
 
 	lrbp = &hba->lrb[tag];
 	WARN_ON(lrbp->cmd);
@@ -2998,7 +2999,8 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
 				    (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
 
 out:
-	up_read(&hba->clk_scaling_lock);
+	if (ufshcd_is_clkscaling_supported(hba))
+		up_read(&hba->clk_scaling_lock);
 	return err;
 }
 
@@ -6014,7 +6016,8 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
 		if (ufshcd_is_clkscaling_supported(hba) &&
 		    hba->clk_scaling.is_enabled)
 			ufshcd_suspend_clkscaling(hba);
-		ufshcd_clk_scaling_allow(hba, false);
+		if (ufshcd_is_clkscaling_supported(hba))
+			ufshcd_clk_scaling_allow(hba, false);
 	}
 	ufshcd_scsi_block_requests(hba);
 	/* Drain ufshcd_queuecommand() */
@@ -6247,7 +6250,8 @@ static void ufshcd_err_handler(struct work_struct *work)
 		 * Hold the scaling lock just in case dev cmds
 		 * are sent via bsg and/or sysfs.
 		 */
-		down_write(&hba->clk_scaling_lock);
+		if (ufshcd_is_clkscaling_supported(hba))
+			down_write(&hba->clk_scaling_lock);
 		hba->force_pmc = true;
 		pmc_err = ufshcd_config_pwr_mode(hba, &(hba->pwr_info));
 		if (pmc_err) {
@@ -6257,7 +6261,8 @@ static void ufshcd_err_handler(struct work_struct *work)
 		}
 		hba->force_pmc = false;
 		ufshcd_print_pwr_info(hba);
-		up_write(&hba->clk_scaling_lock);
+		if (ufshcd_is_clkscaling_supported(hba))
+			up_write(&hba->clk_scaling_lock);
 		spin_lock_irqsave(hba->host->host_lock, flags);
 	}
 
@@ -6753,7 +6758,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
 	/* Protects use of hba->reserved_slot. */
 	lockdep_assert_held(&hba->dev_cmd.lock);
 
-	down_read(&hba->clk_scaling_lock);
+	if (ufshcd_is_clkscaling_supported(hba))
+		down_read(&hba->clk_scaling_lock);
 
 	lrbp = &hba->lrb[tag];
 	WARN_ON(lrbp->cmd);
@@ -6822,7 +6828,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
 	ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
 				    (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
 
-	up_read(&hba->clk_scaling_lock);
+	if (ufshcd_is_clkscaling_supported(hba))
+		up_read(&hba->clk_scaling_lock);
 	return err;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-05  7:39 ` [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported Kiwoong Kim
@ 2022-02-06  8:20   ` Avri Altman
  2022-02-11  2:15     ` Kiwoong Kim
  2022-02-14 19:29   ` Bart Van Assche
  1 sibling, 1 reply; 14+ messages in thread
From: Avri Altman @ 2022-02-06  8:20 UTC (permalink / raw)
  To: Kiwoong Kim, linux-scsi, linux-kernel, alim.akhtar, jejb,
	martin.petersen, beanhuo, cang, adrian.hunter, sc.suh, hy50.seo,
	sh425.lee, bhoon95.kim, vkumar.1997

 
> clk_scaling_lock is to prevent from running clkscaling related operations
> with others which might be affected by the operations concurrently.
> I think it looks hardware specific.
> If the feature isn't supported, I think there is no reasonto prevent from
                                                                                         ^^^ reason to 

> running other functions, such as ufshcd_queuecommand and
It is no longer used in queuecommand since 5675c381ea51 and 8d077ede48c1

> ufshcd_exec_dev_cmd, concurrently.
> 
> So I add a condition at some points protecting with clk_scaling_lock.
But you still need a way to serialize device management commands.

Thanks,
Avri

> 
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
>  drivers/scsi/ufs/ufshcd.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 460d2b4..8471c90 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -2980,7 +2980,8 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
>         /* Protects use of hba->reserved_slot. */
>         lockdep_assert_held(&hba->dev_cmd.lock);
> 
> -       down_read(&hba->clk_scaling_lock);
> +       if (ufshcd_is_clkscaling_supported(hba))
> +               down_read(&hba->clk_scaling_lock);
> 
>         lrbp = &hba->lrb[tag];
>         WARN_ON(lrbp->cmd);
> @@ -2998,7 +2999,8 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
>                                     (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
> 
>  out:
> -       up_read(&hba->clk_scaling_lock);
> +       if (ufshcd_is_clkscaling_supported(hba))
> +               up_read(&hba->clk_scaling_lock);
>         return err;
>  }
> 
> @@ -6014,7 +6016,8 @@ static void ufshcd_err_handling_prepare(struct
> ufs_hba *hba)
>                 if (ufshcd_is_clkscaling_supported(hba) &&
>                     hba->clk_scaling.is_enabled)
>                         ufshcd_suspend_clkscaling(hba);
> -               ufshcd_clk_scaling_allow(hba, false);
> +               if (ufshcd_is_clkscaling_supported(hba))
> +                       ufshcd_clk_scaling_allow(hba, false);
>         }
>         ufshcd_scsi_block_requests(hba);
>         /* Drain ufshcd_queuecommand() */
> @@ -6247,7 +6250,8 @@ static void ufshcd_err_handler(struct work_struct
> *work)
>                  * Hold the scaling lock just in case dev cmds
>                  * are sent via bsg and/or sysfs.
>                  */
> -               down_write(&hba->clk_scaling_lock);
> +               if (ufshcd_is_clkscaling_supported(hba))
> +                       down_write(&hba->clk_scaling_lock);
>                 hba->force_pmc = true;
>                 pmc_err = ufshcd_config_pwr_mode(hba, &(hba->pwr_info));
>                 if (pmc_err) {
> @@ -6257,7 +6261,8 @@ static void ufshcd_err_handler(struct work_struct
> *work)
>                 }
>                 hba->force_pmc = false;
>                 ufshcd_print_pwr_info(hba);
> -               up_write(&hba->clk_scaling_lock);
> +               if (ufshcd_is_clkscaling_supported(hba))
> +                       up_write(&hba->clk_scaling_lock);
>                 spin_lock_irqsave(hba->host->host_lock, flags);
>         }
> 
> @@ -6753,7 +6758,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct
> ufs_hba *hba,
>         /* Protects use of hba->reserved_slot. */
>         lockdep_assert_held(&hba->dev_cmd.lock);
> 
> -       down_read(&hba->clk_scaling_lock);
> +       if (ufshcd_is_clkscaling_supported(hba))
> +               down_read(&hba->clk_scaling_lock);
> 
>         lrbp = &hba->lrb[tag];
>         WARN_ON(lrbp->cmd);
> @@ -6822,7 +6828,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct
> ufs_hba *hba,
>         ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR :
> UFS_QUERY_COMP,
>                                     (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
> 
> -       up_read(&hba->clk_scaling_lock);
> +       if (ufshcd_is_clkscaling_supported(hba))
> +               up_read(&hba->clk_scaling_lock);
>         return err;
>  }
> 
> --
> 2.7.4


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-06  8:20   ` Avri Altman
@ 2022-02-11  2:15     ` Kiwoong Kim
  2022-02-11 12:15       ` Adrian Hunter
  2022-02-11 12:19       ` Avri Altman
  0 siblings, 2 replies; 14+ messages in thread
From: Kiwoong Kim @ 2022-02-11  2:15 UTC (permalink / raw)
  To: 'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, adrian.hunter, sc.suh, hy50.seo, sh425.lee,
	bhoon95.kim, vkumar.1997

> > I think it looks hardware specific.
> > If the feature isn't supported, I think there is no reasonto prevent
> > from
>                                                                                          ^^^
> reason to
> 
> > running other functions, such as ufshcd_queuecommand and
> It is no longer used in queuecommand since 5675c381ea51 and 8d077ede48c1

Yeah, you're right. It's just an example. I just want to tell that the lock also protects things that are not related with clk scaling directly.

> 
> > ufshcd_exec_dev_cmd, concurrently.
> >
> > So I add a condition at some points protecting with clk_scaling_lock.
> But you still need a way to serialize device management commands.
> 
> Thanks,
> Avri

The dev cmd execution period is protected by mutex.
And actual ringing a doorbell is protected by spin lock.

Is there another reason to need clk_scaling_lock even with it?

Thanks.
Kiwoong Kim



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-11  2:15     ` Kiwoong Kim
@ 2022-02-11 12:15       ` Adrian Hunter
  2022-02-12  4:44         ` Kiwoong Kim
  2022-02-11 12:19       ` Avri Altman
  1 sibling, 1 reply; 14+ messages in thread
From: Adrian Hunter @ 2022-02-11 12:15 UTC (permalink / raw)
  To: Kiwoong Kim, 'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, sc.suh, hy50.seo, sh425.lee, bhoon95.kim,
	vkumar.1997

On 11/02/2022 04:15, Kiwoong Kim wrote:
>>> I think it looks hardware specific.
>>> If the feature isn't supported, I think there is no reasonto prevent
>>> from
>>                                                                                          ^^^
>> reason to
>>
>>> running other functions, such as ufshcd_queuecommand and
>> It is no longer used in queuecommand since 5675c381ea51 and 8d077ede48c1
> 
> Yeah, you're right. It's just an example. I just want to tell that the lock also protects things that are not related with clk scaling directly.
> 
>>
>>> ufshcd_exec_dev_cmd, concurrently.
>>>
>>> So I add a condition at some points protecting with clk_scaling_lock.
>> But you still need a way to serialize device management commands.
>>
>> Thanks,
>> Avri
> 
> The dev cmd execution period is protected by mutex.
> And actual ringing a doorbell is protected by spin lock.
> 
> Is there another reason to need clk_scaling_lock even with it?
> 

The error handler really should have exclusive access.  One
of the places you change does explain that:

 		 * Hold the scaling lock just in case dev cmds
 		 * are sent via bsg and/or sysfs.
 		 */
-		down_write(&hba->clk_scaling_lock);
+		if (ufshcd_is_clkscaling_supported(hba))
+			down_write(&hba->clk_scaling_lock);

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-11  2:15     ` Kiwoong Kim
  2022-02-11 12:15       ` Adrian Hunter
@ 2022-02-11 12:19       ` Avri Altman
  1 sibling, 0 replies; 14+ messages in thread
From: Avri Altman @ 2022-02-11 12:19 UTC (permalink / raw)
  To: Kiwoong Kim, linux-scsi, linux-kernel, alim.akhtar, jejb,
	martin.petersen, beanhuo, cang, adrian.hunter, sc.suh, hy50.seo,
	sh425.lee, bhoon95.kim, vkumar.1997

> > > I think it looks hardware specific.
> > > If the feature isn't supported, I think there is no reasonto prevent
> > > from
> >
> > ^^^ reason to
> >
> > > running other functions, such as ufshcd_queuecommand and
> > It is no longer used in queuecommand since 5675c381ea51 and
> > 8d077ede48c1
> 
> Yeah, you're right. It's just an example. I just want to tell that the lock also
> protects things that are not related with clk scaling directly.
OK.

> 
> >
> > > ufshcd_exec_dev_cmd, concurrently.
> > >
> > > So I add a condition at some points protecting with clk_scaling_lock.
> > But you still need a way to serialize device management commands.
> >
> > Thanks,
> > Avri
> 
> The dev cmd execution period is protected by mutex.
> And actual ringing a doorbell is protected by spin lock.
> 
> Is there another reason to need clk_scaling_lock even with it?
Right.

Acked-by: Avri Altman <avri.altman@wdc.com>

> 
> Thanks.
> Kiwoong Kim
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-11 12:15       ` Adrian Hunter
@ 2022-02-12  4:44         ` Kiwoong Kim
  2022-02-14 14:31           ` Adrian Hunter
  2022-02-15 11:00           ` Bean Huo
  0 siblings, 2 replies; 14+ messages in thread
From: Kiwoong Kim @ 2022-02-12  4:44 UTC (permalink / raw)
  To: 'Adrian Hunter', 'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, sc.suh, hy50.seo, sh425.lee, bhoon95.kim,
	vkumar.1997

> The error handler really should have exclusive access.  One of the places
> you change does explain that:
> 
>  		 * Hold the scaling lock just in case dev cmds
>  		 * are sent via bsg and/or sysfs.
>  		 */
> -		down_write(&hba->clk_scaling_lock);
> +		if (ufshcd_is_clkscaling_supported(hba))
> +			down_write(&hba->clk_scaling_lock); 


Yeah.., I saw the comment but didn't get why.

Is there anyone who knows why it's necessary for all SoCs?
At lease, I know there is no reason to forbid concurrent executions of dev cmd and power mode change.

If there's nothing, how about adding a quick to ignore it?

Thanks.
Kiwoong Kim


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-12  4:44         ` Kiwoong Kim
@ 2022-02-14 14:31           ` Adrian Hunter
  2022-02-15 11:00           ` Bean Huo
  1 sibling, 0 replies; 14+ messages in thread
From: Adrian Hunter @ 2022-02-14 14:31 UTC (permalink / raw)
  To: Kiwoong Kim, 'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, sc.suh, hy50.seo, sh425.lee, bhoon95.kim,
	vkumar.1997

On 12/02/2022 06:44, Kiwoong Kim wrote:
>> The error handler really should have exclusive access.  One of the places
>> you change does explain that:
>>
>>  		 * Hold the scaling lock just in case dev cmds
>>  		 * are sent via bsg and/or sysfs.
>>  		 */
>> -		down_write(&hba->clk_scaling_lock);
>> +		if (ufshcd_is_clkscaling_supported(hba))
>> +			down_write(&hba->clk_scaling_lock); 
> 
> 
> Yeah.., I saw the comment but didn't get why.
> 
> Is there anyone who knows why it's necessary for all SoCs?
> At lease, I know there is no reason to forbid concurrent executions of dev cmd and power mode change.
> 
> If there's nothing, how about adding a quick to ignore it?

Is it worth it?

The error handler really should have exclusive access.
Have you considered, for example, races of ufshcd_reset_and restore() and dev commands, tm commands, UIC commands.
I suspect more locking is needed not less.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-05  7:39 ` [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported Kiwoong Kim
  2022-02-06  8:20   ` Avri Altman
@ 2022-02-14 19:29   ` Bart Van Assche
  2022-02-15  6:03     ` Kiwoong Kim
  1 sibling, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2022-02-14 19:29 UTC (permalink / raw)
  To: Kiwoong Kim, linux-scsi, linux-kernel, alim.akhtar, avri.altman,
	jejb, martin.petersen, beanhuo, cang, adrian.hunter, sc.suh,
	hy50.seo, sh425.lee, bhoon95.kim, vkumar.1997

On 2/4/22 23:39, Kiwoong Kim wrote:
> clk_scaling_lock is to prevent from running clkscaling related operations
> with others which might be affected by the operations concurrently.
> I think it looks hardware specific.
> If the feature isn't supported, I think there is no reasonto prevent from
> running other functions, such as ufshcd_queuecommand and
> ufshcd_exec_dev_cmd, concurrently.
> 
> So I add a condition at some points protecting with clk_scaling_lock.
> 
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
>   drivers/scsi/ufs/ufshcd.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 460d2b4..8471c90 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -2980,7 +2980,8 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
>   	/* Protects use of hba->reserved_slot. */
>   	lockdep_assert_held(&hba->dev_cmd.lock);
>   
> -	down_read(&hba->clk_scaling_lock);
> +	if (ufshcd_is_clkscaling_supported(hba))
> +		down_read(&hba->clk_scaling_lock);
>   
>   	lrbp = &hba->lrb[tag];
>   	WARN_ON(lrbp->cmd);

I don't like this patch at all. This patch makes testing the UFS driver 
more complicated without having any clear benefit. Additionally, adding 
if-statements in front of locking makes static source code analysis 
harder and is an anti-pattern. Please don't do this.

Bart.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-14 19:29   ` Bart Van Assche
@ 2022-02-15  6:03     ` Kiwoong Kim
  2022-02-15 17:15       ` Bart Van Assche
  0 siblings, 1 reply; 14+ messages in thread
From: Kiwoong Kim @ 2022-02-15  6:03 UTC (permalink / raw)
  To: 'Bart Van Assche',
	linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
	martin.petersen, beanhuo, cang, adrian.hunter, sc.suh, hy50.seo,
	sh425.lee, bhoon95.kim, vkumar.1997

> > -	down_read(&hba->clk_scaling_lock);
> > +	if (ufshcd_is_clkscaling_supported(hba))
> > +		down_read(&hba->clk_scaling_lock);
> >
> >   	lrbp = &hba->lrb[tag];
> >   	WARN_ON(lrbp->cmd);
> 
> I don't like this patch at all. This patch makes testing the UFS driver
> more complicated without having any clear benefit. Additionally, adding
> if-statements in front of locking makes static source code analysis harder
> and is an anti-pattern. Please don't do this.
> 
> Bart. 

The benefit that I think is not blocking dev cmd during submitting a scsi cmd.
Rather, I don't understand why this lock is required if a SoC doesn't support clk scaling.

The period of ringing doorbells has been already protected by spin lock.

Thanks.
Kiwoong Kim


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-12  4:44         ` Kiwoong Kim
  2022-02-14 14:31           ` Adrian Hunter
@ 2022-02-15 11:00           ` Bean Huo
  2022-02-15 17:09             ` Bart Van Assche
  2022-02-17  8:12             ` Kiwoong Kim
  1 sibling, 2 replies; 14+ messages in thread
From: Bean Huo @ 2022-02-15 11:00 UTC (permalink / raw)
  To: Kiwoong Kim, 'Adrian Hunter', 'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, sc.suh, hy50.seo, sh425.lee, bhoon95.kim,
	vkumar.1997

On Sat, 2022-02-12 at 13:44 +0900, Kiwoong Kim wrote:
> > The error handler really should have exclusive access.  One of the
> > places
> > you change does explain that:
> > 
> >  		 * Hold the scaling lock just in case dev cmds
> >  		 * are sent via bsg and/or sysfs.
> >  		 */
> > -		down_write(&hba->clk_scaling_lock);
> > +		if (ufshcd_is_clkscaling_supported(hba))
> > +			down_write(&hba->clk_scaling_lock); 
> 
> Yeah.., I saw the comment but didn't get why.
> 
> Is there anyone who knows why it's necessary for all SoCs?
> At lease, I know there is no reason to forbid concurrent executions
> of dev cmd and power mode change.
> 
> If there's nothing, how about adding a quick to ignore it?
> 
> Thanks.
> Kiwoong Kim
> 

The name of clk_scaling_lock has explained everything, for the platform
which doesn't support load-based clk scaling, doesn't need to hold this
lock.

Acked-by: Bean Huo <beanhuo@micron.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-15 11:00           ` Bean Huo
@ 2022-02-15 17:09             ` Bart Van Assche
  2022-02-17  8:12             ` Kiwoong Kim
  1 sibling, 0 replies; 14+ messages in thread
From: Bart Van Assche @ 2022-02-15 17:09 UTC (permalink / raw)
  To: Bean Huo, Kiwoong Kim, 'Adrian Hunter',
	'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, sc.suh, hy50.seo, sh425.lee, bhoon95.kim,
	vkumar.1997

On 2/15/22 03:00, Bean Huo wrote:
> The name of clk_scaling_lock has explained everything, for the platform
> which doesn't support load-based clk scaling, doesn't need to hold this
> lock.

Hi Bean,

Have you noticed Adrian's reply? I agree with Adrian that this patch 
breaks the UFS error handler.

Bart.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-15  6:03     ` Kiwoong Kim
@ 2022-02-15 17:15       ` Bart Van Assche
  2022-02-17  8:15         ` Kiwoong Kim
  0 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2022-02-15 17:15 UTC (permalink / raw)
  To: Kiwoong Kim, linux-scsi, linux-kernel, alim.akhtar, avri.altman,
	jejb, martin.petersen, beanhuo, cang, adrian.hunter, sc.suh,
	hy50.seo, sh425.lee, bhoon95.kim, vkumar.1997

On 2/14/22 22:03, Kiwoong Kim wrote:
> The benefit that I think is not blocking dev cmd during submitting a scsi cmd.

Hi Kiwoong,

Both ufshcd_exec_dev_cmd() and previous versions of 
ufshcd_queuecommand() obtain a reader lock on the clock scaling lock so 
concurrent submission of both command types is allowed. I'm not aware of 
any version of the UFS driver that serializes device commands against 
SCSI commands.

Additionally, please take a look at commit 8d077ede48c1 ("scsi: ufs: 
Optimize the command queueing code"). That patch removes the clock 
scaling lock from ufshcd_queuecommand().

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-15 11:00           ` Bean Huo
  2022-02-15 17:09             ` Bart Van Assche
@ 2022-02-17  8:12             ` Kiwoong Kim
  1 sibling, 0 replies; 14+ messages in thread
From: Kiwoong Kim @ 2022-02-17  8:12 UTC (permalink / raw)
  To: 'Bean Huo', 'Adrian Hunter',
	'Avri Altman',
	linux-scsi, linux-kernel, alim.akhtar, jejb, martin.petersen,
	beanhuo, cang, sc.suh, hy50.seo, sh425.lee, bhoon95.kim,
	vkumar.1997

> The name of clk_scaling_lock has explained everything, for the platform
> which doesn't support load-based clk scaling, doesn't need to hold this
> lock.
> 
> Acked-by: Bean Huo <beanhuo@micron.com>

Okay, thank you for your information.
I still have no idea of why the lock is required for ufshcd_exec_dev_cmd from the UFS specification w/o any featuring.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported.
  2022-02-15 17:15       ` Bart Van Assche
@ 2022-02-17  8:15         ` Kiwoong Kim
  0 siblings, 0 replies; 14+ messages in thread
From: Kiwoong Kim @ 2022-02-17  8:15 UTC (permalink / raw)
  To: 'Bart Van Assche',
	linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
	martin.petersen, beanhuo, cang, adrian.hunter, sc.suh, hy50.seo,
	sh425.lee, bhoon95.kim, vkumar.1997

> On 2/14/22 22:03, Kiwoong Kim wrote:
> > The benefit that I think is not blocking dev cmd during submitting a
> scsi cmd.
> 
> Hi Kiwoong,
> 
> Both ufshcd_exec_dev_cmd() and previous versions of
> ufshcd_queuecommand() obtain a reader lock on the clock scaling lock so
> concurrent submission of both command types is allowed. I'm not aware of
> any version of the UFS driver that serializes device commands against SCSI
> commands.
> 
> Additionally, please take a look at commit 8d077ede48c1 ("scsi: ufs:
> Optimize the command queueing code"). That patch removes the clock scaling
> lock from ufshcd_queuecommand().
> 
> Thanks,
> 
> Bart.

Okay, I got it.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-17  8:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220205074128epcas2p40901c37a7328e825d8697f8d3269edba@epcas2p4.samsung.com>
2022-02-05  7:39 ` [PATCH v1] scsi: ufs: remove clk_scaling_lock when clkscaling isn't supported Kiwoong Kim
2022-02-06  8:20   ` Avri Altman
2022-02-11  2:15     ` Kiwoong Kim
2022-02-11 12:15       ` Adrian Hunter
2022-02-12  4:44         ` Kiwoong Kim
2022-02-14 14:31           ` Adrian Hunter
2022-02-15 11:00           ` Bean Huo
2022-02-15 17:09             ` Bart Van Assche
2022-02-17  8:12             ` Kiwoong Kim
2022-02-11 12:19       ` Avri Altman
2022-02-14 19:29   ` Bart Van Assche
2022-02-15  6:03     ` Kiwoong Kim
2022-02-15 17:15       ` Bart Van Assche
2022-02-17  8:15         ` Kiwoong Kim

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).