Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	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 v2 1/9] ufs: core: Introduce ufshcd_add_scsi_host()
Date: Sun, 25 Aug 2024 10:40:37 +0530	[thread overview]
Message-ID: <20240825051037.ggp7sjiieksyiapp@thinkpad> (raw)
In-Reply-To: <20240822213645.1125016-2-bvanassche@acm.org>

On Thu, Aug 22, 2024 at 02:36:02PM -0700, Bart Van Assche wrote:
> Move the code for adding a SCSI host and also the code for managing
> TMF tags from ufshcd_init() into a new function called
> ufshcd_add_scsi_host(). No functionality has been changed.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/ufs/core/ufshcd.c | 84 ++++++++++++++++++++++++---------------
>  1 file changed, 53 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 0dd26059f5d7..d29e469c3873 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10381,6 +10381,56 @@ static const struct blk_mq_ops ufshcd_tmf_ops = {
>  	.queue_rq = ufshcd_queue_tmf,
>  };
>  
> +static int ufshcd_add_scsi_host(struct ufs_hba *hba)
> +{
> +	int err;
> +
> +	if (!is_mcq_supported(hba)) {
> +		err = scsi_add_host(hba->host, hba->dev);
> +		if (err) {
> +			dev_err(hba->dev, "scsi_add_host failed\n");
> +			return err;
> +		}
> +		hba->scsi_host_added = true;
> +	}
> +
> +	hba->tmf_tag_set = (struct blk_mq_tag_set) {
> +		.nr_hw_queues	= 1,
> +		.queue_depth	= hba->nutmrs,
> +		.ops		= &ufshcd_tmf_ops,
> +		.flags		= BLK_MQ_F_NO_SCHED,
> +	};
> +	err = blk_mq_alloc_tag_set(&hba->tmf_tag_set);
> +	if (err < 0)
> +		goto remove_scsi_host;
> +	hba->tmf_queue = blk_mq_alloc_queue(&hba->tmf_tag_set, NULL, NULL);
> +	if (IS_ERR(hba->tmf_queue)) {
> +		err = PTR_ERR(hba->tmf_queue);
> +		goto free_tmf_tag_set;
> +	}
> +	hba->tmf_rqs = devm_kcalloc(hba->dev, hba->nutmrs,
> +				    sizeof(*hba->tmf_rqs), GFP_KERNEL);
> +	if (!hba->tmf_rqs) {
> +		err = -ENOMEM;
> +		goto free_tmf_queue;
> +	}
> +
> +	return 0;
> +
> +free_tmf_queue:
> +	blk_mq_destroy_queue(hba->tmf_queue);
> +	blk_put_queue(hba->tmf_queue);
> +
> +free_tmf_tag_set:
> +	blk_mq_free_tag_set(&hba->tmf_tag_set);
> +
> +remove_scsi_host:
> +	if (hba->scsi_host_added)
> +		scsi_remove_host(hba->host);
> +
> +	return err;
> +}
> +
>  /**
>   * ufshcd_init - Driver initialization routine
>   * @hba: per-adapter instance
> @@ -10514,35 +10564,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
>  		hba->is_irq_enabled = true;
>  	}
>  
> -	if (!is_mcq_supported(hba)) {

I guess this series is based on v6.11-rc1, because starting from -rc2 we have
lsdb check here.

- Mani

> -		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;
> -	}
> -
> -	hba->tmf_tag_set = (struct blk_mq_tag_set) {
> -		.nr_hw_queues	= 1,
> -		.queue_depth	= hba->nutmrs,
> -		.ops		= &ufshcd_tmf_ops,
> -		.flags		= BLK_MQ_F_NO_SCHED,
> -	};
> -	err = blk_mq_alloc_tag_set(&hba->tmf_tag_set);
> -	if (err < 0)
> -		goto out_remove_scsi_host;
> -	hba->tmf_queue = blk_mq_alloc_queue(&hba->tmf_tag_set, NULL, NULL);
> -	if (IS_ERR(hba->tmf_queue)) {
> -		err = PTR_ERR(hba->tmf_queue);
> -		goto free_tmf_tag_set;
> -	}
> -	hba->tmf_rqs = devm_kcalloc(hba->dev, hba->nutmrs,
> -				    sizeof(*hba->tmf_rqs), GFP_KERNEL);
> -	if (!hba->tmf_rqs) {
> -		err = -ENOMEM;
> -		goto free_tmf_queue;
> -	}
> +	err = ufshcd_add_scsi_host(hba);
> +	if (err)
> +		goto out_disable;
>  
>  	/* Reset the attached device */
>  	ufshcd_device_reset(hba);
> @@ -10600,9 +10624,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
>  free_tmf_queue:
>  	blk_mq_destroy_queue(hba->tmf_queue);
>  	blk_put_queue(hba->tmf_queue);
> -free_tmf_tag_set:
>  	blk_mq_free_tag_set(&hba->tmf_tag_set);
> -out_remove_scsi_host:
>  	if (hba->scsi_host_added)
>  		scsi_remove_host(hba->host);
>  out_disable:

-- 
மணிவண்ணன் சதாசிவம்

  parent reply	other threads:[~2024-08-25  5:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 21:36 [PATCH v2 0/9] Simplify the UFS driver initialization code Bart Van Assche
2024-08-22 21:36 ` [PATCH v2 1/9] ufs: core: Introduce ufshcd_add_scsi_host() Bart Van Assche
2024-08-24  9:59   ` Avri Altman
2024-08-25  5:10   ` Manivannan Sadhasivam [this message]
2024-08-27 22:04     ` Bart Van Assche
2024-08-22 21:36 ` [PATCH v2 2/9] ufs: core: Introduce ufshcd_activate_link() Bart Van Assche
2024-08-24 10:06   ` Avri Altman
2024-08-25  5:11   ` Manivannan Sadhasivam
2024-08-22 21:36 ` [PATCH v2 3/9] ufs: core: Introduce ufshcd_post_device_init() Bart Van Assche
2024-08-24 10:12   ` Avri Altman
2024-08-25  5:16   ` Manivannan Sadhasivam
2024-08-28 17:05     ` Bart Van Assche
2024-08-22 21:36 ` [PATCH v2 4/9] ufs: core: Call ufshcd_add_scsi_host() later Bart Van Assche
2024-08-25  5:18   ` Manivannan Sadhasivam
2024-08-22 21:36 ` [PATCH v2 5/9] ufs: core: Move the ufshcd_device_init() call Bart Van Assche
2024-08-25  5:22   ` Manivannan Sadhasivam
2024-08-28 17:14     ` Bart Van Assche
2024-08-22 21:36 ` [PATCH v2 6/9] ufs: core: Move the ufshcd_device_init(hba, true) call Bart Van Assche
2024-08-25  5:33   ` Manivannan Sadhasivam
2024-08-28 17:19     ` Bart Van Assche
2024-08-22 21:36 ` [PATCH v2 7/9] ufs: core: Expand " Bart Van Assche
2024-08-25  5:36   ` Manivannan Sadhasivam
2024-08-22 21:36 ` [PATCH v2 8/9] ufs: core: Move the MCQ scsi_add_host() call Bart Van Assche
2024-08-25  5:38   ` Manivannan Sadhasivam
2024-08-22 21:36 ` [PATCH v2 9/9] 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=20240825051037.ggp7sjiieksyiapp@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --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=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