Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp272720rdh; Mon, 18 Dec 2023 20:22:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZWUot4EvG1yLN6Ey7YWnXhPjm678S3aspsrSnNEoNCC9kbG9HzPO36zihl0e/37uY7fkB X-Received: by 2002:a17:906:4416:b0:a1c:a5ae:c1ea with SMTP id x22-20020a170906441600b00a1ca5aec1eamr8226381ejo.98.1702959770037; Mon, 18 Dec 2023 20:22:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702959770; cv=none; d=google.com; s=arc-20160816; b=rhQVIAxqLbjaCHiE4ni7Vej2XsJoQ3sHmeRyrA2um3sUqYFc5TFEzDnAD3ZkXdwUU8 OXixG3vA/tkc4opwK6dqoUUsbiVlIj9A7WiMf2r1pqgld0oOXzfFTMyhWNIOJtjMdR1Q 2kNTQLBGyBMQ6Ds2fWQn2MveQr36SuBXP2a4sjDct2cJXuNmA1ByB2NkEjavC8A9hVEb DcRAGt6TCKRalhqgavlFpD+YwHP0fQRbrXbTkeoL3RU1JABHS6qWeWd4tq4T3Xgx2yWf zxpMM68LtMj3HzdZCXJI2bPGq4KjTGeroqOtW34BLxdNMA6ACtz2QzNY3GYPJFR1gI4J tA9g== ARC-Message-Signature: i=1; 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=sJ5xSra3t5dFAsnuMBUp57iNjnoC0SWf4D2GsDNoWi0=; fh=ZUMVFjL0ZjvAYl9YLu+Mpf7RsG1h63WakuB0T3OcYc0=; b=pFAAnEe5xodXCOR6UQVrm9twAlSB6pVJCn1epu4HIzjUv0HE7j4SCSy5UFYnoyuEhe qZ2M+u15kjsJBQch2refR0GCYQVG2zXIskgohbMesBgpOYi22xeCgtlxqlmzHeTkhK5+ 893Az91tdwXLPWvSsZiA5I5GjLzPcK0ubwcf7+hEV0SxLhcVS8NLTwzdETEl4rqs7PyB HXbERDjthxNHQ647TDSxMoP41d8dJ0SSw91iBeK60rieqvkkt0wHKTBisx5vAfRww/ow SD1FEJ8cluAW/jJuqY6rsuoFt8IAgld6hPTNIoTq6g+pvzoO/Z9BCyiL8Qf+TkpUZ5lY L+Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fBhPUg42; spf=pass (google.com: domain of linux-kernel+bounces-4668-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4668-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ko28-20020a170907987c00b00a233a47c632si2025985ejc.972.2023.12.18.20.22.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 20:22:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4668-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fBhPUg42; spf=pass (google.com: domain of linux-kernel+bounces-4668-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4668-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id C661B1F24CC4 for ; Tue, 19 Dec 2023 04:22:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E03187486; Tue, 19 Dec 2023 04:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fBhPUg42" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 83E105388; Tue, 19 Dec 2023 04:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702959753; x=1734495753; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1LZxjxPHrj5Hy4pXU6f/fg8syl4gP5AqPpkWahW5tYs=; b=fBhPUg42o+BSGmFmBwn0UaTkBj102S/iAbED4+FvtkqK49moOayFgcvA UdjQ40PX5Aw68GdY9Fl8DIP00nvgB9Vq3yUTzeEQ165syz72GicMGRbSe uCgWjWU3/3rUTcSgsdc8SwuCyoRgIhOzk3Wjs4YD5ZYTL3WfvRSX7YIF5 gPhumDuwp41bCF+EgKuh0+qe20aSqXnruk7BgqUwAUGE2Ah+wJ09zm9tr ntx7ZWVIJ0LvSFXrm2+lk5N4Wmuy0WhpqzCJCU6W2ylniN3T20ePZs5ZC luG8Y4pxVmu7LbslE4Gifwo8rMqrZp97Q7g7T25tUrTEV6tXBoCGAm0vM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="2455974" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="2455974" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 20:22:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="919503099" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="919503099" Received: from mnichels-mobl1.amr.corp.intel.com (HELO rjingar-desk5.intel.com) ([10.212.29.225]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 20:22:30 -0800 From: rjingar To: irenic.rajneesh@gmail.com, david.e.box@intel.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rajvi.jingar@linux.intel.com, Michael Bottini , "David E . Box" Subject: [PATCH 2/8] platform/x86/intel/pmc: Add PSON residency counter Date: Mon, 18 Dec 2023 20:22:10 -0800 Message-Id: <20231219042216.2592029-2-rajvi.jingar@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231219042216.2592029-1-rajvi.jingar@linux.intel.com> References: <20231219042216.2592029-1-rajvi.jingar@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Rajvi Jingar Tiger Lake platform onwards, devices have the capability to track the duration of time that their Power Supply Units (PSUs) are turned off during S0ix. This patch adds a debugfs file `pson_residency_usec` to provide access to this counter. Signed-off-by: Michael Bottini Signed-off-by: Rajvi Jingar Signed-off-by: David E. Box --- drivers/platform/x86/intel/pmc/core.c | 37 +++++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index 983e3a8f4910..91e5e500eb41 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -208,6 +208,20 @@ static int pmc_core_dev_state_get(void *data, u64 *val) DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_dev_state, pmc_core_dev_state_get, NULL, "%llu\n"); +static int pmc_core_pson_residency_get(void *data, u64 *val) +{ + struct pmc *pmc = data; + const struct pmc_reg_map *map = pmc->map; + u32 value; + + value = pmc_core_reg_read(pmc, map->pson_residency_offset); + *val = (u64)value * map->pson_residency_counter_step; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(pmc_core_pson_residency, pmc_core_pson_residency_get, NULL, "%llu\n"); + static int pmc_core_check_read_lock_bit(struct pmc *pmc) { u32 value; @@ -1092,6 +1106,24 @@ int get_primary_reg_base(struct pmc *pmc) return 0; } +static bool pmc_core_is_pson_residency_enabled(struct pmc_dev *pmcdev) +{ + struct platform_device *pdev = pmcdev->pdev; + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); + u8 val; + + if (!adev) + return false; + + if (fwnode_property_read_u8(acpi_fwnode_handle(adev), + "intel-cec-pson-switching-enabled-in-s0", + &val)) + return false; + + return val == 1; +} + + static void pmc_core_dbgfs_unregister(struct pmc_dev *pmcdev) { debugfs_remove_recursive(pmcdev->dbgfs_dir); @@ -1162,6 +1194,11 @@ static void pmc_core_dbgfs_register(struct pmc_dev *pmcdev) &pmc_core_substate_req_regs_fops); } + if (primary_pmc->map->pson_residency_offset && pmc_core_is_pson_residency_enabled(pmcdev)) { + debugfs_create_file("pson_residency_usec", 0444, + pmcdev->dbgfs_dir, primary_pmc, &pmc_core_pson_residency); + } + if (pmcdev->has_die_c6) { debugfs_create_file("die_c6_us_show", 0444, pmcdev->dbgfs_dir, pmcdev, diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index 6d7673145f90..91cb34a6505c 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -323,6 +323,8 @@ struct pmc_reg_map { const u32 lpm_live_status_offset; const u32 etr3_offset; const u8 *lpm_reg_index; + const u32 pson_residency_offset; + const u32 pson_residency_counter_step; }; /** -- 2.34.1