Skip to contentSkip to conversation

qla2xxx patches for kernel v5.9

PATCH Applied Bart Van Assche 4 participants 14 messages Jun 29, 2020 – Jul 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover qla2xxx patches for kernel v5.9

Hi Martin,

This patch series includes cleanup patches and also patches that address complaints from several static source code analyzers. Please consider these patches for kernel v5.9.

Thanks,

Bart.

Changes compared to v1:
- Rewrote patch "Fix a Coverity complaint in qla2100_fw_dump()"

Bart Van Assche (9):
qla2xxx: Check the size of struct fcp_hdr at compile time
qla2xxx: Remove the __packed annotation from struct fcp_hdr and
fcp_hdr_le
qla2xxx: Make qla82xx_flash_wait_write_finish() easier to read
qla2xxx: Initialize 'n' before using it
qla2xxx: Remove a superfluous cast
qla2xxx: Make __qla2x00_alloc_iocbs() initialize 32 bits of
request_t.handle
qla2xxx: Fix a Coverity complaint in qla2100_fw_dump()
qla2xxx: Make qla2x00_restart_isp() easier to read
qla2xxx: Introduce a function for computing the debug message prefix

 drivers/scsi/qla2xxx/qla_bsg.c     |  3 +-
 drivers/scsi/qla2xxx/qla_dbg.c     | 98 ++++++++++--------------------
 drivers/scsi/qla2xxx/qla_dbg.h     |  1 +
 drivers/scsi/qla2xxx/qla_init.c    | 39 ++++++------
 drivers/scsi/qla2xxx/qla_iocb.c    |  4 +-
 drivers/scsi/qla2xxx/qla_nx.c      | 20 +++---
 drivers/scsi/qla2xxx/qla_target.h  |  4 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  1 +
 8 files changed, 70 insertions(+), 100 deletions(-)
#1 lore raw

PATCH v2 1/9 qla2xxx: Check the size of struct fcp_hdr at compile time

Since struct fcp_hdr is used to exchange data with the firmware, check its size at compile time.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +1 -0
index 188aa5f02c01..f7e9b5bc0b26 100644
@@ -1971,6 +1971,7 @@ static int __init tcm_qla2xxx_init(void)
 	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
 	BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64);
 	BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64);
+	BUILD_BUG_ON(sizeof(struct fcp_hdr) != 24);
 	BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24);
 	BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64);
 
#2 lore raw

PATCH v2 2/9 qla2xxx: Remove the __packed annotation from struct fcp_hdr and fcp_hdr_le

In reply to Bart Van Assche

Remove the __packed annotation from struct fcp_hdr* because that annotation is not necessary for these data structures.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_target.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_target.h +2 -2
index 010f12523b2a..1cff7c69d448 100644
@@ -258,7 +258,7 @@ struct fcp_hdr {
 	__be16   ox_id;
 	uint16_t rx_id;
 	__le32	parameter;
-} __packed;
+};
 
 struct fcp_hdr_le {
 	le_id_t  d_id;
@@ -273,7 +273,7 @@ struct fcp_hdr_le {
 	__le16	rx_id;
 	__le16	ox_id;
 	__le32	parameter;
-} __packed;
+};
 
 #define F_CTL_EXCH_CONTEXT_RESP	BIT_23
 #define F_CTL_SEQ_CONTEXT_RESIP	BIT_22
#3 lore raw

PATCH v2 3/9 qla2xxx: Make qla82xx_flash_wait_write_finish() easier to read

In reply to Bart Van Assche

Return early instead of having a single return statement at the end of this function. This patch fixes the following sparse warning:

