diff mbox series

[12/23] mpt3sas: switch to using ->device_configure

Message ID 20240402130645.653507-13-hch@lst.de (mailing list archive)
State Superseded
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
Switch to the ->device_configure method instead of ->slave_configure
and update the block limits on the passed in queue_limits instead
of using the per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Hannes Reinecke April 3, 2024, 7:08 a.m. UTC | #1
On 4/2/24 15:06, Christoph Hellwig wrote:
> Switch to the ->device_configure method instead of ->slave_configure
> and update the block limits on the passed in queue_limits instead
> of using the per-limit accessors.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   drivers/scsi/mpt3sas/mpt3sas_scsih.c | 18 ++++++++----------
>   1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index ef8ee93005eae6..89ef43a5ef862d 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -2497,14 +2497,15 @@ _scsih_enable_tlr(struct MPT3SAS_ADAPTER *ioc, struct scsi_device *sdev)
>   }
>   
>   /**
> - * scsih_slave_configure - device configure routine.
> + * scsih_device_configure - device configure routine.
>    * @sdev: scsi device struct
> + * @lim: queue limits
>    *
>    * Return: 0 if ok. Any other return is assumed to be an error and
>    * the device is ignored.
>    */
>   static int
> -scsih_slave_configure(struct scsi_device *sdev)
> +scsih_device_configure(struct scsi_device *sdev, struct queue_limits *lim)
>   {
>   	struct Scsi_Host *shost = sdev->host;
>   	struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
> @@ -2609,8 +2610,7 @@ scsih_slave_configure(struct scsi_device *sdev)
>   			    raid_device->num_pds, ds);
>   
>   		if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) {
> -			blk_queue_max_hw_sectors(sdev->request_queue,
> -						MPT3SAS_RAID_MAX_SECTORS);
> +			lim->max_hw_sectors = MPT3SAS_RAID_MAX_SECTORS;
>   			sdev_printk(KERN_INFO, sdev,
>   					"Set queue's max_sector to: %u\n",
>   						MPT3SAS_RAID_MAX_SECTORS);
> @@ -2675,8 +2675,7 @@ scsih_slave_configure(struct scsi_device *sdev)
>   				pcie_device->connector_name);
>   
>   		if (pcie_device->nvme_mdts)
> -			blk_queue_max_hw_sectors(sdev->request_queue,
> -					pcie_device->nvme_mdts/512);
> +			lim->max_hw_sectors = pcie_device->nvme_mdts / 512;
>   
>   		pcie_device_put(pcie_device);
>   		spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
> @@ -2687,8 +2686,7 @@ scsih_slave_configure(struct scsi_device *sdev)
>   		 **/
>   		blk_queue_flag_set(QUEUE_FLAG_NOMERGES,
>   				sdev->request_queue);
> -		blk_queue_virt_boundary(sdev->request_queue,
> -				ioc->page_size - 1);
> +		lim->virt_boundary_mask = ioc->page_size - 1;
>   		return 0;
>   	}
Here the same argument as done for the previous patch could be made; if 
we had the possibility to set NOMERGES in the queue limits we could do 
away with the reference to the request queue here.

Cheers,

Hannes
Bart Van Assche April 4, 2024, 5:17 p.m. UTC | #2
On 4/3/24 00:08, Hannes Reinecke wrote:
> On 4/2/24 15:06, Christoph Hellwig wrote:
>> @@ -2687,8 +2686,7 @@ scsih_slave_configure(struct scsi_device *sdev)
>>            **/
>>           blk_queue_flag_set(QUEUE_FLAG_NOMERGES,
>>                   sdev->request_queue);
>> -        blk_queue_virt_boundary(sdev->request_queue,
>> -                ioc->page_size - 1);
>> +        lim->virt_boundary_mask = ioc->page_size - 1;
>>           return 0;
>>       }
> Here the same argument as done for the previous patch could be made; if 
> we had the possibility to set NOMERGES in the queue limits we could do 
> away with the reference to the request queue here.

