From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6619E9E2FD for ; Wed, 11 Feb 2026 12:47:59 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4f9yrt2Xp2z2xlk; Wed, 11 Feb 2026 23:47:58 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=115.124.30.124 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1770814078; cv=none; b=aioQTJHDO1NSoYdFUOBYcXp581RutCTS1NYkxuHinLr+MJDps4wIm7On9eiqlUt+L8WpVoafPoeo3rhkUh6p+GYX/Crq2lsrH+CW9J5IC2iECw2MSZt08siULgkIRYBuZzCObHLV1EKjKQAQp2a86XpCkMYuXB7XkV8LvXBoXky8xIBPXCMpYvna8ulv3pN2hLfxebghYuVswUSz/Sy64Cbi0fwm+mNkgjFfa7VLwO0QpbHtSWBUBdbBHMHnGfZQ9j6av21eGhdeew76NdiM9kLhpH6mvZ5T2EArMr772N7OAlCcAZOrbGqGcV2IZ9ZDiJE9dqmJepqo0GJO4OZoNA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1770814078; c=relaxed/relaxed; bh=G5PYZMNjLjCkB/3J1uvIOFYqNefpUtlIsBo/LElDi20=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=NDqrNBJ7fGWiz0GRiZemFw2KKXg3AdBrW4axiH5h+S1A3EAjQOGG2enBLFsB226nAjx57WJaiFyx0EN4IY0lW29yzTG+pf7sXti8xPTjpV/N0H5vCERV7SgOfVqjQ1hPz3MjTDcbPt5Cwpm7dRootM7Kfzjy7Xu3DCbs+OUbGoFuPAv43NAYkSHl3RO4TdCXzk4OiZaj4eplHhFKxup3ljiJSHiuRBil51vthGvls8RJq484XrKU7lsBKVgAWjNMn8Ua7U+OTMvOKGxoeQMBXnwYHrb00IOFLLOl9qxtheFJl72s/qZliw59Lmh90JTuzg4RCBtmtnwk7+n/XJMpDg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=YqYhJFgd; dkim-atps=neutral; spf=pass (client-ip=115.124.30.124; helo=out30-124.freemail.mail.aliyun.com; envelope-from=xueshuai@linux.alibaba.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=YqYhJFgd; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.124; helo=out30-124.freemail.mail.aliyun.com; envelope-from=xueshuai@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4f9yrr6zJQz2xlM for ; Wed, 11 Feb 2026 23:47:56 +1100 (AEDT) DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1770814072; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=G5PYZMNjLjCkB/3J1uvIOFYqNefpUtlIsBo/LElDi20=; b=YqYhJFgdV7DOCXZc4EIsZQVISfbp3q+dR1KdbgJyQVEZnKIRMpUvHq/hGGpf96SKxPxCo8fDYMvy2X+H9FrRvx0dXmyHs/YfMT5y5chd0oMSmjSlf/Lr388F2Ap7zkZ2r77hDcAtO0t9kwyfqOoRjJ86zrZ8+gpKBszTbuPrdlA= Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Wz1H63b_1770814068 cluster:ay36) by smtp.aliyun-inc.com; Wed, 11 Feb 2026 20:47:49 +0800 From: Shuai Xue To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, bhelgaas@google.com, kbusch@kernel.org, sathyanarayanan.kuppuswamy@linux.intel.com, lukas@wunner.de Cc: mahesh@linux.ibm.com, oohall@gmail.com, xueshuai@linux.alibaba.com, Jonathan.Cameron@huawei.com, terry.bowman@amd.com, tianruidong@linux.alibaba.com, zhuo.song@linux.alibaba.com, oliver.yang@linux.alibaba.com Subject: [PATCH v3] PCI/AER: Only clear error bits in PCIe Device Status register Date: Wed, 11 Feb 2026 20:46:24 +0800 Message-Id: <20260211124624.49656-1-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, pcie_clear_device_status() clears the entire PCIe Device Status register (PCI_EXP_DEVSTA) by writing back the value read from the register, which affects not only the error status bits but also other writable bits. According to PCIe Base Specification r7.0, sec 7.5.3.5 (Device Status Register), this register contains: - RW1C error status bits (CED, NFED, FED, URD at bits 0-3): These are the four error status bits that need to be cleared. - Read-only bits (AUXPD at bit 4, TRPND at bit 5): Writing to these has no effect. - Emergency Power Reduction Detected (bit 6): A RW1C non-error bit introduced in PCIe r5.0 (2019). This is currently the only writable non-error bit in the Device Status register. Unconditionally clearing this bit can interfere with other software components that rely on this power management indication. - Reserved bits (RsvdZ): These bits are required to be written as zero. Writing 1s to them (as the current implementation may do) violates the specification. To prevent unintended side effects, modify pcie_clear_device_status() to only write 1s to the four error status bits (CED, NFED, FED, URD), leaving the Emergency Power Reduction Detected bit and reserved bits unaffected. Fixes: ec752f5d54d7 ("PCI/AER: Clear device status bits during ERR_FATAL and ERR_NONFATAL") Cc: stable@vger.kernel.org Suggested-by: Lukas Wunner Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Lukas Wunner Signed-off-by: Shuai Xue --- changes since v2: - accommodate two macros per line per Lukas - pick up Reviewed-by tag from Lukas --- drivers/pci/pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 13dbb405dc31..0e6a50260555 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2243,10 +2243,9 @@ EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); #ifdef CONFIG_PCIEAER void pcie_clear_device_status(struct pci_dev *dev) { - u16 sta; - - pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &sta); - pcie_capability_write_word(dev, PCI_EXP_DEVSTA, sta); + pcie_capability_write_word(dev, PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_CED | PCI_EXP_DEVSTA_NFED | + PCI_EXP_DEVSTA_FED | PCI_EXP_DEVSTA_URD); } #endif -- 2.43.5