From patchwork Wed Apr 19 02:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 85150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp60108vqo; Tue, 18 Apr 2023 20:05:25 -0700 (PDT) X-Google-Smtp-Source: AKy350ajh6BmALFQB366cFG2KHgte56i8xWsn6b0nT50iVwEY/FTCKb+Mq8waV1s1FVYoT/BPOIW X-Received: by 2002:a05:6a00:1956:b0:63b:64f7:45a0 with SMTP id s22-20020a056a00195600b0063b64f745a0mr2025414pfk.12.1681873525487; Tue, 18 Apr 2023 20:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681873525; cv=none; d=google.com; s=arc-20160816; b=bz62hCgIC2WsrTIPTVUvUrlLlRHY0hpd6fmPuTGSDM7SCeor/tiLDqGGYjLayArjXt pnegd10a9mHjrC5kKb/Pc+GRf/bEDXOxgK7S55CR7e5lYHWQocvMHbz9NBA6doJw/703 Jq2t/LwVjI1iT+Qcd34+iS2Pz8b/4QcUq+einMEOcWC0VqX7UC5luEytbapnNfh1VMD7 EEKgUj5T7wKn61cMj8CUT6bPDzPQM2uNDMkEtNhQc4a7k5Ch4oBMy+fWJDfCRBN/L/sr ETQC9thiK/NAyFh97ELmVjvQzb5557cifXbf98WJkQS84+XDT9MQgfiCgpfvHrXtQxHs yvgA== ARC-Message-Signature: i=1; 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=DIJgWtsnI+hi9CYP0xnK+uLG+0HEcdBFDwNQMmapUhY=; b=cIoou0yTUjcpiXXa9qzlOjWsKoSHz0EdzeNPLf4TArfHe9SPgvdi8JqeldssNGB2g3 IfhN6BCl7wNI5E1FcX5MRAZOTpNvOUm9XU/fsQHjXZAbVD6T9D3pne2+m8BxlV7+LqXC Wq/IITPswvjsTOOula23IY0/3hhj7FOjBgqGvHyk2p8ePmxMQA8QqUgYa24VECGrF7io Fu8eYkoocnfLW/KAqXrclyFqvNVAQ78O8sEGV7XRF5dhBLte0WyBWtr3+hkiSzAcU+rm gNlJvCXv5heZqTw33D3PbHjEUEMSc4WJbBF0lnCwzYzW28JT7e35kCfVZCWbN0RKxJ0M Y6Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QEPOb1sq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g128-20020a636b86000000b0050bf22172d3si15571868pgc.490.2023.04.18.20.05.13; Tue, 18 Apr 2023 20:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QEPOb1sq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbjDSCpS (ORCPT + 99 others); Tue, 18 Apr 2023 22:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbjDSCpA (ORCPT ); Tue, 18 Apr 2023 22:45:00 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C00FCC154; Tue, 18 Apr 2023 19:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681872286; x=1713408286; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jsiHg2i6UjRZGZy2aubZeGbqqNhgW3rTFkSc/x9EGZ4=; b=QEPOb1sq+xaGT+V1WxIG3PXwiFZm12+oXwQ0cVpoBFcXXz0SV03hEYDB 9JsT20XQ+v+kmUGBdfzYRUerRYMnMLoNC2Ri5W8Zvf8RgDKTqet6E2OGE RG2WRJJ1vol/4IcxJg43OayQo31XgShkXn8E77ciaa9/zxYnS8JK60UAH hxxPDKIRYpUA0w0WOcnu6xnHcPk/zc54B+z2gPecRZKvdn1IkOm1a4GmX M9/31ZfTnqXuFcuILW4nPYV63I/YNsmh+EwjrlOvrY/+Woo4yn7w3ZOQB 7C28xaVPrtDhYRkeksFOt+LLX/t3PO3ufZobsAOtjxj8k3SZJ13+kszH0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10684"; a="373215302" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="373215302" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 19:44:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10684"; a="937478028" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="937478028" Received: from hanboyu-mobl.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.255.29.76]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 19:44:44 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, srinivas.pandruvada@intel.com Subject: [PATCH v2 07/15] powercap/intel_rapl: Change primitive order Date: Wed, 19 Apr 2023 10:44:11 +0800 Message-Id: <20230419024419.324436-8-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419024419.324436-1-rui.zhang@intel.com> References: <20230419024419.324436-1-rui.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763572213694754554?= X-GMAIL-MSGID: =?utf-8?q?1763572213694754554?= The same set of operations are shared by different Powert Limits, including Power Limit get/set, Power Limit enable/disable, clamping enable/disable, time window get/set, and max power get/set, etc. But the same operation for different Power Limit has different primitives because they use different registers/register bits. A lot of dirty/duplicate code was introduced to handle this difference. Instead of using hardcoded primitive name directly, using Power Limit id + operation type is much cleaner. For this sense, move POWER_LIMIT1/POWER_LIMIT2/POWER_LIMIT4 to the beginning of enum rapl_primitives so that they can be reused as Power Limit ids. No functional change. Signed-off-by: Zhang Rui Tested-by: Wang Wendy --- drivers/powercap/intel_rapl_common.c | 4 ++-- include/linux/intel_rapl.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c index 97d9e1e628e2..154f93b3dee5 100644 --- a/drivers/powercap/intel_rapl_common.c +++ b/drivers/powercap/intel_rapl_common.c @@ -631,14 +631,14 @@ static u64 rapl_unit_xlate(struct rapl_domain *rd, enum unit_type type, static struct rapl_primitive_info rpi_default[NR_RAPL_PRIMITIVES] = { /* name, mask, shift, msr index, unit divisor */ - [ENERGY_COUNTER] = PRIMITIVE_INFO_INIT(ENERGY_COUNTER, ENERGY_STATUS_MASK, 0, - RAPL_DOMAIN_REG_STATUS, ENERGY_UNIT, 0), [POWER_LIMIT1] = PRIMITIVE_INFO_INIT(POWER_LIMIT1, POWER_LIMIT1_MASK, 0, RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0), [POWER_LIMIT2] = PRIMITIVE_INFO_INIT(POWER_LIMIT2, POWER_LIMIT2_MASK, 32, RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0), [POWER_LIMIT4] = PRIMITIVE_INFO_INIT(POWER_LIMIT4, POWER_LIMIT4_MASK, 0, RAPL_DOMAIN_REG_PL4, POWER_UNIT, 0), + [ENERGY_COUNTER] = PRIMITIVE_INFO_INIT(ENERGY_COUNTER, ENERGY_STATUS_MASK, 0, + RAPL_DOMAIN_REG_STATUS, ENERGY_UNIT, 0), [FW_LOCK] = PRIMITIVE_INFO_INIT(FW_LOCK, POWER_LOW_LOCK, 31, RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0), [PL1_ENABLE] = PRIMITIVE_INFO_INIT(PL1_ENABLE, POWER_LIMIT1_ENABLE, 15, diff --git a/include/linux/intel_rapl.h b/include/linux/intel_rapl.h index 936fb8c3082c..bbd03b17dc8d 100644 --- a/include/linux/intel_rapl.h +++ b/include/linux/intel_rapl.h @@ -37,10 +37,10 @@ enum rapl_domain_reg_id { struct rapl_domain; enum rapl_primitives { - ENERGY_COUNTER, POWER_LIMIT1, POWER_LIMIT2, POWER_LIMIT4, + ENERGY_COUNTER, FW_LOCK, PL1_ENABLE, /* power limit 1, aka long term */ @@ -75,7 +75,8 @@ struct rapl_domain_data { unsigned long timestamp; }; -#define NR_POWER_LIMITS (3) +#define NR_POWER_LIMITS (POWER_LIMIT4 + 1) + struct rapl_power_limit { struct powercap_zone_constraint *constraint; int prim_id; /* primitive ID used to enable */