Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp202929imm; Thu, 21 Jun 2018 16:50:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIkMPf8MzhDOyzDYC/nAq5O9bd79nHNqDtLXuyhpftgds4C4lO8QsY3xRLSpZOumIRsQprT X-Received: by 2002:a62:e03:: with SMTP id w3-v6mr29404956pfi.173.1529625013476; Thu, 21 Jun 2018 16:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529625013; cv=none; d=google.com; s=arc-20160816; b=R3hvc7PMLYxIth5fnP23AZKhGMwuSUlEd95VDQHaqt8yRZSjo1D1zmFZxSgLzqTc9E lIti9nYW1C0jDfMwZpXeVJwElwYwIrFcc26kpm69r2+jHWYjAGdzpaFtf6BX4rQ7tDTd YPsBXencMB4pwj3puFSjmtiq9Mu/E/vz07lQGaWSyPJ+uDKeCNNwnbJquEZ8wpitTe+p wYLe7E6mwGTHEuwkTQ9Q9kMsGIMZkFJt4/VjZbz1/p5my9n3XMa7OZLMEedERYRmOO1u kfL9xKP27djtmSxzmim2vAGhT9M/Vcc+6652ssnWaDlARWoTDKJw3w8OrGRwrk1rYIwj J3AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references:message-id :in-reply-to:date:mime-version:dkim-signature :arc-authentication-results; bh=FP6vlWD22ueiLKj5cfpoh1q4eTUNo7qrzg2b0HHX/Tk=; b=G1HghgNjhZGgvk210m1IZN2N+BiW4lg2hyWFzObbJwU37gMUwDPMsMc1vbIN41D4AP SSm0m/VtDAKGBVdH1D6/vlas2FCdvCz6AY8in0IPp7cYOHS7UUdeAEoRFpkia66gpUBz bkZR6SY/PqrWR2zoESv0q3mYlwlUyakYT2eOxI4L8f9nS7E0VsmSxzsuxyGjmHizB1lT PvOQHovkAY36Ad++Lzxae14IU4MdSoKkGRoIl6GnRlF/EORLyopb4YVf0QVKytf+zs1h ES9/u02w0GXhKBooVzmu/95RG7uj9mE08btf1ey7Lv8EfJlXS0/2I8nLNUKm8MosIyLp QMIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W3lndBPU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34-v6si5748052ple.52.2018.06.21.16.49.59; Thu, 21 Jun 2018 16:50:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W3lndBPU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934035AbeFUXtL (ORCPT + 99 others); Thu, 21 Jun 2018 19:49:11 -0400 Received: from mail-qt0-f202.google.com ([209.85.216.202]:50295 "EHLO mail-qt0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933994AbeFUXtH (ORCPT ); Thu, 21 Jun 2018 19:49:07 -0400 Received: by mail-qt0-f202.google.com with SMTP id z26-v6so3775541qto.17 for ; Thu, 21 Jun 2018 16:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=FP6vlWD22ueiLKj5cfpoh1q4eTUNo7qrzg2b0HHX/Tk=; b=W3lndBPUvopXpwo8aytkZ6NySXbFosaW0jRdyDFDL6NiENMeCeYCNtep4Y9drK8OP/ XbR1mzSL8rFyrHgkppRW0YidVoPnglks9N27vakRKySw3sMN5CCpNebLsCiiesfbDtqW Cv/M6oACFHYG0FXNyeau3lcZTWAud7L7xQ7bIlJH8/UT6l6QgF0ZSJTEBK+5L07UrFc7 unOgv6fnsi88NO1vKE/3qOWOpB1fhD4c7aug+5gKPpM3hhE45VX1WMU36ZG+p9gsNjed YbGxpCGjxwkD6JTVwQNePS2FE5iCf1uiJPcLleFYxuKYBpIGGm7Wfnr7x3LVOTVVNyzJ H3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=FP6vlWD22ueiLKj5cfpoh1q4eTUNo7qrzg2b0HHX/Tk=; b=ePq79PIVbAuD95J2YownEnrcbbeW8OQhz7l6TcXNJCtzPbI5FsjGlBdRJBGCGC1TWd Q6jX+FGnbcbSA5vNcOhMrR2LeZ/tC65R7BXr4KkJdn/1e36pqvrRGfOgeJhuAk37gg9e YkWTl8sFUUtxCMu+Ba9R/TUAOdW+v6E0HUnSDbUUvIWKT3udr0wCLKoI5nMKN8qEuH1H mImPeNVjEdZrnLv18EJZOv/FRJVRcJ7IVDx204ZgiGTZRyQaDDJ1j9bDKH8fG0UILSe3 CFJK7+gWSIgz8cnIqEBZF6Dwtsi4n56ciZspYIUj76RVIsfHYLKwE1Wg1DqHQDwI/L++ wagw== X-Gm-Message-State: APt69E1EaRQPEg3UUBl/uuDLoBw98mHCKJLQVy0NEpJIpwJkuUlzovvt VA8FkLGlv9/ToIzdLR+Ywm6eMl+whyNl MIME-Version: 1.0 X-Received: by 2002:a0c:d2a2:: with SMTP id q31-v6mr14511751qvh.45.1529624946506; Thu, 21 Jun 2018 16:49:06 -0700 (PDT) Date: Thu, 21 Jun 2018 16:48:29 -0700 In-Reply-To: <20180621234829.224566-1-rajatja@google.com> Message-Id: <20180621234829.224566-5-rajatja@google.com> References: <20180621234829.224566-1-rajatja@google.com> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog Subject: [PATCH 4/4] PCI/AER: Add sysfs attributes for rootport cumulative stats From: Rajat Jain To: Bjorn Helgaas , Jonathan Corbet , Philippe Ombredanne , Kate Stewart , Thomas Gleixner , Greg Kroah-Hartman , Frederick Lawler , Oza Pawandeep , Keith Busch , 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 , rajatxjain@gmail.com, helgaas@kernel.org Cc: Rajat Jain Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add sysfs attributes for rootport statistics (that are cumulative of all the ERR_* messages seen on this PCI hierarchy). Signed-off-by: Rajat Jain --- .../testing/sysfs-bus-pci-devices-aer_stats | 28 +++++++++++ drivers/pci/pcie/aer.c | 47 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats index 7dd54bdf910b..3fec94c8e6e2 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats @@ -92,3 +92,31 @@ AtomicOp Egress Blocked 0 TLP Prefix Blocked Error 0 TOTAL_ERR_NONFATAL 0 ------------------------------------------------------------------------- + +============================ +PCIe Rootport AER statistics +============================ +These attributes show up under only the rootports (or root complex event +collectors) that are AER capable. These indicate the number of error messages as +"reported to" the rootport. Please note that the rootports also transmit +(internally) the ERR_* messages for errors seen by the internal rootport PCI +device, so these counters includes them and are thus cumulative of all the error +messages on the PCI hierarchy originating at that root port. + +Where: /sys/bus/pci/devices//aer_stats/aer_rootport_total_err_cor +Date: July 2018 +Kernel Version: 4.19.0 +Contact: linux-pci@vger.kernel.org, rajatja@google.com +Description: Total number of ERR_COR messages reported to rootport. + +Where: /sys/bus/pci/devices//aer_stats/aer_rootport_total_err_fatal +Date: July 2018 +Kernel Version: 4.19.0 +Contact: linux-pci@vger.kernel.org, rajatja@google.com +Description: Total number of ERR_FATAL messages reported to rootport. + +Where: /sys/bus/pci/devices//aer_stats/aer_rootport_total_err_nonfatal +Date: July 2018 +Kernel Version: 4.19.0 +Contact: linux-pci@vger.kernel.org, rajatja@google.com +Description: Total number of ERR_NONFATAL messages reported to rootport. diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 15c6ae4b9754..6801cde534d5 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -597,10 +597,30 @@ aer_stats_dev_attr(aer_dev_nonfatal, dev_nonfatal_errs, aer_uncorrectable_error_string, "ERR_NONFATAL", dev_total_nonfatal_errs); +#define aer_stats_rootport_attr(name, field) \ + static ssize_t \ + name##_show(struct device *dev, struct device_attribute *attr, \ + char *buf) \ +{ \ + struct pci_dev *pdev = to_pci_dev(dev); \ + return sprintf(buf, "%llu\n", pdev->aer_stats->field); \ +} \ +static DEVICE_ATTR_RO(name) + +aer_stats_rootport_attr(aer_rootport_total_err_cor, + rootport_total_cor_errs); +aer_stats_rootport_attr(aer_rootport_total_err_fatal, + rootport_total_fatal_errs); +aer_stats_rootport_attr(aer_rootport_total_err_nonfatal, + rootport_total_nonfatal_errs); + static struct attribute *aer_stats_attrs[] __ro_after_init = { &dev_attr_aer_dev_correctable.attr, &dev_attr_aer_dev_fatal.attr, &dev_attr_aer_dev_nonfatal.attr, + &dev_attr_aer_rootport_total_err_cor.attr, + &dev_attr_aer_rootport_total_err_fatal.attr, + &dev_attr_aer_rootport_total_err_nonfatal.attr, NULL }; @@ -613,6 +633,12 @@ static umode_t aer_stats_attrs_are_visible(struct kobject *kobj, if (!pdev->aer_stats) return 0; + if ((a == &dev_attr_aer_rootport_total_err_cor.attr || + a == &dev_attr_aer_rootport_total_err_fatal.attr || + a == &dev_attr_aer_rootport_total_err_nonfatal.attr) && + pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) + return 0; + return a->mode; } @@ -655,6 +681,25 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev, counter[i]++; } +static void pci_rootport_aer_stats_incr(struct pci_dev *pdev, + struct aer_err_source *e_src) +{ + struct aer_stats *aer_stats = pdev->aer_stats; + + if (!aer_stats) + return; + + if (e_src->status & PCI_ERR_ROOT_COR_RCV) + aer_stats->rootport_total_cor_errs++; + + if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) { + if (e_src->status & PCI_ERR_ROOT_FATAL_RCV) + aer_stats->rootport_total_fatal_errs++; + else + aer_stats->rootport_total_nonfatal_errs++; + } +} + static void __print_tlp_header(struct pci_dev *dev, struct aer_header_log_regs *t) { @@ -1105,6 +1150,8 @@ static void aer_isr_one_error(struct aer_rpc *rpc, struct pci_dev *pdev = rpc->rpd; struct aer_err_info *e_info = &rpc->e_info; + pci_rootport_aer_stats_incr(pdev, e_src); + /* * There is a possibility that both correctable error and * uncorrectable error being logged. Report correctable error first. -- 2.18.0.rc2.346.g013aa6912e-goog