From patchwork Tue May 22 22:28:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10419691 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 DBD8C6016C for ; Tue, 22 May 2018 22:29:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C523428C6C for ; Tue, 22 May 2018 22:29:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B99D928ED1; Tue, 22 May 2018 22:29:20 +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=unavailable 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 5E90F28F2E for ; Tue, 22 May 2018 22:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753367AbeEVW20 (ORCPT ); Tue, 22 May 2018 18:28:26 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:33655 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753298AbeEVW2Y (ORCPT ); Tue, 22 May 2018 18:28:24 -0400 Received: by mail-pl0-f68.google.com with SMTP id n10-v6so11741616plp.0 for ; Tue, 22 May 2018 15:28:24 -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=SRrivjhPDLWdNV30qpcVtjkn9lTsMaVb6ioXmX3jBo0=; b=YgGo/YTnjSddk02ucs49B1gWb4UU/NR5R9CA/Q1kyataQtxeOaYKvYDvfq28TD9uMr FUkqyaq+tNpnYjC9YUvrEiVG8DferPs+UiCQM1D7SKOomxLddMjHcakOdCClHXjuGQrS oIIq839YR+m/929tcKj5GA5H3e63EVFGR0gET3ToWgYOq1mNlCJDthLWVJxzPKibV1cx /Fc9spY5gNBIIg5JUMUv0I12Ivkrbrma2ijY3eCJk+72ne8H2pFbBKqvcKVQRjyDGduG PFMLnFJBKa7qkRmI0vCFzVMjOeVRTfwz2FXJrC2RzMnePLx5kdyQmoqN8jQxzwb167W6 /qXA== 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=SRrivjhPDLWdNV30qpcVtjkn9lTsMaVb6ioXmX3jBo0=; b=LhitUbg4GXl54KT0LFO7aJdhtkPRmMdt8we++/YnBm2LySvLRhB3hvg3/6N6lPb3Qc A8Ae5hGKF5K4VEKis8fuDDnWFHldai7lXO+fw/pZQvcpyHkseBc9rIqX6hR+u4CMWR7o nzDvQEiOPXdKtoaxZUmsx+R+0uhK7IOVyj4zebbGoknLw2IFdsv1YJDenNlp+5Z5pSkV 1bD0LulxXsX6cYbI997TO1UUwtoIoKYAI65TVNDBxLg7jB3QcTSDJP5tWCRl6lipKVGW W5TsIWLGZ8DRb78afoJcgvXj6cJaeDqmJvUBPfWU0J/kzC8FrArJiyaq/sdOfUmUCWgA L+Wg== X-Gm-Message-State: ALKqPwcAKNarFCXDGNANS3ZbOrgpFw4WJ+EWKJ5NXNF8K2VXliNjmDdv ao7k+Uk+GQvNTu6O+3oA7Fx7bQ== X-Google-Smtp-Source: AB8JxZpQ+sSHzqU5dhzLA6U9wKRe/3dc2WmZzYXrqAVDCEMj9tEBB/+oWxAVgnuQMvqrKRq4K+71eQ== X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr283866plo.305.1527028103688; Tue, 22 May 2018 15:28:23 -0700 (PDT) Received: from rajat.mtv.corp.google.com ([2620:0:1000:1501:dc81:9a9e:fdee:decf]) by smtp.gmail.com with ESMTPSA id b72-v6sm34327852pfm.69.2018.05.22.15.28.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 15:28:23 -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 3/5] PCP/AER: Add sysfs attributes to provide breakdown of AERs Date: Tue, 22 May 2018 15:28:03 -0700 Message-Id: <20180522222805.80314-4-rajatja@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180522222805.80314-1-rajatja@google.com> References: <20180522222805.80314-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 --- drivers/pci/pcie/aer/aerdrv.h | 6 ++++++ drivers/pci/pcie/aer/aerdrv_errprint.c | 6 ++++-- drivers/pci/pcie/aer/aerdrv_stats.c | 25 +++++++++++++++++++++++++ 3 files changed, 35 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 87b7119d0a86..5f0a6e144f56 100644 --- a/drivers/pci/pcie/aer/aerdrv_stats.c +++ b/drivers/pci/pcie/aer/aerdrv_stats.c @@ -61,10 +61,35 @@ 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]); \ + } \ + 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 };