From patchwork Tue Oct 18 21:10:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gokul krishna Krishnakumar X-Patchwork-Id: 4323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2167007wrs; Tue, 18 Oct 2022 14:22:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t53n1uFYRYD666NLgng7VM11LRrUraSYS8DMFljGGKFAAmPoMJQpTg2j66612fViVR5rY X-Received: by 2002:a17:907:dac:b0:78e:17a0:d1cb with SMTP id go44-20020a1709070dac00b0078e17a0d1cbmr4114593ejc.618.1666128127005; Tue, 18 Oct 2022 14:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666128127; cv=none; d=google.com; s=arc-20160816; b=wxWhvhykdutLU+kTRWHkcF/14mrGPZPsTdC2eLqQHmeybRWRIknpg6KbGQRcZg2gjx n4AkZ0XSQI7LGJpq9zHi6pZFZZe1oV1E4G0ETiiQpEVV0/iv/n1P5hDsF5rQJwOifiAs COe6Pq/7oNHhKAc/bUfanPqNgwutci1RPp3VFEgNkHhvJi86EfZeuHGCWhmSLXMzBsFS vxe/2cSt6OA9tK1vfOY3lHBSHqsfOhIyBIevahCyF7Hxv2sxccMVGlf6/XbrVy+jI+n2 ExwtVVy+2OrAtLaVM763wHFvoZ/9R35AwFWUanSrYcR3t94fGUamfjQ5Yv6YJTiz+Yov J5mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=ySjEjvEXrKYOOY4ZOLI6Kl+I/1O7wWTHGGDSSI9z5+k=; b=fkyTGD4ZfyQI2s78sbhJiQMV0TOoSiMpN7VJbI45nw60PrxVrmoYP7ReKXYYrwOX3Z S/H40Op+LkOSmLq98rECazLkB2kNXQz/+vC2kfFZ2Q5gMcr85rJFq7+vX2hsWrAX6MSv aXZflrSoltxn6JIIaKrEoovNeGX2cd7vi3WEJcHkHYyOUcLfmHn8ERj/reNy8c2ZJpzx 8OcQ11jv/J24q1pXTuq/A07vg5KIFFh7MruAe7ej2p9w9T4f+uy2xkPEuvwrRRniO+R3 QFyV9mkSVDsjcnV6cKPMDvNCNQmhJTN+QvlB/80pmrnJPF91LizsnkE1XtmtdHC9o1c1 YcSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cWo8RfJ2; 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=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a056402280600b0044f3b9ef98bsi15576289ede.27.2022.10.18.14.21.41; Tue, 18 Oct 2022 14:22:06 -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=@quicinc.com header.s=qcppdkim1 header.b=cWo8RfJ2; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbiJRVLI (ORCPT + 99 others); Tue, 18 Oct 2022 17:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbiJRVLF (ORCPT ); Tue, 18 Oct 2022 17:11:05 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BF317C187; Tue, 18 Oct 2022 14:11:03 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29IF1CoE032457; Tue, 18 Oct 2022 21:10:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=ySjEjvEXrKYOOY4ZOLI6Kl+I/1O7wWTHGGDSSI9z5+k=; b=cWo8RfJ2V5rRSBzQ2bK+LUWxWl0AIE1F6wjqbLajUe84M0guh3cdvsAqNcVFBfWtipRE nheYdEQaiyP8SY7p2Y+MLOymcniFs95su08d38iUeyB4GcTJqfs6bF9wxhmsI26YmxT4 ySKnSqU81jUpF1nbNhOFp27Drxmi89jQfoOhQ4PW0TPad3nvm0Jfy5ojW5ece096GeOO JFi2FHCl76ISsvEvVZ2M2VGzJFjLVTLpNmmZxgT6Fsu9qweoxyFWoEo2a2V3nhZrOn0h tymIZB8r8L2AnLD7C3N4rrEK6+qYrr5fsQbbnlEbeNe7my7Barn2V+EiEcmvDQNduf5L YA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3k9bjvc846-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Oct 2022 21:10:57 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 29ILAuG9014352 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 Oct 2022 21:10:56 GMT Received: from hu-gokukris-sd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 18 Oct 2022 14:10:55 -0700 From: Gokul krishna Krishnakumar To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Mathieu Poirier CC: , , , Trilok Soni , "Satya Durga Srinivasu Prabhala" , Rajendra Nayak , Elliot Berman , "Guru Das Srinagesh" , Gokul krishna Krishnakumar Subject: [PATCH v1 1/1] drivers: remoteproc: Add bus scaling capability during bootup Date: Tue, 18 Oct 2022 14:10:46 -0700 Message-ID: <35eb4ce2bb8f3bb78a616c071a012f1f49d8b593.1666127246.git.quic_gokukris@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: eubTSObGh5LMd3P9HH9yQRNk2PXIjBP4 X-Proofpoint-ORIG-GUID: eubTSObGh5LMd3P9HH9yQRNk2PXIjBP4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-18_07,2022-10-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210180119 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1747061967022003261?= X-GMAIL-MSGID: =?utf-8?q?1747061967022003261?= During bootup since remote processors cannot request for additional bus bandwidth from the interconect framework, platform driver should provide the proxy resources. Make a proxy vote for maximizing the bus bandwidth during bootup for a remote processor and remove it once processor is up. Change-Id: I798b3b000aef4761a7ff8cb6390b7ecd98f925b7 Signed-off-by: Gokul krishna Krishnakumar --- drivers/remoteproc/qcom_q6v5_pas.c | 106 ++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index 6afd094..b02a1dc 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,8 +31,14 @@ #include "qcom_q6v5.h" #include "remoteproc_internal.h" +#define PIL_TZ_AVG_BW UINT_MAX +#define PIL_TZ_PEAK_BW UINT_MAX #define ADSP_DECRYPT_SHUTDOWN_DELAY_MS 100 +static struct icc_path *scm_perf_client; +static int scm_pas_bw_count; +static DEFINE_MUTEX(scm_pas_bw_mutex); + struct adsp_data { int crash_reason_smem; const char *firmware_name; @@ -67,6 +74,7 @@ struct qcom_adsp { int pas_id; unsigned int minidump_id; + struct icc_path *bus_client; int crash_reason_smem; bool has_aggre2_clk; bool decrypt_shutdown; @@ -136,6 +144,44 @@ static void adsp_pds_disable(struct qcom_adsp *adsp, struct device **pds, } } +static int scm_pas_enable_bw(void) +{ + int ret = 0; + + if (IS_ERR(scm_perf_client)) + return -EINVAL; + + mutex_lock(&scm_pas_bw_mutex); + if (!scm_pas_bw_count) { + ret = icc_set_bw(scm_perf_client, PIL_TZ_AVG_BW, + PIL_TZ_PEAK_BW); + if (ret) + goto err_bus; + } + + scm_pas_bw_count++; + mutex_unlock(&scm_pas_bw_mutex); + return ret; + +err_bus: + pr_err("scm-pas: Bandwidth request failed (%d)\n", ret); + icc_set_bw(scm_perf_client, 0, 0); + + mutex_unlock(&scm_pas_bw_mutex); + return ret; +} + +static void scm_pas_disable_bw(void) +{ + if (IS_ERR(scm_perf_client)) + return; + + mutex_lock(&scm_pas_bw_mutex); + if (scm_pas_bw_count-- == 1) + icc_set_bw(scm_perf_client, 0, 0); + mutex_unlock(&scm_pas_bw_mutex); +} + static int adsp_shutdown_poll_decrypt(struct qcom_adsp *adsp) { unsigned int retry_num = 50; @@ -174,15 +220,35 @@ static int adsp_load(struct rproc *rproc, const struct firmware *fw) if (ret) return ret; + scm_pas_enable_bw(); ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, adsp->pas_id, adsp->mem_region, adsp->mem_phys, adsp->mem_size, &adsp->mem_reloc); if (ret) - return ret; + goto exit; qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size); +exit: + scm_pas_disable_bw(); + return ret; +} - return 0; +static int do_bus_scaling(struct qcom_adsp *adsp, bool enable) +{ + int rc = 0; + u32 avg_bw = enable ? PIL_TZ_AVG_BW : 0; + u32 peak_bw = enable ? PIL_TZ_PEAK_BW : 0; + + if (IS_ERR(adsp->bus_client)) + dev_err(adsp->dev, "Bus scaling not setup for %s\n", + adsp->rproc->name); + else + rc = icc_set_bw(adsp->bus_client, avg_bw, peak_bw); + + if (rc) + dev_err(adsp->dev, "bandwidth request failed(rc:%d)\n", rc); + + return rc; } static int adsp_start(struct rproc *rproc) @@ -194,10 +260,14 @@ static int adsp_start(struct rproc *rproc) if (ret) return ret; - ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); + ret = do_bus_scaling(adsp, true); if (ret < 0) goto disable_irqs; + ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); + if (ret < 0) + goto unscale_bus; + ret = clk_prepare_enable(adsp->xo); if (ret) goto disable_proxy_pds; @@ -218,6 +288,8 @@ static int adsp_start(struct rproc *rproc) goto disable_cx_supply; } + scm_pas_enable_bw(); + ret = qcom_scm_pas_auth_and_reset(adsp->pas_id); if (ret) { dev_err(adsp->dev, @@ -234,9 +306,10 @@ static int adsp_start(struct rproc *rproc) qcom_scm_pas_metadata_release(&adsp->pas_metadata); - return 0; - disable_px_supply: + scm_pas_disable_bw(); + if(!ret) + goto exit; if (adsp->px_supply) regulator_disable(adsp->px_supply); disable_cx_supply: @@ -248,9 +321,11 @@ static int adsp_start(struct rproc *rproc) clk_disable_unprepare(adsp->xo); disable_proxy_pds: adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); +unscale_bus: + do_bus_scaling(adsp, false); disable_irqs: qcom_q6v5_unprepare(&adsp->q6v5); - +exit: return ret; } @@ -265,6 +340,7 @@ static void qcom_pas_handover(struct qcom_q6v5 *q6v5) clk_disable_unprepare(adsp->aggre2_clk); clk_disable_unprepare(adsp->xo); adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); + do_bus_scaling(adsp, false); } static int adsp_stop(struct rproc *rproc) @@ -383,6 +459,22 @@ static int adsp_init_regulator(struct qcom_adsp *adsp) return 0; } +static void adsp_init_bus_scaling(struct qcom_adsp *adsp) +{ + if (scm_perf_client) + goto get_rproc_client; + + scm_perf_client = of_icc_get(adsp->dev, "crypto_ddr"); + if (IS_ERR(scm_perf_client)) + dev_warn(adsp->dev, "Crypto scaling not setup\n"); + +get_rproc_client: + adsp->bus_client = of_icc_get(adsp->dev, "rproc_ddr"); + if (IS_ERR(adsp->bus_client)) + dev_warn(adsp->dev, "%s: No bus client\n", __func__); + +} + static int adsp_pds_attach(struct device *dev, struct device **devs, char **pd_names) { @@ -525,6 +617,8 @@ static int adsp_probe(struct platform_device *pdev) if (ret) goto free_rproc; + adsp_init_bus_scaling(adsp); + ret = adsp_pds_attach(&pdev->dev, adsp->proxy_pds, desc->proxy_pd_names); if (ret < 0)