Skip to content

Commit d9adb81

Browse files
Ranjan Kumarmartinkpetersen
authored andcommitted
scsi: mpi3mr: Add support for more than 1MB I/O
Enhance the driver to get the maximum data length per I/O request from IOC Facts data and report that to the upper layers. If the IOC facts data is not reported then a default I/O size of 1MB is reported to the OS. Signed-off-by: Ranjan Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6f81b1c commit d9adb81

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ extern atomic64_t event_counter;
6666
#define MPI3MR_NAME_LENGTH 32
6767
#define IOCNAME "%s: "
6868

69-
#define MPI3MR_MAX_SECTORS 2048
69+
#define MPI3MR_DEFAULT_MAX_IO_SIZE (1 * 1024 * 1024)
7070

7171
/* Definitions for internal SGL and Chain SGL buffers */
7272
#define MPI3MR_PAGE_SIZE_4K 4096
73-
#define MPI3MR_SG_DEPTH (MPI3MR_PAGE_SIZE_4K / sizeof(struct mpi3_sge_common))
73+
#define MPI3MR_DEFAULT_SGL_ENTRIES 256
74+
#define MPI3MR_MAX_SGL_ENTRIES 2048
7475

7576
/* Definitions for MAX values for shost */
7677
#define MPI3MR_MAX_CMDS_LUN 128
@@ -323,6 +324,7 @@ struct mpi3mr_ioc_facts {
323324
u16 max_perids;
324325
u16 max_pds;
325326
u16 max_sasexpanders;
327+
u32 max_data_length;
326328
u16 max_sasinitiators;
327329
u16 max_enclosures;
328330
u16 max_pcie_switches;
@@ -959,6 +961,7 @@ struct scmd_priv {
959961
* @stop_drv_processing: Stop all command processing
960962
* @device_refresh_on: Don't process the events until devices are refreshed
961963
* @max_host_ios: Maximum host I/O count
964+
* @max_sgl_entries: Max SGL entries per I/O
962965
* @chain_buf_count: Chain buffer count
963966
* @chain_buf_pool: Chain buffer pool
964967
* @chain_sgl_list: Chain SGL list
@@ -1129,6 +1132,7 @@ struct mpi3mr_ioc {
11291132
u16 max_host_ios;
11301133
spinlock_t tgtdev_lock;
11311134
struct list_head tgtdev_list;
1135+
u16 max_sgl_entries;
11321136

11331137
u32 chain_buf_count;
11341138
struct dma_pool *chain_buf_pool;

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,12 @@ mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc)
11631163
return -EPERM;
11641164
}
11651165

1166+
if (mrioc->shost->max_sectors != (mrioc->facts.max_data_length / 512))
1167+
ioc_err(mrioc, "Warning: The maximum data transfer length\n"
1168+
"\tchanged after reset: previous(%d), new(%d),\n"
1169+
"the driver cannot change this at run time\n",
1170+
mrioc->shost->max_sectors * 512, mrioc->facts.max_data_length);
1171+
11661172
if ((mrioc->sas_transport_enabled) && (mrioc->facts.ioc_capabilities &
11671173
MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED))
11681174
ioc_err(mrioc,
@@ -2856,6 +2862,7 @@ static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
28562862
le16_to_cpu(facts_data->max_pcie_switches);
28572863
mrioc->facts.max_sasexpanders =
28582864
le16_to_cpu(facts_data->max_sas_expanders);
2865+
mrioc->facts.max_data_length = le16_to_cpu(facts_data->max_data_length);
28592866
mrioc->facts.max_sasinitiators =
28602867
le16_to_cpu(facts_data->max_sas_initiators);
28612868
mrioc->facts.max_enclosures = le16_to_cpu(facts_data->max_enclosures);
@@ -2893,13 +2900,18 @@ static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
28932900
mrioc->facts.io_throttle_high =
28942901
le16_to_cpu(facts_data->io_throttle_high);
28952902

2903+
if (mrioc->facts.max_data_length ==
2904+
MPI3_IOCFACTS_MAX_DATA_LENGTH_NOT_REPORTED)
2905+
mrioc->facts.max_data_length = MPI3MR_DEFAULT_MAX_IO_SIZE;
2906+
else
2907+
mrioc->facts.max_data_length *= MPI3MR_PAGE_SIZE_4K;
28962908
/* Store in 512b block count */
28972909
if (mrioc->facts.io_throttle_data_length)
28982910
mrioc->io_throttle_data_length =
28992911
(mrioc->facts.io_throttle_data_length * 2 * 4);
29002912
else
29012913
/* set the length to 1MB + 1K to disable throttle */
2902-
mrioc->io_throttle_data_length = MPI3MR_MAX_SECTORS + 2;
2914+
mrioc->io_throttle_data_length = (mrioc->facts.max_data_length / 512) + 2;
29032915

29042916
mrioc->io_throttle_high = (mrioc->facts.io_throttle_high * 2 * 1024);
29052917
mrioc->io_throttle_low = (mrioc->facts.io_throttle_low * 2 * 1024);
@@ -2914,9 +2926,9 @@ static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
29142926
ioc_info(mrioc, "SGEModMask 0x%x SGEModVal 0x%x SGEModShift 0x%x ",
29152927
mrioc->facts.sge_mod_mask, mrioc->facts.sge_mod_value,
29162928
mrioc->facts.sge_mod_shift);
2917-
ioc_info(mrioc, "DMA mask %d InitialPE status 0x%x\n",
2929+
ioc_info(mrioc, "DMA mask %d InitialPE status 0x%x max_data_len (%d)\n",
29182930
mrioc->facts.dma_mask, (facts_flags &
2919-
MPI3_IOCFACTS_FLAGS_INITIAL_PORT_ENABLE_MASK));
2931+
MPI3_IOCFACTS_FLAGS_INITIAL_PORT_ENABLE_MASK), mrioc->facts.max_data_length);
29202932
ioc_info(mrioc,
29212933
"max_dev_per_throttle_group(%d), max_throttle_groups(%d)\n",
29222934
mrioc->facts.max_dev_per_tg, mrioc->facts.max_io_throttle_group);
@@ -3414,7 +3426,14 @@ static int mpi3mr_alloc_chain_bufs(struct mpi3mr_ioc *mrioc)
34143426
if (!mrioc->chain_sgl_list)
34153427
goto out_failed;
34163428

3417-
sz = MPI3MR_PAGE_SIZE_4K;
3429+
if (mrioc->max_sgl_entries > (mrioc->facts.max_data_length /
3430+
MPI3MR_PAGE_SIZE_4K))
3431+
mrioc->max_sgl_entries = mrioc->facts.max_data_length /
3432+
MPI3MR_PAGE_SIZE_4K;
3433+
sz = mrioc->max_sgl_entries * sizeof(struct mpi3_sge_common);
3434+
ioc_info(mrioc, "number of sgl entries=%d chain buffer size=%dKB\n",
3435+
mrioc->max_sgl_entries, sz/1024);
3436+
34183437
mrioc->chain_buf_pool = dma_pool_create("chain_buf pool",
34193438
&mrioc->pdev->dev, sz, 16, 0);
34203439
if (!mrioc->chain_buf_pool) {
@@ -3813,7 +3832,7 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc)
38133832
}
38143833

