Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3380236pxb; Fri, 5 Nov 2021 14:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpsAhJMmL31eo/ieOdn34hGm31YOuYAYjj0xKrkdsGnb+is3AzzW7gI6MKhJE3NjEEja8D X-Received: by 2002:a05:6e02:1051:: with SMTP id p17mr31502911ilj.220.1636148944340; Fri, 05 Nov 2021 14:49:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1636148944; cv=pass; d=google.com; s=arc-20160816; b=lMBTKbtEtwCGKuCEODHEHghf9I/Rp4y5vLANz7K827vS9kX3hF56JuNRGL8BY2hMqC o5iV8/NpwQr5IW1/YoBOKoUitXRe+AG9aEX3m44Ir2umjI0u1Q3vx22wEkbvRnyxyNhM YQfW1Z8sWvZQiKwGcm+KGeP6zITShI71oReAoHhqydPhv7QWpiE+csQvv19LiQtruOoE YGtS9+peZ8UkQJq0lNLSPscOh30NptnPvbfHVno3VLE4qUz5s0zcB+/LzqGdFyIv/jfL bpl2j5S8ND/TMJFZAbjdBPvDbhF0+EikroQChDXcdWtEm9xSPU0LAtuub22LLZGln+b5 WKPw== 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 :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=YO3jW5UGO3jTwT1zRqy6iYCaOW75+BKWpRIAJdOPMGg=; b=kWq7qjF37r+T5bBt21wKMB+WMvdk7ZqEXaozkvwnYbVIjpWZRUxb6geQzl4gxKlLZi 2ji+gUbUwJUYEpMYgPfRzb+lDcpaf8unGMTFE+OAIxuBqSRwbtdW1+5P2+C0iV3YYVFx dbZGyDfNGDjbe0mVAtfs/gmWlh8OxuOc4V4n90W5RX+jenuEw7k5KYgARLvXe2F0apVq uxlTsoAWhO39s6YP3NIseFRZkZER9E8d/4m6P02fHfVZQIGiLXuKfv6L/3UU/jvgCaZu oHf1ajMkFiF01DPvB8sGDDeC5DhRcCRnOQ80PsX+GHUBDtujlbtAnU+4d9adthnlEFqz Tr2A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=4GdDwHNt; 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 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si18749958jak.99.2021.11.05.14.48.50; Fri, 05 Nov 2021 14:49:04 -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=@amd.com header.s=selector1 header.b=4GdDwHNt; 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 23.128.96.18 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 S233192AbhKETCn (ORCPT + 99 others); Fri, 5 Nov 2021 15:02:43 -0400 Received: from mail-dm6nam11on2062.outbound.protection.outlook.com ([40.107.223.62]:2016 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233172AbhKETCl (ORCPT ); Fri, 5 Nov 2021 15:02:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GN2ERHBroIsz2+heFcy3KmQamIOsCwodin0n2CI2zezySo07UAaj8CEBb58CICUp6dyL9pjbA4AFea3+CBjtVUBEf32E/VKEiRu2EOabhMcOzV+Qc5G+gDKXmkIgFdpB94ADWscqKiL5/qZOLRxKV6tGsFbkIDZKCl/2CnfE6nkcAK71EUXoeAWTsWRNlXkJDzFaHprbwkYk1zUUvvMCzVZ07vqXkepWcEdZkudr6E55e8bo+ra8DZ0ontah8eCDKzKH4cYEfizcfAl2GA/dh/l3hGY/986YzoU6BO3mjVcHYcJLUbSU7h858+7yOdWvSIGTSM33b4BFFwhtOE0R6g== 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=YO3jW5UGO3jTwT1zRqy6iYCaOW75+BKWpRIAJdOPMGg=; b=T5VBl5hcZpkFXYKwLEzYdMAWqwiJAvvppdD/6BqXBG8jOCZj8fxao0YZXelRTDKGy2+2PKZ4kRljXJshbbUja37jWA6gvnh6y2cgsn715ojKqeakatnUIjfbA5VTa/ntLsUMS3S3U38HX/5iBJX1vqdzy4wdMrcmwJ0JohjnwsMRhPWcjaCHV1e7iOH8vHEvtExzBNayAP00Aod0RC6T0S1I7vCXcEp1//u2GNgPk5xMpwrwmSrfpZefwmCKt4JBXipMwkC2H1+ZDe97caytBlazawilFPbPsPyQWbAIBJ92uP8+yKbElzuPLlPuITkAPcm5/1ycBOGsMnCgCyQCnQ== 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=YO3jW5UGO3jTwT1zRqy6iYCaOW75+BKWpRIAJdOPMGg=; b=4GdDwHNtSiu/ESzVttly5VlR3FSp/SofiEsDgpOstm0zY1drKb+JoH/3D4ovG6ye/4JgMXCiAs+obHEam2WubPvQ3Hlpx+yhpMwPRs0k8X+ZedRQSqzVDc5u84ktJ8bk6ViRLKyUkO28pR5X3DJ1N22gJq7HB4ypZ/wNpl9+M7s= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) by SN6PR12MB2798.namprd12.prod.outlook.com (2603:10b6:805:69::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Fri, 5 Nov 2021 18:59:59 +0000 Received: from SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::c4b9:b9bb:e863:af39]) by SN6PR12MB4720.namprd12.prod.outlook.com ([fe80::c4b9:b9bb:e863:af39%5]) with mapi id 15.20.4669.013; Fri, 5 Nov 2021 18:59:58 +0000 Subject: Re: [PATCH v3 11/21] cpufreq: amd: add amd-pstate frequencies attributes To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , Borislav Petkov , Peter Zijlstra , Ingo Molnar , Giovanni Gherdovich , linux-pm@vger.kernel.org Cc: Deepak Sharma , Alex Deucher , Mario Limonciello , Steven Noonan , Nathan Fontenot , Jinzhou Su , Xiaojian Du , linux-kernel@vger.kernel.org, x86@kernel.org References: <20211029130241.1984459-1-ray.huang@amd.com> <20211029130241.1984459-12-ray.huang@amd.com> From: Nathan Fontenot Message-ID: Date: Fri, 5 Nov 2021 13:59:55 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <20211029130241.1984459-12-ray.huang@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BN6PR11CA0057.namprd11.prod.outlook.com (2603:10b6:404:f7::19) To SN6PR12MB4720.namprd12.prod.outlook.com (2603:10b6:805:e6::31) MIME-Version: 1.0 Received: from [IPv6:2600:1700:271:b60:ca47:7240:2ff:8536] (2600:1700:271:b60:ca47:7240:2ff:8536) by BN6PR11CA0057.namprd11.prod.outlook.com (2603:10b6:404:f7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 18:59:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de0142fa-fd83-46cc-cedc-08d9a08e76b4 X-MS-TrafficTypeDiagnostic: SN6PR12MB2798: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ynA2H8UgXzH7jfz7RRZAjXHcoPu46LMPJd/YcOxBlsgpmln2G+YjfWbl67IWy08rPklMYI2RCaSl481RNBiSStD25Qx5ORAMn4yH4alguHnDRYzXV0c1VbzDTfCdd8+Y2ipx88APUD2J2cXF+tesyUAzhBEHPMgwXAAOGX/ZrROgDL6Oh+ib4pO7ygaqqCBIIbLGjtSzQ4pHjxnKm/Tx9QneRtu6YvdGiUZB+i4O3L2tyBdmXdqECQddrmkg0cSnlC9COLqIODxajN+VyMPh9sCTtP7kqEQ2KBk+ePcsNPPnzaMpXM2tbqdxiDKCPWEHmWNtw/EiJ2dLJOFwJDPruKmR4xngFtM+cWDgwLTpbCZ5J2dY//JJ+qlZNc+pSun+EBmWfO89y5zEwuW3Rd0LuPVp1hz/ak6D4fcfvQE4Gt7olZAvznNxXPUU8JQ4DHB6jTr37XXoZ1btX5+8p9yBbE9vN/1QwQT/6XMK0U+dO9UEBKy1wgmn89r1UmwiiYQ+oIOC+9tROIHlfuZuJDgdIB430do2y54wQrCaK+MHBaX/jznWkf9DdCM2PexaTf1z22HfpIJ441Y5xv+rN6bNUT+S8TSu8UZvjrImX+LXXWm8cCyNsUmZVM7whKVfkF+Rcx1eWXZ7S1z4w09GMWZM801vVRSd7/smVxhcivIjvaphsCVdDJFH2nc1AaaONLFEZuoOIfAcVhIFFqL0GvX/VGyMJThxws67vEsu4yJ+xkCduCrfYHCubxVhkLgbU2TN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB4720.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(2616005)(8936002)(54906003)(110136005)(83380400001)(53546011)(316002)(8676002)(5660300002)(508600001)(38100700002)(31696002)(4326008)(7416002)(66556008)(66476007)(66946007)(2906002)(36756003)(6486002)(31686004)(186003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N2c1RXJTbUtkWUk1bHV1VDNqcDRERE1hTGhUTlUvUEw3K2Jtc0tseUZUTjdS?= =?utf-8?B?aUhGMUVzaWNhZE10Y3R4L21jREpqQ1JQU2NCT0ZQTzNOdFpPMW1mUWoycjQ3?= =?utf-8?B?NnQyRFFuMkpBTjNnRGFkbUtpcUc2RmM2alNVZWpsU2E4L0FJNUp4SWx0b2FV?= =?utf-8?B?cVB5d0tnYXlSb1AzeHdwV3dXdGhSK3loUWYxNDRvZy93dVdNN3BRdSs1cUxN?= =?utf-8?B?QVBCaytTMG1LeFd3elUyWjhwSElaNCtZZVZMVnlpU2JRMllNMDYva2hGa04x?= =?utf-8?B?am1JeGdBNCt3N2FhQnhzRjgrLytpT2xhYWFlaHlteU93bGhMMlJFMTFJd1FY?= =?utf-8?B?eEU5UXJnZVBHNFZ0T1lQRkFzVTZMKzM2K3pJOXlzYzJiZGlFNHJUcW1D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0h0c2pLY0hmZ3FLdjFGSmVPUkJxcmNOcDdhaHQ2NnVkMlF2N1g1dzIvQ1c2?= =?utf-8?Q?dgw8+ppee35rCv94UB5TZ74AFWavSDFbihYUloFf50=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: de0142fa-fd83-46cc-cedc-08d9a08e76b4 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB4720.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 18:59:58.8116 (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: 6k+87BY+mvI5trvA6WZZFy93tkdh5PyaNqFcAIGVRjbj4+dRy2yEhHXedi02kzhA2BU65Fks9Pm4C3JCm5JDWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2798 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/29/21 8:02 AM, Huang Rui wrote: > Introduce sysfs attributes to get the different level processor > frequencies. > > Signed-off-by: Huang Rui > --- > drivers/cpufreq/amd-pstate.c | 63 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 63 insertions(+) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 9af27ac1f818..8cf1e80f44e0 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -485,6 +485,68 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy) > return 0; > } > > +/* Sysfs attributes */ > + > +/* This frequency is to indicate the maximum hardware frequency. > + * If boost is not active but supported, the frequency will be larger than the > + * one in cpuinfo. > + */ > +static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, > + char *buf) > +{ > + int max_freq; > + struct amd_cpudata *cpudata; > + > + cpudata = policy->driver_data; > + > + max_freq = amd_get_max_freq(cpudata); > + if (max_freq < 0) > + return max_freq; > + > + return sprintf(&buf[0], "%u\n", max_freq); > +} > + > +static ssize_t show_amd_pstate_nominal_freq(struct cpufreq_policy *policy, > + char *buf) > +{ > + int nominal_freq; > + struct amd_cpudata *cpudata; > + > + cpudata = policy->driver_data; > + > + nominal_freq = amd_get_nominal_freq(cpudata); > + if (nominal_freq < 0) > + return nominal_freq; > + > + return sprintf(&buf[0], "%u\n", nominal_freq); > +} The nominal_freq valus is already reported in sysfs by drivers/acpi since this value is part of the ACPI spec. Is there a reason to have multiple sysfs entries for the same value? -Nathan > + > +static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *policy, > + char *buf) > +{ > + int freq; > + struct amd_cpudata *cpudata; > + > + cpudata = policy->driver_data; > + > + freq = amd_get_lowest_nonlinear_freq(cpudata); > + if (freq < 0) > + return freq; > + > + return sprintf(&buf[0], "%u\n", freq); > +} > + > +cpufreq_freq_attr_ro(amd_pstate_max_freq); > +cpufreq_freq_attr_ro(amd_pstate_nominal_freq); > +cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq); > + > +static struct freq_attr *amd_pstate_attr[] = { > + &amd_pstate_max_freq, > + &amd_pstate_nominal_freq, > + &amd_pstate_lowest_nonlinear_freq, > + NULL, > +}; > + > static struct cpufreq_driver amd_pstate_driver = { > .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, > .verify = amd_pstate_verify, > @@ -493,6 +555,7 @@ static struct cpufreq_driver amd_pstate_driver = { > .exit = amd_pstate_cpu_exit, > .set_boost = amd_pstate_set_boost, > .name = "amd-pstate", > + .attr = amd_pstate_attr, > }; > > static int __init amd_pstate_init(void) >