Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp528263imm; Wed, 20 Jun 2018 02:18:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpO8jBq+IeGP1P9psD0FfZnpDOSSA3nT16LDZfrn37qYnUjkqqbl+P0+9zJ3864U16uYjW X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr18109098pgp.221.1529486311420; Wed, 20 Jun 2018 02:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529486311; cv=none; d=google.com; s=arc-20160816; b=nQokSKBYt7hKa4v53HeGXKeS+skLmtBoYIY7jLaGBHUMr4wjrOH4iuipxJXs+8M0Lp y46CJAafu/meMgApfJXw5laltdcErJP6Ny9tyfh1A4OapMBmh3557ApWu++1PBWHukM+ tiyX67BLKndXCTi4PckXvHTSs7p0s9IN7lrLCSgGM8HYnIcWwIZmCuyT2pMZzcgwwIrn tkUzsd7oi6ccvtNfiZug8blP8P/5VpXstd8KkYsatu8wdx3hvFCaKqkej+KijNU8sgk7 dfIJera47cESPR9ioemUNOA8uKA6nUgDUSX+1YYF4zCcPvVXxPgKwoMcq+9jLuqst3kP 9p8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=OSrNDoUJ871doqn9WkECZ/1aI3n3RNfGwm0+iNT0ZPU=; b=MSDeRQYYTZBY6itD8hWWOD1OT4nraofWc6uD0N4gpBgM1c9/W71RI9VZ5Q4kZUHdSA WKn1pjFRyAd4d9qJoXrP6fJIeHeKsHmhvG+apYQPrg8qKR2yYp08rzWlKI+dfI1vgBJB j1Z0xaOcHaSOVff64zhNC0iDBevTprJGmLqBcrFwgg/yZIf3Ui0xz1AgxCTM86qLijS0 SGYhRszNhg7UXLPk03xXRir4Ke6v+xgxlXYBQmq0ak8JVlNsmoLcQUufcJtxJT5MC5Ja Dta5Npx7SLL96dDTdWuHs68mFkpNcnm2U4zyO0PU5b5Aamg/nuwWjNnxNvJafwVm+Gs/ L0pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=JufcSMkZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si1634679pgr.49.2018.06.20.02.18.17; Wed, 20 Jun 2018 02:18:31 -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=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=JufcSMkZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754746AbeFTJRd (ORCPT + 99 others); Wed, 20 Jun 2018 05:17:33 -0400 Received: from mail-by2nam03on0057.outbound.protection.outlook.com ([104.47.42.57]:27486 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754326AbeFTJRZ (ORCPT ); Wed, 20 Jun 2018 05:17:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OSrNDoUJ871doqn9WkECZ/1aI3n3RNfGwm0+iNT0ZPU=; b=JufcSMkZUFGXQsTQG52g8/CM/BGiMBHrotn8vDP1saxq1JKDfrle+S3DF2KT0w5+rEkxdnKKXqKLQMc9t5Icye3SIdix5AFbdjfcn4xoBL1fzpo+TCAyA9dBxYbH5/4vtV/eQ7Euw33Mrsrj3WYjdX9I6rNIjJFoHli6sdU87ak= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=George.Cherian@cavium.com; Received: from [10.167.103.249] (111.93.218.67) by BL0PR07MB4914.namprd07.prod.outlook.com (2603:10b6:208:43::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.20; Wed, 20 Jun 2018 09:17:22 +0000 Subject: Re: [PATCH v2] cpufreq / CPPC: Add cpuinfo_cur_freq support for CPPC To: "Prakash, Prashanth" , George Cherian , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: viresh.kumar@linaro.org, rjw@rjwysocki.net References: <1529056995-122792-1-git-send-email-george.cherian@cavium.com> <67822500-0c9d-ac24-71bc-2717831ab29d@codeaurora.org> From: George Cherian Message-ID: <44d52166-ed9d-c199-3e19-3df1317ee78c@caviumnetworks.com> Date: Wed, 20 Jun 2018 14:47:02 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <67822500-0c9d-ac24-71bc-2717831ab29d@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BMXPR01CA0021.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::31) To BL0PR07MB4914.namprd07.prod.outlook.com (2603:10b6:208:43::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc4fcb03-f82e-4db6-0a05-08d5d68ea26a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020);SRVR:BL0PR07MB4914; X-Microsoft-Exchange-Diagnostics: 1;BL0PR07MB4914;3:Jo2f3F4rHHcRZdnN3lKj+6rG+lAySurKNbCoHWyJZBwBNeY+YlBP8QctY8/AKR6eVphU+rKnoMiHoJNUQF17UXapT58lGzbk5hsSiDH6y9W4Mqx8Mu7pTixuEZIBCH1EK0uP4piKwJUjXEAEnK7CHsBxRiWfQSfNb5aeIzioaD85JIccCtt2PKq5z8shUcxXoGEbfm9KsJ3Kd7nYyueWzIveDKPymWga20qpC0aepIAfJxRaigNZEau2KPWbrj7B;25:fgxEbI+Az6u0kgNq+gyG1gFxDpKxFZFuZObPmuZAtfUJLiXp9RXO2OR2kuOabdV9VjI/5A4fU+xcw2hgEj2PXkFGy0CW/knjR4F2U0ERSekVUXmY8/NCUDzRZGNIirYdwBaVcX2GYIXsptr0kuOCh1O4lD8Ou6AIWxXM5pnP64R/63KMxDA/9E94GPz2BY8jJAvruBspSe5lSe81WXttS3TvUJTJ5AM3nfTAqnPxmToR32pbrry0Y2O+CL1MXgaetmHejQKMQwFAs0YFNyT5WxMpsI/o+7y7DwhsdrDUM3PmkTUnFhdUtMxFQ0TjHOxGtO6WL2b7mualp0NZfOtoRw==;31:zUCDoVSysKqCNkTaE4Nxab3PttMDVEDeyNr+Zf3NwxGgy4J6cENlk4xUwfZ6FLawXZSmP1K1HXJnnR/B47FHjkylkqaKPQ+5r328VYNEx+1v9XSoi+DWNtrHvtVhwuKd87ViuZx5XqIjda1oQvfTrvGBw6wz4GtYVuD9Kzh7sfTitNpUdm/WXh3NH3yIeulr507vzncvJ7UfMuRBiF4aw3gPMTvqIOwAVjWOXNb6kic= X-MS-TrafficTypeDiagnostic: BL0PR07MB4914: X-Microsoft-Exchange-Diagnostics: 1;BL0PR07MB4914;20:ZXSzGrs9sFHJn31+JbmYifisAXtI3XEVbk7aQQTcyNrmdcInPACG02fzAhK0QoXxkdeqRtRI2P9w9WdKFVgzNxPqe7WJbYeb/ju8NunWVR7JBOq6LTEczl3Skw+trZAi+1GKVhXQpTNfNnUlC0Ezb5rnDJJvEG2yTm0YogbU1zFgfYF6dgLI5c7th5Xd2qqj0oc1QAykGdGc6ESqE1va2xG+70zqQ4LjW6bOnGqQ4ED5mnkjrywwAIcFab38vo+7vnNunGgyc/8R0w5DS65Cp6U2HtXqdPyt6unAqaExpZDdL+DtV1xV/0X1APUgAwCvUrvcjxbJNWlj2kDYknvPvmpJCXW3Vo6nxQRoeZR9BCfjg8K8RdTrgT0G7GjyZE6JfGcCrUrY6fHhJ7ghemYBrI8rJhVF/8Guphp+EIuMkcYvRbmjhWHb3XL8eQjXCXK5DWvDaEG7ZECL/Y6GH09vUAl6dHBRl0mzO6JuOg0hG5unWGly9OZjAIRsqES/87FBmnBOrwsodjGL87f0plV46PX5tJOCKg73agS4+d7dMyuXWy1SnpHdiaewkjdhkuwz1DQJCm+CvcLvySm1sh6esiZ661xGIn3tJfrNn/gKrZE=;4:cIhEUGImXV3XKhTAGO/Dgu0zcLn9UKpm/jRdK4CAU8bvoJyTT52RpnhAiaU5AwuOqumDK29xBwx/Kz1yZszlpJrbXVmzUDF5RhJipz4OinxP4kTgbf7waHSvXsjIm3yPAZ9p445TCMVrK1bLfZvDLv34GrpCBPZUT1/TJL1692jecnljzFscAU9LGxsokAsQNkh95blrfsmUEtUtxQAL3Gc4PwgsmuD38z7DOyqylvskkp3k8HC+4TvWr/P6gfdQIT660GkAU79AihQ2gUWeJtPRJlmd4VbIsGZtZVcdBuXH/AWNsY9XLFk8SP1fZCzu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(3002001)(10201501046)(93006095)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:BL0PR07MB4914;BCL:0;PCL:0;RULEID:;SRVR:BL0PR07MB4914; X-Forefront-PRVS: 070912876F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(366004)(39860400002)(346002)(396003)(376002)(39380400002)(43544003)(199004)(51914003)(189003)(72206003)(66066001)(2906002)(67846002)(47776003)(6666003)(53546011)(2616005)(478600001)(11346002)(8676002)(81156014)(476003)(956004)(65806001)(486006)(68736007)(8936002)(36756003)(446003)(59450400001)(26005)(16526019)(52116002)(23676004)(186003)(52146003)(2486003)(65956001)(42882007)(16576012)(81166006)(316002)(58126008)(110136005)(7736002)(386003)(305945005)(31696002)(77096007)(76176011)(5660300001)(105586002)(106356001)(6246003)(6486002)(64126003)(31686004)(6116002)(229853002)(53936002)(97736004)(25786009)(3846002)(4326008)(50466002)(230700001)(5009440100003)(65826007);DIR:OUT;SFP:1101;SCL:1;SRVR:BL0PR07MB4914;H:[10.167.103.249];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTDBQUjA3TUI0OTE0OzIzOnRpQllIV0dZY3drYkpZQXY2Vi9KVit5cUtJ?= =?utf-8?B?WHZmNkhzSDgvbXpEbGZNemVXNmUyVS9mTDc0bTlFeUxCQ2M4NStDRmNycEh4?= =?utf-8?B?SWF0eEtqWEd1bHl2R25la28rdDJGbHZ1eDBKUHVjdjB6TUFwMjB4NDJUb0Jj?= =?utf-8?B?QllUeXBWUmRQUnRxcmR4MmQxYWxKcGFiTkFUVzZjQ2c3Q28xby91NUpSYVdr?= =?utf-8?B?VlorOWRIK3VGL3VkUXdvejNSUmsxZzArQTNEQ0FDYjNLTHgzTFVGYlRVTnVt?= =?utf-8?B?RGxPVzBxdGxVVElKMWQzVk5NeFBtSVd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QIH0st3XJ0L4Dq4jioGz2owp19n/B220Yyj8Zt5hTJtuzZgZTlNVnxP7EoAGc13XeQXgt0ZZ4QD97IUIwKl9sjNmk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BL0PR07MB4914;7:dau76S/3DcdVkYvJtJRdmNWvqY+MN+PImAwRb7OycXvhTj/HYdhmXbkHUMDy532n0u2nGrMLSnun5g3vyZAk+Ke//OSJdT4lE28TyiAIJMTHD6liSEVlk4sUnWJAg8nfoHWitzJvPg5jnz93QEHb42bd8Y90I9q/1NwSL6479DFSEE6kxQRb6Tj+GudFv45nZ85ueI9x0q4C0tQEdvfQPVa26ngYxAfMtJUpClHn+Km2YlqqHyTrNwZanJ/MJJLf X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2018 09:17:22.3508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc4fcb03-f82e-4db6-0a05-08d5d68ea26a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR07MB4914 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prakash, Thanks for the review. On 06/19/2018 01:51 AM, Prakash, Prashanth wrote: > External Email > > Hi George, > > On 6/15/2018 4:03 AM, George Cherian wrote: >> Per Section 8.4.7.1.3 of ACPI 6.2, The platform provides performance >> feedback via set of performance counters. To determine the actual >> performance level delivered over time, OSPM may read a set of >> performance counters from the Reference Performance Counter Register >> and the Delivered Performance Counter Register. >> >> OSPM calculates the delivered performance over a given time period by >> taking a beginning and ending snapshot of both the reference and >> delivered performance counters, and calculating: >> >> delivered_perf = reference_perf X (delta of delivered_perf counter / delta of reference_perf counter). >> >> Implement the above and hook this to the cpufreq->get method. >> >> Signed-off-by: George Cherian >> Acked-by: Viresh Kumar >> --- >> drivers/cpufreq/cppc_cpufreq.c | 71 ++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 71 insertions(+) >> >> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c >> index 3464580..3fe7625 100644 >> --- a/drivers/cpufreq/cppc_cpufreq.c >> +++ b/drivers/cpufreq/cppc_cpufreq.c >> @@ -296,10 +296,81 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) >> return ret; >> } >> >> +static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu, >> + struct cppc_perf_fb_ctrs fb_ctrs_t0, >> + struct cppc_perf_fb_ctrs fb_ctrs_t1) >> +{ >> + u64 delta_reference, delta_delivered; >> + u64 reference_perf, delivered_perf; >> + >> + reference_perf = fb_ctrs_t0.reference_perf; >> + if (fb_ctrs_t1.reference > fb_ctrs_t0.reference) { >> + delta_reference = fb_ctrs_t1.reference - fb_ctrs_t0.reference; >> + } else { > There should be another if () here to check if the reference counters are equal. > We cannot assume, there was a overflow when the counters are equal. As I > mentioned on last patch, the counters *may* pause in idle states. My Bad... I somehow, over looked that point. In case of delta_reference being zero there is actually a check below to avoid divide-by-zero. There I returned reference perf instead of desired perf, same I will take care in v3. Isn't that sufficient or is there a need for an explicit check here for delta = zero? Moreover the delta calculation am planning to replace with single line comparison in v3 for both normal and overflow case. >> + /* >> + * Counters would have wrapped-around >> + * We also need to find whether the low level fw >> + * maintains 32 bit or 64 bit counters, to calculate >> + * the correct delta. >> + */ >> + if (fb_ctrs_t0.reference > (~(u32)0)) >> + delta_reference = (~((u64)0) - fb_ctrs_t0.reference) + >> + fb_ctrs_t1.reference; >> + else >> + delta_reference = (~((u32)0) - fb_ctrs_t0.reference) + >> + fb_ctrs_t1.reference; >> + } >> + >> + if (fb_ctrs_t1.delivered > fb_ctrs_t0.delivered) { >> + delta_delivered = fb_ctrs_t1.delivered - fb_ctrs_t0.delivered; >> + } else { >> + /* >> + * Counters would have wrapped-around >> + * We also need to find whether the low level fw >> + * maintains 32 bit or 64 bit counters, to calculate >> + * the correct delta. >> + */ >> + if (fb_ctrs_t0.delivered > (~(u32)0)) >> + delta_delivered = (~((u64)0) - fb_ctrs_t0.delivered) + >> + fb_ctrs_t1.delivered; >> + else >> + delta_delivered = (~((u32)0) - fb_ctrs_t0.delivered) + >> + fb_ctrs_t1.delivered; >> + } >> + >> + if (delta_reference) /* Check to avoid divide-by zero */ >> + delivered_perf = (reference_perf * delta_delivered) / >> + delta_reference; >> + else >> + delivered_perf = reference_perf; > > If we cannot compute delivered performance then we should return > desired/requested perf and not reference_perf. > Noted!! >> + >> + return cppc_cpufreq_perf_to_khz(cpu, delivered_perf); >> +} >> + >> +static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum) >> +{ >> + struct cppc_perf_fb_ctrs fb_ctrs_t0 = {0}, fb_ctrs_t1 = {0}; >> + struct cppc_cpudata *cpu = all_cpu_data[cpunum]; >> + int ret; >> + >> + ret = cppc_get_perf_ctrs(cpunum, &fb_ctrs_t0); >> + if (ret) >> + return ret; >> + >> + udelay(2); /* 2usec delay between sampling */ >> + >> + ret = cppc_get_perf_ctrs(cpunum, &fb_ctrs_t1); >> + if (ret) >> + return ret; >> + >> + return cppc_get_rate_from_fbctrs(cpu, fb_ctrs_t0, fb_ctrs_t1); >> +} >> + >> static struct cpufreq_driver cppc_cpufreq_driver = { >> .flags = CPUFREQ_CONST_LOOPS, >> .verify = cppc_verify_policy, >> .target = cppc_cpufreq_set_target, >> + .get = cppc_cpufreq_get_rate, >> .init = cppc_cpufreq_cpu_init, >> .stop_cpu = cppc_cpufreq_stop_cpu, >> .name = "cppc_cpufreq", > > Thanks, > Prashanth > Thanks, -George