public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Peter Wang <peter.wang@mediatek.com>,
	Avri Altman <avri.altman@wdc.com>,
	Andrew Halaney <ahalaney@redhat.com>,
	Bean Huo <beanhuo@micron.com>
Subject: Re: [PATCH v4 06/10] scsi: ufs: core: Move the ufshcd_device_init(hba, true) call
Date: Sat, 7 Sep 2024 12:38:41 -0700	[thread overview]
Message-ID: <5bc336ef-5dc3-de16-bbab-c093220c4baa@quicinc.com> (raw)
In-Reply-To: <20240905220214.738506-7-bvanassche@acm.org>

On 9/5/2024 3:01 PM, Bart Van Assche wrote:
> Move the ufshcd_device_init(hba, true) call from ufshcd_async_scan()
> into ufshcd_init(). This patch prepares for moving both scsi_add_host()
> calls into ufshcd_add_scsi_host(). Calling ufshcd_device_init() from
> ufshcd_init() without holding hba->host_sem is safe. This is safe because
> hba->host_sem serializes core code and sysfs callbacks. The
> ufshcd_device_init() call is moved before the scsi_add_host() call and
> hence happens before any SCSI sysfs attributes are created.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/ufs/core/ufshcd.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 6e3cffcdf9a6..843566720afa 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8908,10 +8908,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
>   	int ret;
>   
>   	down(&hba->host_sem);
> -	/* Initialize hba, detect and initialize UFS device */
> -	ret = ufshcd_device_init(hba, /*init_dev_params=*/true);
> -	if (ret == 0)
> -		ret = ufshcd_probe_hba(hba);
> +	ret = ufshcd_probe_hba(hba);
>   	up(&hba->host_sem);
>   	if (ret)
>   		goto out;
> @@ -10605,6 +10602,10 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
>   	 */
>   	ufshcd_set_ufs_dev_active(hba);
>   
> +	err = ufshcd_device_init(hba, /*init_dev_params=*/true);
> +	if (err)
> +		goto out_disable;
> +

In SDB mode, the order of execution for these two functions changed by 
this patch. In the original code, the scsi_add_host() happens first, 
then the code within ufshcd_post_device_init(). Here it is the opposite. 
However, it seems the order can be swapped without any issue.

>   	err = ufshcd_add_scsi_host(hba);
>   	if (err)
>   		goto out_disable;
> 


  reply	other threads:[~2024-09-07 19:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05 22:01 [PATCH v4 00/10] Simplify the UFS driver initialization code Bart Van Assche
2024-09-05 22:01 ` [PATCH v4 01/10] scsi: ufs: core: Introduce ufshcd_add_scsi_host() Bart Van Assche
2024-09-06 23:51   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 02/10] scsi: ufs: core: Introduce ufshcd_activate_link() Bart Van Assche
2024-09-06 23:59   ` Bao D. Nguyen
2024-09-09 17:08     ` Bart Van Assche
2024-09-05 22:01 ` [PATCH v4 03/10] scsi: ufs: core: Introduce ufshcd_post_device_init() Bart Van Assche
2024-09-07  0:24   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 04/10] scsi: ufs: core: Call ufshcd_add_scsi_host() later Bart Van Assche
2024-09-07 10:52   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 05/10] scsi: ufs: core: Move the ufshcd_device_init() call Bart Van Assche
2024-09-07 11:12   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 06/10] scsi: ufs: core: Move the ufshcd_device_init(hba, true) call Bart Van Assche
2024-09-07 19:38   ` Bao D. Nguyen [this message]
2024-09-05 22:01 ` [PATCH v4 07/10] scsi: ufs: core: Expand " Bart Van Assche
2024-09-07 20:15   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 08/10] scsi: ufs: core: Move the MCQ scsi_add_host() call Bart Van Assche
2024-09-07 20:27   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 09/10] scsi: ufs: core: Move code out of an if-statement Bart Van Assche
2024-09-07 20:36   ` Bao D. Nguyen
2024-09-05 22:01 ` [PATCH v4 10/10] scsi: ufs: core: Remove the second argument of ufshcd_device_init() Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5bc336ef-5dc3-de16-bbab-c093220c4baa@quicinc.com \
    --to=quic_nguyenb@quicinc.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=ahalaney@redhat.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=martin.petersen@oracle.com \
    --cc=peter.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox