Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1214926imj; Sun, 17 Feb 2019 00:23:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IZH19GORj2DhbcSeGQ06Vhji9ET2GIeSHF4y8ubh1lVUUm42yomPm+5CmS5qUZKu9hHi9SC X-Received: by 2002:a63:f241:: with SMTP id d1mr13373366pgk.2.1550391794752; Sun, 17 Feb 2019 00:23:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550391794; cv=none; d=google.com; s=arc-20160816; b=n/wZl1C9Ka9eXGZif0PlcscLq2ycVidBqGBiAZsb9oI1AOgjjOEGQtQYgrjSAV/alT nLYp9rEBncf8jd57CoewLmDmjhxzDoT9y7hOF51anNfSoGXu4GdxovZtYlMPX6uwwg86 dsNF0b6eU03rG88n+kMo5UI3xy5GSSmPkQqTW3avlY+pmorx9nYewoFaRViFk3bL93pU VqPjE7DT/gCOJCrt/zI38lLN3FLh0GVDGBkKP9W54kopPXPrjXI/6m3frdpVL8Kr20DO okj6yKqlIo35OSF8hT97MMQMCfaSQk0lRDD4xRTFxz13DVM0of+O+exlWKUPpFjoRuTN OMvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=c5MgOpCITZT83psvM1qIX8Ph+wtAq3+f5bFW2zsxAj8=; b=jttavxKBtEj4PZv+hWakkqWu4eq5Omji+peB5sBlvM4pqlyhhY4YFAc4/oIN7AwLHN bFp9XA8RcJtNSVrvgFo9dM95piB1c5ReU2hcOPh4wpiyQFDc5gj2Jet7iWUnayUz+gUT PiUCkA4J09uCS3ZIl19GRiVxiuzJF9eE+TW0gmCth1oCZ7Di0FV02KWcoS/P6FHS5EJM +rCjbEEM5DcLq2tj5Vmz4Z1RfCND7qh1K+4V9PTexylpvMJB68dBsNGIXW14CYWQB+bj k3KLXt3DbeUipfe3oEjBwmkJFH+lXUgfR1DZQdOciQMwKNKnvE72kP7uBx4tSJvmrtl0 SkKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si10157703plt.342.2019.02.17.00.22.59; Sun, 17 Feb 2019 00:23:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728237AbfBQDzT (ORCPT + 99 others); Sat, 16 Feb 2019 22:55:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3752 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725794AbfBQDzS (ORCPT ); Sat, 16 Feb 2019 22:55:18 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 88BBEA1ECEB5ABB27A92; Sun, 17 Feb 2019 11:55:15 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Sun, 17 Feb 2019 11:55:07 +0800 From: Xiongfeng Wang To: , , , , , CC: , , , , Subject: [PATCH v3 1/2] ACPI / CPPC: Add a helper to get desired performance Date: Sun, 17 Feb 2019 11:54:14 +0800 Message-ID: <1550375655-58007-2-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1550375655-58007-1-git-send-email-wangxiongfeng2@huawei.com> References: <1550375655-58007-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add a helper to get the value of desired performance register. Signed-off-by: Xiongfeng Wang --- drivers/acpi/cppc_acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 1 + 2 files changed, 40 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 217a782..231d447 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1051,6 +1051,45 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val) } /** + * cppc_get_desired_perf - Get the value of desired performance register. + * @cpunum: CPU from which to get desired performance. + * @desired_perf: address of a variable to store the returned desired performance + * + * Return: 0 for success, -EIO otherwise. + */ +int cppc_get_desired_perf(int cpunum, u64 *desired_perf) +{ + struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); + int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum); + struct cpc_register_resource *desired_reg; + struct cppc_pcc_data *pcc_ss_data = NULL; + + desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF]; + + if (CPC_IN_PCC(desired_reg)) { + int ret = 0; + + if (pcc_ss_id < 0) + return -EIO; + pcc_ss_data = pcc_data[pcc_ss_id]; + + down_write(&pcc_ss_data->pcc_lock); + if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0) + cpc_read(cpunum, desired_reg, desired_perf); + else + ret = -EIO; + up_write(&pcc_ss_data->pcc_lock); + + return ret; + } + + cpc_read(cpunum, desired_reg, desired_perf); + + return 0; +} +EXPORT_SYMBOL_GPL(cppc_get_desired_perf); + +/** * cppc_get_perf_caps - Get a CPUs performance capabilities. * @cpunum: CPU from which to get capabilities info. * @perf_caps: ptr to cppc_perf_caps. See cppc_acpi.h diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 4f34734..ba6fd72 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -137,6 +137,7 @@ struct cppc_cpudata { cpumask_var_t shared_cpu_map; }; +extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf); extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs); extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls); extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps); -- 1.7.12.4