Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3089747rwb; Mon, 15 Aug 2022 17:52:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7cfudIF4LZrje1wmsZCmn3DDWPa3ayBYcic5e+vMKNvcQh2X3pqVtHjihga8LwiviKp0/I X-Received: by 2002:a17:906:5a49:b0:730:aced:aa0e with SMTP id my9-20020a1709065a4900b00730acedaa0emr11973761ejc.31.1660611164184; Mon, 15 Aug 2022 17:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611164; cv=none; d=google.com; s=arc-20160816; b=igCCJhst2LF3ozjRspA9Vs41aGdXyFJCd20zGkoCk8RrXgxUfoUwPgyr73zuNfZPhJ v4inGSYPWu4ECEIdMGf8PZLHYgdScydedyelYvdURCn0m5hqj4Sbo4HBZPooshm86b8I LY55eM7BfOdH3kntwaCS0nDA3BQmsIquNr+tqQJnRNj8Syp4G+wo8QtVYpBN4AyG4bww 2wA3C2fRPMTHiu7E7RSSR6DPwd5TFlks+PVSpg3RIwX9SylywcxOB1IVUH07qRfbNdMQ rkCk7fKQWBMLdsl3tGxrWI4AqV8pnDR26yyyBZfDehELdxGHbVyvN5FbxKaCZNmS5rF9 ZN4w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wgKj0swpciTtH0w/Uug17PvpA+5gPg/X1YcaXPNnmz0=; b=gLHqjX8zY1YrdNS25oJozl998eayLyGSjtIGY7Np4StKMAnWJCpre9l1QXBF6fCgYv +hTy+TGvDTqf01WQW6R5ZA/sXVwekHyeagLd7XSgsAp6tbflHy5yOlPo9LgB9w6sVb/9 cuDPfbRsRUXcatbGSiJ8gwM919jzIUjTQD5raQWcOEGp/1DG7JDHIfrbIqGqx1YZblcf 7E0q8b6KJiwjjg7mSxxu9pOEObWUDQPU6TuWfBR/w2QQzkQwXeZLehc+f8K7JYPedhxW 6q7lakTsy/OxPmktkuLQJKc1OBeWGMcNc8Dgq4wsXGkGOxiGKVOLt/llIEjdiQJ4QVqN O22Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kp6fmE21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp25-20020a1709073e1900b0073309f33443si9476256ejc.636.2022.08.15.17.52.18; Mon, 15 Aug 2022 17:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kp6fmE21; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345328AbiHOWG7 (ORCPT + 99 others); Mon, 15 Aug 2022 18:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350444AbiHOWCJ (ORCPT ); Mon, 15 Aug 2022 18:02:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 235841141A8; Mon, 15 Aug 2022 12:36:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9E1DEB81158; Mon, 15 Aug 2022 19:36:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC836C43162; Mon, 15 Aug 2022 19:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592209; bh=OSDp1ieq5oS1vHDrtwMBgB5abeqEJgh30yGEort4BEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kp6fmE21+igSdLrf9Wpd1Q1RwfLg/XJo65YIamnbbVOQrUPOFLzmXowB3oYpa5OP+ 8uXJ4QKQwaTKlg7lcxlud1WIKMLGqTM2FEMIJCIeOMbPF+lksm82gMgIBX2iFEicP4 hvee4jdzBPWN8jrIjdBjToh2iOnXwJP/WwJEpex8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Marangi , Bjorn Helgaas , Sasha Levin Subject: [PATCH 5.18 0750/1095] PCI: qcom: Set up rev 2.1.0 PARF_PHY before enabling clocks Date: Mon, 15 Aug 2022 20:02:29 +0200 Message-Id: <20220815180500.387144333@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Christian Marangi [ Upstream commit 38f897ae3d44900f627cad708a15db498ce2ca31 ] We currently enable clocks BEFORE we write to PARF_PHY_CTRL reg to enable clocks and resets. This causes the driver to never set to a ready state with the error 'Phy link never came up'. This is caused by the PHY clock getting enabled before setting the required bits in the PARF regs. A workaround for this was set but with this new discovery we can drop the workaround and use a proper solution to the problem by just enabling the clock only AFTER the PARF_PHY_CTRL bit is set. This correctly sets up the PCIe link and makes it usable even when a bootloader leaves the PCIe link in an undefined state. Fixes: 82a823833f4e ("PCI: qcom: Add Qualcomm PCIe controller driver") Link: https://lore.kernel.org/r/20220708222743.27019-1-ansuelsmth@gmail.com Signed-off-by: Christian Marangi Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- drivers/pci/controller/dwc/pcie-qcom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index ed55421eb9ba..ab04818f6ed9 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -337,8 +337,6 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) reset_control_assert(res->ext_reset); reset_control_assert(res->phy_reset); - writel(1, pcie->parf + PCIE20_PARF_PHY_CTRL); - ret = regulator_bulk_enable(ARRAY_SIZE(res->supplies), res->supplies); if (ret < 0) { dev_err(dev, "cannot enable regulators\n"); @@ -381,15 +379,15 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) goto err_deassert_axi; } - ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); - if (ret) - goto err_clks; - /* enable PCIe clocks and resets */ val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL); val &= ~BIT(0); writel(val, pcie->parf + PCIE20_PARF_PHY_CTRL); + ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks); + if (ret) + goto err_clks; + if (of_device_is_compatible(node, "qcom,pcie-ipq8064") || of_device_is_compatible(node, "qcom,pcie-ipq8064-v2")) { writel(PCS_DEEMPH_TX_DEEMPH_GEN1(24) | -- 2.35.1