From patchwork Wed May 23 17:58:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10421989 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFBF76032A for ; Wed, 23 May 2018 17:59:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE70A28DDC for ; Wed, 23 May 2018 17:59:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1DD8290FC; Wed, 23 May 2018 17:59:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A565228DDC for ; Wed, 23 May 2018 17:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933865AbeEWR65 (ORCPT ); Wed, 23 May 2018 13:58:57 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:40237 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933872AbeEWR6u (ORCPT ); Wed, 23 May 2018 13:58:50 -0400 Received: by mail-pl0-f65.google.com with SMTP id t12-v6so13486280plo.7 for ; Wed, 23 May 2018 10:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lGeDCO5KZ5HItt68m3W4CPfVPF88mA0i3ujcMAiFAH4=; b=S5vR2tXAlQ7wefnc3Mvnghw8BBzWzuZLDuTY4FSrhDcvR6PAb4tJipuBF9fcPQE+Nx oHDo35Gv4KQaqMvwsyuwG4z+qFVXEIOCbUu1TxIOGrDlUhX9VrB71+Vzf0im6ExIBr/Y loUuKBKsqCc0abQZyIHYszx+X0WczciTyHTmvwoKEAIYGRetRSnFLXHXe+5CQCO5Lc6E QhxpwgM/JgHcTW7X+abOOo6slGHZyhJqK6rRBzNU+rZn4Nmx7PiNJWUhf+JfZxG5gVk8 o/wWnP3P6dWTmdYNFkz7Otv4ycnhGw9I349jMU5WmsvW1y43Af10kZtkaVOmoXLBeqJY Nvtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lGeDCO5KZ5HItt68m3W4CPfVPF88mA0i3ujcMAiFAH4=; b=gzAggOVZEardbzoYNdxB3XsEeDoGojDWTdtW17iq88jhQYuYDHp8fN+3nWkbVF0fzc 7w2caKfmHCPP3Eobvf98vs6q14opaCAcC/fJQ3u2sI0mdDJS0um/JXTfs40qA3EQ8aVO oKCpLTDtacsGjHPI6Q2ruTQsWcAQ1U5jFbF//C84+AvkmDV/EyQAjUIL5DqyaDKeygdo WY8nFIoUeEcTILIPDJwgO/PRBU7RZKntXGO8c9ACR99dJnXVAz9VX3KaCQsnKw2TNaMR jtLevjscW5+ja+dEt7z8IXd721NtejnjqkRXoCXRjyZzxGh01AnycLEUW3OsEIJPozAG sCGg== X-Gm-Message-State: ALKqPwcN8eprpUTkYzeDLwSojZ8CIHzEXUDr9EJFPljLgVa+Xt1GmDR2 UuJpriHZLWd8CrQ5w9UXAXqlKA== X-Google-Smtp-Source: AB8JxZpANP7RRVLgE9Map1o+daOHFMLJQf8w7bGDmcbQM/YJK0CR6JK8FrlDveuA7A2vvFWsTO/u8g== X-Received: by 2002:a17:902:6f16:: with SMTP id w22-v6mr3860123plk.216.1527098329768; Wed, 23 May 2018 10:58:49 -0700 (PDT) Received: from rajat.mtv.corp.google.com ([2620:0:1000:1501:dc81:9a9e:fdee:decf]) by smtp.gmail.com with ESMTPSA id k186-v6sm41433025pfc.142.2018.05.23.10.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 10:58:49 -0700 (PDT) From: Rajat Jain To: Bjorn Helgaas , Jonathan Corbet , Philippe Ombredanne , Kate Stewart , Thomas Gleixner , Greg Kroah-Hartman , Rajat Jain , Frederick Lawler , Oza Pawandeep , Keith Busch , Gabriele Paoloni , Alexandru Gagniuc , Thomas Tai , "Steven Rostedt (VMware)" , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jes Sorensen , Kyle McMartin Cc: rajatxjain@gmail.com, Rajat Jain Subject: [PATCH v2 3/5] PCI/AER: Add sysfs attributes to provide breakdown of AERs Date: Wed, 23 May 2018 10:58:06 -0700 Message-Id: <20180523175808.28030-4-rajatja@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180523175808.28030-1-rajatja@google.com> References: <20180522222805.80314-1-rajatja@google.com> <20180523175808.28030-1-rajatja@google.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add sysfs attributes to provide breakdown of the AERs seen, into different type of correctable or uncorrectable errors: dev_breakdown_correctable dev_breakdown_uncorrectable Signed-off-by: Rajat Jain --- v2: Use tabs instead of spaces, fix the subject, and print all non zero counters. drivers/pci/pcie/aer/aerdrv.h | 6 ++++++ drivers/pci/pcie/aer/aerdrv_errprint.c | 6 ++++-- drivers/pci/pcie/aer/aerdrv_stats.c | 28 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h index b5d5ad6f2c03..048fbd7c9633 100644 --- a/drivers/pci/pcie/aer/aerdrv.h +++ b/drivers/pci/pcie/aer/aerdrv.h @@ -89,6 +89,12 @@ int pci_aer_stats_init(struct pci_dev *pdev); void pci_aer_stats_exit(struct pci_dev *pdev); void pci_dev_aer_stats_incr(struct pci_dev *pdev, struct aer_err_info *info); +extern const char +*aer_correctable_error_string[AER_MAX_TYPEOF_CORRECTABLE_ERRS]; + +extern const char +*aer_uncorrectable_error_string[AER_MAX_TYPEOF_UNCORRECTABLE_ERRS]; + #ifdef CONFIG_ACPI_APEI int pcie_aer_get_firmware_first(struct pci_dev *pci_dev); #else diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c index 5e8b98deda08..5585f309f1a8 100644 --- a/drivers/pci/pcie/aer/aerdrv_errprint.c +++ b/drivers/pci/pcie/aer/aerdrv_errprint.c @@ -68,7 +68,8 @@ static const char *aer_error_layer[] = { "Transaction Layer" }; -static const char *aer_correctable_error_string[] = { +const char +*aer_correctable_error_string[AER_MAX_TYPEOF_CORRECTABLE_ERRS] = { "Receiver Error", /* Bit Position 0 */ NULL, NULL, @@ -87,7 +88,8 @@ static const char *aer_correctable_error_string[] = { "Header Log Overflow", /* Bit Position 15 */ }; -static const char *aer_uncorrectable_error_string[] = { +const char +*aer_uncorrectable_error_string[AER_MAX_TYPEOF_UNCORRECTABLE_ERRS] = { "Undefined", /* Bit Position 0 */ NULL, NULL, diff --git a/drivers/pci/pcie/aer/aerdrv_stats.c b/drivers/pci/pcie/aer/aerdrv_stats.c index 5555beffef2b..e47321b267f6 100644 --- a/drivers/pci/pcie/aer/aerdrv_stats.c +++ b/drivers/pci/pcie/aer/aerdrv_stats.c @@ -58,10 +58,38 @@ aer_stats_aggregate_attr(dev_total_cor_errs); aer_stats_aggregate_attr(dev_total_fatal_errs); aer_stats_aggregate_attr(dev_total_nonfatal_errs); +#define aer_stats_breakdown_attr(field, stats_array, strings_array) \ + static ssize_t \ + field##_show(struct device *dev, struct device_attribute *attr, \ + char *buf) \ +{ \ + unsigned int i; \ + char *str = buf; \ + struct pci_dev *pdev = to_pci_dev(dev); \ + u64 *stats = pdev->aer_stats->stats_array; \ + for (i = 0; i < ARRAY_SIZE(strings_array); i++) { \ + if (strings_array[i]) \ + str += sprintf(str, "%s = 0x%llx\n", \ + strings_array[i], stats[i]); \ + else if (stats[i]) \ + str += sprintf(str, #stats_array "bit[%d] = 0x%llx\n",\ + i, stats[i]); \ + } \ + return str-buf; \ +} \ +static DEVICE_ATTR_RO(field) + +aer_stats_breakdown_attr(dev_breakdown_correctable, dev_cor_errs, + aer_correctable_error_string); +aer_stats_breakdown_attr(dev_breakdown_uncorrectable, dev_uncor_errs, + aer_uncorrectable_error_string); + static struct attribute *aer_stats_attrs[] __ro_after_init = { &dev_attr_dev_total_cor_errs.attr, &dev_attr_dev_total_fatal_errs.attr, &dev_attr_dev_total_nonfatal_errs.attr, + &dev_attr_dev_breakdown_correctable.attr, + &dev_attr_dev_breakdown_uncorrectable.attr, NULL };