diff mbox series

[03/23] mpi3mr: pass queue_limits to bsg_setup_queue

Message ID 20240402130645.653507-4-hch@lst.de (mailing list archive)
State New
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
Pass the limits to bsg_setup_queue instead of setting them up on the live
queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/scsi/mpi3mr/mpi3mr_app.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Hannes Reinecke April 3, 2024, 6:46 a.m. UTC | #1
On 4/2/24 15:06, Christoph Hellwig wrote:
> Pass the limits to bsg_setup_queue instead of setting them up on the live
> queue.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: John Garry <john.g.garry@oracle.com>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   drivers/scsi/mpi3mr/mpi3mr_app.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Bart Van Assche April 4, 2024, 4:55 p.m. UTC | #2
On 4/2/24 06:06, Christoph Hellwig wrote:
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
> index ce5445eb9d0e4e..05e061fc6d3a06 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_app.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
> @@ -1838,6 +1838,10 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
>   {
>   	struct device *bsg_dev = &mrioc->bsg_dev;
>   	struct device *parent = &mrioc->shost->shost_gendev;
> +	struct queue_limits lim = {
> +		.max_hw_sectors		= MPI3MR_MAX_APP_XFER_SECTORS,
> +		.max_segments		= MPI3MR_MAX_APP_XFER_SEGMENTS,
> +	};

Can 'lim' be declared 'static const'?

Thanks,

Bart.
Christoph Hellwig April 5, 2024, 6:42 a.m. UTC | #3
On Thu, Apr 04, 2024 at 09:55:13AM -0700, Bart Van Assche wrote:
> On 4/2/24 06:06, Christoph Hellwig wrote:
>> diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
>> index ce5445eb9d0e4e..05e061fc6d3a06 100644
>> --- a/drivers/scsi/mpi3mr/mpi3mr_app.c
>> +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
>> @@ -1838,6 +1838,10 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
>>   {
>>   	struct device *bsg_dev = &mrioc->bsg_dev;
>>   	struct device *parent = &mrioc->shost->shost_gendev;
>> +	struct queue_limits lim = {
>> +		.max_hw_sectors		= MPI3MR_MAX_APP_XFER_SECTORS,
>> +		.max_segments		= MPI3MR_MAX_APP_XFER_SEGMENTS,
>> +	};
>
> Can 'lim' be declared 'static const'?

It can't because the queue limit validation can modify it (and thus
none of the pointers in the chain leading to it are marked const)
diff mbox series

Patch

diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
index ce5445eb9d0e4e..05e061fc6d3a06 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_app.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -1838,6 +1838,10 @@  void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
 {
 	struct device *bsg_dev = &mrioc->bsg_dev;
 	struct device *parent = &mrioc->shost->shost_gendev;
+	struct queue_limits lim = {
+		.max_hw_sectors		= MPI3MR_MAX_APP_XFER_SECTORS,
+		.max_segments		= MPI3MR_MAX_APP_XFER_SEGMENTS,
+	};
 
 	device_initialize(bsg_dev);
 
@@ -1853,20 +1857,14 @@  void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
 		return;
 	}
 
-	mrioc->bsg_queue = bsg_setup_queue(bsg_dev, dev_name(bsg_dev), NULL,
+	mrioc->bsg_queue = bsg_setup_queue(bsg_dev, dev_name(bsg_dev), &lim,
 			mpi3mr_bsg_request, NULL, 0);
 	if (IS_ERR(mrioc->bsg_queue)) {
 		ioc_err(mrioc, "%s: bsg registration failed\n",
 		    dev_name(bsg_dev));
 		device_del(bsg_dev);
 		put_device(bsg_dev);
-		return;
 	}
-
-	blk_queue_max_segments(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SEGMENTS);
-	blk_queue_max_hw_sectors(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SECTORS);
-
-	return;
 }
 
 /**