From patchwork Mon Oct 17 11:24:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 3401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1393357wrs; Mon, 17 Oct 2022 04:30:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GeWmD0My+WZLwQjYeJwtxrbfcXCzhxO9U0t9LU/ibckuUexjjIHwzEq6ZzQAaGvsMZMBk X-Received: by 2002:a17:907:a42c:b0:78e:fd1:61b4 with SMTP id sg44-20020a170907a42c00b0078e0fd161b4mr8384793ejc.289.1666006246182; Mon, 17 Oct 2022 04:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666006246; cv=none; d=google.com; s=arc-20160816; b=SwUvTaD+S1tRSAU2wQ12LooiEBmc0M9gbi4lJI2kvXwlJNp3a1+XkhE6N3kxw3qBsY rSoQo04Wgvnx/Gpg7hkRhVLD1VfJ+Aw7CwzekwlnarZVLYZscvt7CqfDjl0aWJl7/HR1 y4vB8aaX7Pp8K/PeVTpBaGUgGxeNicBADrKUUJD0aaZewHooCOcxUIHnVIpkyFXWwrpk Q2y1XPgCGTl8Ws+j4bcuY81S3tIdWvS5UXif6a8Jc2FHnJWjoBSec19yRgSfbrh7qAxg W3gRwGo+2GpTTyfKlhVvGNe1rbEb/FN0+54adrrH+JsTULfamc9LoyEA3QpnVbR1N2GM qPPQ== 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=1azbWtG7D1r3iQceOogbf82tnZobTG5rJE/Wr+BQSOU=; b=RV2IaDk56GoSt1/hSLeoxAhWrquqwbqOLgUVM7nnP99fbtIk9E30SmmKoG5ETf3mDV bLHHcA2AQnEDC2vX5ry1Psl5v62NY1pDYjt0Ik5ETXxt8L0bDFzM2xg1NbRVugmS8yaa pv0D6ILjQprhrVNK9BkLUDTKLO5gJWMWNpOEoSLUa3KdKkaQI6cWeLIhtxYxbRYwpmKZ OHDQ30KO/+e0KwJyAhWvvqVWF6jGqyPIWmGeIfWk4HdVdtxPFAqCPpRiYaqcBtBwrXt8 2WWNOk75sopYntGOH/tq5UUCWD4eiUcDd3aKvmu2Pa6Fwg7YXK4TbhqXoLKsY5K62bxW WtRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AMpi8BqR; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs7-20020a1709072d0700b0078c5f3569aesi11116004ejc.69.2022.10.17.04.30.17; Mon, 17 Oct 2022 04:30:46 -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=@kernel.org header.s=k20201202 header.b=AMpi8BqR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbiJQL1N (ORCPT + 99 others); Mon, 17 Oct 2022 07:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiJQL1J (ORCPT ); Mon, 17 Oct 2022 07:27:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 355885FAEA; Mon, 17 Oct 2022 04:27:09 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BBEC76106F; Mon, 17 Oct 2022 11:27:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12DD1C433B5; Mon, 17 Oct 2022 11:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666006028; bh=PbGvkepS2v+eRVnenWnJzkdlAGCiypF77ExFQpOAOcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AMpi8BqRL/b+mQFsd8bKNfC2/bIA1tcN+0gzUvft555sCCfSbSyBkVUPoWAhQH0Ul 0FJY8/7cAjg0lHzln7z47hQLJWanO+yNyMOSJ2YhlwusHzOMf6q1Bb+2h9R7E9D2TV tdPw5VHXX5yna0vP1smbGoQ1RD1RF4gRjBLunXFVrV8eLyuvgIAOgVaSIKf0WptxvN 7qG+Xb3oruchfsnzSV+soKelI9Lr/WVWeDe4ix8Z4mZAxiFdqHiM6/Sxzw2xVDnYfK Ttwg3cMRXUlG/Hso9WrMCpSPMtR8zJIvp8uXca12rz6scfCbE0Sc7Zry3m81aRlOvh eFLeILUtHKbhQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1okOGn-0000aZ-LY; Mon, 17 Oct 2022 13:26:57 +0200 From: Johan Hovold To: Stanimir Varbanov , Lorenzo Pieralisi Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Bjorn Helgaas , Rob Herring , Krzysztof Kozlowski , =?utf-8?q?Krzyszto?= =?utf-8?q?f_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Krishna chaitanya chundru , quic_vbadigan@quicinc.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/2] dt-bindings: PCI: qcom: Add SC8280XP/SA8540P interconnects Date: Mon, 17 Oct 2022 13:24:48 +0200 Message-Id: <20221017112449.2146-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221017112449.2146-1-johan+linaro@kernel.org> References: <20221017112449.2146-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746934165711196309?= X-GMAIL-MSGID: =?utf-8?q?1746934165711196309?= Add the missing SC8280XP/SA8540P "pcie-mem" and "cpu-pcie" interconnect paths to the bindings. Fixes: 76d777ae045e ("dt-bindings: PCI: qcom: Add SC8280XP to binding") Fixes: 76c4207f4085 ("dt-bindings: PCI: qcom: Add SA8540P to binding") Signed-off-by: Johan Hovold --- .../devicetree/bindings/pci/qcom,pcie.yaml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/qcom,pcie.yaml b/Documentation/devicetree/bindings/pci/qcom,pcie.yaml index 22a2aac4c23f..a55434f95edd 100644 --- a/Documentation/devicetree/bindings/pci/qcom,pcie.yaml +++ b/Documentation/devicetree/bindings/pci/qcom,pcie.yaml @@ -62,6 +62,12 @@ properties: minItems: 3 maxItems: 12 + interconnects: + maxItems: 2 + + interconnect-names: + maxItems: 2 + resets: minItems: 1 maxItems: 12 @@ -629,6 +635,25 @@ allOf: items: - const: pci # PCIe core reset + - if: + properties: + compatible: + contains: + enum: + - qcom,pcie-sa8540p + - qcom,pcie-sc8280xp + then: + properties: + interconnects: + maxItems: 2 + interconnect-names: + items: + - const: pcie-mem + - const: cpu-pcie + required: + - interconnects + - interconnect-names + - if: not: properties: From patchwork Mon Oct 17 11:24:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 3402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1393356wrs; Mon, 17 Oct 2022 04:30:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kauXB2RBxb+iCwVObM7xz9faM69K+1GJiT5aQsRvaCcii7xGsPgn0AayDijoInIZ5d2qv X-Received: by 2002:a05:6402:360d:b0:459:5f40:5b0a with SMTP id el13-20020a056402360d00b004595f405b0amr9419244edb.168.1666006246184; Mon, 17 Oct 2022 04:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666006246; cv=none; d=google.com; s=arc-20160816; b=p4WCJvzPM4qK+CIf2OVqcuPXKNAxEVh1jvTvtcG11O/m3gmPIMjp1zzvP9ONQe+bpM QJ51EmM4PHSJ7rpgj17Lpx0+sxE00yF2y6gA3MziqmHDTT4/A+0JXlVbT2+wN7cSKNgN kG8UBFPA7/UKLmhxw+/oeZXFK4QP6VHRLyW6U/lsHL0o+iaxAom/6Qi2diVG7dD9cYsf okodeacBnIEwFWTZaTVnFRVxqcDYn0ppxB/1PNfX64snZeQyj6t8zQb7GD5wNRWLaX3E JkwVJXr1sNmOXACpTHsYiLxISYkQeiOVruRkahQyYLH23WM2zLtVaWy+UAXMEEc48E/L 3ZtA== 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=e/ckwt7lCmKSlEcUFs5UuAX+jlUjSYTEkdV/7rLFUAQ=; b=Tep5LDfpzss63dNFbIPr3+DnEh2qLrlqEFMJVDe0Jxih6aa8pfHVhYCgH6F7XPa8qc vT8BTIT7U+R2ZKuU+hu8kSisPi6LchfKCXE5siiq5vKzlAX61Dm9IUQ1qyjZZFMeuyC4 48xQjQHmi15wG43rTf+P53h149azPLlr+bYqUUMwpYWEKIgs9cJ0z7aiyWAItKgOPbEd 0uCsjoeVf1h+ReoD11RJM2R751BTffXJ6N3qNCu/tHvFCdQpXgs24hd+9Mi7ZsIO/RGX O2YKyv9NNr8hxymUI24vlExkte9iXHGzn10Fn+J15V7hcl0vRl+5QKIApuoJ0PSwsZ/8 CKjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YRwIMRbL; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht12-20020a170907608c00b0078e2b64197dsi7258792ejc.351.2022.10.17.04.30.17; Mon, 17 Oct 2022 04:30:46 -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=@kernel.org header.s=k20201202 header.b=YRwIMRbL; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbiJQL1P (ORCPT + 99 others); Mon, 17 Oct 2022 07:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbiJQL1M (ORCPT ); Mon, 17 Oct 2022 07:27:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD83F5FAEA; Mon, 17 Oct 2022 04:27:10 -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 9CCFBB815E5; Mon, 17 Oct 2022 11:27:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26AC0C433D7; Mon, 17 Oct 2022 11:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666006028; bh=8oCvQhILcprioKQIETe9Rm5fLfUWYFFa5k6LkfL/rsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRwIMRbLQhImH2rLtvO7ByXy0VxZdQ2IH0/rbKdmMnepbGX9Ln0YtXde0FYxBp5mU UKc/AxlzI6Z4lrpJ/XNmjGC3A/QmxUA0Rmd5afeY9LTiOdsLuh8tQNCMa5e82Fg25I GNCY61i965ukYpeI0CGbQUxoMC2wNKnJiPqRTBe4lqCZIIH5hQQ+ZfOHQWcsIUrq5z r8dzSgawocLM3Ad3eGHGJ/yqLj/JoAILzBpNn3RAfhtCakZb1LqGwC6xxa4x3Wqqz3 x3PVuXzdwPc5FUGD59L8Yx1WuqCW9RIsa37p9A7fbuq+M8DMbsPMYLll/PMz0lz83v 7SqWUaVdHoyJA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1okOGn-0000ab-OR; Mon, 17 Oct 2022 13:26:57 +0200 From: Johan Hovold To: Stanimir Varbanov , Lorenzo Pieralisi Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Bjorn Helgaas , Rob Herring , Krzysztof Kozlowski , =?utf-8?q?Krzyszto?= =?utf-8?q?f_Wilczy=C5=84ski?= , Manivannan Sadhasivam , Krishna chaitanya chundru , quic_vbadigan@quicinc.com, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/2] PCI: qcom: Add basic interconnect support Date: Mon, 17 Oct 2022 13:24:49 +0200 Message-Id: <20221017112449.2146-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221017112449.2146-1-johan+linaro@kernel.org> References: <20221017112449.2146-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746934163090723217?= X-GMAIL-MSGID: =?utf-8?q?1746934165811400077?= On Qualcomm platforms like SC8280XP and SA8540P interconnect bandwidth must be requested before enabling interconnect clocks. Add basic support for managing an optional "pcie-mem" interconnect path by setting a low constraint before enabling clocks and updating it after the link is up. Note that it is not possible for a controller driver to set anything but a maximum peak bandwidth as expected average bandwidth will vary with use case and actual use (and power policy?). This very much remains an unresolved problem with the interconnect framework. Also note that no constraint is set for the SC8280XP/SA8540P "cpu-pcie" path for now as it is not clear what an appropriate constraint would be (and the system does not crash when left unspecified currently). Fixes: 70574511f3fc ("PCI: qcom: Add support for SC8280XP") Signed-off-by: Johan Hovold Reviewed-by: Brian Masney --- drivers/pci/controller/dwc/pcie-qcom.c | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 7db94a22238d..0c13f976626f 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -224,6 +225,7 @@ struct qcom_pcie { union qcom_pcie_resources res; struct phy *phy; struct gpio_desc *reset; + struct icc_path *icc_mem; const struct qcom_pcie_cfg *cfg; }; @@ -1644,6 +1646,74 @@ static const struct dw_pcie_ops dw_pcie_ops = { .start_link = qcom_pcie_start_link, }; +static int qcom_pcie_icc_init(struct qcom_pcie *pcie) +{ + struct dw_pcie *pci = pcie->pci; + int ret; + + pcie->icc_mem = devm_of_icc_get(pci->dev, "pcie-mem"); + if (IS_ERR(pcie->icc_mem)) { + ret = PTR_ERR(pcie->icc_mem); + return ret; + } + + /* + * Some Qualcomm platforms require interconnect bandwidth constraints + * to be set before enabling interconnect clocks. + * + * Set an initial peak bandwidth corresponding to single-lane Gen 1 + * for the pcie-mem path. + */ + ret = icc_set_bw(pcie->icc_mem, 0, MBps_to_icc(250)); + if (ret) { + dev_err(pci->dev, "failed to set interconnect bandwidth: %d\n", + ret); + return ret; + } + + return 0; +} + +static void qcom_pcie_icc_update(struct qcom_pcie *pcie) +{ + struct dw_pcie *pci = pcie->pci; + u32 offset, status, bw; + int speed, width; + int ret; + + if (!pcie->icc_mem) + return; + + offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); + status = readw(pci->dbi_base + offset + PCI_EXP_LNKSTA); + + /* Only update constraints if link is up. */ + if (!(status & PCI_EXP_LNKSTA_DLLLA)) + return; + + speed = FIELD_GET(PCI_EXP_LNKSTA_CLS, status); + width = FIELD_GET(PCI_EXP_LNKSTA_NLW, status); + + switch (speed) { + case 1: + bw = MBps_to_icc(250); + break; + case 2: + bw = MBps_to_icc(500); + break; + default: + case 3: + bw = MBps_to_icc(985); + break; + } + + ret = icc_set_bw(pcie->icc_mem, 0, width * bw); + if (ret) { + dev_err(pci->dev, "failed to set interconnect bandwidth: %d\n", + ret); + } +} + static int qcom_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1704,6 +1774,10 @@ static int qcom_pcie_probe(struct platform_device *pdev) goto err_pm_runtime_put; } + ret = qcom_pcie_icc_init(pcie); + if (ret) + goto err_pm_runtime_put; + ret = pcie->cfg->ops->get_resources(pcie); if (ret) goto err_pm_runtime_put; @@ -1722,6 +1796,8 @@ static int qcom_pcie_probe(struct platform_device *pdev) goto err_phy_exit; } + qcom_pcie_icc_update(pcie); + return 0; err_phy_exit: