From nobody Thu Sep 24 23:33:23 2026 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011070.outbound.protection.outlook.com [52.101.57.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2650349B47C; Fri, 18 Sep 2026 14:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743414; cv=fail; b=OfYS3W0oYssaEe5YLQbScaQb4klL2JbY8xnRp/QKHOrRePObvpDuSz0g8th9VRXdGy+lswMzXPuXac0pBqvLM+nNrNvo600jHW1qM55KBR2j4en9iWlJsQlnwNOxIJqzmEw7Z7Ix3DzpqzmvOmd+wYEgwO1ZJuRIUsIhWK4tzKU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743414; c=relaxed/simple; bh=9pCY9ZeQpyAdKg3fK4XR6tx7kOr5RHo/X1snONwEXYA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VvxEVmGCE9hAbCx/6NSImZGo1M2cgTgP9AXH6QtWXX0xfFqAmY38zZFOJaTBkVQIg5Z+63MGNPhVGu/W7s7++kIOqY45C0OkRuA0g3V+lD1WxTFlmAEcqOLW0TFAJYhDIWZ9oWmNqY200BOUDe6/+zswX+Zs/HYk/z3Abar8NLY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=MAuT3nDo; arc=fail smtp.client-ip=52.101.57.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MAuT3nDo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=akhh6Z3WtPUB8BY7MrvafmAV3QnbKXzGoU8oujOPVGmAvleJ/euFcwOW/Nq4dcSZkDaNQHQlXCVwZgpG00gz9+Zd65vU3LDY7pL5Fz4tleJMjRwUPJ90m9gKmo8JXVwy/Yzs+MBeHBvcevLvLexzkq1D5FAZwHGWcUk9I9A+8HFs5bu8ezrfofjtZSmvUk1vsqqu6ZcVAU20cmOt80tpDLOlEf/tw8MlF732Aj8pDfUHfK3JQAFBNN7QTaTrUWWdzejvNQxU3vPtICkNu+GK4Sfww0vzWrV6Rfww4/h8LUa0QrOyRlu22vOZ2BLXls1Qm0B6u56GLutg8fJvDp0z/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aJQuHvx45oPtGxUW49G6fmCNHQ8AJPOM7ZoAycURC+8=; b=jR4Py/3Bwm4deFUbrbVnQoYd0qAftwSqAY0HPpKBJzty7x+iuaddRXssdi7YqAIMZ3kal6xXyi7LUdGjmRL9MmrjEixOOW9/5cKi8JUZBMAhR80RPA/oNcNDtSxWZfGp8Fih4gZXyiznArMDZNBgV5xAENBUbsPstarb1iNV7yCVMfZd2LRLgJH+YSvQpSv9OtQ0jpn/YAXg+ozUg9RRDyyLNLRa0wWL40j32R71+tZetE7B7h86Zs6ndW4tdvB1HMhJhPXa33iWZbesvzNcEMTqyI3PRegIMlxeX+SwhI9iAkK4S01t3uTpip3ETBy5kp71lMrMtVW7LDWL5DQ6Kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aJQuHvx45oPtGxUW49G6fmCNHQ8AJPOM7ZoAycURC+8=; b=MAuT3nDocPyHfYu7ZI/8GN124VAcAyisu/WMBja8nzcIxfRQLC5+GGKAr9XisIx/H9KOW1U4AURWqq+Z+Qda93v4jXAs9kfyOsxsCVruNWev4VJVwlydu7SxLbTt7dZ1hCst4qGSBQ7n+Op6JEFKs9wWxNajOrSqaex0aN/K9bY= Received: from CH2PR15CA0029.namprd15.prod.outlook.com (2603:10b6:610:51::39) by CY1PR12MB9604.namprd12.prod.outlook.com (2603:10b6:930:108::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:49 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::4e) by CH2PR15CA0029.outlook.office365.com (2603:10b6:610:51::39) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.11 via Frontend Transport; Fri, 18 Sep 2026 14:56:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:49 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:48 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 01/10] MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM Date: Fri, 18 Sep 2026 09:56:09 -0500 Message-ID: <20260918145619.3016889-2-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|CY1PR12MB9604:EE_ X-MS-Office365-Filtering-Correlation-Id: b1416ca9-4f06-4059-3516-08df15951138 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|1800799024|82310400026|36860700016|22082099003|18002099003|13003099007|11063799006|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: k0e/RMktfW2YPffZoNvGp33+KiW8qEF1O8QkLXshXMSmNjWzUYN7dPAMo7p2INTJgcsvmkRPFuFE9eqxSrX2SgqeSNvTLHtHwDDSmYiqCKyWbnxymgEF52kwXtXjIbhvgaKFfNkHssXhzYBY1Vme/9VOSi8yGxFSJOVzQ38e/3vF2wL0qRNMw8T1Wy5FvtI+KoMVyIYKsFHYIug1n0sD5uCMQH8XvrFclXkOUNI36TsSMqSnbdv0zl8XDTYExVww2hydPmMNeqctzea7in0L29DxGm2/c30J7jTZVwg/KE/zqmo+RM31zVz+YIT1b0zBfH6i5ZWaWF5pAa86p93tukmz2/wgXFJbsmYjs9tEVQBJdvjCRRX+3h/XezvFErBC8Ua7ymS4+taVUPnsGJ2w0vJOFRpcspOAJQqy+EshnytdTK2YCD35isa1daRyhxfdHnJBmqB0yw/Gq178ZYKRPru+0a3G3zGaD9mQG70X2686GPZsNuVF2t7qrGBdRCi+3mGkiKnNpIQMVXS5lX/Tp2DPZfgiDVp5pQgJ7UVwPGWZ/QG+9o7X6OqvNLF+m3Rsknm99DQbWnh80arqX/OMPk4WwWm39ybzLVm+xwhSw/tmSsHdyPYj0eoqKsAGtCMBmggiQ+S/mCuku32o0M/jzA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(23010399003)(1800799024)(82310400026)(36860700016)(22082099003)(18002099003)(13003099007)(11063799006)(56012099006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vS/H/nzTtZtBOaW6cfGrN2omsLuJAVhU/ooXvwfKcQwVmUGy8a9ohYNQrlGiAaibyXyPPqnFeAhETafVq661Gf7TAU8h7UACNc371Bd14Go0e6Zeva7qM3R2OMRiL87CbNbKGeRuR/yUG88OtFijPmfowgWKmsiOrz9HcwsLtviapnT6GPdkNn7cJwqEW+Ml+nbDZhiU3Q0SKLEGjP3EVXKcEXYTzkU85cMImFZ+B3kJN7duqgvmc2isfrx2mt0TlDP4RmKKurBeyDvl7Vqvt98836EL+2BEviSXbrHZNQZ8beayf6o2/DuydM+pUWzaxa5w76tOfR5tdZDBNcAFvm5I3XcKpB4ZKZLMIUmyNKOO/wWeZ52DaMbr8DQXhhTc27m/79meZ1m7D3QJEjy2iSUtJK75U5zEpK9JO5Q+hd6DqqRB7QHKQ6OxJHBbQcuU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:49.2554 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1416ca9-4f06-4059-3516-08df15951138 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9604 Content-Type: text/plain; charset="utf-8" get_maintainer.pl returns only the LKML catch-all for Documentation/ABI/testing/sysfs-bus-pci-devices-aer, so changes to the documented AER sysfs interface do not reach linux-pci. Add the file to the PCI SUBSYSTEM entry. The generic Documentation/ABI/testing/sysfs-bus-pci is left out on purpose. file_match_pattern() matches on a prefix, so that path would also claim eight sibling files describing individual drivers. Covering it needs matching X: lines, which is left for a separate change. Assisted-by: LLM Signed-off-by: Yazen Ghannam --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3a19da74d00c..3df47851869e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21110,6 +21110,7 @@ Q: https://patchwork.kernel.org/project/linux-pci/l= ist/ B: https://bugzilla.kernel.org C: irc://irc.oftc.net/linux-pci T: git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git +F: Documentation/ABI/testing/sysfs-bus-pci-devices-aer F: Documentation/ABI/testing/sysfs-devices-pci-host-bridge F: Documentation/PCI/ F: Documentation/devicetree/bindings/pci/ --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013062.outbound.protection.outlook.com [40.93.201.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF45C48F852; Fri, 18 Sep 2026 14:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743415; cv=fail; b=oWE08DzQJHCQBptRAHVnvOnxl1VCFj5SToMxGr1kuaUtVO25Wd49/NNbDX72/hYG0dyfLAQAVueAsm/CgtYBIF8VOhXa8jEDtlHtHOJJqh95nCXhiJfJXQ7mavOhZx9rSePHVxh7Ba0TRdUt56EP3fnygKyFXSSpooWQz26b7ag= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743415; c=relaxed/simple; bh=PKeM09skoyhUtMoUjeV7TXkPfHeVFynUS+exNEx9l68=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m/2Xxq5E74uBfNEMVo+Y+9F4DY8OXYD5QsPbTcS++HPSo7gS6G56RTrPXnFdqiGOE8JWDHgUvbRK0eZfxZVZjaN6K7sE9gLhWpfNAqm6qVchPg35t9bmMB5IyV8C7SHae9/PgQqleb/KjgX7YKzIcJkwAnzwX/muMhH0Eu7/3Tg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NosAzs8M; arc=fail smtp.client-ip=40.93.201.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NosAzs8M" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O1p6JY2lQJrLoCv7Ze8RvsjUDaTi8NWr4Da3yS66HkxvnGnyUfBmBMvVeHcSwSAIkKLBZQ1puEX36yf/WkCEFClx5Wdrb2xqrfZcE8s3EAtG4AuPXnc/Jkau+cp3lc1EJWctlE4eaT5EqEEWQ7pRwWWhO88shjV9Ssy2ACfIvSniI54sf/7CF0x+mPDLtOaawhs9fwRR5d1B/B/L+K1/fXQ6TWvGWeR0aQ4ZSXvlA0hobHnC/bgVEnpwIKGyIwmQacGC4P2mh546EFSk17FeDbU83CdlnwckP/uT6M/CdR8VsIv9eBmbEgkTdJ9Ma0ZkGjNrTH2QsY5VoOJDDoCimQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iWZ0IvplSI3DCJEHDNVxG3+R9GdTYNvZV4xwQd0xeUM=; b=I5kMHg4eFeeu85jFxR7yx7bkbQPse+rsKlQzh8ezI/HuwffzklR4w8BT9fwtFw3lhlfaNpgHMvFhGZw3xvGTg7A6VyKo0A38btTFKjrkU4j2xfO9C8LubQ4R4eQJeXVMDj68PXhtmckfdkIAJUMLsZKgY0ZT9M2HWkqYY8otXcl0QPQwndre0ravQW9zEm+mH0llv3ZQ83Uj6X802AoX9SQyDhDuCKLY8WmsTVqh3LqtSCZK7t87N9b7UFgZUTCO+pB6lbrACHD9WthvC1mcD0FF8A1SWtJRK9OS29gbGBVROW95PyrX0z8gyH6eHHi9gXr3W7PnTCh4KnJey8dMaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iWZ0IvplSI3DCJEHDNVxG3+R9GdTYNvZV4xwQd0xeUM=; b=NosAzs8MpNWJveFzQEEoVwf5Ha9Glf9wg3jp/3H1FdTrEXWi4BTtnSGgc1uhrmU7nZtdS+vXEM4c/ZLlMpRnXIg6vnJGQ8vp1pHayBzFHCUgMycKCYi2QwOZCfFEyU89ds58PS7ESjy7FIIbMUupQk1UqwyXl47I51KEm6nsD4c= Received: from CH2PR15CA0030.namprd15.prod.outlook.com (2603:10b6:610:51::40) by PH9PR12MB011960.namprd12.prod.outlook.com (2603:10b6:510:418::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:50 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::38) by CH2PR15CA0030.outlook.office365.com (2603:10b6:610:51::40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.11 via Frontend Transport; Fri, 18 Sep 2026 14:56:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:49 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:49 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 02/10] PCI/AER: Clamp negative ratelimit burst to zero Date: Fri, 18 Sep 2026 09:56:10 -0500 Message-ID: <20260918145619.3016889-3-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|PH9PR12MB011960:EE_ X-MS-Office365-Filtering-Correlation-Id: c08fae9f-ab3b-4cc8-a5bb-08df15951190 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|376014|1800799024|36860700016|10067099003|56012099006|5023799004|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: zdiX1Sd7ShoACOmYlYe84DMda9vyEAEehh1usKJXdZrRz4mXvAY+3CPHk6kYAzr+RLiLy9MbwANWnB3+qFgsBrkJhW3nmOIawEBqkX/ZkOQIl91RSACdZheBeZGNo6Fa4Bh+QKDrmd36LTFrOqe/5tiDSBGY7W/KtN5ypzruP3Blxog9Ql344rdqX5jGU+bgXCjTMSjMJpOeUop/JM+XPeQ42UB3V2RyUm1wBiDLkSmK85wk+vzo3yeDpuR+8nRJDwYDmsQ9zqFqIw+KQtDCshxRnks0hg0VRcKV+EKxDKoqVgMwj0V16i2h7ZmRGoAg1prrL6EpPkUglk0tkxpI07c1qBZrLCs1z5eEr7cZdIJNLdEQTXGCp/H9lAEzMgWI9GJsbVSNReYAcjvTAdJDW/kRlWXq3qnOZJL8W0EDT8YYk1ZS+MSXgIJq69c9GaYWdU6fPKWpnK+7rHnw1ZZvGY/1Su4OI/jSuENm9uNSDX4rVcynGjP+iCggcERDBpzDlVnIzy7jicMP5Z12UBUg2QDjfzk/O/vtDQpEti11UqOwk8c+hFze2+SPmMSrTOlP/ZfNzCIoSBpuSganXxQAmJRaHkmMibveFDPTnbj7ZeR+AA5ZkgT9ayLVKnxYvHC52qiFj5yotLX4bPlBuyHjIUIYlJ1ICweC0AybMK+XlxAjczvhUYLpgZDk7DOlrm4mFAi+VIWcsC5Lz7CyYhmJuQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(376014)(1800799024)(36860700016)(10067099003)(56012099006)(5023799004)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 46JLxdqYXbMkGJxXmf+y5b9BIuIA0JuIYIIzi9elE/BctaezuoVU9jbUhl0/AnPPvmHQBoi8p/Vj9kvRpL7luBx08Ot8iIT5D/AAYK/V+FdWsRFdF1jsLXDGEXlC5m+tCIwibzyU/xKdiO9B2puJyU4ik64ykVKESWBUUDWP01GbNkO+lVNHJg7uHaKGuSrrRUs61HHazhVdZsXhQwltX5xC6i2JmNCvm2jndmVXSXD0k/k7DzITflbdjhq0/imzLiSsM67SS2JHig/vjDsA98Cf+L09BnMRZjtWPFby7rw+iZsbE7VlTmXRjUpFpUR6RKhH4LQ6bGgmT2Nr7WLLSy1rK7OHzjHn9xWYXg7DA9khVY7MOQo2qWxKm8cnt8RP3p6HVY/chNUh7+k6hBchrY8IEoD7/7TSDhow8ODrossfbyrB0jOz438DNlZJfWa7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:49.8330 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c08fae9f-ab3b-4cc8-a5bb-08df15951190 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH9PR12MB011960 Content-Type: text/plain; charset="utf-8" The correctable and nonfatal "_ratelimit_burst" attributes store whatever kstrtoint() parses, so a negative value lands directly in ratelimit_state.burst. ___ratelimit() reads a negative burst as an uninitialized ratelimit_state and splats a WARN_ONCE. A CAP_SYS_ADMIN write of "-1" then warns on the next AER error and suppresses every later message, with nothing in the attribute to show that logging is off. Clamp negative values to zero, as the companion interval attribute already does. Zero still suppresses everything, so a negative value keeps its old meaning without the warning. Document that in the ABI description of both burst attributes. Document it for the interval attributes too, where clamping negatives is existing behaviour that was never written down. Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits") Reported-by: Sashiko Closes: https://lore.kernel.org/linux-pci/20260714191826.BA81E1F000E9@smtp.= kernel.org/ Assisted-by: LLM Signed-off-by: Yazen Ghannam --- .../ABI/testing/sysfs-bus-pci-devices-aer | 21 ++++++++++++------- drivers/pci/pcie/aer.c | 3 +++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer b/Document= ation/ABI/testing/sysfs-bus-pci-devices-aer index 5ed284523956..215cf8bd4c30 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer @@ -130,9 +130,10 @@ What: /sys/bus/pci/devices//aer/correctable_rate= limit_interval_ms Date: May 2025 KernelVersion: 6.16.0 Contact: linux-pci@vger.kernel.org -Description: Writing 0 disables AER correctable error log ratelimiting. - Writing a positive value sets the ratelimit interval in ms. - Default is DEFAULT_RATELIMIT_INTERVAL (5000 ms). +Description: Writing 0, or any negative value, disables AER correctable + error log ratelimiting. Writing a positive value sets the + ratelimit interval in ms. Default is + DEFAULT_RATELIMIT_INTERVAL (5000 ms). =20 What: /sys/bus/pci/devices//aer/correctable_ratelimit_burst Date: May 2025 @@ -143,14 +144,17 @@ Description: Ratelimit burst for correctable error lo= gs. Writing a value before ratelimiting. Reading gets the current ratelimit burst. Default is DEFAULT_RATELIMIT_BURST (10). =20 + Writing 0, or any negative value, suppresses all logs + unless the interval attribute is also 0. + What: /sys/bus/pci/devices//aer/nonfatal_ratelimit_interval_ms Date: May 2025 KernelVersion: 6.16.0 Contact: linux-pci@vger.kernel.org -Description: Writing 0 disables AER non-fatal uncorrectable error log - ratelimiting. Writing a positive value sets the ratelimit - interval in ms. Default is DEFAULT_RATELIMIT_INTERVAL - (5000 ms). +Description: Writing 0, or any negative value, disables AER non-fatal + uncorrectable error log ratelimiting. Writing a positive + value sets the ratelimit interval in ms. Default is + DEFAULT_RATELIMIT_INTERVAL (5000 ms). =20 What: /sys/bus/pci/devices//aer/nonfatal_ratelimit_burst Date: May 2025 @@ -161,3 +165,6 @@ Description: Ratelimit burst for non-fatal uncorrectabl= e error logs. allowed per interval before ratelimiting. Reading gets the current ratelimit burst. Default is DEFAULT_RATELIMIT_BURST (10). + + Writing 0, or any negative value, suppresses all logs + unless the interval attribute is also 0. diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index d8dcd238fda1..350b57e5ccb1 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -751,6 +751,9 @@ const struct attribute_group aer_stats_attr_group =3D { if (kstrtoint(buf, 0, &burst) < 0) \ return -EINVAL; \ \ + if (burst < 0) \ + burst =3D 0; \ + \ pdev->aer_info->ratelimit.burst =3D burst; \ \ return count; \ --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010006.outbound.protection.outlook.com [52.101.85.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F99F4F68D4; Fri, 18 Sep 2026 14:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743488; cv=fail; b=WqLLlBDl3BAbhkRcO5yR+9Zwdx2P4fTjYze0JAYB++IMlJ6t/IbEwVKpoRzNIiVmBMz0nCsa9Z4GwLfV9RZqhOD771kl5b7uutB+z3H3gCXkZ9XbO01hAzFitFZKpNhcV5jzb6Bu7AsM3xbBy8u4/qnQj+cRsJJiV7nZxZmuw9g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743488; c=relaxed/simple; bh=W9RIJR0jgri0yz9Tqq/CmoZcWxa5qyliKAjlfDdIl0c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AXbucIgbT7KWz/+LQMSuEn4qpR5rZWB09ECtJLjwFlnS1QMeBgUyPfFpat7VQpU+kyJHcM64R89nHV6BCBjjWevPDIiz/Xt6dL2QGhH40VRUq+pXlZf/hpc8g6p91amsRW8RnU2CHwII0CWAhrPV+lIGqn52vqFra6n75V+Z3WE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2qAKVY6C; arc=fail smtp.client-ip=52.101.85.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2qAKVY6C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a2MwhJynLQhRFhSomMRk/M7Kt1c8+4l36wneR6hHipbGl47PYEi3ZrDtiF3avfntGA0H9SndEe2mMps6THW6DNnKE5lUuoYtkE57v6lpgEUXziXEgBWGmuj2eQIFXpQXKZJBfi0wB8qsZ88fBknI66yumxShOA2pu4R+oSp1heUsDEaY2Tk9Bu+YPfpqWwPRWhfCNkgtRj9Atbwlenj+70E+fgniRUwcJ4o38F/3DRCj6nRePqnLDPMru58sJxbKZDtrQk+yPV+5iWCIL5nijgXiXFQKrwR+MBd01fEl1ZB1iisUv8w5DXsF3G77mFxA0rwyiafmgnqCC9/nvUf6GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0/EJzjalnDkepYCUht93RhoKicB4bQsIUHJ8ISUjGHg=; b=Ugx/aTyiMY9rE+4A0ylrrkYkfRLDOO8LTqZdFXeF5Jf3cfB0AtgjmzIaPa2tOqYniBiwu5rVqYYilyifMg5yXeHBa9PSeimRJIH6RPVhdcyifpDZW941toReDkPvWTAGSaQZ4JPnWZG+ZPUBFWLwB6VY+NJ4qQF/CNc19zpsZH+uryn9j3In1hC4VTfi2/NW6I46RVDvs2MwNnhqWtZuH8xsHKS9QfrhYxGmVL40KCp4WlQHxeU/G+vQnr3yusiG4sovvuSFR7cBVu4sVPG5ZTNlw7bn7NbC7swSt8hODsB4ErlPvElxxiHpgJwxCX/yQLJLuKcrvFAsEeuOo9Fg3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0/EJzjalnDkepYCUht93RhoKicB4bQsIUHJ8ISUjGHg=; b=2qAKVY6CTSQru5hlTYf7ZlxC/ZMjcTxUDX2jByfWGOEDN6tBZHb7S+/faTGd0ffcePEuscutCKuIQQqrTYo99mS3uYzrzELjV+u58V/oiIqSsIww6gRooNohJ2JsvJlYTTvsZaldmU10bFqb5ybpsayqbxm4+e1DISm6zHjucQM= Received: from CH2PR15CA0027.namprd15.prod.outlook.com (2603:10b6:610:51::37) by SJ2PR12MB7845.namprd12.prod.outlook.com (2603:10b6:a03:4ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:51 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::97) by CH2PR15CA0027.outlook.office365.com (2603:10b6:610:51::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.12 via Frontend Transport; Fri, 18 Sep 2026 14:56:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:51 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:49 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 03/10] PCI/AER: Report the ratelimit interval in milliseconds Date: Fri, 18 Sep 2026 09:56:11 -0500 Message-ID: <20260918145619.3016889-4-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|SJ2PR12MB7845:EE_ X-MS-Office365-Filtering-Correlation-Id: b9fd49b7-030d-49f6-73a3-08df15951290 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|82310400026|23010399003|376014|18002099003|22082099003|10067099003|11063799006|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: lOCa0t6IyExMl/6xKlUtz3szGyKhpbQo1KO0AHtjOWxHGU0wremSx7stF+YFrtCEnofbcwkQt6pX0jZllFa2Fr9hRwrjd2NgduHlwWOvFaVAWDsViQkJ6ayPJe8OineGV75g33mPloQX0gtJFjos5f/aXzFQ390RJwO/isPp5srWFJia0axrX2tw+ZxUu7DnuAvoYedF0LGGXhHO5NyDSHDoBlCKdptvGN0WGAOPji1fAlaNWUsIjlpughBkoHtHJppZfen/LzCtINUDkb95N1qiaZIG5oQ/GbpxanL2mX1Q5G7p2+jNgzVZ55saVWZ9w3qOYP8/P66Y6+ENTKQ6j7Ut96KuREy+N4er0EFUzFxJWQqo4nAYRkFcBz26CPbOEHHIOzE/6oWlXVHO6eeaFPwZ1o+K7uLwfl04jVSpLpRxwGM3vxKKiYV9cIw6jyucdNoKoTHY2vRDsRerWTm9SeCNyNH+nKxmwD/34LHGTxxosEnTpxnatuec9kDYyjbT7xCodrL7VNrnYG+cknfh7yYV8MfYcsOEwGC6P28YdZWLUeJW3rpM8pkYALN+gk6SOo4P01u5ruLfqg+jRuL0pEQdzvdTDSCiY8SunY8xSv9ntZ6W1X8dmaX/Em2CRrIRw3bUdSaBX+Xd9knRiD/YqLGm2x0ITlQQRFnNxJTsN0KEplbfMTXtch1mrVDfIeraSofNl9Ppxd5ohE2HcSzI3g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(82310400026)(23010399003)(376014)(18002099003)(22082099003)(10067099003)(11063799006)(56012099006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JkAF3V0h55x9nPHaWaEGu417AwNFMbk/Ee5y7yKqkz4nHWM887Y0a8ozsIhbP1RRe2+8cE3Y7ljAyQ19nZItdkMO6G/zHSqRS+LLUSahzIu0J3P38Aj/GqZMEMc99beYYNvB1Hn28qJDPScPswQiRV+E0TAGq/z8fMF5cg6b15rJPGwhsdmSnrBDa9jz56pGcqhNGuC0z+EB70pqsW+8TKWGx5upUSLNiYJIg7gv0CIbmjdcpATURcFUIJuMiu5zDx7l0LhkiVikMOmkmKMbjVjDXAcn1DdAPVhFwkM9IGBtPvfeSkNzwpt6YMbPEVW0B6RYM246hY4HQwhGtliKS+AMEQqLoZ87a7MmEzpoMjPrL5dW0axCyTUqRZN5kF3ncrBwv1IR1nQcRp/xOhfaJcP2parA0D49+WawXl8BLx9DwO4B2F7fwI3LgxkfD9VK X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:51.5118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9fd49b7-030d-49f6-73a3-08df15951290 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7845 Content-Type: text/plain; charset="utf-8" The "*_ratelimit_interval_ms" attributes convert on the way in but not on the way out. The store path runs msecs_to_jiffies() before assigning to ratelimit_state.interval, and the show path prints that field raw. The field therefore reads back in jiffies while the attribute name and the ABI documentation both say milliseconds. The two only agree when CONFIG_HZ is 1000. With CONFIG_HZ=3D250 the default reads as 1250 rather than the documented 5000. Convert back with jiffies_to_msecs() so the attribute reports the unit it is named for. msecs_to_jiffies() rounds up, so a written value that is not a whole number of jiffies reads back rounded up. Document what a read returns, which the burst attributes beside it already do. Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits") Assisted-by: LLM Signed-off-by: Yazen Ghannam --- Documentation/ABI/testing/sysfs-bus-pci-devices-aer | 6 ++++++ drivers/pci/pcie/aer.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer b/Document= ation/ABI/testing/sysfs-bus-pci-devices-aer index 215cf8bd4c30..732fc03ef5fb 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer @@ -135,6 +135,9 @@ Description: Writing 0, or any negative value, disables= AER correctable ratelimit interval in ms. Default is DEFAULT_RATELIMIT_INTERVAL (5000 ms). =20 + Reading gets the current ratelimit interval in ms, rounded + up to a whole jiffy. + What: /sys/bus/pci/devices//aer/correctable_ratelimit_burst Date: May 2025 KernelVersion: 6.16.0 @@ -156,6 +159,9 @@ Description: Writing 0, or any negative value, disables= AER non-fatal value sets the ratelimit interval in ms. Default is DEFAULT_RATELIMIT_INTERVAL (5000 ms). =20 + Reading gets the current ratelimit interval in ms, rounded + up to a whole jiffy. + What: /sys/bus/pci/devices//aer/nonfatal_ratelimit_burst Date: May 2025 KernelVersion: 6.16.0 diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 350b57e5ccb1..5498fc605556 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -688,9 +688,9 @@ const struct attribute_group aer_stats_attr_group =3D { }; =20 /* - * Ratelimit interval + * Ratelimit interval, in milliseconds * <=3D0: disabled with ratelimit.interval =3D 0 - * >0: enabled with ratelimit.interval in ms + * >0: enabled, ratelimit.interval held in jiffies */ #define aer_ratelimit_interval_attr(name, ratelimit) \ static ssize_t \ @@ -698,9 +698,9 @@ const struct attribute_group aer_stats_attr_group =3D { char *buf) \ { \ struct pci_dev *pdev =3D to_pci_dev(dev); \ + unsigned long iv =3D pdev->aer_info->ratelimit.interval; \ \ - return sysfs_emit(buf, "%d\n", \ - pdev->aer_info->ratelimit.interval); \ + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(iv)); \ } \ \ static ssize_t \ --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012062.outbound.protection.outlook.com [52.101.53.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2402A4FD281; Fri, 18 Sep 2026 14:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743426; cv=fail; b=cSNmFoiK8EGRKeKtqXrpE0PzqA1Skt0jSOFJg0bpIcmnIAOzV8K+4PhL7YjGZ7s1Kt/kd4KkMbZnBMXKt54YwYxx9Fm1XG88Gu3pBhDODszTIOu1tHziU+ebUWAeuJ9uydgiZ5su8Z1zavx1H/4Cauy1FgOVd8xewTgJGl5e68o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743426; c=relaxed/simple; bh=ABlfQmlNy4VsTWgtyfmUTNEoxIA+Z+g75wcAXFRwA7Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FudJncVDnosIV0jDUj55LxWhv+aDR5sogvpxdtOjKOI/i1JbpJ31dWpS1Q9PacpLmlW2IZ0MHILk+epEdXbesmcEcE4dButokfCB/nKAQo0gRDmt/iIBuYTipargyLbcs2phW15UJkPjKdSEoPXVjELxYKorMWLWNU6mrp8KFLI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NoQx8YPc; arc=fail smtp.client-ip=52.101.53.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NoQx8YPc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PTcW2RQY/ly1tXX38odVWzjYfDdD4Szdc44AilUhmTUnm1QLGUwm4DwSGFxrpyc2E8sETHBfaIBEkdgoiWY44fpTM079BJEN7TziGczQgBuOekC8wmn0Y/b0euEsTxdpSGsLn1A5ex/gBngRT9hVUz2H6d062jPPkMgevmRxIr/JIhHwT5b3a1051qxEYKovgRXcuQMnXOD7oZW+VZOq1/0WdfnklHiSa0BGoSXh39kwLrChQDmGRWc6GS19tAt2N2tHaUeb9eiVsvm2e0tXjfQHtM60N/D0UqSZBlh0Lz72GQp5Smg25uQn//BCQEH125TCY47FE1kZblxLlI22rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yniPFnsrsXiNU7/1KIm+Tdr2jVAFwyvuEOJNXY9JFrk=; b=Hdggj0XOd8W541MqAoN1W92RPN6VBmSX+3qZgyt9fOyWlsOJPB7r17U98mM+Ajk02bEAOqBnEec8Na7brU9oM+XIddO+jC50Npjk8FB20x7//n1OpyrkmEbU1zJNzfx+PNwxu5otS8h2pov3YjQuMl7QIGsq11x8J46P5fGOx+lTs43CLIGp/jS/n9qx6sZ+lYB+oxtSF8yTTiA1UAGH73ca36v8Yz7xsWXLmgoRi6u1UkAN8G2jWQG+LtjfYGwUnpP7NSjUTKT+Pncid2B0++hIHaYwQE+wJdhTV6io/XbQvEv04cZPumzC1c5AB/x45nkvFsmuwFVkf5jK5JkbAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yniPFnsrsXiNU7/1KIm+Tdr2jVAFwyvuEOJNXY9JFrk=; b=NoQx8YPc46HbvjWFG+zgl7y8z3r285i139AgLL/LRGNiNmHYd+ZzMaCd5yXhhuY523JShtzIeqp0luX6o0qe8MhWsc/bAHhCh8qVNazw6L4p8ek+E7h5NamkQ+HxBMfd8ptL59w7nkuFrrNU89k6h2QnMBI4mYo2fNlHJwYBGa0= Received: from CH2PR15CA0021.namprd15.prod.outlook.com (2603:10b6:610:51::31) by SJ0PR12MB7474.namprd12.prod.outlook.com (2603:10b6:a03:48d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Fri, 18 Sep 2026 14:56:52 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::20) by CH2PR15CA0021.outlook.office365.com (2603:10b6:610:51::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.12 via Frontend Transport; Fri, 18 Sep 2026 14:56:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:51 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:50 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 04/10] PCI/AER: Hide the "aer" sysfs directory when AER is unavailable Date: Fri, 18 Sep 2026 09:56:12 -0500 Message-ID: <20260918145619.3016889-5-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|SJ0PR12MB7474:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d4a8700-cfbe-4d3f-5725-08df159512da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|82310400026|376014|23010399003|1800799024|11063799006|10067099003|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: Mw5I0XdhsZdSV4YOgysVgXMwv2Meh/P0YnbUm8U2yLdgdaAwsWHD6VOs8YLkZbbiNly/XG4Zp2jX8qjxEmxpoaVMLNUAxq44YefOOgGyTGpRp1uvedckSc/65/gvUarHZMnY67+VJt/w5ClXndp6l2C6k5mlpAF6/w9zFXNCyiX7xNeew0VDf4RqisDqbw0WazsenI3FWY96E54xNgm3gbQ5q3i+xidTM2qVskRQfoxeMlrPhCOK5+C7Qtp+H5ANQahyUjKrrwsHg2eClDUwqOdFaMmxhR6W1MV4/1X62389/bRzifNfEU/9SgaCDQIgax/tS2ACrjVzcPFaECLn7AAaM4GffUg5vTmjq50Yg+OOegGVbD8yUkKG+ZfjX3csRoiFGRttf7gHFmwbwStwJqZrhZ0voFywnFB6oLPyx8Mfb/mzF8TcEOvpVd+fzJWKqni1arT6pqiqWn2VaAWcpmjq66QD3ZFyDf+71yU0kucLr1FMqHrKjGzPbwaSVpzRI+oB1TnjWJVCxf7AcPTfpVGiNDp/8LQknivibBAep0hMUczGHf2zBTrOJlPTYtnmhOhXccnN0Vr8CCfD4VTf9YVCKmaGw4cN2Hd4DjRRBGeUv0Q+qFia2BMvggSptZLz/Pp6c3LsQOP8wpzcCSjdV7iAtGiwOV/zThRB62mP2YCboDe7ofT35p9kmg5Ka7WHLWsE53PZMUQyI14cuNJ6ag== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(82310400026)(376014)(23010399003)(1800799024)(11063799006)(10067099003)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /2YrywH+wsXj6uaRRmm6F9envQZlawgjlrSsmNw9FXpVdL33IC61Lh8JG1/pG0sYJRMokElkJGJENafLC5S4YI616cfcdDhb1IXo21LrOrCTkweXewysrjCLzLAsAHl8GdYRHE0JsH2CdmQ8+7HDJCB0nZHWnVkItznn+LiYZTOPqSmL4l0Zz/+8pWSKH+Rd9HD2udD8eDhXjSSUmxPx2TstmTIIjUUtrdjSyFrjHiG6H1qwz2TMFbz2zixuJsZi4TjB0TiM9k+NsFF/KC2YVx+ICu17zaUGkFafC8wf+Q5QacSA5hnB+v67mFKCrMc9ZxpJ5S0uzCn4jeJoGUPgk0PiYJQ9Y0I/EmPJUfXl1tY8aQLJlDDIklDG6m+UC4GZ8uec11zUobi7tiMdNeeAOWpnU0NczxNBHTGkOTHx4wQFuW2q4WJ7mFhN4aCI1EDm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:51.9949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d4a8700-cfbe-4d3f-5725-08df159512da X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7474 Content-Type: text/plain; charset="utf-8" aer_attr_group is a named group, so sysfs creates an "aer" directory for every PCI device. aer_attrs_are_visible() hides the attributes when the device has no aer_info, but internal_create_group() only skips the directory when is_visible() returns SYSFS_GROUP_INVISIBLE for the first attribute. The result is an empty /sys/bus/pci/devices/*/aer/ on every device without AER. Switch to DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(), which returns SYSFS_GROUP_INVISIBLE when the group predicate is false. Drop the per-attribute callback, since all four attributes share one condition. aer_stats_attr_group is unnamed and creates no directory, so it is left alone. Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits") Reported-by: Sashiko Closes: https://lore.kernel.org/linux-pci/20260714191826.BA81E1F000E9@smtp.= kernel.org/ Assisted-by: LLM Signed-off-by: Yazen Ghannam --- drivers/pci/pcie/aer.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 5498fc605556..91d73bd2ca7c 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -777,22 +777,19 @@ static struct attribute *aer_attrs[] =3D { NULL }; =20 -static umode_t aer_attrs_are_visible(struct kobject *kobj, - struct attribute *a, int n) +static bool aer_group_visible(struct kobject *kobj) { - struct device *dev =3D kobj_to_dev(kobj); - struct pci_dev *pdev =3D to_pci_dev(dev); + struct pci_dev *pdev =3D to_pci_dev(kobj_to_dev(kobj)); =20 - if (!pdev->aer_info) - return 0; - - return a->mode; + return !!pdev->aer_info; } =20 +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(aer); + const struct attribute_group aer_attr_group =3D { .name =3D "aer", .attrs =3D aer_attrs, - .is_visible =3D aer_attrs_are_visible, + .is_visible =3D SYSFS_GROUP_VISIBLE(aer), }; =20 static void pci_dev_aer_stats_incr(struct pci_dev *pdev, --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013018.outbound.protection.outlook.com [40.93.201.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1D004FC352; Fri, 18 Sep 2026 14:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.201.18 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743422; cv=fail; b=FMcTq1CUzbhTKepvV7nyGZPR9drMnm3vaGmms93gF25vjAqRWM1szKBO7IRskc3t7qtuEl+xcxgNbdTfrXZmozdFXIRHj3FNBCUkefKiyM8cYaxP32wMDiFHQDuhx81Std2uluiSe1ppqOfTjN80fFq+Qb3anzMXnGYLKHXh+oE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743422; c=relaxed/simple; bh=7MRMSn+YDW9Pnvrb7Usc6jhAKmzrYYTAxMLralsFcHk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rEzSHc2qFfEzhHg/odBM9FVSpdr5yOgMJg/FOHSOmV2KjzPjJTv8u0lP3mWRTCyYc0D4GR8hiPc0yp2z0jEr1C+jJk9Pk26kEccfK8vAPWa1T9bxa5Di3C8sjMSUkDpNKo6/LZM2XVW/CmfC78EGvIbIygH01yc3dIsr7bqdw6Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ZTkGeFX7; arc=fail smtp.client-ip=40.93.201.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ZTkGeFX7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aiaUrCzHh10FK35WPq81eS21x1YLaMeSzDuSnrR5sj+3XqXn0YtbHd3cAtrGP+vRiYg8XAXggKDZKiM6Vz1C0CwXvWotetM1QiBQVXpOXcT5v1wqVWyfSOa5aSvEb6m4yWTLpi/7TD6RdPDMs1fFsHGxkxU5IQgLufhWcwCcnGqY/XcqaoPRcx31ADt8/py5GmBARM7K1eqkqXnZxuXlTSeQ8vT/OcikWziTYx7MyJMylVU/CrpEh5cp1Bd9G+Y+09Jyv6C9Dz74UCeO9hbs0giQr+Gjc8cnJ1OZ2kZcIQ7M9yMk3KhrBJQaVvvD+qZz+yUl6sRTgwjv6Szjc2qfyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XP1jPW8iXN9pCm9A9aJjRacn1gXM4bSqRMNPAOib3Ac=; b=O2qqtBqx/Awlc3RGMOQCqkBSZ5zRE8g6GmCPsHNaqq9prNRBrD1Bfhktw43pL5ojGuZpAOa+T1gnnxjDKOmGHJwTbraPRn7qJVbFKDCE7TucI52kziE5Jmwuv4G+b80qUPL/YZyePlS3EkMD2XPADvbEYzwjZXb4O6J8/wxTEkng/3gwtm2tFL7gwC3r1+JbTyeThdWaLEkrwNo4zbDsqYoHr1l1ixDEYXvCANrMw6Qrs4mZI5S5co3IffK+imwfUK1oDzSh8i42FtKrcRdmIBPaF9UB3kPN0sMZtDgnBcAK9aavwm9p6goatggZdFX9SDrYEfrNzFGd2dXVEBmFuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XP1jPW8iXN9pCm9A9aJjRacn1gXM4bSqRMNPAOib3Ac=; b=ZTkGeFX79jZhRC8vgnGnzFGQ6nVuqFd0x91KgYOHqKCbjSPiUUj/QYxzfI4mokYzSJ9qBlcJ7iOT8vH4k4Joux9JnposBCsMtSWAjnffuSyq4f/k6hj4M5TadtepVSo5ryj13JAdqPyxX4NmJLWRws7wi7fl+wL6bLRT6+nTmZ4= Received: from CH2PR15CA0025.namprd15.prod.outlook.com (2603:10b6:610:51::35) by LV8PR12MB9713.namprd12.prod.outlook.com (2603:10b6:408:2a1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:52 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::8a) by CH2PR15CA0025.outlook.office365.com (2603:10b6:610:51::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.12 via Frontend Transport; Fri, 18 Sep 2026 14:56:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:52 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:50 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 05/10] PCI: Share the AER ratelimit sysfs accessors Date: Fri, 18 Sep 2026 09:56:13 -0500 Message-ID: <20260918145619.3016889-6-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|LV8PR12MB9713:EE_ X-MS-Office365-Filtering-Correlation-Id: df998540-0340-4508-d433-08df15951332 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|376014|1800799024|56012099006|11063799006|10067099003|6133799003|5023799004|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: WQ+3bVN70ESdLL2KkL1QTvBjekuC/UwlhOeuJ8Zc1rEUa3HtU1Ch8oGLS8uSegzMOgQY427b3O7Src9Tc3t3V9Ogo3N+IWAqL3RD8Y2L7bu6SiD/kGS3LDr9M24LBle/DIm3Zbdo3aikb+wjBDO89noIQP67eg12345xCDixm4PJhWlBDRENjrc8oKw3qah4JlekCdGBcMX7FRz9cNTKEa6AJmHCBjmvEmwWZjbTMxetrcAdiapM3IQK2MLoKi1XGJo0WJBoDoEcJGPO4LaUrLRdcQvAe+heO5qkS57rnJYbtn/dvgSEq+ANhh/J3FzEUOOvDpiZ1RDdIeoWTgTg2fSq5IzLKJoqz3rCwRjzh3LNWyZoiiM8A60n9LyptVZenSmBq127e/GKrrnl1fWGnV8yYIYmL6DeCbYmBp3NuJiBST1IPsITiT/YzK5ns/VG2KpLAnPbMQ0d+r2+C7nwiz+StMo+/3Dq+7J6HprdpXw5YSDMqtGYWIrL0pMRzasjOWE8UNeNbBuhm3Rxz7ZyUme+k1yutHfRQrDk3uhR4EEs2uayg7jR7bE9qQ5R4ySjxHGTFYFtl8/GkmK8XawfTWq4ojZtuiYn161FKlUSQtwXuLITi6nPvYstiCKjYNB8C1F03AYdnWgdN9dkfm70RQcoG02+FXkqy2xumrv2Rb1XbMe2vNBy5JMdu3ZBAm79GOS+TaxJGlbUA8VUDnXarA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(376014)(1800799024)(56012099006)(11063799006)(10067099003)(6133799003)(5023799004)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xIxXaN6zsx1+cUWXbSjMA5vzhlYzQSgnR8DQNS0xNxiTfF2thR7BpoH5CEPBCSYZud6oqbsgVscjx6gpLieUhcbpGv6FYIVdmBufYWACy2nRPlMYmmdoT/LpL7eT+iZLiqdzsWm4TWqXG0M9oXhZmfe8SZJjnIpKFkGxz0tHIxnhWqF2T+DILb/RtI81PabpdZnZ74ksePgjoRysr6KAx6wBtxcundAZ5sf1X8gSoWPwNaPelVs95ftWYw2LArJT/Emaov+owRZS8jf+HqT0FStYQ/WGXSUBNfN43ZgnL50zXFZmg3m7TrGcFCxwkbJ5Sr2yH8bg7K0S767spJeCtHZTB2l04ABv77WKoiMXdiXtPht024IDubOOamsYRmkdzl8vsD/rhwjw3xdGZ32GAO1nmGhJUPNNB+TR39+plioCNx2fONUnpmk3LtHJQxCH X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:52.5739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df998540-0340-4508-d433-08df15951332 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9713 Content-Type: text/plain; charset="utf-8" The show and store paths for a ratelimit_state exposed through sysfs are the same whichever capability owns the state. Only the expression that reaches the ratelimit_state differs. Move the bodies into pci-sysfs.c as four helpers taking a ratelimit_state, and add PCI_RATELIMIT_INTERVAL_ATTR() and PCI_RATELIMIT_BURST_ATTR() to generate the attribute pair around them. Convert AER to use them. The Makefile builds pci-sysfs.c only under CONFIG_SYSFS, so build the AER attributes under it too. They were dead code without it, since pci_dev_attr_groups[] is their only consumer, but they were still emitted and now reference the shared helpers. No functional change intended. Assisted-by: LLM Signed-off-by: Yazen Ghannam --- drivers/pci/pci-sysfs.c | 68 ++++++++++++++++++++++++++++++ drivers/pci/pci.h | 49 ++++++++++++++++++++++ drivers/pci/pcie/aer.c | 93 +++++++---------------------------------- 3 files changed, 131 insertions(+), 79 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 1f21856aac8a..a111e62e39b3 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include "pci.h" @@ -1892,6 +1893,73 @@ static const struct attribute_group pci_dev_group = =3D { .attrs =3D pci_dev_attrs, }; =20 +/* + * Accessors shared by the capabilities that expose a struct ratelimit_sta= te + * through sysfs. Use them via PCI_RATELIMIT_INTERVAL_ATTR() and + * PCI_RATELIMIT_BURST_ATTR() rather than calling them directly. + */ +ssize_t pci_ratelimit_interval_show(struct ratelimit_state *rs, char *buf) +{ + unsigned long iv =3D rs->interval; + + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(iv)); +} + +/* + * Ratelimit interval, in milliseconds + * <=3D0: disabled with ratelimit.interval =3D 0 + * >0: enabled, ratelimit.interval held in jiffies + */ +ssize_t pci_ratelimit_interval_store(struct ratelimit_state *rs, + const char *buf, size_t count) +{ + int interval; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (kstrtoint(buf, 0, &interval) < 0) + return -EINVAL; + + if (interval <=3D 0) + interval =3D 0; + else + interval =3D msecs_to_jiffies(interval); + + rs->interval =3D interval; + + return count; +} + +ssize_t pci_ratelimit_burst_show(struct ratelimit_state *rs, char *buf) +{ + return sysfs_emit(buf, "%d\n", rs->burst); +} + +/* + * Ratelimit burst + * <=3D0: everything suppressed, unless the interval is also 0 + * >0: messages allowed per interval + */ +ssize_t pci_ratelimit_burst_store(struct ratelimit_state *rs, + const char *buf, size_t count) +{ + int burst; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (kstrtoint(buf, 0, &burst) < 0) + return -EINVAL; + + if (burst < 0) + burst =3D 0; + + rs->burst =3D burst; + + return count; +} + const struct attribute_group *pci_dev_groups[] =3D { &pci_dev_group, #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f5fdb5dffdb7..f43c5330fca3 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -9,6 +9,7 @@ #include =20 struct pcie_tlp_log; +struct ratelimit_state; =20 /* Number of possible devfns: 0.0 to 1f.7 inclusive */ #define MAX_NR_DEVFNS 256 @@ -74,6 +75,54 @@ struct pcie_tlp_log; #define PCIE_LINK_WAIT_MAX_RETRIES 10 #define PCIE_LINK_WAIT_SLEEP_MS 90 =20 +ssize_t pci_ratelimit_interval_show(struct ratelimit_state *rs, char *buf); +ssize_t pci_ratelimit_interval_store(struct ratelimit_state *rs, + const char *buf, size_t count); +ssize_t pci_ratelimit_burst_show(struct ratelimit_state *rs, char *buf); +ssize_t pci_ratelimit_burst_store(struct ratelimit_state *rs, + const char *buf, size_t count); + +/* + * Define the "" sysfs attribute for the interval or the burst of a + * struct ratelimit_state. @member names it within struct pci_dev, so it + * reads as e.g. aer_info->correctable_ratelimit. + */ +#define PCI_RATELIMIT_INTERVAL_ATTR(name, member) \ + static ssize_t name##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return pci_ratelimit_interval_show( \ + &to_pci_dev(dev)->member, buf); \ + } \ + \ + static ssize_t name##_store(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ + { \ + return pci_ratelimit_interval_store( \ + &to_pci_dev(dev)->member, buf, count); \ + } \ + static DEVICE_ATTR_RW(name) + +#define PCI_RATELIMIT_BURST_ATTR(name, member) \ + static ssize_t name##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return pci_ratelimit_burst_show( \ + &to_pci_dev(dev)->member, buf); \ + } \ + \ + static ssize_t name##_store(struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ + { \ + return pci_ratelimit_burst_store( \ + &to_pci_dev(dev)->member, buf, count); \ + } \ + static DEVICE_ATTR_RW(name) + /* Format of TLP; PCIe r7.0, sec 2.2.1 */ #define PCIE_TLP_FMT_3DW_NO_DATA 0x00 /* 3DW header, no data */ #define PCIE_TLP_FMT_4DW_NO_DATA 0x01 /* 4DW header, no data */ diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 91d73bd2ca7c..f42b57cac28a 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -599,6 +599,12 @@ static const char *aer_agent_string[] =3D { "", }; =20 +/* + * pci_dev_attr_groups[] in pci-sysfs.c is the only consumer of the groups + * below, and the ratelimit accessors they are built from live there too. + */ +#ifdef CONFIG_SYSFS + #define aer_stats_dev_attr(name, stats_array, strings_array, \ total_string, total_field) \ static ssize_t \ @@ -687,87 +693,14 @@ const struct attribute_group aer_stats_attr_group =3D= { .is_visible =3D aer_stats_attrs_are_visible, }; =20 -/* - * Ratelimit interval, in milliseconds - * <=3D0: disabled with ratelimit.interval =3D 0 - * >0: enabled, ratelimit.interval held in jiffies - */ -#define aer_ratelimit_interval_attr(name, ratelimit) \ - static ssize_t \ - name##_show(struct device *dev, struct device_attribute *attr, \ - char *buf) \ - { \ - struct pci_dev *pdev =3D to_pci_dev(dev); \ - unsigned long iv =3D pdev->aer_info->ratelimit.interval; \ - \ - return sysfs_emit(buf, "%u\n", jiffies_to_msecs(iv)); \ - } \ - \ - static ssize_t \ - name##_store(struct device *dev, struct device_attribute *attr, \ - const char *buf, size_t count) \ - { \ - struct pci_dev *pdev =3D to_pci_dev(dev); \ - int interval; \ - \ - if (!capable(CAP_SYS_ADMIN)) \ - return -EPERM; \ - \ - if (kstrtoint(buf, 0, &interval) < 0) \ - return -EINVAL; \ - \ - if (interval <=3D 0) \ - interval =3D 0; \ - else \ - interval =3D msecs_to_jiffies(interval); \ - \ - pdev->aer_info->ratelimit.interval =3D interval; \ - \ - return count; \ - } \ - static DEVICE_ATTR_RW(name); - -#define aer_ratelimit_burst_attr(name, ratelimit) \ - static ssize_t \ - name##_show(struct device *dev, struct device_attribute *attr, \ - char *buf) \ - { \ - struct pci_dev *pdev =3D to_pci_dev(dev); \ - \ - return sysfs_emit(buf, "%d\n", \ - pdev->aer_info->ratelimit.burst); \ - } \ - \ - static ssize_t \ - name##_store(struct device *dev, struct device_attribute *attr, \ - const char *buf, size_t count) \ - { \ - struct pci_dev *pdev =3D to_pci_dev(dev); \ - int burst; \ - \ - if (!capable(CAP_SYS_ADMIN)) \ - return -EPERM; \ - \ - if (kstrtoint(buf, 0, &burst) < 0) \ - return -EINVAL; \ - \ - if (burst < 0) \ - burst =3D 0; \ - \ - pdev->aer_info->ratelimit.burst =3D burst; \ - \ - return count; \ - } \ - static DEVICE_ATTR_RW(name); - #define aer_ratelimit_attrs(name) \ - aer_ratelimit_interval_attr(name##_ratelimit_interval_ms, \ - name##_ratelimit) \ - aer_ratelimit_burst_attr(name##_ratelimit_burst, \ - name##_ratelimit) + PCI_RATELIMIT_INTERVAL_ATTR(name##_ratelimit_interval_ms, \ + aer_info->name##_ratelimit); \ + PCI_RATELIMIT_BURST_ATTR(name##_ratelimit_burst, \ + aer_info->name##_ratelimit) =20 -aer_ratelimit_attrs(correctable) -aer_ratelimit_attrs(nonfatal) +aer_ratelimit_attrs(correctable); +aer_ratelimit_attrs(nonfatal); =20 static struct attribute *aer_attrs[] =3D { &dev_attr_correctable_ratelimit_interval_ms.attr, @@ -792,6 +725,8 @@ const struct attribute_group aer_attr_group =3D { .is_visible =3D SYSFS_GROUP_VISIBLE(aer), }; =20 +#endif /* CONFIG_SYSFS */ + static void pci_dev_aer_stats_incr(struct pci_dev *pdev, struct aer_err_info *info) { --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011045.outbound.protection.outlook.com [40.93.194.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C7FF4F68D4; Fri, 18 Sep 2026 14:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743418; cv=fail; b=lUNm/z3jFAK6bIgwhiGHyvTkMki9JJNZp3PM4c++5V5SYHyAbITatPvuMMV4u8R5gut+mQvV9pCPA5dx1j2Y1eeJxJbPU7HZ2hKiKb2ACAXCsQWogz981UBfOQZTAktcatrMbhx4vVuvL2QvGc7/KiKI41WxTa/tvfiugpK1pN8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743418; c=relaxed/simple; bh=h6ep5LuMhrJpaOwnEE1SqWGoB6qo3IVnm4JmU6/w6r8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oWh9dq21R2X0xtleXhQd49sgsQBynTsjVHEzlGT0sydKGPPzXbtNdiMk+eV1qrkTMLmw7EUB0iLgjOpex3NJMZgG79v1q0UY8N56dsBDVQjmAjtsZFjr+nlsC2A9iumTMrpV+/2jmEE2u42DmeBgj4EoTUnTYzOpnZiYox5K4TY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=MCmaDTg4; arc=fail smtp.client-ip=40.93.194.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MCmaDTg4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YWX2DopFaDFvNaEpWczBurWpplwDjyS9rbh1ij4vfhjpCrOxMkM0SQmi+j0sw7k5329DrLZ+nM+eyPUOObWTOKNtn9/qKAaDPkOq+GL4kBpjC5hLvqkq/EgaQ6MnmGjL4pfWh+JFJOSRqR5BFd4Ui5mrVyTe8ZFKpp0Sou2pqJJWoHAlHAtxSU9FoR4gxi3OYXnCqxPfq6/wySIJwQNaWe/tzma6ARMTfFUJx+1D7RQzozp8NnsCYymqUAtTCMvjz4UBOxBNGOWoxIBsseZWDxdugNjICO7kycJnLSceg69hpLBC2KCuiaqlOd9XbWRkRIynibMznNErU91XQZJC5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7KfX8o6ry8QSrHj60hG6Mu6+Z5OfIPYZm57Rd7/gAJk=; b=pE3u75NKpE9WytxLG36kXerG/0ImO2hengp58fvjwPS9x5ULIyIHu8A7dtIJLA1nlw8eyh2cpjIBVwKDLY3yzD4oIO/ULIQ0Kzo0+7j90xXUQ0VmxdI7JVuYxZzSBH14pMsZlZ0vR6lz9ch1VfF7bFM/CcFw7uasDpelEmeI34L79vYGdmSAaFWXfxi8l0iurvm0aaDQqDQXzDl4vjnagbByiSuVBFIt2Sax/0FXdY3/7JN6XiZZRNt6310IBccMQHDwVw9u2071WXSlFOB1pvf9erafNrPkZ3gglvOMT5MVZ7uk3V01mx8X/B2UMME6QyWjSnHUHGvIDvMWs60YpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7KfX8o6ry8QSrHj60hG6Mu6+Z5OfIPYZm57Rd7/gAJk=; b=MCmaDTg4uA8lAiV+rhoINkJFtZCLBzM1tNldCuioKW9wXm+gOMuXum0My17+GrFXBWnzMuMitpDH9CtkZBgWGYWODjLr/ee1ZYP2nW1mQxH2HEqnFos29xGItp8YqCNvuv28ZBTiKS0wpFVDeWaZmbPuGW4mNDZN/d3TGcrhqvw= Received: from CH2PR15CA0007.namprd15.prod.outlook.com (2603:10b6:610:51::17) by CH3PR12MB9316.namprd12.prod.outlook.com (2603:10b6:610:1ce::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:53 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::6a) by CH2PR15CA0007.outlook.office365.com (2603:10b6:610:51::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.12 via Frontend Transport; Fri, 18 Sep 2026 14:56:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:53 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:51 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 06/10] PCI/portdrv: Group PCI Exp Cap services into a single mask Date: Fri, 18 Sep 2026 09:56:14 -0500 Message-ID: <20260918145619.3016889-7-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|CH3PR12MB9316:EE_ X-MS-Office365-Filtering-Correlation-Id: fa0d1c9a-6ad5-4f67-0238-08df15951389 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700016|23010399003|22082099003|18002099003|11063799006|10067099003|56012099006; X-Microsoft-Antispam-Message-Info: 6W6QX0WY0dfbQv3WY8N0h0LLbAOsCb/2d2MpNvlPn8D5VOzRQacoOjeRVXZzjhMGSF9RrRBYZOX9hMUakADK1fMXz+0Cpu7bTu4JqWMa5lDdSRhCrOXvt+aHvIOUsXJ/oUxbzypKom+d6JcI2iONWslrzWqeCzxHEPyVGur5J6hkbE9WskmStl5jX2G++9i5YCJf6EBN1zEbGZA9QBniJAascgIiUMrZnfq8yaUCk1VjI8b9vVr2k24BhZrPO29hAGKJ8N5EUiOD+sq6X8oEwr67hdwXrLDQpxmtEuVbZ0hx90gpEZwaaBJx8DYxA8iKmS742HsvOcyjdeK4ndrRIc5sxniIlRoWKCw7XRHCktARoShkhZpVxXb2Hdz8Nqism0qpQFKyL/pp/cvu0LqOA7SDTfRMT9QkWnyM3jVBiyCX9G1F0Qp6zXNq+mZPmSEbaKQQbp4+CQF/HAUMKSqX3g3KFQG9BJVKhq6XSWU2wicXSW/xVF5F904RKJiwb1zmORmK7IT/Q5/OdNB131xM4qSC9LewEz4O2IK4DUoro92ruSRRMelqwN0FQasuw67WAvoFUiD1pjCniq1+bOEq8PnLVSNB7u2QU5iBO+jz8bFSkAf5+/bM1pwzMYukt/lZcakBz/ZSqqKjYgT8QNR9sSaZrf2HQNOuWrEQnTAFyQV4RjMq6Bp+8RiwuZ1gHlHdu1PZLrBynWYV1+K/Qd6E8A== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700016)(23010399003)(22082099003)(18002099003)(11063799006)(10067099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OMDxV4g9SDntZx/oOgNoBTNFQI6PzNYx6W6fsc/Z/aORyYaLuCv9NvKkfjhSWMZbk4EtX5bQkzQgBCaA+hhdVk+JzK4YUH8I9SJFOj50MElcR1Wc149oI9Yq26stHCnRRAuB//OBzFp0w5pJ8YrQ7yN6gE4OeO+XXN4EU2vDcU2U3TNz3YGT6GxgzlSEJuJqNMuUSeKanro2iGIspHEW9/BgjXEHv+z4H65LeBu6ynSJ9DwS39ixvZMZDKTDfLZi7k1YZgT6+OC+K+5Cu8H0FDc61eaNzYzuLiaeeB7vXiE94ylCdL3CZD/o0k5USPsiUTSR5u/FpNOKnYSY5azbrwTRjzDjJH/icDBKs/vQNmgV76cBcqAtwMk+KmWNfpj/qNdDcMNE35xgSyAiTvpmFgfHbZU1+oq6DU94HBqlXOXJfs+eYMYuGdHYfD8CTY3v X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:53.1401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa0d1c9a-6ad5-4f67-0238-08df15951389 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9316 Content-Type: text/plain; charset="utf-8" PME, hotplug, and bandwidth notification are all services of the PCI Express Capability and share a single MSI/MSI-X interrupt vector. The set of these services is open-coded as a bitmask in more than one place. That is repetitive and easy to get out of sync as services are added. Define a single PCIE_PORT_SERVICES_EXPCAP mask beside the service bits it groups, and use it in place of the open-coded expressions. Assign the shared vector by iterating the mask rather than naming each service again, so adding one is a single edit. Iterating narrows which irqs[] entries get written. The open-coded version filled the slot of every service in the group as soon as one of them was in the mask. Those extra entries were never read, since pcie_init_service_irqs() presets the array to -1 and pcie_port_device_register() only reads the slot of a service it found. No functional change intended. Assisted-by: LLM Signed-off-by: Yazen Ghannam --- drivers/pci/pcie/portdrv.c | 16 ++++++++-------- drivers/pci/pcie/portdrv.h | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c index a9cbfc1d2bc7..ca1b9dbb8b08 100644 --- a/drivers/pci/pcie/portdrv.c +++ b/drivers/pci/pcie/portdrv.c @@ -67,8 +67,7 @@ static int pcie_message_numbers(struct pci_dev *dev, int = mask, * 7.8.2, 7.10.10, 7.31.2. */ =20 - if (mask & (PCIE_PORT_SERVICE_PME | PCIE_PORT_SERVICE_HP | - PCIE_PORT_SERVICE_BWCTRL)) { + if (mask & PCIE_PORT_SERVICES_EXPCAP) { pcie_capability_read_word(dev, PCI_EXP_FLAGS, ®16); *pme =3D FIELD_GET(PCI_EXP_FLAGS_IRQ, reg16); nvec =3D *pme + 1; @@ -114,6 +113,8 @@ static int pcie_port_enable_irq_vec(struct pci_dev *dev= , int *irqs, int mask) { int nr_entries, nvec, pcie_irq; u32 pme =3D 0, aer =3D 0, dpc =3D 0; + unsigned long expcap; + unsigned int i; =20 /* Allocate the maximum possible number of MSI/MSI-X vectors */ nr_entries =3D pci_alloc_irq_vectors(dev, 1, PCIE_PORT_MAX_MSI_ENTRIES, @@ -148,13 +149,12 @@ static int pcie_port_enable_irq_vec(struct pci_dev *d= ev, int *irqs, int mask) return nr_entries; } =20 - /* PME, hotplug and bandwidth notification share an MSI/MSI-X vector */ - if (mask & (PCIE_PORT_SERVICE_PME | PCIE_PORT_SERVICE_HP | - PCIE_PORT_SERVICE_BWCTRL)) { + /* These services share the PCIe Capability Interrupt Message Number */ + expcap =3D mask & PCIE_PORT_SERVICES_EXPCAP; + if (expcap) { pcie_irq =3D pci_irq_vector(dev, pme); - irqs[PCIE_PORT_SERVICE_PME_SHIFT] =3D pcie_irq; - irqs[PCIE_PORT_SERVICE_HP_SHIFT] =3D pcie_irq; - irqs[PCIE_PORT_SERVICE_BWCTRL_SHIFT] =3D pcie_irq; + for_each_set_bit(i, &expcap, PCIE_PORT_DEVICE_MAXSERVICES) + irqs[i] =3D pcie_irq; } =20 if (mask & PCIE_PORT_SERVICE_AER) diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index cc58bf2f2c84..bf18ca415990 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -23,6 +23,11 @@ #define PCIE_PORT_SERVICE_BWCTRL_SHIFT 4 /* Bandwidth Controller (notifica= tions) */ #define PCIE_PORT_SERVICE_BWCTRL (1 << PCIE_PORT_SERVICE_BWCTRL_SHIFT) =20 +/* Services sharing the PCI Express Capability Interrupt Message Number */ +#define PCIE_PORT_SERVICES_EXPCAP (PCIE_PORT_SERVICE_PME | \ + PCIE_PORT_SERVICE_HP | \ + PCIE_PORT_SERVICE_BWCTRL) + #define PCIE_PORT_DEVICE_MAXSERVICES 5 =20 extern bool pcie_ports_dpc_native; --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011017.outbound.protection.outlook.com [40.107.208.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CE944F96C1; Fri, 18 Sep 2026 14:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743422; cv=fail; b=iJcfW0ryIVn/Wy4m7rEARB0M6sN29QbhwJ5CavOMvSYNC9/55U31xj4nXHw6FJEaQS8DXLm8rwbSOxCmttpVN0M3s7gcrqBkFpWLO3R/Lsl+MzxXgPHSaZV8BEKNYF8JBLlR5Hr0feWPAoacBQLMJjZmgbysKp+441cI/6lXfKo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743422; c=relaxed/simple; bh=wuBw8YeZb1Z5raaCv7ll1oTmjW5AWhSX+Y2n2QCYeBs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Scy9IRwNWBbDJGAmYEFIR4A9gPv5EpT80dlnFcDtCoZkOmWSGG3aQJcJneX4bB7wHCjkim1+y2lFi0D7rJC1gbiA8s/0/mNi+sIgJd5hgXQsW1BLOCyChBH3VgGUmpdOFpzb37QK9LS6IiX9ApOhijR9T+9MqsXmbre00dyt5iI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DJRu6ELa; arc=fail smtp.client-ip=40.107.208.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DJRu6ELa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r2h5EwCmEKo0KrNR82sfY7NrbTzLguqLTGYi99snYpn6QNXEsUNoZZ+xXvTImK3iEoEIiB8qZ7mE6B339KQBVgfQ4JGWzSdg02QEL5ewFa1TOpwLy+R5WAUp3aE/vNCQg4GiHDiQKSk7k963RnA+w4sw+bSixfTuBFf93BHj5IlSFZpI3mMM0tkOxNd0AyNXT98sE2a6icZ2OwggEP4QidzczVQGzx+o9NOnOdamT0fvcuH3PV6M5N54H3KPfdYs8TzQSPbAsv0obq2A2U285Ip2JXIbAT4eczKV49bxx7rgYSy2AWHjSi35HL7pFGS29dBca4MUDr1f6nAHXDO4RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a8I2YqlTXvuMxYr0kB6BZustc9alF8S36fI7xUyCBVI=; b=QAtvbt+sdwGWzxh7RZ9R4b57DOQHLiAE45Bfxfl+zDbFTuGVIsedeLiwjgJyYUQMp81as2fFyuyx7FP+A9Va3jbIeWlmtthRPXJBEVkOaAVK9IYBwFOi6k8HY5IbSGLzBkLt5DEqEMOvipisd5KdRKwQaMsA2ZtpvYbrQDWwO4wd46lY25g6YL7/zYwXmgM0fQ2wXMW1JxpYOhcwP+j9bjlbFFE/LuFiCHSqw07tNxMD16j5U32HuAMgs2oUaY9MI+YXs5ihf7PV4aiqIXqSQIDJJF0+WFhGx7o3l7MZf/vEtT+BWxWvXe7bE0YkdJ/9x/u0Tmij0xiBLHo4nfZgLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a8I2YqlTXvuMxYr0kB6BZustc9alF8S36fI7xUyCBVI=; b=DJRu6ELaDTYZJkESsJXE1sAsAFlGXj+wYuNXkd0x1+PaaoZP86gV+3Krx+x26CTLs72TfQ/+MAQFSLurhrVt3z6R64345vYH4v9F/SMH/uj3Y/0EWr6/GJE8O+TI58tUTdtWZQcOxhohyJlhEZQ7BBqUffPwXT7Bdpk9dgrbBiw= Received: from CH2PR15CA0001.namprd15.prod.outlook.com (2603:10b6:610:51::11) by SN7PR12MB7276.namprd12.prod.outlook.com (2603:10b6:806:2af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Fri, 18 Sep 2026 14:56:53 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::8e) by CH2PR15CA0001.outlook.office365.com (2603:10b6:610:51::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.11 via Frontend Transport; Fri, 18 Sep 2026 14:56:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:53 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:51 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 07/10] PCI/FLIT: Add support for Flit Logging Extended Capability Date: Fri, 18 Sep 2026 09:56:15 -0500 Message-ID: <20260918145619.3016889-8-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|SN7PR12MB7276:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e8a6ff9-1aa7-4c24-beda-08df159513b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|82310400026|1800799024|23010399003|56012099006|5023799004|11063799006|6133799003|10067099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: cApch4lbYiYgU2psM1+S4693ga8DagMCc0are8+/vclukvrpKd4BEDWNrMUlsI9ukIEc6dsb4Z5pxpEek6ubNooxQrhO7eqs4ma/Svzwh7dGCpqqeXtklO99czFyBJYNcZv2eAz+1ge13cmoLetuX5QFC88MVfncomSU/BtXkcqnDB77gVlE/auo6wpudMc+y3ZQakeAGhKdOAWy4gleTdvO50THBUcpz9v1IHDoZC1PJD6AJtwXOjLoGNw744a9JGZg8zz6UBQSBjWu7oce1fJsi3dtngpyoKbZY84HshD+Al/tg4wGZzB5dHKS3RaRyQ1aYmOzPKQ5QcqBgv2CyuMTxfISPTR225megOoBG6Qdxm9llnvIH5TI1kqWKwMtBD3OIFBZD+KRcvSWCDb4Oohnd7N9IcLi126/WvqUx0JG1j5iZnAz8Ci5g4MFM4P90DzKMb0LS6pmcU8zc0l7e3rrAG248gqxOQ0w3D0rxA1zKJDzTsAecX35J5QpoQ8cYkiT0AGL2ylPPUZo1soJzxsxG3FfIPQsgtVJEkVQBXZU5pXFpAtJaUvdD/rKYno0NPQEg3wV9dHw2VtXrgKcyUToT+cIBVyDF8O+PjYpWnztZdvlJ5W8Qs6kgPTqKc86q9UewJ4SiyDCsWWlYOr9MnVNxKDoxmd0xABdOQdfAvKG4HNqXxRVrsEZp1BK1V/axWupam5dMwo+MJbY2x2ayg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(376014)(82310400026)(1800799024)(23010399003)(56012099006)(5023799004)(11063799006)(6133799003)(10067099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p8UKsCTqXJX9PwwTf+x1rM6HWYKZe7I4RIqHGI1DisscrHcqhHKMzA0d1eQSNSMUUbn6/oHgzBHs+ztl+qkyMYuXo0OqSCegdCtSXEOEaQxs9YXhjigAm4Xm+WPq0wRORCLLyp1Er/kgqsFnD4msYKTi8jlYkqXxD8JA9nAIgjkUWpaBj+Ayfu1/N00uMpJrL2zeQjpLmREengwznO2IVDf4bS1R+p+c2B0e1YW1IhT07xvTP04zMgD/lHCYau4n2XKGo4lS7JPttykdX6KNYSdqvEW923Q/EteL4VzPTeju2pQZAd1ylPgY5uyXCj4Hd/VV94gBXWbnLAUHUAwgXyCnA5TYr7OHzO8dSacmgTaSoeS5JXUbrJjQfpT+USRM3dD2ErGWbdfFdS/A6qfToPAHatn/5DkhhdxPQLlbk9aVt1jq1nTmQcC2jGIFwmYT X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:53.4491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e8a6ff9-1aa7-4c24-beda-08df159513b8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7276 PCIe r6.4 defines the Flit Logging Extended Capability for logging erroneous flits, and requires it on ports and RCRBs that support PCIe Flit Mode.[1] Add a port service driver for it. Include _OSC negotiation for control of the capability. The driver claims only the port types the PCIe port bus driver binds to. An Endpoint implements the capability on its Upstream Port too, and _OSC is negotiated per host bridge, so accepting control leaves those instances with neither firmware nor the OS managing them. Covering them needs a home outside the port bus driver. [1] PCI Express=C2=AE Base Specification Revision 6.4, section 7.7.8 Link: https://pcisig.com/specification/extend-osc-negotiate-control-pcie-fl= it-logging-extended-capability Originally-by: Avadhut Naik Assisted-by: LLM Signed-off-by: Yazen Ghannam --- drivers/acpi/pci_root.c | 11 ++ drivers/pci/pci.c | 2 + drivers/pci/pci.h | 12 ++ drivers/pci/pcie/Kconfig | 9 + drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/flit.c | 324 ++++++++++++++++++++++++++++++++++ drivers/pci/pcie/portdrv.c | 7 + drivers/pci/pcie/portdrv.h | 13 +- drivers/pci/probe.c | 3 + include/linux/acpi.h | 1 + include/linux/pci.h | 6 + include/uapi/linux/pci_regs.h | 19 +- 12 files changed, 405 insertions(+), 3 deletions(-) create mode 100644 drivers/pci/pcie/flit.c diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 88c65f34e305..402686a9ca4c 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -137,6 +137,7 @@ static struct pci_osc_bit_struct pci_osc_control_bit[] = =3D { { OSC_PCI_EXPRESS_CAPABILITY_CONTROL, "PCIeCapability" }, { OSC_PCI_EXPRESS_LTR_CONTROL, "LTR" }, { OSC_PCI_EXPRESS_DPC_CONTROL, "DPC" }, + { OSC_PCI_EXPRESS_FLIT_CONTROL, "FlitLogging" }, }; =20 static struct pci_osc_bit_struct cxl_osc_support_bit[] =3D { @@ -520,6 +521,14 @@ static u32 calculate_control(void) if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR)) control |=3D OSC_PCI_EXPRESS_DPC_CONTROL; =20 + /* + * An OS that requests Flit Logging control must request AER control + * as well, so pair it with the bit that was actually requested above. + */ + if (IS_ENABLED(CONFIG_PCIE_FLIT) && + (control & OSC_PCI_EXPRESS_AER_CONTROL)) + control |=3D OSC_PCI_EXPRESS_FLIT_CONTROL; + return control; } =20 @@ -1040,6 +1049,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_= root *root, host_bridge->native_ltr =3D 0; if (!(root->osc_control_set & OSC_PCI_EXPRESS_DPC_CONTROL)) host_bridge->native_dpc =3D 0; + if (!(root->osc_control_set & OSC_PCI_EXPRESS_FLIT_CONTROL)) + host_bridge->native_flit =3D 0; =20 if (!(root->osc_ext_control_set & OSC_CXL_ERROR_REPORTING_CONTROL)) host_bridge->native_cxl_error =3D 0; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b2879a6be5f8..c1cfa0e3d75c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1798,6 +1798,7 @@ int pci_save_state(struct pci_dev *dev) =20 pci_save_dpc_state(dev); pci_save_aer_state(dev); + pci_save_flit_state(dev); pci_save_ptm_state(dev); pci_save_tph_state(dev); return pci_save_vc_state(dev); @@ -1870,6 +1871,7 @@ void pci_restore_state(struct pci_dev *dev) =20 pci_aer_clear_status(dev); pci_restore_aer_state(dev); + pci_restore_flit_state(dev); =20 pci_restore_config_space(dev); =20 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f43c5330fca3..53a90f75cd76 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1000,6 +1000,18 @@ static inline void pci_dpc_init(struct pci_dev *pdev= ) { } static inline bool pci_dpc_recovered(struct pci_dev *pdev) { return false;= } #endif =20 +#ifdef CONFIG_PCIE_FLIT +void pci_flit_init(struct pci_dev *pdev); +void pci_flit_exit(struct pci_dev *pdev); +void pci_save_flit_state(struct pci_dev *pdev); +void pci_restore_flit_state(struct pci_dev *pdev); +#else +static inline void pci_flit_init(struct pci_dev *pdev) { } +static inline void pci_flit_exit(struct pci_dev *pdev) { } +static inline void pci_save_flit_state(struct pci_dev *pdev) { } +static inline void pci_restore_flit_state(struct pci_dev *pdev) { } +#endif + #ifdef CONFIG_PCIEPORTBUS void pci_rcec_init(struct pci_dev *dev); void pci_rcec_exit(struct pci_dev *dev); diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index 207c2deae35f..7ddadad57d3f 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -146,3 +146,12 @@ config PCIE_EDR the PCI Firmware Specification r3.2. Enable this if you want to support hybrid DPC model which uses both firmware and OS to implement DPC. + +config PCIE_FLIT + bool "PCI Express Flit Logging support" + depends on PCIEPORTBUS && PCIEAER + help + This enables support for the PCI Express Flit Logging Extended + Capability, which logs errors encountered by a port operating + in PCIe Flit Mode. If your system doesn't have this capability + or you do not want to use this feature, it is safe to answer N. diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile index b0b43a18c304..14a5222920b9 100644 --- a/drivers/pci/pcie/Makefile +++ b/drivers/pci/pcie/Makefile @@ -14,3 +14,4 @@ obj-$(CONFIG_PCIE_PME) +=3D pme.o obj-$(CONFIG_PCIE_DPC) +=3D dpc.o obj-$(CONFIG_PCIE_PTM) +=3D ptm.o obj-$(CONFIG_PCIE_EDR) +=3D edr.o +obj-$(CONFIG_PCIE_FLIT) +=3D flit.o diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c new file mode 100644 index 000000000000..7c0b9c8dd481 --- /dev/null +++ b/drivers/pci/pcie/flit.c @@ -0,0 +1,324 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Service driver for PCIe Flit Logging Extended Capability + * + * Copyright (c) 2026, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Authors: Avadhut Naik + * Yazen Ghannam + */ + +#define pr_fmt(fmt) "Flit: " fmt +#define dev_fmt pr_fmt + +#include +#include +#include +#include +#include +#include +#include "portdrv.h" +#include "../pci.h" + +/* + * Report only a link accumulating errors far faster than the counter drai= ns. + * 0xff never fires, since an event needs the counter to exceed the trigge= r. + */ +#define FLIT_DEFAULT_TRIGGER 0xfe + +/* + * Per PCIe r6.4, sec 7.7.8.2, table 7-93, More Entries can be set again + * mid-drain, so bound the loop. + */ +#define FLIT_MAX_LOG_ENTRIES 0xff + +/* + * Per PCIe r6.4, sec 7.7.8.2, table 7-92, an entry with none of these set + * and Flit Error Log 2 zero is Reserved. + */ +#define FLIT_ERR_LOG1_ERROR (PCI_FLIT_ERR_LOG1_UNRECOG | \ + PCI_FLIT_ERR_LOG1_FEC_UNCOR | \ + PCI_FLIT_ERR_LOG1_SYND_PARITY0 | \ + PCI_FLIT_ERR_LOG1_SYND_CHECK0) + +/* Only the port types pcie_portdrv_probe() claims get a Flit service. */ +static bool flit_is_port(struct pci_dev *pdev) +{ + if (!pci_is_pcie(pdev)) + return false; + + switch (pci_pcie_type(pdev)) { + case PCI_EXP_TYPE_ROOT_PORT: + case PCI_EXP_TYPE_UPSTREAM: + case PCI_EXP_TYPE_DOWNSTREAM: + case PCI_EXP_TYPE_RC_EC: + return true; + default: + return false; + } +} + +/* + * Without _OSC control the OS must not touch the capability. Flit Logging + * control is only meaningful alongside AER control, so require both. + */ +static bool flit_is_native(struct pci_dev *pdev) +{ + struct pci_host_bridge *host =3D pci_find_host_bridge(pdev->bus); + + if (pcie_ports_native) + return true; + + return host->native_flit && host->native_aer; +} + +struct flit_info { + spinlock_t lock; /* serializes Counter Control read-modify-write */ + bool cntr_enabled; /* Counter Enable as the driver intends it */ +}; + +void pci_flit_init(struct pci_dev *pdev) +{ + if (!flit_is_port(pdev) || !flit_is_native(pdev)) + return; + + pdev->flit_cap =3D pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_FLIT); + if (!pdev->flit_cap) + return; + + pdev->flit_info =3D kzalloc_obj(*pdev->flit_info); + if (!pdev->flit_info) { + pdev->flit_cap =3D 0; + return; + } + + spin_lock_init(&pdev->flit_info->lock); + + pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_FLIT, sizeof(u16)); + + pci_dbg(pdev, "Flit Logging Extended Capability present.\n"); +} + +void pci_flit_exit(struct pci_dev *pdev) +{ + kfree(pdev->flit_info); + pdev->flit_info =3D NULL; + pdev->flit_cap =3D 0; +} + +void pci_save_flit_state(struct pci_dev *pdev) +{ + struct pci_cap_saved_state *save_state; + u16 *cap; + + if (!pdev->flit_cap) + return; + + save_state =3D pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_FLIT); + if (!save_state) + return; + + /* + * Take Counter Enable from the driver rather than the register. + * flit_isr() clears it and only flit_ist() sets it again once the log + * is drained, and a save landing in between would capture a zero that + * the next restore writes back for good. + */ + cap =3D (u16 *)&save_state->cap.data[0]; + pci_read_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, cap); + if (pdev->flit_info->cntr_enabled) + *cap |=3D PCI_FLIT_ERR_CNTR_CTRL_EN; + else + *cap &=3D ~PCI_FLIT_ERR_CNTR_CTRL_EN; +} + +void pci_restore_flit_state(struct pci_dev *pdev) +{ + struct pci_cap_saved_state *save_state; + u16 *cap; + + if (!pdev->flit_cap) + return; + + save_state =3D pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_FLIT); + if (!save_state) + return; + + cap =3D (u16 *)&save_state->cap.data[0]; + pci_write_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, *cap= ); +} + +/* + * Serializes the Counter Control read-modify-write against flit_isr(), wh= ich + * runs in hard irq context on the vector this port shares with PME, hotpl= ug + * and bandwidth notification. A lost update here leaves Trigger Event on = Error + * Count at zero, and per PCIe r6.4, sec 7.7.8.4, table 7-95, a zero trigg= er + * never generates an event. + */ +static void flit_cntr_ctrl_update(struct pci_dev *pdev, u16 clear, u16 set) +{ + unsigned long flags; + u16 ctrl; + + spin_lock_irqsave(&pdev->flit_info->lock, flags); + pci_read_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, &ctrl= ); + ctrl &=3D ~clear; + ctrl |=3D set; + pci_write_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, ctrl= ); + spin_unlock_irqrestore(&pdev->flit_info->lock, flags); +} + +static void flit_cntr_enable(struct pci_dev *pdev) +{ + u16 flit =3D pdev->flit_cap; + unsigned long flags; + u16 reg; + + pci_read_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_STA, ®); + pci_write_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_STA, reg); + + pdev->flit_info->cntr_enabled =3D true; + + spin_lock_irqsave(&pdev->flit_info->lock, flags); + pci_read_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_CTRL, ®); + + /* Set default trigger count if not set by platform, since zero never fir= es */ + if (!(reg & PCI_FLIT_ERR_CNTR_CTRL_TRIGGER)) + reg |=3D FIELD_PREP(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, FLIT_DEFAULT_TRIGGER= ); + + reg |=3D PCI_FLIT_ERR_CNTR_CTRL_EN | PCI_FLIT_ERR_CNTR_CTRL_INTR_EN; + pci_write_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_CTRL, reg); + spin_unlock_irqrestore(&pdev->flit_info->lock, flags); +} + +static void flit_cntr_disable(struct pci_dev *pdev) +{ + pdev->flit_info->cntr_enabled =3D false; + flit_cntr_ctrl_update(pdev, PCI_FLIT_ERR_CNTR_CTRL_EN | PCI_FLIT_ERR_CNTR= _CTRL_INTR_EN, 0); +} + +static void flit_report(struct pci_dev *pdev, u32 err_log1, u32 err_log2) +{ + /* Software should silently discard a Reserved entry */ + if (!(err_log1 & FLIT_ERR_LOG1_ERROR) && !err_log2) + return; + + pci_warn(pdev, "ErrLog1: 0x%08x ErrLog2: 0x%08x\n", err_log1, err_log2); +} + +static irqreturn_t flit_ist(int irq, void *context) +{ + struct pcie_device *dev =3D (struct pcie_device *)context; + struct pci_dev *pdev =3D dev->port; + u16 flit =3D pdev->flit_cap; + u32 err_log1, err_log2; + unsigned int i; + + for (i =3D 0; i < FLIT_MAX_LOG_ENTRIES; i++) { + pci_read_config_dword(pdev, flit + PCI_FLIT_ERR_LOG1, &err_log1); + + if (PCI_POSSIBLE_ERROR(err_log1) || !(err_log1 & PCI_FLIT_ERR_LOG1_VALID= )) + break; + + pci_read_config_dword(pdev, flit + PCI_FLIT_ERR_LOG2, &err_log2); + + flit_report(pdev, err_log1, err_log2); + + pci_write_config_dword(pdev, flit + PCI_FLIT_ERR_LOG1, err_log1); + + if (!(err_log1 & PCI_FLIT_ERR_LOG1_MORE)) + break; + } + + /* + * Re-enable the counter. Per PCIe r6.4, sec 7.7.8.5, table 7-96, the + * status bit is "Cleared on 0b to 1b transition of Flit Error Counter + * Enable", which also clears the counter and re-arms interrupt + * generation. + */ + flit_cntr_ctrl_update(pdev, 0, PCI_FLIT_ERR_CNTR_CTRL_EN); + return IRQ_HANDLED; +} + +static irqreturn_t flit_isr(int irq, void *context) +{ + struct pcie_device *dev =3D (struct pcie_device *)context; + struct pci_dev *pdev =3D dev->port; + u16 flit =3D pdev->flit_cap; + u16 cntr_sta; + + pci_read_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_STA, &cntr_sta); + if (PCI_POSSIBLE_ERROR(cntr_sta) || !(cntr_sta & PCI_FLIT_ERR_CNTR_STA_IN= TR_GEN)) + return IRQ_NONE; + + /* + * Clear Flit Error Counter Enable first, so the counter cannot reach + * the trigger again while the thread runs, then clear the status bit. + * A message-signaled vector needs no more than that, but this service + * can land on INTx, where the line stays asserted until the status is + * cleared. flit_ist() transitions Counter Enable back 0->1. + */ + flit_cntr_ctrl_update(pdev, PCI_FLIT_ERR_CNTR_CTRL_EN, 0); + pci_write_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_STA, + PCI_FLIT_ERR_CNTR_STA_INTR_GEN); + return IRQ_WAKE_THREAD; +} + +static int flit_probe(struct pcie_device *dev) +{ + struct pci_dev *pdev =3D dev->port; + int status; + + /* + * Not devm_request_threaded_irq(): devres would free the IRQ only + * after .remove() runs, too late to stop flit_ist() re-enabling the + * counter. + */ + status =3D request_threaded_irq(dev->irq, flit_isr, flit_ist, + IRQF_SHARED, "pcie-flit", dev); + if (status) { + pci_warn(pdev, "request Flit IRQ %d failed: %d\n", dev->irq, status); + return status; + } + + flit_cntr_enable(pdev); + pci_info(pdev, "enabled with IRQ %d\n", dev->irq); + + return 0; +} + +/* + * No .suspend or .runtime_suspend counterpart. pci_save_state() runs after + * both, so disabling the counter there would put a transient value in the + * save buffer, and pcie_portdrv_slot_reset() restores that buffer after + * calling .slot_reset. + */ +static int flit_cntr_restore(struct pcie_device *dev) +{ + flit_cntr_enable(dev->port); + return 0; +} + +static void flit_cntr_remove(struct pcie_device *dev) +{ + /* Drop the IRQ first: free_irq() waits for the threaded handler. */ + free_irq(dev->irq, dev); + flit_cntr_disable(dev->port); +} + +static struct pcie_port_service_driver flitdriver =3D { + .name =3D "flit", + .port_type =3D PCIE_ANY_PORT, + .service =3D PCIE_PORT_SERVICE_FLIT, + .probe =3D flit_probe, + .resume =3D flit_cntr_restore, + .runtime_resume =3D flit_cntr_restore, + .slot_reset =3D flit_cntr_restore, + .remove =3D flit_cntr_remove, +}; + +int __init pcie_flit_init(void) +{ + return pcie_port_service_register(&flitdriver); +} diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c index ca1b9dbb8b08..6328233c75d7 100644 --- a/drivers/pci/pcie/portdrv.c +++ b/drivers/pci/pcie/portdrv.c @@ -278,6 +278,12 @@ static int get_port_device_capability(struct pci_dev *= dev) services |=3D PCIE_PORT_SERVICE_BWCTRL; } =20 +#ifdef CONFIG_PCIE_FLIT + /* flit_cap is set only when the capability is OS-managed */ + if (dev->flit_cap) + services |=3D PCIE_PORT_SERVICE_FLIT; +#endif + return services; } =20 @@ -834,6 +840,7 @@ static void __init pcie_init_services(void) pcie_dpc_init(); pcie_bwctrl_init(); pcie_hp_init(); + pcie_flit_init(); } =20 static int __init pcie_portdrv_init(void) diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index bf18ca415990..975f83134a5b 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -22,13 +22,16 @@ #define PCIE_PORT_SERVICE_DPC (1 << PCIE_PORT_SERVICE_DPC_SHIFT) #define PCIE_PORT_SERVICE_BWCTRL_SHIFT 4 /* Bandwidth Controller (notifica= tions) */ #define PCIE_PORT_SERVICE_BWCTRL (1 << PCIE_PORT_SERVICE_BWCTRL_SHIFT) +#define PCIE_PORT_SERVICE_FLIT_SHIFT 5 /* Flit Logging */ +#define PCIE_PORT_SERVICE_FLIT (1 << PCIE_PORT_SERVICE_FLIT_SHIFT) =20 /* Services sharing the PCI Express Capability Interrupt Message Number */ #define PCIE_PORT_SERVICES_EXPCAP (PCIE_PORT_SERVICE_PME | \ PCIE_PORT_SERVICE_HP | \ - PCIE_PORT_SERVICE_BWCTRL) + PCIE_PORT_SERVICE_BWCTRL | \ + PCIE_PORT_SERVICE_FLIT) =20 -#define PCIE_PORT_DEVICE_MAXSERVICES 5 +#define PCIE_PORT_DEVICE_MAXSERVICES 6 =20 extern bool pcie_ports_dpc_native; =20 @@ -56,6 +59,12 @@ int pcie_dpc_init(void); static inline int pcie_dpc_init(void) { return 0; } #endif =20 +#ifdef CONFIG_PCIE_FLIT +int pcie_flit_init(void); +#else +static inline int pcie_flit_init(void) { return 0; } +#endif + int pcie_bwctrl_init(void); =20 /* Port Type */ diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 27008e2ea5af..6bf62bdadc8d 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -674,6 +674,7 @@ static void pci_init_host_bridge(struct pci_host_bridge= *bridge) bridge->native_pme =3D 1; bridge->native_ltr =3D 1; bridge->native_dpc =3D 1; + bridge->native_flit =3D 1; bridge->domain_nr =3D PCI_DOMAIN_NR_NOT_SET; bridge->native_cxl_error =3D 1; bridge->dev.type =3D &pci_host_bridge_type; @@ -2465,6 +2466,7 @@ static void pci_configure_device(struct pci_dev *dev) =20 static void pci_release_capabilities(struct pci_dev *dev) { + pci_flit_exit(dev); pci_aer_exit(dev); pci_rcec_exit(dev); pci_iov_release(dev); @@ -2666,6 +2668,7 @@ static void pci_init_capabilities(struct pci_dev *dev) pci_pasid_init(dev); /* Process Address Space ID */ pci_acs_init(dev); /* Access Control Services */ pci_ptm_init(dev); /* Precision Time Measurement */ + pci_flit_init(dev); /* Flit Logging */ pci_aer_init(dev); /* Advanced Error Reporting */ pci_dpc_init(dev); /* Downstream Port Containment */ pci_rcec_init(dev); /* Root Complex Event Collector */ diff --git a/include/linux/acpi.h b/include/linux/acpi.h index ddacac812094..b3d8a5bb79e9 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -667,6 +667,7 @@ extern u32 osc_sb_native_usb4_control; #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010 #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 #define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 +#define OSC_PCI_EXPRESS_FLIT_CONTROL 0x00000800 =20 /* CXL _OSC: Capabilities DWORD 4: Support Field */ #define OSC_CXL_1_1_PORT_REG_ACCESS_SUPPORT 0x00000001 diff --git a/include/linux/pci.h b/include/linux/pci.h index 8650c627bebb..37d01fab50bb 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -598,6 +598,11 @@ struct pci_dev { u8 tph_mode; /* TPH mode */ u8 tph_req_type; /* TPH requester type */ #endif + +#ifdef CONFIG_PCIE_FLIT + u16 flit_cap; /* Flit Logging Capability offset */ + struct flit_info *flit_info; /* Flit Logging state */ +#endif }; =20 static inline struct pci_dev *pci_physfn(struct pci_dev *dev) @@ -663,6 +668,7 @@ struct pci_host_bridge { unsigned int native_pme:1; /* OS may use PCIe PME */ unsigned int native_ltr:1; /* OS may use PCIe LTR */ unsigned int native_dpc:1; /* OS may use PCIe DPC */ + unsigned int native_flit:1; /* OS may use PCIe Flit logging */ unsigned int native_cxl_error:1; /* OS may use CXL RAS/Events */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index facaa324bd86..73482024359b 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -763,7 +763,8 @@ #define PCI_EXT_CAP_ID_DEV3 0x2F /* Device 3 Capability/Control/Status */ #define PCI_EXT_CAP_ID_IDE 0x30 /* Integrity and Data Encryption */ #define PCI_EXT_CAP_ID_PL_64GT 0x31 /* Physical Layer 64.0 GT/s */ -#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_64GT +#define PCI_EXT_CAP_ID_FLIT 0x32 /* Flit Logging */ +#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_FLIT =20 #define PCI_EXT_CAP_DSN_SIZEOF 12 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40 @@ -1187,6 +1188,22 @@ /* Physical Layer 64.0 GT/s */ #define PCI_PL_64GT_LE_CTRL 0x20 /* Lane Equalization Control Register */ =20 +/* Flit Logging Extended Capability */ +#define PCI_FLIT_ERR_LOG1 0x04 /* Flit Error Log 1 Register */ +#define PCI_FLIT_ERR_LOG1_VALID 0x00000001 /* Flit Error Log Valid */ +#define PCI_FLIT_ERR_LOG1_MORE 0x00002000 /* More Entries Valid */ +#define PCI_FLIT_ERR_LOG1_UNRECOG 0x00004000 /* Unrecognized Flit */ +#define PCI_FLIT_ERR_LOG1_FEC_UNCOR 0x00008000 /* FEC Uncorrectable Error= in Flit */ +#define PCI_FLIT_ERR_LOG1_SYND_PARITY0 0x00ff0000 /* Syndrome Parity for = ECC Group 0 */ +#define PCI_FLIT_ERR_LOG1_SYND_CHECK0 0xff000000 /* Syndrome Check for EC= C Group 0 */ +#define PCI_FLIT_ERR_LOG2 0x08 /* Flit Error Log 2 Register */ +#define PCI_FLIT_ERR_CNTR_CTRL 0x0c /* Flit Error Counter Control Regist= er */ +#define PCI_FLIT_ERR_CNTR_CTRL_EN 0x0001 /* Flit Error Counter Enable */ +#define PCI_FLIT_ERR_CNTR_CTRL_INTR_EN 0x0002 /* Flit Error Counter Inte= rrupt Enable */ +#define PCI_FLIT_ERR_CNTR_CTRL_TRIGGER 0x0ff0 /* Trigger Event on Error = Count */ +#define PCI_FLIT_ERR_CNTR_STA 0x0e /* Flit Error Counter Status Register= */ +#define PCI_FLIT_ERR_CNTR_STA_INTR_GEN 0x0008 /* Interrupt Generated bas= ed on Trigger */ + /* Native PCIe Enclosure Management */ #define PCI_NPEM_CAP 0x04 /* NPEM capability register */ #define PCI_NPEM_CAP_CAPABLE 0x00000001 /* NPEM Capable */ --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010038.outbound.protection.outlook.com [52.101.193.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84E2F4FD278; Fri, 18 Sep 2026 14:57:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743428; cv=fail; b=pZpp11J259k55DfntpKZx+4ObuLJ074F1bQVRPYoibIR0R582kPXPU0rAvLeQL4GoK/iQL1r6zyiJ7miINsKUD4QzFokcFy5wGjePAR4fDm+va4lcUMDaYcefsB2UgdoSOo0BVPy3GEi3UPFZag+77y9I9kkPkjhc1jtyXeImyo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743428; c=relaxed/simple; bh=xEoRLEwWV2hzEwhjM9Kad4z4Sx+x/yGJO2HXug8gyVM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C25GEEaiRc51j+ksjdaPVUlzEs0vooCjj2ROnUydwq3I0v6G0w1+HBsmgeaUKn4YPxx174abU2F9c7klB3Y8orTSilgFrEOJ7tZnchaE6tmVNBYxQZRF3cDifkOmNEMGGy4BYs9TPAAyI9SwxocvpZiBqmfCJiMf/nFaZxZJlMw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=zFKuN1yL; arc=fail smtp.client-ip=52.101.193.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zFKuN1yL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JnnVJZE1NGr5SZxV9NqwUqid5n/qGXaspLyB0MnMTFcxU1R6emc6YU7WJNfS8814bpQgGenWuJ1gO0Q1gD1xe1rkclwloqKIHRwYUoOkwtUrRI/ShDNBkf1oYp0r0XeUXeC57lZ+/CBD/03Tn2i8ZC9fnsXWnx34XNS7myv8q0ZVZ3qsgsRGxlqznGTG8/vE3ODGL9Hdd1v7uIPFGvvETnOsNPCXP1lklhSdmmFuUhiau4YywoNJP8wn5hjknjgwvAySUagcErfJuam7JVQj/aCJ+tKgve8jT55X5W0Pw5LiF+MLSSaNgPkPBGoFM4gVorevv78oftb+5ME03LSn7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=udl2dOM+1zcBA9cWNYdd1I0SskvjKCezZUHeSg6/Jsg=; b=Bs3B59qa+eaf045nb7pMWoB6Lc4ThreKt0WlD3XH8BCoFxsL4OteRjgCPiTfbCbcnwZ8Bo6UXfqs9B4KHsfnEVrY8Ax1ZcWsGY+p0pzijPJzZVSQFc77mUXaPdkRQ462gvu5AvQTzHtSNNETqnXc8anuaTfxleqj9/4odlFF5Ipwvt6pL+z6qs8dbs8h0h8AfSvQruaiSjbRvXSxGeDtQ33gLSxT6NS47GYE8PpDLbpOhoI2B6HtOGhm3znGpJtUYEc4xUrX7ErbCR/aNDSRvRAHpYzYo9QRw4SeAz+X1hLMkaLLGmgeuUczubUhcWdz37vEpIZXlanpxY8/KAorMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=udl2dOM+1zcBA9cWNYdd1I0SskvjKCezZUHeSg6/Jsg=; b=zFKuN1yLMZEh8yIPbmjRAzFBxOBbd3ERciyDYkcJOVmo7rXN5A1zz7gG/GYJWHM/Eg2treG1hwsSkYUB9a5yfF+qARHUKqVHAGkoBAc1AnE1nBmWMQ6VlvMDrH4QiJGHEQwnB+NWeZWzVclA+c7cPuB2IUtCX78O95vRwmGfhmU= Received: from CH2PR15CA0002.namprd15.prod.outlook.com (2603:10b6:610:51::12) by PH7PR12MB7818.namprd12.prod.outlook.com (2603:10b6:510:269::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:54 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::8d) by CH2PR15CA0002.outlook.office365.com (2603:10b6:610:51::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.11 via Frontend Transport; Fri, 18 Sep 2026 14:56:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:53 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:52 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 08/10] PCI/FLIT: Add trace event for flit errors Date: Fri, 18 Sep 2026 09:56:16 -0500 Message-ID: <20260918145619.3016889-9-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|PH7PR12MB7818:EE_ X-MS-Office365-Filtering-Correlation-Id: 334aece7-e183-4a59-06bf-08df159513fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|23010399003|1800799024|376014|56012099006|11063799006|10067099003|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: KA8htCMjJWYdv9ih/TnWdtpcV1KIrlAExcBE0YACZil6kFsjrej9L0Pg1QKOi2Qp9afCOyd1yHJC33x8uHT/6thB4utsJdr8l0TIVjOvGWo4BeZbKDQI/R4nd5/0Ff+zdkyC/ek/fcarnf478EXkSXrvftPepB7m9ZUCQrNN7As9T2jyAf6E+6TTVVrmb6VkBP2+oSvTPAVWqqFT/TfFvjuNOXiOKZ4ul8VajzcpK/71c21G0rY8TRs+RX06klf8hjETQxIVFFOtH87NoVuAMStEefWmxp5XzbzjK/KAASSE3RJ8NwCfNSH8OUVlVyh48TrWcOSryLd/X5MSH/b/rv6oAPAo4eu4za7nvHf4V0UMs6pLWdZ20SI/s1oeGlYjOrnCO+RLNyPhIfQ3kf97WDmmy6aIN7oulxcAtzUzFcwaGnxR7KLs144Zk7Ey4g+NdYSP/Qo84xIySrn1t34M/Ag76kI/TBmIXS4Q96jdyBzjEnXIBeJ7/oPguZ4p/F57ldPfihKLhoMYObKuv6NtwjcnityLhYfRizm3BObyhsgQz+fxSSypR8zlJAlsRV9b8HwfTiQ+7usAuaR2GyYnUIAwWaB2Vlu8bzxIyWxH2fgYjo1fdnY4qUw29GlrU3XsA6OIzLw3eZlD5m3/KiAxsX4XXsVPlwZKmcCd2ZetylSsdhzc4QqtPyCond5w61QY6Pw8rEB4IV5+0nZh+WLtlA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(23010399003)(1800799024)(376014)(56012099006)(11063799006)(10067099003)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bvB0/SF5TvwWdcnYEi4CNnvlD4x7QEE1MtexRxkbVW16ajdG0QcBLxoQISDqeGU/7M6kTfp6FTVbDVK9KS1QyGCn6SrGBIXr9C++kAWDgXLF9zV0NgAQv05KlojZ6BVc0B2/ahZzQ5S1Z/jTwtvikD5V65gGOQWD0a2gp6XnflwQi+SMQsJzwHNWlowI5mLPc/0ZPRBRZn1N7NlGbisFfVB6vP9IyoFXIXvdmF/nLNXTllEWnpH6ecXnz+JFhOpbo6ihAulVbTcAa4IgFTG/+pT3XxOSkaS4FSpKCoebsDerSP6J3Mgl2tnuXPjR8I0L52O8elTWxfun9nxTzOvtcK5SF/9aQf5kv+pNs3ZlHPcFHxMuipuT6cNMFgHijg4fbElSwnsedHrfmEFpdW+3KFnL8HCWqdmzvC4GV6Asag+ZYDP8cR2WN0XCcg+hL+W6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:53.8996 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 334aece7-e183-4a59-06bf-08df159513fd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7818 Content-Type: text/plain; charset="utf-8" Emit a trace event for each flit error logged from the Flit Error Log. The event carries both Error Log registers. Assisted-by: LLM Signed-off-by: Yazen Ghannam --- drivers/pci/pcie/flit.c | 3 +++ include/ras/ras_event.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c index 7c0b9c8dd481..9eb804035997 100644 --- a/drivers/pci/pcie/flit.c +++ b/drivers/pci/pcie/flit.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "portdrv.h" #include "../pci.h" =20 @@ -205,6 +206,8 @@ static void flit_report(struct pci_dev *pdev, u32 err_l= og1, u32 err_log2) return; =20 pci_warn(pdev, "ErrLog1: 0x%08x ErrLog2: 0x%08x\n", err_log1, err_log2); + + trace_flit_event(pci_name(pdev), err_log1, err_log2); } =20 static irqreturn_t flit_ist(int irq, void *context) diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h index fdb785fa4613..427585505dd6 100644 --- a/include/ras/ras_event.h +++ b/include/ras/ras_event.h @@ -381,6 +381,44 @@ TRACE_EVENT(aer_event, "Not available") ); #endif /* CONFIG_PCIEAER */ + +/* + * PCIe Flit Logging trace event + * + * One event is generated for each flit error the driver logs from the Flit + * Error Log of a PCIe Flit Mode port. + * + * char * dev_name - The name of the slot where the device resides + * ([domain:]bus:device.function). + * u32 err_log1 - Flit Error Log 1 register value. + * u32 err_log2 - Flit Error Log 2 register value. + */ +#ifdef CONFIG_PCIE_FLIT +TRACE_EVENT(flit_event, + TP_PROTO(const char *dev_name, + const u32 err_log1, + const u32 err_log2), + + TP_ARGS(dev_name, err_log1, err_log2), + + TP_STRUCT__entry( + __string( dev_name, dev_name ) + __field( u32, err_log1 ) + __field( u32, err_log2 ) + ), + + TP_fast_assign( + __assign_str(dev_name); + __entry->err_log1 =3D err_log1; + __entry->err_log2 =3D err_log2; + ), + + TP_printk("%s err_log1:0x%08x err_log2:0x%08x", + __get_str(dev_name), + __entry->err_log1, + __entry->err_log2) +); +#endif /* CONFIG_PCIE_FLIT */ #endif /* _TRACE_HW_EVENT_MC_H */ =20 /* This part must be outside protection */ --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012002.outbound.protection.outlook.com [52.101.48.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A6744E9C36; Fri, 18 Sep 2026 14:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.2 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743424; cv=fail; b=of0SojhMaakmUfvk2xRjCZGi6x6dRx59LSsDtV1lkct6L/gfzLKgzNEQ1IP/WVaVh0yyqq/4a5mvEQJQU6ydj1pm9v4GHtxS1ZQKh9NM3Yx1ATmlKUTy2q9RathTXR13NhtqbcEiEMFQrQ7J46W48e8O3LMLaPmvLOUl4g30GME= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743424; c=relaxed/simple; bh=xzwxyVBDYCyd2ZeTE/kzD69P+IQrzK1xSrBLdtsXzzI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t6Xfd+AF55rWUHLpz4KZvmD+VIPOQaA6A9Lk8LuJ6FQFTArm1euqK4SLsuwkSaDeFZp+bXkeUKG5+5rCS3OGnCjyRjCu2K6eJOVTG/5cAYaEC4eDTGO3WfEg4kEVo4IZs6qT7ojUJHzJo7VmVu+EwjcdItwsT4Zxjd7qqdUX7sU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=IdKtrL3Q; arc=fail smtp.client-ip=52.101.48.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="IdKtrL3Q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f2hXgVc0EVPAcZUspTtRCrbNzOqw7dETkpUmxxoUXosoZAfdiVzlmS/vY+QRO3mYHMA8MtjVV0lshWp/JVlm+gEUiWB5RVxbi10tQ09w9k7OHiDiKDrNQSv+Q6qG1HZ8k81YSWhZ7hqGU2dDvnZu+ovmcR7ZdPwhKzGRhWWs96qlKET8FUeZJu6tejcWkK3X1y2vJORuuuU+64Af8JTRDU9sl8bHc8zIZdq7OCNdtB5xfmgg4NiIvHhYzm9anTn1pV/HyiiCSZ46VVVXJKts3vpcBLqjPXB1Q8uQiUg6fpFkFhvT/mxFkCsKRvxyXcMEVQOEBopy40kkwpYOy9RnhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LR5qT8cz3Ne1J4GwHHSAHQYdvCfbRy4PXCG8JfmyJ+A=; b=iAfnQPJVB/NapqaNvBrvtZSTe5Gnyhdcx06VOJCnU7NDAiQntUbbTzL1KbxTQCKgCd0EV+pNP7WqFPnwE9m9McouGralNebs/6XrH9W0esV93MMp8+yE68e3pbRFGR4azpf0bsQi7bMwTLS5B/5clT2aWKV5qEDHY50FfxjklpzMHsmg2TJI4houQ3hH6hQtyLwmQ7V//FUFq7UbzCPP0MMQwwx4Ku382K4YXemnKe1ZfpyoQPAHTlaz0kWKSCesfsMOiq92CXGxECiTCh/VF4Z2SpUGu6BGEMa1pkvCRybh81VAdURe+y0PvSls8cnZgpQs5Oe0+0oXW0/U2Ona3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LR5qT8cz3Ne1J4GwHHSAHQYdvCfbRy4PXCG8JfmyJ+A=; b=IdKtrL3QwYKy8WYXahr0pAN1O0BlHpx7YL3LPuRNZzjiQICdf6VnP20OZll+nuu7BQcLXEMcgLXyPvVRD1SCXy75uZsCAubtnA7EoMAdoze5ukDgMj1eQfVHFRbWbRApGlLI0EupIlwuI0fuukHuDEVMEF3WeGo1leBuLExs+i4= Received: from CH2PR15CA0021.namprd15.prod.outlook.com (2603:10b6:610:51::31) by DM4PR12MB5820.namprd12.prod.outlook.com (2603:10b6:8:64::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:55 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::56) by CH2PR15CA0021.outlook.office365.com (2603:10b6:610:51::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.12 via Frontend Transport; Fri, 18 Sep 2026 14:56:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:54 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:52 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 09/10] PCI/FLIT: Ratelimit flit error logging Date: Fri, 18 Sep 2026 09:56:17 -0500 Message-ID: <20260918145619.3016889-10-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|DM4PR12MB5820:EE_ X-MS-Office365-Filtering-Correlation-Id: 70dcd143-f9b2-4ab2-f30d-08df15951491 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|1800799024|23010399003|376014|10067099003|6133799003|18002099003|22082099003|11063799006|56012099006|13003099007; X-Microsoft-Antispam-Message-Info: 7bJSQ8DfNdFG7/vVxC4t2jd9WVtluTbzqeNVPLi0OqvYxsg3yVlWqfKUSczL2V4JgxrKhqhA+VGYBoP9TW6m4bmrKiuPZ0PrWE4vhH8hstHakle1sHTfxFL2f3RF1Ekl5542mNskEuEvHrsTz7LbP1luiusf05lmj1VcY5Uhg4tCjp1s/xMxgQY+NDJrJjab4uPsgDhZKdeZ0uKbhw5rpoYxkosHLUyuyBthDJIrtFaZTmwSIZ63wgC7IhHocqEtakPmQlXctUyfKLllXLIYk20lsFgMT43sKD2lU/sUg0LcWT0DV2io/FbjghphnVbTMKLSQUVJLGzoWSEyObQ5Sm5hjIGul998tguJnWMfJN11uas44M87+8MkdjHh+8mLB9iLblz1gWpl0gkZMsROeN1KlmTYreh3Zo5OkWTvH2QRPgxZCdoOdmU2ubkAtnF6RBwyAdUlPQYhIPM8alWItt76Rb02+bA9sRHRXwm6qmhuR1SHssn6kjfiGfB/fVgVqCl2zQYOTbBqJPoJJ12tHH5DEdtTIxK+ElBk/YqfGK3s29QGZP9dInhxTXPbuyoH8v8nP9bRBK619mo18V8mGXgOi9q3XCz0hI7t0yhbZzlM5xA8zgx40KWdPBDRj62A4F2Qkk9pxTBDUu+JWTTvAQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(1800799024)(23010399003)(376014)(10067099003)(6133799003)(18002099003)(22082099003)(11063799006)(56012099006)(13003099007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F5wWkQJIF18KR3vG4FBr0FAwcGDrVpq/P+EYC8HUmiDpBZ3gBNKl+1rkLbcSuPClkq3oUcqQHBVIhMZ8moiwpIMzBxbYIFQi1GBH7wy6Z8RBci5oSQmLur0AhtH2iw4sUrNwS7LFwNxNW9gqfAs6j3uAL2+8g5Q7qLaZ3W2gHopFimLMlh+MnvvKlbiuOqWaDSkUpIObtwXm9C0q3v459Ha5rcKfvzdevvN1F7ojJOXwV7beLqNvJ+g2gyIRH1CuI8Tk3N/VM8+7O5ypJaEvgxHoWwXnxdDEZoOr9eTeDrwSZBobhvP3/rwt6vCd3HCnMtt0jGlShfa7eslCc1Me67Iv+rfc4En57f8P2W6bWpPWXj8d529YB1JV1AEXV4DlABCI8n0AAPGxGJE9VvxB4JNyV4Puts9dWNhVgMGAvOgU3HoV2nfdSgslpHWr4GWp X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:54.8751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70dcd143-f9b2-4ab2-f30d-08df15951491 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5820 Content-Type: text/plain; charset="utf-8" A high rate of flit errors can flood the kernel log. Ratelimit it. Keep the limit per port, so a storm on one port cannot suppress logging on another, and take the decision per logged error rather than per interrupt, so the configured burst counts console lines. AER does both for the same reasons. The trace event is left unthrottled, so tooling records every erroneous flit even while the console log is limited. Expose the interval and burst through a per-device "flit" sysfs group, gated on CAP_SYS_ADMIN, so the limit can be tuned or disabled at runtime. Document the attributes and list the new file in the PCI SUBSYSTEM entry. Assisted-by: LLM Signed-off-by: Yazen Ghannam --- .../ABI/testing/sysfs-bus-pci-devices-flit | 35 ++++++++++++++++ MAINTAINERS | 1 + drivers/pci/pci-sysfs.c | 3 ++ drivers/pci/pci.h | 1 + drivers/pci/pcie/flit.c | 42 ++++++++++++++++++- 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-pci-devices-flit diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-flit b/Documen= tation/ABI/testing/sysfs-bus-pci-devices-flit new file mode 100644 index 000000000000..43d7c7aacf81 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-flit @@ -0,0 +1,35 @@ +PCIe Flit error log ratelimits +------------------------------ + +These attributes show up under the Root Ports, Switch Ports and Root Compl= ex +Event Collectors that implement the PCI Express Flit Logging Extended +Capability, where the OS was granted control of it. They represent configu= rable +ratelimits of the flit error logs written to the kernel log. + +The ratelimit applies only to the kernel log. The flit_event trace event is +emitted for every flit error the driver drains from the Flit Error Log, +regardless of these settings. The log is a FIFO of implementation specific +depth, so errors the hardware could not log are not reported either way. + +Writing these attributes requires CAP_SYS_ADMIN. + +What: /sys/bus/pci/devices//flit/ratelimit_interval_ms +Date: September 2026 +KernelVersion: 7.4.0 +Contact: linux-pci@vger.kernel.org +Description: Writing 0, or any negative value, disables flit error log + ratelimiting. Writing a positive value sets the ratelimit + interval in ms. Reading gets the current ratelimit interval + in ms, rounded up to a whole jiffy. Default is + DEFAULT_RATELIMIT_INTERVAL (5000 ms). + +What: /sys/bus/pci/devices//flit/ratelimit_burst +Date: September 2026 +KernelVersion: 7.4.0 +Contact: linux-pci@vger.kernel.org +Description: Ratelimit burst for flit error logs. Writing a value changes + the number of logs (burst) allowed per interval before + ratelimiting. Reading gets the current ratelimit burst. + Writing 0, or any negative value, suppresses all logs + unless the interval attribute is also 0. Default is + DEFAULT_RATELIMIT_BURST (10). diff --git a/MAINTAINERS b/MAINTAINERS index 3df47851869e..2faa74c190f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21111,6 +21111,7 @@ B: https://bugzilla.kernel.org C: irc://irc.oftc.net/linux-pci T: git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git F: Documentation/ABI/testing/sysfs-bus-pci-devices-aer +F: Documentation/ABI/testing/sysfs-bus-pci-devices-flit F: Documentation/ABI/testing/sysfs-devices-pci-host-bridge F: Documentation/PCI/ F: Documentation/devicetree/bindings/pci/ diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index a111e62e39b3..e53e81ef5d91 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -2016,6 +2016,9 @@ const struct attribute_group *pci_dev_attr_groups[] = =3D { &aer_stats_attr_group, &aer_attr_group, #endif +#ifdef CONFIG_PCIE_FLIT + &flit_attr_group, +#endif #ifdef CONFIG_PCIEASPM &aspm_ctrl_attr_group, #endif diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 53a90f75cd76..733f0db70413 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1005,6 +1005,7 @@ void pci_flit_init(struct pci_dev *pdev); void pci_flit_exit(struct pci_dev *pdev); void pci_save_flit_state(struct pci_dev *pdev); void pci_restore_flit_state(struct pci_dev *pdev); +extern const struct attribute_group flit_attr_group; #else static inline void pci_flit_init(struct pci_dev *pdev) { } static inline void pci_flit_exit(struct pci_dev *pdev) { } diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c index 9eb804035997..252bbb54e617 100644 --- a/drivers/pci/pcie/flit.c +++ b/drivers/pci/pcie/flit.c @@ -16,8 +16,10 @@ #include #include #include +#include #include #include +#include #include #include "portdrv.h" #include "../pci.h" @@ -76,6 +78,7 @@ static bool flit_is_native(struct pci_dev *pdev) =20 struct flit_info { spinlock_t lock; /* serializes Counter Control read-modify-write */ + struct ratelimit_state ratelimit; bool cntr_enabled; /* Counter Enable as the driver intends it */ }; =20 @@ -96,6 +99,10 @@ void pci_flit_init(struct pci_dev *pdev) =20 spin_lock_init(&pdev->flit_info->lock); =20 + ratelimit_state_init(&pdev->flit_info->ratelimit, + DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_FLIT, sizeof(u16)); =20 pci_dbg(pdev, "Flit Logging Extended Capability present.\n"); @@ -170,6 +177,38 @@ static void flit_cntr_ctrl_update(struct pci_dev *pdev= , u16 clear, u16 set) spin_unlock_irqrestore(&pdev->flit_info->lock, flags); } =20 +/* + * pci_dev_attr_groups[] in pci-sysfs.c is the only consumer of the group + * below, and the ratelimit accessors it is built from live there too. + */ +#ifdef CONFIG_SYSFS + +PCI_RATELIMIT_INTERVAL_ATTR(ratelimit_interval_ms, flit_info->ratelimit); +PCI_RATELIMIT_BURST_ATTR(ratelimit_burst, flit_info->ratelimit); + +static struct attribute *flit_attrs[] =3D { + &dev_attr_ratelimit_interval_ms.attr, + &dev_attr_ratelimit_burst.attr, + NULL +}; + +static bool flit_group_visible(struct kobject *kobj) +{ + struct pci_dev *pdev =3D to_pci_dev(kobj_to_dev(kobj)); + + return !!pdev->flit_info; +} + +DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(flit); + +const struct attribute_group flit_attr_group =3D { + .name =3D "flit", + .attrs =3D flit_attrs, + .is_visible =3D SYSFS_GROUP_VISIBLE(flit), +}; + +#endif /* CONFIG_SYSFS */ + static void flit_cntr_enable(struct pci_dev *pdev) { u16 flit =3D pdev->flit_cap; @@ -205,7 +244,8 @@ static void flit_report(struct pci_dev *pdev, u32 err_l= og1, u32 err_log2) if (!(err_log1 & FLIT_ERR_LOG1_ERROR) && !err_log2) return; =20 - pci_warn(pdev, "ErrLog1: 0x%08x ErrLog2: 0x%08x\n", err_log1, err_log2); + if (__ratelimit(&pdev->flit_info->ratelimit)) + pci_warn(pdev, "ErrLog1: 0x%08x ErrLog2: 0x%08x\n", err_log1, err_log2); =20 trace_flit_event(pci_name(pdev), err_log1, err_log2); } --=20 2.43.0 From nobody Thu Sep 24 23:33:23 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010067.outbound.protection.outlook.com [52.101.56.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19B164FE2CE; Fri, 18 Sep 2026 14:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743431; cv=fail; b=KGI2U3xVZ/LFVpL1b2Y3BsXaH1zjNAfcr9JrNVYrHZ9XXbUaxX1CfP0HGo3CCenv/ZJJfktc5PkKACnBo6kRy0LiVAl+EoMXNIfwQ5yuseR2l0KvPaklzD6k8XEHWU2YrGr7IkzBSKvjkj9o+XAAWV0X29PCefPSKJPtAF6HmA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789743431; c=relaxed/simple; bh=kSHot8/hvEMPsIl9d05qUKCsqxi09TLkdVjmNgXqXIo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jwaXyjgUDiog3dugzhHSSotDm8lQvyiO4vkqVQp2KdRD+vat3Tj7igb1f/Wxqvw5RyMmFrfFeYqIKu/3tow6dD3AtTYBuyJlRrYvSuecGI6YpO1dprAB6oIXXwRzLWa2qb4jcWFyw5PCW21n8GrPoZI5d74uCO4kpoFT+yCo5gU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=crPeWY/U; arc=fail smtp.client-ip=52.101.56.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="crPeWY/U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cJjVQQVoQpCquqlAX3fdQUfugwaeQBFcKJEEWyjM2I8n/h4TZhtN5IGdqqMnU5tg5tMrrgk2iUtNMb7enpIHYKvvS3LX5G4h8v6+FmAAS5t8DTOKO7Tx8twYKb2e2lxdFel9Fnr4ETEWLrxkWU/lCH6oJxIPBwME+ZD8Y8ur0xOwMnruKmQcENTyE1A1+fPUAikL6oGoOj/JUysY7/xtsiB3+6+V0FUrDrzvY0JouvJmopJ/him4kAjL0CsqDwjba39mQXB/r5XeVWdaP34dbJemRPOzTyD2o4fnrNbWO/PcSu3ErUKa1I4VRbCc6IHjOF+ulq09KXgkQAKtU47m9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b0aAb9AOdB8UvJlawE2kKNMMUALij+YUstcRWH0liE4=; b=gUk4JDCQvk81+oACpqJtnJuYQ36lAl46aWvP408gwQ7iidcf7LRdZkvg5IY/jRJAQkG5bKeYKiwcpIzw+3VJF/fq9k8CUoqcEwOUklfClq6K+mVrthWm34th9naXQZCpclnd1cnihR6IriDHOKPzl7XUAs+RvwKRlWw8+LoO5g60poskMt5n3WpK+P5Wp0ylgW85esYffOkNdIbLlD4K4EF1L3NPamCDFqC2yLHs4CjLF2Elj35hcPUE4a3B3KMkW+G/dkHZWrYZPJlfyFcmDmeSzJjeVZnOalMupIdnUtJsFuTgFWrr5ZFyiGpYrZJaa/mOPOBwVQy9vOLo8vvyug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b0aAb9AOdB8UvJlawE2kKNMMUALij+YUstcRWH0liE4=; b=crPeWY/UgrmgFZNK7qERkc2ivClbXAu5wH+ksB5LapDC9mHh7hL3j+wMOS1fxfqxLxnyy1qnuo9EeVzwBWJXP7zV9vm3mvYmj7uevhobs2xG22K8RXM+GkO0cfcMz9fsnChh6/qgOazImvWsiTlER4MTFPZi8yRsOGr0kIPTwsE= Received: from CH2PR15CA0009.namprd15.prod.outlook.com (2603:10b6:610:51::19) by DM3PR12MB9391.namprd12.prod.outlook.com (2603:10b6:0:3d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.13; Fri, 18 Sep 2026 14:56:55 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:51:cafe::10) by CH2PR15CA0009.outlook.office365.com (2603:10b6:610:51::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.11 via Frontend Transport; Fri, 18 Sep 2026 14:56:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 18 Sep 2026 14:56:55 +0000 Received: from quartz-7b1chost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Fri, 18 Sep 2026 09:56:53 -0500 From: Yazen Ghannam To: CC: , , , , Yazen Ghannam Subject: [PATCH v2 10/10] PCI/FLIT: Expose the error counter controls through sysfs Date: Fri, 18 Sep 2026 09:56:18 -0500 Message-ID: <20260918145619.3016889-11-yazen.ghannam@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com> References: <20260918145619.3016889-1-yazen.ghannam@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|DM3PR12MB9391:EE_ X-MS-Office365-Filtering-Correlation-Id: b433535c-73a9-4471-98ec-08df159514d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|36860700016|376014|82310400026|1800799024|10067099003|6133799003|18002099003|22082099003|56012099006|5023799004|11063799006; X-Microsoft-Antispam-Message-Info: UCpsDsrTfPu4GP8CrqhMV8GyPB3utGDFNwdBqgQpmkhNhqSs2E+0DLIJ9JB63WuAlFPzmM/P+ll0A015494L6XrInwLGW9Vp/MdWiFAWbHFD6QQYGZuC0Lsct4PQS3WMSBZGZCopB4w56X76tD24rml4kHC2RSdUyv2rdn8vUw/UFH8oNqiqCXZRuVh4g63gP3ftOaPhP0/weqzYTPnK4IwOZQ3JmzMmxP/qnVE8coMGkl4NxLYD+SR76uy3cPrXg7IngcAr/6IzfSUGJTOH42YVIkoaSlsgwyqHASuE0UVON48ToX8pggRK+u2Hnm0capMIN9lEoDo9LRIabdFMwIVwg4MNx4vFQgVwH0Jl+Ibvy8kZiyvIGg49LXHiNWKWqfv+larg/3iX8GRE/OLl8goTvZw8XStNQE50+i9FauIi75tg51SvivQkaSquhTJCVFLM8hQCInD4Ozut437DOwu8eMaQAdhM94LMRrfm1hm52kUDBrJO8fcCKR97JirYkzVliflWdQRr5Sd9qNWJoWFBv5Y8JU3p1Xa8ghzLMnMB+54iSlXvcQwdRyk/OhHOHG9rJ98UZbgG7E3pMcdEOPenacw/1MbhHvIOaiiFxCFP9zwcOxUyArOhPj4XSI6iCO5oGtJSZQbZXTiXSic3xpDwe03RpFfAcRxuFRn/mLUdh9ND/vYiwOgMs4fHKaGYa3LO73Kmv5+PTQoBIY0WvQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(36860700016)(376014)(82310400026)(1800799024)(10067099003)(6133799003)(18002099003)(22082099003)(56012099006)(5023799004)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1Wx7GHSp61LVqrxOKqbWz6hvytwTo5Auca9sVTjPnnzePasmpEiSyERjzewKPAEAItEp8kwGaLRjBNvhNxlXDt/zask2LnOnw/0ps5lXQrsSubeVmNxVARdXypLUnV8TT1RhyXAcqCzUaU2UYqqJX4RSZeEQNbyzQQRt6zjCIB23QwKffA90LF3ebUTGRpLMgJhFBbeGIRxn9vtrQ9Cxlagg3s+DZXg4bI1e1wef26iKg3kNlw7cNSHebVdW/+RMkoQ/ZFrTwsQWcWB5JPjZgpplUMvWb/aaxeSPjWmxSHbQa2Q7Cnie1mUjXyPNkHxzA5jcmtxmCjPz5r3rAaYmUYLl2Dohwx9KcT/mFzbA2vmu3epwUduCLj9wo71CsXV1Xt07oswcmy+1EJUa5/96j/15J7UV3yX3u46BX7U5qBLDp+RuG2ayouodohIcRJI+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2026 14:56:55.3002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b433535c-73a9-4471-98ec-08df159514d2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9391 Content-Type: text/plain; charset="utf-8" The Flit Error Counter only generates an event when the Flit Error Counter exceeds Trigger Event on Error Count, and the counter drains on its own at a rate set by the link width and encoding. The driver picks a default for that field when the platform leaves it at zero, but the right threshold depends on the link and on how noisy an error rate is worth reporting. Which events the counter counts at all is likewise a policy choice, not something the driver can pick for every user. Expose both fields of the Flit Error Counter Control register through the per-device "flit" sysfs group, gated on CAP_SYS_ADMIN like the ratelimit attributes beside them. Track the trigger in struct flit_info rather than rereading it from the register on every enable. Sampling the register only works while nothing but the platform writes it. Once the value can come from sysfs, a zero means "the user asked for no events" rather than "the platform left it alone", and rederiving the default would put it back on the next resume. Apply each write to the extended capability save buffer as well. pcie_portdrv_slot_reset() restores that buffer after running the .slot_reset callbacks, so it is the last writer on the recovery path and would otherwise put the probe-time settings back. These attributes are the first user-context config accesses in this driver, so hold a runtime PM reference across them. Assisted-by: LLM Signed-off-by: Yazen Ghannam --- .../ABI/testing/sysfs-bus-pci-devices-flit | 35 ++++ drivers/pci/pcie/flit.c | 156 +++++++++++++++++- include/uapi/linux/pci_regs.h | 1 + 3 files changed, 186 insertions(+), 6 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-flit b/Documen= tation/ABI/testing/sysfs-bus-pci-devices-flit index 43d7c7aacf81..01f22ac9ebf6 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-flit +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-flit @@ -33,3 +33,38 @@ Description: Ratelimit burst for flit error logs. Writin= g a value changes Writing 0, or any negative value, suppresses all logs unless the interval attribute is also 0. Default is DEFAULT_RATELIMIT_BURST (10). + +What: /sys/bus/pci/devices//flit/trigger_count +Date: September 2026 +KernelVersion: 7.4.0 +Contact: linux-pci@vger.kernel.org +Description: Trigger Event on Error Count field of the Flit Error Counter + Control register. An event is generated when the Flit Error + Counter exceeds this value. Accepts 0 to 255. Reading gets + the current field value. + + The counter is eight bits and decrements on its own at a + rate set by the link width and encoding, so a high value + reports only a link whose error rate greatly exceeds that + drain rate. Writing 0 disables event generation, and 255 + can never be exceeded, so neither value generates an event. + + A value set by the platform is left alone. Default is 254 + where the platform left the field at zero. + +What: /sys/bus/pci/devices//flit/events_to_count +Date: September 2026 +KernelVersion: 7.4.0 +Contact: linux-pci@vger.kernel.org +Description: Events to Count field of the Flit Error Counter Control + register, selecting which events the Flit Error Counter + counts. Reading gets the current field value:: + + 0 FEC-correctable Flit, Invalid Flit, or Framing Error + 1 FEC-correctable Flit + 2 Invalid Flit + 3 the events selected by 0, plus a 1b/1b TS Ordered Set + with only one valid half, and an invalid Ordered Set + + The driver never writes this field on its own, so it + defaults to the value set by the platform. diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c index 252bbb54e617..33ec1b9c385c 100644 --- a/drivers/pci/pcie/flit.c +++ b/drivers/pci/pcie/flit.c @@ -13,6 +13,7 @@ #define dev_fmt pr_fmt =20 #include +#include #include #include #include @@ -79,11 +80,14 @@ static bool flit_is_native(struct pci_dev *pdev) struct flit_info { spinlock_t lock; /* serializes Counter Control read-modify-write */ struct ratelimit_state ratelimit; + u16 trigger; /* Trigger Event on Error Count to program */ bool cntr_enabled; /* Counter Enable as the driver intends it */ }; =20 void pci_flit_init(struct pci_dev *pdev) { + u16 ctrl, trigger; + if (!flit_is_port(pdev) || !flit_is_native(pdev)) return; =20 @@ -103,6 +107,17 @@ void pci_flit_init(struct pci_dev *pdev) DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); =20 + /* + * Sample the trigger before anything here writes the register. A zero + * field means the platform left it alone, so fall back to the default. + * From here on flit_info->trigger is what gets programmed, so a zero + * written through sysfs stays zero. + */ + pci_read_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, + &ctrl); + trigger =3D FIELD_GET(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, ctrl); + pdev->flit_info->trigger =3D trigger ? trigger : FLIT_DEFAULT_TRIGGER; + pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_FLIT, sizeof(u16)); =20 pci_dbg(pdev, "Flit Logging Extended Capability present.\n"); @@ -164,16 +179,24 @@ void pci_restore_flit_state(struct pci_dev *pdev) * Count at zero, and per PCIe r6.4, sec 7.7.8.4, table 7-95, a zero trigg= er * never generates an event. */ -static void flit_cntr_ctrl_update(struct pci_dev *pdev, u16 clear, u16 set) +static void __flit_cntr_ctrl_update(struct pci_dev *pdev, u16 clear, u16 s= et) { - unsigned long flags; u16 ctrl; =20 - spin_lock_irqsave(&pdev->flit_info->lock, flags); + lockdep_assert_held(&pdev->flit_info->lock); + pci_read_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, &ctrl= ); ctrl &=3D ~clear; ctrl |=3D set; pci_write_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, ctrl= ); +} + +static void flit_cntr_ctrl_update(struct pci_dev *pdev, u16 clear, u16 set) +{ + unsigned long flags; + + spin_lock_irqsave(&pdev->flit_info->lock, flags); + __flit_cntr_ctrl_update(pdev, clear, set); spin_unlock_irqrestore(&pdev->flit_info->lock, flags); } =20 @@ -186,9 +209,130 @@ static void flit_cntr_ctrl_update(struct pci_dev *pde= v, u16 clear, u16 set) PCI_RATELIMIT_INTERVAL_ATTR(ratelimit_interval_ms, flit_info->ratelimit); PCI_RATELIMIT_BURST_ATTR(ratelimit_burst, flit_info->ratelimit); =20 +/* + * Program a durable setting into the register and the save buffer. + * pcie_portdrv_slot_reset() restores that buffer after running .slot_rese= t, so + * it is the last writer on the recovery path and would otherwise put the + * probe-time word back. + * + * Both writes happen under the lock, so the register and the buffer cannot + * disagree if trigger_count and events_to_count are written at once. The + * buffer gets the same clear and set rather than a fresh sample, which wo= uld + * pick up the Counter Enable that flit_isr() leaves clear for flit_ist(). + */ +static void flit_cntr_ctrl_set(struct pci_dev *pdev, u16 clear, u16 set) +{ + struct pci_cap_saved_state *save_state; + unsigned long flags; + u16 *cap; + + save_state =3D pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_FLIT); + cap =3D save_state ? (u16 *)&save_state->cap.data[0] : NULL; + + pci_config_pm_runtime_get(pdev); + + spin_lock_irqsave(&pdev->flit_info->lock, flags); + __flit_cntr_ctrl_update(pdev, clear, set); + if (cap) { + *cap &=3D ~clear; + *cap |=3D set; + } + spin_unlock_irqrestore(&pdev->flit_info->lock, flags); + + pci_config_pm_runtime_put(pdev); +} + +/* A port in D3cold answers config reads with all ones. */ +static u16 flit_cntr_ctrl_read(struct pci_dev *pdev) +{ + u16 ctrl; + + pci_config_pm_runtime_get(pdev); + pci_read_config_word(pdev, pdev->flit_cap + PCI_FLIT_ERR_CNTR_CTRL, + &ctrl); + pci_config_pm_runtime_put(pdev); + + return ctrl; +} + +static ssize_t trigger_count_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pci_dev *pdev =3D to_pci_dev(dev); + u16 ctrl, trigger; + + ctrl =3D flit_cntr_ctrl_read(pdev); + trigger =3D FIELD_GET(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, ctrl); + + return sysfs_emit(buf, "%u\n", trigger); +} + +static ssize_t trigger_count_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pci_dev *pdev =3D to_pci_dev(dev); + u16 val; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (kstrtou16(buf, 0, &val) < 0) + return -EINVAL; + + if (val > FIELD_MAX(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER)) + return -EINVAL; + + pdev->flit_info->trigger =3D val; + flit_cntr_ctrl_set(pdev, PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, + FIELD_PREP(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, val)); + + return count; +} + +static DEVICE_ATTR_RW(trigger_count); + +static ssize_t events_to_count_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pci_dev *pdev =3D to_pci_dev(dev); + u16 ctrl, events; + + ctrl =3D flit_cntr_ctrl_read(pdev); + events =3D FIELD_GET(PCI_FLIT_ERR_CNTR_CTRL_EVENTS, ctrl); + + return sysfs_emit(buf, "%u\n", events); +} + +static ssize_t events_to_count_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pci_dev *pdev =3D to_pci_dev(dev); + u16 val; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (kstrtou16(buf, 0, &val) < 0) + return -EINVAL; + + if (val > FIELD_MAX(PCI_FLIT_ERR_CNTR_CTRL_EVENTS)) + return -EINVAL; + + flit_cntr_ctrl_set(pdev, PCI_FLIT_ERR_CNTR_CTRL_EVENTS, + FIELD_PREP(PCI_FLIT_ERR_CNTR_CTRL_EVENTS, val)); + + return count; +} + +static DEVICE_ATTR_RW(events_to_count); + static struct attribute *flit_attrs[] =3D { &dev_attr_ratelimit_interval_ms.attr, &dev_attr_ratelimit_burst.attr, + &dev_attr_trigger_count.attr, + &dev_attr_events_to_count.attr, NULL }; =20 @@ -223,9 +367,9 @@ static void flit_cntr_enable(struct pci_dev *pdev) spin_lock_irqsave(&pdev->flit_info->lock, flags); pci_read_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_CTRL, ®); =20 - /* Set default trigger count if not set by platform, since zero never fir= es */ - if (!(reg & PCI_FLIT_ERR_CNTR_CTRL_TRIGGER)) - reg |=3D FIELD_PREP(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, FLIT_DEFAULT_TRIGGER= ); + reg &=3D ~PCI_FLIT_ERR_CNTR_CTRL_TRIGGER; + reg |=3D FIELD_PREP(PCI_FLIT_ERR_CNTR_CTRL_TRIGGER, + pdev->flit_info->trigger); =20 reg |=3D PCI_FLIT_ERR_CNTR_CTRL_EN | PCI_FLIT_ERR_CNTR_CTRL_INTR_EN; pci_write_config_word(pdev, flit + PCI_FLIT_ERR_CNTR_CTRL, reg); diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 73482024359b..bf55b2e42ce3 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -1200,6 +1200,7 @@ #define PCI_FLIT_ERR_CNTR_CTRL 0x0c /* Flit Error Counter Control Regist= er */ #define PCI_FLIT_ERR_CNTR_CTRL_EN 0x0001 /* Flit Error Counter Enable */ #define PCI_FLIT_ERR_CNTR_CTRL_INTR_EN 0x0002 /* Flit Error Counter Inte= rrupt Enable */ +#define PCI_FLIT_ERR_CNTR_CTRL_EVENTS 0x000c /* Events to count */ #define PCI_FLIT_ERR_CNTR_CTRL_TRIGGER 0x0ff0 /* Trigger Event on Error = Count */ #define PCI_FLIT_ERR_CNTR_STA 0x0e /* Flit Error Counter Status Register= */ #define PCI_FLIT_ERR_CNTR_STA_INTR_GEN 0x0008 /* Interrupt Generated bas= ed on Trigger */ --=20 2.43.0