Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4636451ybb; Tue, 7 Apr 2020 11:20:08 -0700 (PDT) X-Google-Smtp-Source: APiQypKwtkDY7HQ8rLL9p2B/+wwXyhTqB6GlaGlNKhFfdpf1m/8t8V3EnT9w2KPqJUmFdoN+4dYf X-Received: by 2002:a9d:23a6:: with SMTP id t35mr2914625otb.154.1586283608002; Tue, 07 Apr 2020 11:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586283607; cv=none; d=google.com; s=arc-20160816; b=09DmT6loTzsPxNYPQkQeuG+xbHtdhUqRz2ykAh+LtnASPjLNMXHltJvtZ8O0TYjkze Xmwb/2tKzoNt5G8BdcNBKHSCqq6dY6m7k69uDLkyMk/7PNnuNC6aKDWDASGEnVGgrh0T UR82V369gbFDICCmjIvgm/53n8PrkP0Asg/GeXqoaDTzrlIsTlg8IuddwxZLOVrFS3/z oqvx672rkbUDdu7D7X9b4hLQLhsoa8swk9a/RHRCLWGi4vihiY1FR0dbLAeconssvStE F0MMleUMO3EjgqKUHNwZOdPGp1oFVlGrGtEHC8xLMbZsgjvSzuEdUbMNHpxIQsKDD38u r0tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=1T8Mav91EqAdJ7H6yxiF8ECC4x0Y7inBotcMr+uv4UU=; b=JLXvjDSVaRgN89RXxWwrTH9zRB4H0E+tGEWKZGMWGCQTwCjIlVd8b6ErQgq1G/FqkE U7w+GZPeq+VlbcghkKKGHUgMIErmoa6ZHit1cX+9sBsgYmnWekppJOkpV2Y9lHdrv6bI Kctn/K8LI2dmXmPiPQ/MuFzc52XulvFNBZDHSR3u0gS1ZxL4/2L8ZnC87VhY3A9SOcIY nL8AB9TpsyIHUF18r5YoBMTQ7iH738/3j3wZFB2JcyfD7GFu7skciD14nfDdeYe0a/i5 lb3RPMvjmzRk+r9ESoHNPtN5kyqw+5IqMrNA7prcjfD17F8bG/lL7+AelmZ6QM5jA1lM 4whg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=DXJxJwgV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19si1498659oos.45.2020.04.07.11.19.53; Tue, 07 Apr 2020 11:20:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=DXJxJwgV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgDGSR7 (ORCPT + 99 others); Tue, 7 Apr 2020 14:17:59 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:8286 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbgDGSR7 (ORCPT ); Tue, 7 Apr 2020 14:17:59 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 07 Apr 2020 11:16:15 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 07 Apr 2020 11:17:58 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 07 Apr 2020 11:17:58 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 7 Apr 2020 18:17:57 +0000 Received: from [10.24.37.103] (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 7 Apr 2020 18:17:53 +0000 From: sumitg Subject: Re: [TEGRA194_CPUFREQ Patch 2/3] cpufreq: Add Tegra194 cpufreq driver To: Viresh Kumar CC: , , , , , , , , , , , , References: <1575394348-17649-1-git-send-email-sumitg@nvidia.com> <1575394348-17649-2-git-send-email-sumitg@nvidia.com> <20200326115023.xy3n5bl7uetuw7mx@vireshk-i7> <20200406025549.qfwzlk3745y3r274@vireshk-i7> Message-ID: <3ab4136c-8cca-c2f9-d286-b82dac23e720@nvidia.com> Date: Tue, 7 Apr 2020 23:48:22 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200406025549.qfwzlk3745y3r274@vireshk-i7> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1586283375; bh=1T8Mav91EqAdJ7H6yxiF8ECC4x0Y7inBotcMr+uv4UU=; h=X-PGP-Universal:From:Subject:To:CC:References:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=DXJxJwgV63yMneG9NLjEmWWUAkmrYMcc7CHERtAKRPWQdrWD/1IzJDVG1OoovZLbz oYIIJk7Yd35G4cW1OGxRcbfeSPgB7GGtOMiKbRDwaRfo8svzcr3wC+EEaREzKJ0Jwp utHFXro6HYDCeB/2BYvjOWpryJhSebyxPb+BtHFa/vROP22IkGkmOkFWkG0pwjmCyo Y1dX+geavXWWcTspY2UmpHcGrNVEc44rYvupoD3gIVqM4wUrwQbAtAe3x/1XgEI4S2 2hizYx3N8sdj8sMRJd2PFxBn56xiAEcOoXndN+G/JqUbYcKNBgwFAyBhKt50O0vNyy CfpxLfWxiv/Vw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/04/20 8:25 AM, Viresh Kumar wrote: > External email: Use caution opening links or attachments > > > On 05-04-20, 00:08, sumitg wrote: >> >> >> On 26/03/20 5:20 PM, Viresh Kumar wrote: >>> On 03-12-19, 23:02, Sumit Gupta wrote: >>>> diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c >>>> +enum cluster { >>>> + CLUSTER0, >>>> + CLUSTER1, >>>> + CLUSTER2, >>>> + CLUSTER3, >>> >>> All these have same CPUs ? Or big little kind of stuff ? How come they >>> have different frequency tables ? >>> >> T194 SOC has homogeneous architecture where each cluster has two symmetric >> Carmel cores and and not big little. LUT's are per cluster and all LUT's >> have same values currently. Future SOC's may have different LUT values per >> cluster. > > LUT ? > LUT is "Lookup Table" which provides "hardware frequency request" as a function of voltage. For each frequency, the table can have multiple voltages based on temperature. The table is maintained in "BPMP R5". >>>> + MAX_CLUSTERS, >>>> +}; > >>>> +static unsigned int tegra194_get_speed_common(u32 cpu, u32 delay) >>>> +{ >>>> + struct read_counters_work read_counters_work; >>>> + struct tegra_cpu_ctr c; >>>> + u32 delta_refcnt; >>>> + u32 delta_ccnt; >>>> + u32 rate_mhz; >>>> + >>>> + read_counters_work.c.cpu = cpu; >>>> + read_counters_work.c.delay = delay; >>>> + INIT_WORK_ONSTACK(&read_counters_work.work, tegra_read_counters); >>>> + queue_work_on(cpu, read_counters_wq, &read_counters_work.work); >>>> + flush_work(&read_counters_work.work); >>> >>> Why can't this be done in current context ? >>> >> We used work queue instead of smp_call_function_single() to have long delay. > > Please explain completely, you have raised more questions than you > answered :) > > Why do you want to have long delays ? > Long delay value is used to have the observation window long enough for correctly reconstructing the CPU frequency considering noise. In next patch version, changed delay value to 500us which in our tests is considered reliable. >>>> +static int tegra194_cpufreq_init(struct cpufreq_policy *policy) >>>> +{ >>>> + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); >>>> + int cluster = get_cpu_cluster(policy->cpu); >>>> + >>>> + if (cluster >= data->num_clusters) >>>> + return -EINVAL; >>>> + >>>> + policy->cur = tegra194_fast_get_speed(policy->cpu); /* boot freq */ >>>> + >>>> + /* set same policy for all cpus */ >>>> + cpumask_copy(policy->cpus, cpu_possible_mask); >>> >>> You are copying cpu_possible_mask mask here, and so this routine will >>> get called only once. >>> >>> I still don't understand the logic behind clusters and frequency >>> tables. >>> >> Currently, we use same policy for all CPU's to maximize throughput. Will add >> separate patch later to set policy as per cluster. But we are not using that >> in T194 due to perf reasons. > > You can't misrepresent the hardware this way, sorry. > ok. Updated the policy to be per cluster now. > Again few questions, I understand that you have multiple clusters > here: > > - All clusters will always have the frequency table ? Yes, frequency table is per cluster. > - All clusters are capable of having a different frequency at any > point of time ? Or they will always run at same freq ? > Yes, all clusters are capable to run at different frequencies. >>>> + freqs.old = policy->cur; >>>> + freqs.new = tbl->frequency; >>>> + >>>> + cpufreq_freq_transition_begin(policy, &freqs); >>>> + on_each_cpu_mask(policy->cpus, set_cpu_ndiv, tbl, true); >>> >>> When CPUs share clock line, why is this required for every CPU ? >>> Per core NVFREQ_REQ system register is written to make frequency >> requests for the core. Cluster h/w then forwards the max(core0, core1) >> request to cluster NAFLL. > > You mean that each cluster can set frequency independently ? > Yes. > If all the clusters can run at independent frequencies but you still > want them to run at same frequency, then that can be done with a > single set of governor tunables, which is the default anyway. So this > should just work for you. > > I will not be reviewing the v2 version you sent for now as that is > most likely wrong anyway. > > -- > viresh >