small pm80xx cleanups and fixes
Subsystems (2)
cover small pm80xx cleanups and fixes
Igor Pylypiv (4):
scsi: pm80xx: Apply byte mask for phy id in mpi_phy_start_resp()
scsi: pm80xx: Do not check the address-of value for NULL
scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd()
scsi: pm80xx: Use bitmap_zalloc() for tags bitmap allocation
drivers/scsi/pm8001/pm8001_hwi.c | 28 +++++++--------------------- drivers/scsi/pm8001/pm8001_init.c | 4 ++-- drivers/scsi/pm8001/pm80xx_hwi.c | 31 +++++++++---------------------- 3 files changed, 18 insertions(+), 45 deletions(-)
Signature · 1 line
2.33.1.1089.g2158813163f-goog
PATCH 1/4 scsi: pm80xx: Apply byte mask for phy id in mpi_phy_start_resp()
Phy id is located in the least significant byte of the 4-byte field. mpi_phy_stop_resp() already applies such mask.
--- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/pm8001/pm80xx_hwi.c +1 -1
@@ -3481,7 +3481,7 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)u32 status =le32_to_cpu (pPayload->status);u32 phy_id = -le32_to_cpu (pPayload->phyid); +le32_to_cpu (pPayload->phyid) &0xFF ;struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; pm8001_dbg(pm8001_ha, INIT,
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 1/4] scsi: pm80xx: Apply byte mask for phy id in mpi_phy_start_resp()
Quoted 6 lines · Igor Pylypiv
Phy id is located in the least significant byte of the 4-byte field.
mpi_phy_stop_resp()already applies such mask.Reviewed-by Vishakha Channapattan <[email protected]>Signed-off-by Igor Pylypiv <[email protected]>
Thanks
Quoted 20 lines
--- drivers/scsi/pm8001/pm80xx_hwi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/pm8001/pm80xx_hwi.c +1
-2@@ -3481,7 +3481,7 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)u32 status =le32_to_cpu (pPayload->status);u32 phy_id = -le32_to_cpu (pPayload->phyid); +le32_to_cpu (pPayload->phyid) &0xFF ;struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; pm8001_dbg(pm8001_ha, INIT, --2.33.1.1089.g2158813163f-goog
PATCH 2/4 scsi: pm80xx: Do not check the address-of value for NULL
In reply to Igor PylypivAddress-of operator cannot return NULL.
--- drivers/scsi/pm8001/pm8001_hwi.c | 24 ++++-------------------- drivers/scsi/pm8001/pm80xx_hwi.c | 29 ++++++++--------------------- 2 files changed, 12 insertions(+), 41 deletions(-)
drivers/scsi/pm8001/pm8001_hwi.c +4 -20
@@ -2304,21 +2304,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) psataPayload = (struct sata_completion_resp *)(piomb +4 ); status =le32_to_cpu (psataPayload->status); + param =le32_to_cpu (psataPayload->param); tag =le32_to_cpu (psataPayload->tag);if (!tag) {pm8001_dbg (pm8001_ha,FAIL ,"tag null\n" );return ; } + ccb = &pm8001_ha->ccb_info[tag]; - param =le32_to_cpu (psataPayload->param); -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"ccb null\n" ); -return ; - } + t = ccb->task; + pm8001_dev = ccb->device;if (t) {if (t->dev && (t->dev->lldd_dev))
@@ -2335,10 +2331,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) } ts = &t->task_status; -if (!ts) { -pm8001_dbg (pm8001_ha,FAIL ,"ts null\n" ); -return ; - }if (status) pm8001_dbg(pm8001_ha, IOERR,
@@ -2695,14 +2687,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)u32 dev_id =le32_to_cpu (psataPayload->device_id);unsigned long flags; - ccb = &pm8001_ha->ccb_info[tag]; - -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"No CCB !!!. returning\n" ); - }if (event)pm8001_dbg (pm8001_ha,FAIL ,"SATA EVENT 0x%x\n" , event);
drivers/scsi/pm8001/pm80xx_hwi.c +8 -21
@@ -2399,21 +2399,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) psataPayload = (struct sata_completion_resp *)(piomb +4 ); status =le32_to_cpu (psataPayload->status); + param =le32_to_cpu (psataPayload->param); tag =le32_to_cpu (psataPayload->tag);if (!tag) {pm8001_dbg (pm8001_ha,FAIL ,"tag null\n" );return ; } + ccb = &pm8001_ha->ccb_info[tag]; - param =le32_to_cpu (psataPayload->param); -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"ccb null\n" ); -return ; - } + t = ccb->task; + pm8001_dev = ccb->device;if (t) {if (t->dev && (t->dev->lldd_dev))
@@ -2430,10 +2426,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) } ts = &t->task_status; -if (!ts) { -pm8001_dbg (pm8001_ha,FAIL ,"ts null\n" ); -return ; - }if (status !=IO_SUCCESS ) { pm8001_dbg(pm8001_ha, FAIL,
@@ -2804,15 +2796,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)u32 dev_id =le32_to_cpu (psataPayload->device_id);unsigned long flags; - ccb = &pm8001_ha->ccb_info[tag]; - -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"No CCB !!!. returning\n" ); -return ; - }if (event)pm8001_dbg (pm8001_ha,FAIL ,"SATA EVENT 0x%x\n" , event);
@@ -2826,6 +2809,10 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)return ; } + ccb = &pm8001_ha->ccb_info[tag]; + t = ccb->task; + pm8001_dev = ccb->device; +if (unlikely (!t || !t->lldd_task || !t->dev)) {pm8001_dbg (pm8001_ha,FAIL ,"task or dev null\n" );return ;
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 2/4] scsi: pm80xx: Do not check the address-of value for NULL
Quoted 5 lines · Igor Pylypiv
Address-of operator cannot return NULL.
Reviewed-by Vishakha Channapattan <[email protected]>Signed-off-by Igor Pylypiv <[email protected]>
Thanks
Quoted 132 lines
--- drivers/scsi/pm8001/pm8001_hwi.c | 24 ++++-------------------- drivers/scsi/pm8001/pm80xx_hwi.c | 29 ++++++++--------------------- 2 files changed, 12 insertions(+), 41 deletions(-)drivers/scsi/pm8001/pm8001_hwi.c +4
-20@@ -2304,21 +2304,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) psataPayload = (struct sata_completion_resp *)(piomb +4 ); status =le32_to_cpu (psataPayload->status); + param =le32_to_cpu (psataPayload->param); tag =le32_to_cpu (psataPayload->tag);if (!tag) {pm8001_dbg (pm8001_ha,FAIL ,"tag null\n" );return ; } + ccb = &pm8001_ha->ccb_info[tag]; - param =le32_to_cpu (psataPayload->param); -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"ccb null\n" ); -return ; - } + t = ccb->task; + pm8001_dev = ccb->device;if (t) {if (t->dev && (t->dev->lldd_dev))@@ -2335,10 +2331,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) } ts = &t->task_status; -if (!ts) { -pm8001_dbg (pm8001_ha,FAIL ,"ts null\n" ); -return ; - }if (status) pm8001_dbg(pm8001_ha, IOERR,@@ -2695,14 +2687,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)u32 dev_id =le32_to_cpu (psataPayload->device_id);unsigned long flags; - ccb = &pm8001_ha->ccb_info[tag]; - -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"No CCB !!!. returning\n" ); - }if (event)pm8001_dbg (pm8001_ha,FAIL ,"SATA EVENT 0x%x\n" , event);drivers/scsi/pm8001/pm80xx_hwi.c +8
-22@@ -2399,21 +2399,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) psataPayload = (struct sata_completion_resp *)(piomb +4 ); status =le32_to_cpu (psataPayload->status); + param =le32_to_cpu (psataPayload->param); tag =le32_to_cpu (psataPayload->tag);if (!tag) {pm8001_dbg (pm8001_ha,FAIL ,"tag null\n" );return ; } + ccb = &pm8001_ha->ccb_info[tag]; - param =le32_to_cpu (psataPayload->param); -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"ccb null\n" ); -return ; - } + t = ccb->task; + pm8001_dev = ccb->device;if (t) {if (t->dev && (t->dev->lldd_dev))@@ -2430,10 +2426,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) } ts = &t->task_status; -if (!ts) { -pm8001_dbg (pm8001_ha,FAIL ,"ts null\n" ); -return ; - }if (status !=IO_SUCCESS ) { pm8001_dbg(pm8001_ha, FAIL,@@ -2804,15 +2796,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)u32 dev_id =le32_to_cpu (psataPayload->device_id);unsigned long flags; - ccb = &pm8001_ha->ccb_info[tag]; - -if (ccb) { - t = ccb->task; - pm8001_dev = ccb->device; - }else { -pm8001_dbg (pm8001_ha,FAIL ,"No CCB !!!. returning\n" ); -return ; - }if (event)pm8001_dbg (pm8001_ha,FAIL ,"SATA EVENT 0x%x\n" , event);@@ -2826,6 +2809,10 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)return ; } + ccb = &pm8001_ha->ccb_info[tag]; + t = ccb->task; + pm8001_dev = ccb->device; +if (unlikely (!t || !t->lldd_task || !t->dev)) {pm8001_dbg (pm8001_ha,FAIL ,"task or dev null\n" );return ; --2.33.1.1089.g2158813163f-goog
PATCH 3/4 scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd()
In reply to Igor PylypivStarting from commit 05c6c029a44d9 ("scsi: pm80xx: Increase number of supported queues") driver initializes only max_q_num queues. Do not use an invalid queue if the WARN_ON condition is true.
--- drivers/scsi/pm8001/pm8001_hwi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/pm8001/pm8001_hwi.c +3 -1
@@ -1325,7 +1325,9 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,int q_index = circularQ - pm8001_ha->inbnd_q_tbl;int rv; -WARN_ON (q_index >=PM8001_MAX_INB_NUM ); +if (WARN_ON (q_index >= pm8001_ha->max_q_num)) +return -EINVAL ; +spin_lock_irqsave (&circularQ->iq_lock, flags); rv =pm8001_mpi_msg_free_get (circularQ, pm8001_ha->iomb_size, &pMessage);
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 3/4] scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd()
Quoted 8 lines · Igor Pylypiv
Starting from commit
05c6c029a44d9("scsi: pm80xx: Increase number of supported queues") driver initializes onlymax_q_numqueues. Do not use an invalid queue if theWARN_ONcondition is true.Fixes 7640e1eb8c5de ("scsi: pm80xx: Make mpi_build_cmd locking consistent")Reviewed-by Vishakha Channapattan <[email protected]>Signed-off-by Igor Pylypiv <[email protected]>
Thanks
Quoted 22 lines
--- drivers/scsi/pm8001/pm8001_hwi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/scsi/pm8001/pm8001_hwi.c +3
-2@@ -1325,7 +1325,9 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,int q_index = circularQ - pm8001_ha->inbnd_q_tbl;int rv; -WARN_ON (q_index >=PM8001_MAX_INB_NUM ); +if (WARN_ON (q_index >= pm8001_ha->max_q_num)) +return -EINVAL ; +spin_lock_irqsave (&circularQ->iq_lock, flags); rv =pm8001_mpi_msg_free_get (circularQ, pm8001_ha->iomb_size, &pMessage); --2.33.1.1089.g2158813163f-goog
PATCH 4/4 scsi: pm80xx: Use bitmap_zalloc() for tags bitmap allocation
In reply to Igor PylypivWe used to allocate X bytes while we only need X bits.
--- drivers/scsi/pm8001/pm8001_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +2 -2
@@ -178,7 +178,7 @@ static void pm8001_free(struct pm8001_hba_info *pm8001_ha) }PM8001_CHIP_DISP ->chip_iounmap (pm8001_ha);flush_workqueue (pm8001_wq); -kfree (pm8001_ha->tags); +bitmap_free (pm8001_ha->tags);kfree (pm8001_ha); }
@@ -1193,7 +1193,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, can_queue = ccb_count -PM8001_RESERVE_SLOT ; shost->can_queue = can_queue; - pm8001_ha->tags =kzalloc (ccb_count,GFP_KERNEL ); + pm8001_ha->tags =bitmap_zalloc (ccb_count,GFP_KERNEL );if (!pm8001_ha->tags) goto err_out;
Signature · 1 line
2.33.1.1089.g2158813163f-goog
Re: [PATCH 4/4] scsi: pm80xx: Use bitmap_zalloc() for tags bitmap allocation
Quoted 5 lines · Igor Pylypiv
We used to allocate X bytes while we only need X bits.
Reviewed-by Vishakha Channapattan <[email protected]>Signed-off-by Igor Pylypiv <[email protected]>
Thanks
Quoted 29 lines
--- drivers/scsi/pm8001/pm8001_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/pm8001/pm8001_init.c +2
-3@@ -178,7 +178,7 @@ static void pm8001_free(struct pm8001_hba_info *pm8001_ha) }PM8001_CHIP_DISP ->chip_iounmap (pm8001_ha);flush_workqueue (pm8001_wq); -kfree (pm8001_ha->tags); +bitmap_free (pm8001_ha->tags);kfree (pm8001_ha); }@@ -1193,7 +1193,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, can_queue = ccb_count -PM8001_RESERVE_SLOT ; shost->can_queue = can_queue; - pm8001_ha->tags =kzalloc (ccb_count,GFP_KERNEL ); + pm8001_ha->tags =bitmap_zalloc (ccb_count,GFP_KERNEL );if (!pm8001_ha->tags) goto err_out; --2.33.1.1089.g2158813163f-goog
Martin K. Petersen
AppliedIgor,
Quoted 5 lines
Igor Pylypiv (4):
scsi: pm80xx: Apply byte mask for phy id inmpi_phy_start_resp()
scsi: pm80xx: Do not check the address-of value for NULL
scsi: pm80xx: UpdateWARN_ONcheck inpm8001_mpi_build_cmd()
scsi: pm80xx: Usebitmap_zalloc()for tags bitmap allocation
Applied to 5.17/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 6 lines · Igor Pylypiv
Igor Pylypiv (4):
scsi: pm80xx: Apply byte mask for phy id inmpi_phy_start_resp()
scsi: pm80xx: Do not check the address-of value for NULL
scsi: pm80xx: UpdateWARN_ONcheck inpm8001_mpi_build_cmd()
scsi: pm80xx: Usebitmap_zalloc()for tags bitmap allocation
Quoted 6 lines
drivers/scsi/pm8001/pm8001_hwi.c| 28 +++++++---------------------drivers/scsi/pm8001/pm8001_init.c | 4 ++-- drivers/scsi/pm8001/pm80xx_hwi.c | 31 +++++++++---------------------- 3 files changed, 18 insertions(+), 45 deletions(-)[...]
Applied to 5.17/scsi-queue, thanks!
[1/4] scsi: pm80xx: Apply byte mask for phy id in mpi_phy_start_resp()
https://git.kernel.org/mkp/scsi/c/744798fcd2b3 [2/4] scsi: pm80xx: Do not check the address-of value for NULL https://git.kernel.org/mkp/scsi/c/60de1a67d66d [3/4] scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd() https://git.kernel.org/mkp/scsi/c/606c54ae975a [4/4] scsi: pm80xx: Use bitmap_zalloc() for tags bitmap allocation https://git.kernel.org/mkp/scsi/c/853615582d6f
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering