From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: hdegoede@redhat.com, markgross@kernel.org
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH 05/12] platform/x86: ISST: Add support for MSR 0x54
Date: Fri, 10 Feb 2023 22:32:50 -0800 [thread overview]
Message-ID: <20230211063257.311746-6-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20230211063257.311746-1-srinivas.pandruvada@linux.intel.com>
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. Use this MSR and convert the IOCTL format
to match existing MSR 0x53, in this case user spaces don't need to
be aware of this change.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
.../intel/speed_select_if/isst_if_common.c | 51 +++++++++++++++++++
1 file changed, 51 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 60e58b0b3835..97d1b4566535 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 <linux/uaccess.h>
#include <uapi/linux/isst_if.h>
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+
#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,43 @@ 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) {
+ u64 raw_data;
+
+ ret = rdmsrl_safe(MSR_PM_LOGICAL_ID, &raw_data);
+ if (!ret) {
+ /*
+ * Use the same format as MSR 53, for user space harmony
+ * Format
+ * Bit 0 – thread ID
+ * Bit 8:1 – core ID
+ * Bit 13:9 – Compute domain ID (aka die ID)
+ * From the MSR 0x54 format
+ * [15:11] PM_DOMAIN_ID
+ * [10:3] MODULE_ID (aka IDI_AGENT_ID)
+ * [2:0] LP_ID (We don't care about these bits we only
+ * care die and core id
+ * For Atom:
+ * [2] Always 0
+ * [1:0] core ID within module
+ * For Core
+ * [2:1] Always 0
+ * [0] thread ID
+ */
+ data = (raw_data >> 11) & 0x1f;
+ data <<= 9;
+ data |= (((raw_data >> 3) & 0xff) << 1);
+ 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 +743,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 +756,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;
--
2.39.1
next prev parent reply other threads:[~2023-02-11 6:33 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-11 6:32 [PATCH 00/12] platform/x86: ISST: Use TPMI interface Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 01/12] platform/x86: ISST: Fix kernel documentation warnings Srinivas Pandruvada
2023-03-01 14:23 ` Hans de Goede
2023-03-01 14:48 ` srinivas pandruvada
2023-03-01 14:48 ` Hans de Goede
2023-02-11 6:32 ` [PATCH 02/12] platform/x86: ISST: Add TPMI target Srinivas Pandruvada
2023-03-01 14:25 ` Hans de Goede
2023-02-11 6:32 ` [PATCH 03/12] platform/x86: ISST: Add IOCTL default callback Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 04/12] platform/x86: ISST: Add API version of the target Srinivas Pandruvada
2023-02-11 6:32 ` Srinivas Pandruvada [this message]
2023-03-01 14:30 ` [PATCH 05/12] platform/x86: ISST: Add support for MSR 0x54 Hans de Goede
2023-03-01 14:41 ` srinivas pandruvada
2023-03-01 14:46 ` Hans de Goede
2023-02-11 6:32 ` [PATCH 06/12] platform/x86: ISST: Enumerate TPMI SST and create framework Srinivas Pandruvada
2023-03-01 14:37 ` Hans de Goede
2023-03-01 14:45 ` srinivas pandruvada
2023-03-01 14:47 ` Hans de Goede
2023-02-11 6:32 ` [PATCH 07/12] platform/x86: ISST: Parse SST MMIO and update instance Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 08/12] platform/x86: ISST: Add SST-CP support via TPMI Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 09/12] platform/x86: ISST: Add SST-PP " Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 10/12] platform/x86: ISST: Add SST-BF " Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 11/12] platform/x86: ISST: Add SST-TF " Srinivas Pandruvada
2023-02-11 6:32 ` [PATCH 12/12] platform/x86: ISST: Add suspend/resume callbacks Srinivas Pandruvada
2023-03-01 14:40 ` Hans de Goede
2023-03-01 14:46 ` srinivas pandruvada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230211063257.311746-6-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®