qla_nx.c:1018: qla82xx_flash_wait_write_finish() error: uninitialized symbol 'val'.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_nx.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/scsi/qla2xxx/qla_nx.c +7 -12
index 0baf55b7e88f..ff365b434a02 100644
@@ -966,26 +966,21 @@ qla82xx_read_status_reg(struct qla_hw_data *ha, uint32_t *val)
 static int
 qla82xx_flash_wait_write_finish(struct qla_hw_data *ha)
 {
-	long timeout = 0;
-	uint32_t done = 1 ;
 	uint32_t val;
-	int ret = 0;
+	int i, ret;
 	scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
 
 	qla82xx_wr_32(ha, QLA82XX_ROMUSB_ROM_ABYTE_CNT, 0);
-	while ((done != 0) && (ret == 0)) {
+	for (i = 0; i < 50000; i++) {
 		ret = qla82xx_read_status_reg(ha, &val);
-		done = val & 1;
-		timeout++;
+		if (ret < 0 || (val & 1) == 0)
+			return ret;
 		udelay(10);
 		cond_resched();
-		if (timeout >= 50000) {
-			ql_log(ql_log_warn, vha, 0xb00d,
-			    "Timeout reached waiting for write finish.\n");
-			return -1;
-		}
 	}
-	return ret;
+	ql_log(ql_log_warn, vha, 0xb00d,
+	       "Timeout reached waiting for write finish.\n");
+	return -1;
 }
 
 static int
#4 lore raw

PATCH v2 4/9 qla2xxx: Initialize 'n' before using it

In reply to Bart Van Assche

The following code:

	qla82xx_rom_fast_read(ha, 0, &n)

only initializes 'n' if it succeeds. Since 'n' may be reported in a debug message even if no ROM reads succeeded, initialize 'n' to zero.

This patch fixes the following sparse warning:

qla_nx.c:1218: qla82xx_pinit_from_rom() error: uninitialized symbol 'n'.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_nx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_nx.c +1 -0
index ff365b434a02..71273eb634d3 100644
@@ -1167,6 +1167,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
 	 * Offset 4: Offset and number of addr/value pairs
 	 * that present in CRB initialize sequence
 	 */
+	n = 0;
 	if (qla82xx_rom_fast_read(ha, 0, &n) != 0 || n != 0xcafecafeUL ||
 	    qla82xx_rom_fast_read(ha, 4, &n) != 0) {
 		ql_log(ql_log_fatal, vha, 0x006e,
#5 lore raw

PATCH v2 5/9 qla2xxx: Remove a superfluous cast

In reply to Bart Van Assche

Remove an unnecessary cast because it prevents the compiler to perform type checking.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_bsg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +1 -2
index 88c0338a2ec7..67efde1d4b8e 100644
@@ -223,8 +223,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 
 		/* validate fcp priority data */
 
-		if (!qla24xx_fcp_prio_cfg_valid(vha,
-		    (struct qla_fcp_prio_cfg *) ha->fcp_prio_cfg, 1)) {
+		if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 1)) {
 			bsg_reply->result = (DID_ERROR << 16);
 			ret = -EINVAL;
 			/* If buffer was invalidatic int
Reviewed-by on v2 5/9
#6 lore raw

Re: [PATCH v2 5/9] qla2xxx: Remove a superfluous cast

Quoted 30 lines · Bart Van Assche

Remove an unnecessary cast because it prevents the compiler to perform type checking.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>

---
drivers/scsi/qla2xxx/qla_bsg.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +1 -2
index 88c0338a2ec7..67efde1d4b8e 100644
@@ -223,8 +223,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct bsg_job *bsg_job)
 
 		/* validate fcp priority data */
 
-		if (!qla24xx_fcp_prio_cfg_valid(vha,
-		    (struct qla_fcp_prio_cfg *) ha->fcp_prio_cfg, 1)) {
+		if (!qla24xx_fcp_prio_cfg_valid(vha, ha->fcp_prio_cfg, 1)) {
 			bsg_reply->result = (DID_ERROR << 16);
 			ret = -EINVAL;
 			/* If buffer was invalidatic int
#7 lore raw

PATCH v2 6/9 qla2xxx: Make __qla2x00_alloc_iocbs() initialize 32 bits of request_t.handle

In reply to Bart Van Assche

The request_t 'handle' member is 32-bits wide, hence use wrt_reg_dword(). Change the cast in the wrt_reg_byte() call to make it clear that a regular pointer is casted to an __iomem pointer.

Note: 'pkt' points to I/O memory for the qlafx00 adapter family and to coherent memory for all other adapter families.

This patch fixes the following Coverity complaint:

CID 358864 (#1 of 1): Reliance on integer endianness (INCOMPATIBLE_CAST)
incompatible_cast: Pointer &pkt->handle points to an object whose effective type is unsigned int (32 bits, unsigned) but is dereferenced as a narrower unsigned short (16 bits, unsigned). This may lead to unexpected results depending on machine endianness.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
Fixes 8ae6d9c7eb10 ("[SCSI] qla2xxx: Enhancements to support ISPFx00.")
---
 drivers/scsi/qla2xxx/qla_iocb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +2 -2
index 1d3c58c5f0e2..e3d2dea0b057 100644
@@ -2305,8 +2305,8 @@ __qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp)
 	pkt = req->ring_ptr;
 	memset(pkt, 0, REQUEST_ENTRY_SIZE);
 	if (IS_QLAFX00(ha)) {
-		wrt_reg_byte((void __iomem *)&pkt->entry_count, req_cnt);
-		wrt_reg_word((void __iomem *)&pkt->handle, handle);
+		wrt_reg_byte((u8 __force __iomem *)&pkt->entry_count, req_cnt);
+		wrt_reg_dword((__le32 __force __iomem *)&pkt->handle, handle);
 	} else {
 		pkt->entry_count = req_cnt;
 		pkt->handle = handle;
#8 lore raw

PATCH v2 7/9 qla2xxx: Fix a Coverity complaint in qla2100_fw_dump()

In reply to Bart Van Assche

'cnt' can exceed the size of the risc_ram[] array. Prevent that Coverity complains by rewriting an address calculation expression. This patch fixes the following Coverity complaint:

CID 337803 (#1 of 1): Out-of-bounds read (OVERRUN)
109. overrun-local: Overrunning array of 122880 bytes at byte offset 122880 by dereferencing pointer &fw->risc_ram[cnt].

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_dbg.c | 2 +-
 drivers/scsi/qla2xxx/qla_dbg.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_dbg.c +1 -1
index 19005710f7f6..41493bd53fc0 100644
@@ -1063,7 +1063,7 @@ qla2100_fw_dump(scsi_qla_host_t *vha)
 	}
 
 	if (rval == QLA_SUCCESS)
-		qla2xxx_copy_queues(ha, &fw->risc_ram[cnt]);
+		qla2xxx_copy_queues(ha, &fw->queue_dump[0]);
 
 	qla2xxx_dump_post_process(base_vha, rval);
 }
drivers/scsi/qla2xxx/qla_dbg.h +1 -0
index 54ed020e6f75..91eb6901815c 100644
@@ -53,6 +53,7 @@ struct qla2100_fw_dump {
 	__be16 fpm_b0_reg[64];
 	__be16 fpm_b1_reg[64];
 	__be16 risc_ram[0xf000];
+	u8	queue_dump[];
 };
 
 struct qla24xx_fw_dump {
#9 lore raw

PATCH v2 8/9 qla2xxx: Make qla2x00_restart_isp() easier to read

In reply to Bart Van Assche

Instead of using complicated control flow to only have one return statement at the end of qla2x00_restart_isp(), return an error status as soon as it is known that this function will fail.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_init.c | 39 +++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 17 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +22 -17
index d2717e7cf22a..8c739abf5589 100644
@@ -6996,36 +6996,41 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
 static int
 qla2x00_restart_isp(scsi_qla_host_t *vha)
 {
-	int status = 0;
+	int status;
 	struct qla_hw_data *ha = vha->hw;
 
 	/* If firmware needs to be loaded */
 	if (qla2x00_isp_firmware(vha)) {
 		vha->flags.online = 0;
 		status = ha->isp_ops->chip_diag(vha);
-		if (!status)
-			status = qla2x00_setup_chip(vha);
+		if (status)
+			return status;
+		status = qla2x00_setup_chip(vha);
+		if (status)
+			return status;
 	}
 
-	if (!status && !(status = qla2x00_init_rings(vha))) {
-		clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
-		ha->flags.chip_reset_done = 1;
+	status = qla2x00_init_rings(vha);
+	if (status)
+		return status;
 
-		/* Initialize the queues in use */
-		qla25xx_init_queues(ha);
+	clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
+	ha->flags.chip_reset_done = 1;
 
-		status = qla2x00_fw_ready(vha);
-		if (!status) {
-			/* Issue a marker after FW becomes ready. */
-			qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL);
-			set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
-		}
+	/* Initialize the queues in use */
+	qla25xx_init_queues(ha);
 
+	status = qla2x00_fw_ready(vha);
+	if (status) {
 		/* if no cable then assume it's good */
-		if ((vha->device_flags & DFLG_NO_CABLE))
-			status = 0;
+		return vha->device_flags & DFLG_NO_CABLE ? 0 : status;
 	}
-	return (status);
+
+	/* Issue a marker after FW becomes ready. */
+	qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL);
+	set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
+
+	return 0;
 }
 
 static int
#10 lore raw

PATCH v2 9/9 qla2xxx: Introduce a function for computing the debug message prefix

In reply to Bart Van Assche

Instead of repeating the code for generating a debug message prefix six times, introduce a function for computing the debug message prefix.

Cc Nilesh Javali <[email protected]>
Cc Quinn Tran <[email protected]>
Cc Himanshu Madhani <[email protected]>
Cc Martin Wilck <[email protected]>
Cc Roman Bolshakov <[email protected]>
---
 drivers/scsi/qla2xxx/qla_dbg.c | 96 ++++++++++++----------------------
 1 file changed, 32 insertions(+), 64 deletions(-)
drivers/scsi/qla2xxx/qla_dbg.c +32 -64
index 41493bd53fc0..911c7852e660 100644
@@ -2447,6 +2447,23 @@ qla83xx_fw_dump(scsi_qla_host_t *vha)
 /*                         Driver Debug Functions.                          */
 /****************************************************************************/
 
+/* Write the debug message prefix into @pbuf. */
+static void ql_dbg_prefix(char *pbuf, int pbuf_size,
+			  const scsi_qla_host_t *vha, uint msg_id)
+{
+	if (vha) {
+		const struct pci_dev *pdev = vha->hw->pdev;
+
+		/* <module-name> [<dev-name>]-<msg-id>:<host>: */
+		snprintf(pbuf, pbuf_size, "%s [%s]-%04x:%ld: ", QL_MSGHDR,
+			 dev_name(&(pdev->dev)), msg_id, vha->host_no);
+	} else {
+		/* <module-name> [<dev-name>]-<msg-id>: : */
+		snprintf(pbuf, pbuf_size, "%s [%s]-%04x: : ", QL_MSGHDR,
+			 "0000:00:00.0", msg_id);
+	}
+}
+
 /*
  * This function is for formatting and logging debug information.
  * It is to be used when vha is available. It formats the message
@@ -2465,41 +2482,19 @@ ql_dbg(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...)
 {
 	va_list va;
 	struct va_format vaf;
+	char pbuf[64];
 
 	va_start(va, fmt);
 
 	vaf.fmt = fmt;
 	vaf.va = &va;
 
-	if (!ql_mask_match(level)) {
-		char pbuf[64];
+	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id);
 
-		if (vha != NULL) {
-			const struct pci_dev *pdev = vha->hw->pdev;
-			/* <module-name> <msg-id>:<host> Message */
-			snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ",
-			    QL_MSGHDR, dev_name(&(pdev->dev)), id,
-			    vha->host_no);
-		} else {
-			snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
-			    QL_MSGHDR, "0000:00:00.0", id);
-		}
-		pbuf[sizeof(pbuf) - 1] = 0;
+	if (!ql_mask_match(level))
 		trace_ql_dbg_log(pbuf, &vaf);
