> Hi Kiwoong, > > > -----Original Message----- > > From: Kiwoong Kim <kwmad.kim@xxxxxxxxxxx> > > Sent: 11 July 2020 12:28 > > To: linux-scsi@xxxxxxxxxxxxxxx; alim.akhtar@xxxxxxxxxxx; > > avri.altman@xxxxxxx; jejb@xxxxxxxxxxxxx; martin.petersen@xxxxxxxxxx; > > beanhuo@xxxxxxxxxx; asutoshd@xxxxxxxxxxxxxx; cang@xxxxxxxxxxxxxx; > > bvanassche@xxxxxxx; grant.jung@xxxxxxxxxxx; sc.suh@xxxxxxxxxxx; > > hy50.seo@xxxxxxxxxxx; sh425.lee@xxxxxxxxxxx > > Cc: Kiwoong Kim <kwmad.kim@xxxxxxxxxxx> > > Subject: [RFC PATCH v5 2/3] ufs: exynos: introduce command history > > > > This includes functions to record contexts of incoming commands in a > > circular queue. ufshcd.c has already some function tracer calls to get > > command history but ftrace would be gone when system dies before you > > get the information, such as panic cases. > > > > This patch also implements callbacks compl_xfer_req to store IO > > contexts at completion times. > > > > When you turn on CONFIG_SCSI_UFS_EXYNOS_CMD_LOG, the driver collects > > the information from incoming commands in the circular queue. > > > > Signed-off-by: Kiwoong Kim <kwmad.kim@xxxxxxxxxxx> > > +void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, > > + struct ufs_hba *hba, int tag) { > > + struct ufs_s_dbg_mgr *mgr = (struct ufs_s_dbg_mgr *)handle->private; > > + 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; > > + > > + if (mgr->active == 0) > > + return; > > + > > + cmd_log->start_time = cpu_clock(cpu); > > + cmd_log->op = cmd->cmnd[0]; > > + cmd_log->tag = tag; > > + > > + /* This function runtime is protected by spinlock from outside */ > > + cmd_log->outstanding_reqs = hba->outstanding_reqs; > > + > > + /* Now assume using WRITE_10 and READ_10 */ > > + put_unaligned(cpu_to_le32(*(u32 *)cmd->cmnd[2]), (u32 *)&lba); > This gives compilation error, you need to include <asm- > generic/unaligned.h> Also type casting to u32 is not needed, will give > build warnings. > > > + put_unaligned(cpu_to_le16(*(u16 *)cmd->cmnd[7]), (u16 *)&sct); > Type casting to u16 is not needed. > > > + if (cmd->cmnd[0] != UNMAP) > > + cmd_log->lba = lba; > > + > > + cmd_log->sct = sct; > > + cmd_log->retries = cmd->allowed; > > + > > + ufs_s_put_cmd_log(mgr, cmd_log); > > +} > > + > > +void exynos_ufs_cmd_log_end(struct ufs_exynos_handle *handle, > > + struct ufs_hba *hba, int tag) > > +{ > > + struct ufs_s_dbg_mgr *mgr = (struct ufs_s_dbg_mgr *)handle->private; > > + struct scsi_cmnd *cmd = hba->lrb[tag].cmd; > Unused variable "cmd" > > > + struct ufs_cmd_info *cmd_info = &mgr->cmd_info; > > + int cpu = raw_smp_processor_id(); > > + > > + if (mgr->active == 0) > > + return; > > + > > + cmd_info->pdata[tag]->end_time = cpu_clock(cpu); } > > + > > +int exynos_ufs_init_dbg(struct ufs_exynos_handle *handle, struct > > +device > > +*dev) { > > + struct ufs_s_dbg_mgr *mgr; > > + > > + mgr = devm_kzalloc(dev, sizeof(struct ufs_s_dbg_mgr), GFP_KERNEL); > > + if (!mgr) > > + return -ENOMEM; > > + handle->private = (void *)mgr; > > + mgr->handle = handle; > > + mgr->active = 1; > > + > > + /* cmd log */ > > + spin_lock_init(&mgr->cmd_lock); > > + > > + return 0; > > +} > > +MODULE_AUTHOR("Kiwoong Kim <kwmad.kim@xxxxxxxxxxx>"); > > +MODULE_DESCRIPTION("Exynos UFS debug information"); > > +MODULE_LICENSE("GPL"); MODULE_VERSION("0.1"); > May be "GPL v2" > > > diff --git a/drivers/scsi/ufs/ufs-exynos-if.h > > b/drivers/scsi/ufs/ufs-exynos-if.h > > new file mode 100644 > > 2.7.4 > Have Checked what you commented. Thanks. Kiwoong Kim