diff mbox series

[v5,07/10] scsi: ufs: core: Expand the ufshcd_device_init(hba, true) call

Message ID 20240910215139.3352387-8-bvanassche@acm.org (mailing list archive)
State Changes Requested
Headers show
Series Combine the UFS driver scsi_add_host() calls | expand

Commit Message

Bart Van Assche Sept. 10, 2024, 9:50 p.m. UTC
Expand the ufshcd_device_init(hba, true) call and remove all code that
depends on init_dev_params == false. This change prepares for combining
the two scsi_add_host() calls.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 55 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

Comments

Bao D. Nguyen Sept. 13, 2024, 5:47 a.m. UTC | #1
On 9/10/2024 2:50 PM, Bart Van Assche wrote:
> Expand the ufshcd_device_init(hba, true) call and remove all code that
> depends on init_dev_params == false. This change prepares for combining
> the two scsi_add_host() calls.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/ufs/core/ufshcd.c | 55 ++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index a3c5493ccc8f..efa9c177a80f 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10608,7 +10608,60 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
>   
>   	/* Initialize hba, detect and initialize UFS device */
>   	hba->device_init_start = ktime_get();
> -	err = ufshcd_device_init(hba, /*init_dev_params=*/true);
> +
> +	hba->ufshcd_state = UFSHCD_STATE_RESET;
> +
> +	err = ufshcd_link_startup(hba);
> +	if (err)
> +		goto out_disable;
> +
> +	if (hba->quirks & UFSHCD_QUIRK_SKIP_PH_CONFIGURATION)
> +		goto initialized;
> +
> +	/* Debug counters initialization */
> +	ufshcd_clear_dbg_ufs_stats(hba);
> +
> +	/* UniPro link is active now */
> +	ufshcd_set_link_active(hba);
> +
> +	/* Verify device initialization by sending NOP OUT UPIU */
> +	err = ufshcd_verify_dev_init(hba);
> +	if (err)
> +		goto out_disable;
> +
> +	/* Initiate UFS initialization, and waiting until completion */
> +	err = ufshcd_complete_dev_init(hba);
> +	if (err)
> +		goto out_disable;
> +
> +	err = ufshcd_device_params_init(hba);
> +	if (err)
> +		goto out_disable;
> +
> +	if (is_mcq_supported(hba)) {
> +		ufshcd_mcq_enable(hba);
> +		err = ufshcd_alloc_mcq(hba);
> +		if (!err) {
> +			ufshcd_config_mcq(hba);
> +		} else {
> +			/* Continue with SDB mode */
> +			ufshcd_mcq_disable(hba);
> +			use_mcq_mode = false;
> +			dev_err(hba->dev, "MCQ mode is disabled, err=%d\n",
> +				err);
> +		}
> +		err = scsi_add_host(host, hba->dev);
> +		if (err) {
> +			dev_err(hba->dev, "scsi_add_host failed\n");
> +			goto out_disable;
> +		}
> +		hba->scsi_host_added = true;
> +	}
> +
> +	err = ufshcd_post_device_init(hba);
> +
> +initialized:
> +	ufshcd_process_device_init_result(hba, hba->device_init_start, err);

I have similar comment as in previous patch #6. This patch probably 
changed the print. In the original code, it prints the time spent in 
probe_hba(), but here it prints some part of the time spent in 
ufshcd_init(). There will be some trace prints during init, but the data 
it prints would have inconsistent meaning.

>   	if (err)
>   		goto out_disable;
>   
>
Bart Van Assche Oct. 9, 2024, 10:04 p.m. UTC | #2
On 9/12/24 10:47 PM, Bao D. Nguyen wrote:
> On 9/10/2024 2:50 PM, Bart Van Assche wrote:
>> +    ufshcd_process_device_init_result(hba, hba->device_init_start, err);
> 
> I have similar comment as in previous patch #6. This patch probably 
> changed the print. In the original code, it prints the time spent in 
> probe_hba(), but here it prints some part of the time spent in 
> ufshcd_init(). There will be some trace prints during init, but the data 
> it prints would have inconsistent meaning.

I will see what I can do about this.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index a3c5493ccc8f..efa9c177a80f 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10608,7 +10608,60 @@  int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 
 	/* Initialize hba, detect and initialize UFS device */
 	hba->device_init_start = ktime_get();
-	err = ufshcd_device_init(hba, /*init_dev_params=*/true);
+
+	hba->ufshcd_state = UFSHCD_STATE_RESET;
+
+	err = ufshcd_link_startup(hba);
+	if (err)
+		goto out_disable;
+
+	if (hba->quirks & UFSHCD_QUIRK_SKIP_PH_CONFIGURATION)
+		goto initialized;
+
+	/* Debug counters initialization */
+	ufshcd_clear_dbg_ufs_stats(hba);
+
+	/* UniPro link is active now */
+	ufshcd_set_link_active(hba);
+
+	/* Verify device initialization by sending NOP OUT UPIU */
+	err = ufshcd_verify_dev_init(hba);
+	if (err)
+		goto out_disable;
+
+	/* Initiate UFS initialization, and waiting until completion */
+	err = ufshcd_complete_dev_init(hba);
+	if (err)
+		goto out_disable;
+
+	err = ufshcd_device_params_init(hba);
+	if (err)
+		goto out_disable;
+
+	if (is_mcq_supported(hba)) {
+		ufshcd_mcq_enable(hba);
+		err = ufshcd_alloc_mcq(hba);
+		if (!err) {
+			ufshcd_config_mcq(hba);
+		} else {
+			/* Continue with SDB mode */
+			ufshcd_mcq_disable(hba);
+			use_mcq_mode = false;
+			dev_err(hba->dev, "MCQ mode is disabled, err=%d\n",
+				err);
+		}
+		err = scsi_add_host(host, hba->dev);
+		if (err) {
+			dev_err(hba->dev, "scsi_add_host failed\n");
+			goto out_disable;
+		}
+		hba->scsi_host_added = true;
+	}
+
+	err = ufshcd_post_device_init(hba);
+
+initialized:
+	ufshcd_process_device_init_result(hba, hba->device_init_start, err);
 	if (err)
 		goto out_disable;