-		va_end(va);
-		return;
-	}
-
-	if (vha != NULL) {
-		const struct pci_dev *pdev = vha->hw->pdev;
-		/* <module-name> <pci-name> <msg-id>:<host> Message */
-		pr_warn("%s [%s]-%04x:%ld: %pV",
-			QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset,
-			vha->host_no, &vaf);
-	} else {
-		pr_warn("%s [%s]-%04x: : %pV",
-			QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf);
-	}
+	else
+		pr_warn("%s%pV", pbuf, &vaf);
 
 	va_end(va);
 
@@ -2524,6 +2519,7 @@ ql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...)
 {
 	va_list va;
 	struct va_format vaf;
+	char pbuf[128];
 
 	if (pdev == NULL)
 		return;
@@ -2535,9 +2531,8 @@ ql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...)
 	vaf.fmt = fmt;
 	vaf.va = &va;
 
-	/* <module-name> <dev-name>:<msg-id> Message */
-	pr_warn("%s [%s]-%04x: : %pV",
-		QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset, &vaf);
+	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id + ql_dbg_offset);
+	pr_warn("%s%pV", pbuf, &vaf);
 
 	va_end(va);
 }
@@ -2565,16 +2560,7 @@ ql_log(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...)
 	if (level > ql_errlev)
 		return;
 
