From patchwork Wed Mar 15 18:34:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 70365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp57066wrt; Wed, 15 Mar 2023 11:38:31 -0700 (PDT) X-Google-Smtp-Source: AK7set8zyXRiLpKBJCDtv7H6604R13hrvmHINmM88G4ez3LKMragY1YIUhrlvdumX0EW3TdI7UEZ X-Received: by 2002:a05:6a20:548f:b0:d5:10ca:5264 with SMTP id i15-20020a056a20548f00b000d510ca5264mr862935pzk.59.1678905510739; Wed, 15 Mar 2023 11:38:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678905510; cv=none; d=google.com; s=arc-20160816; b=q7m2XX8IDxswz3Pp4JjT7xEFEYK7irnI3dExMtVddr1TZF03BGI/egZppUG8iAAXm0 YpubyLYLGhAn1cLbiHFIE8Xte7jafQ0YzK6moXz6F5j1un3AW63CPi861rqo91UUaDgb Mry0QFBvFiGzW/RNAKr7URJO9DtSDxfvlVERbLPX38CjrO3AiXw6fQqgHBIlRAm5e6Hs bxCnNza001ATMIpQKBtIGGbqoDB+KHvcVh2fTapGTgrX16XSjt7DSL1KQqzYg8N+v9od 1C7fJ0wqD40Qh8kYX+xX1cTgyqMcIqN0dWEZp0Th3jRDcHv7nobLGxGDVqYOV415Od/W 5YlQ== 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=3Lg4fZbMssG8jcBtSAZMSnPrO1OzJEvxuIuM/sBPgSY=; b=VwnepfJCiskbh4y07KzMKNnFIil5ddNF2bp/MnHHr3ZN42VxCIXQuN2og0NS32FwKg X2bqqdvfuvfCYo4mpDnrU7nth+/TJExfLlYHRQMAULdHq2M1869KhIYNrT0dE9S9oPgY bj3EqpHIzOHcfhXauARfUfJjWvc5bQ1QWIZXbabottVaRYXkMZAlBXYLxfT7i9ryo8Wp be9N74H4TX9sEXqYLsqjqLWkwBYi1AycvQBtYVUXmqfwBp9zp7dMaf3LjmaGTudU/iJ8 1qaMc+o/Oyc5maUtGTXyqrFE5494esqkcoP7rE4VGSsb6XGcjm3zUUjIyC+WbvTL5f8X +pig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BMtYe1nb; 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 a24-20020aa795b8000000b0058bcb6283edsi5280980pfk.288.2023.03.15.11.38.16; Wed, 15 Mar 2023 11:38:30 -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=BMtYe1nb; 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 S232143AbjCOSeg (ORCPT + 99 others); Wed, 15 Mar 2023 14:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231875AbjCOSeP (ORCPT ); Wed, 15 Mar 2023 14:34:15 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A6E87DA5; Wed, 15 Mar 2023 11:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678905254; x=1710441254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n16cQ4kymyynRY6n5R36txntCnbHvo09MUKHWcfcmk0=; b=BMtYe1nbaAgf5695fyjDZ3luVhYEZCd2/3SWosp/EWTpbdp++3PP3+w0 ROTHdEb+bm09ONRmRkwAp5bD4Y5IFDALe10mjxyp603UvnIOQt1ZbIL63 ejmsWax1H4ejggos+U9G7uRA6zMlReiJrkzpLyhPDFcaBbaX3FPZ3OXhg daxxOGz8FeyiVZz0EzsFHv8Fw1tDLIFQ6Iz1Pmrt3OiU3NQ2SdHXTMbq1 XhHfW8MW5J0e/ynurUfsm8hDaAK5tsN41s0B5itXln6bRQG+6yVatHv9I RXSGt2emayU50VGXpBC8pq5AuzdZhPBQFVw2KLvRILWhdLdps1HWAkzyG w==; X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="340154556" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="340154556" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 11:34:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="925435217" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="925435217" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 15 Mar 2023 11:34:08 -0700 Received: from debox1-desk4.intel.com (unknown [10.209.75.205]) by linux.intel.com (Postfix) with ESMTP id CF8D1580BF6; Wed, 15 Mar 2023 11:34:07 -0700 (PDT) From: "David E. Box" To: irenic.rajneesh@gmail.com, david.e.box@linux.intel.com, hdegoede@redhat.com, markgross@kernel.org, andy.shevchenko@gmail.com, rajvi.jingar@linux.intel.com, xi.pardee@intel.com Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH 07/11] platform/x86/intel/pmc: Alder Lake slp_s0_residency fix Date: Wed, 15 Mar 2023 11:34:01 -0700 Message-Id: <20230315183405.2465630-8-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315183405.2465630-1-david.e.box@linux.intel.com> References: <20230315183405.2465630-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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?1760460024884828842?= X-GMAIL-MSGID: =?utf-8?q?1760460024884828842?= From: Rajvi Jingar For platforms with Alder Lake PCH (Alder Lake S and Raptor Lake S) the slp_s0_residency attribute has been reporting the wrong value. Unlike other platforms, ADL PCH does not have a counter for the time that the SLP_S0 signal was asserted. Instead, firmware uses the aggregate of the Low Power Mode (LPM) substate counters as the S0ix value. Since the LPM counters run at a different frequency, this lead to misreporting of the S0ix time. Add a check for Alder Lake PCH and adjust the frequency accordingly when display slp_s0_residency. Fixes: bbab31101f44 ("platform/x86/intel: pmc/core: Add Alderlake support to pmc core driver") Signed-off-by: Rajvi Jingar Signed-off-by: David E. Box --- drivers/platform/x86/intel/pmc/core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index e489d2175e42..61ca7c37fb02 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -66,7 +66,18 @@ static inline void pmc_core_reg_write(struct pmc_dev *pmcdev, int reg_offset, static inline u64 pmc_core_adjust_slp_s0_step(struct pmc_dev *pmcdev, u32 value) { - return (u64)value * pmcdev->map->slp_s0_res_counter_step; + /* + * ADL PCH does not have the SLP_S0 counter and LPM Residency counters are + * used as a workaround which uses 30.5 usec tick. All other client + * programs have the legacy SLP_S0 residency counter that is using the 122 + * usec tick. + */ + const int lpm_adj_x2 = pmcdev->map->lpm_res_counter_step_x2; + + if (pmcdev->map == &adl_reg_map) + return (u64)value * GET_X2_COUNTER((u64)lpm_adj_x2); + else + return (u64)value * pmcdev->map->slp_s0_res_counter_step; } static int set_etr3(struct pmc_dev *pmcdev)