diff mbox series

[v2,1/1] ufs: mcq: fix incorrectly set queue depth

Message ID 8840cea4a57b46dabce18acc39afc50ab826330f.1676567593.git.quic_asutoshd@quicinc.com (mailing list archive)
State Deferred
Headers show
Series [v2,1/1] ufs: mcq: fix incorrectly set queue depth | expand

Commit Message

Asutosh Das Feb. 16, 2023, 5:13 p.m. UTC
ufshcd_config_mcq() may change the can_queue value.
The current code invokes scsi_add_host() before ufshcd_config_mcq().
So the tags are limited to the old can_queue value.

Fix this by invoking scsi_add_host() after ufshcd_config_mcq().

Fixes: 2468da61ea09 ("scsi: ufs: core: mcq: Configure operation and runtime interface")
Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>

----
v1 -> v2:
  - Added Fixes tag
  - Reworked to handle success case first
---
 drivers/ufs/core/ufshcd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Bart Van Assche Feb. 16, 2023, 5:46 p.m. UTC | #1
On 2/16/23 09:13, Asutosh Das wrote:
> ufshcd_config_mcq() may change the can_queue value.
> The current code invokes scsi_add_host() before ufshcd_config_mcq().
> So the tags are limited to the old can_queue value.
> 
> Fix this by invoking scsi_add_host() after ufshcd_config_mcq().

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Manivannan Sadhasivam Feb. 16, 2023, 6:09 p.m. UTC | #2
On Thu, Feb 16, 2023 at 09:13:46AM -0800, Asutosh Das wrote:
> ufshcd_config_mcq() may change the can_queue value.
> The current code invokes scsi_add_host() before ufshcd_config_mcq().
> So the tags are limited to the old can_queue value.
> 
> Fix this by invoking scsi_add_host() after ufshcd_config_mcq().
> 
> Fixes: 2468da61ea09 ("scsi: ufs: core: mcq: Configure operation and runtime interface")
> Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> 
> ----
> v1 -> v2:
>   - Added Fixes tag
>   - Reworked to handle success case first
> ---
>  drivers/ufs/core/ufshcd.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 3b3cf78d3b10..3891183897f0 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8530,7 +8530,9 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
>  			return ret;
>  		if (is_mcq_supported(hba) && !hba->scsi_host_added) {
>  			ret = ufshcd_alloc_mcq(hba);
> -			if (ret) {
> +			if (!ret) {
> +				ufshcd_config_mcq(hba);
> +			} else {
>  				/* Continue with SDB mode */
>  				use_mcq_mode = false;
>  				dev_err(hba->dev, "MCQ mode is disabled, err=%d\n",
> @@ -8542,10 +8544,10 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
>  				return ret;
>  			}
>  			hba->scsi_host_added = true;
> -		}
> -		/* MCQ may be disabled if ufshcd_alloc_mcq() fails */
> -		if (is_mcq_supported(hba) && use_mcq_mode)
> +		} else if (is_mcq_supported(hba)) {
> +			/* UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is set */
>  			ufshcd_config_mcq(hba);
> +		}
>  	}
>  
>  	ufshcd_tune_unipro_params(hba);
> -- 
> 2.7.4
>
Martin K. Petersen Feb. 21, 2023, 11:21 p.m. UTC | #3
Asutosh,

> ufshcd_config_mcq() may change the can_queue value.  The current code
> invokes scsi_add_host() before ufshcd_config_mcq().  So the tags are
> limited to the old can_queue value.

Applied to 6.3/scsi-staging, thanks!
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 3b3cf78d3b10..3891183897f0 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8530,7 +8530,9 @@  static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
 			return ret;
 		if (is_mcq_supported(hba) && !hba->scsi_host_added) {
 			ret = ufshcd_alloc_mcq(hba);
-			if (ret) {
+			if (!ret) {
+				ufshcd_config_mcq(hba);
+			} else {
 				/* Continue with SDB mode */
 				use_mcq_mode = false;
 				dev_err(hba->dev, "MCQ mode is disabled, err=%d\n",
@@ -8542,10 +8544,10 @@  static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
 				return ret;
 			}
 			hba->scsi_host_added = true;
-		}
-		/* MCQ may be disabled if ufshcd_alloc_mcq() fails */
-		if (is_mcq_supported(hba) && use_mcq_mode)
+		} else if (is_mcq_supported(hba)) {
+			/* UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is set */
 			ufshcd_config_mcq(hba);
+		}
 	}
 
 	ufshcd_tune_unipro_params(hba);