Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28056rwd; Wed, 14 Jun 2023 11:42:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VyDdx8UXcwIH4KnAUQj61O0UnC+gZhogTLNnH4a3r5koTLAC6Mq4ITvtfd9r/Vkc8FwlF X-Received: by 2002:a05:6a00:8cc:b0:655:6bcf:208a with SMTP id s12-20020a056a0008cc00b006556bcf208amr3627135pfu.6.1686768160414; Wed, 14 Jun 2023 11:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686768160; cv=none; d=google.com; s=arc-20160816; b=SHQtC9DiCZ+TbJmVkfQ/f8ggEK8oIHH0g3BDUENZYmJMke+EKJFVyODLpTKD0KRSKO 4F74MYM8AMMtz0ypjpwDjt5642GyStyhukJ22DHpNiuGieF4UeOa2R2xGHAaiP3unole bTRJJ1izEGbViGpXCf7IeubeBWTt14LnYICBXohsLDxdthC7b0Nn79ABxTkYWUlJZFJd QYC3TlMChJt0x/cRVnJl6ApVBTUyTiZpiG5IfCILy/MdoLmXDK0bazPu/ySckjOGHz/k 7RdBJYBLgvf/6iAheCRzM/doBIdc78K/CwZuFafOO/oMm28ZhmA6xziEL6Tmc8gmsDhm 1kKQ== 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=UEM3N0iLIlvYLepw85JsPFibfyRzMkZ98OPjRwmkvbs=; b=E4XG/R7cvMaE1tzXyiC3ehJG2hFu7IwGP6lPHmbzr1T+7INRx059dxsG9Oew3i70OH NgFV8durgjScEkEbLv2mwpLofXWMxLokhdnOHKxHaqREz4eaphv8cXOUg/L2DekqJPy5 esn8woqWhZp+c2pN3hvaXKf/oKlQdKcr4dvtQkDrFJtocUvy9orFj85U6cl8OxN5ptZ6 MeqQKeFSM/OoBcotzGfhFDezEI2XuG4rT8vBI+tYukBkRd1VMoOsi9K/WYz314b/6AgU RTEkYaSY1lLLnhERqD0LNytLDpPzsu4y2TLfqdYVUp2mGwK0YeiuMFCm/QhQoh/1wBGL +NOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I2qpiZG9; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a633c51000000b0053fbae20d02si11839221pgn.655.2023.06.14.11.42.26; Wed, 14 Jun 2023 11:42:40 -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=I2qpiZG9; 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 S236045AbjFNSFf (ORCPT + 99 others); Wed, 14 Jun 2023 14:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235927AbjFNSEr (ORCPT ); Wed, 14 Jun 2023 14:04:47 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 555232119 for ; Wed, 14 Jun 2023 11:04:45 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f60a27c4a2so8632293e87.2 for ; Wed, 14 Jun 2023 11:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686765883; x=1689357883; 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=UEM3N0iLIlvYLepw85JsPFibfyRzMkZ98OPjRwmkvbs=; b=I2qpiZG9IlhpHLrWDbUfivORf3SP4eWt8EyCsInFmabtqInJMA0ELNMOuPs/wWZ0mA E97LOikyIZtyN4YUF9b8J64JA6qaUDafc9apsPr8nVcWzTNDSX3wMN3oJV1DT0j7OSVp /+E9B5eiN0tYgMYhFxQeKFQr7wOU8mhwDlavxuVWnXINyLnbrWr+fJ+5CE2HJNoFRUKp GBsohJJi/KHxBeqanUb75i/pRSuiSMdCCPJFxM+YoW1/eOgodS36/pAHCb1cnXzeSG22 UxgFukcqwnjcrWmZ2Pft6OZyLXRkceGI1iGfkCi0CrKPJYy2afgs2nqhpovlw0J9eIGD v6aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686765883; x=1689357883; 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=UEM3N0iLIlvYLepw85JsPFibfyRzMkZ98OPjRwmkvbs=; b=YvqXXsM5dwWYoP8kUQrGJ7bBtFybb2uINcn21nL2wAZCuFyv3kn5ggLUDO4mFUbXOH dQ7cGQ99I7epnxaXhHGGAt+jDFRL4uqWi+MfJhFMRd/UA6QT4iJyzCdLF+X76lI/uR6e q9ce1YEDYk8QPYinCKBmWPnXrFPb5zfRX7kylmZa+B1pE1mNb0jnhJ+yc4RTWeAucn9k JfWDnV19h0GAY1xcNlAbZIXPdAKsqpRr6GlmtRpdp7TdTElsaVjdAS1s7jUb5dHYsEmD q7tegBP4gQkp91xN3EYm1A6s7vRI7bAK8S0iYuAToiAOKjtwvKXWQ7GxnU1ZFkWvVoQN cv/A== X-Gm-Message-State: AC+VfDzpe/L32kEjygmcvzPoRtkbchNN+8dGGIdQ6dAty6ta8SpSNCxM +5gLwDbAL9hDCbQcpe5kBVE0rQ== X-Received: by 2002:a05:6512:465:b0:4eb:18d:91de with SMTP id x5-20020a056512046500b004eb018d91demr8327587lfd.43.1686765883519; Wed, 14 Jun 2023 11:04:43 -0700 (PDT) Received: from [192.168.1.101] (abyj190.neoplus.adsl.tpnet.pl. [83.9.29.190]) by smtp.gmail.com with ESMTPSA id l18-20020a19c212000000b004eff1f7f206sm2224053lfc.9.2023.06.14.11.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 11:04:43 -0700 (PDT) From: Konrad Dybcio Date: Wed, 14 Jun 2023 20:04:25 +0200 Subject: [PATCH v6 06/22] interconnect: qcom: icc-rpm: Introduce keep_alive MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230526-topic-smd_icc-v6-6-263283111e66@linaro.org> References: <20230526-topic-smd_icc-v6-0-263283111e66@linaro.org> In-Reply-To: <20230526-topic-smd_icc-v6-0-263283111e66@linaro.org> To: Andy Gross , Bjorn Andersson , Michael Turquette , Stephen Boyd , Georgi Djakov , Leo Yan , Evan Green , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio , Dmitry Baryshkov X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1686765872; l=3661; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=g6kESh9vFn5cUExPwamnhleED6tFd+S7dtFe11cmEVE=; b=c3wTBcTebBtYHKq28YJz0R1OV4U4PKJUyiO3yyEw/DPpHxsYLAEsnGeb8UHIJ2FFCnIlQs1WE eMH16p4dT/oAj5IPhQJp2U6lv4Rwt1aRN5cS6ax7U+AUlqmTaGNgRWr 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=unavailable 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 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Konrad Dybcio --- 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; -- 2.41.0