diff mbox series

[05/23] scsi_transport_fc: add a max_bsg_segments field to struct fc_function_template

Message ID 20240402130645.653507-6-hch@lst.de (mailing list archive)
State Accepted
Commit 7eaae991c30d46a4ea45aa00f50eba939d7f951b
Headers show
Series [01/23] block: add a helper to cancel atomic queue limit updates | expand

Commit Message

Christoph Hellwig April 2, 2024, 1:06 p.m. UTC
ibmvfc only supports a single segment for BSG FC passthrough.  Instead of
having it set a queue limits after creating the BSD queues, add a field so
that the FC transport can set it before allocating the queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/scsi/ibmvscsi/ibmvfc.c   | 5 +----
 drivers/scsi/scsi_transport_fc.c | 2 ++
 include/scsi/scsi_transport_fc.h | 1 +
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Hannes Reinecke April 3, 2024, 6:50 a.m. UTC | #1
On 4/2/24 15:06, Christoph Hellwig wrote:
> ibmvfc only supports a single segment for BSG FC passthrough.  Instead of
> having it set a queue limits after creating the BSD queues, add a field so
> that the FC transport can set it before allocating the queue.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   drivers/scsi/ibmvscsi/ibmvfc.c   | 5 +----
>   drivers/scsi/scsi_transport_fc.c | 2 ++
>   include/scsi/scsi_transport_fc.h | 1 +
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
> index 05b126bfd18b55..a3d1013c83075c 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc.c
> @@ -5541,8 +5541,6 @@ static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt)
>   			rport->supported_classes |= FC_COS_CLASS2;
>   		if (be32_to_cpu(tgt->service_parms.class3_parms[0]) & 0x80000000)
>   			rport->supported_classes |= FC_COS_CLASS3;
> -		if (rport->rqst_q)
> -			blk_queue_max_segments(rport->rqst_q, 1);
>   	} else
>   		tgt_dbg(tgt, "rport add failed\n");
>   	spin_unlock_irqrestore(vhost->host->host_lock, flags);
> @@ -6391,8 +6389,6 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
>   
>   	ibmvfc_init_sub_crqs(vhost);
>   
> -	if (shost_to_fc_host(shost)->rqst_q)
> -		blk_queue_max_segments(shost_to_fc_host(shost)->rqst_q, 1);
>   	dev_set_drvdata(dev, vhost);
>   	spin_lock(&ibmvfc_driver_lock);
>   	list_add_tail(&vhost->queue, &ibmvfc_head);
> @@ -6547,6 +6543,7 @@ static struct fc_function_template ibmvfc_transport_functions = {
>   	.get_starget_port_id = ibmvfc_get_starget_port_id,
>   	.show_starget_port_id = 1,
>   
> +	.max_bsg_segments = 1,
>   	.bsg_request = ibmvfc_bsg_request,
>   	.bsg_timeout = ibmvfc_bsg_timeout,
>   };
> diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
> index 0799700b0fca77..7d088b8da07578 100644
> --- a/drivers/scsi/scsi_transport_fc.c
> +++ b/drivers/scsi/scsi_transport_fc.c
> @@ -4288,6 +4288,7 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)
>   	snprintf(bsg_name, sizeof(bsg_name),
>   		 "fc_host%d", shost->host_no);
>   	scsi_init_limits(shost, &lim);
> +	lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
>   	q = bsg_setup_queue(dev, bsg_name, &lim, fc_bsg_dispatch,
>   			fc_bsg_job_timeout, i->f->dd_bsg_size);
>   	if (IS_ERR(q)) {
> @@ -4320,6 +4321,7 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
>   		return -ENOTSUPP;
>   
>   	scsi_init_limits(shost, &lim);
> +	lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
>   	q = bsg_setup_queue(dev, dev_name(dev), &lim, fc_bsg_dispatch_prep,
>   				fc_bsg_job_timeout, i->f->dd_bsg_size);
>   	if (IS_ERR(q)) {
> diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
> index 483513c575976c..fd039306ffbb20 100644
> --- a/include/scsi/scsi_transport_fc.h
> +++ b/include/scsi/scsi_transport_fc.h
> @@ -709,6 +709,7 @@ struct fc_function_template {
>   	int  	(*vport_delete)(struct fc_vport *);
>   
>   	/* bsg support */
> +	u32				max_bsg_segments;
>   	int	(*bsg_request)(struct bsg_job *);
>   	int	(*bsg_timeout)(struct bsg_job *);
>   
That looks like an odd alignment...

Anyway:
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Christoph Hellwig April 3, 2024, 12:53 p.m. UTC | #2
On Wed, Apr 03, 2024 at 08:50:52AM +0200, Hannes Reinecke wrote:
>> +++ b/include/scsi/scsi_transport_fc.h
>> @@ -709,6 +709,7 @@ struct fc_function_template {
>>   	int  	(*vport_delete)(struct fc_vport *);
>>     	/* bsg support */
>> +	u32				max_bsg_segments;
>>   	int	(*bsg_request)(struct bsg_job *);
>>   	int	(*bsg_timeout)(struct bsg_job *);
>>   
> That looks like an odd alignment...

With alignment do you mean the indentation?  It matches that of other
non-function pointer fields in this structure.
Bart Van Assche April 4, 2024, 4:56 p.m. UTC | #3
On 4/2/24 06:06, Christoph Hellwig wrote:
> ibmvfc only supports a single segment for BSG FC passthrough.  Instead of
> having it set a queue limits after creating the BSD queues, add a field so
                                                   ^^^
                                                   BSG?
> that the FC transport can set it before allocating the queue.

Thanks,

Bart.
Christoph Hellwig April 5, 2024, 6:43 a.m. UTC | #4
On Thu, Apr 04, 2024 at 09:56:45AM -0700, Bart Van Assche wrote:
> On 4/2/24 06:06, Christoph Hellwig wrote:
>> ibmvfc only supports a single segment for BSG FC passthrough.  Instead of
>> having it set a queue limits after creating the BSD queues, add a field so
>                                                   ^^^
>                                                   BSG?

Yes, thanks.
diff mbox series

Patch

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 05b126bfd18b55..a3d1013c83075c 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -5541,8 +5541,6 @@  static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt)
 			rport->supported_classes |= FC_COS_CLASS2;
 		if (be32_to_cpu(tgt->service_parms.class3_parms[0]) & 0x80000000)
 			rport->supported_classes |= FC_COS_CLASS3;
-		if (rport->rqst_q)
-			blk_queue_max_segments(rport->rqst_q, 1);
 	} else
 		tgt_dbg(tgt, "rport add failed\n");
 	spin_unlock_irqrestore(vhost->host->host_lock, flags);
@@ -6391,8 +6389,6 @@  static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
 
 	ibmvfc_init_sub_crqs(vhost);
 
-	if (shost_to_fc_host(shost)->rqst_q)
-		blk_queue_max_segments(shost_to_fc_host(shost)->rqst_q, 1);
 	dev_set_drvdata(dev, vhost);
 	spin_lock(&ibmvfc_driver_lock);
 	list_add_tail(&vhost->queue, &ibmvfc_head);
@@ -6547,6 +6543,7 @@  static struct fc_function_template ibmvfc_transport_functions = {
 	.get_starget_port_id = ibmvfc_get_starget_port_id,
 	.show_starget_port_id = 1,
 
+	.max_bsg_segments = 1,
 	.bsg_request = ibmvfc_bsg_request,
 	.bsg_timeout = ibmvfc_bsg_timeout,
 };
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 0799700b0fca77..7d088b8da07578 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -4288,6 +4288,7 @@  fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)
 	snprintf(bsg_name, sizeof(bsg_name),
 		 "fc_host%d", shost->host_no);
 	scsi_init_limits(shost, &lim);
+	lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
 	q = bsg_setup_queue(dev, bsg_name, &lim, fc_bsg_dispatch,
 			fc_bsg_job_timeout, i->f->dd_bsg_size);
 	if (IS_ERR(q)) {
@@ -4320,6 +4321,7 @@  fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
 		return -ENOTSUPP;
 
 	scsi_init_limits(shost, &lim);
+	lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
 	q = bsg_setup_queue(dev, dev_name(dev), &lim, fc_bsg_dispatch_prep,
 				fc_bsg_job_timeout, i->f->dd_bsg_size);
 	if (IS_ERR(q)) {
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 483513c575976c..fd039306ffbb20 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -709,6 +709,7 @@  struct fc_function_template {
 	int  	(*vport_delete)(struct fc_vport *);
 
 	/* bsg support */
+	u32				max_bsg_segments;
 	int	(*bsg_request)(struct bsg_job *);
 	int	(*bsg_timeout)(struct bsg_job *);