Skip to content

Commit

Permalink
scsi: qla2xxx: Simplify the functions for dumping firmware
Browse files Browse the repository at this point in the history
Instead of passing an argument to the firmware dumping functions that tells
these functions whether or not to obtain the hardware lock, obtain that
lock before calling these functions. This patch fixes the following
recently introduced C=2 build error:

  CHECK   drivers/scsi/qla2xxx/qla_tmpl.c
drivers/scsi/qla2xxx/qla_tmpl.c:1133:1: error: Expected ; at end of statement
drivers/scsi/qla2xxx/qla_tmpl.c:1133:1: error: got }
drivers/scsi/qla2xxx/qla_tmpl.h:247:0: error: Expected } at end of function
drivers/scsi/qla2xxx/qla_tmpl.h:247:0: error: got end-of-input

Link: https://lore.kernel.org/r/20200518211712.11395-4-bvanassche@acm.org
Fixes: cbb01c2 ("scsi: qla2xxx: Fix MPI failure AEN (8200) handling")
Cc: Arun Easi <aeasi@marvell.com>
Cc: Nilesh Javali <njavali@marvell.com>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Bart Van Assche authored and Martin K. Petersen committed May 20, 2020
1 parent fbbc95a commit 8ae1787
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 156 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/qla2xxx/qla_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
* dump and reset the chip.
*/
if (ret) {
ha->isp_ops->fw_dump(vha, 0);
qla2xxx_dump_fw(vha);
set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
}
rval = -EINVAL;
Expand Down Expand Up @@ -896,7 +896,7 @@ qla2x00_process_loopback(struct bsg_job *bsg_job)
* doesn't work take FCoE dump and then
* reset the chip.
*/
ha->isp_ops->fw_dump(vha, 0);
qla2xxx_dump_fw(vha);
set_bit(ISP_ABORT_NEEDED,
&vha->dpc_flags);
}
Expand Down
153 changes: 39 additions & 114 deletions drivers/scsi/qla2xxx/qla_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,43 +716,45 @@ qla2xxx_dump_post_process(scsi_qla_host_t *vha, int rval)
}
}

void qla2xxx_dump_fw(scsi_qla_host_t *vha)
{
unsigned long flags;

spin_lock_irqsave(&vha->hw->hardware_lock, flags);
vha->hw->isp_ops->fw_dump(vha);
spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
}

/**
* qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
* @vha: HA context
* @hardware_locked: Called with the hardware_lock
*/
void
qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla2300_fw_dump(scsi_qla_host_t *vha)
{
int rval;
uint32_t cnt;
struct qla_hw_data *ha = vha->hw;
struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
uint16_t __iomem *dmp_reg;
unsigned long flags;
struct qla2300_fw_dump *fw;
void *nxt;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

flags = 0;

#ifndef __CHECKER__
if (!hardware_locked)
spin_lock_irqsave(&ha->hardware_lock, flags);
#endif
lockdep_assert_held(&ha->hardware_lock);

if (!ha->fw_dump) {
ql_log(ql_log_warn, vha, 0xd002,
"No buffer available for dump.\n");
goto qla2300_fw_dump_failed;
return;
}

if (ha->fw_dumped) {
ql_log(ql_log_warn, vha, 0xd003,
"Firmware has been previously dumped (%p) "
"-- ignoring request.\n",
ha->fw_dump);
goto qla2300_fw_dump_failed;
return;
}
fw = &ha->fw_dump->isp.isp23;
qla2xxx_prep_dump(ha, ha->fw_dump);
Expand Down Expand Up @@ -876,56 +878,39 @@ qla2300_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla2xxx_copy_queues(ha, nxt);

qla2xxx_dump_post_process(base_vha, rval);

qla2300_fw_dump_failed:
#ifndef __CHECKER__
if (!hardware_locked)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
#else
;
#endif
}

