Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1364709pxb; Fri, 21 Jan 2022 16:36:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzkLlgziAqH5tTkcXxm91XIAUGEcFpmFoxi8YtRZUpTC2ocgDNW8JYuwcz/EzHpk30Zdjp X-Received: by 2002:a63:90c9:: with SMTP id a192mr4656037pge.68.1642811796260; Fri, 21 Jan 2022 16:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811796; cv=none; d=google.com; s=arc-20160816; b=fcomrTqogAZGT1zlNvp0r373UbmDpXB17uIzD2xnkKhs/XjvQ/KcCo0gfcWGStQP0q qSOs2nDAxWEOXShuIuVG9FcdIbdAwmOSkgXooJyLxecygoK3oKXaQ2winqdt2UIUhorM PgdgTxVOXoPBVshnugJ+/YcdhMDC9f3UTUYF8EMaw2OjhAi0qGy+k9kdolmI/etT446E Du3lwP+2zo5a5X06YxgFVV+kLK8tmXUqAeyMCXAO+ruJT7IN5kVa1A0UrHIEb9n2wWHp O7ThWRa59N1+UwxnbQnxlY1UhBl91U9EZd7Uh6ISZxCjyGfFDDvxCQYzw5h9DB3nCHLV VA7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=I/eeaD7Dm/sSojUmq9eEFlyVRDRbreiCV1ujxN+W7RE=; b=nz77Sz1kSjvAlqjWlwyvl2rmBOzJPF6RcETwJaZuYXaivryZ7V1bbAId+JIPSOzysI BTeT2CyI8pMELIIB798cxU/FxtLltdHfQ7anknOReSnM4PBoiKluOGPEoyM3N3YcMpeb OjbiyqsixVo/QU/58ygy6n61wQxOCPuWXTlsr1R272xeWj7E7yPPQ7fxGMPsRqEy3G7a th2E/1omz+vX4iQNAztbBXlXYKemStwq6+LgE8B2tb5Ja8Q2QyTUAjxVdPhm8n2CcKsI ELRUMkPBqv3lUrSQInWmYSZ0dA3EgI+MdCXiBK17EFjZf2wFgSVYxsonxWlN/Xx7mrW/ np0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aFlt8xfE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si7061328pfn.59.2022.01.21.16.36.23; Fri, 21 Jan 2022 16:36:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aFlt8xfE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378856AbiAUHKY (ORCPT + 99 others); Fri, 21 Jan 2022 02:10:24 -0500 Received: from mga11.intel.com ([192.55.52.93]:4714 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378849AbiAUHKX (ORCPT ); Fri, 21 Jan 2022 02:10:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642749023; x=1674285023; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=cM6sqe1tElQ75X6OU6MbVxnvuy1jBR7apqeVeis91xo=; b=aFlt8xfE+nQ8If20tCm2aIPGiAuIk+hgBRwpo9fsCZaCTwZiNdJFLS2A 1u6HoPRZU55mz7gdHRsJt5JRuXtnK33Wt+tnfweg4Pdj4ivXm1vtwDh1W zmklA3eJy8IE3GB5V8J5kXc4KtnoJ2A0o5HrMJKERq3lKQat9KBknh78o 0keSK/zoKOhjiejvdy+yXeTGS5B6+FLRp0q2JSTCs3vfFqnwehpKd+j2I 49xjNokR5HGfvv82JFVplVvWBVOOCIkfos5RdY2USLnLZwNZczV+NK5gP B7EjPW28a+8Cmr3tUvnrLuODA2uOeI8NG6DWyDOzMhO8EZ2bdGWY/wQ3g A==; X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="243179422" X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="243179422" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2022 23:10:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="694541074" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.92]) ([10.237.72.92]) by orsmga005.jf.intel.com with ESMTP; 20 Jan 2022 23:10:18 -0800 Subject: Re: [PATCH V3 2/4] mmc: debugfs: Add debug fs entry for mmc driver To: Shaik Sajida Bhanu , quic_asutoshd@quicinc.com, ulf.hansson@linaro.org, agross@kernel.org, bjorn.andersson@linaro.org, linux-mmc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stummala@codeaurora.org, vbadigan@codeaurora.org, quic_rampraka@quicinc.com, quic_pragalla@quicinc.com, sartgarg@codeaurora.org, nitirawa@codeaurora.org, sayalil@codeaurora.org, Liangliang Lu , "Bao D . Nguyen" References: <1642699582-14785-1-git-send-email-quic_c_sbhanu@quicinc.com> <1642699582-14785-3-git-send-email-quic_c_sbhanu@quicinc.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <0886f705-562f-6c8d-f396-60c2244b6375@intel.com> Date: Fri, 21 Jan 2022 09:10:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <1642699582-14785-3-git-send-email-quic_c_sbhanu@quicinc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/01/2022 19:26, Shaik Sajida Bhanu wrote: > Add debug fs entry to query eMMC and SD card errors statistics > > Signed-off-by: Shaik Sajida Bhanu > Signed-off-by: Liangliang Lu > Signed-off-by: Sayali Lokhande > Signed-off-by: Bao D. Nguyen > --- > drivers/mmc/core/debugfs.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 81 insertions(+) > > diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c > index 3fdbc80..f4cb594 100644 > --- a/drivers/mmc/core/debugfs.c > +++ b/drivers/mmc/core/debugfs.c > @@ -223,6 +223,82 @@ static int mmc_clock_opt_set(void *data, u64 val) > DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, > "%llu\n"); > > +static int mmc_err_state_get(void *data, u64 *val) > +{ > + struct mmc_host *host = data; > + > + if (!host) > + return -EINVAL; > + > + *val = host->err_state ? 1 : 0; > + > + return 0; > +} > + > +DEFINE_SIMPLE_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n"); > + > +static int mmc_err_stats_show(struct seq_file *file, void *data) > +{ > + struct mmc_host *host = (struct mmc_host *)file->private; > + const char *desc[MMC_ERR_MAX] = { > + [MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred", > + [MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred", > + [MMC_ERR_DAT_TIMEOUT] = "Data Timeout Occurred", > + [MMC_ERR_DAT_CRC] = "Data CRC Errors Occurred", > + [MMC_ERR_AUTO_CMD] = "Auto-Cmd Error Occurred", > + [MMC_ERR_ADMA] = "ADMA Error Occurred", > + [MMC_ERR_TUNING] = "Tuning Error Occurred", > + [MMC_ERR_CMDQ_RED] = "CMDQ RED Errors", > + [MMC_ERR_CMDQ_GCE] = "CMDQ GCE Errors", > + [MMC_ERR_CMDQ_ICCE] = "CMDQ ICCE Errors", > + [MMC_ERR_REQ_TIMEOUT] = "Request Timedout", > + [MMC_ERR_CMDQ_REQ_TIMEOUT] = "CMDQ Request Timedout", > + [MMC_ERR_ICE_CFG] = "ICE Config Errors", > + }; > + int i; > + > + if (!host) > + return -EINVAL; > + > + if (!host->err_stats_enabled) { > + seq_printf(file, "Not supported by driver\n"); > + return 0; > + } > + > + for (i = 0; i < MMC_ERR_MAX; i++) { > + if (desc[i]) > + seq_printf(file, "# %s:\t %d\n", > + desc[i], host->err_stats[i]); > + } > + > + return 0; > +} > + > +static int mmc_err_stats_open(struct inode *inode, struct file *file) > +{ > + return single_open(file, mmc_err_stats_show, inode->i_private); > +} > + > +static ssize_t mmc_err_stats_write(struct file *filp, const char __user *ubuf, > + size_t cnt, loff_t *ppos) > +{ > + struct mmc_host *host = filp->f_mapping->host->i_private; > + > + if (!host) > + return -EINVAL; > + > + pr_debug("%s: Resetting MMC error statistics\n", __func__); > + memset(host->err_stats, 0, sizeof(host->err_stats)); > + > + return cnt; > +} > + > +static const struct file_operations mmc_err_stats_fops = { > + .open = mmc_err_stats_open, > + .read = seq_read, > + .write = mmc_err_stats_write, > +}; > + > void mmc_add_host_debugfs(struct mmc_host *host) > { > struct dentry *root; > @@ -236,6 +312,11 @@ void mmc_add_host_debugfs(struct mmc_host *host) > debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host, > &mmc_clock_fops); > > + debugfs_create_file("err_state", 0600, root, host, > + &mmc_err_state); Please, let's drop err_state for now > + debugfs_create_file("err_stats", 0600, root, host, > + &mmc_err_stats_fops); > + > #ifdef CONFIG_FAIL_MMC_REQUEST > if (fail_request) > setup_fault_attr(&fail_default_attr, fail_request); >