@@ -986,6 +986,25 @@ static int mpi3mr_change_queue_depth(struct scsi_device *sdev,
986
986
return retval ;
987
987
}
988
988
989
+ static void mpi3mr_configure_nvme_dev (struct mpi3mr_tgt_dev * tgt_dev ,
990
+ struct queue_limits * lim )
991
+ {
992
+ u8 pgsz = tgt_dev -> dev_spec .pcie_inf .pgsz ? : MPI3MR_DEFAULT_PGSZEXP ;
993
+
994
+ lim -> max_hw_sectors = tgt_dev -> dev_spec .pcie_inf .mdts / 512 ;
995
+ lim -> virt_boundary_mask = (1 << pgsz ) - 1 ;
996
+ }
997
+
998
+ static void mpi3mr_configure_tgt_dev (struct mpi3mr_tgt_dev * tgt_dev ,
999
+ struct queue_limits * lim )
1000
+ {
1001
+ if (tgt_dev -> dev_type == MPI3_DEVICE_DEVFORM_PCIE &&
1002
+ (tgt_dev -> dev_spec .pcie_inf .dev_info &
1003
+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK ) ==
1004
+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE )
1005
+ mpi3mr_configure_nvme_dev (tgt_dev , lim );
1006
+ }
1007
+
989
1008
/**
990
1009
* mpi3mr_update_sdev - Update SCSI device information
991
1010
* @sdev: SCSI device reference
@@ -1001,31 +1020,17 @@ static void
1001
1020
mpi3mr_update_sdev (struct scsi_device * sdev , void * data )
1002
1021
{
1003
1022
struct mpi3mr_tgt_dev * tgtdev ;
1023
+ struct queue_limits lim ;
1004
1024
1005
1025
tgtdev = (struct mpi3mr_tgt_dev * )data ;
1006
1026
if (!tgtdev )
1007
1027
return ;
1008
1028
1009
1029
mpi3mr_change_queue_depth (sdev , tgtdev -> q_depth );
1010
- switch (tgtdev -> dev_type ) {
1011
- case MPI3_DEVICE_DEVFORM_PCIE :
1012
- /*The block layer hw sector size = 512*/
1013
- if ((tgtdev -> dev_spec .pcie_inf .dev_info &
1014
- MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK ) ==
1015
- MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE ) {
1016
- blk_queue_max_hw_sectors (sdev -> request_queue ,
1017
- tgtdev -> dev_spec .pcie_inf .mdts / 512 );
1018
- if (tgtdev -> dev_spec .pcie_inf .pgsz == 0 )
1019
- blk_queue_virt_boundary (sdev -> request_queue ,
1020
- ((1 << MPI3MR_DEFAULT_PGSZEXP ) - 1 ));
1021
- else
1022
- blk_queue_virt_boundary (sdev -> request_queue ,
1023
- ((1 << tgtdev -> dev_spec .pcie_inf .pgsz ) - 1 ));
1024
- }
1025
- break ;
1026
- default :
1027
- break ;
1028
- }
1030
+
1031
+ lim = queue_limits_start_update (sdev -> request_queue );
1032
+ mpi3mr_configure_tgt_dev (tgtdev , & lim );
1033
+ WARN_ON_ONCE (queue_limits_commit_update (sdev -> request_queue , & lim ));
1029
1034
}
1030
1035
1031
1036
/**
@@ -4393,15 +4398,17 @@ static void mpi3mr_target_destroy(struct scsi_target *starget)
4393
4398
}
4394
4399
4395
4400
/**
4396
- * mpi3mr_slave_configure - Slave configure callback handler
4401
+ * mpi3mr_device_configure - Slave configure callback handler
4397
4402
* @sdev: SCSI device reference
4403
+ * @lim: queue limits
4398
4404
*
4399
4405
* Configure queue depth, max hardware sectors and virt boundary
4400
4406
* as required
4401
4407
*
4402
4408
* Return: 0 always.
4403
4409
*/
4404
- static int mpi3mr_slave_configure (struct scsi_device * sdev )
4410
+ static int mpi3mr_device_configure (struct scsi_device * sdev ,
4411
+ struct queue_limits * lim )
4405
4412
{
4406
4413
struct scsi_target * starget ;
4407
4414
struct Scsi_Host * shost ;
@@ -4432,28 +4439,8 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev)
4432
4439
sdev -> eh_timeout = MPI3MR_EH_SCMD_TIMEOUT ;
4433
4440
blk_queue_rq_timeout (sdev -> request_queue , MPI3MR_SCMD_TIMEOUT );
4434
4441
4435
- switch (tgt_dev -> dev_type ) {
4436
- case MPI3_DEVICE_DEVFORM_PCIE :
4437
- /*The block layer hw sector size = 512*/
4438
- if ((tgt_dev -> dev_spec .pcie_inf .dev_info &
4439
- MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK ) ==
4440
- MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE ) {
4441
- blk_queue_max_hw_sectors (sdev -> request_queue ,
4442
- tgt_dev -> dev_spec .pcie_inf .mdts / 512 );
4443
- if (tgt_dev -> dev_spec .pcie_inf .pgsz == 0 )
4444
- blk_queue_virt_boundary (sdev -> request_queue ,
4445
- ((1 << MPI3MR_DEFAULT_PGSZEXP ) - 1 ));
4446
- else
4447
- blk_queue_virt_boundary (sdev -> request_queue ,
4448
- ((1 << tgt_dev -> dev_spec .pcie_inf .pgsz ) - 1 ));
4449
- }
4450
- break ;
4451
- default :
4452
- break ;
4453
- }
4454
-
4442
+ mpi3mr_configure_tgt_dev (tgt_dev , lim );
4455
4443
mpi3mr_tgtdev_put (tgt_dev );
4456
-
4457
4444
return retval ;
4458
4445
}
4459
4446
@@ -4921,7 +4908,7 @@ static const struct scsi_host_template mpi3mr_driver_template = {
4921
4908
.queuecommand = mpi3mr_qcmd ,
4922
4909
.target_alloc = mpi3mr_target_alloc ,
4923
4910
.slave_alloc = mpi3mr_slave_alloc ,
4924
- .slave_configure = mpi3mr_slave_configure ,
4911
+ .device_configure = mpi3mr_device_configure ,
4925
4912
.target_destroy = mpi3mr_target_destroy ,
4926
4913
.slave_destroy = mpi3mr_slave_destroy ,
4927
4914
.scan_finished = mpi3mr_scan_finished ,
0 commit comments