From patchwork Wed Jun 20 23:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10478889 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 A81C2601D7 for ; Wed, 20 Jun 2018 23:43:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99EEC28599 for ; Wed, 20 Jun 2018 23:43:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E4E6286E5; Wed, 20 Jun 2018 23:43:46 +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 3C79B28599 for ; Wed, 20 Jun 2018 23:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932597AbeFTXnO (ORCPT ); Wed, 20 Jun 2018 19:43:14 -0400 Received: from mail-it0-f73.google.com ([209.85.214.73]:50382 "EHLO mail-it0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933160AbeFTXmF (ORCPT ); Wed, 20 Jun 2018 19:42:05 -0400 Received: by mail-it0-f73.google.com with SMTP id g125-v6so1151879ita.0 for ; Wed, 20 Jun 2018 16:42:04 -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=Fy6bOjKKTweFLCCTIlnpZiRcE4qX5oDENmYHoVBVYu0=; b=EYlFIv/X1rwRRvH6HBeswuuq9mXdgp0FFxajLAYbWnE5gdZ3zbN/3KuG+dYegpkryT 33KcDXWW9Lrv6VIS5f2ji35/kqebqU6s20jnc9zEoSMAFnGvVORwm+EUsjKxVMC0KfLu NWa4tTAp9re+zcIBdEX5Ahj0aOQahK0xUzKHYHG7YEutzcLODtodLH5MkhdcojOaQOtF v1kRJd3ajlizIlHm7FYi3ICF/LuKO/awN40MRlT/ZixXUa2CWWanaIg2kaxl9cJScqEq ZSXjizzronzg5ZP8GwSe128Wqbt7hOS9qnvDZ8JFNZBurxAsxJsc9spgo8vX2hMDBx5e CDoA== 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=Fy6bOjKKTweFLCCTIlnpZiRcE4qX5oDENmYHoVBVYu0=; b=KLwI6QHf1CII/i5th2xtYGlzKZZVzgXxuQ6BgyrpGEGCCPCzUdr7kpvoUBgUZ30Opj nQCxctLjpo29cebNQwyaoq9sIrv2myyCK6uU4AQ4oOGfB4+lWC7+RnTbZoLranxqNj2w 4FhZZdqJo5LJGiU0YzJrRybKgo3OY+D5LBXj5wQQzsq1Y9MWyqsBwGr63ma5Wy04Pzv/ orose+dPlRkF+GceK8BIY3hP+HsUoG/6XEQSLVG0xhhI2mxPeCDl1cW3jhOJWrSPSA1z UNFhaUJ8Z0YhIZR1NM3CD5efjF4FH8+jsmkSI8jenLWJGr1esxsmw45EppspXCN62he7 /MAQ== X-Gm-Message-State: APt69E1eYT2iNSWAvO1dvZtni7yBKZz27+yjVElq3tuD4f31Hg4OFadx lTkgMVPRsZdztYatVxAbw/1mGsIiNgFS X-Google-Smtp-Source: ADUXVKJ3hxZ4qN9tudZm+AqJulChSfUbtz2CoSjp7A+IreDXcm/tXvB56R8D5nvz+iubhXg5MwWKysptnwsg MIME-Version: 1.0 X-Received: by 2002:a24:28c7:: with SMTP id h190-v6mr1716242ith.20.1529538124185; Wed, 20 Jun 2018 16:42:04 -0700 (PDT) Date: Wed, 20 Jun 2018 16:41:45 -0700 In-Reply-To: <20180620234147.48438-1-rajatja@google.com> Message-Id: <20180620234147.48438-3-rajatja@google.com> References: <20180522222805.80314-1-rajatja@google.com> <20180620234147.48438-1-rajatja@google.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog Subject: [PATCH v5 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 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 --- v5: Fix the signature v4: use "%llu" in place of "%llx" v3: Merge everything in aer.c 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..c989bb5bb6f1 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%llu\n", \ + strings_array[i], stats[i]); \ + else if (stats[i]) \ + str += sprintf(str, #stats_array "bit[%d] = 0x%llu\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 };