Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp441276rwl; Wed, 4 Jan 2023 22:43:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvlCwElEZlGu8KFXUNhckHLZDWAiYCHXslT1dSDwrrZFun13r0hrBIZcz8Tj5xuNV2DPX+ X-Received: by 2002:a50:d0d1:0:b0:478:be92:3384 with SMTP id g17-20020a50d0d1000000b00478be923384mr46421263edf.14.1672901033348; Wed, 04 Jan 2023 22:43:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672901033; cv=pass; d=google.com; s=arc-20160816; b=BMp9kw7JB4gY/SBKwrW8IR79Lz+7WLvnesfv4pbjIhpNOHZ2kFM7A9qXd2IkOrZT4O VvOnuMr87G0ZJADNK6Z9qck29flJOfTMmUSehr3KxvZLj3tB9Xvx43gGt2qgVFSpGCGF MK46OOPPisp9iqZMHdorgfmpHoCuhwcxsfrRtt9y928UBkevf6MmNhn0rpsEpgFcU0dV SZjE0lHbOtPLJpVN0mwnvsqHWLj9a54h3Ou4LjWbE24YzJakCz0rECAoMk+I5O1TKtcK nDQYmCsJj920+6PXQ9Bir4CtBIJWt+8uhmGEFemH/b+M4y8zPCS0IixoxNrAxJZpEIZL b7gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=UEuyPcoZqgW0ysZK/80Vj5OYuGqkTV0vR76ZGWf4W9A=; b=ki2Wzbq069JYrMDLZzfsYl27SlNWY+QhdIs28svbuhjyti5eUyQn+UVRo2tKN4hhZ0 2L7G0BDm17VGOkSw7Q16urGlGcMXiUJH8hRr9Z/2NNKysnsK/vreH7rKoqOGc2Jm617q mRrAO/fxavzVXdRT7NF3YQkJ4fKDGLEltQ9R6BbL087JThXHKSa+TgDHKBWnChKc/rjf kUtg+KtUcMjZ8KUchRrytcPYSkFovDzeIItUC6TlRqrdvpG5o7lkhOKJUAegqf+WNuXp zBjmCbHPle3uNfQM6hOjWgYmyrc4TX5+L7GDhsMGdZrpjZlB/J7JoLHNa+FYJEtvIVxi tbxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rRtB6aWr; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020a05640226cd00b0046ac13261a1si37224624edd.459.2023.01.04.22.43.40; Wed, 04 Jan 2023 22:43:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rRtB6aWr; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbjAEGCW (ORCPT + 55 others); Thu, 5 Jan 2023 01:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjAEGCU (ORCPT ); Thu, 5 Jan 2023 01:02:20 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2074.outbound.protection.outlook.com [40.107.93.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90F8348833; Wed, 4 Jan 2023 22:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OUP9haITFkk0VwJ7cOysBy4cGVG8QCtXXDQu8DUtxcR/0qlYWRJNrRan+KHNvKgvPM+JM3PCbZ1QQSPuLr6ZKIP6j3NP8hl41RXrUwp2cauB+sDck4CCJZaFN3DGfGk4opOEA4lGz+bURnO8T0/oAP7f1M7oxVzHCJEcrPaRnrqWyD91hPcah2o2YIJzx0gEp84Zs2b8l1XX4xS8zLZsf/IzvJQ0gJQPUvuZ/GIo+N80RYFUul40fxcVCuDfvlt5j+eFQOFoZJK4Cu0d9cYndi/2MYuFr9GamgBl3B2zz4KBA8tGG4P9kz0vRY316rUnGKPx0Dt0zE1WgIF9WTls1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UEuyPcoZqgW0ysZK/80Vj5OYuGqkTV0vR76ZGWf4W9A=; b=PfCowHsQQ9EgoZY4dsDyjxdHvYw9Sp3m32Zlcnxzk3jeYLsPVC5dCuf0RDtesVG3vDrLG7c/LJAucQ3ynsqDxiMQ8DWVX6t3SZHvW0P7SOLwHrZzyVqVKe7NyFPW50DoVf2XnXN33a3524/NlRtvnGzlz4MAcmqgyz5HW+lTCZ2D4o2MQqUMhLSvb6Q62KoNiGgw7B+i8BNg6OP8Tf0eQZ61J1qhqDmam3AtbTXXnRZt1EZk9wCwimqq5Ohd5EGaEy+OreJWig9T3fx56hWynTlfNdKUyriWKAbPgOCwS22QDNmyQdr/MHZNqQT0Fkf9w0NEZRbOMOU3i6ud1D1c7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UEuyPcoZqgW0ysZK/80Vj5OYuGqkTV0vR76ZGWf4W9A=; b=rRtB6aWrMes/czXV5YT1PGPFzz9s3uV5+XB/Bsn6mc5UfMj6gmQXaKLdTCkxzwOdkH7rYST2SbxHvZBlVUU3Q1jchiMXHd+T/rHhcareLnVW8ChS7BEDLno90/XGPItpDZ7agGKhYDFoPUZln1hu8NivxEHCZShvM3bdRir8Uao= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BY5PR12MB3876.namprd12.prod.outlook.com (2603:10b6:a03:1a7::26) by IA0PR12MB8352.namprd12.prod.outlook.com (2603:10b6:208:3dd::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 06:02:17 +0000 Received: from BY5PR12MB3876.namprd12.prod.outlook.com ([fe80::45ef:724b:4b64:b98]) by BY5PR12MB3876.namprd12.prod.outlook.com ([fe80::45ef:724b:4b64:b98%3]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 06:02:17 +0000 Message-ID: <6bf69386-3e8d-d820-de38-38a1bbe987fc@amd.com> Date: Thu, 5 Jan 2023 11:32:05 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v9 09/13] cpufreq: amd-pstate: add driver working mode switch support Content-Language: en-US To: Perry Yuan , rafael.j.wysocki@intel.com, Mario.Limonciello@amd.com, ray.huang@amd.com, viresh.kumar@linaro.org Cc: Deepak.Sharma@amd.com, Nathan.Fontenot@amd.com, Alexander.Deucher@amd.com, Shimmer.Huang@amd.com, Xiaojian.Du@amd.com, Li.Meng@amd.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221225163442.2205660-1-perry.yuan@amd.com> <20221225163442.2205660-10-perry.yuan@amd.com> From: Wyes Karny In-Reply-To: <20221225163442.2205660-10-perry.yuan@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN2PR01CA0187.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:e8::14) To BY5PR12MB3876.namprd12.prod.outlook.com (2603:10b6:a03:1a7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR12MB3876:EE_|IA0PR12MB8352:EE_ X-MS-Office365-Filtering-Correlation-Id: 73dd7eaa-fde2-4368-0004-08daeee26632 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: efAWl1rV5TCFvnxxxX5BGEX7l9qnOB5iDa6BlSXokiwuxoN3kmYaxwqRRIUkgEF4s48ma8z4nEMBrsGs40PhEJvUums8zdmUUw+0ifNEyTbzcYgch6JwlPELmfJcgiG8uQzgc+xtHrNSQxTbx822uR0IUOWLR9rbipz2ZP+IQ4AuyvjcHDOrIa314KYxKWZV7ldZjDAzDjZOjuMNq+20f3aZ4HF/RWsB0p0N++wlwSOGo+7MwA9dyB6CqvEPzZSRyqIO3C7bLQniyT5fVy8M5Wd01a6GexDN4Bx7fmZXyY8+o5xPJ9kMEDrjawS9uRBT3wHcLuBQuFS5aUJ6qKtXjNt9dhLk5h6jsvb2c+BMn+pjouWla1tOkYjnMr0flr4PRb9JozEXE+1EohnZBtvOPL1CYsg2xaN3O6i4O+OmJ1VzONSOD/KXYKUpllWIMKKSLIYY7rOpLap4hxiPDXlEtQYW8BQpVzDoNGDNw6xQXQ1Vt91fsw4w+yeGwS5AAjgK1OUzEcp69XsfY3osU6Bs6sCpvAneFQ95zgDXCxyaRAL6NzExdK/a1JU+hLYhBdpk0KpH9NtI4QuLaDJeJNAbr+TOyIYzHwEoVv5EAl2UgG4BtQEsSYAocHpPvYBlheV9hVxOpYQXpyfPxxirU1dTIJDTwZkVFVyHRzS6nJbilaFqP60SP02sXXFHfRcrQsZkHqclpHvFQO2HkEpkjCKOaRmCqQ8Vde1t046UvjRB/yg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB3876.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(366004)(376002)(346002)(136003)(451199015)(83380400001)(86362001)(31696002)(8936002)(44832011)(5660300002)(38100700002)(41300700001)(2906002)(6666004)(4326008)(26005)(478600001)(6506007)(186003)(2616005)(53546011)(316002)(66476007)(6512007)(66946007)(6486002)(66556008)(31686004)(8676002)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MVpXTDFKZ2FPZHlWN0s2RmZFd2d0cUluVkFvSTBFajdCb2tHQktqUWVKZytu?= =?utf-8?B?ZGJqaE5uRmozTTB2bS9VNlBGVDNkT0RZaklZVkxsbmlxQUQ0dDd3bm1PV0RL?= =?utf-8?B?Y1NvaE1OS2hZSEwzTnI1WmtXaGZRSmRnTTk0ckRyYjVRN3ZxR0R5aEROUDl1?= =?utf-8?B?Z0JYZWhrOXoyWGFydWtPK1ZxZVIremNkMHorYVZhMkhkRlZESUNzOW9aVlJQ?= =?utf-8?B?Y0dwdGdOR3V2Mzcxb2hsVjlxa2d5dXB4SU4xQ2tFeE02R01BSUhYdmcyMHVG?= =?utf-8?B?cE9sSDM2Mnd6NUtlV3cyMGlmc3kySlByVC9VRi9SNU5yZW1hOUF0NE5HaDJo?= =?utf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QV?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73dd7eaa-fde2-4368-0004-08daeee26632 X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB3876.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 06:02:17.4199 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h1oivdNdu82qBC2BBo+TiOnVabO8G8gYdTdaIqEVN2N8dA1HL7K4RIbUBKsXWXCb7zAd8SZTrW8s6X3uIfA0XA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8352 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Perry, On 12/25/2022 10:04 PM, Perry Yuan wrote: > From: Perry Yuan > > While amd-pstate driver was loaded with specific driver mode, it will > need to check which mode is enabled for the pstate driver,add this sysfs > entry to show the current status > > $ cat /sys/devices/system/cpu/amd-pstate/status > active > > Meanwhile, user can switch the pstate driver mode with writing mode > string to sysfs entry as below. > > Enable passive mode: > $ sudo bash -c "echo passive > /sys/devices/system/cpu/amd-pstate/status" > > Enable active mode (EPP driver mode): > $ sudo bash -c "echo active > /sys/devices/system/cpu/amd-pstate/status" > > Signed-off-by: Perry Yuan > --- > drivers/cpufreq/amd-pstate.c | 118 +++++++++++++++++++++++++++++++++++ > 1 file changed, 118 insertions(+) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index e3676d1a85c7..8ceca4524fc1 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -63,6 +63,7 @@ static struct cpufreq_driver *default_pstate_driver; > static struct cpufreq_driver amd_pstate_driver; > static struct cpufreq_driver amd_pstate_epp_driver; > static int cppc_state = AMD_PSTATE_DISABLE; > +struct kobject *amd_pstate_kobj; > > static inline int get_mode_idx_from_str(const char *str, size_t size) > { > @@ -632,6 +633,8 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) > policy->driver_data = cpudata; > > amd_pstate_boost_init(cpudata); > + if (!default_pstate_driver->adjust_perf) > + default_pstate_driver->adjust_perf = amd_pstate_adjust_perf; > > return 0; > > @@ -772,12 +775,99 @@ static ssize_t show_energy_performance_preference( > return sysfs_emit(buf, "%s\n", energy_perf_strings[preference]); > } > > +static ssize_t amd_pstate_show_status(char *buf) > +{ > + if (!default_pstate_driver) > + return sysfs_emit(buf, "off\n"); IMO 'disable' is more consistent to cppc_state. > + > + return sysfs_emit(buf, "%s\n", amd_pstate_mode_string[cppc_state]); > +} > + > +static void amd_pstate_driver_cleanup(void) > +{ > + default_pstate_driver = NULL; > +} > + > +static int amd_pstate_update_status(const char *buf, size_t size) > +{ > + int ret; > + int mode_idx; > + > + if (size > 7 || size < 3) > + return -EINVAL; > + mode_idx = get_mode_idx_from_str(buf, size); > + > + switch(mode_idx) { > + case AMD_PSTATE_DISABLE: > + if (!default_pstate_driver) > + return -EINVAL; > + if (cppc_state == AMD_PSTATE_ACTIVE) > + return -EBUSY; > + ret = cpufreq_unregister_driver(default_pstate_driver); > + amd_pstate_driver_cleanup(); > + break; > + case AMD_PSTATE_PASSIVE: > + if (default_pstate_driver) { > + if (default_pstate_driver == &amd_pstate_driver) > + return 0; > + cpufreq_unregister_driver(default_pstate_driver); > + cppc_state = AMD_PSTATE_PASSIVE; > + default_pstate_driver = &amd_pstate_driver; > + } > + > + ret = cpufreq_register_driver(default_pstate_driver); > + break; > + case AMD_PSTATE_ACTIVE: > + if (default_pstate_driver) { > + if (default_pstate_driver == &amd_pstate_epp_driver) > + return 0; > + cpufreq_unregister_driver(default_pstate_driver); > + default_pstate_driver = &amd_pstate_epp_driver; > + cppc_state = AMD_PSTATE_ACTIVE; > + } > + > + ret = cpufreq_register_driver(default_pstate_driver); > + break; > + default: > + break; > + ret = -EINVAL; > + } > + > + return ret; > +} The implementation of amd_pstate_update_status function is good as long as the possible states are less. Currently prev_state and next_state has 9 combinations. But with guided mode this becomes 16 combinations. Do you have any concerns if I optimize this function by creating a state transition table in guided patch series? > + > +static ssize_t show_status(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + ssize_t ret; > + > + mutex_lock(&amd_pstate_driver_lock); > + ret = amd_pstate_show_status(buf); > + mutex_unlock(&amd_pstate_driver_lock); > + > + return ret; > +} > + > +static ssize_t store_status(struct kobject *a, struct kobj_attribute *b, > + const char *buf, size_t count) > +{ > + char *p = memchr(buf, '\n', count); > + int ret; > + > + mutex_lock(&amd_pstate_driver_lock); > + ret = amd_pstate_update_status(buf, p ? p - buf : count); > + mutex_unlock(&amd_pstate_driver_lock); > + > + return ret < 0 ? ret : count; > +} > + > cpufreq_freq_attr_ro(amd_pstate_max_freq); > cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); > > cpufreq_freq_attr_ro(amd_pstate_highest_perf); > cpufreq_freq_attr_rw(energy_performance_preference); > cpufreq_freq_attr_ro(energy_performance_available_preferences); > +define_one_global_rw(status); > > static struct freq_attr *amd_pstate_attr[] = { > &amd_pstate_max_freq, > @@ -795,6 +885,15 @@ static struct freq_attr *amd_pstate_epp_attr[] = { > NULL, > }; > > +static struct attribute *pstate_global_attributes[] = { > + &status.attr, > + NULL > +}; > + > +static const struct attribute_group amd_pstate_global_attr_group = { > + .attrs = pstate_global_attributes, > +}; > + > static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) > { > int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret; > @@ -1154,6 +1253,25 @@ static int __init amd_pstate_init(void) > if (ret) > pr_err("failed to register with return %d\n", ret); > > + amd_pstate_kobj = kobject_create_and_add("amd-pstate", &cpu_subsys.dev_root->kobj); > + if (!amd_pstate_kobj) { > + ret = -EINVAL; > + pr_err("global sysfs registration failed.\n"); > + goto kobject_free; > + } > + > + ret = sysfs_create_group(amd_pstate_kobj, &amd_pstate_global_attr_group); > + if (ret) { > + pr_err("sysfs attribute export failed with error %d.\n", ret); > + goto global_attr_free; > + } > + > + return ret; > + > +global_attr_free: > + kobject_put(amd_pstate_kobj); > +kobject_free: > + cpufreq_unregister_driver(default_pstate_driver); > return ret; > } > device_initcall(amd_pstate_init); -- Thanks & Regards, Wyes