From patchwork Wed Jun 20 01:12:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10475759 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 62B76603B5 for ; Wed, 20 Jun 2018 01:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53B59287FA for ; Wed, 20 Jun 2018 01:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 465A32887F; Wed, 20 Jun 2018 01:13:11 +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 47C50287FA for ; Wed, 20 Jun 2018 01:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753765AbeFTBNH (ORCPT ); Tue, 19 Jun 2018 21:13:07 -0400 Received: from mail-ua0-f202.google.com ([209.85.217.202]:49863 "EHLO mail-ua0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbeFTBMZ (ORCPT ); Tue, 19 Jun 2018 21:12:25 -0400 Received: by mail-ua0-f202.google.com with SMTP id d12-v6so504922uak.16 for ; Tue, 19 Jun 2018 18:12:25 -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=3Y+QluKJwrqjzjy8KY30yUXxcpwjF/AHZBdPidFilXs=; b=Xz5SW4joaesf7pBEyzVH/YP4nCqavwPvyLywEK/aCntTgxLyVyPjT+xCWxIoxhsLA+ HPzVndo30GImyXLbqBCmtLK8sO3NDO7lJOrI+UT+hMuuMuKKZVT66yOZPXvdkSOsolc2 vpixwsEy1T0ipVpf+JJOYap6Ag+QZzAlf7OLMHT14HKbYIp76nOPau1d6xLY373EcqwB lOCs77Lr2JoFt/S9IQ/pnyPOf94YdJmhUVR0OdUZOJOBv1UYXURtiyzHBYodx7g9xJHJ xChd42wqzxaUszOx/16/6sjVeIP+KltMbxfdAcvl88ODaLKu84jKdaLCEzOH9rPHKG7r +r+Q== 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=3Y+QluKJwrqjzjy8KY30yUXxcpwjF/AHZBdPidFilXs=; b=YAY3UG4jHVjsbjhyR7w1x1LdxI/htVr9WjeD6ynQG2XkkP/gZQ6LpMVdHP8pJzh2hY Fa6zD+N4cHdfIvm5H7OO54S9CVfkGHFKWnB/h6kjZDs3tf7BiqzivVyD81i4cRF3PkcE pQ57z5J004gQFaqu4jvT1rxe51aFuGofWzHsSo7vBVUn86HxDVFm3KPTDchXspq0f18A 7LXXney2v1tMMSiBnJA/szQg2xpXfQ1wnqoyHYhikxgBMfE9Rgjqj7wWFdzd7DUQFIk5 wgIHbYQG9RMJyP2ZzyXxIdFp5bwiTCsKAPy1dsu2vzw27pZmRXl71xFJxQC4RRwLxId+ 5c9w== X-Gm-Message-State: APt69E3bfemw/qSLh40rukxvTdSzx87y4+j2w7krMaPdRl1yZcXxaVql uHQ2H9jXQ/avco0vglnt78UXIAl6i2Zl X-Google-Smtp-Source: ADUXVKJp5SzZsDSEnCjKx04NWG0HrK86s+Go7SZxaj4r1ed+jutdar4xXWwzk2T5p5udOip69b21A6Hofo0E MIME-Version: 1.0 X-Received: by 2002:a9f:21b4:: with SMTP id 49-v6mr8325832uac.16.1529457144592; Tue, 19 Jun 2018 18:12:24 -0700 (PDT) Date: Tue, 19 Jun 2018 18:12:08 -0700 In-Reply-To: <20180620011210.254601-1-rajatja@google.com> Message-Id: <20180620011210.254601-3-rajatja@google.com> References: <20180619221651.GH33049@bhelgaas-glaptop.roam.corp.google.com> <20180620011210.254601-1-rajatja@google.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog Subject: [PATCH v3 3/5] PCI/AER: Add sysfs attributes to provide breakdown of AERs 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 , Rajat Jain 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 --- v3: Merge everything in aer.c, use "%llu" in place of "%llx" drivers/pci/pcie/aer.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index ce0d675d7bd3..876f03799810 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -587,10 +587,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 };