-	if (vha != NULL) {
-		const struct pci_dev *pdev = vha->hw->pdev;
-		/* <module-name> <msg-id>:<host> Message */
-		snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x:%ld: ",
-			QL_MSGHDR, dev_name(&(pdev->dev)), id, vha->host_no);
-	} else {
-		snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
-			QL_MSGHDR, "0000:00:00.0", id);
-	}
-	pbuf[sizeof(pbuf) - 1] = 0;
+	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id);
 
 	va_start(va, fmt);
 
@@ -2625,10 +2611,7 @@ ql_log_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...)
 	if (level > ql_errlev)
 		return;
 
-	/* <module-name> <dev-name>:<msg-id> Message */
-	snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
-		 QL_MSGHDR, dev_name(&(pdev->dev)), id);
-	pbuf[sizeof(pbuf) - 1] = 0;
+	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id);
 
 	va_start(va, fmt);
 
@@ -2724,16 +2707,7 @@ ql_log_qp(uint32_t level, struct qla_qpair *qpair, int32_t id,
 	if (level > ql_errlev)
 		return;
 
-	if (qpair != NULL) {
-		const struct pci_dev *pdev = qpair->pdev;
-		/* <module-name> <msg-id>:<host> Message */
-		snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: ",
-			QL_MSGHDR, dev_name(&(pdev->dev)), id);
-	} else {
-		snprintf(pbuf, sizeof(pbuf), "%s [%s]-%04x: : ",
-			QL_MSGHDR, "0000:00:00.0", id);
-	}
-	pbuf[sizeof(pbuf) - 1] = 0;
+	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, id);
 
 	va_start(va, fmt);
 
