From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796515493; b=R4EjiTyHi+LET7gULtbJBKa9igUXQjahYmLhoyP68GIlFO3BulZEeaM/lomp7gOI4+Sp /+PkL3f0UdeXwVjYZTlrO+wufP2CqSwYnHJU8WlLtczfBndWBR70pDruEDA09m4J5E/HB g+3Z34iRdEyg1OOjjUE1XszvNPsQjrlZ5ujGzh1gYeVY/c2/a/NAy0/FGgvK4oi7FF+VE J4nHxvSDr7KyIIFwuuNS+jheOg62HEtDFynVKxiQs+Svu+BbVuSfy8+lfg3gtXJG9tZ6n RVrkG3zK5OJg/5otHhtc1uAKfnJGkN8mfxbtcQRcNUpNIodbfG7IYrzOhU96UPQIWxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796515493; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=tw08uajm+UKnKhtemOtlXyUJjReTLUq2vfXZ5XdbGTc=; b=4kNVYCDxpCEYBueSWTgPS2Ykec7RspDLfutzt1kALved7rXE4jLRGP45yOnKPPzHVk/8 F1REB7wR8yH8A0uZxOSWMwfA3ff6PlNz/1PEkw1r2fCfg6um2/pzzyjpSvkVoqzfTpgxd bFfKKb7Jnm5wnytrW7e7d1Al+Esln4gHufZy0wkbLB7ynb5RWMJZ1DxfAbLR9y4L5//PC dhkofvHuArSQAuuQPRJDex3wDJCE62Q9SvkD4sl0BoM87SX1Y0997BpcKOnlszU0+pxZo GO7OdRcT0JqpTXq0qPQaOukoY4RNLApqizMCJ2h0W9X+5l8kIibE3TNBPNSDpQFBHYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TB8ZI6rP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F086606A31F; Sun, 6 Dec 2026 00:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TB8ZI6rP Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE5CF1F0092B; Sun, 6 Dec 2026 00:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796515493; bh=tw08uajm+UKnKhtemOtlXyUJjReTLUq2vfXZ5XdbGTc=; h=Date:From:To:Cc:Subject:In-Reply-To; b=TB8ZI6rPzPOBNznFhP8uU/3RQRD0bUgEdVmAUXyMpVzIjHcTxKkCs/Yk9pKwBdDAQ CZOrF/kc57zWRTt6KxjzMJjEBSm8uFzForYnAZttIrqoTUZcgbf0ieopiKhputBAOQ eF9AOyoihX1Xh+geVxqzwV/5XkUASiK6CpSXElt21KTwc7bvUs5FiBRSnG8GNsBRk0 Zi/birf9SJ+DEoMx/L2sRmnqCv2Yfg6dFeGSOBd2SzPcBBzAFdh+fvuPud8rbfAV3c M5499PXFeESFuQtneWL6ze8+61LXk6+JHSqV/VQ13rTc7e4pHWy6KECACkq0t0QSND to11CDDNuFt/g== Date: Sat, 5 Dec 2026 18:04:51 -0600 From: Bjorn Helgaas To: xianhutan@asrmicro.com Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, lukas@wunner.de, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH v2] PCI/PM: Reject invalid PMCSR when checking PME status Message-ID: <20261206000451.GA1174821@bhelgaas> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202062959.3519241-1-xianhutan@asrmicro.com> [+cc Rafael, author of 58ff463396ad ("PCI PM: Add function for checking PME status of devices"), which sashiko suggested as Fixes:] On Wed, Dec 02, 2026 at 02:29:59PM +0800, xianhutan@asrmicro.com wrote: > From: Xianhu Tan > > pci_check_pme_status() reads the PMCSR and checks the PME_STATUS > bit without validating the value read from the device. > > If the device or its upstream bridge is inaccessible, a > configuration read may return all ones. Since bit 15 of 0xffff > is set, the PCI core incorrectly interprets the value as an > asserted PME_STATUS bit and reports a spurious PME event. > > This can cause an unnecessary runtime resume of a suspended > device. > > The issue occurs in pci_pme_list_scan(), which scans devices > on the PME list and calls pci_check_pme_status() to check > their PME status. > > On the affected platform, reading the PMCSR after the device > enters D3hot with the PCIe link in L1 returns 0xffff, causing > the PME scan to trigger a false PME event. What is the affected platform and why is it relevant? And why is L1 relevant? I thought L1 should be a hardware concern, not something software needs to worry about. Reading config space, including PMCSR, while in D3hot is supposed to work, isn't it? I do agree that we shouldn't interpret a 0xffff value from PMCSR as having PME_STATUS set, because 0xffff is not a valid value for that register, so the patch itself seems fine to me. I guess I'm only probing for whether there's something special about some platform. If not, maybe we can trim down the commit log a bit. > Use PCI_POSSIBLE_ERROR() to reject an invalid PMCSR value > before checking PME_STATUS. > > This also prevents writing the invalid PMCSR value back to > the device when clearing the PME status. > > Tested on: > - ARM32 platform with PCIe endpoint. > > Test cases: > - PMCSR read returns 0xffff: no false PME event is reported. > - Normal PME status handling remains unchanged. > > Signed-off-by: Xianhu Tan > --- > v2: Use PCI_POSSIBLE_ERROR() instead of open-coding the 0xffff check, > and drop the return value check of pci_read_config_word(), since the > PCI core already sets PCI_ERROR_RESPONSE on failed config reads. > (Lukas Wunner) > > drivers/pci/pci.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 7c6f2aba8144..29ef31411dc8 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -2331,6 +2331,9 @@ bool pci_check_pme_status(struct pci_dev *dev) > > pmcsr_pos = dev->pm_cap + PCI_PM_CTRL; > pci_read_config_word(dev, pmcsr_pos, &pmcsr); > + if (PCI_POSSIBLE_ERROR(pmcsr)) > + return false; > + > if (!(pmcsr & PCI_PM_CTRL_PME_STATUS)) > return false; > > -- > 2.34.1 >