Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1522547ybm; Thu, 23 May 2019 02:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwQDPg+zCZB6IAFr73lzTZCP60/fb8d2uVBix5SzFFwQW/GoOO5twLAX9XOVqLXasNyc9U X-Received: by 2002:a62:aa15:: with SMTP id e21mr103541281pff.140.1558603666115; Thu, 23 May 2019 02:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558603666; cv=none; d=google.com; s=arc-20160816; b=fkMk2o8SB+TMUJomk6vT20aC/jAvX4sikTsb7ongE2wESo+YFN9+BoWcK2+uA5mWV9 aHXfHTtF5HMqZKB8Hv4xc26C2+aWIRFyVyg0okXKxAS8n3xuktzvQ5t7qpnDsri/jLHD nGAB32irScbnJrqFkcxGh+OeL2ZmI5ccq2HE2QKYbVGbGaDw/F+RrN5dbJOTtfXPCuOf YQlrt/tf2ZVR4uqA14MQpCRHMW/OE21WEaJe8JFNcYP1l8IlgJia5zXmnVD1ofz11zEw OrVV6BXMlNCBUVBBHwmrZi+NmWfcCEA3wdc3ZY6PX5L/E93uemNuLMJX5TN2kTjpUP2C 4OEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=SeRSkk7rBDoF9RcYi/fBKrnRRUiI9j1SpLKdo4Y/naE=; b=AO/F1O3Vcyvdp/LzOpkKyviYLlQY1rt7IRVmLmhPHdxp03mSvfXHgHYXWBHG0OMd// N3ChAuNt4z3leSI4IeqP0tjuKgywhqiwhBw4MehXJUnpsOoHJSrDkeSCd7lqKIL5QRGH dG6EJkoN81B+QdvM+jMN0BlT1skZTh4SrhxzxIy1uF2TKWjdYvG7exr/NZNuZsLdy063 ALoi+T/CY3L4Epp3+PoRw1wteItgxETgmcFnX115Hwzerd2cu7eppVC34HeLelh3iVzl idLUPxsD6f1apHEg1B27jom/3tCbdPhWcuLQtFfWaSjSEGVvXe7tbvWOcraUbQTm4OA7 6whw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=p7I4z70C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si14123207pgq.440.2019.05.23.02.27.31; Thu, 23 May 2019 02:27:46 -0700 (PDT) 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; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=p7I4z70C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730080AbfEWJ0Z (ORCPT + 99 others); Thu, 23 May 2019 05:26:25 -0400 Received: from terminus.zytor.com ([198.137.202.136]:38179 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbfEWJ0Y (ORCPT ); Thu, 23 May 2019 05:26:24 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x4N9QD6C4041756 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 23 May 2019 02:26:14 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x4N9QD6C4041756 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1558603574; bh=SeRSkk7rBDoF9RcYi/fBKrnRRUiI9j1SpLKdo4Y/naE=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=p7I4z70CsmCMGkM6cyYe7hrDbmW96Q2wEWOiQgPhicuHsKSicrxAAP4kwZGHm1WzT Fp6VT3Iwq7UlxxelyQSMpqJROsv/EUo3qw6ECQD+nYaYVFH907bcWj8nd21WNavFMU ylCR/Z1Vsjg5sr3ynI4V8ecU2cAbXxj1uGRVzAS4bOOQ/EiviFDSp2QZzC1ia9bHSu WrAvUwZyosGdlGJhhe6UP5L7vFrWp3082AYKZi5nPi9+o3kSRqyhU9Dh6dAkU6vocQ hFVwFW3BPi9Q+Um/BZSL7fpRevJT4ZSa8IxyofPXTot2q0yvdHNyXYQANCzeQcXtX0 +zrqNxTZf1juA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x4N9QDjV4041753; Thu, 23 May 2019 02:26:13 -0700 Date: Thu, 23 May 2019 02:26:13 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Zhang Rui Message-ID: Cc: tglx@linutronix.de, len.brown@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, rui.zhang@intel.com, mingo@kernel.org, peterz@infradead.org, rafael.j.wysocki@intel.com Reply-To: mingo@kernel.org, rui.zhang@intel.com, rafael.j.wysocki@intel.com, peterz@infradead.org, len.brown@intel.com, tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/topology] powercap/intel_rapl: Simplify rapl_find_package() Git-Commit-ID: aadf7b38337108627b014fb285147aacdfafe42e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: aadf7b38337108627b014fb285147aacdfafe42e Gitweb: https://git.kernel.org/tip/aadf7b38337108627b014fb285147aacdfafe42e Author: Zhang Rui AuthorDate: Mon, 13 May 2019 13:58:50 -0400 Committer: Thomas Gleixner CommitDate: Thu, 23 May 2019 10:08:32 +0200 powercap/intel_rapl: Simplify rapl_find_package() Simplify how the code to discover a package is called. Rename find_package_by_id() to rapl_find_package_domain() Syntax only, no functional or semantic change. Signed-off-by: Zhang Rui Signed-off-by: Len Brown Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Acked-by: Rafael J. Wysocki Acked-by: Peter Zijlstra (Intel) Cc: linux-pm@vger.kernel.org Link: https://lkml.kernel.org/r/ae3d1903407fd6e3684234b674f4f0e62c2ab54c.1557769318.git.len.brown@intel.com --- drivers/powercap/intel_rapl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index 4347f15165f8..3c3c0c23180b 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c @@ -264,8 +264,9 @@ static struct powercap_control_type *control_type; /* PowerCap Controller */ static struct rapl_domain *platform_rapl_domain; /* Platform (PSys) domain */ /* caller to ensure CPU hotplug lock is held */ -static struct rapl_package *find_package_by_id(int id) +static struct rapl_package *rapl_find_package_domain(int cpu) { + int id = topology_physical_package_id(cpu); struct rapl_package *rp; list_for_each_entry(rp, &rapl_packages, plist) { @@ -1300,7 +1301,7 @@ static int __init rapl_register_psys(void) rd->rpl[0].name = pl1_name; rd->rpl[1].prim_id = PL2_ENABLE; rd->rpl[1].name = pl2_name; - rd->rp = find_package_by_id(0); + rd->rp = rapl_find_package_domain(0); power_zone = powercap_register_zone(&rd->power_zone, control_type, "psys", NULL, @@ -1456,8 +1457,9 @@ static void rapl_remove_package(struct rapl_package *rp) } /* called from CPU hotplug notifier, hotplug lock held */ -static struct rapl_package *rapl_add_package(int cpu, int pkgid) +static struct rapl_package *rapl_add_package(int cpu) { + int id = topology_physical_package_id(cpu); struct rapl_package *rp; int ret; @@ -1466,7 +1468,7 @@ static struct rapl_package *rapl_add_package(int cpu, int pkgid) return ERR_PTR(-ENOMEM); /* add the new package to the list */ - rp->id = pkgid; + rp->id = id; rp->lead_cpu = cpu; /* check if the package contains valid domains */ @@ -1497,12 +1499,11 @@ err_free_package: */ static int rapl_cpu_online(unsigned int cpu) { - int pkgid = topology_physical_package_id(cpu); struct rapl_package *rp; - rp = find_package_by_id(pkgid); + rp = rapl_find_package_domain(cpu); if (!rp) { - rp = rapl_add_package(cpu, pkgid); + rp = rapl_add_package(cpu); if (IS_ERR(rp)) return PTR_ERR(rp); } @@ -1512,11 +1513,10 @@ static int rapl_cpu_online(unsigned int cpu) static int rapl_cpu_down_prep(unsigned int cpu) { - int pkgid = topology_physical_package_id(cpu); struct rapl_package *rp; int lead_cpu; - rp = find_package_by_id(pkgid); + rp = rapl_find_package_domain(cpu); if (!rp) return 0;