Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp133452imm; Tue, 22 May 2018 15:29:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr2AzN+Wa8t4jrggBULxm7no2xGfhieP4Y8Md2AaPqz1lmoDx9a9JMTbsHREPAYFstyuHgH X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr298680pli.267.1527028189274; Tue, 22 May 2018 15:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527028189; cv=none; d=google.com; s=arc-20160816; b=nBzRtDW3pFOc+cn0KZ8fV+uxotx/MGgAVWyJYYgC6eu50zLzSWP2es94jNKPKJjZS3 xJXSY2bSsbn65/732yacYq4e9ZrmHoOTXBk5DNsGy6jdQ7Bh+CEAwbD//J2Vjsa/9l5V gAQHmJHFD1IPkeKGqUvqjVTNfYt/u2PGO60LBTz4KVrASQ6tf1xXmZRiJnP2irpEttvN dLEA7pJYt/MbwEf02wD7P3Ho7Lcleu9EpINJaXJjnFBnUg5rkuKXOC+vYCrZelgt2Bh8 Eoz5AJSmsjd0+MwLLLgD9KowEwKa1ZU5t/OShRb021sh5gFT9obbKecNbh9Q4aOiFdvn e+GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=QKcKcRFDM+kZMuWTKwR5gZ8Wzy562GkTub02J8EN9g8=; b=otvgcJSOaDmqTh5W05chBgW2Pc3Zy04zTtXt64/XL1K7s7qoJL9YvXHGjwvPpj9EuS n5JofSg5XgHr4yavtnuthax15LCVXMrztflyf2EJIexDNz1Kq6I3cAiWGeeiQexZkPvf nRFc0bCTU1owHHO3HhIEFHEf6x4jkomuyq6EZpRFmvPcU4UpNyF0Zytmu0Z4yXELyAzN Y200lozWvjCBhux6myjsbQPN0xEO5SclD0/S3OfUPvJkwKO8RT91GvN3ZOUfwUKfjTnN VpDoG7UP7B8U62q/VjZG4fJzjktmp3ScVo3rbQKdTsdnuO6DtPmq/faKIzoe4EJRPQ7U p6/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hfPJi7b5; 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 v11-v6si10914258pgt.114.2018.05.22.15.29.34; Tue, 22 May 2018 15:29:49 -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=hfPJi7b5; 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 S1753487AbeEVW3E (ORCPT + 99 others); Tue, 22 May 2018 18:29:04 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:34194 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753373AbeEVW21 (ORCPT ); Tue, 22 May 2018 18:28:27 -0400 Received: by mail-pl0-f67.google.com with SMTP id ay10-v6so11742150plb.1 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=Lqtbn+sKgZhSy/bycIikZdIFv+8ijTb+9fU+JthOAUwF5ynQZpK6DhDSruOMYaqt0c GCp3bQIq8utFXVgW6R318t3vrgn7wGfzMN4CaeLWvNnDeZTA0HvXKZgbcB2IjEYtdoJb HRO7ZWyIxbrcLp81xTtgHu6+hDG2FIjyf0OsTNQdGAH07xQOOrVEIf52PByj2RIGl/Mg Sf/2lIllShpnGSbnrtFPHFDNpv9+Nqw6b/ihj/iVg4LNxYuo6x5CONONKzw3wqCyyzMx lgZ9I1bO8Zp9lw4nYqGLQWI+pI4v7LaHUy917NWW10/LB1OucB6anw8RRWh31+IVCd10 51gg== X-Gm-Message-State: ALKqPwdTcMJZUo3BwntA/BTCULjlD4B2H4O2X6ydystZx3L76HxedM4E aDdnmyfBHvxwcQCa62xMgcLuyA== 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-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 --- 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); -- 2.17.0.441.gb46fe60e1d-goog