/**
* qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
* @vha: HA context
* @hardware_locked: Called with the hardware_lock
*/
void
qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla2100_fw_dump(scsi_qla_host_t *vha)
{
int rval;
uint32_t cnt, timer;
uint16_t risc_address;
uint16_t mb0, mb2;
uint16_t risc_address = 0;
uint16_t mb0 = 0, mb2 = 0;
struct qla_hw_data *ha = vha->hw;
struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
uint16_t __iomem *dmp_reg;
unsigned long flags;
struct qla2100_fw_dump *fw;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

risc_address = 0;
mb0 = mb2 = 0;
flags = 0;

#ifndef __CHECKER__
if (!hardware_locked)
spin_lock_irqsave(&ha->hardware_lock, flags);
#endif
lockdep_assert_held(&ha->hardware_lock);

if (!ha->fw_dump) {
ql_log(ql_log_warn, vha, 0xd004,
"No buffer available for dump.\n");
goto qla2100_fw_dump_failed;
return;
}

if (ha->fw_dumped) {
ql_log(ql_log_warn, vha, 0xd005,
"Firmware has been previously dumped (%p) "
"-- ignoring request.\n",
ha->fw_dump);
goto qla2100_fw_dump_failed;
return;
}
fw = &ha->fw_dump->isp.isp21;
qla2xxx_prep_dump(ha, ha->fw_dump);
Expand Down Expand Up @@ -1080,18 +1065,10 @@ qla2100_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]);

qla2xxx_dump_post_process(base_vha, rval);

qla2100_fw_dump_failed:
#ifndef __CHECKER__
if (!hardware_locked)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
#else
;
#endif
}

void
qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla24xx_fw_dump(scsi_qla_host_t *vha)
{
int rval;
uint32_t cnt;
Expand All @@ -1100,36 +1077,31 @@ qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
uint32_t __iomem *dmp_reg;
uint32_t *iter_reg;
uint16_t __iomem *mbx_reg;
unsigned long flags;
struct qla24xx_fw_dump *fw;
void *nxt;
void *nxt_chain;
uint32_t *last_chain = NULL;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

lockdep_assert_held(&ha->hardware_lock);

if (IS_P3P_TYPE(ha))
return;

flags = 0;
ha->fw_dump_cap_flags = 0;

#ifndef __CHECKER__
if (!hardware_locked)
spin_lock_irqsave(&ha->hardware_lock, flags);
#endif

if (!ha->fw_dump) {
ql_log(ql_log_warn, vha, 0xd006,
"No buffer available for dump.\n");
goto qla24xx_fw_dump_failed;
return;
}

if (ha->fw_dumped) {
ql_log(ql_log_warn, vha, 0xd007,
"Firmware has been previously dumped (%p) "
"-- ignoring request.\n",
ha->fw_dump);
goto qla24xx_fw_dump_failed;
return;
}
QLA_FW_STOPPED(ha);
fw = &ha->fw_dump->isp.isp24;
Expand Down Expand Up @@ -1339,18 +1311,10 @@ qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)

qla24xx_fw_dump_failed_0:
qla2xxx_dump_post_process(base_vha, rval);

qla24xx_fw_dump_failed:
#ifndef __CHECKER__
if (!hardware_locked)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
#else
;
#endif
}

void
qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla25xx_fw_dump(scsi_qla_host_t *vha)
{
int rval;
uint32_t cnt;
Expand All @@ -1359,32 +1323,27 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
uint32_t __iomem *dmp_reg;
uint32_t *iter_reg;
uint16_t __iomem *mbx_reg;
unsigned long flags;
struct qla25xx_fw_dump *fw;
void *nxt, *nxt_chain;
uint32_t *last_chain = NULL;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

flags = 0;
ha->fw_dump_cap_flags = 0;
lockdep_assert_held(&ha->hardware_lock);

#ifndef __CHECKER__
if (!hardware_locked)
spin_lock_irqsave(&ha->hardware_lock, flags);
#endif
ha->fw_dump_cap_flags = 0;

if (!ha->fw_dump) {
ql_log(ql_log_warn, vha, 0xd008,
"No buffer available for dump.\n");
goto qla25xx_fw_dump_failed;
return;
}

if (ha->fw_dumped) {
ql_log(ql_log_warn, vha, 0xd009,
"Firmware has been previously dumped (%p) "
"-- ignoring request.\n",
ha->fw_dump);
goto qla25xx_fw_dump_failed;
return;
}
QLA_FW_STOPPED(ha);
fw = &ha->fw_dump->isp.isp25;
Expand Down Expand Up @@ -1665,18 +1624,10 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)