@@ -2777,6 +2751,7 @@ ql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id,
 {
 	va_list va;
 	struct va_format vaf;
+	char pbuf[128];
 
 	if (!ql_mask_match(level))
 		return;
@@ -2786,16 +2761,9 @@ ql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id,
 	vaf.fmt = fmt;
 	vaf.va = &va;
 
-	if (qpair != NULL) {
-		const struct pci_dev *pdev = qpair->pdev;
-		/* <module-name> <pci-name> <msg-id>:<host> Message */
-		pr_warn("%s [%s]-%04x: %pV",
-		    QL_MSGHDR, dev_name(&(pdev->dev)), id + ql_dbg_offset,
-		    &vaf);
-	} else {
-		pr_warn("%s [%s]-%04x: : %pV",
-			QL_MSGHDR, "0000:00:00.0", id + ql_dbg_offset, &vaf);
-	}
+	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL,
+		      id + ql_dbg_offset);
+	pr_warn("%s%pV", pbuf, &vaf);
 
 	va_end(va);
 
#11 lore raw
In reply to Bart Van Assche

Hi Bart,

Quoted 28 lines · Bart Van Assche

Hi Martin,

This patch series includes cleanup patches and also patches that address complaints from several static source code analyzers. Please consider these patches for kernel v5.9.

