Skip to content

Commit 5a14131

Browse files
Viswas Gmartinkpetersen
authored andcommitted
scsi: pm80xx: Increase the number of outstanding I/O supported to 1024
The pm80xx driver currently sets the controller queue depth to 256. Hoewver, the controller supports outstanding I/Os up 1024. Increase the number of outstanding I/Os from 256 to 1024. CCBs and tags are allocated according to outstanding I/Os. Also update the can_queue value (max_out_io - PM8001_RESERVE_SLOT) used by the SCSI midlayer. [mkp: fixed zeroday complaint] Link: https://lore.kernel.org/r/20201005145011.23674-4-Viswas.G@microchip.com.com Reported-by: kernel test robot <lkp@intel.com> Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com> Signed-off-by: Viswas G <Viswas.G@microchip.com> Signed-off-by: Ruksar Devadi <Ruksar.devadi@microchip.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 27bc43b commit 5a14131

5 files changed

Lines changed: 73 additions & 47 deletions

File tree

drivers/scsi/pm8001/pm8001_defs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ enum port_type {
7575
};
7676

7777
/* driver compile-time configuration */
78-
#define PM8001_MAX_CCB 256 /* max ccbs supported */
78+
#define PM8001_MAX_CCB 1024 /* max ccbs supported */
7979
#define PM8001_MPI_QUEUE 1024 /* maximum mpi queue entries */
8080
#define PM8001_MAX_INB_NUM 64
8181
#define PM8001_MAX_OUTB_NUM 64
@@ -90,9 +90,11 @@ enum port_type {
9090
#define PM8001_MAX_PORTS 16 /* max. possible ports */
9191
#define PM8001_MAX_DEVICES 2048 /* max supported device */
9292
#define PM8001_MAX_MSIX_VEC 64 /* max msi-x int for spcv/ve */
93+
#define PM8001_RESERVE_SLOT 8
9394

9495
#define CONFIG_SCSI_PM8001_MAX_DMA_SG 528
9596
#define PM8001_MAX_DMA_SG CONFIG_SCSI_PM8001_MAX_DMA_SG
97+
9698
enum memory_region_num {
9799
AAP1 = 0x0, /* application acceleration processor */
98100
IOP, /* IO processor */

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4375,8 +4375,7 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
43754375
/* fill in PRD (scatter/gather) table, if any */
43764376
if (task->num_scatter > 1) {
43774377
pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd);
4378-
phys_addr = ccb->ccb_dma_handle +
4379-
offsetof(struct pm8001_ccb_info, buf_prd[0]);
4378+
phys_addr = ccb->ccb_dma_handle;
43804379
ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(phys_addr));
43814380
ssp_cmd.addr_high = cpu_to_le32(upper_32_bits(phys_addr));
43824381
ssp_cmd.esgl = cpu_to_le32(1<<31);
@@ -4449,8 +4448,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
44494448
/* fill in PRD (scatter/gather) table, if any */
44504449
if (task->num_scatter > 1) {
44514450
pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd);
4452-
phys_addr = ccb->ccb_dma_handle +
4453-
offsetof(struct pm8001_ccb_info, buf_prd[0]);
4451+
phys_addr = ccb->ccb_dma_handle;
44544452
sata_cmd.addr_low = lower_32_bits(phys_addr);
44554453
sata_cmd.addr_high = upper_32_bits(phys_addr);
44564454
sata_cmd.esgl = cpu_to_le32(1 << 31);

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ MODULE_PARM_DESC(link_rate, "Enable link rate.\n"
5656
" 8: Link rate 12.0G\n");
5757

5858
static struct scsi_transport_template *pm8001_stt;
59+
static int pm8001_init_ccb_tag(struct pm8001_hba_info *, struct Scsi_Host *, struct pci_dev *);
5960

6061
/*
6162
* chip info structure to identify chip key functionality as
@@ -302,9 +303,6 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
302303
INIT_LIST_HEAD(&pm8001_ha->port[i].list);
303304
}
304305

305-
pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
306-
if (!pm8001_ha->tags)
307-
goto err_out;
308306
/* MPI Memory region 1 for AAP Event Log for fw */
309307
pm8001_ha->memoryMap.region[AAP1].num_elements = 1;
310308
pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE;
@@ -416,29 +414,11 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
416414
pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES;
417415
pm8001_ha->devices[i].running_req = 0;
418416
}
419-
/* Memory region for ccb_info*/
420-
pm8001_ha->ccb_info = kzalloc(PM8001_MAX_CCB
421-
* sizeof(struct pm8001_ccb_info), GFP_KERNEL);
422-
if (!pm8001_ha->ccb_info) {
423-
rc = -ENOMEM;
424-
goto err_out_noccb;
425-
}
426-
for (i = 0; i < PM8001_MAX_CCB; i++) {
427-
pm8001_ha->ccb_info[i].ccb_dma_handle =
428-
virt_to_phys(pm8001_ha->ccb_info) +
429-
(i * sizeof(struct pm8001_ccb_info));
430-
pm8001_ha->ccb_info[i].task = NULL;
431-
pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
432-
pm8001_ha->ccb_info[i].device = NULL;
433-
++pm8001_ha->tags_num;
434-
}
435417
pm8001_ha->flags = PM8001F_INIT_TIME;
436418
/* Initialize tags */
437419
pm8001_tag_init(pm8001_ha);
438420
return 0;
439421

