linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kiwoong Kim" <kwmad.kim@samsung.com>
To: "'Alim Akhtar'" <alim.akhtar@samsung.com>,
	<linux-scsi@vger.kernel.org>, <avri.altman@wdc.com>,
	<jejb@linux.ibm.com>, <martin.petersen@oracle.com>,
	<beanhuo@micron.com>, <asutoshd@codeaurora.org>,
	<cang@codeaurora.org>, <bvanassche@acm.org>,
	<grant.jung@samsung.com>, <sc.suh@samsung.com>,
	<hy50.seo@samsung.com>, <sh425.lee@samsung.com>
Subject: RE: [RFC PATCH v5 2/3] ufs: exynos: introduce command history
Date: Mon, 13 Jul 2020 13:33:22 +0900	[thread overview]
Message-ID: <000401d658ce$bdf18e40$39d4aac0$@samsung.com> (raw)
In-Reply-To: <000001d657ef$8c084200$a418c600$@samsung.com>

> Hi Kiwoong,
> 
> > -----Original Message-----
> > From: Kiwoong Kim <kwmad.kim@samsung.com>
> > Sent: 11 July 2020 12:28
> > To: linux-scsi@vger.kernel.org; alim.akhtar@samsung.com;
> > avri.altman@wdc.com; jejb@linux.ibm.com; martin.petersen@oracle.com;
> > beanhuo@micron.com; asutoshd@codeaurora.org; cang@codeaurora.org;
> > bvanassche@acm.org; grant.jung@samsung.com; sc.suh@samsung.com;
> > hy50.seo@samsung.com; sh425.lee@samsung.com
> > Cc: Kiwoong Kim <kwmad.kim@samsung.com>
> > 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@samsung.com>
> > +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@samsung.com>");
> > +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


  reply	other threads:[~2020-07-13  4:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200711070541epcas2p47678883840df461f649becfc73792da5@epcas2p4.samsung.com>
2020-07-11  6:57 ` [RFC PATCH v5 0/3] ufs: exynos: introduce the way to get cmd info Kiwoong Kim
     [not found]   ` <CGME20200711070543epcas2p28a42f8386624ecaede5329e035e5e1a9@epcas2p2.samsung.com>
2020-07-11  6:57     ` [RFC PATCH v5 1/3] ufs: introduce a callback to get info of command completion Kiwoong Kim
     [not found]   ` <CGME20200711070544epcas2p4d3a75d2f56b8162c09efa0eeaf012fa2@epcas2p4.samsung.com>
2020-07-11  6:57     ` [RFC PATCH v5 2/3] ufs: exynos: introduce command history Kiwoong Kim
2020-07-12  1:55       ` Alim Akhtar
2020-07-13  4:33         ` Kiwoong Kim [this message]
     [not found]   ` <CGME20200711070544epcas2p10291ef069c92d54a7cb8a6b7e0eb09a1@epcas2p1.samsung.com>
2020-07-11  6:57     ` [RFC PATCH v5 3/3] ufs: exynos: implement dbg_register_dump Kiwoong Kim
2020-07-12  1:58   ` [RFC PATCH v5 0/3] ufs: exynos: introduce the way to get cmd info Alim Akhtar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000401d658ce$bdf18e40$39d4aac0$@samsung.com' \
    --to=kwmad.kim@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=grant.jung@samsung.com \
    --cc=hy50.seo@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sc.suh@samsung.com \
    --cc=sh425.lee@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).