From patchwork Tue May 30 10:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 100739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2078923vqr; Tue, 30 May 2023 03:33:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4g2DJ3oFVASSiSalXfYPQ0cQuofeH49e6mV8INAJLV63VxT6pAjLcrtRnGmggAczFUv+s/ X-Received: by 2002:a05:6a00:aca:b0:64b:43d8:a57d with SMTP id c10-20020a056a000aca00b0064b43d8a57dmr2051252pfl.13.1685442812877; Tue, 30 May 2023 03:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685442812; cv=none; d=google.com; s=arc-20160816; b=gemvc8st1bw+fckqu+N049/IzFH4gNNk+V0s9qd8X3Eqg73hDAOMhCYBYtJTnYmDND lFU1gExXxs+uAjuHIKUSzFazUnJaaeEvpuj8xD0OoxpITmZD59t8NOT+N0CgpOs9I9Ow Jc7QFYM38d+ppAjoWBTVOV1bEcWt0uI3FSkgVDvNzeQoF2bU6CIz+TL6/mUe0mjoyGKN PcSdivrjjdcD9/Q2IVfjjdutIvAKLcUZZb7BUNt9px/BomXUkMEhGs/4WBEg1f4Fyelk bpCmsobDt9Rbh3iVLqDuBEiXWBFzQhIW6ee6qJ5iPYWn2GtLlBMWtfcDTtaMf9BZl9Mn R1UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=1aF5NzyLnKl7zoihaKOQABOmTLo7g2FiY8plhOqJWWE=; b=aZbRcj8Ha1ekn7+p7g2y9gtAjrqBc9/agvOj76UgKGv9gFDXaZfEWRuGkz47Dax7NC c7BdLG8URlI6b1YjouRyWrBtaKCy0hK8XAOzq+WNphQmVf1mmJEP5i3dihWIuoldZDY2 glzUvy1+liFMtanGmGEepRErSN4hQlVNJIVLGqWMNupuI1Vn0viip9moi64SM9Sg4gCD j5zsA18KVBTBPWxRATcczntafiZj4Ey6TsfczuPQrFFjWmDb7SPj2ls5suMRwvOcxCaA cVTG6rN1nZYtJhFBfxdvYFOKNYYwoXKYKnxLD/kPnJmxcEur4GLA6JSGUpdMNi90gRtQ JHHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KL18hG5Z; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z26-20020aa7959a000000b0064f30e53fcdsi1544424pfj.100.2023.05.30.03.33.20; Tue, 30 May 2023 03:33:32 -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=@linaro.org header.s=google header.b=KL18hG5Z; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbjE3KUd (ORCPT + 99 others); Tue, 30 May 2023 06:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbjE3KUU (ORCPT ); Tue, 30 May 2023 06:20:20 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A2490 for ; Tue, 30 May 2023 03:20:12 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f4b384c09fso4875185e87.3 for ; Tue, 30 May 2023 03:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685442010; x=1688034010; 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=1aF5NzyLnKl7zoihaKOQABOmTLo7g2FiY8plhOqJWWE=; b=KL18hG5ZcSfHdXMU8nINo0ozNDShQjM5vzvdQuBSHtY8YnyCUBmK0JZYp92oSvzksz PJQqas3ZWqa4uYoee36tPlrt6K10lXQHtVKYF2cW3gyGaV6CugK3HNjqBlEcjSbgyvhN BYPG0i2uXOVmHQYzYj2RmSu1sonzGpZobIdCyRq+Jwd8GauYG6o2hoq0OYgs8uyr9hl9 U7VB8/H3ET0xjVi+EcWBz/ldjf7CGA/Su/bH6nPnABwYhBT9ZymCpfSm/xqOZnuKqmHU DASloBUVF60q3Tw0cOG29oGQt9JmVyRg1kl/hmZpMueKIBgjlFNf0UYTO1VtgUIZKcca apjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685442010; x=1688034010; 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=1aF5NzyLnKl7zoihaKOQABOmTLo7g2FiY8plhOqJWWE=; b=MlfaStnmn2EG1jHpH/29IUjfEK31fFQpuhkBdjjj2Kk5l1BoAxhabRPhfBJlu8YF7j tFzIbpCYfbBFzc4io16/WGjYlyuzGJdJDxwajBp5OsIZYblS0jeuj+4gPZWSsQfFte3k HVf16BgbrsF2VTukG0jjhq47nEo2K80C8Gp943vUFnx4zqYof8b9P9vyzFxZesJaiANa jD9vxWISzoMw2Ry3adPqUf71FG1upXnoJkhKCNQ3XHZ1fyRufD0hSiATpsYWp6vL6dAC UG/JXimzxZAxzrPdTYG3ykE5HCoO1oKSuW8pBPctAFyuCvj2ciR//nw0KPx19vA3HRNP axXg== X-Gm-Message-State: AC+VfDwH3J55H5X7ru5nqm30owG7jKWj6rMDmmUnsrtVO13jVqnifwY9 en/GasiDcFZG0Bxxwm54NAkk9g== X-Received: by 2002:a05:6512:243:b0:4f3:a485:919a with SMTP id b3-20020a056512024300b004f3a485919amr532930lfo.57.1685442010378; Tue, 30 May 2023 03:20:10 -0700 (PDT) Received: from [192.168.1.101] (abyj77.neoplus.adsl.tpnet.pl. [83.9.29.77]) by smtp.gmail.com with ESMTPSA id c25-20020ac24159000000b004cc8196a308sm290902lfi.98.2023.05.30.03.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 03:20:10 -0700 (PDT) From: Konrad Dybcio Date: Tue, 30 May 2023 12:20:04 +0200 Subject: [PATCH 05/20] interconnect: qcom: icc-rpm: Introduce keep_alive MIME-Version: 1.0 Message-Id: <20230526-topic-smd_icc-v1-5-1bf8e6663c4e@linaro.org> References: <20230526-topic-smd_icc-v1-0-1bf8e6663c4e@linaro.org> In-Reply-To: <20230526-topic-smd_icc-v1-0-1bf8e6663c4e@linaro.org> To: Andy Gross , Bjorn Andersson , Michael Turquette , Stephen Boyd , Georgi Djakov , Leo Yan , Evan Green Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1685442001; l=3600; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=k3FKq4hsanyAIvzotN0m6bauADNeL2Fo1rigqnJlDac=; b=hvFTnD/dH0Sj2ysZovpz3wr8bDb7GQWdzjJvH/HBaWZIqENeiuglNUMKjH8ib2RYdbqm3Aj/e ZPbjZA4ZiqTDbcPF408eXt58YEsIIk+Y0RIP/mR78KKzxnrjj8nlfwg X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1767314883008550576?= X-GMAIL-MSGID: =?utf-8?q?1767314883008550576?= The downstream kernel employs the concept of "keeping the bus alive" by voting for the minimum (XO/19.2MHz) rate at all times on certain (well, most) buses. This is a very important thing to have, as if we either have a lackluster/wrong DT that doesn't specify a (high enough) vote on a certain bus, we may lose access to the entire bus altogether. This is very apparent when we only start introducing interconnect support on a given platform and haven't yet introduced voting on all peripherals. The same can happen if we only have a single driver casting a vote on a certain bus and that driver exits/crashes/suspends. The keepalive vote is limited to the ACTIVE bucket, as keeping a permanent vote on the SLEEP one could prevent the platform from properly entering low power mode states. Introduce the very same concept, with a slight twist: the vendor kernel checks whether the rate is zero before setting the minimum vote, but that's rather silly, as in doing so we're at the mercy of CCF. Instead, explicitly clamp the rates to always be >= 19.2 MHz for providers with keep_alive=true. Signed-off-by: Konrad Dybcio Reviewed-by: Dmitry Baryshkov --- drivers/interconnect/qcom/icc-rpm.c | 10 ++++++++++ drivers/interconnect/qcom/icc-rpm.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index 6acc7686ed38..863e8ba1daa2 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -50,6 +50,8 @@ #define NOC_QOS_MODE_FIXED_VAL 0x0 #define NOC_QOS_MODE_BYPASS_VAL 0x2 +#define ICC_BUS_CLK_MIN_RATE 19200000ULL + static int qcom_icc_set_qnoc_qos(struct icc_node *src) { struct icc_provider *provider = src->provider; @@ -380,6 +382,13 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) do_div(rate, src_qn->buswidth); rate = min_t(u64, rate, LONG_MAX); + /* + * Downstream checks whether the requested rate is zero, but it makes little sense + * to vote for a value that's below the lower threshold, so let's not do so. + */ + if (bucket == QCOM_ICC_BUCKET_WAKE && qp->keep_alive) + rate = max(ICC_BUS_CLK_MIN_RATE, rate); + if (qp->bus_clk_rate[i] == rate) continue; @@ -453,6 +462,7 @@ int qnoc_probe(struct platform_device *pdev) for (i = 0; i < qp->num_bus_clks; i++) qp->bus_clks[i].id = bus_clocks[i]; + qp->keep_alive = desc->keep_alive; qp->type = desc->type; qp->qos_offset = desc->qos_offset; diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h index ee705edf19dd..d2c04c400cad 100644 --- a/drivers/interconnect/qcom/icc-rpm.h +++ b/drivers/interconnect/qcom/icc-rpm.h @@ -33,6 +33,7 @@ enum qcom_icc_type { * @bus_clk_rate: bus clock rate in Hz * @bus_clks: the clk_bulk_data table of bus clocks * @intf_clks: a clk_bulk_data array of interface clocks + * @keep_alive: whether to always keep a minimum vote on the bus clocks * @is_on: whether the bus is powered on */ struct qcom_icc_provider { @@ -45,6 +46,7 @@ struct qcom_icc_provider { u64 bus_clk_rate[NUM_BUS_CLKS]; struct clk_bulk_data bus_clks[NUM_BUS_CLKS]; struct clk_bulk_data *intf_clks; + bool keep_alive; bool is_on; }; @@ -102,6 +104,7 @@ struct qcom_icc_desc { const char * const *bus_clocks; const char * const *intf_clocks; size_t num_intf_clocks; + bool keep_alive; bool no_clk_scaling; enum qcom_icc_type type; const struct regmap_config *regmap_cfg;