From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03F2A606A32F for ; Tue, 1 Dec 2026 11:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jKkfN637; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=D18me52e DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=k500jxZ/IJBI++3s9q/TxRrVUhvlb1c8y50G9KoBv4Y=; b=jKkfN637nBN0kjAr2rTqi883dC vtri3H20lTcefJOIyqEMr1gOOgmzedVNrNZhsoQtiqZ6eDNZCitnsleCoOo8BNK1oIUHzfo0IWusP M+Rd3v89aQ4Gowm3Hpw/6n91fsl363YDH0M3mgyGk3+eusU037HKnplsjnegfMqkBB+37byJXVDn7 Dbtcw3bzc6N7cZj7IZIQzApWUBxURDBBU6s4KvtyeTby2cD0fdU+ch5jTN+z3e1KNjWouhwkLy3e9 OTFNfgQAPvQ/7XaUSSKwbOof4+DhwtuldStscEspJ3ct9RXyuJfdk4WtJlUcu9YCq+inxcbo0VueY Y6Kczg5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYLcV-00000007USP-40F5; Tue, 01 Dec 2026 11:02:00 +0000 Received: from smtpout-03.galae.net ([185.246.85.4]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYLcP-00000007URA-0rN4 for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 11:01:54 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 52B174E41799; Tue, 1 Dec 2026 11:01:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 25D44603CB; Tue, 1 Dec 2026 11:01:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B5E1111EA11F6; Tue, 01 Dec 2026 12:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796122909; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=k500jxZ/IJBI++3s9q/TxRrVUhvlb1c8y50G9KoBv4Y=; b=D18me52eOU2qhXjzKCW86dOrdNxCQ0Fq3/BiEKQjGSVvcPfAvA8wNpoZR5NKbbvvk+2y5X ify2PY7h/hTlashCtViQyxN3BKhBYW4IKkB6QTkL3zwgWcF3rZxIDWAKwMPIlg7xBJU+Fq OgBxqSZ4wstQlETRLf1hGRUtiNb2LYKRicefVk4c4U4y1PhAVyBi6asSCQKJ+q07Omc22P CjB2IlSpgukKXXZisD7G6iJ+5A07H3NDkbneuMKUR2oR6quAtooymNR4PObqX05DJxOgBW QD2vckUS/PjVOei5i61ie6iykNzNBNQPSIbdWBXeWG+bTerScBy/pGE2y2ZiVQ== From: Paul Cercueil To: Will Deacon , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Bjorn Helgaas , Rob Herring , Lukas Wunner Cc: Frank Li , Qiang Yu , Manivannan Sadhasivam , Thomas Petazzoni , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paul Cercueil , stable@vger.kernel.org Subject: [PATCH v2] PCI: Fix root port reset lock ordering issue Date: Tue, 1 Dec 2026 12:01:30 +0100 Message-ID: <20261201110130.87336-1-paul.cercueil@bootlin.com> X-Mailer: git-send-email 2.47.3 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_030153_379196_9F1ED3D4 X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Currently, pci_host_reset_root_port() calls pci_lock_rescan_remove(), to protect pci_bus_error_reset() racing against pciehp_unconfigure_device(). The reset function then calls pci_reset_bridge(), then pci_slot_reset(), pci_reset_hotplug_slot(), which will call the .reset_slot callback. For a pciehp root port, this calls the pciehp_reset_slot() function, which will grab the 'reset_lock'. On the other hand, the pciehp IRQ handler pciehp_ist() gets the 'reset_lock' first, then calls pciehp_handle_presence_or_link_change(), which will call pciehp_enable_slot(), __pciehp_enable_slot(), board_added(), then finally pciehp_configure_device(), which will call pci_lock_rescan_remove(). This is a typical ABBA locking issue. However, the rescan lock is used in pci_host_reset_root_port() only to protect against the PCI device disappearing. We can keep this protection while fixing this locking issue by getting a reference to the PCI device instead. Fixes: 4c99bace4f4e ("PCI: host-common: Add link down handling for Root Ports") Cc: stable@vger.kernel.org Signed-off-by: Paul Cercueil --- Changelog: v2: - Grab a reference to the PCI device in pci_host_reset_root_port() instead of grabbing the rescan lock. This makes the ABBA locking issue disappear. --- drivers/pci/controller/pci-host-common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c index 35ee51cf9d06..157328f393f4 100644 --- a/drivers/pci/controller/pci-host-common.c +++ b/drivers/pci/controller/pci-host-common.c @@ -327,11 +327,10 @@ EXPORT_SYMBOL_GPL(pci_host_common_d3cold_possible); static pci_ers_result_t pci_host_reset_root_port(struct pci_dev *dev) { + struct pci_dev *pdev __free(pci_dev_put) = pci_dev_get(dev); int ret; - pci_lock_rescan_remove(); ret = pci_bus_error_reset(dev); - pci_unlock_rescan_remove(); if (ret) { pci_err(dev, "Failed to reset Root Port: %d\n", ret); return PCI_ERS_RESULT_DISCONNECT; -- 2.47.3