Thanks,

Bart.

Changes compared to v1:
- Rewrote patch "Fix a Coverity complaint in qla2100_fw_dump()"

Bart Van Assche (9):
qla2xxx: Check the size of struct fcp_hdr at compile time
qla2xxx: Remove the __packed annotation from struct fcp_hdr and
fcp_hdr_le
qla2xxx: Make qla82xx_flash_wait_write_finish() easier to read
qla2xxx: Initialize 'n' before using it
qla2xxx: Remove a superfluous cast
qla2xxx: Make __qla2x00_alloc_iocbs() initialize 32 bits of
request_t.handle
qla2xxx: Fix a Coverity complaint in qla2100_fw_dump()
qla2xxx: Make qla2x00_restart_isp() easier to read
qla2xxx: Introduce a function for computing the debug message prefix

Quoted 10 lines
drivers/scsi/qla2xxx/qla_bsg.c     |  3 +-
drivers/scsi/qla2xxx/qla_dbg.c     | 98 ++++++++++--------------------
drivers/scsi/qla2xxx/qla_dbg.h     |  1 +
drivers/scsi/qla2xxx/qla_init.c    | 39 ++++++------
drivers/scsi/qla2xxx/qla_iocb.c    |  4 +-
drivers/scsi/qla2xxx/qla_nx.c      | 20 +++---
drivers/scsi/qla2xxx/qla_target.h  |  4 +-
drivers/scsi/qla2xxx/tcm_qla2xxx.c |  1 +
8 files changed, 70 insertions(+), 100 deletions(-)

I had reviewed this series earlier and provided Reviewed-by tag.

https://lore.kernel.org/linux-scsi/[email protected]/

--
Himanshu Madhani Oracle Linux Engineering

#13 lore raw
In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche

This patch series includes cleanup patches and also patches that address complaints from several static source code analyzers. Please consider these patches for kernel v5.9.

Thanks,

Bart.

[...]

Applied to 5.9/scsi-queue, thanks!

[1/9] scsi: qla2xxx: Check the size of struct fcp_hdr at compile time

      https://git.kernel.org/mkp/scsi/c/a7f474542ea3
[2/9] scsi: qla2xxx: Remove the __packed annotation from struct fcp_hdr and fcp_hdr_le
      https://git.kernel.org/mkp/scsi/c/f1e12bee55e6
[3/9] scsi: qla2xxx: Make qla82xx_flash_wait_write_finish() easier to read
      https://git.kernel.org/mkp/scsi/c/2f91a0a03c2d
[4/9] scsi: qla2xxx: Initialize 'n' before using it
      https://git.kernel.org/mkp/scsi/c/67668b5b13c7
[5/9] scsi: qla2xxx: Remove a superfluous cast
      https://git.kernel.org/mkp/scsi/c/9bb013584a5e
[6/9] scsi: qla2xxx: Make __qla2x00_alloc_iocbs() initialize 32 bits of request_t.handle
      https://git.kernel.org/mkp/scsi/c/f8f12bda53ea
[7/9] scsi: qla2xxx: Fix a Coverity complaint in qla2100_fw_dump()
      https://git.kernel.org/mkp/scsi/c/57fec9f24e58
[8/9] scsi: qla2xxx: Make qla2x00_restart_isp() easier to read
      https://git.kernel.org/mkp/scsi/c/f85a299f5ec5
[9/9] scsi: qla2xxx: Introduce a function for computing the debug message prefix
      https://git.kernel.org/mkp/scsi/c/e7019c95c40d
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering