diff options
Diffstat (limited to 'drivers/scsi/ufs/ufshcd.c')
-rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 397081d320b1..9d5d2ca7fc4f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -99,8 +99,29 @@ _ret; \ }) -#define ufshcd_hex_dump(prefix_str, buf, len) \ -print_hex_dump(KERN_ERR, prefix_str, DUMP_PREFIX_OFFSET, 16, 4, buf, len, false) +#define ufshcd_hex_dump(prefix_str, buf, len) do { \ + size_t __len = (len); \ + print_hex_dump(KERN_ERR, prefix_str, \ + __len > 4 ? DUMP_PREFIX_OFFSET : DUMP_PREFIX_NONE,\ + 16, 4, buf, __len, false); \ +} while (0) + +int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, + const char *prefix) +{ + u8 *regs; + + regs = kzalloc(len, GFP_KERNEL); + if (!regs) + return -ENOMEM; + + memcpy_fromio(regs, hba->mmio_base + offset, len); + ufshcd_hex_dump(prefix, regs, len); + kfree(regs); + + return 0; +} +EXPORT_SYMBOL_GPL(ufshcd_dump_regs); enum { UFSHCD_MAX_CHANNEL = 0, @@ -321,18 +342,19 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, sector_t lba = -1; u8 opcode = 0; u32 intr, doorbell; - struct ufshcd_lrb *lrbp; + struct ufshcd_lrb *lrbp = &hba->lrb[tag]; int transfer_len = -1; - /* trace UPIU also */ - ufshcd_add_cmd_upiu_trace(hba, tag, str); - - if (!trace_ufshcd_command_enabled()) + if (!trace_ufshcd_command_enabled()) { + /* trace UPIU W/O tracing command */ + if (lrbp->cmd) + ufshcd_add_cmd_upiu_trace(hba, tag, str); return; - - lrbp = &hba->lrb[tag]; + } if (lrbp->cmd) { /* data phase exists */ + /* trace UPIU also */ + ufshcd_add_cmd_upiu_trace(hba, tag, str); opcode = (u8)(*lrbp->cmd->cmnd); if ((opcode == READ_10) || (opcode == WRITE_10)) { /* @@ -386,15 +408,7 @@ static void ufshcd_print_uic_err_hist(struct ufs_hba *hba, static void ufshcd_print_host_regs(struct ufs_hba *hba) { - /* - * hex_dump reads its data without the readl macro. This might - * cause inconsistency issues on some platform, as the printed - * values may be from cache and not the most recent value. - * To know whether you are looking at an un-cached version verify - * that IORESOURCE_MEM flag is on when xxx_get_resource() is invoked - * during platform/pci probe function. - */ - ufshcd_hex_dump("host regs: ", hba->mmio_base, UFSHCI_REG_SPACE_SIZE); + ufshcd_dump_regs(hba, 0, UFSHCI_REG_SPACE_SIZE, "host_regs: "); dev_err(hba->dev, "hba->ufs_version = 0x%x, hba->capabilities = 0x%x\n", hba->ufs_version, hba->capabilities); dev_err(hba->dev, @@ -7290,7 +7304,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n", pwr_mode, ret); - if (driver_byte(ret) & DRIVER_SENSE) + if (driver_byte(ret) == DRIVER_SENSE) scsi_print_sense_hdr(sdp, NULL, &sshdr); } |