At present, I just add command history print and you can add various vendor regions. I tried this with force error injection to verify this: [ 421.876751] exynos-ufs 13100000.ufs: :--------------------------------------------------- [ 421.876767] exynos-ufs 13100000.ufs: :\x09\x09SCSI CMD(19262) [ 421.876779] exynos-ufs 13100000.ufs: :--------------------------------------------------- [ 421.876793] exynos-ufs 13100000.ufs: :OP, TAG, LBA, SCT, RETRIES, STIME, ETIME, REQS\x0a ... [ 421.876979] exynos-ufs 13100000.ufs: : 0x2a, 00, 0x0012f1ae, 0x10000, 5, 415979836143, 0, 0x0 [ 421.876991] exynos-ufs 13100000.ufs: : 0x2a, 00, 0x00f7ddbc, 0x410000, 5, 416246257103, 0, 0x0 [ 421.877004] exynos-ufs 13100000.ufs: : 0x2a, 01, 0x00130e62, 0x80000, 5, 416246296834, 0, 0x1 [ 421.877017] exynos-ufs 13100000.ufs: : 0x2a, 02, 0x0085597f, 0x40000, 5, 416246309988, 0, 0x3 [ 421.877030] exynos-ufs 13100000.ufs: : 0x2a, 03, 0x00855985, 0x240000, 5, 416246331373, 0, 0x7 ... [ 421.877206] exynos-ufs 13100000.ufs: : 0x2a, 00, 0x0012f1b9, 0x10000, 5, 417676828598, 0, 0x0 [ 421.877217] exynos-ufs 13100000.ufs: : 0x2a, 00, 0x0012f1ba, 0x10000, 5, 417677462136, 0, 0x0 Signed-off-by: Kiwoong Kim <kwmad.kim@xxxxxxxxxxx> Tested-by: Kiwoong Kim <kwmad.kim@xxxxxxxxxxx> --- drivers/scsi/ufs/Kconfig | 2 +- drivers/scsi/ufs/ufs-exynos-dbg.c | 11 +++++------ drivers/scsi/ufs/ufs-exynos.c | 13 ++++++++++++- drivers/scsi/ufs/ufs-exynos.h | 10 ++++++++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig index c946d8f..b906ff8 100644 --- a/drivers/scsi/ufs/Kconfig +++ b/drivers/scsi/ufs/Kconfig @@ -181,7 +181,7 @@ config SCSI_UFS_EXYNOS_DBG This selects EXYNOS specific functions to get and even print some information to see what's happening at both command issue time completion time. - The information may contain gerernal things as well as + The information may contain general things as well as EXYNOS specific, such as vendor specific hardware contexts. Select this if you want to get and print the information. diff --git a/drivers/scsi/ufs/ufs-exynos-dbg.c b/drivers/scsi/ufs/ufs-exynos-dbg.c index e1f1452..bd1f4be 100644 --- a/drivers/scsi/ufs/ufs-exynos-dbg.c +++ b/drivers/scsi/ufs/ufs-exynos-dbg.c @@ -74,6 +74,7 @@ static void ufs_s_print_cmd_log(struct ufs_s_dbg_mgr *mgr, struct device *dev) dev_err(dev, ":OP, TAG, LBA, SCT, RETRIES, STIME, ETIME, REQS\n\n"); idx = (last == max - 1) ? 0 : last + 1; + data = &cmd_info->data[idx]; for (i = 0 ; i < max ; i++, data = &cmd_info->data[idx]) { dev_err(dev, ": 0x%02x, %02d, 0x%08llx, 0x%04x, %d, %llu, %llu, 0x%llx", data->op, data->tag, data->lba, data->sct, data->retries, @@ -122,9 +123,7 @@ void exynos_ufs_dump_info(struct ufs_exynos_handle *handle, struct device *dev) mgr->time = cpu_clock(raw_smp_processor_id()); -#ifdef CONFIG_SCSI_UFS_EXYNOS_CMD_LOG ufs_s_print_cmd_log(mgr, dev); -#endif if (mgr->first_time == 0ULL) mgr->first_time = mgr->time; @@ -139,8 +138,8 @@ void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, struct scsi_cmnd *cmd = hba->lrb[tag].cmd; int cpu = raw_smp_processor_id(); struct cmd_data *cmd_log = &mgr->cmd_log; /* temp buffer to put */ - u64 lba = 0; - u32 sct = 0; + u64 lba; + u32 sct; if (mgr->active == 0) return; @@ -153,8 +152,8 @@ void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, cmd_log->outstanding_reqs = hba->outstanding_reqs; /* Now assume using WRITE_10 and READ_10 */ - put_unaligned(cpu_to_le32(*(u32 *)cmd->cmnd[2]), &lba); - put_unaligned(cpu_to_le16(*(u16 *)cmd->cmnd[7]), &sct); + lba = get_unaligned_be32(&cmd->cmnd[2]); + sct = get_unaligned_be32(&cmd->cmnd[7]); if (cmd->cmnd[0] != UNMAP) cmd_log->lba = lba; diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c index 53b9d6e..be2e74f 100644 --- a/drivers/scsi/ufs/ufs-exynos.c +++ b/drivers/scsi/ufs/ufs-exynos.c @@ -1033,7 +1033,6 @@ static int exynos_ufs_init(struct ufs_hba *hba) ret = exynos_ufs_init_dbg(&ufs->handle, dev); if (ret) return ret; - spin_lock_init(&ufs->dbg_lock); return 0; phy_off: @@ -1236,6 +1235,17 @@ static int exynos_ufs_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) return 0; } +static void exynos_ufs_dbg_register_dump(struct ufs_hba *hba) +{ + struct exynos_ufs *ufs = ufshcd_get_variant(hba); + + if (!test_and_set_bit(EXYNOS_UFS_DBG_DUMP_CXT, &ufs->dbg_flag)) { + exynos_ufs_dump_info(&ufs->handle, hba->dev); + clear_bit(EXYNOS_UFS_DBG_DUMP_CXT, &ufs->dbg_flag); + } + return; +} + static struct ufs_hba_variant_ops ufs_hba_exynos_ops = { .name = "exynos_ufs", .init = exynos_ufs_init, @@ -1248,6 +1258,7 @@ static struct ufs_hba_variant_ops ufs_hba_exynos_ops = { .hibern8_notify = exynos_ufs_hibern8_notify, .suspend = exynos_ufs_suspend, .resume = exynos_ufs_resume, + .dbg_register_dump = exynos_ufs_dbg_register_dump, }; static int exynos_ufs_probe(struct platform_device *pdev) diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h index b9cb517..cd752eb 100644 --- a/drivers/scsi/ufs/ufs-exynos.h +++ b/drivers/scsi/ufs/ufs-exynos.h @@ -215,8 +215,8 @@ struct exynos_ufs { #define EXYNOS_UFS_OPT_USE_SW_HIBERN8_TIMER BIT(4) struct ufs_exynos_handle handle; - spinlock_t dbg_lock; - int under_dump; + unsigned long dbg_flag; +#define EXYNOS_UFS_DBG_DUMP_CXT BIT(0) }; #define for_each_ufs_rx_lane(ufs, i) \ @@ -297,6 +297,7 @@ void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, void exynos_ufs_cmd_log_end(struct ufs_exynos_handle *handle, struct ufs_hba *hba, int tag); int exynos_ufs_init_dbg(struct ufs_exynos_handle *handle, struct device *dev); +void exynos_ufs_dump_info(struct ufs_exynos_handle *handle, struct device *dev); #else void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, struct ufs_hba *hba, int tag) @@ -312,5 +313,10 @@ int exynos_ufs_init_dbg(struct ufs_exynos_handle *handle, struct device *dev) { return 0; } + +void exynos_ufs_dump_info(struct ufs_exynos_handle *handle, struct device *dev) +{ + return; +} #endif #endif /* _UFS_EXYNOS_H_ */ -- 2.7.4