When controller fails to transition to READY state during driver probe, dump the system interface register set. This will give snapshot of the firmware status for debugging driver load issues.
Signed-off-by: Sumit Saxena <sumit.sax...@broadcom.com> Signed-off-by: Shivasharan S <shivasharan.srikanteshw...@broadcom.com> --- drivers/scsi/megaraid/megaraid_sas_base.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 5d2f346f3f49..5725d4cfbd14 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -2862,6 +2862,24 @@ megasas_dump(void *buf, int sz, int format) printk(KERN_CONT "\n"); } +/** + * megasas_dump_reg_set - This function will print hexdump of register set + * @buf: Buffer to be dumped + * @sz: Size in bytes + * @format: Different formats of dumping e.g. format=n will + * cause only 'n' 32 bit words to be dumped in a + * single line. + */ +inline void +megasas_dump_reg_set(void __iomem *reg_set) +{ + unsigned int i, sz = 256; + __le32 *reg = (__le32 *)reg_set; + + for (i = 0; i < (sz / sizeof(__le32)); i++) + printk("%08x: %08x\n", (i * 4), le32_to_cpu(readl(®[i]))); +} + /** * megasas_dump_fusion_io - This function will print key details * of SCSI IO @@ -3891,8 +3909,11 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr) max_wait = MEGASAS_RESET_WAIT_TIME; cur_state = MFI_STATE_FAULT; break; - } else + } else { + dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); + megasas_dump_reg_set(instance->reg_set); return -ENODEV; + } case MFI_STATE_WAIT_HANDSHAKE: /* @@ -4000,6 +4021,8 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr) default: dev_printk(KERN_DEBUG, &instance->pdev->dev, "Unknown state 0x%x\n", fw_state); + dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); + megasas_dump_reg_set(instance->reg_set); return -ENODEV; } @@ -4022,6 +4045,8 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr) if (curr_abs_state == abs_state) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "FW state [%d] hasn't changed " "in %d secs\n", fw_state, max_wait); + dev_printk(KERN_DEBUG, &instance->pdev->dev, "System Register set:\n"); + megasas_dump_reg_set(instance->reg_set); return -ENODEV; } -- 2.16.1