[SCSI] megaraid_sas: prints pending cmds before setting hw_crit_error

This patch adds function to print the pending frame details before returning
failure from the reset routine. It also exposes a new variable megasas_dbg_lvl
that allows the user to set the debug level for logging.

Signed-off-by: Sumant Patro <Sumant.Patro@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Sumant Patro and committed by James Bottomley 658dcedb b274cab7

+94
+92
drivers/scsi/megaraid/megaraid_sas.c
··· 71 71 static struct fasync_struct *megasas_async_queue; 72 72 static DEFINE_MUTEX(megasas_async_queue_mutex); 73 73 74 + static u32 megasas_dbg_lvl; 75 + 74 76 /** 75 77 * megasas_get_cmd - Get a command from the free pool 76 78 * @instance: Adapter soft state ··· 760 758 } 761 759 } 762 760 761 + /** 762 + * megasas_dump_pending_frames - Dumps the frame address of all pending cmds 763 + * in FW 764 + * @instance: Adapter soft state 765 + */ 766 + static inline void 767 + megasas_dump_pending_frames(struct megasas_instance *instance) 768 + { 769 + struct megasas_cmd *cmd; 770 + int i,n; 771 + union megasas_sgl *mfi_sgl; 772 + struct megasas_io_frame *ldio; 773 + struct megasas_pthru_frame *pthru; 774 + u32 sgcount; 775 + u32 max_cmd = instance->max_fw_cmds; 776 + 777 + printk(KERN_ERR "\nmegasas[%d]: Dumping Frame Phys Address of all pending cmds in FW\n",instance->host->host_no); 778 + printk(KERN_ERR "megasas[%d]: Total OS Pending cmds : %d\n",instance->host->host_no,atomic_read(&instance->fw_outstanding)); 779 + if (IS_DMA64) 780 + printk(KERN_ERR "\nmegasas[%d]: 64 bit SGLs were sent to FW\n",instance->host->host_no); 781 + else 782 + printk(KERN_ERR "\nmegasas[%d]: 32 bit SGLs were sent to FW\n",instance->host->host_no); 783 + 784 + printk(KERN_ERR "megasas[%d]: Pending OS cmds in FW : \n",instance->host->host_no); 785 + for (i = 0; i < max_cmd; i++) { 786 + cmd = instance->cmd_list[i]; 787 + if(!cmd->scmd) 788 + continue; 789 + printk(KERN_ERR "megasas[%d]: Frame addr :0x%08lx : ",instance->host->host_no,(unsigned long)cmd->frame_phys_addr); 790 + if (megasas_is_ldio(cmd->scmd)){ 791 + ldio = (struct megasas_io_frame *)cmd->frame; 792 + mfi_sgl = &ldio->sgl; 793 + sgcount = ldio->sge_count; 794 + printk(KERN_ERR "megasas[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x, lba lo : 0x%x, lba_hi : 0x%x, sense_buf addr : 0x%x,sge count : 0x%x\n",instance->host->host_no, cmd->frame_count,ldio->cmd,ldio->target_id, ldio->start_lba_lo,ldio->start_lba_hi,ldio->sense_buf_phys_addr_lo,sgcount); 795 + } 796 + else { 797 + pthru = (struct megasas_pthru_frame *) cmd->frame; 798 + mfi_sgl = &pthru->sgl; 799 + sgcount = pthru->sge_count; 800 + printk(KERN_ERR "megasas[%d]: frame count : 0x%x, Cmd : 0x%x, Tgt id : 0x%x, lun : 0x%x, cdb_len : 0x%x, data xfer len : 0x%x, sense_buf addr : 0x%x,sge count : 0x%x\n",instance->host->host_no,cmd->frame_count,pthru->cmd,pthru->target_id,pthru->lun,pthru->cdb_len , pthru->data_xfer_len,pthru->sense_buf_phys_addr_lo,sgcount); 801 + } 802 + if(megasas_dbg_lvl & MEGASAS_DBG_LVL){ 803 + for (n = 0; n < sgcount; n++){ 804 + if (IS_DMA64) 805 + printk(KERN_ERR "megasas: sgl len : 0x%x, sgl addr : 0x%08lx ",mfi_sgl->sge64[n].length , (unsigned long)mfi_sgl->sge64[n].phys_addr) ; 806 + else 807 + printk(KERN_ERR "megasas: sgl len : 0x%x, sgl addr : 0x%x ",mfi_sgl->sge32[n].length , mfi_sgl->sge32[n].phys_addr) ; 808 + } 809 + } 810 + printk(KERN_ERR "\n"); 811 + } /*for max_cmd*/ 812 + printk(KERN_ERR "\nmegasas[%d]: Pending Internal cmds in FW : \n",instance->host->host_no); 813 + for (i = 0; i < max_cmd; i++) { 814 + 815 + cmd = instance->cmd_list[i]; 816 + 817 + if(cmd->sync_cmd == 1){ 818 + printk(KERN_ERR "0x%08lx : ", (unsigned long)cmd->frame_phys_addr); 819 + } 820 + } 821 + printk(KERN_ERR "megasas[%d]: Dumping Done.\n\n",instance->host->host_no); 822 + } 823 + 763 824 /** 764 825 * megasas_queue_command - Queue entry point 765 826 * @scmd: SCSI command to be queued ··· 934 869 */ 935 870 writel(MFI_STOP_ADP, 936 871 &instance->reg_set->inbound_doorbell); 872 + megasas_dump_pending_frames(instance); 937 873 instance->hw_crit_error = 1; 938 874 return FAILED; 939 875 } ··· 2302 2236 instance->unique_id = pdev->bus->number << 8 | pdev->devfn; 2303 2237 instance->init_id = MEGASAS_DEFAULT_INIT_ID; 2304 2238 2239 + megasas_dbg_lvl = 0; 2240 + 2305 2241 /* 2306 2242 * Initialize MFI Firmware 2307 2243 */ ··· 2930 2862 static DRIVER_ATTR(release_date, S_IRUGO, megasas_sysfs_show_release_date, 2931 2863 NULL); 2932 2864 2865 + static ssize_t 2866 + megasas_sysfs_show_dbg_lvl(struct device_driver *dd, char *buf) 2867 + { 2868 + return sprintf(buf,"%u",megasas_dbg_lvl); 2869 + } 2870 + 2871 + static ssize_t 2872 + megasas_sysfs_set_dbg_lvl(struct device_driver *dd, const char *buf, size_t count) 2873 + { 2874 + int retval = count; 2875 + if(sscanf(buf,"%u",&megasas_dbg_lvl)<1){ 2876 + printk(KERN_ERR "megasas: could not set dbg_lvl\n"); 2877 + retval = -EINVAL; 2878 + } 2879 + return retval; 2880 + } 2881 + 2882 + static DRIVER_ATTR(dbg_lvl, S_IRUGO|S_IWUGO, megasas_sysfs_show_dbg_lvl, 2883 + megasas_sysfs_set_dbg_lvl); 2884 + 2933 2885 /** 2934 2886 * megasas_init - Driver load entry point 2935 2887 */ ··· 2990 2902 driver_create_file(&megasas_pci_driver.driver, &driver_attr_version); 2991 2903 driver_create_file(&megasas_pci_driver.driver, 2992 2904 &driver_attr_release_date); 2905 + driver_create_file(&megasas_pci_driver.driver, 2906 + &driver_attr_dbg_lvl); 2993 2907 2994 2908 return rval; 2995 2909 } ··· 3004 2914 driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version); 3005 2915 driver_remove_file(&megasas_pci_driver.driver, 3006 2916 &driver_attr_release_date); 2917 + driver_remove_file(&megasas_pci_driver.driver, 2918 + &driver_attr_dbg_lvl); 3007 2919 3008 2920 pci_unregister_driver(&megasas_pci_driver); 3009 2921 unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
+2
drivers/scsi/megaraid/megaraid_sas.h
··· 537 537 #define MEGASAS_MAX_LUN 8 538 538 #define MEGASAS_MAX_LD 64 539 539 540 + #define MEGASAS_DBG_LVL 1 541 + 540 542 /* 541 543 * When SCSI mid-layer calls driver's reset routine, driver waits for 542 544 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note