Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp568646pxb; Mon, 25 Apr 2022 16:50:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPNV9B7hJwYErUC7wK/l4qCSrQR1NY479UOqw7OIkx6r9kpnHoZiMbxt2Dn/rnaa4arv5J X-Received: by 2002:a17:90b:4a41:b0:1d9:a086:280b with SMTP id lb1-20020a17090b4a4100b001d9a086280bmr3112120pjb.106.1650930603747; Mon, 25 Apr 2022 16:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650930603; cv=none; d=google.com; s=arc-20160816; b=zVvxz+eVGJL3vukVE/gr1o4vNZ9f7dW8VLIwMOtKzurVblJqU385uwDD/T92TmilnB YxHc3OJixbwm8wj9jloPEhmWF0xPxUZ0UN5D+5MOAQFU6QjSMTWl9sWevZD8y+OZcxxi xsCcSR4QF4vzs/zGv+lCVdNBXyts8W5Od3ldYbo3hbO1JT1gAjIW0VwZ6eqemt8Yer1W O7wzYavntmFeaBuCA1lGdROUWNjDT15XtqKw9gwwH5cG4UDV70/Nf0N5q9eatuqfCudF hEkgqcTOOyJ/apr5lruSXI4XC5OsyGf7R7YSfeNyvNQxUTVsO8xejohkoqBoK09+4n+0 e/qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=BN5wLRGjtLKhwO/YI3QqYiT0K0JR0D0zC9Y19zaVu+w=; b=rcFXHrSIquSTwQFVCYbsjA9ITM2/rbKqTrwJQicAnE57aBKK68sZDw/c7PVNCKQ30Z S3dy65Roc2P0r0zv1QhAtowt4zeZkiBdKmqM2yMCeYYonrTg/DtfSK1oO2BeEResUmCJ HdrglwSAJSEqfjfHHySpHKd0bxBdI0qwLjtjzwgWmfMThk6zdjsGbpI4MH7bRorijDTi DBuY+AwNlFmdG2M/QhYxLuaFQ8atrG+SZ38ercP/LJCUQRDIy+BdgepzrsNZtqTh3DH7 SHC5tZ8/cT1o/YV8WBKXhRFeKkpHE4+Dy+X3BZHgVMBLud4ebhUYU3mutAmbSy7ygCmv TtLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=qFYqaMsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i190-20020a6387c7000000b003ab1f09b880si6005228pge.694.2022.04.25.16.49.47; Mon, 25 Apr 2022 16:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=qFYqaMsP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243176AbiDYQEY (ORCPT + 99 others); Mon, 25 Apr 2022 12:04:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243147AbiDYQEU (ORCPT ); Mon, 25 Apr 2022 12:04:20 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4EAB101FB; Mon, 25 Apr 2022 09:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1650902476; x=1682438476; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=BN5wLRGjtLKhwO/YI3QqYiT0K0JR0D0zC9Y19zaVu+w=; b=qFYqaMsPXXNP9Cr44nM7HF05zNr5lMWPp+cWSGN0wbZqUhRV49+KBC2t 7h4clUUyZPtJVh5k43U7ezM4pXRuvWx1NekU03LW59skrpOvNwaVUcOrl n0UrbNnY/d8s34wc2A+vKQ/3hMA5bMC/ckLlbdOEt9RuiKYxOGPsEg31n Y=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 25 Apr 2022 09:01:15 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 25 Apr 2022 09:01:14 -0700 X-QCInternal: smtphost Received: from c-sbhanu-linux.qualcomm.com ([10.242.50.201]) by ironmsg02-blr.qualcomm.com with ESMTP; 25 Apr 2022 21:30:51 +0530 Received: by c-sbhanu-linux.qualcomm.com (Postfix, from userid 2344807) id A34A0C07; Mon, 25 Apr 2022 21:30:49 +0530 (IST) From: Shaik Sajida Bhanu To: adrian.hunter@intel.com, ulf.hansson@linaro.org, wsa+renesas@sang-engineering.com, yoshihiro.shimoda.uh@renesas.com, linus.walleij@linaro.org, digetx@gmail.com, briannorris@chromium.org, quic_riteshh@quicinc.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, quic_asutoshd@quicinc.com, quic_rampraka@quicinc.com, quic_pragalla@quicinc.com, quic_sartgarg@quicinc.com, quic_nitirawa@quicinc.com, quic_sayalil@quicinc.com, Shaik Sajida Bhanu , Liangliang Lu , "Bao D . Nguyen" Subject: [PATCH V5 3/5] mmc: debugfs: Add debug fs entry for mmc driver Date: Mon, 25 Apr 2022 21:30:41 +0530 Message-Id: <1650902443-26357-4-git-send-email-quic_c_sbhanu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1650902443-26357-1-git-send-email-quic_c_sbhanu@quicinc.com> References: <1650902443-26357-1-git-send-email-quic_c_sbhanu@quicinc.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add debug fs entry to query eMMC and SD card errors statistics Signed-off-by: Liangliang Lu Signed-off-by: Sayali Lokhande Signed-off-by: Bao D. Nguyen Signed-off-by: Shaik Sajida Bhanu --- drivers/mmc/core/debugfs.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 3fdbc80..6aa5a60 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -223,6 +223,59 @@ 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_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", + [MMC_ERR_CTRL_TIMEOUT] = "Controller Timedout errors", + [MMC_ERR_UNEXPECTED_IRQ] = "Unexpected IRQ errors", + }; + int i; + + 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; + + 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 +289,9 @@ 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_stats", 0600, root, host, + &mmc_err_stats_fops); + #ifdef CONFIG_FAIL_MMC_REQUEST if (fail_request) setup_fault_attr(&fail_default_attr, fail_request); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation