From patchwork Mon May 9 18:14:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohamed Khalfella X-Patchwork-Id: 571212 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C5B9C433EF for ; Mon, 9 May 2022 18:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240076AbiEISTC (ORCPT ); Mon, 9 May 2022 14:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240055AbiEISTC (ORCPT ); Mon, 9 May 2022 14:19:02 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27340224A49 for ; Mon, 9 May 2022 11:15:07 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id c11so14614888plg.13 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=7uS3xgNEh6pcOSm7znCbsITbx9oux+qO2BTPQFgVJn/yNfhr9BLVwzZCQhceHZi9rr zxdDiMhbX2udhh23b+0PhRSBce2HakxWmfDjdJ7VNaM8fS8jklSU3LDx/aqxOChSD5wc tQX40eJ0RrPZhhxMT51C43M3IM2b5yd6E9Va9pRwtrVKHBQXM5dRFRbnY/N20hZvani3 XdpwYU5TQ7SubNyYWHlp/J7Vf5qP3Ua/P/fbtWA0kKww0hUPfct4M/5dNvFtEUepaMeP rZKDxiK7F/uTE1oMwtBMihCqmg4aW/03dtCUaTc9R1kEPqOoJd75BhUUthv+y4L4fYoF YrJQ== X-Gm-Message-State: AOAM530wHNZ8s8GICIsiei8RDEKE6Rb6Vjk93QMG6QlYx/B1bHj2/7DK jBNVN6G5NRGhIdn8refQty25tA== X-Google-Smtp-Source: ABdhPJzFNBRQ2Q1XDKbHbd7ZYGXOOytDH274fEG/tp2JYfzyhz5+wsbzR7mkgvY/m4+E/0FXM7Wjsg== 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 Precedence: bulk List-ID: X-Mailing-List: stable@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))