diff mbox series

[v2,11/14] qla2xxx: Check for MB timeout while capturing ISP27/28xx FW dump

Message ID 20190912180918.6436-12-hmadhani@marvell.com (mailing list archive)
State Accepted
Headers show
Series qla2xxx: Bug fixes for the driver | expand

Commit Message

Himanshu Madhani Sept. 12, 2019, 6:09 p.m. UTC
From: Quinn Tran <qutran@marvell.com>

Add mailbox timeout checkout for ISP 27xx/28xx during FW dump
procedure. Without the timeout check, hardware lock can
be held for long period. This patch would shorten the dump
procedure, if a timeout condition is encountered.

Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
---
 drivers/scsi/qla2xxx/qla_tmpl.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

Comments

Laurence Oberman Sept. 12, 2019, 8:22 p.m. UTC | #1
On Thu, 2019-09-12 at 11:09 -0700, Himanshu Madhani wrote:
> From: Quinn Tran <qutran@marvell.com>
> 
> Add mailbox timeout checkout for ISP 27xx/28xx during FW dump
> procedure. Without the timeout check, hardware lock can
> be held for long period. This patch would shorten the dump
> procedure, if a timeout condition is encountered.
> 
> Signed-off-by: Quinn Tran <qutran@marvell.com>
> Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
> ---
>  drivers/scsi/qla2xxx/qla_tmpl.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c
> b/drivers/scsi/qla2xxx/qla_tmpl.c
> index 294d77c02cdf..b948d94c8b3c 100644
> --- a/drivers/scsi/qla2xxx/qla_tmpl.c
> +++ b/drivers/scsi/qla2xxx/qla_tmpl.c
> @@ -10,6 +10,7 @@
>  #define ISPREG(vha)	(&(vha)->hw->iobase->isp24)
>  #define IOBAR(reg)	offsetof(typeof(*(reg)), iobase_addr)
>  #define IOBASE(vha)	IOBAR(ISPREG(vha))
> +#define INVALID_ENTRY ((struct qla27xx_fwdt_entry
> *)0xffffffffffffffffUL)
>  
>  static inline void
>  qla27xx_insert16(uint16_t value, void *buf, ulong *len)
> @@ -261,6 +262,7 @@ qla27xx_fwdt_entry_t262(struct scsi_qla_host
> *vha,
>  	ulong start = le32_to_cpu(ent->t262.start_addr);
>  	ulong end = le32_to_cpu(ent->t262.end_addr);
>  	ulong dwords;
> +	int rc;
>  
>  	ql_dbg(ql_dbg_misc, vha, 0xd206,
>  	    "%s: rdram(%x) [%lx]\n", __func__, ent->t262.ram_area,
> *len);
> @@ -308,7 +310,13 @@ qla27xx_fwdt_entry_t262(struct scsi_qla_host
> *vha,
>  	dwords = end - start + 1;
>  	if (buf) {
>  		buf += *len;
> -		qla24xx_dump_ram(vha->hw, start, buf, dwords, &buf);
> +		rc = qla24xx_dump_ram(vha->hw, start, buf, dwords,
> &buf);
> +		if (rc != QLA_SUCCESS) {
> +			ql_dbg(ql_dbg_async, vha, 0xffff,
> +			    "%s: dump ram MB failed. Area %xh start
> %lxh end %lxh\n",
> +			    __func__, area, start, end);
> +			return INVALID_ENTRY;
> +		}
>  	}
>  	*len += dwords * sizeof(uint32_t);
>  done:
> @@ -838,6 +846,13 @@ qla27xx_walk_template(struct scsi_qla_host *vha,
>  		ent = qla27xx_find_entry(type)(vha, ent, buf, len);
>  		if (!ent)
>  			break;
> +
> +		if (ent == INVALID_ENTRY) {
> +			*len = 0;
> +			ql_dbg(ql_dbg_async, vha, 0xffff,
> +			    "Unable to capture FW dump");
> +			goto bailout;
> +		}
>  	}
>  
>  	if (tmp->count)
> @@ -847,6 +862,9 @@ qla27xx_walk_template(struct scsi_qla_host *vha,
>  	if (ent)
>  		ql_dbg(ql_dbg_misc, vha, 0xd019,
>  		    "%s: missing end entry\n", __func__);
> +
> +bailout:
> +	cpu_to_le32s(&tmp->count);	/* endianize residual count
> */
>  }
>  
>  static void
> @@ -1010,7 +1028,9 @@ qla27xx_fwdump(scsi_qla_host_t *vha, int
> hardware_locked)
>  			}
>  			len = qla27xx_execute_fwdt_template(vha,
>  			    fwdt->template, buf);
> -			if (len != fwdt->dump_size) {
> +			if (len == 0) {
> +				goto bailout;
> +			} else if (len != fwdt->dump_size) {
>  				ql_log(ql_log_warn, vha, 0xd013,
>  				    "-> fwdt%u fwdump residual=%+ld\n",
>  				    j, fwdt->dump_size - len);
> @@ -1025,6 +1045,7 @@ qla27xx_fwdump(scsi_qla_host_t *vha, int
> hardware_locked)
>  		qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);
>  	}
>  
> +bailout:
>  #ifndef __CHECKER__
>  	if (!hardware_locked)
>  		spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);

