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=1796053552; b=atqoju04pDN5tu8NCeMUoDtxgT9DlqDVos6YRJSRKhH7Emc6KpYZKlHIZx4bWZNZ2Ogi B5vqm5yDUf0VuzpA/E/CytPgFkeNNEAU58b1codDoqL7izhZW+vQzlXWHi7gmG9RV0VJM NsMxgXICnmKEliydUr0LLnrnbMZZgj23jRBVbmVPl6fFU1bMoIcZeCJtWlwpQzrgyx8Y5 n5wSD+0DIsA/gLDm+8Ckil8KFYKFzHOs4PBHKgdRnydyohujQtFZEyYjCzBkfXespd/R+ 4n13HacyQTPiEBsZWdiU1+yVsSiS0mJ3D/29APV76HTtM2dQ4ePS75pI+MhJ8L5qLmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053552; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=gLPPCda8xWLWlWeKvjsewK5e8n2TQ/wcN8yBinHe074=; b=ATlTNnQ0YCGSctZxAXutPJwvPOAq/PR2IcMYwLodNqRPh3nOj09bP6K6754pX7hd9Vvu qxc2F5eOMxEnthJLld7aPpqHr7KPTyyxWkJ7N1i7lxP857lWW/5vR1dMUAiMWjuV+TDDP +RVPsiH7EPCwG0Dx8u3GyWPjVRmEnL4VwyIUKR56MCaUGcw3xc8LEcTG13DyZEaeJ6v5T jl5hEtmBTSsJ5hDu4AreeTDFX14ndCyZ87GCDEj/CHOsF3y0LjG5w5BhlYDGWf032pjyN 4oSLbX4jmUkOmPjs735GsvM/l9DyS2V/fJ6wMDROkr0CPqv/UAxPKTRrCXOsvDENynA== 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=osi1Uqif; 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 3E0C9606A31C for ; Mon, 30 Nov 2026 15:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=osi1Uqif Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B6611F00896; Mon, 30 Nov 2026 15:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796053551; bh=gLPPCda8xWLWlWeKvjsewK5e8n2TQ/wcN8yBinHe074=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=osi1UqifHFQiVu7kA6hV6FAG57MKSrcMQH2HZdIBPH0EgNjLzCTGk7wyznD2f/txa Qipch6cGu5mgFNASn+/ljaP6eFkbNR1IDPCVYmz2JaUKWMPDpleXP+jd/bTXaGizut 3mG1iern4n/6er++MGERf1/azHvgqCnLJixFAK+mx5+AbzrnPyea2s5GBNaDgcimZF iph5wDeB5oE77a0pfG2c8uGSf9NngeEv6QxQhz2OBylfchb630FhvfCK5qRcsZv7D5 tiGb98pzbE+hYmBw6i4x/R7hwmHbEfgVbf6YEe2gpbLW6ZUi9KrqkGUnpCw/hgjxlH hkHJ4hGOUUxMA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] PCI: Fix root port reset lock ordering Reply-To: sashiko-reviews@lists.linux.dev To: "Paul Cercueil" Cc: linux-pci@vger.kernel.org In-Reply-To: <20261130153218.189926-1-paul.cercueil@bootlin.com> References: <20261130153218.189926-1-paul.cercueil@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 15:45:50 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] PCI: pciehp: ABBA deadlock with pci_slot_mutex in pciehp_lock_rescan_remove() -- commit 70e71b321e54d0d7c6157b8dbdebfb52c2965df1 Author: Paul Cercueil PCI: Fix root port reset lock ordering This commit adds pciehp_lock_rescan_remove() to temporarily release ctrl->reset_lock while acquiring pci_rescan_remove_lock in pciehp_configure_device() and pciehp_unconfigure_device(). > diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pcieh= p_pci.c > index 65e50bee1a8c0..20549c83870e2 100644 > --- a/drivers/pci/hotplug/pciehp_pci.c > +++ b/drivers/pci/hotplug/pciehp_pci.c > @@ -21,11 +21,28 @@ > #include "../pci.h" > #include "pciehp.h" > =20 > +static inline void pciehp_lock_rescan_remove(struct controller *ctrl) > +{ > + /* > + * pciehp_ist() calls us holding reset_lock, whereas the error-reset > + * path takes pci_rescan_remove_lock before reset_lock. Drop the > + * reader to acquire the rescan lock as the outermost lock, then > + * reacquire reset_lock below it so the order rescan lock -> > + * reset_lock is preserved. > + */ > + lockdep_assert_held_read(&ctrl->reset_lock); > + up_read(&ctrl->reset_lock); > + > + pci_lock_rescan_remove(); > + down_read_nested(&ctrl->reset_lock, ctrl->depth); > +} [Severity: High] Does re-acquiring ctrl->reset_lock here leave an ABBA deadlock with pci_slot_mutex? CPU0 CPU1 ---- ---- down_read(&ctrl->reset_lock) mutex_lock(&pci_slot_mutex) mutex_lock(&pci_slot_mutex) down_write(&ctrl->reset_lock) *** DEADLOCK *** CPU0: pciehp_ist() -> ... -> pciehp_configure_device() -> pciehp_lock_rescan_remove() -> pci_scan_slot() -> ... -> pci_setup_device() -> pci_dev_assign_slot() CPU1: aer_root_reset() -> pci_bus_error_reset() -> pci_reset_bridge() -> pci_slot_reset() -> pci_reset_hotplug_slot() -> pciehp_reset_slot() In pciehp_configure_device(), pci_scan_slot() and pci_hp_add_bridge() run while ctrl->reset_lock is held and take pci_slot_mutex via pci_dev_assign_slot(). Meanwhile, pci_reset_bridge() takes pci_slot_mutex before calling into pciehp_reset_slot(), which takes ctrl->reset_lock for writing. In pci_host_reset_root_port(), where pci_rescan_remove_lock is held around pci_bus_error_reset(), the lock order is pci_rescan_remove_lock -> pci_slot_mutex -> ctrl->reset_lock, which triggers a lockdep circular locking splat against pciehp_configure_device() (pci_rescan_remove_lock -> ctrl->reset_lock -> pci_slot_mutex). Callers of pci_reset_bridge() that do not hold pci_rescan_remove_lock, such as aer_root_reset() and reset_subordinate_store(), can deadlock at runtime with pciehp_configure_device(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130153218.1899= 26-1-paul.cercueil@bootlin.com?part=3D1