Another possibility is to remove all code from drivers that sets
QUEUE_FLAG_NOMERGES. I agree with Christoph that drivers shouldn't set
that flag.

Thanks,

Bart.
Christoph Hellwig April 5, 2024, 6:44 a.m. UTC | #3
On Thu, Apr 04, 2024 at 10:17:15AM -0700, Bart Van Assche wrote:
> Another possibility is to remove all code from drivers that sets
> QUEUE_FLAG_NOMERGES.

That is probably the right thing to do.  Not for this series, though :)
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index ef8ee93005eae6..89ef43a5ef862d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2497,14 +2497,15 @@  _scsih_enable_tlr(struct MPT3SAS_ADAPTER *ioc, struct scsi_device *sdev)
 }
 
 /**
- * scsih_slave_configure - device configure routine.
+ * scsih_device_configure - device configure routine.
  * @sdev: scsi device struct
+ * @lim: queue limits
  *
  * Return: 0 if ok. Any other return is assumed to be an error and
  * the device is ignored.
  */
 static int
-scsih_slave_configure(struct scsi_device *sdev)
+scsih_device_configure(struct scsi_device *sdev, struct queue_limits *lim)
 {
 	struct Scsi_Host *shost = sdev->host;
 	struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
@@ -2609,8 +2610,7 @@  scsih_slave_configure(struct scsi_device *sdev)
 			    raid_device->num_pds, ds);
 
 		if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) {
-			blk_queue_max_hw_sectors(sdev->request_queue,
-						MPT3SAS_RAID_MAX_SECTORS);
+			lim->max_hw_sectors = MPT3SAS_RAID_MAX_SECTORS;
 			sdev_printk(KERN_INFO, sdev,
 					"Set queue's max_sector to: %u\n",
 						MPT3SAS_RAID_MAX_SECTORS);
@@ -2675,8 +2675,7 @@  scsih_slave_configure(struct scsi_device *sdev)
 				pcie_device->connector_name);
 
 		if (pcie_device->nvme_mdts)
-			blk_queue_max_hw_sectors(sdev->request_queue,
-					pcie_device->nvme_mdts/512);
+			lim->max_hw_sectors = pcie_device->nvme_mdts / 512;
 
 		pcie_device_put(pcie_device);
 		spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
@@ -2687,8 +2686,7 @@  scsih_slave_configure(struct scsi_device *sdev)
 		 **/
 		blk_queue_flag_set(QUEUE_FLAG_NOMERGES,
 				sdev->request_queue);
-		blk_queue_virt_boundary(sdev->request_queue,
-				ioc->page_size - 1);
+		lim->virt_boundary_mask = ioc->page_size - 1;
 		return 0;
 	}
 
@@ -11914,7 +11912,7 @@  static const struct scsi_host_template mpt2sas_driver_template = {
 	.queuecommand			= scsih_qcmd,
 	.target_alloc			= scsih_target_alloc,
 	.slave_alloc			= scsih_slave_alloc,
-	.slave_configure		= scsih_slave_configure,
+	.device_configure		= scsih_device_configure,
 	.target_destroy			= scsih_target_destroy,
 	.slave_destroy			= scsih_slave_destroy,
 	.scan_finished			= scsih_scan_finished,
@@ -11952,7 +11950,7 @@  static const struct scsi_host_template mpt3sas_driver_template = {
 	.queuecommand			= scsih_qcmd,
 	.target_alloc			= scsih_target_alloc,
 	.slave_alloc			= scsih_slave_alloc,
-	.slave_configure		= scsih_slave_configure,
+	.device_configure		= scsih_device_configure,
 	.target_destroy			= scsih_target_destroy,
 	.slave_destroy			= scsih_slave_destroy,
 	.scan_finished			= scsih_scan_finished,