From patchwork Wed Jan 15 07:42:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13939997 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7072435944 for ; Wed, 15 Jan 2025 07:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736926999; cv=none; b=rIgaPiYlNFtcG6Eo2VRpHc5IKfh6s6FbM2B6R0WdfeahHBAwTXGQAYboCrm9Vqq0UKOvr1JIx887ZbWJlFcHunftLtcFEUaE9i4ojRkglLNWk8E4h/MyQ+GwPcTo8Nw9au3i/wsImR+HjxanH1NNDulpjdsCUZ2HI38MZyH1WVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736926999; c=relaxed/simple; bh=3DcuRaRR3rek/iMtx7Kx3cYHCFvPlsbEJPib8SHWNp8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pQdadZmmxGT0Lw3i2LdOxr7YBXBNzR4VXhAYoE+Sn49wQ4j8PXeBi3ZY59J/orx0Y7uB214x9b6ucOuaFD1pOcszcn9vbEsDbjGJFhtlJ+XvHJwsU0+42FGtfvRX7VkvR7TGOmvp6du0TUXXLEsvgRer2JkND3Sk1vWg6LLabrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I2KeVv6B; arc=none smtp.client-ip=209.85.160.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I2KeVv6B" Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-29fb38de98eso2009899fac.1 for ; Tue, 14 Jan 2025 23:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736926997; x=1737531797; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=32d3TvXIAITzMzw8IRW1CVQ06ZVjM6jnHvqP8pOAfRU=; b=I2KeVv6BKZFYsyveQUV9OyGr2g05B56Ri597s/JKuwuHIfxzKZu+FHtCuznQhv7+Bx DCpr1io0cijs766e849aFQymvCgImixEyNSZJvIKZ3pnO2yqcum8Zl5LeMmEgZIRpeXq 9zfBfuJXjxKrBHtn07VujeXQbBpimzX6sb+bi0aLX4fAL5Ao4ZASoGniYJuUaS3RPf38 K5hzsAPl7XKUbSxNJTsbExCR5/eExhGc3a+TD84kmDItsaYzhvry1ezz5l/nZ8i9Ztzp xIQmqDElYvJPEYKJwFRMOqjB6HFbyXDiBUbDFcFmSHOJuplE77xCH+1rUAWXX6TL+gDg EHYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736926997; x=1737531797; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=32d3TvXIAITzMzw8IRW1CVQ06ZVjM6jnHvqP8pOAfRU=; b=DXubLWaWGzXN38pNZWvc2bMCKixfohccryZpwPn8LllciKusJ/CRKGygMQmQSeHxLM Mvg0j4JrooTYejsqUqEz8kpvQd4s6SDTcBNeVoPfpbF6Js9J3DXley89DzfZ6qD3jWvY ruMuVoNzsWlHwDS6itySzmuLsKS2aNB+VNfqAzooGXPaSOcLkXb4//FoYIIpyDRVm2fX +fRlXOK3dF/yyWkx2NfyEGWiFUE9TPUcAbKI6RG7wFisPVI8VDSS/HeRh/8RcFNTUSnm X3nmoMRnc9j6IkQwCDSoewCVzIDT8NIhzmWLZY6reLiYpXVJ9eOfcmgzRpnAUSf5S5WW bzQg== X-Gm-Message-State: AOJu0YwBvhZTdBnnf1xsyZBjb+hJVtndepCRxYrnn7MRYNBlIm7LicsI rJTEK1obJJQloCkPNV38DaZHM85AybJj/WpwkcWXK9lf75jjP3DPMPVbN5cxlgs2ouHI3JktlFP OkA== X-Google-Smtp-Source: AGHT+IFDki1PU+72glSpjoiw/40WNkQMVAU0yTnmz6NLTCW2eFevSl76QhUxSojvA5WFxQKQNq99B9QOiAk= X-Received: from oabgx6.prod.google.com ([2002:a05:6870:b906:b0:29f:9847:446f]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6871:a08b:b0:29e:76d1:db3b with SMTP id 586e51a60fabf-2aa066470fdmr16145556fac.5.1736926997427; Tue, 14 Jan 2025 23:43:17 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:53 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-2-pandoh@google.com> Subject: [PATCH 1/8] PCI/AER: Remove aer_print_port_info From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Info logged is duplicated when either the source device is processed. If no source device is found, than an error is logged. Code flow: aer_isr_one_error() -> aer_print_port_info() -> find_source_device() -> return/pci_info() if no device found else continue -> aer_process_err_devices() -> aer_print_error() aer_print_port_info(): [ 21.596150] pcieport 0000:00:04.0: Correctable error message received from 0000:01:00.0 aer_print_error(): [ 21.596163] e1000e 0000:01:00.0: PCIe Bus Error: severity=Correctable, type=Data Link Layer, (Receiver ID) [ 21.600575] e1000e 0000:01:00.0: device [8086:10d3] error status/mask=00000040/0000e000 [ 21.604707] e1000e 0000:01:00.0: [ 6] BadTLP Tested using aer-inject[1] tool. No more root port log on dmesg. [1] https://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/aer-inject.git Signed-off-by: Jon Pan-Doh Reviewed-by: Karolina Stolarek --- drivers/pci/pcie/aer.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 34ce9f834d0c..ba40800b5494 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -735,18 +735,6 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) info->severity, info->tlp_header_valid, &info->tlp); } -static void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) -{ - u8 bus = info->id >> 8; - u8 devfn = info->id & 0xff; - - pci_info(dev, "%s%s error message received from %04x:%02x:%02x.%d\n", - info->multi_error_valid ? "Multiple " : "", - aer_error_severity_string[info->severity], - pci_domain_nr(dev->bus), bus, PCI_SLOT(devfn), - PCI_FUNC(devfn)); -} - #ifdef CONFIG_ACPI_APEI_PCIEAER int cper_severity_to_aer(int cper_severity) { @@ -1295,7 +1283,6 @@ static void aer_isr_one_error(struct aer_rpc *rpc, e_info.multi_error_valid = 1; else e_info.multi_error_valid = 0; - aer_print_port_info(pdev, &e_info); if (find_source_device(pdev, &e_info)) aer_process_err_devices(&e_info); @@ -1314,8 +1301,6 @@ static void aer_isr_one_error(struct aer_rpc *rpc, else e_info.multi_error_valid = 0; - aer_print_port_info(pdev, &e_info); - if (find_source_device(pdev, &e_info)) aer_process_err_devices(&e_info); } From patchwork Wed Jan 15 07:42:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13939998 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB1035944 for ; Wed, 15 Jan 2025 07:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927004; cv=none; b=twtW/FbgPYFadKYy5iULuLHrwMAqF1vWrOMM5DK3dc03LP2xQNSf30W4+qlG6b8b4hQ19ZeeshgYYz07v93xbvpJMt5m1DEk1ywkM5qYQX0IgqjngUoYitzr86BPrihQUUixpVQMq+62XidvuwqafeqYRus6uhpmtfDd4GARxtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927004; c=relaxed/simple; bh=4ZyxmZewjNvkK8q//P2xmPYBRtGP4PbKOMZcgwIUnKQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QCqyyUOLOIA9bCjrom+0eAu3zs5x2wvB8u0JdUONwsn6UWUB520qc2SrURJM6Y4AiMkpQMGuxNaN2JJd5tKLOSWAOzEqUfd0S49cwnEKdNF7QMd/lwY7Cv80KmszFrld0qwBsQ6WP4Xithsyb15iqiciY+BdYSFQ41tcEuIwYWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EzYRvGoH; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EzYRvGoH" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef91d5c863so11529594a91.2 for ; Tue, 14 Jan 2025 23:43:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927002; x=1737531802; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=00fdl5t/ss+33VkJUdI/h4fMuW4xZbqtiRqS2wEoBLg=; b=EzYRvGoHkR0Du/wumYbI+Z/cW6tidaQxQ9zvugST5zZ3aAgGSTCAlMe4AdDKiVL8rp QnBgBpJIPfmfEdHC4cmHePo+PmEYlIkmbqyxF4cYoziX0xGITKohG4/1Aml/CYqkrv2r sc43Si7u/NvYxHcW5/8cJcSMXGnzwRYOfdZ7ufCl2FKDJ62sVD1LhCQd2XjDsF4Pyrza F12Gu8dWL2hRQ66XIMRKeqhHthtmpm/5mLV2jahkewJwT3wpHWy8Php0YqgtbWQ5Mu8/ WybLJlOWiq2b5xmVzvcG8pJHAzYJBf5FSBodyeKGxfMBuaNbkx0mwIzsIHhMoh6ulaRK Ek3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927002; x=1737531802; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=00fdl5t/ss+33VkJUdI/h4fMuW4xZbqtiRqS2wEoBLg=; b=CU9YnlzYLFAgLTzsqfc1iZJwpg4qxLi2U8hPnFI+nRhYGpYFj66dj0x3pGgBQsQdNM GzOHHisEcBwYq7dCMGEuZxrbceX0RrFhqAtP9VWzrKh907A+oK6ENq3TqbImt3CtK1t9 G+X7vG2h0hKNsbgvAwGkBWRpUOflqGOXxxLU8XQJkzCFpx5jEcsOfKm/tISd8Kw/2LLA DXu1eHOKOTknmkyNvIPMB6mxl/a9q9MsV/0b8JhBaK8HVXbBrnSgKFQJxsxeDz2gNGnc /SnSWjSt+aUImSl4u4QKcCYAfZA2b1T6TJb9NH1By+WGENQLpE9ksNhAEGrEqv0sNiUy kxlg== X-Gm-Message-State: AOJu0Yw/v2m9E16RZZBdQ42N6BnnOoxowvpHysUcFYz0S/j9ih9ESzhE iYtKvcMuLWTOj8YNRwN6Ad0z2MoqiM4+EJ8c2SSWYkNFXBFetQnRLnjNFcC8UU5K5LfqsF903Il 5qA== X-Google-Smtp-Source: AGHT+IHXVFOc71gEhKIhtB1AfHix+zxdGSLq7rwrmHrXvrfGflNOZp2zvUqoZ/OHuOeMFIdfSkPIV/Wv02w= X-Received: from pjbse16.prod.google.com ([2002:a17:90b:5190:b0:2e0:aba3:662a]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3a0e:b0:2ee:e113:815d with SMTP id 98e67ed59e1d1-2f548e98373mr39570900a91.8.1736927001881; Tue, 14 Jan 2025 23:43:21 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:54 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-3-pandoh@google.com> Subject: [PATCH 2/8] PCI/AER: Move AER stat collection out of __aer_print_error From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Decouple stat collection from internal AER print functions. AERs from ghes or cxl drivers have stat collection in pci_print_aer as that is where aer_err_info is populated. Tested using aer-inject[1] tool. AER sysfs counters still updated correctly. [1] https://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/aer-inject.git Signed-off-by: Jon Pan-Doh --- drivers/pci/pcie/aer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index ba40800b5494..4bb0b3840402 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -695,7 +695,6 @@ static void __aer_print_error(struct pci_dev *dev, pci_printk(level, dev, " [%2d] %-22s%s\n", i, errmsg, info->first_error == i ? " (First)" : ""); } - pci_dev_aer_stats_incr(dev, info); } void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) @@ -775,6 +774,8 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, info.mask = mask; info.first_error = PCI_ERR_CAP_FEP(aer->cap_control); + pci_dev_aer_stats_incr(dev, &info); + pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); __aer_print_error(dev, &info); pci_err(dev, "aer_layer=%s, aer_agent=%s\n", @@ -1249,8 +1250,10 @@ static inline void aer_process_err_devices(struct aer_err_info *e_info) /* Report all before handle them, not to lost records by reset etc. */ for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { - if (aer_get_device_error_info(e_info->dev[i], e_info)) + if (aer_get_device_error_info(e_info->dev[i], e_info)) { + pci_dev_aer_stats_incr(e_info->dev[i], e_info); aer_print_error(e_info->dev[i], e_info); + } } for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { if (aer_get_device_error_info(e_info->dev[i], e_info)) From patchwork Wed Jan 15 07:42:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13939999 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7B4935944 for ; Wed, 15 Jan 2025 07:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927006; cv=none; b=OgpsAxXo4iz138If3BNymzI1Ld1Ns9Y+5PKPIJcXaW35b99wIC0z+1B/4ltpJWMFKEP10FE3cfzPuk675POyIFosAW1Mu3Wgoh+BeIy41CjwP7UoHoBpTHy9d1arE+m5qyF0IfxyYuPGGJqm5w7MfWmpw0KWaQWQKJrH1BHs0XA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927006; c=relaxed/simple; bh=jbbciFKr4lpWzVTPwRRUH0gti5k1BFus+usyKRHjipw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TLlto6zwoODuWnEQWjQbJ2qxLudU5thzIlGwIy9RoDfKKa7gC4nlDq6/mzTPFmTDC2JFm5jX9UtYVZ+ftJoq/W0ko5FWSgdXW4ZjesA/4IYKqPMC3bgPwrStSyyDsvccEHBNJdxQrBQbets8pjiMhQiKZj9sZt2pNRDuU91Nu7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=w+GhFUw9; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="w+GhFUw9" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21632eacb31so77567835ad.0 for ; Tue, 14 Jan 2025 23:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927004; x=1737531804; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/TucB/r+uGQd5ERcyy2UEFhzZ73Y9fQ1zg8lqsEqfHE=; b=w+GhFUw9FSHYf+o2D3H0xQxcvUzgLtjNMHJFKKScLKEr2HCFqBG7mXvMvkvzwketcW UXiiSciItD2JaBLO8NUx4tKuvdyzJosCl9OlJincnRS9nMghNedh3nndIldSlRYT/v+o P7pDq+dI7EEXK24duFfoSGYCDh8XB1KJNJled0E72BkSCDmzy5EYVkw5fZrr39piJ6cF fSyBBFWJFcvhN7azMZJe6xHPOEiptrPyNvwd+r8gKxEVQnThv2XQ836GTobFSFre5pZm uc8WgxoZo0F6nBN6sCfy9dPKJsci0tfULPoeutqWdXrOPt6h9p2zt5AujN1TgCbCTvrz S5QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927004; x=1737531804; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/TucB/r+uGQd5ERcyy2UEFhzZ73Y9fQ1zg8lqsEqfHE=; b=saxwC0jjKhCI5DshRjidc9nLSccjSNHPz4xQgZKOQxjXhCcXUpcq/uhjF7YxycAwv7 At0vM/vqVANzilI2AkgEI6PWpSgt66+8dSdV0daZRl4sg/9BlhjKzE9DHb1dXhIAfSk+ Lwyy8P/eh3xquD2HygH1nASURzwjgNCuj7osgWMijG6om8k/MjSefSDTcyHjHsuZ8zQq RSr9OPdDyQaQnzxr4XywO/ssS17CbMZGzwPcsHI1cjKUQYI1UE++ggX4Ea2OxmIcwwLO fPWyFXRz//vzVc4wlU6FWIrqioLVSpeWhDVO1pXEkK/L3iEpGjuYoPkd8lqmqP4qeYFw 3lQg== X-Gm-Message-State: AOJu0YwXjuZVjeioxu/wRBXftTlONi94LcEeoOGPUXvb+iR0hKl7J1y5 YnhfCmNbmyDYgpy2yEceX/CIN64eq4EPpsHTakqMb14vikNJXUaI0wguqiO5VH0Ooq9SHThbFNw +iA== X-Google-Smtp-Source: AGHT+IGq6M2yvrzEbN9fc6D2kZjbUSNpgwq1zNbRj2fM8biGYkBsPt7bKTkRqQP8DqzTwj2ymJJ0Qpz/gac= X-Received: from plaw1.prod.google.com ([2002:a17:902:c781:b0:21a:7dbb:d6d9]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:120b:b0:215:a190:ba10 with SMTP id d9443c01a7336-21a83f54ec2mr394361145ad.15.1736927004125; Tue, 14 Jan 2025 23:43:24 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:55 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-4-pandoh@google.com> Subject: [PATCH 3/8] PCI/AER: Rename struct aer_stats to aer_info From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Update name to reflect the broader definition of structs/variables that are stored (e.g. ratelimits). Signed-off-by: Jon Pan-Doh --- drivers/pci/pcie/aer.c | 50 +++++++++++++++++++++--------------------- include/linux/pci.h | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 4bb0b3840402..5ab5cd7368bc 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -50,11 +50,11 @@ struct aer_rpc { DECLARE_KFIFO(aer_fifo, struct aer_err_source, AER_ERROR_SOURCES_MAX); }; -/* AER stats for the device */ -struct aer_stats { +/* AER info for the device */ +struct aer_info { /* - * Fields for all AER capable devices. They indicate the errors + * Stats for all AER capable devices. They indicate the errors * "as seen by this device". Note that this may mean that if an * end point is causing problems, the AER counters may increment * at its link partner (e.g. root port) because the errors will be @@ -76,7 +76,7 @@ struct aer_stats { u64 dev_total_nonfatal_errs; /* - * Fields for Root ports & root complex event collectors only, these + * Stats for Root ports & root complex event collectors only, these * indicate the total number of ERR_COR, ERR_FATAL, and ERR_NONFATAL * messages received by the root port / event collector, INCLUDING the * ones that are generated internally (by the rootport itself) @@ -373,7 +373,7 @@ void pci_aer_init(struct pci_dev *dev) if (!dev->aer_cap) return; - dev->aer_stats = kzalloc(sizeof(struct aer_stats), GFP_KERNEL); + dev->aer_info = kzalloc(sizeof(struct aer_info), GFP_KERNEL); /* * We save/restore PCI_ERR_UNCOR_MASK, PCI_ERR_UNCOR_SEVER, @@ -394,8 +394,8 @@ void pci_aer_init(struct pci_dev *dev) void pci_aer_exit(struct pci_dev *dev) { - kfree(dev->aer_stats); - dev->aer_stats = NULL; + kfree(dev->aer_info); + dev->aer_info = NULL; } #define AER_AGENT_RECEIVER 0 @@ -533,10 +533,10 @@ static const char *aer_agent_string[] = { { \ unsigned int i; \ struct pci_dev *pdev = to_pci_dev(dev); \ - u64 *stats = pdev->aer_stats->stats_array; \ + u64 *stats = pdev->aer_info->stats_array; \ size_t len = 0; \ \ - for (i = 0; i < ARRAY_SIZE(pdev->aer_stats->stats_array); i++) {\ + for (i = 0; i < ARRAY_SIZE(pdev->aer_info->stats_array); i++) {\ if (strings_array[i]) \ len += sysfs_emit_at(buf, len, "%s %llu\n", \ strings_array[i], \ @@ -547,7 +547,7 @@ static const char *aer_agent_string[] = { i, stats[i]); \ } \ len += sysfs_emit_at(buf, len, "TOTAL_%s %llu\n", total_string, \ - pdev->aer_stats->total_field); \ + pdev->aer_info->total_field); \ return len; \ } \ static DEVICE_ATTR_RO(name) @@ -568,7 +568,7 @@ aer_stats_dev_attr(aer_dev_nonfatal, dev_nonfatal_errs, char *buf) \ { \ struct pci_dev *pdev = to_pci_dev(dev); \ - return sysfs_emit(buf, "%llu\n", pdev->aer_stats->field); \ + return sysfs_emit(buf, "%llu\n", pdev->aer_info->field); \ } \ static DEVICE_ATTR_RO(name) @@ -595,7 +595,7 @@ static umode_t aer_stats_attrs_are_visible(struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct pci_dev *pdev = to_pci_dev(dev); - if (!pdev->aer_stats) + if (!pdev->aer_info) return 0; if ((a == &dev_attr_aer_rootport_total_err_cor.attr || @@ -619,25 +619,25 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev, unsigned long status = info->status & ~info->mask; int i, max = -1; u64 *counter = NULL; - struct aer_stats *aer_stats = pdev->aer_stats; + struct aer_info *aer_info = pdev->aer_info; - if (!aer_stats) + if (!aer_info) return; switch (info->severity) { case AER_CORRECTABLE: - aer_stats->dev_total_cor_errs++; - counter = &aer_stats->dev_cor_errs[0]; + aer_info->dev_total_cor_errs++; + counter = &aer_info->dev_cor_errs[0]; max = AER_MAX_TYPEOF_COR_ERRS; break; case AER_NONFATAL: - aer_stats->dev_total_nonfatal_errs++; - counter = &aer_stats->dev_nonfatal_errs[0]; + aer_info->dev_total_nonfatal_errs++; + counter = &aer_info->dev_nonfatal_errs[0]; max = AER_MAX_TYPEOF_UNCOR_ERRS; break; case AER_FATAL: - aer_stats->dev_total_fatal_errs++; - counter = &aer_stats->dev_fatal_errs[0]; + aer_info->dev_total_fatal_errs++; + counter = &aer_info->dev_fatal_errs[0]; max = AER_MAX_TYPEOF_UNCOR_ERRS; break; } @@ -649,19 +649,19 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev, static void pci_rootport_aer_stats_incr(struct pci_dev *pdev, struct aer_err_source *e_src) { - struct aer_stats *aer_stats = pdev->aer_stats; + struct aer_info *aer_info = pdev->aer_info; - if (!aer_stats) + if (!aer_info) return; if (e_src->status & PCI_ERR_ROOT_COR_RCV) - aer_stats->rootport_total_cor_errs++; + aer_info->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++; + aer_info->rootport_total_fatal_errs++; else - aer_stats->rootport_total_nonfatal_errs++; + aer_info->rootport_total_nonfatal_errs++; } } diff --git a/include/linux/pci.h b/include/linux/pci.h index db9b47ce3eef..72e6f5560164 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -346,7 +346,7 @@ struct pci_dev { u8 hdr_type; /* PCI header type (`multi' flag masked out) */ #ifdef CONFIG_PCIEAER u16 aer_cap; /* AER capability offset */ - struct aer_stats *aer_stats; /* AER stats for this device */ + struct aer_info *aer_info; /* AER info for this device */ #endif #ifdef CONFIG_PCIEPORTBUS struct rcec_ea *rcec_ea; /* RCEC cached endpoint association */ From patchwork Wed Jan 15 07:42:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13940000 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF8FD22F84F for ; Wed, 15 Jan 2025 07:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927008; cv=none; b=dYXkrxL2My/DVrgZfeMGGlEwBBlYgfwMEIZa8SffFZ50gbRab5XLBd95iLjDZNo+yt3odCe9oyieUGEtfPqeZySTKWQz7fK8uvlLW8Aijck026qQ05uw+BTf6k1RsIPvreLHRuKBKu8R+pt2nf8PKot6PBMMlFQ6SMjNOCKhsB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927008; c=relaxed/simple; bh=IM7yP5EalKHZtTxPHuuFwdgrvigaCtKIa7SSBRfAHuw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AjsoOvTPXJNsJZz2RVbetwP4hfBQXrpgoiCWhZc0sqhGVn1kQVV2G/InXjMuj36mObv2BfMPnbWstv8ZLNO3vEI9HIwnzTSYXmnh82x+tF0+HgHpuaMPMK6x3trbzo5zRGT4Amtv4PFGwFJbYZpJf/kZwhkABcjpuJQgBQVPK1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UnTXON1x; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UnTXON1x" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-216750b679eso81824935ad.1 for ; Tue, 14 Jan 2025 23:43:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927006; x=1737531806; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YLA8BfXAyOsGawEI0SfcV0jVnz1LUpPhnTpff1nkyuI=; b=UnTXON1xUP03CZMTf6pY8sZqjxXnh2KYXRbuYvoDJRKxxMa0TU/dPBs7z06v2bm0z0 PQT8OVKAq79c8prja2L2xU2I/NBtAm9420YzSP+yVQyZs/3vmwSH+rRbgycKtIMyNIxa lV9may6YxRuiczHlRM66JIlQIo6cxi7IjjKuYNWveu7wB5wO8+0MCoN/TZjtlafQ7Vuu DuV4mWEC4xC0uESLmK0YxrI8ZIFphukALEfJ6TdLxOmticooHaQVJlj1MVl7woGcbtKt qhhoInMAJ/uuR+F1HfcZleMlhwFe8TM8Q8oEhrgF2Xo2U7g7f9OlxCkaLe3pl8a7vtME JAIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927006; x=1737531806; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YLA8BfXAyOsGawEI0SfcV0jVnz1LUpPhnTpff1nkyuI=; b=k/GyOVo75I7D2ceid1TGZrU0XVxYxOpjB+XqLE0b+zbuQ/cYbl1gea3vhfN5qfAoBH ZPVy6QP55bV+pftIb0ZLGjCk69rUnKrx+YQPW1Rtp3hJJQK5zUkpRSs0USt8arjaLvMx N42hL2NUjqCRKye8eHqUBBl/vMkA0nRIHLfxnnPc4clNFRsRJqY3ozKSbqAfxDKZza3w dHwX4VjCS5+HRgy4ffjazOnYFZtgJCd3jpcLRkuJQiAwMVMGhKeZHwmzWOpUPK+UrwN/ Y5hSJYJoo/n+sVcHLQn4fMR3d3QyVAPmwSgLmj7A42/mzI1HyQVcycJKn/7S/0dJN/xu wsmQ== X-Gm-Message-State: AOJu0Yzt31iWfZeFbZMop3atlrX1sASVMyfB23iEaw1wb0F/t7JUDqx4 Hbc44/FiTQRLT6rl+ln5MmLF6iC3on0PHWJoyv/fqFOKIe3sk8hb11HQMss4vczm6CYbWVkLWoe rmg== X-Google-Smtp-Source: AGHT+IEuFI8qJPg0sQoJhm64k4w3rhjOs2sT9jPCCRvBypEQ7eKqSPGl+SbLtIsRCgMDc7y8S6Y3WDMLQ3I= X-Received: from pldr2.prod.google.com ([2002:a17:903:4102:b0:216:23fc:b4a1]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ce8d:b0:216:282d:c697 with SMTP id d9443c01a7336-21a83f62877mr395988265ad.27.1736927006323; Tue, 14 Jan 2025 23:43:26 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:56 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-5-pandoh@google.com> Subject: [PATCH 4/8] PCI/AER: Introduce ratelimit for error logs From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Spammy devices can flood kernel logs with AER errors and slow/stall execution. Add per-device ratelimits for AER errors (correctable and uncorrectable). Set the default rate to the default kernel ratelimit (10 per 5s). Tested using aer-inject[1] tool. Sent 11 AER errors. Observed 10 errors logged while AER stats (cat /sys/bus/pci/devices//aer_dev_correctable) show true count of 11. [1] https://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/aer-inject.git Signed-off-by: Jon Pan-Doh --- Documentation/PCI/pcieaer-howto.rst | 6 ++++++ drivers/pci/pcie/aer.c | 31 +++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Documentation/PCI/pcieaer-howto.rst b/Documentation/PCI/pcieaer-howto.rst index f013f3b27c82..5546de60f184 100644 --- a/Documentation/PCI/pcieaer-howto.rst +++ b/Documentation/PCI/pcieaer-howto.rst @@ -85,6 +85,12 @@ In the example, 'Requester ID' means the ID of the device that sent the error message to the Root Port. Please refer to PCIe specs for other fields. +AER Ratelimits +------------------------- + +Error messages are ratelimited per device and error type. This prevents spammy +devices from flooding the console. + AER Statistics / Counters ------------------------- diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 5ab5cd7368bc..025c50b0f293 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,10 @@ struct aer_info { u64 rootport_total_cor_errs; u64 rootport_total_fatal_errs; u64 rootport_total_nonfatal_errs; + + /* Ratelimits for errors */ + struct ratelimit_state cor_log_ratelimit; + struct ratelimit_state uncor_log_ratelimit; }; #define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \ @@ -374,6 +379,12 @@ void pci_aer_init(struct pci_dev *dev) return; dev->aer_info = kzalloc(sizeof(struct aer_info), GFP_KERNEL); + ratelimit_state_init(&dev->aer_info->cor_log_ratelimit, + DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); + ratelimit_state_init(&dev->aer_info->uncor_log_ratelimit, + DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); + ratelimit_set_flags(&dev->aer_info->cor_log_ratelimit, RATELIMIT_MSG_ON_RELEASE); + ratelimit_set_flags(&dev->aer_info->uncor_log_ratelimit, RATELIMIT_MSG_ON_RELEASE); /* * We save/restore PCI_ERR_UNCOR_MASK, PCI_ERR_UNCOR_SEVER, @@ -702,6 +713,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) int layer, agent; int id = pci_dev_id(dev); const char *level; + struct ratelimit_state *ratelimit; if (!info->status) { pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n", @@ -709,11 +721,20 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) goto out; } + if (info->severity == AER_CORRECTABLE) { + ratelimit = &dev->aer_info->cor_log_ratelimit; + level = KERN_WARNING; + } else { + ratelimit = &dev->aer_info->uncor_log_ratelimit; + level = KERN_ERR; + } + + if (!__ratelimit(ratelimit)) + return; + layer = AER_GET_LAYER_ERROR(info->severity, info->status); agent = AER_GET_AGENT(info->severity, info->status); - level = (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR; - pci_printk(level, dev, "PCIe Bus Error: severity=%s, type=%s, (%s)\n", aer_error_severity_string[info->severity], aer_error_layer[layer], aer_agent_string[agent]); @@ -755,11 +776,14 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, int layer, agent, tlp_header_valid = 0; u32 status, mask; struct aer_err_info info; + struct ratelimit_state *ratelimit; if (aer_severity == AER_CORRECTABLE) { + ratelimit = &dev->aer_info->cor_log_ratelimit; status = aer->cor_status; mask = aer->cor_mask; } else { + ratelimit = &dev->aer_info->uncor_log_ratelimit; status = aer->uncor_status; mask = aer->uncor_mask; tlp_header_valid = status & AER_LOG_TLP_MASKS; @@ -776,6 +800,9 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, pci_dev_aer_stats_incr(dev, &info); + if (!__ratelimit(ratelimit)) + return; + pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); __aer_print_error(dev, &info); pci_err(dev, "aer_layer=%s, aer_agent=%s\n", From patchwork Wed Jan 15 07:42:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13940001 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1210222F84F for ; Wed, 15 Jan 2025 07:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927010; cv=none; b=Ft5XVYEN5y/dn1rghuw/Sos+ULBDt0b8x68bvquHIaSENtnZmwxFf6uVkjhUroy/rN3oZKbeRNy3UOtgYDb9E5xiClQDs7DUt1kExktfWhwy8szRNlCFrXptvkqVqYJM/k9rfueCv71Tr6QUOCrpPxE+pQxx4JLlUjoOkyWGwJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927010; c=relaxed/simple; bh=AaRwseQYUhklbNnb1otoMO+0fpMTsbExqcehBF0JpnU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qAe3PvFU8gtXpJKeZY3pttbrQahqurNGI0siJ5lmBUjxupAKFEvsoyIX9nhDetdUwhnY6zMGBxBBs4/eVfMSx/ytp1247/+TGRjjHV2EYtGV0lp7061kPp7FpQM8NzzseKEs4XvQA+nB2N1DlGRYN7p2svSoq7Hv0ixXAQcNED4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uSF2vEA7; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uSF2vEA7" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2166f9f52fbso199476275ad.2 for ; Tue, 14 Jan 2025 23:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927008; x=1737531808; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=T2hkO9ecKAiOgwd/fwTHBr3GM0JTbJkNKW0Qdn18gN4=; b=uSF2vEA71xxL0Ot32ZNg3kKQfrzjuG0sj9Mwvkqn1BfrGsS2MCdWFyNL6k0Z8uZKEI GGQJATpSgFf2I5/oujZk8OWB7AUXRJeWTZohy/1p2ae5zYycGpalePgf4STB1Of+Wg3j mvPMJ5MZ8jmAnToy0CNX3a96L7TfntEE10ii2ybuHhodgbq26Ru+MM+ZzPc91vLhyrE5 qwbbSQTDXJXNOPIiRdN7T3kUdUoupC4hJd6hv7pt6GmXV8YxhgSdnYdRalGy60h/sIZR 2qIKB+XVojL0vhsT3jesrsiu29qMQXVVE4j5zON6mvxRE9Q1NDWOVFt14lGRKFlzh8v2 agmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927008; x=1737531808; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T2hkO9ecKAiOgwd/fwTHBr3GM0JTbJkNKW0Qdn18gN4=; b=teLodKMmAfL2zJfU9mcDiPRKlrBhgFoWq0zNH+mFmQqs3Xzm0cav0DfeEXrJjI6+g/ 5fW8BODTE4HQ+Up+zs3Kx9HXmJLQSyAJEsbFdmGTynz9bSgZ7nj8K9M1cJpKQU+8oS3V u5OMH5dE4tKgl5jtnEE6Oz2gMJuEqkyrXuFwVrLPrOlM6LCbVxk9AAFgYCZNbhIyDweN HxFs1bvDjoGImOsMDFNxEiuZszPuLY1aAdkZg1XSENYJ+MDGLoxgVLIxdlTAuyCfhBmF D+KT9rSutBQaoc6aP6VXTVFiYrtWfGiUpAolOrhPdVAThJIGMdhS/V+Gigj4zqKBd+y/ uaBw== X-Gm-Message-State: AOJu0YyvF0CWeho/e9/YlyFcipw4rGJ8+brC2VefojYV0FS52oXnWJva xgQSgyE0fa2UqvKhn2FAlZ3SPzcuS5P/qwYg92AXHcxAlNxOeTgTLFjFOlV5/FTIRyjfumKdeW5 Tyw== X-Google-Smtp-Source: AGHT+IFAt4fQjhDkxUfvXtP2HxSEVaclOsQHOD9OkFBuZ2ovbOEGtAqj+Q2zKOYXspIa8Ej61/Y9pRlv/OE= X-Received: from plte6.prod.google.com ([2002:a17:902:7446:b0:215:515c:124e]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d2d2:b0:216:3dc0:c8ab with SMTP id d9443c01a7336-21a83f3ee9emr404760155ad.9.1736927008305; Tue, 14 Jan 2025 23:43:28 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:57 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-6-pandoh@google.com> Subject: [PATCH 5/8] PCI/AER: Introduce ratelimit for AER IRQs From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh After ratelimiting logs, spammy devices can still slow execution by continued AER IRQ servicing. Add higher per-device ratelimits for AER errors to mask out those IRQs. Set the default rate to 3x default AER ratelimit (30 per 5s). Tested using aer-inject[1] tool. Injected 32 AER errors. Observed IRQ masked via lspci and sysfs counters record 31 errors (1 masked). Before: CEMsk: BadTLP- After: CEMsk: BadTLP+ [1] https://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/aer-inject.git Signed-off-by: Jon Pan-Doh --- Documentation/PCI/pcieaer-howto.rst | 4 +- drivers/pci/pcie/aer.c | 64 +++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/Documentation/PCI/pcieaer-howto.rst b/Documentation/PCI/pcieaer-howto.rst index 5546de60f184..d41272504b18 100644 --- a/Documentation/PCI/pcieaer-howto.rst +++ b/Documentation/PCI/pcieaer-howto.rst @@ -88,8 +88,8 @@ fields. AER Ratelimits ------------------------- -Error messages are ratelimited per device and error type. This prevents spammy -devices from flooding the console. +Errors, both at log and IRQ level, are ratelimited per device and error type. +This prevents spammy devices from stalling execution. AER Statistics / Counters ------------------------- diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 025c50b0f293..1db70ae87f52 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -87,6 +87,8 @@ struct aer_info { u64 rootport_total_nonfatal_errs; /* Ratelimits for errors */ + struct ratelimit_state cor_irq_ratelimit; + struct ratelimit_state uncor_irq_ratelimit; struct ratelimit_state cor_log_ratelimit; struct ratelimit_state uncor_log_ratelimit; }; @@ -379,6 +381,10 @@ void pci_aer_init(struct pci_dev *dev) return; dev->aer_info = kzalloc(sizeof(struct aer_info), GFP_KERNEL); + ratelimit_state_init(&dev->aer_info->cor_irq_ratelimit, + DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST*3); + ratelimit_state_init(&dev->aer_info->uncor_irq_ratelimit, + DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST*3); ratelimit_state_init(&dev->aer_info->cor_log_ratelimit, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); ratelimit_state_init(&dev->aer_info->uncor_log_ratelimit, @@ -676,6 +682,39 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev, } } +static void mask_reported_error(struct pci_dev *dev, struct aer_err_info *info) +{ + const char **strings; + const char *errmsg; + u16 aer_offset = dev->aer_cap; + u16 mask_reg_offset; + u32 mask; + unsigned long status = info->status; + int i; + + if (info->severity == AER_CORRECTABLE) { + strings = aer_correctable_error_string; + mask_reg_offset = PCI_ERR_COR_MASK; + } else { + strings = aer_uncorrectable_error_string; + mask_reg_offset = PCI_ERR_UNCOR_MASK; + } + + pci_read_config_dword(dev, aer_offset + mask_reg_offset, &mask); + mask |= status; + pci_write_config_dword(dev, aer_offset + mask_reg_offset, mask); + + pci_warn(dev, "%s error(s) masked due to rate-limiting:", + aer_error_severity_string[info->severity]); + for_each_set_bit(i, &status, 32) { + errmsg = strings[i]; + if (!errmsg) + errmsg = "Unknown Error Bit"; + + pci_warn(dev, " [%2d] %-22s\n", i, errmsg); + } +} + static void __print_tlp_header(struct pci_dev *dev, struct pcie_tlp_log *t) { pci_err(dev, " TLP Header: %08x %08x %08x %08x\n", @@ -713,7 +752,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) int layer, agent; int id = pci_dev_id(dev); const char *level; - struct ratelimit_state *ratelimit; + struct ratelimit_state *irq_ratelimit; + struct ratelimit_state *log_ratelimit; if (!info->status) { pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n", @@ -722,14 +762,20 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) } if (info->severity == AER_CORRECTABLE) { - ratelimit = &dev->aer_info->cor_log_ratelimit; + irq_ratelimit = &dev->aer_info->cor_irq_ratelimit; + log_ratelimit = &dev->aer_info->cor_log_ratelimit; level = KERN_WARNING; } else { - ratelimit = &dev->aer_info->uncor_log_ratelimit; + irq_ratelimit = &dev->aer_info->uncor_irq_ratelimit; + log_ratelimit = &dev->aer_info->uncor_log_ratelimit; level = KERN_ERR; } - if (!__ratelimit(ratelimit)) + if (!__ratelimit(irq_ratelimit)) { + mask_reported_error(dev, info); + return; + } + if (!__ratelimit(log_ratelimit)) return; layer = AER_GET_LAYER_ERROR(info->severity, info->status); @@ -776,14 +822,14 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, int layer, agent, tlp_header_valid = 0; u32 status, mask; struct aer_err_info info; - struct ratelimit_state *ratelimit; + struct ratelimit_state *log_ratelimit; if (aer_severity == AER_CORRECTABLE) { - ratelimit = &dev->aer_info->cor_log_ratelimit; + log_ratelimit = &dev->aer_info->cor_log_ratelimit; status = aer->cor_status; mask = aer->cor_mask; } else { - ratelimit = &dev->aer_info->uncor_log_ratelimit; + log_ratelimit = &dev->aer_info->uncor_log_ratelimit; status = aer->uncor_status; mask = aer->uncor_mask; tlp_header_valid = status & AER_LOG_TLP_MASKS; @@ -799,8 +845,8 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, info.first_error = PCI_ERR_CAP_FEP(aer->cap_control); pci_dev_aer_stats_incr(dev, &info); - - if (!__ratelimit(ratelimit)) + /* Only ratelimit logs (no IRQ) as AERs reported via GHES/CXL (caller). */ + if (!__ratelimit(log_ratelimit)) return; pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask); From patchwork Wed Jan 15 07:42:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13940002 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37DD222F84F for ; Wed, 15 Jan 2025 07:43:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927012; cv=none; b=mSM112YQ/9QI7HHRd3YsTSoSyBhG/Mh2fOU2knNkqYZ9RFeR1KDPFWcy+SGQbvE6PC0c8fUiqmFo3LQfQsg1JfzSwECGi+ThjLTsdM71HGl4yLpb0w5+3XLzQc482fXoGfE55qzCztcEVkg9iABTzxCSXl7cD1dXlx+9CY43rH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927012; c=relaxed/simple; bh=DnVlNVZntTNB75ypAXjHLmMddAEJeIDtG2Y6om/Gu2E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jYRLMirjwtCQxpy2h2dQBD5pmF0xFSTHyYl9DtZxVKKRaXdSzk5CSO5MvjxJlvquds4ptAYLvpDMFJCpG6V2MPHbm35XXCg/+5bZ61H2XicvY+CWVjddqHKXk8FTmCf+/7gxKKr1WeY+KckmBfwNBP1/GbK/oFe4sD3wFAXDUrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yb1Gf3gW; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yb1Gf3gW" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2166e907b5eso122527585ad.3 for ; Tue, 14 Jan 2025 23:43:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927010; x=1737531810; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cZAgiyHyFBPyDef19tcdRpdqCs2mXbDbvlAtOLxsTFI=; b=yb1Gf3gW3fC02Xfok4vUlf6AVotC4W/OB0/rC3ALdUTDIEd7jR1EorfFWuaQ0vDps2 TCUcUfAPTdzhrpA7bt6hpKTPHheEUMbbxVfSNgwZZSIw3JyN+Csx5/6u72Fj9uxhLKud Y21+mVpXPGStZeYlBEaB4OYdx16TUjY2dyNoB/+5WnIDZPWy7G3OxEcof28z9zI+FjW5 6LN/Zh60Ibvx9+u1LbKaD25xne1mbrUlS9s7ivFa2O+GCinBoZiUN7hAfHyCYSefCaD9 OUBz21NZBPxC71lsbPpr2eN8TA+xivd5TiokVpWjjDR8Y3Pw/bDe5MXAGScm4p8FjeVx YDZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927010; x=1737531810; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cZAgiyHyFBPyDef19tcdRpdqCs2mXbDbvlAtOLxsTFI=; b=K/UpzJUCj9R7vdgxxQZG1WW9MhMJKyZp+Y642CGU2paiGKcqhmTXw433iRr8cMQLLg rCQi21FOAL5U2VnrE40JU1W+gWGpjIJzw7fdNxoUE7+CsJj/6gTXTx0k3puEU8hqDYg4 iOV7taTh5hD08B0JSYeNmBhqExWDfaLZ2rZa5FCN4YMQqVPk0vbDxhdjd32pSnNYBSU5 iEasgxr68Vs4326SQwV/DxN4242KZ3o3izv7Xc1ko4Pkz9EBxt9+rnEDCQxQ1T4WWnxa HpWT94+Qry5JIYeVSiYTf/GLb+JpDSuPTfAQ8BpXjmZeFFwxKuCE7Wix4DSJgl45Clcn juiA== X-Gm-Message-State: AOJu0Yxp2stHkJ2Ne4XNfAxPkl7al+C9ftZIuFUKY2VSttFKTrBsRyQw qdpSZCowj1Netvp7tLmG7o1zDDaiLaUCAwA0T18xBbE/r8pbKJPNBjL5pE/teKka8ki6WzeW7LB KIg== X-Google-Smtp-Source: AGHT+IFG5rIz0GU4Z1fM2b75ItRedG9R3nHu5Xp3eIOsZFzh+MaNBsX1Z+w/bsXJOIs0jBcxKptSVXkredg= X-Received: from pgox11.prod.google.com ([2002:a63:aa4b:0:b0:7fd:4497:f282]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:32a6:b0:1e6:5323:58d3 with SMTP id adf61e73a8af0-1e88cfdc67amr44670780637.23.1736927010431; Tue, 14 Jan 2025 23:43:30 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:58 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-7-pandoh@google.com> Subject: [PATCH 6/8] PCI/AER: Add AER sysfs attributes for ratelimits From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Allow userspace to read/write ratelimits per device. Create aer/ sysfs directory to store them and any future aer configs. Tested using aer-inject[1] tool. Configured correctable log/irq ratelimits to 5/10 respectively. Sent 12 AER errors. Observed 5 errors logged while AER stats (cat /sys/bus/pci/devices//aer_dev_correctable) shows 11 (1 masked). Before: CEMsk: BadTLP- After: CEMsk: BadTLP+. [1] https://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/aer-inject.git Signed-off-by: Jon Pan-Doh --- .../testing/sysfs-bus-pci-devices-aer_stats | 32 +++++++++++ Documentation/PCI/pcieaer-howto.rst | 4 +- drivers/pci/pci-sysfs.c | 1 + drivers/pci/pci.h | 1 + drivers/pci/pcie/aer.c | 56 +++++++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats index d1f67bb81d5d..c680a53af0f4 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats @@ -117,3 +117,35 @@ Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com Description: Total number of ERR_NONFATAL messages reported to rootport. + +PCIe AER ratelimits +---------------------------- + +These attributes show up under all the devices that are AER capable. Provides +configurable ratelimits of logs/irq per error type. Writing a nonzero value +changes the number of errors (burst) allowed per 5 second window before +ratelimiting. Reading gets the current ratelimits. + +What: /sys/bus/pci/devices//aer/ratelimit_cor_irq +Date: Jan 2025 +KernelVersion: 6.14.0 +Contact: linux-pci@vger.kernel.org, pandoh@google.com +Description: IRQ ratelimit for correctable errors. + +What: /sys/bus/pci/devices//aer/ratelimit_uncor_irq +Date: Jan 2025 +KernelVersion: 6.14.0 +Contact: linux-pci@vger.kernel.org, pandoh@google.com +Description: IRQ ratelimit for uncorrectable errors. + +What: /sys/bus/pci/devices//aer/ratelimit_cor_log +Date: Jan 2025 +KernelVersion: 6.14.0 +Contact: linux-pci@vger.kernel.org, pandoh@google.com +Description: Log ratelimit for correctable errors. + +What: /sys/bus/pci/devices//aer/ratelimit_uncor_log +Date: Jan 2025 +KernelVersion: 6.14.0 +Contact: linux-pci@vger.kernel.org, pandoh@google.com +Description: Log ratelimit for uncorrectable errors. diff --git a/Documentation/PCI/pcieaer-howto.rst b/Documentation/PCI/pcieaer-howto.rst index d41272504b18..4d5b0638f120 100644 --- a/Documentation/PCI/pcieaer-howto.rst +++ b/Documentation/PCI/pcieaer-howto.rst @@ -89,7 +89,9 @@ AER Ratelimits ------------------------- Errors, both at log and IRQ level, are ratelimited per device and error type. -This prevents spammy devices from stalling execution. +This prevents spammy devices from stalling execution. Ratelimits are exposed +in the form of sysfs attributes and configurable. See +Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats AER Statistics / Counters ------------------------- diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7679d75d71e5..41acb6713e2d 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1693,6 +1693,7 @@ const struct attribute_group *pci_dev_attr_groups[] = { &pcie_dev_attr_group, #ifdef CONFIG_PCIEAER &aer_stats_attr_group, + &aer_attr_group, #endif #ifdef CONFIG_PCIEASPM &aspm_ctrl_attr_group, diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 2e40fc63ba31..9d0272a890ef 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -881,6 +881,7 @@ void pci_no_aer(void); void pci_aer_init(struct pci_dev *dev); void pci_aer_exit(struct pci_dev *dev); extern const struct attribute_group aer_stats_attr_group; +extern const struct attribute_group aer_attr_group; void pci_aer_clear_fatal_status(struct pci_dev *dev); int pci_aer_clear_status(struct pci_dev *dev); int pci_aer_raw_clear_status(struct pci_dev *dev); diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 1db70ae87f52..e48e2951baae 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -630,6 +630,62 @@ const struct attribute_group aer_stats_attr_group = { .is_visible = aer_stats_attrs_are_visible, }; +#define aer_ratelimit_attr(name, ratelimit) \ + static ssize_t \ + name##_show(struct device *dev, struct device_attribute *attr, \ + char *buf) \ +{ \ + struct pci_dev *pdev = to_pci_dev(dev); \ + return sysfs_emit(buf, "%u errors every %u seconds\n", \ + pdev->aer_info->ratelimit.burst, \ + pdev->aer_info->ratelimit.interval / HZ); \ +} \ + \ + static ssize_t \ + name##_store(struct device *dev, struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct pci_dev *pdev = to_pci_dev(dev); \ + int burst; \ + \ + if (kstrtoint(buf, 0, &burst) < 0) \ + return -EINVAL; \ + \ + pdev->aer_info->ratelimit.burst = burst; \ + return count; \ +} \ +static DEVICE_ATTR_RW(name) + +aer_ratelimit_attr(ratelimit_cor_irq, cor_irq_ratelimit); +aer_ratelimit_attr(ratelimit_uncor_irq, uncor_irq_ratelimit); +aer_ratelimit_attr(ratelimit_cor_log, cor_log_ratelimit); +aer_ratelimit_attr(ratelimit_uncor_log, uncor_log_ratelimit); + +static struct attribute *aer_attrs[] __ro_after_init = { + &dev_attr_ratelimit_cor_irq.attr, + &dev_attr_ratelimit_uncor_irq.attr, + &dev_attr_ratelimit_cor_log.attr, + &dev_attr_ratelimit_uncor_log.attr, + NULL +}; + +static umode_t aer_attrs_are_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev = kobj_to_dev(kobj); + struct pci_dev *pdev = to_pci_dev(dev); + + if (!pdev->aer_info) + return 0; + return a->mode; +} + +const struct attribute_group aer_attr_group = { + .name = "aer", + .attrs = aer_attrs, + .is_visible = aer_attrs_are_visible, +}; + static void pci_dev_aer_stats_incr(struct pci_dev *pdev, struct aer_err_info *info) { From patchwork Wed Jan 15 07:42:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13940003 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BE8B22F84A for ; Wed, 15 Jan 2025 07:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927014; cv=none; b=egPyfJFiV5FEU8VPSsNK3Z2nJBNuKesCE1yjWp5+vYKiEh1ZCIOB1XV1xaEvkBP4zj3qUgyGM2EiIPTP/MhHvQ/p8LYRIL41/COYgLcplp1rHWYJV9D+OUcju2FcZCuj1MmoTvZA8Gy+zwgrkttLPGdXE0A/cnQNxCv63N7BVGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927014; c=relaxed/simple; bh=aLs1kVabz8SXWHoDYirdPtPlYiUBWZR4XLsoSu4ojQY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KZuHgiKMXAEKssZeqcpV1SiVHMCI7ELE080jm0uUXAZ3sacRT7LTqcvqNq0BO9apZ12W9F2GicYrqLG8AD9Mg25BLuqum90fu/BMQAKMvgxzgIYeQld2nQs8EGrNZCetkJjWjH0vk9cXftjz8ObGaEKaq2cqHWCBJ61oMeVm8zY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mAMf6IJ+; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mAMf6IJ+" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef9204f898so10922871a91.2 for ; Tue, 14 Jan 2025 23:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927012; x=1737531812; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2gAaVaoZaLejhKa/KYtuGMLg0tIhxnvk0TL9V6UpHa8=; b=mAMf6IJ+SnuIGUZzXMemS4vNyOXB2pZsCjhEKaXMcKQnyHw670lOStyzV1omEhD43F KnsVQQas/gBTxTC7ugS1eDtZxsKT60D/oaiilrSFVvOXfgd1CIoJZ5Pw7+eOBlV+0twj ud2MXr6tQBwud+N+wgpvl3KaRNRAo5CCcWGeBFMhJqz9Dh/P06M8261sXQtzM4nVvV9F aJfmbHZRNOnhTlvQ94HMlIFVCs91/HSsJZvVed9kXwez8Y5NT7h8xvNt2AYCbKPW3Fyf dqkBLP9SF3NHxLkCmqTN5LZyjQLIIJHxtYzeIR2YIqoqPLM4p87ZPWpudVbLqHiu8sr2 U/Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927012; x=1737531812; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2gAaVaoZaLejhKa/KYtuGMLg0tIhxnvk0TL9V6UpHa8=; b=kEtwZIM78kPicfIEQxvcYaAxafreN5rRcBu09CXRDe7yeHbdOJnBAjGhWOaKlu6zyK QCcG0TLLaT9yx78Zw2ZhbodOBUoBe7G0iUQv2X2IaYfKE5PbVR6iMfJwziqt/dX6fvQc K/CjM6rzqOurMpmqkj/68Q+HzqxTdhtGXodYYpjz544B9cH13AUhKxWJMy/iVNnzKWWn bI3M8lKniWrv7PAdCxjiya2yCdWMM49c13AjFUAiM85xbLDuV0SHsTKRweV5UsgHpqRR VEFkNvMoSiWe6uR2uVIZqQdps5ivxVtTzdcp+QlKGIratQuz/klNvQLf21LciwRYKm5Y nGxA== X-Gm-Message-State: AOJu0YzLVt2rc+mg7RKJXV9jtm/xmUF4+2jvVT6ejrhjRj7ILC6YhUUO lLScw3Vqs/Rhu0+oYaiE2623pZOMDQJ6rzkAcvBddygUlotuefKvqS5M8QkjeC+i2PfwmAwty19 8Vw== X-Google-Smtp-Source: AGHT+IGkmv6i+kASnX9W44jzEIpkZXcgCM6WcYxW+/+/4GmwxrQ4iA8Z3/wjLONgW5H1ZUmQA0H7qlMaYys= X-Received: from pjbtb7.prod.google.com ([2002:a17:90b:53c7:b0:2ea:5fc2:b503]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:53c5:b0:2ea:a9ac:eee1 with SMTP id 98e67ed59e1d1-2f548f33ba3mr42227271a91.10.1736927012585; Tue, 14 Jan 2025 23:43:32 -0800 (PST) Date: Tue, 14 Jan 2025 23:42:59 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-8-pandoh@google.com> Subject: [PATCH 7/8] PCI/AER: Update AER sysfs ABI filename From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Change Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats to Documentation/ABI/testing/sysfs-bus-pci-devices-aer to reflect the broader scope of AER sysfs attributes (e.g. stats and ratelimits). Signed-off-by: Jon Pan-Doh --- ...fs-bus-pci-devices-aer_stats => sysfs-bus-pci-devices-aer} | 0 Documentation/PCI/pcieaer-howto.rst | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename Documentation/ABI/testing/{sysfs-bus-pci-devices-aer_stats => sysfs-bus-pci-devices-aer} (100%) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer similarity index 100% rename from Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats rename to Documentation/ABI/testing/sysfs-bus-pci-devices-aer diff --git a/Documentation/PCI/pcieaer-howto.rst b/Documentation/PCI/pcieaer-howto.rst index 4d5b0638f120..4c9d31ae7d88 100644 --- a/Documentation/PCI/pcieaer-howto.rst +++ b/Documentation/PCI/pcieaer-howto.rst @@ -91,14 +91,14 @@ AER Ratelimits Errors, both at log and IRQ level, are ratelimited per device and error type. This prevents spammy devices from stalling execution. Ratelimits are exposed in the form of sysfs attributes and configurable. See -Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats +Documentation/ABI/testing/sysfs-bus-pci-devices-aer AER Statistics / Counters ------------------------- When PCIe AER errors are captured, the counters / statistics are also exposed in the form of sysfs attributes which are documented at -Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats +Documentation/ABI/testing/sysfs-bus-pci-devices-aer Developer Guide =============== From patchwork Wed Jan 15 07:43:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Pan-Doh X-Patchwork-Id: 13940004 X-Patchwork-Delegate: bhelgaas@google.com Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F95C22F84A for ; Wed, 15 Jan 2025 07:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927017; cv=none; b=Ar+DY1eUY54lbwmXIFOgL2GLa6KcYE4jhVgM2nCQvWSZPJj/1qUkHaqn6nskt84lfFTVdL+i4hTsN0uLgWjH+dtC1gcgEpnjdxBvHvSO+CPzO11wy/ANe4yMZa+RUOlA3lBAMy4fkQsAhk8Jy26wP8GUhhsdEEgtxTcVWlp6u/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736927017; c=relaxed/simple; bh=AmX3sj84Axy3Te5hRUYWAisKnHDQ42FvBLSN/lQmFAg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=B2ptWko+UGH2rjxbHi0nodAgesY1hB1M6OCEiHS5MC4sa6qYO8XOHc+kQXN/jc7DHeW2XZzzb/04er1WsyqT43rZ7C/TwoAjxJ3ojq5xAA37DVxLbIgJjbciIbwXHW3+rxxykUmvaqhlmjDfrm+tZFiBL/p82cyzQy9yZXvkseM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=v9ZyrnQA; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pandoh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="v9ZyrnQA" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21648c8601cso107676125ad.2 for ; Tue, 14 Jan 2025 23:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736927015; x=1737531815; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DL5cB9M1yphXMlMTohz+ovJ0iS53nDSxYYcxqM/vlWE=; b=v9ZyrnQAud5iMfujDgiWMFIrI6liwntG0Mve85tTKnVDNDEAqNwywl1zUPjytViKKY nJ+M/xrlYHcz4K3lSDdZM8/XSAvnIYpvmdT9M+eMm2vf9MsYsnSQUkimb3K1JVufVxrz 2s+cLONiouorLdg4jazweX4IhdgvAlGgMP/EoGBQl84sAnI6inTqY1UvByEftdlr4pk5 ANUCRpQuzprccOoTny9cud2FVzccOockF4PW8jCpdOVORyKwWPPSYGS2DHwlgLl9TbpI O1oFM2cpEuvlzEfc2gBf8t9v+9XLBqQejHL6YhYdzpX6wYPRnNnrWAzNVtZ/dwNbycO+ bEGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736927015; x=1737531815; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DL5cB9M1yphXMlMTohz+ovJ0iS53nDSxYYcxqM/vlWE=; b=aHI3NbqlqrCEsvrB+NRV2/t6QtLrSZqV5qA8Pd0Mb2M8bjp322crYVy7Ai46LFm/EQ my4ZvW4cKHIFUyOXR4nUk4/F3QNtxLMaqVbxbgJOOvX0COY6+xOf5LjpjWzLnGA2SCKR pvz2p/Nmd1xeNksOV9gT6E7y755ebUAlZ3TR2dWbHBRVtr3yMRVd2DFYWdfdAkFgrjrA h8/nB1alLgNuy97CKbCLDT0cgPTIIgMIAGPRhCayGMMJUvJkmuxbEy1HubOI8dGWlxB3 k/lvSzmvESQImkzKse4LbRlScJ4IhEtdqxiuoKVRZogtEHi5UK0b242r0EN9GDasdBdO b7Sg== X-Gm-Message-State: AOJu0YylLzDt3rqzwR/LnSza5TIa9jxKJmGzWuFqQKJJjo9XNM4Nufv2 cmVeDhemIMRRMzLXOR+82yoZKQ36RIysgnTgPylYppHAScaa4LkLzmsP7+Nzrqn3zA64aNtX0zl 7ow== X-Google-Smtp-Source: AGHT+IHxjYgc/3qBkaeexQjj9Cur+QV9IrZxJ8Ce9HjFjRciZpckF6E6Q6S3n31iXUVFkebt2mM84Ahxi3M= X-Received: from pgpj10.prod.google.com ([2002:a65:428a:0:b0:7fd:de44:ec7d]) (user=pandoh job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7284:b0:1e0:eb49:b81b with SMTP id adf61e73a8af0-1e88d09c97emr49185248637.31.1736927014705; Tue, 14 Jan 2025 23:43:34 -0800 (PST) Date: Tue, 14 Jan 2025 23:43:00 -0800 In-Reply-To: <20250115074301.3514927-1-pandoh@google.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250115074301.3514927-1-pandoh@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250115074301.3514927-9-pandoh@google.com> Subject: [PATCH 8/8] PCI/AER: Move AER sysfs attributes into separate directory From: Jon Pan-Doh To: Bjorn Helgaas , Karolina Stolarek Cc: linux-pci@vger.kernel.org, Martin Petersen , Ben Fuller , Drew Walton , Anil Agrawal , Tony Luck , Jon Pan-Doh Prepare for the addition of new AER sysfs attributes (e.g. ratelimits) by moving them into their own directory. Update naming to reflect broader definition and for consistency. /sys/bus/pci/devices//aer_dev_correctable /sys/bus/pci/devices//aer_dev_fatal /sys/bus/pci/devices//aer_dev_nonfatal /sys/bus/pci/devices//aer_rootport_total_err_cor /sys/bus/pci/devices//aer_rootport_total_err_fatal /sys/bus/pci/devices//aer_rootport_total_err_nonfatal -> /sys/bus/pci/devices//aer/err_cor /sys/bus/pci/devices//aer/err_fatal /sys/bus/pci/devices//aer/err_nonfatal /sys/bus/pci/devices//aer/rootport_total_err_cor /sys/bus/pci/devices//aer/rootport_total_err_fatal /sys/bus/pci/devices//aer/rootport_total_err_nonfatal Tested using aer-inject[1] tool. Sent 1 AER error. Observed AER stats correctedly logged (cat /sys/bus/pci/devices//aer/dev_err_cor). [1] https://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/aer-inject.git Signed-off-by: Jon Pan-Doh --- .../ABI/testing/sysfs-bus-pci-devices-aer | 18 +++--- drivers/pci/pci-sysfs.c | 1 - drivers/pci/pci.h | 1 - drivers/pci/pcie/aer.c | 64 +++++++------------ 4 files changed, 32 insertions(+), 52 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer index c680a53af0f4..e1472583207b 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer @@ -9,7 +9,7 @@ errors may be "seen" / reported by the link partner and not the problematic endpoint itself (which may report all counters as 0 as it never saw any problems). -What: /sys/bus/pci/devices//aer_dev_correctable +What: /sys/bus/pci/devices//aer/err_cor Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com @@ -19,7 +19,7 @@ Description: List of correctable errors seen and reported by this TOTAL_ERR_COR at the end of the file may not match the actual total of all the errors in the file. Sample output:: - localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_correctable + localhost /sys/devices/pci0000:00/0000:00:1c.0/aer # cat err_cor Receiver Error 2 Bad TLP 0 Bad DLLP 0 @@ -30,7 +30,7 @@ Description: List of correctable errors seen and reported by this Header Log Overflow 0 TOTAL_ERR_COR 2 -What: /sys/bus/pci/devices//aer_dev_fatal +What: /sys/bus/pci/devices//aer/err_fatal Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com @@ -40,7 +40,7 @@ Description: List of uncorrectable fatal errors seen and reported by this TOTAL_ERR_FATAL at the end of the file may not match the actual total of all the errors in the file. Sample output:: - localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_fatal + localhost /sys/devices/pci0000:00/0000:00:1c.0/aer # cat err_fatal Undefined 0 Data Link Protocol 0 Surprise Down Error 0 @@ -60,7 +60,7 @@ Description: List of uncorrectable fatal errors seen and reported by this TLP Prefix Blocked Error 0 TOTAL_ERR_FATAL 0 -What: /sys/bus/pci/devices//aer_dev_nonfatal +What: /sys/bus/pci/devices//aer/err_nonfatal Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com @@ -70,7 +70,7 @@ Description: List of uncorrectable nonfatal errors seen and reported by this TOTAL_ERR_NONFATAL at the end of the file may not match the actual total of all the errors in the file. Sample output:: - localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_nonfatal + localhost /sys/devices/pci0000:00/0000:00:1c.0/aer # cat err_nonfatal Undefined 0 Data Link Protocol 0 Surprise Down Error 0 @@ -100,19 +100,19 @@ collectors) that are AER capable. These indicate the number of error messages as device, so these counters include them and are thus cumulative of all the error messages on the PCI hierarchy originating at that root port. -What: /sys/bus/pci/devices//aer_rootport_total_err_cor +What: /sys/bus/pci/devices//aer/rootport_total_err_cor Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com Description: Total number of ERR_COR messages reported to rootport. -What: /sys/bus/pci/devices//aer_rootport_total_err_fatal +What: /sys/bus/pci/devices//aer/rootport_total_err_fatal Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com Description: Total number of ERR_FATAL messages reported to rootport. -What: /sys/bus/pci/devices//aer_rootport_total_err_nonfatal +What: /sys/bus/pci/devices//aer/rootport_total_err_nonfatal Date: July 2018 KernelVersion: 4.19.0 Contact: linux-pci@vger.kernel.org, rajatja@google.com diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 41acb6713e2d..e16b92edf3bd 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1692,7 +1692,6 @@ const struct attribute_group *pci_dev_attr_groups[] = { &pci_bridge_attr_group, &pcie_dev_attr_group, #ifdef CONFIG_PCIEAER - &aer_stats_attr_group, &aer_attr_group, #endif #ifdef CONFIG_PCIEASPM diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 9d0272a890ef..a80cfc08f634 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -880,7 +880,6 @@ static inline void of_pci_remove_node(struct pci_dev *pdev) { } void pci_no_aer(void); void pci_aer_init(struct pci_dev *dev); void pci_aer_exit(struct pci_dev *dev); -extern const struct attribute_group aer_stats_attr_group; extern const struct attribute_group aer_attr_group; void pci_aer_clear_fatal_status(struct pci_dev *dev); int pci_aer_clear_status(struct pci_dev *dev); diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index e48e2951baae..68850525cc8d 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -569,13 +569,13 @@ static const char *aer_agent_string[] = { } \ static DEVICE_ATTR_RO(name) -aer_stats_dev_attr(aer_dev_correctable, dev_cor_errs, +aer_stats_dev_attr(err_cor, dev_cor_errs, aer_correctable_error_string, "ERR_COR", dev_total_cor_errs); -aer_stats_dev_attr(aer_dev_fatal, dev_fatal_errs, +aer_stats_dev_attr(err_fatal, dev_fatal_errs, aer_uncorrectable_error_string, "ERR_FATAL", dev_total_fatal_errs); -aer_stats_dev_attr(aer_dev_nonfatal, dev_nonfatal_errs, +aer_stats_dev_attr(err_nonfatal, dev_nonfatal_errs, aer_uncorrectable_error_string, "ERR_NONFATAL", dev_total_nonfatal_errs); @@ -589,47 +589,13 @@ aer_stats_dev_attr(aer_dev_nonfatal, dev_nonfatal_errs, } \ static DEVICE_ATTR_RO(name) -aer_stats_rootport_attr(aer_rootport_total_err_cor, +aer_stats_rootport_attr(rootport_total_err_cor, rootport_total_cor_errs); -aer_stats_rootport_attr(aer_rootport_total_err_fatal, +aer_stats_rootport_attr(rootport_total_err_fatal, rootport_total_fatal_errs); -aer_stats_rootport_attr(aer_rootport_total_err_nonfatal, +aer_stats_rootport_attr(rootport_total_err_nonfatal, rootport_total_nonfatal_errs); -static struct attribute *aer_stats_attrs[] __ro_after_init = { - &dev_attr_aer_dev_correctable.attr, - &dev_attr_aer_dev_fatal.attr, - &dev_attr_aer_dev_nonfatal.attr, - &dev_attr_aer_rootport_total_err_cor.attr, - &dev_attr_aer_rootport_total_err_fatal.attr, - &dev_attr_aer_rootport_total_err_nonfatal.attr, - NULL -}; - -static umode_t aer_stats_attrs_are_visible(struct kobject *kobj, - struct attribute *a, int n) -{ - struct device *dev = kobj_to_dev(kobj); - struct pci_dev *pdev = to_pci_dev(dev); - - if (!pdev->aer_info) - return 0; - - if ((a == &dev_attr_aer_rootport_total_err_cor.attr || - a == &dev_attr_aer_rootport_total_err_fatal.attr || - a == &dev_attr_aer_rootport_total_err_nonfatal.attr) && - ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) && - (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_EC))) - return 0; - - return a->mode; -} - -const struct attribute_group aer_stats_attr_group = { - .attrs = aer_stats_attrs, - .is_visible = aer_stats_attrs_are_visible, -}; - #define aer_ratelimit_attr(name, ratelimit) \ static ssize_t \ name##_show(struct device *dev, struct device_attribute *attr, \ @@ -662,6 +628,14 @@ aer_ratelimit_attr(ratelimit_cor_log, cor_log_ratelimit); aer_ratelimit_attr(ratelimit_uncor_log, uncor_log_ratelimit); static struct attribute *aer_attrs[] __ro_after_init = { + /* Stats */ + &dev_attr_err_cor.attr, + &dev_attr_err_fatal.attr, + &dev_attr_err_nonfatal.attr, + &dev_attr_rootport_total_err_cor.attr, + &dev_attr_rootport_total_err_fatal.attr, + &dev_attr_rootport_total_err_nonfatal.attr, + /* Ratelimits */ &dev_attr_ratelimit_cor_irq.attr, &dev_attr_ratelimit_uncor_irq.attr, &dev_attr_ratelimit_cor_log.attr, @@ -670,13 +644,21 @@ static struct attribute *aer_attrs[] __ro_after_init = { }; static umode_t aer_attrs_are_visible(struct kobject *kobj, - struct attribute *a, int n) + struct attribute *a, int n) { struct device *dev = kobj_to_dev(kobj); struct pci_dev *pdev = to_pci_dev(dev); if (!pdev->aer_info) return 0; + + if ((a == &dev_attr_rootport_total_err_cor.attr || + a == &dev_attr_rootport_total_err_fatal.attr || + a == &dev_attr_rootport_total_err_nonfatal.attr) && + ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) && + (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_EC))) + return 0; + return a->mode; }