Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp505608ybb; Wed, 8 Apr 2020 04:27:14 -0700 (PDT) X-Google-Smtp-Source: APiQypJHYy/rL4N242JJZ6Vz42NEbLaVJTSBTL8u8lKC8EPTVa5ugLrgosoKFJuW0JTbtoQXszbG X-Received: by 2002:a9d:1786:: with SMTP id j6mr5034094otj.235.1586345233934; Wed, 08 Apr 2020 04:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586345233; cv=none; d=google.com; s=arc-20160816; b=o1U/7Vi1RlMtxPUEbcfQVUPI9qlv/I6MJrvNae7H/2g8h3OwxrOD/AQ8cXAtAzUSOc Ccemb8jtIPsw+Ks8hPjic5if/2NStMgbNOPQK4Cr3+x9EBdoKP0uZd0iWz/MkLRTydMz A2EB1BOBqPyC8txs1CCwc8IVY5+7Cf11n6qSwwi3aEPsp8KSO9K5LaU1QVHu0gp2yhW+ EpHsK1jPq4/EiJ9OlKhQSBYz2cIM5VKt9I9DYawFYfdg3YXHtPEewB3Mm2Ab/N44eWBp 43L35MJ82Yeg0lxF7j96OA4d/4/D4x6zo3S3e0Stp05drsYvf45eUp9ozi8PkFaB/uI2 AT/A== 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:from:references:cc:to:subject; bh=oYFcSb+xjYNh1lFY2wJ0O1MqXnEs9+vbafQpizW2IEQ=; b=yqf8WO1p1xkzdgwXuhlFrW0pP5oUHuWn2EucIkjI+iXqa69hPfdLJJW8B3831XzTEL eEsbldDISeaeN3sQ2xwF6P81cL959RhHxPgFPTvyiH4Cts0Zn8/nYzb4HNC5xE2/+02D HrxFkocozTz7zfEbezne6RDUkir6w/TYnh9TEF+qW3vp9AnoNrFiR06llyastSmJ365Q 7/1U/cb+NgHAeBiOo7MpJmexUZ3o29fpHarDdYpNDEDlfQ9aHscURv4wYGu0LRNKDmET qLaZ0nG0cZVEhWOtE5JcYECgFq6hzHJNs85wwJtHo8yeVAgjAkamrXWf2puXfBPrqHsp BZ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=iB1I9IcX; 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 l62si808765oih.269.2020.04.08.04.26.58; Wed, 08 Apr 2020 04:27:13 -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=iB1I9IcX; 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 S1728454AbgDHLX7 (ORCPT + 99 others); Wed, 8 Apr 2020 07:23:59 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:14525 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728442AbgDHLX7 (ORCPT ); Wed, 8 Apr 2020 07:23: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 ; Wed, 08 Apr 2020 04:22:14 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 08 Apr 2020 04:23:57 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 08 Apr 2020 04:23:57 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 8 Apr 2020 11:23: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; Wed, 8 Apr 2020 11:23:53 +0000 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> <3ab4136c-8cca-c2f9-d286-b82dac23e720@nvidia.com> <20200408055301.jhvu5bc2luu3b5qr@vireshk-i7> From: sumitg Message-ID: <08307e54-0e14-14a3-7d6a-d59e1e04a683@nvidia.com> Date: Wed, 8 Apr 2020 16:54:07 +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: <20200408055301.jhvu5bc2luu3b5qr@vireshk-i7> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) 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=1586344935; bh=oYFcSb+xjYNh1lFY2wJ0O1MqXnEs9+vbafQpizW2IEQ=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=iB1I9IcXw9V27t4+8PI4OAE3+gQvSQNfry3VT4hcWVhrBiwyoP597DPogUKCkoT1T noPO3H03Ywg4wflAC9Ia4kxBER2iSwLeKpREetVAh7XJCFFi4XPdCIyoTlC/U5um+/ SJXmDCIWMx0ZcCM6DWwG4RSDzDfGW6fe/qh3A1RwelVKh3QMxSx3yek/CnhqruUCBg /YbbOmIC5PlPUdVbHPF2LzBKgiwzdF2OiYj0HeitxVPZiVCJ+DSbg3xxEtSrFKN6YC nzUxvfm43RrhlWn1xmRskmWhQ928Nr3TSppfXaHBma2nW+tAxHyFzCMvVKDssd3E7r clyE9PtKQW0dg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/04/20 11:23 AM, Viresh Kumar wrote: > External email: Use caution opening links or attachments > > > On 07-04-20, 23:48, sumitg wrote: >> On 06/04/20 8:25 AM, Viresh Kumar wrote: >>> 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 >>>>>> +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. > > I understand that you need to put a udelay() while reading the freq from > hardware, that is fine, but why do you need a workqueue for that? Why can't you > just read the values directly from the same context ? > The register to read frequency is per core and not accessible to other cores. So, we have to execute the function remotely as the target core to read frequency might be different from current. The functions for that are smp_call_function_single or queue_work_on. We used queue_work_on() to avoid long delay inside ipi interrupt context with interrupts disabled. > -- > viresh >