From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F2CC433EF for ; Thu, 9 Sep 2021 15:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13AD360F24 for ; Thu, 9 Sep 2021 15:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240266AbhIIPDJ (ORCPT ); Thu, 9 Sep 2021 11:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236843AbhIIPDE (ORCPT ); Thu, 9 Sep 2021 11:03:04 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DA0C061575; Thu, 9 Sep 2021 08:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/Y5MADjdN8PfBLXXdisZCNOGIKICg1o3R1wg6sLA0F0=; b=n0r32pBAY1IV9h2w7DoeJMyOoS H1Rzt3uYTOlPQMqb6PcKGFYj7Dny0GAtWGm26Cvk+BNSHpAHOF3wSOaZZ11F0o0NwUcE7iK/8RvIK Fn5DWktzPwzi/oeVOBQpSB8Tdv5qwyzV/xovHdUrVgc0SfiL8IW7P+R8mN/zt0j6YNxV9IPLJabG+ zm0KJLt+3y/nrrW2G47diDSC8/AyVLeGM9AOzRZaNlYXIjq+FDt+dDpSXr/y50lfaqZ4B8moxgUm8 IcKz9DYX15I29Y/oPAv3iJ9SthEsSAlwNlzjphTEHQLrjb/MBthxEedADbaB7zuRmtsx4M551+6uL Sm8VwI8g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOLYc-001tWu-Rb; Thu, 09 Sep 2021 15:01:43 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D7CA130004C; Thu, 9 Sep 2021 17:01:41 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BFB5E20C09044; Thu, 9 Sep 2021 17:01:41 +0200 (CEST) Date: Thu, 9 Sep 2021 17:01:41 +0200 From: Peter Zijlstra To: Huang Rui Cc: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , Borislav Petkov , Ingo Molnar , linux-pm@vger.kernel.org, Deepak Sharma , Alex Deucher , Mario Limonciello , Nathan Fontenot , Jinzhou Su , Xiaojian Du , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 04/19] cpufreq: amd: introduce a new amd pstate driver to support future processors Message-ID: References: <20210908150001.3702552-1-ray.huang@amd.com> <20210908150001.3702552-5-ray.huang@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210908150001.3702552-5-ray.huang@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Wed, Sep 08, 2021 at 10:59:46PM +0800, Huang Rui wrote: > +struct amd_pstate_perf_funcs { > + int (*enable)(bool enable); > + int (*init_perf)(struct amd_cpudata *cpudata); > + void (*update_perf)(struct amd_cpudata *cpudata, > + u32 min_perf, u32 des_perf, > + u32 max_perf, bool fast_switch); > +}; > +static int > +amd_pstate_enable(struct amd_pstate_perf_funcs *funcs, bool enable) > +{ > + if (!funcs) > + return -EINVAL; > + > + return funcs->enable(enable); > +} > +static int amd_pstate_init_perf(struct amd_cpudata *cpudata) > +{ > + struct amd_pstate_perf_funcs *funcs = cpufreq_get_driver_data(); > + > + if (!funcs) > + return -EINVAL; > + > + return funcs->init_perf(cpudata); > +} > +static int > +amd_pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf, > + u32 des_perf, u32 max_perf, bool fast_switch) > +{ > + struct amd_pstate_perf_funcs *funcs = cpufreq_get_driver_data(); > + > + if (!funcs) > + return -EINVAL; > + > + funcs->update_perf(cpudata, min_perf, des_perf, > + max_perf, fast_switch); > + > + return 0; > +} > +static struct amd_pstate_perf_funcs pstate_funcs = { > + .enable = pstate_enable, > + .init_perf = pstate_init_perf, > + .update_perf = pstate_update_perf, > +}; > +static int __init amd_pstate_init(void) > +{ > + int ret; > + struct amd_pstate_perf_funcs *funcs; > + > + funcs = &pstate_funcs; What is the purpose of this seemingly pointless indirection? Showing off how good AMD hardware is at doing retpolines or something?