Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp606293pxb; Thu, 9 Sep 2021 08:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT2uZudk+bobKj9wd9d75XtQkWWLsGtFW7YVXQpIaVwBDt+jTmhQJEfzLDfkaxyFvm4z1y X-Received: by 2002:a5e:c807:: with SMTP id y7mr3045239iol.87.1631199911259; Thu, 09 Sep 2021 08:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631199911; cv=none; d=google.com; s=arc-20160816; b=Zp2jlcB0Gg8gbXmVTeg8TnHHE+Zx98VbhIjwpvFUZJ8gi21FTnv0XqPQNm40BXI1zP 1+AXnsfgBqIl/W0JRjq3U8Hk2ouoBXbF39xprjfoQKODGeCTOWl79nyJIYBhVaPiV5Hg JEtD2P4ecG0kDmczxHE+hiF1dz4aQ9YkFYNK+yPEf7Qah1vj0dELr5yWK15/YqQr4NsS DaNRnUC4DPt7xm8Uy2VWlOqchuI85xDChmE9x8Bo7ULJJeQvbVCJoZrZ6iTPF+2wPrWq 2YkAnsnBPUesaNYnUBBfWnv16kloxKa7A+rSVg/CKrJfOvy49BuM01nvB6L3loRmL7y4 R+Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/Y5MADjdN8PfBLXXdisZCNOGIKICg1o3R1wg6sLA0F0=; b=jM7MakOWz8T5pmcNpODyYnIzCljjnn4XbI2GB2W1u4o75VP9JFH7dgsmh0jBRq+nEW SWhsTZeJ/Pptxoxw8tZcPAHtjhGKoMyLp8uitHBGz5hcPeg67zm/uPp6MdVI8hxppJrK K3TZZvyGyD19L5hlTB2JZup7bchLpMOlHi21uNDyzVDWZE96owGH9b8O8YoyRn0woOtS Omq9B4ZYjkLz7mw1Z1tzKeEPgbMFRrQTufGPD/AjC1R5Pk+RGeXXrCeXczWriF1smKDX pGW5tSo9iNScuHWTeKI/IwI8JZEjZHejGO9ilW96jwVom/mn/LRSyHqJMD4BhTcYwxTQ DnjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=n0r32pBA; 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 c8si1690885iot.67.2021.09.09.08.04.30; Thu, 09 Sep 2021 08:05:11 -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; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=n0r32pBA; 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 S240681AbhIIPDJ (ORCPT + 99 others); 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-kernel@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?