Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1779566iob; Thu, 5 May 2022 08:05:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySCzJatHCqcZJcc3yq8XPjCMdCF08VD6ijtC2XfQv7W0sBe7SjCPTrYZP3h9+K4pkCCqP7 X-Received: by 2002:a17:90b:3142:b0:1dc:c4c9:cdf8 with SMTP id ip2-20020a17090b314200b001dcc4c9cdf8mr2496737pjb.125.1651763136523; Thu, 05 May 2022 08:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651763136; cv=none; d=google.com; s=arc-20160816; b=to1bvNSDJJD+9EIjyyptawmPz5wBQ2lpTPDsceKzrSpNtAj/LgG5mu6W9stOVxS/l3 pcqOJOU+vYe0xAO+pj8g6q8Dl5aMnOoXEy9n7urOBsCEQeQyCdGQIECeUTSsrqyCLs4d NP6R+wGejUOsXH7wMahOOlAasTL/SQ08Y4GusaOVys2mQeR4TOibdO32MgAiHL5NABsF I7xaAeXmzwUxpHs6nv5Y79+36GI6ay5JfvxOUMqcZFYSs5Ga//hQ5YLjC3NwQWogEtY+ MkwWFGJiTmR/soq4Rz8SGbvwhPWjLmdE1RjlrjQj4TOWsPCHDk4lkHvH5uQFEBAgh4fj mOlg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MVjNpv2x+d0cPnK8s78Qs8D6Dsadm7uKOsVYlA9Gb2w=; b=EDUQoxo5Qv7XWNZ/iG3xhlCSENw7vGb8Rlg58ztOtwDQ462WQw/uVpszlWwx64pm6R NNst3OrqvLixVZJ9o78hQ/qXbGSQV7SRAFUE7BvoLc+VlS13fOgSwVAPxfcuNX7M0NB7 qD0wgUmdFo/sN+dLZOpVXMjpxKIJ9nV1Gh3K43L2qphmPNFBswE3Oz8D9GBMkV4yO9F3 aU+Io0IeuMTJQBia5OFQxaG3lZDkQ3yUg5RcSASvAORBOO2T+RMU+ie1ddmsYX5kXgyM 0lssVcnXmjKir9iMW3b/VMl5JratrTd4uorMhogjD7LfqJzPXH3GULsBp4odUuzL8t8R MhtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M0FgI3ZG; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ip13-20020a17090b314d00b001dc62080a06si8918632pjb.74.2022.05.05.08.05.03; Thu, 05 May 2022 08:05:36 -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=@linuxfoundation.org header.s=korg header.b=M0FgI3ZG; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358562AbiEDRQF (ORCPT + 99 others); Wed, 4 May 2022 13:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355701AbiEDREj (ORCPT ); Wed, 4 May 2022 13:04:39 -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 F18864F44B; Wed, 4 May 2022 09:53:14 -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 5EFF4617BD; Wed, 4 May 2022 16:53:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD0FCC385A5; Wed, 4 May 2022 16:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683193; bh=GZgX069Xig3QT1ywx3SlIJvq+f8nwWelsRS134k74wo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0FgI3ZGbGGeMbkRleVSSq2JTEhUKJ5xLirHLK8rRpi4q1D+xE3zDae5ixXoBrGdX NtQtdGEy4sf4RVTfAlVB1+VvbOJcIGDorSvuYMC4mGfb9KKecPwFP1IdzJu5vFci+h rmmf/5+DZI3Jdq6wwGEAqvjlF11lreRPL8Cft66o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Andersson , Vladimir Zapolskiy , Viresh Kumar , Sasha Levin Subject: [PATCH 5.15 046/177] cpufreq: qcom-cpufreq-hw: Fix throttle frequency value on EPSS platforms Date: Wed, 4 May 2022 18:43:59 +0200 Message-Id: <20220504153057.045373689@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,T_SCC_BODY_TEXT_LINE 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 From: Vladimir Zapolskiy [ Upstream commit f84ccad5f5660f86a642a3d7e2bfdc4e7a8a2d49 ] On QCOM platforms with EPSS flavour of cpufreq IP a throttled frequency is obtained from another register REG_DOMAIN_STATE, thus the helper function qcom_lmh_get_throttle_freq() should be modified accordingly, as for now it returns gibberish since .reg_current_vote is unset for EPSS hardware. To exclude a hardcoded magic number 19200 it is replaced by "xo" clock rate in KHz. Fixes: 275157b367f4 ("cpufreq: qcom-cpufreq-hw: Add dcvs interrupt support") Reviewed-by: Bjorn Andersson Signed-off-by: Vladimir Zapolskiy Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- drivers/cpufreq/qcom-cpufreq-hw.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index dfe72d82858f..e73ecab23c85 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -28,6 +28,7 @@ struct qcom_cpufreq_soc_data { u32 reg_enable; + u32 reg_domain_state; u32 reg_freq_lut; u32 reg_volt_lut; u32 reg_current_vote; @@ -266,11 +267,16 @@ static void qcom_get_related_cpus(int index, struct cpumask *m) } } -static unsigned int qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data) +static unsigned long qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data) { - unsigned int val = readl_relaxed(data->base + data->soc_data->reg_current_vote); + unsigned int lval; - return (val & 0x3FF) * 19200; + if (data->soc_data->reg_current_vote) + lval = readl_relaxed(data->base + data->soc_data->reg_current_vote) & 0x3ff; + else + lval = readl_relaxed(data->base + data->soc_data->reg_domain_state) & 0xff; + + return lval * xo_rate; } static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) @@ -280,14 +286,12 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) int cpu = cpumask_first(policy->related_cpus); struct device *dev = get_cpu_device(cpu); struct dev_pm_opp *opp; - unsigned int freq; /* * Get the h/w throttled frequency, normalize it using the * registered opp table and use it to calculate thermal pressure. */ - freq = qcom_lmh_get_throttle_freq(data); - freq_hz = freq * HZ_PER_KHZ; + freq_hz = qcom_lmh_get_throttle_freq(data); opp = dev_pm_opp_find_freq_floor(dev, &freq_hz); if (IS_ERR(opp) && PTR_ERR(opp) == -ERANGE) @@ -359,6 +363,7 @@ static const struct qcom_cpufreq_soc_data qcom_soc_data = { static const struct qcom_cpufreq_soc_data epss_soc_data = { .reg_enable = 0x0, + .reg_domain_state = 0x20, .reg_freq_lut = 0x100, .reg_volt_lut = 0x200, .reg_perf_state = 0x320, -- 2.35.1