Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3371474ybt; Tue, 23 Jun 2020 00:08:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO0p+cr/Y/eWBBepL+R+oTRFlW6vH/KWGOZKLJ+3DZDDjEwrvzB74JQ8y52Ftlae9L4KpP X-Received: by 2002:a50:d785:: with SMTP id w5mr19966542edi.212.1592896090542; Tue, 23 Jun 2020 00:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592896090; cv=none; d=google.com; s=arc-20160816; b=ZtEmqhHZwXwpvrh2naIniNnTgRsXAn5IgeJ7yUXkuSMdTE8AYvLz3GgSPd9mILIwXH PLd8TrcggrYDTBn3WfgfLu7S2LfLaIGpciIHFtOoYRA4pvcs5SBZsBtUGdcMo6rnl5Yp bTFfxkBDmegrDDvt1uHgGyUusGoFhspkThwdz7PJ0Tui/Fw0TlxbJ8EB0gu68gZRzAH/ 2Z5fqC+p3+5WK2kENouFb5n4SRMdleQctTadth+YrMFD0SKfiyLIgyTbyMuF4C2mHr8d C3E+M7iLB8f0lWumqfiKfE8yfrPHByovEiOOcnK4nXPghT4YvNCHMWDWvTN+mlQCh+FI zBqQ== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=8Dik++wrK2R9Fge9PyS0k1CcQKqtHqQXrlOOoqwhCHs=; b=r8GwcKBczdzfYzLxlG07SO5KHiHhhPj4sIWR0c+5CstEskmYvTZQcNtwndckYmN+Ri mNh7QGfkJSK5VC4FdwjewmMvq3NxU/tiNG8SzlU3ssHvJOAzz3Q+l/lSToz/1B9R2Grx zOIX9RSwO4Sd44lCnCgf0luO2MtzEI1P8c5lLJ2BbrbYtBfuOxeXp4NlOMMgtLz3ROgO b+WijBquPW2ryWa50nVU+E9liJmwwAqvWmwGKYOOMvAXvp8qt5VsQ+iy3vJVuJPqQWpT waj07VrfiUEaHc7Hcp1xMMnBVprY4aWgIIzS7URnVyeBggal9xLz9BOeKnIHXry+Uk9y pWGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y27si3936791eje.284.2020.06.23.00.07.48; Tue, 23 Jun 2020 00:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730928AbgFWHEH (ORCPT + 99 others); Tue, 23 Jun 2020 03:04:07 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6386 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730765AbgFWHEH (ORCPT ); Tue, 23 Jun 2020 03:04:07 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 14EE8C2AE916BDDE6F2F; Tue, 23 Jun 2020 15:04:05 +0800 (CST) Received: from [127.0.0.1] (10.166.215.101) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Tue, 23 Jun 2020 15:03:59 +0800 Subject: Re: [PATCH] cpufreq: cppc: Reorder code and remove apply_hisi_workaround variable To: Viresh Kumar , Rafael Wysocki CC: , Vincent Guittot , References: From: Xiongfeng Wang Message-ID: Date: Tue, 23 Jun 2020 15:03:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.166.215.101] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Viresh, On 2020/6/23 13:15, Viresh Kumar wrote: > With the current approach we have an extra check in the > cppc_cpufreq_get_rate() callback, which checks if hisilicon's get rate > implementation should be used instead. While it works fine, the approach > isn't very straight forward, over that we have an extra check in the > routine. > > Rearrange code and update the cpufreq driver's get() callback pointer > directly for the hisilicon case. This gets the extra variable is removed > and the extra check isn't required anymore as well. > > Signed-off-by: Viresh Kumar > --- > Xiongfeng Wang, will it be possible for you to give this a try as I > can't really test it locally. I have tested it on D05. It works well. Tested-by: Xiongfeng Wang Thanks, Xiongfeng > > drivers/cpufreq/cppc_cpufreq.c | 91 ++++++++++++++++------------------ > 1 file changed, 42 insertions(+), 49 deletions(-) > > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c > index 257d726a4456..03a21daddbec 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -45,8 +45,6 @@ struct cppc_workaround_oem_info { > u32 oem_revision; > }; > > -static bool apply_hisi_workaround; > - > static struct cppc_workaround_oem_info wa_info[] = { > { > .oem_id = "HISI ", > @@ -59,50 +57,6 @@ static struct cppc_workaround_oem_info wa_info[] = { > } > }; > > -static unsigned int cppc_cpufreq_perf_to_khz(struct cppc_cpudata *cpu, > - unsigned int perf); > - > -/* > - * HISI platform does not support delivered performance counter and > - * reference performance counter. It can calculate the performance using the > - * platform specific mechanism. We reuse the desired performance register to > - * store the real performance calculated by the platform. > - */ > -static unsigned int hisi_cppc_cpufreq_get_rate(unsigned int cpunum) > -{ > - struct cppc_cpudata *cpudata = all_cpu_data[cpunum]; > - u64 desired_perf; > - int ret; > - > - ret = cppc_get_desired_perf(cpunum, &desired_perf); > - if (ret < 0) > - return -EIO; > - > - return cppc_cpufreq_perf_to_khz(cpudata, desired_perf); > -} > - > -static void cppc_check_hisi_workaround(void) > -{ > - struct acpi_table_header *tbl; > - acpi_status status = AE_OK; > - int i; > - > - status = acpi_get_table(ACPI_SIG_PCCT, 0, &tbl); > - if (ACPI_FAILURE(status) || !tbl) > - return; > - > - for (i = 0; i < ARRAY_SIZE(wa_info); i++) { > - if (!memcmp(wa_info[i].oem_id, tbl->oem_id, ACPI_OEM_ID_SIZE) && > - !memcmp(wa_info[i].oem_table_id, tbl->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && > - wa_info[i].oem_revision == tbl->oem_revision) { > - apply_hisi_workaround = true; > - break; > - } > - } > - > - acpi_put_table(tbl); > -} > - > /* Callback function used to retrieve the max frequency from DMI */ > static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private) > { > @@ -402,9 +356,6 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum) > struct cppc_cpudata *cpu = all_cpu_data[cpunum]; > int ret; > > - if (apply_hisi_workaround) > - return hisi_cppc_cpufreq_get_rate(cpunum); > - > ret = cppc_get_perf_ctrs(cpunum, &fb_ctrs_t0); > if (ret) > return ret; > @@ -455,6 +406,48 @@ static struct cpufreq_driver cppc_cpufreq_driver = { > .name = "cppc_cpufreq", > }; > > +/* > + * HISI platform does not support delivered performance counter and > + * reference performance counter. It can calculate the performance using the > + * platform specific mechanism. We reuse the desired performance register to > + * store the real performance calculated by the platform. > + */ > +static unsigned int hisi_cppc_cpufreq_get_rate(unsigned int cpunum) > +{ > + struct cppc_cpudata *cpudata = all_cpu_data[cpunum]; > + u64 desired_perf; > + int ret; > + > + ret = cppc_get_desired_perf(cpunum, &desired_perf); > + if (ret < 0) > + return -EIO; > + > + return cppc_cpufreq_perf_to_khz(cpudata, desired_perf); > +} > + > +static void cppc_check_hisi_workaround(void) > +{ > + struct acpi_table_header *tbl; > + acpi_status status = AE_OK; > + int i; > + > + status = acpi_get_table(ACPI_SIG_PCCT, 0, &tbl); > + if (ACPI_FAILURE(status) || !tbl) > + return; > + > + for (i = 0; i < ARRAY_SIZE(wa_info); i++) { > + if (!memcmp(wa_info[i].oem_id, tbl->oem_id, ACPI_OEM_ID_SIZE) && > + !memcmp(wa_info[i].oem_table_id, tbl->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && > + wa_info[i].oem_revision == tbl->oem_revision) { > + /* Overwrite the get() callback */ > + cppc_cpufreq_driver.get = hisi_cppc_cpufreq_get_rate; > + break; > + } > + } > + > + acpi_put_table(tbl); > +} > + > static int __init cppc_cpufreq_init(void) > { > int i, ret = 0; >