Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp196707imj; Thu, 14 Feb 2019 18:27:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IaXtCwmEerxTzCjR2e6jNLpKLQ6HEdOIdyc2NHaIO1SCfgLycjrX0WfdpWWih32qiWKsOvB X-Received: by 2002:a63:3548:: with SMTP id c69mr3113549pga.256.1550197675436; Thu, 14 Feb 2019 18:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197675; cv=none; d=google.com; s=arc-20160816; b=cRWbVt0GarXopOrL/oHvSqiIps6dsitiBZJApsxnKIEBxqsfDcgsr4TCkYtTx54StG qtA/XUdipxicLqpZexALnm9zHx/8lihH+SnUH9yfH+WPimdWHj5pclExr5Rmg4rfCkbL V6hioRb3cKBJA/UiJaHcQYoqF35XI7T3gxcUlsT2rnUNRCdoNSXMA/c9NvfBX9W9v+I7 B4wl+uT+U4KdUTmT35Z6f2DskvICWEb5gJ2flmsFgSCafjTHOLzqE3BBeLRW7iipesHi +iwyP0QkorFztdfs3/rq4p5LKlJEDCOfu1I2yShxBIu3U0c3TzLBBExirexii346Taeq 7/wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=bxt2mJd6RA5/GCOQ7JgfSGRbmuXVw+EPo+wc7OYQmzU=; b=PEh2OKynG1hBy7Gr5u921o7Q6d1i72tGkHjus1b6m8lYvYAcvaeVn6qJ/lxLD5mv92 /be0QDHW5scDI6XCaNz18VU7dv+v53ZFD2dnk8kOPDHWo+/H20YWvH3HCpOmHl8CcDPe kbeWLlPWUhzsdvIs7nibkU31dcEGmWkKPfgO24SmJgD623NXi1DonveuSIQQa/H0twGA E52VGvSNagwNFgMv+Fu5VyRhl8e+E4v8vts/ZA5rLulvPa8QPFqUNyqw6jM7I+zQYBw1 MRYL0S1SlunI7WN8hz3q8hzpdyQ8KRayMjeR6sYKd1gyBhlLEnvVY/CuM0VRIO0oS6Pt EkNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 s2si4087296plp.380.2019.02.14.18.27.39; Thu, 14 Feb 2019 18:27:55 -0800 (PST) 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; 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 S1730705AbfBOBZe (ORCPT + 99 others); Thu, 14 Feb 2019 20:25:34 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:52022 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725939AbfBOBZd (ORCPT ); Thu, 14 Feb 2019 20:25:33 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 32509802DB9B8445CEDB; Fri, 15 Feb 2019 09:25:31 +0800 (CST) Received: from [127.0.0.1] (10.184.52.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Fri, 15 Feb 2019 09:25:23 +0800 Subject: Re: [PATCH v2 2/2] cpufreq / cppc: Work around for Hisilicon CPPC cpufreq To: "Rafael J. Wysocki" CC: "Rafael J. Wysocki" , Viresh Kumar , , Prashanth Prakash , George Cherian , "Robert Moore" , ACPI Devel Maling List , Linux Kernel Mailing List , Hanjun Guo , John Garry References: <1550130368-60513-1-git-send-email-wangxiongfeng2@huawei.com> <86a1eddc-01aa-f32a-9bef-c18c7649149b@huawei.com> <2813657.1l3PCoQO4Z@aspire.rjw.lan> From: Xiongfeng Wang Message-ID: <8baf1617-6037-2645-bc8a-a6dcf8f7f53b@huawei.com> Date: Fri, 15 Feb 2019 09:25:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <2813657.1l3PCoQO4Z@aspire.rjw.lan> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.52.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/2/15 7:15, Rafael J. Wysocki wrote: > On Thursday, February 14, 2019 2:58:21 PM CET Xiongfeng Wang wrote: >> >> On 2019/2/14 18:58, Rafael J. Wysocki wrote: >>> On Thu, Feb 14, 2019 at 8:46 AM Xiongfeng Wang >>> wrote: >>>> >>>> Hisilicon chips do not support delivered performance counter register >>>> and reference performance counter register. But the platform can >>>> calculate the real performance using its own method. This patch provide >>>> a workaround for this problem, and other platforms can also use this >>>> workaround framework. We reuse the desired performance register to >>>> store the real performance calculated by the platform. After the >>>> platform finished the frequency adjust, it gets the real performance and >>>> writes it into desired performance register. OS can use it to calculate >>>> the real frequency. >>>> >>>> Signed-off-by: Xiongfeng Wang >>>> --- >>>> drivers/cpufreq/cppc_cpufreq.c | 70 ++++++++++++++++++++++++++++++++++++++++++ >>>> 1 file changed, 70 insertions(+) >>>> >>>> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c >>>> index fd25c21c..da96fec 100644 >>>> --- a/drivers/cpufreq/cppc_cpufreq.c >>>> +++ b/drivers/cpufreq/cppc_cpufreq.c >>>> @@ -33,6 +33,16 @@ >>>> /* Offest in the DMI processor structure for the max frequency */ >>>> #define DMI_PROCESSOR_MAX_SPEED 0x14 >>>> >>>> +struct cppc_workaround_info { >>>> + char oem_id[ACPI_OEM_ID_SIZE +1]; >>>> + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1]; >>>> + u32 oem_revision; >>>> + unsigned int (*get_rate)(unsigned int cpu); >>>> +}; >>>> + >>>> +/* CPPC workaround for get_rate callback */ >>>> +unsigned int (*cppc_wa_get_rate)(unsigned int cpu); >>>> + >>> >>> First off, please don't split the workaround material into two parts. >>> IOW, the other new function added below can go here just fine IMO. >>> >>>> /* >>>> * These structs contain information parsed from per CPU >>>> * ACPI _CPC structures. >>>> @@ -334,6 +344,9 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum) >>>> struct cppc_cpudata *cpu = all_cpu_data[cpunum]; >>>> int ret; >>>> >>>> + if (cppc_wa_get_rate) >>>> + return cppc_wa_get_rate(cpunum); >>> >>> Second, what is the value of using the function pointer above? >>> >>> All we need for now is a flag to indicate whether or not to call >>> hisi_cppc_cpufreq_get_rate() here and return its return value. >> >> How about adding a pointer of 'struct cppc_workaround_info' to indicate whether we have >> found a matches workaround ? >> If I use a flag, I will need another variable to indicate which item of the workaround array 'wa_info' >> to use. > > And why do you need to distinguish one of them from the other? > I was thinking about future extension. Different platform may have different implementation of 'get_rate' in the future. > > . >