From patchwork Fri Aug 11 11:55:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 712766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96263C001B0 for ; Fri, 11 Aug 2023 11:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235702AbjHKLzb (ORCPT ); Fri, 11 Aug 2023 07:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234773AbjHKLzY (ORCPT ); Fri, 11 Aug 2023 07:55:24 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EB492723 for ; Fri, 11 Aug 2023 04:55:23 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4fe0eb0ca75so2893667e87.2 for ; Fri, 11 Aug 2023 04:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691754921; x=1692359721; 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=votk4MaYH9iEJdjenquLal2dl89uf7f2OrMOIxamFPM=; b=Fx2JVGT8ntOGcFTc1NrbXwlE82Z97ETjK7AOLvqACVJXdposPwTyYI/GQE+Rzwpw6V XtDvP2fOSUDYZyvFS2VHTB55D4Z4v805bQGod21ruBQbX+/7oAjnZ3Lomj0wnaxVPIR5 0lM56TsSY1SbkZ/gTQNPo6WRt4Na04NLUv6cqgeOCwZJEkTij2egzVx5fCRNhNkbNFKJ NVbV74yebKRRiHwjPJCOSpQdaIy49v8zqhTy1kNps0xzIVXesNXnSUobo8aJVrlZj0dl LJPOwvFr+yiPpQkKfdCUDdqlNlj0L6rhjW2XFXi9fYhMjTUlCJQu/6loQFEBdGPE9Mpb Pyjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691754921; x=1692359721; 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=votk4MaYH9iEJdjenquLal2dl89uf7f2OrMOIxamFPM=; b=G2SKC4ffasHE2q52tqA205WvL3p0yX0VlBcNpc/KPq3CmDSWQKcateciSTJr6mWyhd yqv/cNGbFvY5WqEUEgQeh32Ip6k2aFN//FbI18oZxFy4MSGQXLKH/gMVoozQKDtV+kwi yzemGejaXpZbhuFqPKn6Q8vVdog+TNtfjSyai9Vg7N4qqwLKg0jWbFe0z8R1+nDHWEfL tRKeZkfAP/TMdTG7Oip9/6UIQxwunxm2p92TcAtoYMkwvVK9mP8hm7qE5GoKQu3OkkfU i7iUXetR9P+EUxisEsaiRM9ICdSnTvkXUekBnE7QI4935UK+Ys7Rzec8fojB/HC83u9A 3ziQ== X-Gm-Message-State: AOJu0YxLMY73nRkCIROWG07n3PcBC3iygp634eOT4KhwCuKPo4IJ2e08 wVtu/Z0KWTbmdCoSP9+pkOE90w== X-Google-Smtp-Source: AGHT+IGoeWd+hmADTR5N0V3Dawi8YFFRfybqAmq8VhBXbgFzMyW2f0ZhttypuvVV9uQmVirmyin4jQ== X-Received: by 2002:ac2:53ad:0:b0:4fd:c923:db5e with SMTP id j13-20020ac253ad000000b004fdc923db5emr1229203lfh.21.1691754921738; Fri, 11 Aug 2023 04:55:21 -0700 (PDT) Received: from [192.168.1.101] (abyj188.neoplus.adsl.tpnet.pl. [83.9.29.188]) by smtp.gmail.com with ESMTPSA id b17-20020ac25631000000b004fe4a4c61f0sm691729lff.191.2023.08.11.04.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 04:55:21 -0700 (PDT) From: Konrad Dybcio Date: Fri, 11 Aug 2023 13:55:07 +0200 Subject: [PATCH 1/2] interconnect: qcom: bcm-voter: Improve enable_mask handling MIME-Version: 1.0 Message-Id: <20230811-topic-icc_fix_1he-v1-1-5c96ccef3399@linaro.org> References: <20230811-topic-icc_fix_1he-v1-0-5c96ccef3399@linaro.org> In-Reply-To: <20230811-topic-icc_fix_1he-v1-0-5c96ccef3399@linaro.org> To: Andy Gross , Bjorn Andersson , Georgi Djakov , Mike Tipton , Neil Armstrong Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1691754919; l=2465; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=QCAAvsp604ImmQ7hP5JbjgwsUhs0zxDvdhVnwg2+edc=; b=M5wMD0hgtAW/Zv45Zl64U4GK45BkeSAY0Cn6Wbo3+OxP9/KYzsAQinIwfaRbmeew7rqB2adMY kXPFZxtMwBBBlKH1LjRG8ob52RA0uqlbO83L+r32KXneAAneQZSvNpJ X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org We don't need all the complex arithmetic for BCMs utilizing enable_mask, as all we need to do is to determine whether there's any user (or keepalive) asking for it to be on. Separate the logic for such BCMs for a small speed boost. Signed-off-by: Konrad Dybcio Reviewed-by: Bjorn Andersson --- drivers/interconnect/qcom/bcm-voter.c | 40 +++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c index d5f2a6b5376b..82433f35717f 100644 --- a/drivers/interconnect/qcom/bcm-voter.c +++ b/drivers/interconnect/qcom/bcm-voter.c @@ -58,6 +58,33 @@ static u64 bcm_div(u64 num, u32 base) return num; } +/* BCMs with enable_mask use one-hot-encoding for on/off signaling */ +static void bcm_aggregate_1he(struct qcom_icc_bcm *bcm) +{ + struct qcom_icc_node *node; + int bucket, i; + + for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) { + for (i = 0; i < bcm->num_nodes; i++) { + node = bcm->nodes[i]; + + /* If any vote in this bucket exists, keep the BCM enabled */ + if (node->sum_avg[bucket] || node->max_peak[bucket]) { + bcm->vote_x[bucket] = 0; + bcm->vote_y[bucket] = bcm->enable_mask; + break; + } + } + } + + if (bcm->keepalive) { + bcm->vote_x[QCOM_ICC_BUCKET_AMC] = 1; + bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = 1; + bcm->vote_y[QCOM_ICC_BUCKET_AMC] = 1; + bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = 1; + } +} + static void bcm_aggregate(struct qcom_icc_bcm *bcm) { struct qcom_icc_node *node; @@ -83,11 +110,6 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm) temp = agg_peak[bucket] * bcm->vote_scale; bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit); - - if (bcm->enable_mask && (bcm->vote_x[bucket] || bcm->vote_y[bucket])) { - bcm->vote_x[bucket] = 0; - bcm->vote_y[bucket] = bcm->enable_mask; - } } if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 && @@ -260,8 +282,12 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter) return 0; mutex_lock(&voter->lock); - list_for_each_entry(bcm, &voter->commit_list, list) - bcm_aggregate(bcm); + list_for_each_entry(bcm, &voter->commit_list, list) { + if (bcm->enable_mask) + bcm_aggregate_1he(bcm); + else + bcm_aggregate(bcm); + } /* * Pre sort the BCMs based on VCD for ease of generating a command list From patchwork Fri Aug 11 11:55:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 713426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9378C001DB for ; Fri, 11 Aug 2023 11:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235539AbjHKLza (ORCPT ); Fri, 11 Aug 2023 07:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234317AbjHKLz0 (ORCPT ); Fri, 11 Aug 2023 07:55:26 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8FB72D61 for ; Fri, 11 Aug 2023 04:55:24 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4fe28f92d8eso3060888e87.1 for ; Fri, 11 Aug 2023 04:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691754923; x=1692359723; 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=Ch1MMPzXxt2ZLlG7nltXMcHjVLEaj7rMyA9/R+Q9Z3Y=; b=oeoNxyzUCf/7wTNdJY6f32WjV37AuuwyBZga1pT/Vxsyaq7xfywmkt9c59bHuAf6hE nvDCDMSIbVhuTykuD24U0eXWxmHvkSQ/GCgaM9q5vz9gX7MaE6/Y9CgB5cgTyx5USUmM d54N90N1LVZnrVnUPmlWeH52bp8QU+LXy1GPEHV+p07/F/4mkwc7uUp6lUwKSG9Ivps7 9OUk6s30Y55GTUmWqKTmfKi2Sf3UGGOUT7jH9dwgGGlES2Nc5posp4ZQ1poNWeIzp58V Rw/eunQPHMaXzpf9MUXpP5pdFAg/noTjajEOYWhQYKGk7b6Hiw90keq4TVdK3eBwJthC mxEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691754923; x=1692359723; 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=Ch1MMPzXxt2ZLlG7nltXMcHjVLEaj7rMyA9/R+Q9Z3Y=; b=K0sHHS/4nORQxQFhtc4V/Joory2DGjlmghd05kI3qQg8P68N8/Su9bT3UnFLCH0pX2 pzHi2mnxVg860YwlPEQa4oZJh5SkrGV6f8Q0cRTTNyn5Xp/12QLvirtqZWJGzm0rXc8j c3r1XJ8u8NQXUEQ6FQa/kz7rIn92rA9cJ37HROVAL4PqXSS8to32qyNY+8Jgf4bsUpFR WhZMrQr3c6+IKx1WMDg5athLEDnej2UkLLSZO6y5cr85mYMIaBJgLcDHi0yMVinrCiSV hJk2xCt5ypLGlJQnALd/tema9uxScmTESqaNfWuuSURRH6uqbU3stDB8Ezznf/dUQkjr xHIA== X-Gm-Message-State: AOJu0YzU+DdA8Xww76y0u2xWzRTXgo2n9m/FjozXELnpF8QpAzgxfxBC zDHtyOnOqvk//Dz8/OrlVm2RFg== X-Google-Smtp-Source: AGHT+IGWAiMNIiztaw+MSdWe2bowZ2pGCFgH/LkYVAzY8FUXhxigTgDv5wnxvaZ2/jT3M8aUTATP8w== X-Received: by 2002:a05:6512:1154:b0:4f8:5885:61e with SMTP id m20-20020a056512115400b004f85885061emr1303842lfg.40.1691754923165; Fri, 11 Aug 2023 04:55:23 -0700 (PDT) Received: from [192.168.1.101] (abyj188.neoplus.adsl.tpnet.pl. [83.9.29.188]) by smtp.gmail.com with ESMTPSA id b17-20020ac25631000000b004fe4a4c61f0sm691729lff.191.2023.08.11.04.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 04:55:22 -0700 (PDT) From: Konrad Dybcio Date: Fri, 11 Aug 2023 13:55:08 +0200 Subject: [PATCH 2/2] interconnect: qcom: bcm-voter: Use enable_maks for keepalive voting MIME-Version: 1.0 Message-Id: <20230811-topic-icc_fix_1he-v1-2-5c96ccef3399@linaro.org> References: <20230811-topic-icc_fix_1he-v1-0-5c96ccef3399@linaro.org> In-Reply-To: <20230811-topic-icc_fix_1he-v1-0-5c96ccef3399@linaro.org> To: Andy Gross , Bjorn Andersson , Georgi Djakov , Mike Tipton , Neil Armstrong Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Bjorn Andersson X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1691754919; l=1365; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=ooKoWDrIZBGoRmYbzBT936ZVDY0VC6/O2RuTPuEpqXc=; b=tWCHfvHPwWdJ+l7tj7scfETlbh3LpPB3jM6S4mCR0aIO+zrEmhfuWOqfuwneYYhij6dzsCNvi Cy/1avBW7rKA2app07sfTr621oIoFoYrJIqh+oReAI5Z/rxilUUBNQM X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org BCMs with an enable_mask expect to only have that specific value written to them. The current implementation only works by miracle for BCMs with enable mask == BIT(0), as the minimal vote we've been using so far just so happens to be equal to that. Use the correct value with keepalive voting. Fixes: d8630f050d3f ("interconnect: qcom: Add support for mask-based BCMs") Reported-by: Bjorn Andersson Signed-off-by: Konrad Dybcio --- drivers/interconnect/qcom/bcm-voter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c index 82433f35717f..a28b87eec3da 100644 --- a/drivers/interconnect/qcom/bcm-voter.c +++ b/drivers/interconnect/qcom/bcm-voter.c @@ -78,10 +78,10 @@ static void bcm_aggregate_1he(struct qcom_icc_bcm *bcm) } if (bcm->keepalive) { - bcm->vote_x[QCOM_ICC_BUCKET_AMC] = 1; - bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = 1; - bcm->vote_y[QCOM_ICC_BUCKET_AMC] = 1; - bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = 1; + bcm->vote_x[QCOM_ICC_BUCKET_AMC] = bcm->enable_mask; + bcm->vote_x[QCOM_ICC_BUCKET_WAKE] = bcm->enable_mask; + bcm->vote_y[QCOM_ICC_BUCKET_AMC] = bcm->enable_mask; + bcm->vote_y[QCOM_ICC_BUCKET_WAKE] = bcm->enable_mask; } }