From patchwork Wed Mar 8 07:06:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 66036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp180969wrd; Tue, 7 Mar 2023 23:08:05 -0800 (PST) X-Google-Smtp-Source: AK7set88G+QdOjBP4om53dLQ43nRapqJ3GgB5QUgapI7YZdw4h0y9/2RyGy4yORcRaFmVdJUZQqa X-Received: by 2002:a17:90b:1c88:b0:234:1d1d:6ae6 with SMTP id oo8-20020a17090b1c8800b002341d1d6ae6mr17989265pjb.1.1678259285553; Tue, 07 Mar 2023 23:08:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678259285; cv=none; d=google.com; s=arc-20160816; b=fHqxxMrXJqgMoT9PRN/EutZ7pvYhhbySdVLK4qCaPrMOxydU0lOMAtDxuIVX6DoCLR J5XuIRotYPd0TjaDE2af5Rb+5puMrPfjsNnJh8U1wtO7lmIEhbEmflADRnqeAUhUDKry ySGp9402Dp7NYP9wQk0mMW99XrXdCmEzDPC5rguqWZF/FhtLJQPE0X4RbwkufigU5Ewg BYcRcxZoEBPacudPamP0T9WtqFa3k7npmo53Aq0EyTEz7YCfAzLvrylJdWX7s2jl/+bG Hfgkyj4dqWU8aY3MfUrqFivyneFJ9NOyXvUBsa6JwJuwAiyYVErBiUkDcBHfYYwxrMtG ga8Q== 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=kLvTY6XnQvLlyzxXlMBHTlcoSGX0IFgPh1SayPNxWC0=; b=ACUnV4qysi52RY1ruV5D6TZssPCdaq36HiOJ+R3OfsXHCpSzfURMLqEb4sp3Zvkc5X 5oRTlkfVQhSXnQrRlKEr9maeZo79wtQID05A+0OAUBajBypt0Fs61Z/SoTMKWjZZF4Px Y29FgEhTa/QqfZLt+jgOiH2z9nhfiA7uRzZaIUSHxJPdnpBm5KmDEPlUWtsRBCzdCJQU hsoB8xNgdZdVjkCcrr/Ge6l2alSj4V0fdt+rSPAT7lrPsGmuQXrX7UuTV+2WBV+em4/6 HmjG8pBvjSft66QJtxTU/FzRjvGXnj+svu7NV6r1b+LnBf4pbkftFKJJbq9DRpzp0Fwr kHfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HH2wroMq; 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 bj19-20020a17090b089300b002340e196aa0si12559387pjb.176.2023.03.07.23.07.51; Tue, 07 Mar 2023 23:08:05 -0800 (PST) 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=HH2wroMq; 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 S229945AbjCHHHD (ORCPT + 99 others); Wed, 8 Mar 2023 02:07:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjCHHGx (ORCPT ); Wed, 8 Mar 2023 02:06:53 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8519BA2F04; Tue, 7 Mar 2023 23:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678259205; x=1709795205; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nHC2S8VQU/i3DgShSFHJyWHqj0biVys2rxofZiFuJkg=; b=HH2wroMqxTzOjxUH+ytFV+pdJEpUryJMI+3W7d0c/Igg/T7qw55PUzr+ XSjZSNUvMYp6jDgNuQpDSfivBMZf9vCvhmThbB438R1ZO1YggJQIAcQ5u IZQHK4NcSYFu4vURXAtbOYkv5tiQxYO6f3HLn0ukIEEMOfwhaYq8CzA1J tFteEpCPrcMYBpZhhE8+p9wkx/RArB1x+NSJ/1VBw5M8DTNd+n8dEju9K J/O/RTeF1i64IMM746lx3kbvDO/1HtKcYJw4XxExdokIs6OiuCPbS/y6p fzKGQMjyd8pt1lBwwMfk9FDkQLnCAA/QsoPXFOl+/zTee9OftuqY7SjSO g==; X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="333553967" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="333553967" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 23:06:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="850986377" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="850986377" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga005.jf.intel.com with ESMTP; 07 Mar 2023 23:06:43 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Zhang Rui , Pragya Tanwar Subject: [PATCH v2 1/8] platform/x86: ISST: Add support for MSR 0x54 Date: Tue, 7 Mar 2023 23:06:35 -0800 Message-Id: <20230308070642.1727167-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230308070642.1727167-1-srinivas.pandruvada@linux.intel.com> References: <20230308070642.1727167-1-srinivas.pandruvada@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?1759782408765366376?= X-GMAIL-MSGID: =?utf-8?q?1759782408765366376?= To map Linux CPU numbering scheme to hardware CPU numbering scheme MSR 0x53 is getting used. But for new generation of CPUs, this MSR is not valid. Since this is model specific MSR, this is possible. A new MSR 0x54 is defined for this purpose. User space can use the API version to distinguish format from MSR 0x53. Intel speed select utility is updated to use the new format based on the API version. Signed-off-by: Srinivas Pandruvada Reviewed-by: Zhang Rui Tested-by: Pragya Tanwar --- v2 - Don't do any format conversion, let user space do this .../intel/speed_select_if/isst_if_common.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_if_common.c b/drivers/platform/x86/intel/speed_select_if/isst_if_common.c index 19e671500f00..e0572a29212e 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_if_common.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_if_common.c @@ -19,9 +19,13 @@ #include #include +#include +#include + #include "isst_if_common.h" #define MSR_THREAD_ID_INFO 0x53 +#define MSR_PM_LOGICAL_ID 0x54 #define MSR_CPU_BUS_NUMBER 0x128 static struct isst_if_cmd_cb punit_callbacks[ISST_IF_DEV_MAX]; @@ -31,6 +35,7 @@ static int punit_msr_white_list[] = { MSR_CONFIG_TDP_CONTROL, MSR_TURBO_RATIO_LIMIT1, MSR_TURBO_RATIO_LIMIT2, + MSR_PM_LOGICAL_ID, }; struct isst_valid_cmd_ranges { @@ -73,6 +78,8 @@ struct isst_cmd { u32 param; }; +static bool isst_hpm_support; + static DECLARE_HASHTABLE(isst_hash, 8); static DEFINE_MUTEX(isst_hash_lock); @@ -411,11 +418,20 @@ static int isst_if_cpu_online(unsigned int cpu) isst_cpu_info[cpu].pci_dev[1] = _isst_if_get_pci_dev(cpu, 1, 30, 1); } + if (isst_hpm_support) { + + ret = rdmsrl_safe(MSR_PM_LOGICAL_ID, &data); + if (!ret) + goto set_punit_id; + } + ret = rdmsrl_safe(MSR_THREAD_ID_INFO, &data); if (ret) { isst_cpu_info[cpu].punit_cpu_id = -1; return ret; } + +set_punit_id: isst_cpu_info[cpu].punit_cpu_id = data; isst_restore_msr_local(cpu); @@ -704,6 +720,12 @@ static struct miscdevice isst_if_char_driver = { .fops = &isst_if_char_driver_ops, }; +static const struct x86_cpu_id hpm_cpu_ids[] = { + X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SIERRAFOREST_X, NULL), + {} +}; + static int isst_misc_reg(void) { mutex_lock(&punit_misc_dev_reg_lock); @@ -711,6 +733,12 @@ static int isst_misc_reg(void) goto unlock_exit; if (!misc_usage_count) { + const struct x86_cpu_id *id; + + id = x86_match_cpu(hpm_cpu_ids); + if (id) + isst_hpm_support = true; + misc_device_ret = isst_if_cpu_info_init(); if (misc_device_ret) goto unlock_exit;