Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1600112imj; Thu, 14 Feb 2019 08:59:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IZMX5demorEV8BhRAAOx+P/uZG3Z1HeMBsz+AKLNCJrkXQRTBjgyhPiJWNYlvYO8NsnqqV+ X-Received: by 2002:a63:a11:: with SMTP id 17mr691614pgk.310.1550163594965; Thu, 14 Feb 2019 08:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550163594; cv=none; d=google.com; s=arc-20160816; b=LtVbNJjMcM3EnxkcVvtDLPrsp534w1zkchyVkX+nt4/PbEH9Dt6zdi9orhsaEfONuz mmrOxX9Ct0huQuL3JzMaryfOci4gzhRAJc9J3pPWkiOtpypWim3f3WSTd89U/7kUZe18 mV0WMNvtokR9cn+0fxwo9DWFZAWCehWVSp7hy6DVb8hwEmJhV1Ji5GhBvK1C9vDds0Tp b7f56CtSdB+agyUvsQF+Dd+gmDxXUhGmf38f1OznuzJtzESP8DzDveLcYDUhJo2KphQY MKW2bOyHix4VmsnUkpyLKayCNGnJ+i7A8mqMWDtecaFzZ+iyPPkdWoSt+4d0DiwqP0Gm KR1Q== 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=9XWtPcuucFX0ejcMeckzS0xMkp/rWzY32t5jZFMC1xk=; b=jInE8jbps+ZBg9r9W3FHB3LL1wXoh+k92Yl8LY7ekXrAt/KSBLS4fac5mGdOl+CJWu Qq5YFC6Y2pyXL2uI+WjVOMRY4sQavh41llrXc0TfcVjmFk2pTH4aAgajiID4+4nHmeev 2P1qdIaQC/honv9ajb6rufGGZRauaST4j8r/0vIOixGzr8a6bMmYJub5xAXImuceGZ3z a3GfwoyUtdd39JLYxC0rgbK6vD3upOCF4j9+QBMSpvyOvn99+3kYqMGRe5uq3h4WcMSH 6NNp01FyINCtkY7DpEkIC8cLfE9r0xYwNWk1yozzW1enNYsqkeJbmNAsHBTDSRd45r1B XNEg== 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 v7si2642539pgr.154.2019.02.14.08.59.38; Thu, 14 Feb 2019 08:59:54 -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 S2437340AbfBNHq6 (ORCPT + 99 others); Thu, 14 Feb 2019 02:46:58 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:44878 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2437330AbfBNHq5 (ORCPT ); Thu, 14 Feb 2019 02:46:57 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 459F262CF30613A63F0B; Thu, 14 Feb 2019 15:46:54 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Thu, 14 Feb 2019 15:46:45 +0800 From: Xiongfeng Wang To: , , , , , CC: , , , , Subject: [PATCH v2 1/2] ACPI / CPPC: Add a helper to get desired performance Date: Thu, 14 Feb 2019 15:46:07 +0800 Message-ID: <1550130368-60513-2-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1550130368-60513-1-git-send-email-wangxiongfeng2@huawei.com> References: <1550130368-60513-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 | 38 ++++++++++++++++++++++++++++++++++++++ include/acpi/cppc_acpi.h | 1 + 2 files changed, 39 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 217a782..93588c5 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1051,6 +1051,44 @@ 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; + int regs_in_pcc = 0; + + desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF]; + + if (CPC_IN_PCC(desired_reg)) { + if (pcc_ss_id < 0) + return -EIO; + pcc_ss_data = pcc_data[pcc_ss_id]; + down_write(&pcc_ss_data->pcc_lock); + regs_in_pcc = 1; + if (send_pcc_cmd(pcc_ss_id, CMD_READ) < 0) { + up_write(&pcc_ss_data->pcc_lock); + return -EIO; + } + } + + cpc_read(cpunum, desired_reg, desired_perf); + + if (regs_in_pcc) + up_write(&pcc_ss_data->pcc_lock); + + 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