Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3633569rdb; Wed, 27 Dec 2023 14:18:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFb4torpQJAmKNkRt9+Bv2BmvW2ND66pOdbr4IKgYf3mqRhaKKth3u+ZwxYS4o7MZ/J/gFx X-Received: by 2002:ac2:5f7a:0:b0:50e:74e9:150c with SMTP id c26-20020ac25f7a000000b0050e74e9150cmr2421526lfc.43.1703715482124; Wed, 27 Dec 2023 14:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703715482; cv=none; d=google.com; s=arc-20160816; b=To/KKaw4uX2Qxa3yI6N6vbLa6bcOoeC7ujMEoTWy3HAKQHNRU17DrKVGUGy2PWJwyu PBDT3G0X2ihRK/4zL2rEQx4Wp+jIkFa4EFcDGafZdnQXqt/93aKus+4CNYK4XPg8rQkS 04M21wee8gUPzsruh759CRHbUIMynzrwcdatLFOBXOIAitFfZB9khsOjdUHS+D2+Ij91 o2pogzHUfr6bhX31a6Op5zGgmtpTE4iLH1LBu/blt1Az/2H3Fw5N+XSWF/ZOcQqsm95V MkVOWISIuv5qCQ3uWP5g/sG1JB0DNNacpJNijtusMdryUeIHZZbMTtHTpLe4WsZzC0k+ 2e6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=gK+Z+cJ3q8PnVX9vvxAmwYo7P5nCQEAASDVIG/h3FtI=; fh=X8pXoFLFvGWmbv/Fk/vRV5jDDmu9esBAehfVQgQVvEM=; b=qUT6wmHd/JE3a7Eq1KNWHrpXWDO2cO1uKOYlnI3m1rF+2X7Sjm2HVxa5glB27Edw0S avTkfq2ZO6UwhM4KloWPsJejT23vyOqGA+UNWHxZH6+6WHsC5olRkLivRX4sxEiYLLzO htlXN1y4dCqIvsE4SW9KBapH+eFi5QTcfbss6KqTtYGMo+61gGzDRcCgOK1oa54Tz6YF lXGnuIg5LRNZi86xuWk14ADbphmQ1ZtvZ5/G9AQrD89lbrB8nBzsxSB6BkhNoiJ6d499 ztdO1P3ayrmkfdwNw3DlghJBgia6oD5GJpXgnyqxoGc6/lcA4uGCpDU24njIJleoa6QM VDGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A5335x0G; spf=pass (google.com: domain of linux-kernel+bounces-12286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dv1-20020a170906b80100b00a1ceee6bf75si6170698ejb.475.2023.12.27.14.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 14:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A5335x0G; spf=pass (google.com: domain of linux-kernel+bounces-12286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D87D01F23133 for ; Wed, 27 Dec 2023 22:18:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82BEE481DB; Wed, 27 Dec 2023 22:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="A5335x0G" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45261481C0 for ; Wed, 27 Dec 2023 22:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-554dbe1857dso2964047a12.3 for ; Wed, 27 Dec 2023 14:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703715456; x=1704320256; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gK+Z+cJ3q8PnVX9vvxAmwYo7P5nCQEAASDVIG/h3FtI=; b=A5335x0GpX/qFf1RFyxvzOR+PyrltkD6t2s15lZXqFnYmvTH4o1Ql8LvlFYynTpGbb WbXGkIhS+ooJApPZfKI6TB5MuMQtQ+CZnXgnVFkw8mZW2FU+P3kUS9DhiiGT4oVrVBXF B2lPd8+/CVyHMKAhsXoFtNRgH/M0iMHdB66fJzsyFrUyQ4ngzXwTFawCb+ADasL7EBZR c9m+pq0yJPBkNavajT/8I6JYzXK1dszS6CsN+S8vcylq6zBxmpookvwBfkvqjIeKwZPT TaxwSfQZjyo7tGCTU5rHK1SoezqnJCQs+MpA3/OxS/Uexz9tvjgVAGhCWyp7zP571vuC RkyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703715456; x=1704320256; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gK+Z+cJ3q8PnVX9vvxAmwYo7P5nCQEAASDVIG/h3FtI=; b=PTEXb1S2IgZZx5K0Qz2SMGQxmYGSC9mOcaA0JhfU9WYgRt8BPF6YcBd07e2FhwU0dQ bxzMXXGUFa6eBB/R2WAvst+7DRy2/A3qYAFYQprODHkRzkHSNYjHECbWhTdy+suH5WxE SQXzUqyQ31an5Seqz3R0lABVnGmZtIzGBj/Rb6YReePBKydqFk4rZ/FcrAFQv9upEO9y lS0PBRMphSIC4iW10aCNEQpJJgUd1JZf+xiMizOs6KWa1Sm/yxCEP0FY2stpGfTENs0F jYV/ajflFT/SKGSvQ/KCq889jYosedt4vwJVyECC/QNNp6U2lHiZ3iqL0JZJTtdWnS/0 8UAQ== X-Gm-Message-State: AOJu0YwFtCHbs+6Y8ja9/NsUncwosVl15R7/dZBrqpqMRLLuQJFJTsUC HX9gcJ/6l36yfcyCvWvQGgCJyre3IwyYtA== X-Received: by 2002:a17:907:710e:b0:a27:59fa:51de with SMTP id zr14-20020a170907710e00b00a2759fa51demr376464ejb.0.1703715456417; Wed, 27 Dec 2023 14:17:36 -0800 (PST) Received: from [10.167.154.1] (178235179028.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.28]) by smtp.gmail.com with ESMTPSA id ka12-20020a170907920c00b00a26ac57b951sm6245712ejb.23.2023.12.27.14.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 14:17:36 -0800 (PST) From: Konrad Dybcio Date: Wed, 27 Dec 2023 23:17:19 +0100 Subject: [PATCH 1/4] PCI: qcom: Reshuffle reset logic in 2_7_0 .init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231227-topic-8280_pcie-v1-1-095491baf9e4@linaro.org> References: <20231227-topic-8280_pcie-v1-0-095491baf9e4@linaro.org> In-Reply-To: <20231227-topic-8280_pcie-v1-0-095491baf9e4@linaro.org> To: Manivannan Sadhasivam , Bjorn Andersson , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Philipp Zabel , Stanimir Varbanov , Andrew Murray , Vinod Koul Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703715452; l=2311; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=Y85jS3ioUk1DQv8qH2gvXdl3T2x3NSOAYdPJTx3pyQM=; b=hoXqb4uT3vpTCXfQv6VngPZNtLPyrOIl3j8S1277XzoP0A9AZ2jiqAbd2P3bhkGsgoYh1p5+k 5ue8mA0U803CdHHnSBa93k4XkY3BdR9CeA7LBCBucFfkLjuLg/uUtYK X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= At least on SC8280XP, if the PCIe reset is asserted, the corresponding AUX_CLK will be stuck at 'off'. Assert the reset (which may end up being a NOP if it was previously asserted) and de-assert it back *before* turning on the clocks to avoid such cases. In addition to that, in case the clock bulk enable fails, assert the RC reset back, as the hardware is in an unknown state at best. Fixes: ed8cc3b1fc84 ("PCI: qcom: Add support for SDM845 PCIe controller") Signed-off-by: Konrad Dybcio --- drivers/pci/controller/dwc/pcie-qcom.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 11c80555d975..1c5ab8c4ff39 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -900,27 +900,27 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie) return ret; } - ret = clk_bulk_prepare_enable(res->num_clks, res->clks); - if (ret < 0) - goto err_disable_regulators; - + /* Assert the reset to hold the RC in a known state */ ret = reset_control_assert(res->rst); if (ret) { dev_err(dev, "reset assert failed (%d)\n", ret); - goto err_disable_clocks; + goto err_disable_regulators; } - usleep_range(1000, 1500); + /* GCC_PCIE_n_AUX_CLK won't come up if the reset is asserted */ ret = reset_control_deassert(res->rst); if (ret) { dev_err(dev, "reset deassert failed (%d)\n", ret); - goto err_disable_clocks; + goto err_disable_regulators; } - /* Wait for reset to complete, required on SM8450 */ usleep_range(1000, 1500); + ret = clk_bulk_prepare_enable(res->num_clks, res->clks); + if (ret < 0) + goto err_assert_reset; + /* configure PCIe to RC mode */ writel(DEVICE_TYPE_RC, pcie->parf + PARF_DEVICE_TYPE); @@ -951,8 +951,9 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie) writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2); return 0; -err_disable_clocks: - clk_bulk_disable_unprepare(res->num_clks, res->clks); + +err_assert_reset: + reset_control_assert(res->rst); err_disable_regulators: regulator_bulk_disable(ARRAY_SIZE(res->supplies), res->supplies); -- 2.43.0