Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1686110imj; Thu, 14 Feb 2019 10:18:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IaVVKG1GQ0CLSMfa5JhKzp+ZOJofK6iHzUMJaptS6p3lnYMVXzdruYjpV8sa2vYxU0c60r6 X-Received: by 2002:a63:aa46:: with SMTP id x6mr1160714pgo.452.1550168290784; Thu, 14 Feb 2019 10:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550168290; cv=none; d=google.com; s=arc-20160816; b=GFdc35RiWNKl8FJe3HmHlgzVPw8CefDTGxKM7tosY5bdi5ZoLug1yk/+1+ARAG63aw 4/MW0WIyzE0m8SuuygE/xgqUCO1YW7k0q4Ad6vUDI3hlx1bIo96H3fCdFp/WE+/Uf+4Y jb6QhVnOGryELuqKJfNDBRZ+cbHvHbA0k/BwF18VfKes4BwhPFOzqqQKltFX2DVCvL8p A/6iZqMDxaHF/EhKiKYZbS82M9qX530lgcaR5LIFbXUUfplVKssX2rtuyXI3HRa5eSCX WtZGAbEZYOGFnDkWXHqDsJ1TTx2HWuYF3Z8VIzrRjP221zz+NQCAX9zZfSwHVxVJ+p0+ ICFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=RSC7FfOp1eL3+/dELdJD9KCYfJPiqPMHcMMMOYxa89A=; b=y72MYoc+3sqyXxHHmu2WzyUHywQXinuobTmzRNX+focNz/Jg0n3NAy32QDRGBy+4VB u1yl3lKbQ2YogKK5ZQoiO1h+e6qmwoR8nVBlSkcSp4ffx0V+X1iaMs/mgLe0eCuwbNVK LAj1H+dEtzLuTbojmsdykhHw2y1C5OCf5whUWWhjD5Nx6MA5IaW8/bDT0/dQkXm90p/t G/vIcf/qY5/KMRSd2K+BeTgab2Hakl0xDAu8uiwJiENMQpTwb2qQyEq6BkJOUu4JuQJj Mu/yfgOfJHpTtt+U/jVRESExc1CCr6bhu2i0KzPj/HLn9YXSaiRTv0dmkH1WC/ZSxjAS KenA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si1687490pld.183.2019.02.14.10.17.50; Thu, 14 Feb 2019 10:18:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406696AbfBNKnD (ORCPT + 99 others); Thu, 14 Feb 2019 05:43:03 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:33377 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394286AbfBNKnC (ORCPT ); Thu, 14 Feb 2019 05:43:02 -0500 Received: by mail-ot1-f68.google.com with SMTP id i20so9759713otl.0; Thu, 14 Feb 2019 02:43:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RSC7FfOp1eL3+/dELdJD9KCYfJPiqPMHcMMMOYxa89A=; b=Vhvwbb+2SJy9sMbZRbeHh+ZAIU7HReuImsI0kOqa579l7S4a/pCJeTCnaaYTRZgkWy 7vkCmLhtddRGRQGzrBsKuySHXDR14272G2LNw1xo4SbMYeFSk/4ej6qxMUkgpYwDJuMo Yqf4QYpyy0dZRuluSlfJgb2Qkitmt2ZB00y7PbWl6Cd0PQCIks6zKy02qqPwVUutpXi+ u5Yc4rFe/rspGA7ZYJmXwxzX6knZcBErmJWQ6LZWb6/o0rCo/flI3WTsRZaU2O2aDuPc +xD0iNHeaVwe3Av9nZIs1Uo1WVqLs8n8eG8TeeD9d1jCHWhTe7HFvsur/LF+lBlQfUwT lY5w== X-Gm-Message-State: AHQUAuZev8t5x/xpKfLrMHTEsJkcG8Ej18i3E/hUAb29EFoPI6xEqYlK dZriCylbPHMvlPOstXBuh7QN/ye9z4D+eZrGUyQ= X-Received: by 2002:a9d:638c:: with SMTP id w12mr1923290otk.139.1550140980784; Thu, 14 Feb 2019 02:43:00 -0800 (PST) MIME-Version: 1.0 References: <1550130368-60513-1-git-send-email-wangxiongfeng2@huawei.com> <1550130368-60513-2-git-send-email-wangxiongfeng2@huawei.com> In-Reply-To: <1550130368-60513-2-git-send-email-wangxiongfeng2@huawei.com> From: "Rafael J. Wysocki" Date: Thu, 14 Feb 2019 11:42:49 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] ACPI / CPPC: Add a helper to get desired performance To: Xiongfeng Wang Cc: Viresh Kumar , "Rafael J. Wysocki" , gcherianv@gmail.com, Prashanth Prakash , George Cherian , Robert Moore , ACPI Devel Maling List , Linux Kernel Mailing List , Hanjun Guo , John Garry Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 14, 2019 at 8:46 AM Xiongfeng Wang wrote: > > 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; It would be better to use bool here, but it would be even better to not try to avoid calling cpc_read() in two branches. > + > + 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; > + 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); return 0; > + > + 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