Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1148505imm; Wed, 23 May 2018 11:02:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrzXEPMw+pVLCqv8IUfcm+hDn5fgG/u1TrbOktddZki8sW8n8FGMMDnN9/tnUtPiXS+8Cxy X-Received: by 2002:a63:82c7:: with SMTP id w190-v6mr2504684pgd.172.1527098551788; Wed, 23 May 2018 11:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527098551; cv=none; d=google.com; s=arc-20160816; b=hDH5MCRLlvelcEqdFzHH8/BWc8eDsBrFFIDtkHDS3gyEhUPZr3wgrhvGc/gnQNwG+Y Fou1KNExlTauT+VsCKqoIFiO6Pd6w6+utL9POswymuUF9xc6S8tyF/IAjz4nXQbjQrUy mtpEi6WcWyPZ7tW0MpMatdQkK1lR3plZRnLrXnRrQHfIza4bk4D1R0E4BzL+OOAic8x7 o9anR8wM/ekBytzFv3GiiVGsbuqPJQa8DFJ4GW2WSYDQ9MBX/hthtsQnPPzAHOT4N6Mz 3ivRs+tY3FoZjKEq51iCOBZO/u07umRICl63nZ87U0FpoIiXWs5+rX7KvCRF2Ra+KK8T Cx+Q== 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=rRJmxrzXnUxJl5YE/ieiOxX3vdnvlw4/Cw16gBRP6I0=; b=KJaQAcbah6ypXjasCkS0noNRu9tQxoVKyej28PVDVOuooPJPU+QZRdWTeTJk5rPvA+ 3ItrhYklqSkbaMph0JQoSPAX6yoGs78wWXqrD+1QsJZgiOlMBsKNxYAh3W9jVOo98ULC gOwiv9/P5i9AXk0tVco75kr7LSTCuaQr+1fH/TEx5PuCojPpFQWEmvZ3+gGatYC8cGb/ AqqtZk0pjxEA45g0H5DWe1Cvp9JkoNvnOF+qQQACMc5/w0TusSM5ut2kxR8jIIu3/Izm eass4dH1/w+k8RkAFHL9ZwnHEgN5sBxFMA9Vl1fT7V1jAjJnQVzJRt2ovFOl3XnYkV8j PSLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=f5WpiZnj; 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 h127-v6si20976272pfb.111.2018.05.23.11.02.10; Wed, 23 May 2018 11:02:31 -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=f5WpiZnj; 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 S933973AbeEWSAH (ORCPT + 99 others); Wed, 23 May 2018 14:00:07 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:44626 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933800AbeEWR6w (ORCPT ); Wed, 23 May 2018 13:58:52 -0400 Received: by mail-pl0-f66.google.com with SMTP id m24-v6so2106200pls.11 for ; Wed, 23 May 2018 10:58:52 -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=rRJmxrzXnUxJl5YE/ieiOxX3vdnvlw4/Cw16gBRP6I0=; b=f5WpiZnjE2Z0ZdMKxx/JMooxieg6CgiFpCXUpYMqRul2gSz+T0stNdzzGG9WV6qfi/ Yg0NKY1ZY56TIV5yNKB2dMbr9BtATvhEA9e27ZFsqMvIhnaNkyW0kmSPiMR4PLrLpOgL dPdcobj0J73n02ClCCFGlsi+FoI18rzI0UK5un24y2NNKWZxQ6r+YsXZLHS2/exLbC81 bxcExxZd6v7vbF73xcKyqleMAQItLshG/qkroF9ZnW+PK4X7DZpHotBqkrzI6yTA83ZM PdGizY2n2qS/PHIp5rl23CkUgobdqqsWHldhTPQ3PdHREwGT4sub6dTgJiFLV3JKoXaG ZOHA== 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=rRJmxrzXnUxJl5YE/ieiOxX3vdnvlw4/Cw16gBRP6I0=; b=jum7XyMiQIXV1DjQgx9zdrrmlBjp+p9ZYbY7QLbWaPgpMm6U6ps/MOXU/LRTxpaRMS ekjp3GJh7inhML03ZchH/x+sY9cmmGfXcjltMQ+03jzgB5K5+dXrf5V/od2/+JgRPhol 0TT5pTrl1NIFgUoG0gt+bXnUHoFjYskxAUeyhkUbuC44nBt2G3NlxRjAk/2zYdmMAhxH 2ULs1K6gi/93P7J3CljFREzKbiHk7zc4OmdVB4EGNgLOxlGOiwje/6/KKHluRAAoOdgl Nv3iiGPDEDPhT82qhbwHQdURSMBvp0Vy0H02FvIzQZ/Ry9b/5TQBDWaLrC/7tns3bLe2 peSw== X-Gm-Message-State: ALKqPweflUHqHEAaFVNaSRHEuyL9MsTgdU+ZpOJ639n7RD9DSs+2FUOk GHrAI5dObcJOVGQGLCjbzhTNmA== X-Received: by 2002:a17:902:28a7:: with SMTP id f36-v6mr3890374plb.155.1527098331982; Wed, 23 May 2018 10:58:51 -0700 (PDT) Received: from rajat.mtv.corp.google.com ([2620:0:1000:1501:dc81:9a9e:fdee:decf]) by smtp.gmail.com with ESMTPSA id k186-v6sm41433025pfc.142.2018.05.23.10.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 10:58:51 -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 v2 4/5] PCI/AER: Add sysfs attributes for rootport cumulative stats Date: Wed, 23 May 2018 10:58:07 -0700 Message-Id: <20180523175808.28030-5-rajatja@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180523175808.28030-1-rajatja@google.com> References: <20180522222805.80314-1-rajatja@google.com> <20180523175808.28030-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 --- v2: same as v1 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 e47321b267f6..898c9bc02ec2 100644 --- a/drivers/pci/pcie/aer/aerdrv_stats.c +++ b/drivers/pci/pcie/aer/aerdrv_stats.c @@ -57,6 +57,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 (!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