From patchwork Wed Jul 15 07:39:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11664373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E731138C for ; Wed, 15 Jul 2020 07:48:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5A3C2075B for ; Wed, 15 Jul 2020 07:48:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="rpObkymi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729434AbgGOHsF (ORCPT ); Wed, 15 Jul 2020 03:48:05 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:17570 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729375AbgGOHsE (ORCPT ); Wed, 15 Jul 2020 03:48:04 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200715074802epoutp024010132620efab0862c972f559acadd3~h3X9dct472952429524epoutp02z for ; Wed, 15 Jul 2020 07:48:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200715074802epoutp024010132620efab0862c972f559acadd3~h3X9dct472952429524epoutp02z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594799282; bh=ESW9/859tMw8nuAmuvv783Rqq0SSjQhD6jWoM46pHBs=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=rpObkymi89L6/4/RXoMUfDFy3Y1nOvRByxGPONEhBkQFFMrcgVwq/JJT+5Msklxk3 1Kv+UhpgVp2ZiBvrETSIohmWNL0Wgi2zJHVKBcIaqsPBV4xv/v9L5K1yDTuzrnDgE4 YVLaNGWTB9AjDNjo2HJWSd6Os6N8hC2/WxnmofRY= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20200715074801epcas2p4f0c39c308a14ee1a955c57762c1f2f7f~h3X83TlR21805018050epcas2p4C; Wed, 15 Jul 2020 07:48:01 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.40.183]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4B68ct6FkpzMqYkZ; Wed, 15 Jul 2020 07:47:58 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id D1.B5.19322.EA4BE0F5; Wed, 15 Jul 2020 16:47:58 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20200715074758epcas2p31bd668e519f59a47268bb086363b1826~h3X5xSgHC2699126991epcas2p3a; Wed, 15 Jul 2020 07:47:58 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200715074758epsmtrp2969ddc092d18a51e27034a43d89031c4~h3X5wZuAB3059730597epsmtrp2i; Wed, 15 Jul 2020 07:47:58 +0000 (GMT) X-AuditID: b6c32a45-7adff70000004b7a-9e-5f0eb4aef711 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 91.97.08303.EA4BE0F5; Wed, 15 Jul 2020 16:47:58 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200715074757epsmtip224cfbcf25d33244985e6bf548b44b2be~h3X5j-Ru53053030530epsmtip2q; Wed, 15 Jul 2020 07:47:57 +0000 (GMT) From: Kiwoong Kim 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 Subject: [PATCH v6 1/3] ufs: introduce a callback to get info of command completion Date: Wed, 15 Jul 2020 16:39:55 +0900 Message-Id: <770fe25cc0210c80fe7a1083a2d31a479afaa548.1594798514.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmqe66LXzxBscPy1o8mLeNzWJv2wl2 i5c/r7JZHHzYyWIx7cNPZotP65exWvz6u57dYvXiBywWi25sY7K4ueUoi0X39R1sFsuP/2Oy 6Lp7g9Fi6b+3LA58HpeveHtc7utl8piw6ACjx/f1HWweH5/eYvHo27KK0ePzJjmP9gPdTAEc UTk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUB3KymU JeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKDA0L9IoTc4tL89L1kvNzrQwNDIxMgSoT cjKuT5/PVjBXsGL9k1a2BsY1fF2MnBwSAiYS/ZuusHYxcnEICexglHj0axkLhPOJUWLGxJ+M IFVCAp8ZJY7dLITpuLD4N1THLkaJ3+ufQnX8YJRoebWHBaSKTUBT4unNqUwgCRGBzUwSrxbc ZwZJMAuoS+yacIIJxBYWCJX43vCQFcRmEVCVOPRkBdg6XoFoiZ279rFArJOTuHmuE6yXU8BS Yt2k8+yobC6gmqkcEq27F7BDNLhIzP70mRHCFpZ4dXwLVFxK4vO7vWwQdr3EvqkNrBDNPYwS T/f9g2owlpj1rB3I5gC6VFNi/S59EFNCQFniyC0WiPv5JDoO/2WHCPNKdLQJQ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g3PbfYsMAoL7Vcrzgxt7g0L10vOT93EyM4FrS0djDu WfVB7xAjEwfjIUYJDmYlEV4eLt54Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rxfZy2MExJITyxJ zU5NLUgtgskycXBKNTAt3h7j+vxTilWj507llwq2q8t11MWaX/5/NGn//+jeTeIsv3Tdj/A+ OPhhv+GL+7sezDj8TFx6m71lmKPS5KzIg8lHFyrU/6r+euF7Oo+RsO3Loht69q03uidcTX5Z 1r//kcGfyXEvbBNWntv/4L9CzIcHRp6yNdOcROV03AP/Z9zZ/ddY+/eiBpl6HoFwC9eNW+vl JnlvqMx5a2q4bukKsYfWopduZP2W2ptqlSza48NTI+IzbZrUN63Y3CDFO4/rmI0OfjK5UcXS JHmnVEM+5lqvr9jtBxvnf0xt++YTMG9KGZd7h9JmjlczuPUfhkq/men8p5p9xeTtFwsWBfvm hDrJz7l0vf+GzOH70ReUWIozEg21mIuKEwF2Wahf9AIAAA== X-CMS-MailID: 20200715074758epcas2p31bd668e519f59a47268bb086363b1826 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200715074758epcas2p31bd668e519f59a47268bb086363b1826 References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Some SoC specific might need command history for various reasons, such as stacking command contexts in system memory to check for debugging in the future or scaling some DVFS knobs to boost IO throughput. What you would do with the information could be variant per SoC vendor. Signed-off-by: Kiwoong Kim Acked-by: Stanley Chu Reviewed-by: Avri Altman Tested-by: Kiwoong Kim --- drivers/scsi/ufs/ufshcd.c | 1 + drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 292af12..092480a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4884,6 +4884,7 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, lrbp = &hba->lrb[index]; lrbp->compl_time_stamp = ktime_get(); cmd = lrbp->cmd; + ufshcd_vops_compl_xfer_req(hba, index, (cmd) ? true : false); if (cmd) { ufshcd_add_command_trace(hba, index, "complete"); result = ufshcd_transfer_rsp_status(hba, lrbp); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index c774012..e5353d6 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -294,6 +294,7 @@ struct ufs_hba_variant_ops { struct ufs_pa_layer_attr *, struct ufs_pa_layer_attr *); void (*setup_xfer_req)(struct ufs_hba *, int, bool); + void (*compl_xfer_req)(struct ufs_hba *hba, int tag, bool is_scsi); void (*setup_task_mgmt)(struct ufs_hba *, int, u8); void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme, enum ufs_notify_change_status); @@ -1070,6 +1071,13 @@ static inline void ufshcd_vops_setup_xfer_req(struct ufs_hba *hba, int tag, return hba->vops->setup_xfer_req(hba, tag, is_scsi_cmd); } +static inline void ufshcd_vops_compl_xfer_req(struct ufs_hba *hba, + int tag, bool is_scsi) +{ + if (hba->vops && hba->vops->compl_xfer_req) + hba->vops->compl_xfer_req(hba, tag, is_scsi); +} + static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba, int tag, u8 tm_function) { From patchwork Wed Jul 15 07:39:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11664375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2A24138C for ; Wed, 15 Jul 2020 07:48:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D64B2072E for ; Wed, 15 Jul 2020 07:48:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="FW1+6jbn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbgGOHsI (ORCPT ); Wed, 15 Jul 2020 03:48:08 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:31379 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729377AbgGOHsH (ORCPT ); Wed, 15 Jul 2020 03:48:07 -0400 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200715074803epoutp03666b8b4e7091f00009d08239bedefcbe~h3X_wkoXq1563615636epoutp03B for ; Wed, 15 Jul 2020 07:48:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200715074803epoutp03666b8b4e7091f00009d08239bedefcbe~h3X_wkoXq1563615636epoutp03B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594799283; bh=WzinotoHMl+6qWjtls4Q749DNmSppu/jolSUz7lm4x8=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=FW1+6jbnvitzNv6+YpxRx7x1TcW9jOS2X0w8euYzIGSzbAQ+0D9/We2yBwx6/g3H5 g1guC1GssIq4D9GSiruwBF9JGi1IIkGamozX7udj5CxsTAOrxX3NNmTq7iFsjwRhPo NIz5PwtH+pF4+GCK8+6KmBSNSIcCYKOtEv/dkLjE= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20200715074802epcas2p21a1dd13be1d39c7fb7ef650353e1e6b7~h3X9-fqpU0609106091epcas2p2p; Wed, 15 Jul 2020 07:48:02 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.40.186]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4B68cw4kk7zMqYks; Wed, 15 Jul 2020 07:48:00 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.54.27441.FA4BE0F5; Wed, 15 Jul 2020 16:47:59 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20200715074758epcas2p117bed09c65271199ac0008a5a1564570~h3X6YLak12828628286epcas2p1m; Wed, 15 Jul 2020 07:47:58 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200715074758epsmtrp20488cd24a0a4f05abf5f44ff69b5d145~h3X6XTe6Z3059830598epsmtrp2f; Wed, 15 Jul 2020 07:47:58 +0000 (GMT) X-AuditID: b6c32a47-fc5ff70000006b31-66-5f0eb4af562b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B2.00.08382.EA4BE0F5; Wed, 15 Jul 2020 16:47:58 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200715074758epsmtip24299d7d3fd2b5ea6dd7f2030ad8a8c36~h3X6GTK_72959329593epsmtip2W; Wed, 15 Jul 2020 07:47:58 +0000 (GMT) From: Kiwoong Kim 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 Subject: [PATCH v6 2/3] ufs: exynos: introduce command history Date: Wed, 15 Jul 2020 16:39:56 +0900 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJJsWRmVeSWpSXmKPExsWy7bCmqe76LXzxBkfPsVs8mLeNzWJv2wl2 i5c/r7JZHHzYyWIx7cNPZotP65exWvz6u57dYvXiBywWi25sY7K4ueUoi0X39R1sFsuP/2Oy 6Lp7g9Fi6b+3LA58HpeveHtc7utl8piw6ACjx/f1HWweH5/eYvHo27KK0ePzJjmP9gPdTAEc UTk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUB3KymU JeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVILUnIKDA0L9IoTc4tL89L1kvNzrQwNDIxMgSoT cjJ2Hn/BWrA1sWLxww62BsbrAV2MnBwSAiYSr9omMnUxcnEICexglOjd0g3lfGKU+DS/jxWk SkjgG6PEyqmxMB1TXs9khijayyjx6/1SqKIfjBLr18qA2GwCmhJPb04FmyQisJlJ4tWC+8wg CWYBdYldE04wgdjCAnYSD4/fAmtmEVCVmHJ7CWMXIwcHr0C0RPMsZohlchI3z3WC2ZwClhLr Jp1nR2VzAdVM5ZDoO36CFaLBReLl/09MELawxKvjW9ghbCmJz+/2skHY9RL7pjawQjT3MEo8 3fePESJhLDHrWTvYEcxAH6zfpQ9iSggoSxy5xQJxPp9Ex+G/7BBhXomONiGIRmWJX5MmQw2R lJh58w7UVg+J+zvnQAMUaNPOK8eZJzDKz0JYsICRcRWjWGpBcW56arFRgTFy5G1iBKdRLfcd jDPeftA7xMjEwXiIUYKDWUmEl4eLN16INyWxsiq1KD++qDQntfgQoykwHCcyS4km5wMTeV5J vKGpkZmZgaWphamZkYWSOG+x1YU4IYH0xJLU7NTUgtQimD4mDk6pBiY7afNv8u84kxW99ZK/ Kn0s+mnWoPI44fKhYu9ZG1Sm6cfxa9ZKJofuact/eKmupOjY605z3jcpz9Wuvv/e92lSa7fM JVXZr8UOR9a4nw54UF0h8Ku8tZT5///Nzme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ut+XxLW1w/vzd6P6EbzWB7MfzPvEVT07ePCl/Tol38t1t/fuPR/x3P7bb bm6rqo/jn1Q7H5k46bsP7r2bd1L03bmMVQbLSlJWbXvjtLvT6cPFmFqXr5XHXyy/KOa37sWC /lU1PuZPm9VmKD4+c2e6EktxRqKhFnNRcSIAEQTicPICAAA= X-CMS-MailID: 20200715074758epcas2p117bed09c65271199ac0008a5a1564570 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200715074758epcas2p117bed09c65271199ac0008a5a1564570 References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 Tested-by: Kiwoong Kim Reviewed-by: Avri Altman --- drivers/scsi/ufs/Kconfig | 14 +++ drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/ufs-exynos-dbg.c | 199 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufs-exynos-if.h | 17 ++++ drivers/scsi/ufs/ufs-exynos.c | 27 ++++++ drivers/scsi/ufs/ufs-exynos.h | 29 ++++++ 6 files changed, 287 insertions(+) create mode 100644 drivers/scsi/ufs/ufs-exynos-dbg.c create mode 100644 drivers/scsi/ufs/ufs-exynos-if.h diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig index 8cd9026..c946d8f 100644 --- a/drivers/scsi/ufs/Kconfig +++ b/drivers/scsi/ufs/Kconfig @@ -172,3 +172,17 @@ config SCSI_UFS_EXYNOS Select this if you have UFS host controller on EXYNOS chipset. If unsure, say N. + +config SCSI_UFS_EXYNOS_DBG + bool "EXYNOS specific debug functions" + default n + depends on SCSI_UFS_EXYNOS + help + 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 + EXYNOS specific, such as vendor specific hardware contexts. + + Select this if you want to get and print the information. + If unsure, say N. diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile index f0c5b95..ee09961 100644 --- a/drivers/scsi/ufs/Makefile +++ b/drivers/scsi/ufs/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-d obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o obj-$(CONFIG_SCSI_UFS_EXYNOS) += ufs-exynos.o +obj-$(CONFIG_SCSI_UFS_EXYNOS_DBG) += ufs-exynos-dbg.o obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-y += ufshcd.o ufs-sysfs.o ufshcd-core-$(CONFIG_SCSI_UFS_BSG) += ufs_bsg.o diff --git a/drivers/scsi/ufs/ufs-exynos-dbg.c b/drivers/scsi/ufs/ufs-exynos-dbg.c new file mode 100644 index 0000000..e1f1452 --- /dev/null +++ b/drivers/scsi/ufs/ufs-exynos-dbg.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * UFS Exynos debugging functions + * + * Copyright (C) 2020 Samsung Electronics Co., Ltd. + * Author: Kiwoong Kim + * + */ +#include +#include +#include +#include "ufshcd.h" +#include "ufs-exynos-if.h" + +#define MAX_CMD_LOGS 32 + +struct cmd_data { + unsigned int tag; + u32 sct; + u64 lba; + u64 start_time; + u64 end_time; + u64 outstanding_reqs; + int retries; + u8 op; +}; + +struct ufs_cmd_info { + u32 total; + u32 last; + struct cmd_data data[MAX_CMD_LOGS]; + struct cmd_data *pdata[MAX_CMD_LOGS]; +}; + +/* + * This structure points out several contexts on debugging + * per one host instant. + * Now command history exists in here but later handle may + * contains some mmio base addresses including vendor specific + * regions to get hardware contexts. + */ +struct ufs_s_dbg_mgr { + struct ufs_exynos_handle *handle; + int active; + u64 first_time; + u64 time; + + /* cmd log */ + struct ufs_cmd_info cmd_info; + struct cmd_data cmd_log; /* temp buffer to put */ + spinlock_t cmd_lock; +}; + +static void ufs_s_print_cmd_log(struct ufs_s_dbg_mgr *mgr, struct device *dev) +{ + struct ufs_cmd_info *cmd_info = &mgr->cmd_info; + struct cmd_data *data; + u32 i, idx; + u32 last; + u32 max = MAX_CMD_LOGS; + unsigned long flags; + u32 total; + + spin_lock_irqsave(&mgr->cmd_lock, flags); + total = cmd_info->total; + if (cmd_info->total < max) + max = cmd_info->total; + last = (cmd_info->last + MAX_CMD_LOGS - 1) % MAX_CMD_LOGS; + spin_unlock_irqrestore(&mgr->cmd_lock, flags); + + dev_err(dev, ":---------------------------------------------------\n"); + dev_err(dev, ":\t\tSCSI CMD(%u)\n", total - 1); + dev_err(dev, ":---------------------------------------------------\n"); + dev_err(dev, ":OP, TAG, LBA, SCT, RETRIES, STIME, ETIME, REQS\n\n"); + + idx = (last == max - 1) ? 0 : last + 1; + 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, + data->start_time, data->end_time, data->outstanding_reqs); + idx = (idx == max - 1) ? 0 : idx + 1; + } +} + +static void ufs_s_put_cmd_log(struct ufs_s_dbg_mgr *mgr, + struct cmd_data *cmd_data) +{ + struct ufs_cmd_info *cmd_info = &mgr->cmd_info; + unsigned long flags; + struct cmd_data *pdata; + + spin_lock_irqsave(&mgr->cmd_lock, flags); + pdata = &cmd_info->data[cmd_info->last]; + ++cmd_info->total; + ++cmd_info->last; + cmd_info->last = cmd_info->last % MAX_CMD_LOGS; + spin_unlock_irqrestore(&mgr->cmd_lock, flags); + + pdata->op = cmd_data->op; + pdata->tag = cmd_data->tag; + pdata->lba = cmd_data->lba; + pdata->sct = cmd_data->sct; + pdata->retries = cmd_data->retries; + pdata->start_time = cmd_data->start_time; + pdata->end_time = 0; + pdata->outstanding_reqs = cmd_data->outstanding_reqs; + cmd_info->pdata[cmd_data->tag] = pdata; +} + +/* + * EXTERNAL FUNCTIONS + * + * There are two classes that are to initialize data structures for debug + * and to define actual behavior. + */ +void exynos_ufs_dump_info(struct ufs_exynos_handle *handle, struct device *dev) +{ + struct ufs_s_dbg_mgr *mgr = (struct ufs_s_dbg_mgr *)handle->private; + + if (mgr->active == 0) + goto out; + + 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; +out: + return; +} + +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]), &lba); + put_unaligned(cpu_to_le16(*(u16 *)cmd->cmnd[7]), &sct); + 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 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 "); +MODULE_DESCRIPTION("Exynos UFS debug information"); +MODULE_LICENSE("GPL v2"); +MODULE_VERSION("0.1"); diff --git a/drivers/scsi/ufs/ufs-exynos-if.h b/drivers/scsi/ufs/ufs-exynos-if.h new file mode 100644 index 0000000..c746f59 --- /dev/null +++ b/drivers/scsi/ufs/ufs-exynos-if.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * UFS Exynos debugging functions + * + * Copyright (C) 2020 Samsung Electronics Co., Ltd. + * Author: Kiwoong Kim + * + */ +#ifndef _UFS_EXYNOS_IF_H_ +#define _UFS_EXYNOS_IF_H_ + +/* more members would be added in the future */ +struct ufs_exynos_handle { + void *private; +}; + +#endif /* _UFS_EXYNOS_IF_H_ */ diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c index 440f2af..53b9d6e 100644 --- a/drivers/scsi/ufs/ufs-exynos.c +++ b/drivers/scsi/ufs/ufs-exynos.c @@ -700,12 +700,26 @@ static int exynos_ufs_post_pwr_mode(struct ufs_hba *hba, return 0; } +static void exynos_ufs_cmd_log(struct ufs_hba *hba, int tag, int start) +{ + struct exynos_ufs *ufs = ufshcd_get_variant(hba); + struct ufs_exynos_handle *handle = &ufs->handle; + + if (start == 1) + exynos_ufs_cmd_log_start(handle, hba, tag); + else if (start == 2) + exynos_ufs_cmd_log_end(handle, hba, tag); +} + static void exynos_ufs_specify_nexus_t_xfer_req(struct ufs_hba *hba, int tag, bool op) { struct exynos_ufs *ufs = ufshcd_get_variant(hba); u32 type; + if (op) + exynos_ufs_cmd_log(hba, tag, 1); + type = hci_readl(ufs, HCI_UTRL_NEXUS_TYPE); if (op) @@ -714,6 +728,12 @@ static void exynos_ufs_specify_nexus_t_xfer_req(struct ufs_hba *hba, hci_writel(ufs, type & ~(1 << tag), HCI_UTRL_NEXUS_TYPE); } +static void exynos_ufs_compl_xfer_req(struct ufs_hba *hba, int tag, bool op) +{ + if (op) + exynos_ufs_cmd_log(hba, tag, 0); +} + static void exynos_ufs_specify_nexus_t_tm_req(struct ufs_hba *hba, int tag, u8 func) { @@ -1008,6 +1028,12 @@ static int exynos_ufs_init(struct ufs_hba *hba) goto out; exynos_ufs_specify_phy_time_attr(ufs); exynos_ufs_config_smu(ufs); + + /* init dbg */ + ret = exynos_ufs_init_dbg(&ufs->handle, dev); + if (ret) + return ret; + spin_lock_init(&ufs->dbg_lock); return 0; phy_off: @@ -1217,6 +1243,7 @@ static struct ufs_hba_variant_ops ufs_hba_exynos_ops = { .link_startup_notify = exynos_ufs_link_startup_notify, .pwr_change_notify = exynos_ufs_pwr_change_notify, .setup_xfer_req = exynos_ufs_specify_nexus_t_xfer_req, + .compl_xfer_req = exynos_ufs_compl_xfer_req, .setup_task_mgmt = exynos_ufs_specify_nexus_t_tm_req, .hibern8_notify = exynos_ufs_hibern8_notify, .suspend = exynos_ufs_suspend, diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h index 76d6e39..b9cb517 100644 --- a/drivers/scsi/ufs/ufs-exynos.h +++ b/drivers/scsi/ufs/ufs-exynos.h @@ -8,6 +8,7 @@ #ifndef _UFS_EXYNOS_H_ #define _UFS_EXYNOS_H_ +#include "ufs-exynos-if.h" /* * UNIPRO registers @@ -212,6 +213,10 @@ struct exynos_ufs { #define EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL BIT(2) #define EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX BIT(3) #define EXYNOS_UFS_OPT_USE_SW_HIBERN8_TIMER BIT(4) + + struct ufs_exynos_handle handle; + spinlock_t dbg_lock; + int under_dump; }; #define for_each_ufs_rx_lane(ufs, i) \ @@ -284,4 +289,28 @@ struct exynos_ufs_uic_attr exynos7_uic_attr = { .rx_hs_g3_prep_sync_len_cap = PREP_LEN(0xf), .pa_dbg_option_suite = 0x30103, }; + +/* public function declarations */ +#ifdef CONFIG_SCSI_UFS_EXYNOS_DBG +void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, + struct ufs_hba *hba, int tag); +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); +#else +void exynos_ufs_cmd_log_start(struct ufs_exynos_handle *handle, + struct ufs_hba *hba, int tag) +{ +} + +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) +{ + return 0; +} +#endif #endif /* _UFS_EXYNOS_H_ */ From patchwork Wed Jul 15 07:39:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 11664377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D83C138C for ; Wed, 15 Jul 2020 07:48:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 826472074B for ; Wed, 15 Jul 2020 07:48:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="HGRz47B3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729444AbgGOHsK (ORCPT ); Wed, 15 Jul 2020 03:48:10 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:31404 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729430AbgGOHsJ (ORCPT ); Wed, 15 Jul 2020 03:48:09 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200715074804epoutp03d98735fb370ca86424e67186721b3ac9~h3X--ju5e1592215922epoutp03r for ; Wed, 15 Jul 2020 07:48:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200715074804epoutp03d98735fb370ca86424e67186721b3ac9~h3X--ju5e1592215922epoutp03r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594799284; bh=8xOeQ3Mw86ciSgBzQ3w+8aDLYwqSJxwEJ6HIro0l/s4=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=HGRz47B3XhCiz3WPBHoC53al/kgKgJyDL1WN6kOcz9YIzm8bBQKE4Gob8mztZCewV ebIwC53+aiE+c+USJ+OelFNQfCyy/dTht8IFgZQmgkGjOpWfAizb+EEtUoswzSzJpB Lt9J3+TVdHws0fqaFalbTPiVV36FrpH1f5gC1Occ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20200715074804epcas2p16edd3d57232ae6e05f1f5a63e558dedf~h3X-c0pSx2828228282epcas2p1M; Wed, 15 Jul 2020 07:48:04 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.40.182]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4B68cx0RrRzMqYmK; Wed, 15 Jul 2020 07:48:01 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 43.0A.27013.FA4BE0F5; Wed, 15 Jul 2020 16:48:00 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20200715074759epcas2p2a2046f8fc8548601d644089c141ab7cd~h3X6y50Bf2918829188epcas2p2i; Wed, 15 Jul 2020 07:47:59 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200715074759epsmtrp2c7bd5c868f2643c20e0bfb223d101058~h3X6yLmDl3059630596epsmtrp2b; Wed, 15 Jul 2020 07:47:59 +0000 (GMT) X-AuditID: b6c32a48-d35ff70000006985-04-5f0eb4af2a17 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id A2.97.08303.FA4BE0F5; Wed, 15 Jul 2020 16:47:59 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [12.36.155.120]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200715074759epsmtip24060bb84902a7442bc85ca7947d3e216~h3X6iAncN2906829068epsmtip2r; Wed, 15 Jul 2020 07:47:59 +0000 (GMT) From: Kiwoong Kim 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 Subject: [PATCH v6 3/3] ufs: exynos: implement dbg_register_dump Date: Wed, 15 Jul 2020 16:39:57 +0900 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To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lRs9ffxR8uCttzvx9dcpz/81eNe1RaPW/k6LxyfMuZCeGVF8qWD5tluSB8Hmi NzmZtticfG1+mL2u7e6Whmj760dmaSukt5/ffHzTLqYTa28fN7AJ6Zh4ZItLYw7nT6l5+S// /mZsczz+c35t7ZXvD2NjXJRYijMSDbWYi4oTAcYhL/vxAgAA X-CMS-MailID: 20200715074759epcas2p2a2046f8fc8548601d644089c141ab7cd X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200715074759epcas2p2a2046f8fc8548601d644089c141ab7cd References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 Tested-by: Kiwoong Kim Reviewed-by: Avri Altman --- 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_ */