Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796122912; b=OrlvYsy9ScOEhnKa56FOfmyq0gjZ3wAImXtjtNkT0QK8DKHdoLZVc/C4Qf3wiz9xevzp WQYEWHrkYU2Kr1maJ4xK0WXN7AMFhlOWVKGd5CBhAnv+S+f9O1l6Jfb8pav1lT20907o/ Qz/ddqMrr+Z69Izsy6z0qtsysJMZLheiFS0FhOMbNYHd6MRa7NJcQHJv68R0ywWyuvBGT 0uw8YoDIn259deKfg5xez/Xi8amDZMQshyNM4uV/mYZZsuyZRklClMxRONQnJHYwZAGVt r57YbaLiioHYMKVFz+S8talylgqVDa5hOB2sCZMC6s/R3/pa7F7HYCFcNJ/wAf5hY4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796122912; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=k500jxZ/IJBI++3s9q/TxRrVUhvlb1c8y50G9KoBv4Y=; b=OHsdP+tXRNWZ7qn+KutHekyqBgj+4gV53uhteqCvXa1I0/HF9FI6iHEnX29cdZrWO/VD QvGXP5zq+awbUl/TBDVn4I2UAbDd6FwM8FbQh4zuBkAWn/3ZaUtUVQL9pbiVMEXnkNnBg a46xRSHUjxTR2jIaeP7MV0TADMDPDbTUSBe+Xi8nU99xkmCRBA8W8gJaiFu7XN8vwtPDH UCIv+HbcdN+CZPTHnx0CJ9s6wsUkhMI0n8+6iSDYm5w8GbLvp5oXHkZhhp+OnSV3p2Wyq AY7BhE1BUFnNulw/42K4/4FlmlPbpi9xR1wCBMFGi13Eu/JnIaWFkOuTUihbS5ajM/g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=D18me52e; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 23082606A320 for ; Tue, 1 Dec 2026 11:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 23082606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=D18me52e 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-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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