Message ID | 20231114135553.32301-4-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1874347vqg; Tue, 14 Nov 2023 05:57:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtz2AaeuFuLVNuawqf1MfCTwvIpgAIQ70kIi4N/FTe2rzocSz1LYhlEgPTi2cmU+tf6Sj1 X-Received: by 2002:a05:6808:2120:b0:3a8:7c67:7f5 with SMTP id r32-20020a056808212000b003a87c6707f5mr14294934oiw.1.1699970256471; Tue, 14 Nov 2023 05:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699970256; cv=none; d=google.com; s=arc-20160816; b=KgXaWMGqCRMW2BrFEG+j09npWHuULNCI/aPtX3QuzGjLVd2SslzOdXgcNnJ3oczDAZ 4dV9FYT031vboheGkLMXxFnKARydH7E0wmQCDQyxEpuFrvURacXZHEijPLdypnqYJ7jg DT8JrtNOq1MZD6uyRCpy3HifhfvC7cdno3HwHdMgMx2y3l/Bpv80J5qyAbbbk26HKET4 VpqNHR11/Lbmxy5FP6z2E9bnszZ8wON+QGnG6gTm85IGo3nex1nIenEifuDZ9oCKKXcz ZkFTB0P/ehp3PObNyx0qy0vn4N9FQR7C1VtXZMcqWhhC1FAhQde8bRFIlGV4GST5UI+9 p+hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HWPCc8wsM0OlpiCnTYvTZXmO5g6aIq5USRSb071hcYA=; fh=rFAz3d4A+o3qmWVmTnNUOYHTdtiy9pBa5VpsIqranwE=; b=pcVRStGQtS5Ek0av9axmnHklyi/UOUBBCCAzFHwAxfrDI+fHkKnxC5DN5pYsVaLdVc kIS95r301R+PdTOUPbDqscyBM+OcDzjNJ+kGgzQStxOnkfmNhSYI3r73iGPS88TpBhA1 TZMRHNTlmqiKFZj8tebxNwTUOiSw42LdeXoW8FyhFKXNXueCpDpjQIxkPaPILILJqA8L lgzlSLsCuO+AEDeyUz0XEPxT0knyD86aVXbDKWbOAYY3+j+oXxOkVGkNd6B60Nb4ASup AQfpTpC/5mY9J2auAyTGSZlam1+JHJIXjlyaV638jdtSry/+sKcMNl90cevmaIBhHHOz x49g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BBHOHfNc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q8-20020a6557c8000000b005bdd76219edsi7577498pgr.675.2023.11.14.05.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:57:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BBHOHfNc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 941FB80C9C9F; Tue, 14 Nov 2023 05:57:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233325AbjKNN4z (ORCPT <rfc822;lhua1029@gmail.com> + 29 others); Tue, 14 Nov 2023 08:56:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232168AbjKNN4k (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Nov 2023 08:56:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C022D55; Tue, 14 Nov 2023 05:56:35 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA8C7C43397; Tue, 14 Nov 2023 13:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699970193; bh=FBrVwkCNQ13rjcfw1rE/Ykhh7nhHv9rEy/bYSmsBegQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBHOHfNckzRz7mnu26EM4ZGNdr34Tk+SyDvwuccRYDg3/vBsf5XfdAI532RpNgedV N2JcKrllILDtvNuhJ1nbPIeWY5nSHp8yMzs02lrEnGHsngcHmdgVmFYB5nTN+iedLp dvT6K9UjGj7xIwUy0BOu+U75X49pqAxeZkUf7ZxLMW3AZ48e94dDU7baWsnE/IUxOa iaaixLJK/z0HBKHZwYXQuw/48ot5+xto239+Sedo42JooeUiqBl1f8et7L58/eNSHe YuICzi3eeb6/fxPrdVYw8HwDXX7YFZzoBaJw4GEid+wCUMf1pJd2tiDkUHS0LBHoQ/ u85joJ6WXsyug== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from <johan+linaro@kernel.org>) id 1r2tu2-0008PT-2c; Tue, 14 Nov 2023 14:56:30 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Lorenzo Pieralisi <lpieralisi@kernel.org>, =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= <kw@linux.com>, Bjorn Helgaas <bhelgaas@google.com> Cc: Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Manivannan Sadhasivam <mani@kernel.org>, Rob Herring <robh@kernel.org>, Nirmal Patel <nirmal.patel@linux.intel.com>, Jonathan Derrick <jonathan.derrick@linux.dev>, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Subject: [PATCH 3/6] PCI: qcom: Fix deadlock when enabling ASPM Date: Tue, 14 Nov 2023 14:55:50 +0100 Message-ID: <20231114135553.32301-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231114135553.32301-1-johan+linaro@kernel.org> References: <20231114135553.32301-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 14 Nov 2023 05:57:04 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782548011822343310 X-GMAIL-MSGID: 1782548011822343310 |
Series |
PCI: Fix deadlocks when enabling ASPM
|
|
Commit Message
Johan Hovold
Nov. 14, 2023, 1:55 p.m. UTC
The qcom_pcie_enable_aspm() helper is called from pci_walk_bus() during
host init to enable ASPM.
Since pci_walk_bus() already holds a pci_bus_sem read lock, use the new
locked helper to enable link states in order to avoid a potential
deadlock (e.g. in case someone takes a write lock before reacquiring
the read lock).
This issue was reported by lockdep:
============================================
WARNING: possible recursive locking detected
6.7.0-rc1 #4 Not tainted
--------------------------------------------
kworker/u16:6/147 is trying to acquire lock:
ffffbf3ff9d2cfa0 (pci_bus_sem){++++}-{3:3}, at: pci_enable_link_state+0x74/0x1e8
but task is already holding lock:
ffffbf3ff9d2cfa0 (pci_bus_sem){++++}-{3:3}, at: pci_walk_bus+0x34/0xbc
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(pci_bus_sem);
lock(pci_bus_sem);
*** DEADLOCK ***
Fixes: 9f4f3dfad8cf ("PCI: qcom: Enable ASPM for platforms supporting 1.9.0 ops")
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/pci/controller/dwc/pcie-qcom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Nov 14, 2023 at 02:55:50PM +0100, Johan Hovold wrote: > The qcom_pcie_enable_aspm() helper is called from pci_walk_bus() during > host init to enable ASPM. > > Since pci_walk_bus() already holds a pci_bus_sem read lock, use the new > locked helper to enable link states in order to avoid a potential > deadlock (e.g. in case someone takes a write lock before reacquiring > the read lock). > > This issue was reported by lockdep: > > ============================================ > WARNING: possible recursive locking detected > 6.7.0-rc1 #4 Not tainted > -------------------------------------------- > kworker/u16:6/147 is trying to acquire lock: > ffffbf3ff9d2cfa0 (pci_bus_sem){++++}-{3:3}, at: pci_enable_link_state+0x74/0x1e8 > > but task is already holding lock: > ffffbf3ff9d2cfa0 (pci_bus_sem){++++}-{3:3}, at: pci_walk_bus+0x34/0xbc > > other info that might help us debug this: > Possible unsafe locking scenario: > > CPU0 > ---- > lock(pci_bus_sem); > lock(pci_bus_sem); > > *** DEADLOCK *** > > Fixes: 9f4f3dfad8cf ("PCI: qcom: Enable ASPM for platforms supporting 1.9.0 ops") > Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> - Mani > --- > drivers/pci/controller/dwc/pcie-qcom.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c > index ce3ece28fed2..21523115f6a4 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom.c > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > @@ -971,7 +971,7 @@ static int qcom_pcie_enable_aspm(struct pci_dev *pdev, void *userdata) > { > /* Downstream devices need to be in D0 state before enabling PCI PM substates */ > pci_set_power_state(pdev, PCI_D0); > - pci_enable_link_state(pdev, PCIE_LINK_STATE_ALL); > + pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); > > return 0; > } > -- > 2.41.0 >
diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index ce3ece28fed2..21523115f6a4 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -971,7 +971,7 @@ static int qcom_pcie_enable_aspm(struct pci_dev *pdev, void *userdata) { /* Downstream devices need to be in D0 state before enabling PCI PM substates */ pci_set_power_state(pdev, PCI_D0); - pci_enable_link_state(pdev, PCIE_LINK_STATE_ALL); + pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); return 0; }