38153834
mrioc->max_host_ios = mrioc->facts.max_reqs - MPI3MR_INTERNAL_CMDS_RESVD;
3816-
3835+
mrioc->shost->max_sectors = mrioc->facts.max_data_length / 512;
38173836
mrioc->num_io_throttle_group = mrioc->facts.max_io_throttle_group;
38183837
atomic_set(&mrioc->pend_large_data_sz, 0);
38193838

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ static int logging_level;
3333
module_param(logging_level, int, 0);
3434
MODULE_PARM_DESC(logging_level,
3535
" bits for enabling additional logging info (default=0)");
36+
static int max_sgl_entries = MPI3MR_DEFAULT_SGL_ENTRIES;
37+
module_param(max_sgl_entries, int, 0444);
38+
MODULE_PARM_DESC(max_sgl_entries,
39+
"Preferred max number of SG entries to be used for a single I/O\n"
40+
"The actual value will be determined by the driver\n"
41+
"(Minimum=256, Maximum=2048, default=256)");
3642

3743
/* Forward declarations*/
3844
static void mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
@@ -3413,7 +3419,7 @@ static int mpi3mr_prepare_sg_scmd(struct mpi3mr_ioc *mrioc,
34133419
scsi_bufflen(scmd));
34143420
return -ENOMEM;
34153421
}
3416-
if (sges_left > MPI3MR_SG_DEPTH) {
3422+
if (sges_left > mrioc->max_sgl_entries) {
34173423
sdev_printk(KERN_ERR, scmd->device,
34183424
"scsi_dma_map returned unsupported sge count %d!\n",
34193425
sges_left);
@@ -4818,10 +4824,10 @@ static const struct scsi_host_template mpi3mr_driver_template = {
48184824
.no_write_same = 1,
48194825
.can_queue = 1,
48204826
.this_id = -1,
4821-
.sg_tablesize = MPI3MR_SG_DEPTH,
4827+
.sg_tablesize = MPI3MR_DEFAULT_SGL_ENTRIES,
48224828
/* max xfer supported is 1M (2K in 512 byte sized sectors)
48234829
*/
4824-
.max_sectors = 2048,
4830+
.max_sectors = (MPI3MR_DEFAULT_MAX_IO_SIZE / 512),
48254831
.cmd_per_lun = MPI3MR_MAX_CMDS_LUN,
48264832
.max_segment_size = 0xffffffff,
48274833
.track_queue_depth = 1,
@@ -5004,6 +5010,16 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
50045010
mrioc->pdev = pdev;
50055011
mrioc->stop_bsgs = 1;
50065012

5013+
mrioc->max_sgl_entries = max_sgl_entries;
5014+
if (max_sgl_entries > MPI3MR_MAX_SGL_ENTRIES)
5015+
mrioc->max_sgl_entries = MPI3MR_MAX_SGL_ENTRIES;
5016+
else if (max_sgl_entries < MPI3MR_DEFAULT_SGL_ENTRIES)
5017+
mrioc->max_sgl_entries = MPI3MR_DEFAULT_SGL_ENTRIES;
5018+
else {
5019+
mrioc->max_sgl_entries /= MPI3MR_DEFAULT_SGL_ENTRIES;
5020+
mrioc->max_sgl_entries *= MPI3MR_DEFAULT_SGL_ENTRIES;
5021+
}
5022+
50075023
/* init shost parameters */
50085024
shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH;
50095025
shost->max_lun = -1;
@@ -5068,7 +5084,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
50685084
shost->nr_maps = 3;
50695085

50705086
shost->can_queue = mrioc->max_host_ios;
5071-
shost->sg_tablesize = MPI3MR_SG_DEPTH;
5087+
shost->sg_tablesize = mrioc->max_sgl_entries;
50725088
shost->max_id = mrioc->facts.max_perids + 1;
50735089

50745090
retval = scsi_add_host(shost, &pdev->dev);

0 commit comments

Comments
 (0)