Being aware of this issue I reviewed it for sanity and code. I cant
speak to functions that interract with the firmware though.
Looks good otherwise

Reviewed-by: Laurence Oberman <loberman@redhat.com>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 294d77c02cdf..b948d94c8b3c 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -10,6 +10,7 @@ 
 #define ISPREG(vha)	(&(vha)->hw->iobase->isp24)
 #define IOBAR(reg)	offsetof(typeof(*(reg)), iobase_addr)
 #define IOBASE(vha)	IOBAR(ISPREG(vha))
+#define INVALID_ENTRY ((struct qla27xx_fwdt_entry *)0xffffffffffffffffUL)
 
 static inline void
 qla27xx_insert16(uint16_t value, void *buf, ulong *len)
@@ -261,6 +262,7 @@  qla27xx_fwdt_entry_t262(struct scsi_qla_host *vha,
 	ulong start = le32_to_cpu(ent->t262.start_addr);
 	ulong end = le32_to_cpu(ent->t262.end_addr);
 	ulong dwords;
+	int rc;
 
 	ql_dbg(ql_dbg_misc, vha, 0xd206,
 	    "%s: rdram(%x) [%lx]\n", __func__, ent->t262.ram_area, *len);
@@ -308,7 +310,13 @@  qla27xx_fwdt_entry_t262(struct scsi_qla_host *vha,
 	dwords = end - start + 1;
 	if (buf) {
 		buf += *len;
-		qla24xx_dump_ram(vha->hw, start, buf, dwords, &buf);
+		rc = qla24xx_dump_ram(vha->hw, start, buf, dwords, &buf);
+		if (rc != QLA_SUCCESS) {
+			ql_dbg(ql_dbg_async, vha, 0xffff,
+			    "%s: dump ram MB failed. Area %xh start %lxh end %lxh\n",
+			    __func__, area, start, end);
+			return INVALID_ENTRY;
+		}
 	}
 	*len += dwords * sizeof(uint32_t);
 done:
@@ -838,6 +846,13 @@  qla27xx_walk_template(struct scsi_qla_host *vha,
 		ent = qla27xx_find_entry(type)(vha, ent, buf, len);
 		if (!ent)
 			break;
+
+		if (ent == INVALID_ENTRY) {
+			*len = 0;
+			ql_dbg(ql_dbg_async, vha, 0xffff,
+			    "Unable to capture FW dump");
+			goto bailout;
+		}
 	}
 
 	if (tmp->count)
@@ -847,6 +862,9 @@  qla27xx_walk_template(struct scsi_qla_host *vha,
 	if (ent)
 		ql_dbg(ql_dbg_misc, vha, 0xd019,
 		    "%s: missing end entry\n", __func__);
+
+bailout:
+	cpu_to_le32s(&tmp->count);	/* endianize residual count */
 }
 
 static void
@@ -1010,7 +1028,9 @@  qla27xx_fwdump(scsi_qla_host_t *vha, int hardware_locked)
 			}
 			len = qla27xx_execute_fwdt_template(vha,
 			    fwdt->template, buf);
-			if (len != fwdt->dump_size) {
+			if (len == 0) {
+				goto bailout;
+			} else if (len != fwdt->dump_size) {
 				ql_log(ql_log_warn, vha, 0xd013,
 				    "-> fwdt%u fwdump residual=%+ld\n",
 				    j, fwdt->dump_size - len);
@@ -1025,6 +1045,7 @@  qla27xx_fwdump(scsi_qla_host_t *vha, int hardware_locked)
 		qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);
 	}
 
+bailout:
 #ifndef __CHECKER__
 	if (!hardware_locked)
 		spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);