From patchwork Tue May 22 22:28:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10419687 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 7B2636016C for ; Tue, 22 May 2018 22:29:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 623C328C6C for ; Tue, 22 May 2018 22:29:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55C9A28F26; Tue, 22 May 2018 22:29:18 +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 E5AAC28C6C for ; Tue, 22 May 2018 22:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753406AbeEVW3E (ORCPT ); Tue, 22 May 2018 18:29:04 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38572 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753379AbeEVW21 (ORCPT ); Tue, 22 May 2018 18:28:27 -0400 Received: by mail-pl0-f66.google.com with SMTP id c11-v6so11739655plr.5 for ; Tue, 22 May 2018 15:28:27 -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=QKcKcRFDM+kZMuWTKwR5gZ8Wzy562GkTub02J8EN9g8=; b=hfPJi7b5gEYXO4UH0/nQh3e2IgJeq0G9TcziX0fJmeuQp+3QCYl9u1VGnC26dyTKFM quU1I6jHXGz6WQTCQkbCPayPeXyGAHgeQ1Nqh2cBAZDCD9QZzlJxPTqpbUYTRQYstIHh PoOCGcEnlcS3CkLNSyTEbTTkPjHzXClHyTLfYuTvqIeLkNKUHR7I8v6J3bo53JQP0s54 yuxTtF2/yreQ3Wu1hf/V+qFoGHeqzGfSD1W1aCiVP2tQIhUe8yhI37OBjy+b568ofQrx Ki2BdGWuC/y4KzwPAEkdQgifCy1o2ZtHMCGSwLLsC5RMssCsNDVhYUQv4I5WY0FT4ZzC SURg== 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=QKcKcRFDM+kZMuWTKwR5gZ8Wzy562GkTub02J8EN9g8=; b=ZsgZ3Qf+ilk70pIaQ4mP6Ygtro8rdMiwFEjUhuQaMRYvodOAhhm1W7xJoydWrAxfoP 1K5NQr6aZaaPWWtbgzpRB820Xg2gt6fiLAu/MOhm/7L5VUg3AdiKOA4vSoHpgjTIIqGh 236u5wAG5r7UT3OIPIDtHEdFa0r2ygEIAb+vlq3IuSx7rwIcWwZaA/vSZy/Ny4KavTra Yun8vKbQZyKf4HTCDs3cru5yrxNu0Ing4Y3xYY/3fAc15RCXGLVR/j2HUWtNZNVFlQsK 40rjgmW/slsPTXyeiUtEy1Dq840veWxNyzvjy3PRBAPO7hkvpHigpMY+PCuNe6jdqT1F 1xxg== X-Gm-Message-State: ALKqPwdw70DFR2LLMTVYqPJLXKt5WmSxotMAc3DvB9Adx3vID7mQfNpn v8VlgrEianYtFHDB3TZWOfOcyA== X-Google-Smtp-Source: AB8JxZq0jHDHSClsU97Ym3W3HyJO+RkLXs0YY7voXo66FvqhcVf1SrWwoE1uzk4f1OBotenDmCe0OA== X-Received: by 2002:a17:902:9004:: with SMTP id a4-v6mr299673plp.143.1527028106482; Tue, 22 May 2018 15:28:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 15:28:25 -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 Subject: [PATCH 4/5] PCI/AER: Add sysfs attributes for rootport cumulative stats Date: Tue, 22 May 2018 15:28:04 -0700 Message-Id: <20180522222805.80314-5-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 for rootport statistics (that are cumulative of all the ERR_* messages seen on this PCI hierarchy). Signed-off-by: Rajat Jain --- drivers/pci/pcie/aer/aerdrv.h | 2 ++ drivers/pci/pcie/aer/aerdrv_core.c | 2 ++ drivers/pci/pcie/aer/aerdrv_stats.c | 31 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h index 048fbd7c9633..77d8355551d9 100644 --- a/drivers/pci/pcie/aer/aerdrv.h +++ b/drivers/pci/pcie/aer/aerdrv.h @@ -88,6 +88,8 @@ irqreturn_t aer_irq(int irq, void *context); 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); +void pci_rootport_aer_stats_incr(struct pci_dev *pdev, + struct aer_err_source *e_src); extern const char *aer_correctable_error_string[AER_MAX_TYPEOF_CORRECTABLE_ERRS]; diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index 42a6f913069a..0f70e22563f3 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c @@ -424,6 +424,8 @@ static void aer_isr_one_error(struct pcie_device *p_device, struct aer_rpc *rpc = get_service_data(p_device); struct aer_err_info *e_info = &rpc->e_info; + pci_rootport_aer_stats_incr(p_device->port, e_src); + /* * There is a possibility that both correctable error and * uncorrectable error being logged. Report correctable error first. diff --git a/drivers/pci/pcie/aer/aerdrv_stats.c b/drivers/pci/pcie/aer/aerdrv_stats.c index 5f0a6e144f56..a526e26c8683 100644 --- a/drivers/pci/pcie/aer/aerdrv_stats.c +++ b/drivers/pci/pcie/aer/aerdrv_stats.c @@ -60,6 +60,9 @@ static DEVICE_ATTR_RO(field) aer_stats_aggregate_attr(dev_total_cor_errs); aer_stats_aggregate_attr(dev_total_fatal_errs); aer_stats_aggregate_attr(dev_total_nonfatal_errs); +aer_stats_aggregate_attr(rootport_total_cor_errs); +aer_stats_aggregate_attr(rootport_total_fatal_errs); +aer_stats_aggregate_attr(rootport_total_nonfatal_errs); #define aer_stats_breakdown_attr(field, stats_array, strings_array) \ static ssize_t \ @@ -90,6 +93,9 @@ static struct attribute *aer_stats_attrs[] __ro_after_init = { &dev_attr_dev_total_nonfatal_errs.attr, &dev_attr_dev_breakdown_correctable.attr, &dev_attr_dev_breakdown_uncorrectable.attr, + &dev_attr_rootport_total_cor_errs.attr, + &dev_attr_rootport_total_fatal_errs.attr, + &dev_attr_rootport_total_nonfatal_errs.attr, NULL }; @@ -102,6 +108,12 @@ static umode_t aer_stats_attrs_are_visible(struct kobject *kobj, if (!pdev->aer_stats) return 0; + if ((a == &dev_attr_rootport_total_cor_errs.attr || + a == &dev_attr_rootport_total_fatal_errs.attr || + a == &dev_attr_rootport_total_nonfatal_errs.attr) && + pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) + return 0; + return a->mode; } @@ -144,6 +156,25 @@ void pci_dev_aer_stats_incr(struct pci_dev *pdev, struct aer_err_info *info) counter[i]++; } +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 (unlikely(!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++; + } +} + int pci_aer_stats_init(struct pci_dev *pdev) { pdev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL);