Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp414495rdb; Fri, 17 Nov 2023 02:29:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBZtnS820Bsj06cLbTQEE8FaVMpmSYcprfZLZLSsOKBvR+h5gmOczRK0HSSrThkWSx3hmM X-Received: by 2002:a17:902:e88e:b0:1cc:5aef:f2c3 with SMTP id w14-20020a170902e88e00b001cc5aeff2c3mr6640344plg.22.1700216961091; Fri, 17 Nov 2023 02:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700216961; cv=none; d=google.com; s=arc-20160816; b=Ja6DVfaTfqzRl3thDO+iMi9sFMXpMu7E4vKkYQZIzuq61gcGyffJn9EDBWZP1ArAKj KPnLGvSIFlCUbTqabg7d4gmBbfJp2g5j1wdA7eaXFTLcjrAeZjIGLxSvEhdTYEVxxM8s HwguRqisCIuwrB4NJ9MJv9Q5lm9EqArlO9RntHdrnYn8MZmlp3Yzk+KScwzeF4PxYrlf CQ2Qw4wa8GT5J7/FwVXteE7WmQJKvFrgAASvzHrDV8OlU5W4X9iRS/UhGcHuHFMJn5Rt DEOQ4wXpN4kWLrg8rF8sRv4WkLkssHGvh2TKlN0iLvrtSO36P5Uv9lD3j1WBaGxMNKWm nZow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hxg8gNaqwGd/7GQMevBRKFEnBpau/SHoOVp4V/sFB+o=; fh=3limvSBv3PlbtiYgcNU0QKFJa8xX/cVRT0QqTcpvbv4=; b=Y4JhC8MJM5GLh1iK3RoF2bacM8U6hUMNx/s6sUmmcDAP+PZQ4xvAi7IlgR4higDFKx 5WPALdUWYnPo/K1W0XTBaftc6edVG3xRxTOfJgDFtpZsWeRMKYCviR5LpWJQ4LxxldCr bIq5gqgM8LlD7jJQrNeTAy95VHMa74ecqog5xj7tNcstepx7LHrUBUXBfr8tyMj8BZ3+ 4hDpS/zq9lOtdJKfzv+/4RAtmtOo5EKx9OWzU7jMVj17NP0eTbs+FcoMsTZGeMGXTWe8 Qm9JmapH2l+k59Jd46qj2RfSm4rHqCl/vWHQTpHQ69bxal5/eOghovXAi/r2zCPAlNCa KvJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QAzrvEpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m12-20020a170902db0c00b001ce160421b2si1663269plx.408.2023.11.17.02.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 02:29:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QAzrvEpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 AEB25827330D; Fri, 17 Nov 2023 02:29:19 -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 S1345802AbjKQK3M (ORCPT + 99 others); Fri, 17 Nov 2023 05:29:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345827AbjKQK3H (ORCPT ); Fri, 17 Nov 2023 05:29:07 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52F0DD51; Fri, 17 Nov 2023 02:29:04 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C514C433C7; Fri, 17 Nov 2023 10:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700216943; bh=6ojBfPtGsykYO6BkGzyzKQW4IsE0MACKzcENBodryjo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QAzrvEpg87B/5pkgFMFV67PnJ3Yp9jFqRDNJ8Vt5NGj3xC8VZvrGUisrv6B1Ki/Uh pmJaql2Hf/poztSX8w9nDtnn/7GEHWJz1FotKlr7dkS6TvIEsivXJYY2R/mjx0QNSB eKCcNr885umgAF++UKTbNsU6YFi3hCbYM8BtvSwcYxRvD4WEpmvV2XKYngqbdbbJEP YUn4KoM04Z83s5cGJ0nbMnCS7s7zVRlvpoTrOHd6v+OVWNvmxn7tqSccpkzBHOrBcE 03705HR/Lbi0dKt4dpnODqkflREzkjR+lFPfgHflzaix+ykfGOqozjYmMj5JWgkotX aoTThAV2WEO7A== Date: Fri, 17 Nov 2023 15:58:55 +0530 From: Manivannan Sadhasivam To: Johan Hovold Cc: Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Nirmal Patel , Jonathan Derrick , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: Re: [PATCH 3/6] PCI: qcom: Fix deadlock when enabling ASPM Message-ID: <20231117102855.GL250770@thinkpad> References: <20231114135553.32301-1-johan+linaro@kernel.org> <20231114135553.32301-4-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231114135553.32301-4-johan+linaro@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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: 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]); Fri, 17 Nov 2023 02:29:19 -0800 (PST) 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 > Signed-off-by: Johan Hovold Reviewed-by: Manivannan Sadhasivam - 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 > -- மணிவண்ணன் சதாசிவம்