qla25xx_fw_dump_failed_0:
qla2xxx_dump_post_process(base_vha, rval);

qla25xx_fw_dump_failed:
#ifndef __CHECKER__
if (!hardware_locked)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
#else
;
#endif
}

void
qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla81xx_fw_dump(scsi_qla_host_t *vha)
{
int rval;
uint32_t cnt;
Expand All @@ -1685,32 +1636,27 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
uint32_t __iomem *dmp_reg;
uint32_t *iter_reg;
uint16_t __iomem *mbx_reg;
unsigned long flags;
struct qla81xx_fw_dump *fw;
void *nxt, *nxt_chain;
uint32_t *last_chain = NULL;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

flags = 0;
ha->fw_dump_cap_flags = 0;
lockdep_assert_held(&ha->hardware_lock);

#ifndef __CHECKER__
if (!hardware_locked)
spin_lock_irqsave(&ha->hardware_lock, flags);
#endif
ha->fw_dump_cap_flags = 0;

if (!ha->fw_dump) {
ql_log(ql_log_warn, vha, 0xd00a,
"No buffer available for dump.\n");
goto qla81xx_fw_dump_failed;
return;
}

if (ha->fw_dumped) {
ql_log(ql_log_warn, vha, 0xd00b,
"Firmware has been previously dumped (%p) "
"-- ignoring request.\n",
ha->fw_dump);
goto qla81xx_fw_dump_failed;
return;
}
fw = &ha->fw_dump->isp.isp81;
qla2xxx_prep_dump(ha, ha->fw_dump);
Expand Down Expand Up @@ -1993,18 +1939,10 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)

qla81xx_fw_dump_failed_0:
qla2xxx_dump_post_process(base_vha, rval);

qla81xx_fw_dump_failed:
#ifndef __CHECKER__
if (!hardware_locked)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
#else
;
#endif
}

void
qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
qla83xx_fw_dump(scsi_qla_host_t *vha)
{
int rval;
uint32_t cnt;
Expand All @@ -2013,31 +1951,26 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
uint32_t __iomem *dmp_reg;
uint32_t *iter_reg;
uint16_t __iomem *mbx_reg;
unsigned long flags;
struct qla83xx_fw_dump *fw;
void *nxt, *nxt_chain;
uint32_t *last_chain = NULL;
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);

flags = 0;
ha->fw_dump_cap_flags = 0;
lockdep_assert_held(&ha->hardware_lock);

#ifndef __CHECKER__
if (!hardware_locked)
spin_lock_irqsave(&ha->hardware_lock, flags);
#endif
ha->fw_dump_cap_flags = 0;

if (!ha->fw_dump) {
ql_log(ql_log_warn, vha, 0xd00c,
"No buffer available for dump!!!\n");
goto qla83xx_fw_dump_failed;
return;
}

if (ha->fw_dumped) {
ql_log(ql_log_warn, vha, 0xd00d,
"Firmware has been previously dumped (%p) -- ignoring "
"request...\n", ha->fw_dump);
goto qla83xx_fw_dump_failed;
return;
}
QLA_FW_STOPPED(ha);
fw = &ha->fw_dump->isp.isp83;
Expand Down Expand Up @@ -2507,14 +2440,6 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)

qla83xx_fw_dump_failed_0:
qla2xxx_dump_post_process(base_vha, rval);

qla83xx_fw_dump_failed:
#ifndef __CHECKER__
if (!hardware_locked)
spin_unlock_irqrestore(&ha->hardware_lock, flags);
#else
;
#endif
}

/****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,7 @@ struct isp_operations {
int (*write_nvram)(struct scsi_qla_host *, void *, uint32_t,
uint32_t);

void (*fw_dump) (struct scsi_qla_host *, int);
void (*fw_dump)(struct scsi_qla_host *vha);
void (*mpi_fw_dump)(struct scsi_qla_host *, int);

int (*beacon_on) (struct scsi_qla_host *);
Expand Down
Loading

0 comments on commit 8ae1787

Please sign in to comment.