440-
err_out_noccb:
441-
kfree(pm8001_ha->devices);
442422
err_out_shost:
443423
scsi_remove_host(pm8001_ha->shost);
444424
err_out_nodev:
@@ -1133,6 +1113,10 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
11331113
goto err_out_ha_free;
11341114
}
11351115

1116+
rc = pm8001_init_ccb_tag(pm8001_ha, shost, pdev);
1117+
if (rc)
1118+
goto err_out_enable;
1119+
11361120
rc = scsi_add_host(shost, &pdev->dev);
11371121
if (rc)
11381122
goto err_out_ha_free;
@@ -1178,6 +1162,60 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
11781162
return rc;
11791163
}
11801164

1165+
/*
1166+
* pm8001_init_ccb_tag - allocate memory to CCB and tag.
1167+
* @pm8001_ha: our hba card information.
1168+
* @shost: scsi host which has been allocated outside.
1169+
*/
1170+
static int
1171+
pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost,
1172+
struct pci_dev *pdev)
1173+
{
1174+
int i = 0;
1175+
u32 max_out_io, ccb_count;
1176+
u32 can_queue;
1177+
1178+
max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io;
1179+
ccb_count = min_t(int, PM8001_MAX_CCB, max_out_io);
1180+
1181+
/* Update to the scsi host*/
1182+
can_queue = ccb_count - PM8001_RESERVE_SLOT;
1183+
shost->can_queue = can_queue;
1184+
1185+
pm8001_ha->tags = kzalloc(ccb_count, GFP_KERNEL);
1186+
if (!pm8001_ha->tags)
1187+
goto err_out;
1188+
1189+
/* Memory region for ccb_info*/
1190+
pm8001_ha->ccb_info = (struct pm8001_ccb_info *)
1191+
kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL);
1192+
if (!pm8001_ha->ccb_info) {
1193+
PM8001_FAIL_DBG(pm8001_ha, pm8001_printk
1194+
("Unable to allocate memory for ccb\n"));
1195+
goto err_out_noccb;
1196+
}
1197+
for (i = 0; i < ccb_count; i++) {
1198+
pm8001_ha->ccb_info[i].buf_prd = pci_alloc_consistent(pdev,
1199+
sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG,
1200+
&pm8001_ha->ccb_info[i].ccb_dma_handle);
1201+
if (!pm8001_ha->ccb_info[i].buf_prd) {
1202+
PM8001_FAIL_DBG(pm8001_ha, pm8001_printk
1203+
("pm80xx: ccb prd memory allocation error\n"));
1204+
goto err_out;
1205+
}
1206+
pm8001_ha->ccb_info[i].task = NULL;
1207+
pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
1208+
pm8001_ha->ccb_info[i].device = NULL;
1209+
++pm8001_ha->tags_num;
1210+
}
1211+
return 0;
1212+
1213+
err_out_noccb:
1214+
kfree(pm8001_ha->devices);
1215+
err_out:
1216+
return -ENOMEM;
1217+
}
1218+
11811219
static void pm8001_pci_remove(struct pci_dev *pdev)
11821220
{
11831221
struct sas_ha_struct *sha = pci_get_drvdata(pdev);

drivers/scsi/pm8001/pm8001_sas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ struct pm8001_ccb_info {
315315
u32 ccb_tag;
316316
dma_addr_t ccb_dma_handle;
317317
struct pm8001_device *device;
318-
struct pm8001_prd buf_prd[PM8001_MAX_DMA_SG];
318+
struct pm8001_prd *buf_prd;
319319
struct fw_control_ex *fw_control_context;
320320
u8 open_retry;
321321
};

drivers/scsi/pm8001/pm80xx_hwi.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4483,8 +4483,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
44834483
if (task->num_scatter > 1) {
44844484
pm8001_chip_make_sg(task->scatter,
44854485
ccb->n_elem, ccb->buf_prd);
4486-
phys_addr = ccb->ccb_dma_handle +
4487-
offsetof(struct pm8001_ccb_info, buf_prd[0]);
4486+
phys_addr = ccb->ccb_dma_handle;
44884487
ssp_cmd.enc_addr_low =
44894488
cpu_to_le32(lower_32_bits(phys_addr));
44904489
ssp_cmd.enc_addr_high =
@@ -4513,9 +4512,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
45134512
end_addr_high, end_addr_low));
45144513
pm8001_chip_make_sg(task->scatter, 1,
45154514
ccb->buf_prd);
4516-
phys_addr = ccb->ccb_dma_handle +
4517-
offsetof(struct pm8001_ccb_info,
4518-
buf_prd[0]);
4515+
phys_addr = ccb->ccb_dma_handle;
45194516
ssp_cmd.enc_addr_low =
45204517
cpu_to_le32(lower_32_bits(phys_addr));
45214518
ssp_cmd.enc_addr_high =
@@ -4543,8 +4540,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
45434540
if (task->num_scatter > 1) {
45444541
pm8001_chip_make_sg(task->scatter, ccb->n_elem,
45454542
ccb->buf_prd);
4546-
phys_addr = ccb->ccb_dma_handle +
4547-
offsetof(struct pm8001_ccb_info, buf_prd[0]);
4543+
phys_addr = ccb->ccb_dma_handle;
45484544
ssp_cmd.addr_low =
45494545
cpu_to_le32(lower_32_bits(phys_addr));
45504546
ssp_cmd.addr_high =
@@ -4572,9 +4568,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
45724568
end_addr_high, end_addr_low));
45734569
pm8001_chip_make_sg(task->scatter, 1,
45744570
ccb->buf_prd);
4575-
phys_addr = ccb->ccb_dma_handle +
4576-
offsetof(struct pm8001_ccb_info,
4577-
buf_prd[0]);
4571+
phys_addr = ccb->ccb_dma_handle;
45784572
ssp_cmd.addr_low =
45794573
cpu_to_le32(lower_32_bits(phys_addr));
45804574
ssp_cmd.addr_high =
@@ -4666,8 +4660,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
46664660
if (task->num_scatter > 1) {
46674661
pm8001_chip_make_sg(task->scatter,
46684662
ccb->n_elem, ccb->buf_prd);
4669-
phys_addr = ccb->ccb_dma_handle +
4670-
offsetof(struct pm8001_ccb_info, buf_prd[0]);
4663+
phys_addr = ccb->ccb_dma_handle;
46714664
sata_cmd.enc_addr_low = lower_32_bits(phys_addr);
46724665
sata_cmd.enc_addr_high = upper_32_bits(phys_addr);
46734666
sata_cmd.enc_esgl = cpu_to_le32(1 << 31);
@@ -4692,9 +4685,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
46924685
end_addr_high, end_addr_low));
46934686
pm8001_chip_make_sg(task->scatter, 1,
46944687
ccb->buf_prd);
4695-
phys_addr = ccb->ccb_dma_handle +
4696-
offsetof(struct pm8001_ccb_info,
4697-
buf_prd[0]);
4688+
phys_addr = ccb->ccb_dma_handle;
46984689
sata_cmd.enc_addr_low =
46994690
lower_32_bits(phys_addr);
47004691
sata_cmd.enc_addr_high =
@@ -4732,8 +4723,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
47324723
if (task->num_scatter > 1) {
47334724
pm8001_chip_make_sg(task->scatter,
47344725
ccb->n_elem, ccb->buf_prd);
4735-
phys_addr = ccb->ccb_dma_handle +
4736-
offsetof(struct pm8001_ccb_info, buf_prd[0]);
4726+
phys_addr = ccb->ccb_dma_handle;
47374727
sata_cmd.addr_low = lower_32_bits(phys_addr);
47384728
sata_cmd.addr_high = upper_32_bits(phys_addr);
47394729
sata_cmd.esgl = cpu_to_le32(1 << 31);
@@ -4758,9 +4748,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
47584748
end_addr_high, end_addr_low));
47594749
pm8001_chip_make_sg(task->scatter, 1,
47604750
ccb->buf_prd);
4761-
phys_addr = ccb->ccb_dma_handle +
4762-
offsetof(struct pm8001_ccb_info,
4763-
buf_prd[0]);
4751+
phys_addr = ccb->ccb_dma_handle;
47644752
sata_cmd.addr_low =
47654753
lower_32_bits(phys_addr);
47664754
sata_cmd.addr_high =

0 commit comments

Comments
 (0)