Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5224415iob; Mon, 9 May 2022 11:19:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAZUe2AGeJoAC7s3ptCvA+SGVkeWUeCd6EIqqViHth2rUpGhvz4dpa0ami75rGDl4j8yey X-Received: by 2002:a0c:d80e:0:b0:456:31a1:fa52 with SMTP id h14-20020a0cd80e000000b0045631a1fa52mr14449170qvj.109.1652120373764; Mon, 09 May 2022 11:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652120373; cv=none; d=google.com; s=arc-20160816; b=c8Hlk2rmyvB11DWAuu4i9yZA274M5+dYwZUqt1/h9OZY/UqjxruIphK5u2I1DmlqsN mWQCgma0A3eclUgYiUvwSurmd1EP0q77A4AsFfSFl3PA32KPsaD/ttAN2dREGEif0dBW b2RETv8684nsOzR3OXvqWE7BT+zLwlL8RtJqhX8W6h74Vi4csQH1ehdvEWNExE830AmQ ZzQ2KUj6vgUpwBLP3q1r5Rx/nYlQZ4dFGzVfR+qyidHQbQsjrASDkcjwQuo5aYcDWLjP Jn2vmfyR0BSgQdjfaRyUkgdo29PyyACTYPX5VExFNn7orO/FKIAhvuO2kagGSmvfZmdP vxUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SyowesK9U7eSVq7QMaQPegZAs2FL+kTvFFeYpSRPCwQ=; b=dYhQXMRrFVJOY7RSyHTHtpVGPSis3bGCxCpwh0N5Y/yTLuU9zQtLQ/qO8yyEaukwzD HHr+8kGWdrFbvMgYy+bYx+XDxhcHEKqrbq4qjIJ52ae3ySsKYvacKyq0f98apA+RlAR/ NTjrB4zZpzb1i34BXTE64+HT2OY2zU4nyyEgMBfKTFi4Ulb3KCMfm0vVoWEXm35kLWgP cM7kFAyJZZcHpo6CJYyr6mitCNA/V46BPMAbzvZ3oixDukRj7Eg/pQK4BDCYWNo4/xDR 5prusO7PwUDXUtLK7PYIrGnKpIB6pd/4OrG+ZueaU7Jap6ZIdu96NqM2GDIuD4r7Nq/4 TUlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@purestorage.com header.s=google header.b=fgQGgwon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=purestorage.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k1-20020a05620a414100b006a0135df269si10273947qko.20.2022.05.09.11.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 11:19:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@purestorage.com header.s=google header.b=fgQGgwon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=purestorage.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3CAE6229FE9; Mon, 9 May 2022 11:15:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240055AbiEISTD (ORCPT + 99 others); Mon, 9 May 2022 14:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239998AbiEISTC (ORCPT ); Mon, 9 May 2022 14:19:02 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F812246A0 for ; Mon, 9 May 2022 11:15:07 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id n18so14644265plg.5 for ; Mon, 09 May 2022 11:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SyowesK9U7eSVq7QMaQPegZAs2FL+kTvFFeYpSRPCwQ=; b=fgQGgwonLNudSAc9oIt4TtM9RE17sdmswvDyDJ0PtqtNkRiny6l0en3Jkns0vr/kKi 1UGmLm2hTfC2iwuhwJutDwXkb558QFwjLEUZRr4+xUePhvmoJ2ZyTUito0NusLIL+X+/ Z7PuITXKzLlUwXe3pq2kAYJxKJhXFaEg7hTbg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SyowesK9U7eSVq7QMaQPegZAs2FL+kTvFFeYpSRPCwQ=; b=zObC4HFffdt3GSmCsV2O+kwKx5vePfsojlrMaVA7HtYGwWWb3nsGJtOtjk4BquQOEy a0tT6J8ADXM9/JNUalfTBq5cETXguWDxeU8FOnKSanLXTVS4dsKstw+pwPGfh7KVKXwu ZtLCAd3n/IzWOHa96BU3CHXHro/ldEV9tmlgFHDB62v1aflNX7TGphCTrpP/neWep/ih NSB4/AXImUjDEqtZJRewJuDt6d2q1OZQD7cpBHUAJlbib4sHJKa+9fuAWi0sYzFhQP1H SB90dAQe5vdZQWIpsj/32GyR2RIukpriatILfY7d/1jYssRZClpcdp1isn9a+Gu1DJta TLdw== X-Gm-Message-State: AOAM533Nmld+ws50timY2iA5ReRGnsdCIvH9fiLMeJeEP2kYr+uLG5g8 U8t0MzqJ0crXfpOVUABNJ/zYYA== X-Received: by 2002:a17:903:240f:b0:158:b871:33ac with SMTP id e15-20020a170903240f00b00158b87133acmr16950870plo.135.1652120106524; Mon, 09 May 2022 11:15:06 -0700 (PDT) Received: from irdv-mkhalfella.dev.purestorage.com ([208.88.158.129]) by smtp.googlemail.com with ESMTPSA id m18-20020a170902db1200b0015e8d4eb293sm152377plx.221.2022.05.09.11.15.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 May 2022 11:15:05 -0700 (PDT) From: Mohamed Khalfella To: mkhalfella@purestorage.com Cc: stable@vger.kernel.org, Meeta Saggi , Eric Badger , Russell Currey , "Oliver O'Halloran" , Bjorn Helgaas , linuxppc-dev@lists.ozlabs.org (open list:PCI ENHANCED ERROR HANDLING (EEH) FOR POWERPC), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] PCI/AER: Iterate over error counters instead of error strings Date: Mon, 9 May 2022 18:14:41 +0000 Message-Id: <20220509181441.31884-1-mkhalfella@purestorage.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PCI AER stats counters sysfs attributes need to iterate over stats counters instead of stats names. Also, added a build time check to make sure all counters have entries in strings array. Fixes: 0678e3109a3c ("PCI/AER: Simplify __aer_print_error()") Cc: stable@vger.kernel.org Reported-by: Meeta Saggi Signed-off-by: Mohamed Khalfella Reviewed-by: Meeta Saggi Reviewed-by: Eric Badger --- drivers/pci/pcie/aer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 9fa1f97e5b27..ce99a6d44786 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -533,7 +533,7 @@ static const char *aer_agent_string[] = { u64 *stats = pdev->aer_stats->stats_array; \ size_t len = 0; \ \ - for (i = 0; i < ARRAY_SIZE(strings_array); i++) { \ + for (i = 0; i < ARRAY_SIZE(pdev->aer_stats->stats_array); i++) {\ if (strings_array[i]) \ len += sysfs_emit_at(buf, len, "%s %llu\n", \ strings_array[i], \ @@ -1342,6 +1342,11 @@ static int aer_probe(struct pcie_device *dev) struct device *device = &dev->device; struct pci_dev *port = dev->port; + BUILD_BUG_ON(ARRAY_SIZE(aer_correctable_error_string) < + AER_MAX_TYPEOF_COR_ERRS); + BUILD_BUG_ON(ARRAY_SIZE(aer_uncorrectable_error_string) < + AER_MAX_TYPEOF_UNCOR_ERRS); + /* Limit to Root Ports or Root Complex Event Collectors */ if ((pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC) && (pci_pcie_type(port) != PCI_EXP_TYPE_ROOT_PORT)) -- 2.29.0