Skip to content

Commit 98132d8

Browse files
John Garrymartinkpetersen
authored andcommitted
scsi: pm8001: Set up tags before using them
The current code is buggy in that the tags are set up after they are needed in pm80xx_chip_init() -> pm80xx_set_sas_protocol_timer_config(). The tag depth is earlier read in pm80xx_chip_init() -> read_main_config_table(). Add a post init callback to do the pm80xx work which needs to be done after reading the tags. I don't see a better way to do this. Link: https://lore.kernel.org/r/1654879602-33497-3-git-send-email-john.garry@huawei.com Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 35a7e9d commit 98132d8

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,10 @@ static int pm8001_chip_init(struct pm8001_hba_info *pm8001_ha)
699699
return 0;
700700
}
701701

702+
static void pm8001_chip_post_init(struct pm8001_hba_info *pm8001_ha)
703+
{
704+
}
705+
702706
static int mpi_uninit_check(struct pm8001_hba_info *pm8001_ha)
703707
{
704708
u32 max_wait_count;
@@ -4947,6 +4951,7 @@ pm8001_chip_sas_re_initialization(struct pm8001_hba_info *pm8001_ha)
49474951
const struct pm8001_dispatch pm8001_8001_dispatch = {
49484952
.name = "pmc8001",
49494953
.chip_init = pm8001_chip_init,
4954+
.chip_post_init = pm8001_chip_post_init,
49504955
.chip_soft_rst = pm8001_chip_soft_rst,
49514956
.chip_rst = pm8001_hw_chip_rst,
49524957
.chip_iounmap = pm8001_chip_iounmap,

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +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 *);
59+
static int pm8001_init_ccb_tag(struct pm8001_hba_info *);
6060

6161
/*
6262
* chip info structure to identify chip key functionality as
@@ -1119,10 +1119,12 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
11191119
goto err_out_ha_free;
11201120
}
11211121

1122-
rc = pm8001_init_ccb_tag(pm8001_ha, shost, pdev);
1122+
rc = pm8001_init_ccb_tag(pm8001_ha);
11231123
if (rc)
11241124
goto err_out_enable;
11251125

1126+
PM8001_CHIP_DISP->chip_post_init(pm8001_ha);
1127+
11261128
rc = scsi_add_host(shost, &pdev->dev);
11271129
if (rc)
11281130
goto err_out_ha_free;
@@ -1172,16 +1174,14 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
11721174
/**
11731175
* pm8001_init_ccb_tag - allocate memory to CCB and tag.
11741176
* @pm8001_ha: our hba card information.
1175-
* @shost: scsi host which has been allocated outside.
1176-
* @pdev: pci device.
11771177
*/
1178-
static int
1179-
pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost,
1180-
struct pci_dev *pdev)
1178+
static int pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha)
11811179
{
1182-
int i = 0;
1180+
struct Scsi_Host *shost = pm8001_ha->shost;
1181+
struct device *dev = pm8001_ha->dev;
11831182
u32 max_out_io, ccb_count;
11841183
u32 can_queue;
1184+
int i;
11851185

11861186
max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io;
11871187
ccb_count = min_t(int, PM8001_MAX_CCB, max_out_io);
@@ -1204,7 +1204,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost,
12041204
goto err_out_noccb;
12051205
}
12061206
for (i = 0; i < ccb_count; i++) {
1207-
pm8001_ha->ccb_info[i].buf_prd = dma_alloc_coherent(&pdev->dev,
1207+
pm8001_ha->ccb_info[i].buf_prd = dma_alloc_coherent(dev,
12081208
sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG,
12091209
&pm8001_ha->ccb_info[i].ccb_dma_handle,
12101210
GFP_KERNEL);

drivers/scsi/pm8001/pm8001_sas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ struct forensic_data {
172172
struct pm8001_dispatch {
173173
char *name;
174174
int (*chip_init)(struct pm8001_hba_info *pm8001_ha);
175+
void (*chip_post_init)(struct pm8001_hba_info *pm8001_ha);
175176
int (*chip_soft_rst)(struct pm8001_hba_info *pm8001_ha);
176177
void (*chip_rst)(struct pm8001_hba_info *pm8001_ha);
177178
int (*chip_ioremap)(struct pm8001_hba_info *pm8001_ha);

drivers/scsi/pm8001/pm80xx_hwi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,11 +1469,18 @@ static int pm80xx_chip_init(struct pm8001_hba_info *pm8001_ha)
14691469
} else
14701470
return -EBUSY;
14711471

1472+
return 0;
1473+
}
1474+
1475+
static void pm80xx_chip_post_init(struct pm8001_hba_info *pm8001_ha)
1476+
{
14721477
/* send SAS protocol timer configuration page to FW */
1473-
ret = pm80xx_set_sas_protocol_timer_config(pm8001_ha);
1478+
pm80xx_set_sas_protocol_timer_config(pm8001_ha);
14741479

14751480
/* Check for encryption */
14761481
if (pm8001_ha->chip->encrypt) {
1482+
int ret;
1483+
14771484
pm8001_dbg(pm8001_ha, INIT, "Checking for encryption\n");
14781485
ret = pm80xx_get_encrypt_info(pm8001_ha);
14791486
if (ret == -1) {
@@ -1485,7 +1492,6 @@ static int pm80xx_chip_init(struct pm8001_hba_info *pm8001_ha)
14851492
}
14861493
}
14871494
}
1488-
return 0;
14891495
}
14901496

14911497
static int mpi_uninit_check(struct pm8001_hba_info *pm8001_ha)
@@ -5007,6 +5013,7 @@ void pm8001_set_phy_profile_single(struct pm8001_hba_info *pm8001_ha,
50075013
const struct pm8001_dispatch pm8001_80xx_dispatch = {
50085014
.name = "pmc80xx",
50095015
.chip_init = pm80xx_chip_init,
5016+
.chip_post_init = pm80xx_chip_post_init,
50105017
.chip_soft_rst = pm80xx_chip_soft_rst,
50115018
.chip_rst = pm80xx_hw_chip_rst,
50125019
.chip_iounmap = pm8001_chip_iounmap,

0 commit comments

Comments
 (0)