From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796120960; b=FaVn8kxPLAWeMC5GRc5qSMGjdGjYW/kUCgyqgIXnTT1QC3RIjNMtowqhb9wQjEsJomvT s5eGPiC9hhzrQfhotmgCSRfJGKZiHz+g3Mx0Po4LFSyspZpyUHFMhYR32vwz165dFeOeP HHRBtWAjyQdBZwkfPIaS8M67sUMaWEN1ez19e/wY93Y4RLhN1aiRSGZal2DaEFH3KaxEp GQCS14QFzDLih9jHsPtIvJgTonxLaM7UuhFNLJ0MugKDmIF1akSCJYHo089WVFw6lf51C mogXH7rGNtyQ5bRsCeZYxjAqez1Rh16jJTxm6T9+JMCBNFNDx0iSJAZgHJpeJOGN/Fw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796120960; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Date:From: To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=taIqHeJHjC2B3QTdCEDH3fM48eFodqtAWZBqv/xmAAQ=; b=f2z2oS0w94F2TheLfR+rgyhybT/6YInP7VKDFFK1dT1QtTA8ryhV/wnWTp6wOErsYc87 Y209HNHYM0J/e2Sk4i6BnjXP8QYjTWZ1L7RVJP/jecrxbh11MLnxYpt5LMBkS8mVYgUU+ cV2Ur2zcJOIjUkJRin/YrG9e5WgF8sWypim7m3kbRsBRST+Hq8IqJkd4SYsbcM8Hih6Pk HTvQ07isHg85R37DKrZHqLPo+Ke6hvxUfAfUEdZxsCjLgVwZ9F8z6OTHDOyWfm4kju1RL BPHbtZHG8oGRb0t9+POMsvp4TV+leXUUQiGNDr5R9A+Sal31Qp5xOIBJzV3xBDAiB7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Eu9mI2vS; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=e8E8kfaO; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 55218606A31A for ; Tue, 1 Dec 2026 10:29:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 55218606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Eu9mI2vS; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=e8E8kfaO Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1AQOSW2313327 for ; Tue, 1 Dec 2026 10:29:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=taIqHeJHjC2B3QTdCEDH3fM4 8eFodqtAWZBqv/xmAAQ=; b=Eu9mI2vSksTsFkLA4p56wkbvuCB2WU2M+M/bjNUj 8cRiNeVLQLG4pvPhjyo6Z/OSHYRNtRXCAVfPuvIWkdd5S8hDvURbPZ157BfkHmJB XzGMYkRQ7oLj8jJr6Ow8Qn9bg6DAAntwz3lUQ4yuLyoFYXktykfaBfRhMerWqgwU 8ixWS1k+RX2O6qy/b0PSXIZz3J15ssYQgq0oPPkwaJUcONlkDJFFDG721Dgr9uI5 hGNhmduQlfx1zOtJHuKWS4Gf1z1Bo7bY7w7t8vnjlgKuw1U8b6q7IDIftdrtoYW0 4t1Rj1wb4bpXi5ezFYlqM1Rwig6PG3hhuFU1G3H0friGRA== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9nb61u98-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 10:29:19 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-386a0f79047so12834253eec.1 for ; Tue, 01 Dec 2026 02:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796120959; x=1796725759; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=taIqHeJHjC2B3QTdCEDH3fM48eFodqtAWZBqv/xmAAQ=; b=e8E8kfaO3Cg+MuhMOEaquRh4q107iG7Yiq7fQBjNWBq/pkUFfZX2xPxaRcqsgfcMZ3 zsbAv6hA+eOmWA/lEmEOcBoaW3wnoSENOCsokc/pa0hZPZYyF+MIgBg/20FLVDYrjnaE ZmokU4A+uSWtO6RpvfpWXPJot7JsExytRekHSc7hJIhxPpfB/thhgfBCym+zkl36IXJi nkysQxc49/6mh1npfhUHIJpaMMYn85nLSHpBrx4K/KpoV8sFaxguAnE18b+mJH3lrHbW A3U8KYxlOso4+WmZqVQa7BZPE1tB43L/OYIKMbFRrXAF17mar5JVfQqiIGSiImphwOso Gl0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796120959; x=1796725759; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=taIqHeJHjC2B3QTdCEDH3fM48eFodqtAWZBqv/xmAAQ=; b=S6xvFTsYULdZkQ6pfVacndam5a6QF76pop076Geq2QQnmfzdsMcYtEvdiDtXO+Lj3c /iYNKap9lCNbCKM5dubSlJjMMwfnzGJzSz5CQhLDB2vh7mKD3AZKXf2p3dtcYeEMx7/9 UqfEjSQtjhbHUt5tIJ1wjVonA9zOGiKkDe7H/zuPn1sGsbbu8Xf9cWrLvgEiK9GlQdg9 7D7O3PTbyzP6hjTUkXFLzNltt4E4lppLI3fLAh4GP0X9STloSXNo2N2xS6/4ism58PbT t+NWggNWarhzcHj+mW8MZ81sgpLoRuUZKBtcgLURTjQIXlGmg+aXh1Ff1tgR3LE3J89C bITg== X-Forwarded-Encrypted: i=1; AL+hErFe9oxSFtnRtXauarQ12vTBMnLDhKBI8XFD4uRFS5ab/qkR5asex6TxzDtVWcMPinZQMe9AcH3LSgwZT3c=@vger.kernel.org X-Gm-Message-State: APuU4Z+KynoHG71wA9A63/uFsqrGdeQffivD+lkbJI+lbvupUt1Qi96B CaA8ZPZVB/RMd/JQCMJwhdX7d+jk3Xu+5hA321K8q2C+rkmEvWdlEFiW8o8+tQwYsS49Cqw9HHq BBOSKdrbhAjhIKThdH3A3wjRIg+QK2CmCYPDyGDPRTDDeA2KUw0BnTEIzuLHgQil56jk= X-Gm-Gg: AZFdTZes/W5dYQiYWNbmtyPYAoJdF4QHCEN1JrJ10T+lYGEU+VkWpB6H7iv6Kjng769 qujW6J3dDt0bD3iLIslPGftkwxiNRJcYSCrd8v8KuyPMro/4Hy3+pCYXqaGfwXCH73ts/OzXAqg SpVQ97MfMqUEa118y7vTTFEzEuCP0JM9Rwq+gGTOVz//B+xwzLtXJHUDcgRg8PTXEDnPB0F1psz TvEiuzwdm3HoWiQjiacK0RAcxdiOyiILMLIaamU8wIME6vvW/jlmr3NtfIW1VSzC1KK5mbxeiTc ULDYECMT+Shwb1fEF07j9PvE4kUn/fufr2lzKKFPVH+TabYZjFmlwjprfIewu1EBjIatgyM0C8g ldOHi6wHWSRUHZgZlJ+5e12Eb2oITJkb+rrV1IBLIg/YZLMqNmzA0BcOCCSHy4CBX0qVgx9AO47 U5J180azyNu1GdctyunA== X-Received: by 2002:a05:7300:f68e:b0:36d:4560:dd38 with SMTP id 5a478bee46e88-38571807cecmr33020694eec.37.1796120958719; Tue, 01 Dec 2026 02:29:18 -0800 (PST) X-Received: by 2002:a05:7300:f68e:b0:36d:4560:dd38 with SMTP id 5a478bee46e88-38571807cecmr33020677eec.37.1796120958224; Tue, 01 Dec 2026 02:29:18 -0800 (PST) Received: from hu-qianyu-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e7fc3sm95925688eec.8.2026.12.01.02.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 02:29:17 -0800 (PST) Date: Tue, 1 Dec 2026 02:29:15 -0800 From: Qiang Yu To: Lukas Wunner Cc: Will Deacon , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Nirmal Patel , Jonathan Derrick , Frank Li , Manivannan Sadhasivam , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC v2] PCI: pciehp: Fix AB-BA deadlocks between reset_lock, pci_rescan_remove_lock and pci_slot_mutex Message-ID: References: <20261126-fix_deadlock_1126-v2-1-c0ed50bc7b04@oss.qualcomm.com> 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: X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA0MSBTYWx0ZWRfX9fNwUsUJV08S 1wYpblssLQ3p+npqY+mOSsV6K+srv7a1h1CrE6XMt5T+isxvI1H+2WKAQBReeO8aF5yYeMTbTo5 5rqMECF7ksngYF7N19+WCvEmNgaVUWg= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA0MSBTYWx0ZWRfXw6Es+1D+S0p9 AwzHgrijSsY+1Nh1Fkb9ZhqgaWilMe8X+5WtOVMgArvBGoZg5iZQx8heTbJfu0U8WNsFiwxVt+X v+C14lCHZKyjvQYcxynDmbN+NA/NI1dPkgG0RY0wJxOsKXXPl4X9DwN4opoFcsKP9y9qORVk610 iOh4+pSx34yVjfZF2NXvGa+xvHGbMvNndkElzeaecaFMY92O7LcFfyt7uiiNLmdva3W8WxmZE7O SHJ++EaNzworTxK7kJT+ddDcrhfZGnIFumKqg4mMEKf+tQL0ydTvUZ3wXxgv+yJ5ExC130RCwfF Yg0nzPq4V6u6lvEqbqrmMBmMZrZD0padp2u83A1hmRkO28gaLMOJUpCpbXE9xundMA5if/2tY1R WX30ExtfV8J0uvgkNkOJP96yXC63c7pXVVyD+cWXp7J9aJoHGJxaUVAv+8V9tfkq3RdC5HqpLNd EP/TofOppRFZPRnhXwA== X-Authority-Analysis: v=2.4 cv=fc44WEQF c=1 sm=1 tr=0 ts=6b0ea17f cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=kj9zAlcOel0A:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=LjTsM69vYG4bKIzwk6QA:9 a=CjuIK1q_8ugA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-ORIG-GUID: auGutSUnKMWplwdKqaRSg6sFO4TJiMtF X-Proofpoint-GUID: auGutSUnKMWplwdKqaRSg6sFO4TJiMtF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_02,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010041 On Sun, Nov 29, 2026 at 10:06:33PM +0100, Lukas Wunner wrote: > On Thu, Nov 26, 2026 at 12:26:45AM -0800, Qiang Yu wrote: > > Commit 5b3f7b7d062b ("PCI: pciehp: Avoid slot access during reset") > > introduced ctrl->reset_lock to serialize a Secondary Bus Reset (SBR) > > with the pciehp code paths that read the Link Active and Presence > > Detect bits, both of which flap during an SBR. > > > > pciehp_ist() holds reset_lock across the whole event handling, > > including enumerating or de-enumerating the hotplugged devices. That > > nests two PCI core locks inside reset_lock, each taken in the opposite > > order by a concurrent SBR, causing two AB-BA deadlocks. > > It looks like you're trying to fix two separate deadlocks in a single > patch. Can this be split in two patches? > Both deadlocks are fixed by the same hunk: in pciehp_configure_device() and pciehp_unconfigure_device(), the up_read() / down_read_nested() pair is moved so that it wraps the whole pci_lock_rescan_remove() section. reset_lock then no longer nests pci_rescan_remove_lock or pci_slot_mutex, which breaks both AB-BA chains at once. What that hunk gives up is the serialization between a bridge reset and bus scanning, which reset_lock used to provide. The pci.c changes add it back via pci_rescan_remove_lock, so they belong with the same hunk -- hence one patch. > > A Root Port reset from link-down recovery takes them the other way > > round, pci_rescan_remove_lock -> reset_lock (the boot path, via > > pci_host_probe(), takes the same reverse order): > > > > qcom_pcie_global_irq_thread() > > pci_host_handle_link_down() > > pci_host_reset_root_port() > > pci_lock_rescan_remove() # pci_rescan_remove_lock > > pci_bus_error_reset() > > pci_reset_bridge() > > pci_slot_reset() > > pci_reset_hotplug_slot() > > pciehp_reset_slot() # down_write(reset_lock) > > Why is it necessary to lock rescan/remove for a reset? > This looks wrong. I suggest removing pci_lock_rescan_remove() > from pci_host_reset_root_port(). > It's needed because on qcom the reset goes through host->reset_root_port() -> qcom_pcie_reset_root_port() which powers down the PHY, disables clocks and regulators before re-training. So a concurrent bus scan would access config space and lead to NOC error in that window. - Qiang Yu