Skip to content

Commit 310887f

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: mpi3mr: Switch to using ->device_configure
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. Note that mpi3mr also updates the limits from an event handler that iterates all SCSI devices. This is also updated to use the queue_limits, but the complete locking of this path probably means it already is completely broken and needs a proper audit. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent a25a9c8 commit 310887f

File tree

1 file changed

+30
-43
lines changed

1 file changed

+30
-43
lines changed

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,25 @@ static int mpi3mr_change_queue_depth(struct scsi_device *sdev,
986986
return retval;
987987
}
988988

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+
9891008
/**
9901009
* mpi3mr_update_sdev - Update SCSI device information
9911010
* @sdev: SCSI device reference
@@ -1001,31 +1020,17 @@ static void
10011020
mpi3mr_update_sdev(struct scsi_device *sdev, void *data)
10021021
{
10031022
struct mpi3mr_tgt_dev *tgtdev;
1023+
struct queue_limits lim;
10041024

10051025
tgtdev = (struct mpi3mr_tgt_dev *)data;
10061026
if (!tgtdev)
10071027
return;
10081028

10091029
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));
10291034
}
10301035

10311036
/**
@@ -4393,15 +4398,17 @@ static void mpi3mr_target_destroy(struct scsi_target *starget)
43934398
}
43944399

43954400
/**
4396-
* mpi3mr_slave_configure - Slave configure callback handler
4401+
* mpi3mr_device_configure - Slave configure callback handler
43974402
* @sdev: SCSI device reference
4403+
* @lim: queue limits
43984404
*
43994405
* Configure queue depth, max hardware sectors and virt boundary
44004406
* as required
44014407
*
44024408
* Return: 0 always.
44034409
*/
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)
44054412
{
44064413
struct scsi_target *starget;
44074414
struct Scsi_Host *shost;
@@ -4432,28 +4439,8 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev)
44324439
sdev->eh_timeout = MPI3MR_EH_SCMD_TIMEOUT;
44334440
blk_queue_rq_timeout(sdev->request_queue, MPI3MR_SCMD_TIMEOUT);
44344441

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);
44554443
mpi3mr_tgtdev_put(tgt_dev);
4456-
44574444
return retval;
44584445
}
44594446

@@ -4921,7 +4908,7 @@ static const struct scsi_host_template mpi3mr_driver_template = {
49214908
.queuecommand = mpi3mr_qcmd,
49224909
.target_alloc = mpi3mr_target_alloc,
49234910
.slave_alloc = mpi3mr_slave_alloc,
4924-
.slave_configure = mpi3mr_slave_configure,
4911+
.device_configure = mpi3mr_device_configure,
49254912
.target_destroy = mpi3mr_target_destroy,
49264913
.slave_destroy = mpi3mr_slave_destroy,
49274914
.scan_finished = mpi3mr_scan_finished,

0 commit comments

Comments
 (0)