From patchwork Wed Jan 31 11:37:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 194714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1827940dyb; Wed, 31 Jan 2024 03:46:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1FvBVuSW4Lg3iYwr8OuTtSEuk1uRBYCifONJbe0b8Xh9UEhVbmCPDFazU2Nizu7gMzJx3 X-Received: by 2002:a17:903:246:b0:1d7:147d:6a1d with SMTP id j6-20020a170903024600b001d7147d6a1dmr1209417plh.55.1706701565089; Wed, 31 Jan 2024 03:46:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701565; cv=pass; d=google.com; s=arc-20160816; b=VPjIzqrBqM9IynJZ6DsZz7Jy2c3qB4qpgj+jTKGKNAITq/8L8g2B6nDYfGStaNzKAB 9uGlGNy9DePr/S6nnTHZf8tgAg3LMDKG1OJcPjj2rSKU9RdSmi+8gIXTe2TNSemesQBz 6Itc94B1h7x/3VbMNRB/oyqPkdXY45k2dCMX4SGPG2J7b1p1+hZG+lrV4S3oGHHM4OoR okY5HPaUeWt07uCI/WC930S3rn06QrUBu/po5BlRTNVN+0/qY33ncf94iyrLs0KuXBOm ulANGaJozEy9Na1nVd2T/PgqyzLxuopHOYv5s8KWbLCsLiy6QiKLXOIO8TKUGpflRbFE h1aw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yJPCAMz/vMA4HmQMU0bc0iPvmSl0aRSnV4b75I8QiDo=; fh=UFrNadGS6KSrMLseDSc/ysdZ+Drkb91EZyNUrwGhaRY=; b=BDQ8eYyt6WIYsWDaX7ExTDP93LMInWbrxq+CMa2Vv/4RgKkwej8romJoHCgt4/k3D6 297J7xBIZoZBDSdFtUnbTpff01klZRRah4GnfkY3CpehU57K2271EitKpDYX4Rv6hcXI ZbrqZ/wR/NDV+EqyhKcD712ZXYa7phedkYAOPT9L0BUigv68WeSSCLycdFTCmxYv6SJf xMOZTivcsNEVMIBININC6IuEMCOpfo08eMrsNdXlVHBWL+6jZoSlH1lCCKmdBcmnURfC qkD9HFlMZiWmpGCUKlSfQ/OCGryyyjiQJrkRERdVnPq6sgywzrvFR2Kfw1lP4CngBTON NJyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NHR3II2i; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-46370-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46370-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVVowOj8HaJuK8Nx25TmEeCkkai8ourBMOCQVY+SuCSSq60d3cxBgm8O8w70MM0lBRddYzxXpPbBVmmLUzi2fE+pG0hGA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p15-20020a170902e74f00b001d7271fb159si5540212plf.105.2024.01.31.03.46.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:46:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46370-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NHR3II2i; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-46370-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46370-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1CC0528B25F for ; Wed, 31 Jan 2024 11:40:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E918780BE9; Wed, 31 Jan 2024 11:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NHR3II2i" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 876A47D3F5; Wed, 31 Jan 2024 11:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706701054; cv=none; b=oLvF6Hnrsb4RXWJgtgTAY+jjf7DrPquUa/F1W7DkxIpcr2jQ22VAbo3uP/hyl4hGEW56h1QvXbF8jNXuAPxVXeoJ7yyhEMZSJRnWpBUjFG8WEfTali0dkxm/7u2G0Pw+mrSU8iK0yIUsLy7/uhFpavAUSK9RQ5jwnpwFmFPJL9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706701054; c=relaxed/simple; bh=qqS366ENXAObLZelQMQdQKQUmZl5yUdXm3AHKjxtXp8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pKXo3mT1OmHRrtzGw8iuh8L1W0x7azL/TdU++9d6+ZeDtE+BhjkVkXKb3vNSSdL9fx1hFp0Kv27nScrLjL+AepewBV8N7C7LZ6IisB5grxDvv65Zyd0yAtqOeYzV4Npu2mqsHatsqm9jtiyRpa6fyD0iTuvS/VJJ3/rTErv5iNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NHR3II2i; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706701052; x=1738237052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qqS366ENXAObLZelQMQdQKQUmZl5yUdXm3AHKjxtXp8=; b=NHR3II2ioMEs+bVqqettnbQe1SUBQs1ykmOX3+/25PrHVgi4uX7eKwEB Myj5ylSeOXCbM7YmYyvKU9nZowHWniNPjZj9h3KLipgVSjl0LxNnLtdus rH3A3RGIIsPv4+84ZwIoMYH/7o54Z9+LQNS+ewjBHPOXIoJZXuW7K+ySs uMXW9kcUcWH+AakuNb/YV8lqyF5B+fgWQNCSuD3azTjTLEYerUc/om3tG 5r41Ryq9ahxN/EDcc3pS8nuJnmavOaN8EPCTtsjwVrfX70Hp23DWiWLYd j2dcfDvXW/Ko9U3knbBStfy8i9zbJAQ8rHt62aAC8/SRs/KsYFijyq3Vj Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="3441644" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="3441644" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 03:37:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="788542498" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="788542498" Received: from puhongt-mobl2.ccr.corp.intel.com (HELO rzhang1-mobl7.ccr.corp.intel.com) ([10.255.29.147]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 03:37:30 -0800 From: Zhang Rui To: rafael.j.wysocki@intel.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 4/6] powercap: intel_rapl_tpmi: Fix System Domain probing Date: Wed, 31 Jan 2024 19:37:11 +0800 Message-Id: <20240131113713.74779-5-rui.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240131113713.74779-1-rui.zhang@intel.com> References: <20240131113713.74779-1-rui.zhang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789606300552025945 X-GMAIL-MSGID: 1789606300552025945 Only domain root packages can enumerate System (Psys) domain. Whether a package is domain root or not is described in the Bit 0 of the Domain Info register. Add support for Domain Info register and fix the System domain probing accordingly. Fixes: 9eef7f9da928 ("powercap: intel_rapl: Introduce RAPL TPMI interface driver") Signed-off-by: Zhang Rui --- drivers/powercap/intel_rapl_tpmi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/powercap/intel_rapl_tpmi.c b/drivers/powercap/intel_rapl_tpmi.c index f1c734ac3c34..f6b7f085977c 100644 --- a/drivers/powercap/intel_rapl_tpmi.c +++ b/drivers/powercap/intel_rapl_tpmi.c @@ -131,6 +131,12 @@ static void trp_release(struct tpmi_rapl_package *trp) mutex_unlock(&tpmi_rapl_lock); } +/* + * Bit 0 of TPMI_RAPL_REG_DOMAIN_INFO indicates if the current package is a domain + * root or not. Only domain root packages can enumerate System (Psys) Domain. + */ +#define TPMI_RAPL_DOMAIN_ROOT BIT(0) + static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) { u8 tpmi_domain_version; @@ -140,6 +146,7 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) enum rapl_domain_reg_id reg_id; int tpmi_domain_size, tpmi_domain_flags; u64 tpmi_domain_header = readq(trp->base + offset); + u64 tpmi_domain_info; /* Domain Parent bits are ignored for now */ tpmi_domain_version = tpmi_domain_header & 0xff; @@ -170,6 +177,13 @@ static int parse_one_domain(struct tpmi_rapl_package *trp, u32 offset) domain_type = RAPL_DOMAIN_PACKAGE; break; case TPMI_RAPL_DOMAIN_SYSTEM: + if (!(tpmi_domain_flags & BIT(TPMI_RAPL_REG_DOMAIN_INFO))) { + pr_warn(FW_BUG "System domain must support Domain Info register\n"); + return -ENODEV; + } + tpmi_domain_info = readq(trp->base + offset + TPMI_RAPL_REG_DOMAIN_INFO); + if (!(tpmi_domain_info & TPMI_RAPL_DOMAIN_ROOT)) + return 0; domain_type = RAPL_DOMAIN_PLATFORM; break; case TPMI_RAPL_DOMAIN_MEMORY: