Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp593713pxb; Wed, 8 Sep 2021 08:05:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpIuY6kWZpg2luihoOV9VJSRYrXLpwdWrL6RfSn4eQfO1PrkL2HuwYemO0hbDs0zgyrUq2 X-Received: by 2002:a17:906:584b:: with SMTP id h11mr302929ejs.209.1631113501626; Wed, 08 Sep 2021 08:05:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631113501; cv=pass; d=google.com; s=arc-20160816; b=wPl9QBtosH0+PL8BxhQkxtCZqgc6Kw2QILWRoAvt4kSCE+VQSSoJUGvYs/xZb67Dlh ORzLpjGOMKW4RHO+/aKGFlCPJ+LseQRhYj1Ai24csoYUdKeCa5IHTQ8tonCN1ZhtkO3G lk/3PfSp5NbkuGwRtdWpsVeP++5o1fzr/huepoEve3Q4pKCAmCXiB113dmeVgEdFE624 gj7ez+aZOC/U/gVdVx0WWTW7bGvlaqhuVMmtAAoNWyWgpJVDGT33lCpAH7oPCBityvXd XDi33SIi3UpLy5KabgpGCoalWCAOO98A3qloqMb9a2+VYzYn22XQ8O0WBAadXfQtbhYA YUGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pv4oq08kf3tAlLw7OGigFu4eeqHnwr1cI0XJnv+bU+M=; b=KouGJx/H41JZrcquLeuOObe6xaPpmOltXOYRdiIM6YhNcFslsWRVhUuC9H4V/JFhtA AJIejvQmcdnY9yiyl9LhocIqBl1AAQPqBb2RdI8sGQXuAc1k4K7W/ATttCxUswbqC6GS ZljtdRS6Q+2pekC6ZCqWSoHgPAVf0ZIQO04F0AG6Q9Z5Mxw8Zo7tGrkdbc5KxXcC5Oqk L/u66yuOhYZJXi1HhoKvREZSD8jHeHJVBZFJ5tj43iq/mi8XRTd3yG15b0wkYX/0qf6n 4QzMvzOlJpdKAPpxouSdnbYZx0L24vrY8oMROPV3rE4/nUL6ExrKhGZoYgQBe4pmwJ1N dIJg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=tYnN0pCG; arc=pass (i=1 spf=pass spfdomain=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 b17si2330586edv.518.2021.09.08.08.04.36; Wed, 08 Sep 2021 08:05:01 -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=tYnN0pCG; arc=pass (i=1 spf=pass spfdomain=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 S1352086AbhIHPCz (ORCPT + 99 others); Wed, 8 Sep 2021 11:02:55 -0400 Received: from mail-dm6nam08on2078.outbound.protection.outlook.com ([40.107.102.78]:62240 "EHLO NAM04-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1352046AbhIHPCs (ORCPT ); Wed, 8 Sep 2021 11:02:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XrJO9kE+JlkZdrZhg+wvQJ5pPY6UdlGCWpjtKh+0Vl5DUtg9DVnIEo9HUp4Y5pYA3UHt2iKWK61CT/mv2iFOKj5OpZqur3F9VPlly2HbT8DrsvfrPzm4mzraq6e9TCt9zaAEHLxc0tTv3d+UjRCGr5Ct1+Qw1Wxl+P9z/Sw+pqE/fJXkHalLLm7M/HzHcD5XrWKUkAKAb9m5+TTVK/R9CS3M5i4of/CvGeL4SmrM2eXqvzTuu2QmFokmAkMjUO9M7P1ephU7tjaYZGrDIaOPJdFhuveScqiUW7YC/Ysst0+gNTxd5V47TZKZrAPvVuLzv4LG0dup8uwz6IYRfoAWAg== 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; bh=pv4oq08kf3tAlLw7OGigFu4eeqHnwr1cI0XJnv+bU+M=; b=Sd1RaphKf3cr43AHoHE3WIGcSsfx9nV+HL5Rf33xhmkZQReqbZhD07s8E+ja6tX2eQUdAbAAGR9kI1lz+NUCSG3Dqejo83uRAbsWgBvIB0hKcPtgd3q3TpBEMOZ06CY2fmr710JkSOsXMERGK95aLAyhie3JloMCe3H1A0QsnkvK4YMSAxCaBPB6LuwdtDU9m5SEq4Fxh5VEqtooEENqAHS8F6hZGRag5O+Rfn67r27/ye462jT8CgUUwfdhWsM8EI/D+2BAGeNvZk7wALhsJzIHRy9jWr7wV+fIR2zUoxMXFdukLnIZrBg6Y4pXRhem3bfpPALIT0QVPAsfRx2dXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=pv4oq08kf3tAlLw7OGigFu4eeqHnwr1cI0XJnv+bU+M=; b=tYnN0pCGw7Bh6kP6OajJeSBOldt0gILAYq/L1y2E5hlBWQQGBU9OhBlwfa4V10nH7X1Khl8qxtvbK0PNzlwsM1CfWOuvM2KW7Vbli19XZLdMH6qyruqtPhGg0EopI6IDvEus2HK4DqfFoxOmr2DetE0YMRaK3dn48vcihbdBfVs= Received: from MWHPR10CA0018.namprd10.prod.outlook.com (2603:10b6:301::28) by SJ0PR12MB5405.namprd12.prod.outlook.com (2603:10b6:a03:3af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 15:01:33 +0000 Received: from CO1NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:301:0:cafe::cb) by MWHPR10CA0018.outlook.office365.com (2603:10b6:301::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16 via Frontend Transport; Wed, 8 Sep 2021 15:01:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT057.mail.protection.outlook.com (10.13.174.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 15:01:32 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 8 Sep 2021 10:01:23 -0500 From: Huang Rui To: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Ingo Molnar , CC: Deepak Sharma , Alex Deucher , Mario Limonciello , Nathan Fontenot , Jinzhou Su , Xiaojian Du , , , Huang Rui Subject: [PATCH 10/19] cpufreq: amd: add amd-pstate frequencies attributes Date: Wed, 8 Sep 2021 22:59:52 +0800 Message-ID: <20210908150001.3702552-11-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908150001.3702552-1-ray.huang@amd.com> References: <20210908150001.3702552-1-ray.huang@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9dabfd4-399a-4e9f-ff88-08d972d98bf2 X-MS-TrafficTypeDiagnostic: SJ0PR12MB5405: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:497; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8S+HLIRajyTSN1U6YMJa7dk9yJaq1l4aCdCXoRULHxnM+wNQPs3H1iG0bUz1U0o6UoRzLOpMoxab4FVjOGkxaEoDW7kVbElalLhnnges7vljzjsWIBhETrejgxB8TBCCIdIGBH/+QXURHtpVz1bPvh9GU9l/J3tJ5AJOEMdfNvScMDO9oe/V67h2Z/NJA99ifOODU311FblQeq5dqOrb5XSEwPRBvW/9KLqbmf0HDUlamMeBFz18+IPEttgD2IlhjMofe55iJUyK/fr9x5IZVPm+DHO7AQ1GJokulYN6cQ0R4OhjExFOVwQ151jrYeqnBfgQ5jVGmJGk2uef3HN055uIi+RkfsY/++DSQdNatIh/P/WZQEoCck5p+85/edm8iGWVHISXbXlfm5eDHUVt9uJXRlq6A+jZrBeSpFZRb0C9Ol/CH1TTmy7CppS6iTccqFyTq2/c04SPeMrO2X7BD+NqQF4BYzNvYDKF7JXuuujyBoEUerurXsKM53tLicDBphtUH4wj/GjI4bQNCE/j4li2RakUbW/M0FcrMdmUl5RAKlS1gNivR7J0zBrJOwBquB63RgTC5JI9dmpQxxaNvingrdqeJuBtxVIel5CPpadnQTitDjcNzaBWM0XTvsR2PxJ/gFDrZueozi8BCvrj0qMhSAihMEbOspkH6YFTNuunqs6BsO1Pl5BsslyXxW5nz1pwqtFMXWVlMisz28PIHzvS6CI/GWezPYjGrniIEsE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(136003)(396003)(376002)(346002)(39860400002)(46966006)(36840700001)(26005)(36860700001)(47076005)(426003)(2616005)(1076003)(4326008)(82740400003)(70586007)(82310400003)(5660300002)(86362001)(186003)(83380400001)(336012)(81166007)(70206006)(478600001)(8936002)(6666004)(7696005)(8676002)(2906002)(110136005)(356005)(54906003)(36756003)(316002)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 15:01:32.9524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9dabfd4-399a-4e9f-ff88-08d972d98bf2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5405 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce sysfs attributes to get the different level processor frequencies. Signed-off-by: Huang Rui --- drivers/cpufreq/amd-pstate.c | 80 +++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 48dedd5af101..3c727a22cb69 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -577,16 +577,94 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy) return 0; } -static ssize_t show_is_amd_pstate_enabled(struct cpufreq_policy *policy, +/* Sysfs attributes */ + +static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy, char *buf) +{ + int ret = 0, max_freq; + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + max_freq = amd_get_max_freq(cpudata); + if (max_freq < 0) + return max_freq; + + ret += sprintf(&buf[ret], "%u\n", max_freq); + + return ret; +} + +static ssize_t show_amd_pstate_nominal_freq(struct cpufreq_policy *policy, + char *buf) +{ + int ret = 0, nominal_freq; + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + nominal_freq = amd_get_nominal_freq(cpudata); + if (nominal_freq < 0) + return nominal_freq; + + ret += sprintf(&buf[ret], "%u\n", nominal_freq); + + return ret; +} + +static ssize_t +show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *policy, char *buf) +{ + int ret = 0, freq; + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + freq = amd_get_lowest_nonlinear_freq(cpudata); + if (freq < 0) + return freq; + + ret += sprintf(&buf[ret], "%u\n", freq); + + return ret; +} + +static ssize_t show_amd_pstate_min_freq(struct cpufreq_policy *policy, char *buf) +{ + int ret = 0; + int freq; + struct amd_cpudata *cpudata; + + cpudata = policy->driver_data; + + freq = amd_get_min_freq(cpudata); + if (freq < 0) + return freq; + + ret += sprintf(&buf[ret], "%u\n", freq); + + return ret; +} + +static ssize_t show_is_amd_pstate_enabled(struct cpufreq_policy *policy, + char *buf) { return sprintf(&buf[0], "%d\n", acpi_cpc_valid() ? 1 : 0); } cpufreq_freq_attr_ro(is_amd_pstate_enabled); +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); +cpufreq_freq_attr_ro(amd_pstate_min_freq); static struct freq_attr *amd_pstate_attr[] = { &is_amd_pstate_enabled, + &amd_pstate_max_freq, + &amd_pstate_nominal_freq, + &amd_pstate_lowest_nonlinear_freq, + &amd_pstate_min_freq, NULL, }; -- 2.25.1