Skip to content

Commit f8d23cd

Browse files
committed
Merge: platform/x86: ISST: and tools/power/x86/intel-speed-select: updates
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5626 Description: updates for platform/x86 ISST and tools/power/x86/intel-speed-select JIRA: https://issues.redhat.com/browse/RHEL-65196 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=65493656 Tested: Successful platform test results on Intel (intel-eaglestream-emr-03) system. Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Desnes Nunes <desnesn@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents a4511ae + 08841a4 commit f8d23cd

File tree

7 files changed

+77
-62
lines changed

7 files changed

+77
-62
lines changed

arch/x86/include/asm/intel-family.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@
193193

194194
#define INTEL_FAM6_ARROWLAKE 0xC6
195195

196+
#define INTEL_PANTHERLAKE_L IFM(6, 0xCC)
197+
196198
/* "Small Core" Processors (Atom/E-Core) */
197199

198200
#define INTEL_FAM6_ATOM_BONNELL 0x1C /* Diamondville, Pineview */
@@ -259,4 +261,7 @@
259261
#define INTEL_FAM5_QUARK_X1000 0x09 /* Quark X1000 SoC */
260262
#define INTEL_QUARK_X1000 IFM(5, 0x09) /* Quark X1000 SoC */
261263

264+
/* Family 19 */
265+
#define INTEL_PANTHERCOVE_X IFM(19, 0x01) /* Diamond Rapids */
266+
262267
#endif /* _ASM_X86_INTEL_FAMILY_H */

drivers/platform/x86/intel/speed_select_if/isst_if_common.c

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,6 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd,
653653

654654
/* Lock to prevent module registration when already opened by user space */
655655
static DEFINE_MUTEX(punit_misc_dev_open_lock);
656-
/* Lock to allow one shared misc device for all ISST interfaces */
657-
static DEFINE_MUTEX(punit_misc_dev_reg_lock);
658-
static int misc_usage_count;
659-
static int misc_device_ret;
660656
static int misc_device_open;
661657

662658
static int isst_if_open(struct inode *inode, struct file *file)
@@ -720,55 +716,25 @@ static struct miscdevice isst_if_char_driver = {
720716
.fops = &isst_if_char_driver_ops,
721717
};
722718

723-
static const struct x86_cpu_id hpm_cpu_ids[] = {
724-
X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_D, NULL),
725-
X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, NULL),
726-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT, NULL),
727-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT_X, NULL),
728-
{}
729-
};
730-
731719
static int isst_misc_reg(void)
732720
{
733-
mutex_lock(&punit_misc_dev_reg_lock);
734-
if (misc_device_ret)
735-
goto unlock_exit;
736-
737-
if (!misc_usage_count) {
738-
const struct x86_cpu_id *id;
739-
740-
id = x86_match_cpu(hpm_cpu_ids);
741-
if (id)
742-
isst_hpm_support = true;
743-
744-
misc_device_ret = isst_if_cpu_info_init();
745-
if (misc_device_ret)
746-
goto unlock_exit;
721+
int ret;
747722

748-
misc_device_ret = misc_register(&isst_if_char_driver);
749-
if (misc_device_ret) {
750-
isst_if_cpu_info_exit();
751-
goto unlock_exit;
752-
}
753-
}
754-
misc_usage_count++;
723+
ret = isst_if_cpu_info_init();
724+
if (ret)
725+
return ret;
755726

756-
unlock_exit:
757-
mutex_unlock(&punit_misc_dev_reg_lock);
727+
ret = misc_register(&isst_if_char_driver);
728+
if (ret)
729+
isst_if_cpu_info_exit();
758730

759-
return misc_device_ret;
731+
return ret;
760732
}
761733

762734
static void isst_misc_unreg(void)
763735
{
764-
mutex_lock(&punit_misc_dev_reg_lock);
765-
if (misc_usage_count)
766-
misc_usage_count--;
767-
if (!misc_usage_count && !misc_device_ret) {
768-
misc_deregister(&isst_if_char_driver);
769-
isst_if_cpu_info_exit();
770-
}
771-
mutex_unlock(&punit_misc_dev_reg_lock);
736+
misc_deregister(&isst_if_char_driver);
737+
isst_if_cpu_info_exit();
772738
}
773739

774740
/**
@@ -788,11 +754,12 @@ static void isst_misc_unreg(void)
788754
*/
789755
int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb)
790756
{
791-
int ret;
792-
793757
if (device_type >= ISST_IF_DEV_MAX)
794758
return -EINVAL;
795759

760+
if (device_type < ISST_IF_DEV_TPMI && isst_hpm_support)
761+
return -ENODEV;
762+
796763
mutex_lock(&punit_misc_dev_open_lock);
797764
/* Device is already open, we don't want to add new callbacks */
798765
if (misc_device_open) {
@@ -807,15 +774,6 @@ int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb)
807774
punit_callbacks[device_type].registered = 1;
808775
mutex_unlock(&punit_misc_dev_open_lock);
809776

810-
ret = isst_misc_reg();
811-
if (ret) {
812-
/*
813-
* No need of mutex as the misc device register failed
814-
* as no one can open device yet. Hence no contention.
815-
*/
816-
punit_callbacks[device_type].registered = 0;
817-
return ret;
818-
}
819777
return 0;
820778
}
821779
EXPORT_SYMBOL_GPL(isst_if_cdev_register);
@@ -831,7 +789,6 @@ EXPORT_SYMBOL_GPL(isst_if_cdev_register);
831789
*/
832790
void isst_if_cdev_unregister(int device_type)
833791
{
834-
isst_misc_unreg();
835792
mutex_lock(&punit_misc_dev_open_lock);
836793
punit_callbacks[device_type].def_ioctl = NULL;
837794
punit_callbacks[device_type].registered = 0;
@@ -841,5 +798,52 @@ void isst_if_cdev_unregister(int device_type)
841798
}
842799
EXPORT_SYMBOL_GPL(isst_if_cdev_unregister);
843800

801+
#define SST_HPM_SUPPORTED 0x01
802+
#define SST_MBOX_SUPPORTED 0x02
803+
804+
static const struct x86_cpu_id isst_cpu_ids[] = {
805+
X86_MATCH_VFM(INTEL_ATOM_CRESTMONT, SST_HPM_SUPPORTED),
806+
X86_MATCH_VFM(INTEL_ATOM_CRESTMONT_X, SST_HPM_SUPPORTED),
807+
X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, 0),
808+
X86_MATCH_VFM(INTEL_GRANITERAPIDS_D, SST_HPM_SUPPORTED),
809+
X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, SST_HPM_SUPPORTED),
810+
X86_MATCH_VFM(INTEL_ICELAKE_D, 0),
811+
X86_MATCH_VFM(INTEL_ICELAKE_X, 0),
812+
X86_MATCH_VFM(INTEL_PANTHERCOVE_X, SST_HPM_SUPPORTED),
813+
X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, 0),
814+
X86_MATCH_VFM(INTEL_SKYLAKE_X, SST_MBOX_SUPPORTED),
815+
{}
816+
};
817+
MODULE_DEVICE_TABLE(x86cpu, isst_cpu_ids);
818+
819+
static int __init isst_if_common_init(void)
820+
{
821+
const struct x86_cpu_id *id;
822+
823+
id = x86_match_cpu(isst_cpu_ids);
824+
if (!id)
825+
return -ENODEV;
826+
827+
if (id->driver_data == SST_HPM_SUPPORTED) {
828+
isst_hpm_support = true;
829+
} else if (id->driver_data == SST_MBOX_SUPPORTED) {
830+
u64 data;
831+
832+
/* Can fail only on some Skylake-X generations */
833+
if (rdmsrl_safe(MSR_OS_MAILBOX_INTERFACE, &data) ||
834+
rdmsrl_safe(MSR_OS_MAILBOX_DATA, &data))
835+
return -ENODEV;
836+
}
837+
838+
return isst_misc_reg();
839+
}
840+
module_init(isst_if_common_init)
841+
842+
static void __exit isst_if_common_exit(void)
843+
{
844+
isst_misc_unreg();
845+
}
846+
module_exit(isst_if_common_exit)
847+
844848
MODULE_DESCRIPTION("ISST common interface module");
845849
MODULE_LICENSE("GPL v2");

drivers/platform/x86/intel/speed_select_if/isst_if_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#define PCI_DEVICE_ID_INTEL_RAPL_PRIO_DEVID_1 0x3251
1717
#define PCI_DEVICE_ID_INTEL_CFG_MBOX_DEVID_1 0x3259
1818

19+
#define MSR_OS_MAILBOX_INTERFACE 0xB0
20+
#define MSR_OS_MAILBOX_DATA 0xB1
21+
1922
/*
2023
* Validate maximum commands in a single request.
2124
* This is enough to handle command to every core in one ioctl, or all

drivers/platform/x86/intel/speed_select_if/isst_if_mbox_msr.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#include "isst_if_common.h"
2323

24-
#define MSR_OS_MAILBOX_INTERFACE 0xB0
25-
#define MSR_OS_MAILBOX_DATA 0xB1
2624
#define MSR_OS_MAILBOX_BUSY_BIT 31
2725

2826
/*
@@ -161,7 +159,7 @@ static struct notifier_block isst_pm_nb = {
161159
};
162160

163161
static const struct x86_cpu_id isst_if_cpu_ids[] = {
164-
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, NULL),
162+
X86_MATCH_VFM(INTEL_SKYLAKE_X, NULL),
165163
{}
166164
};
167165
MODULE_DEVICE_TABLE(x86cpu, isst_if_cpu_ids);

drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,7 @@ int tpmi_sst_dev_add(struct auxiliary_device *auxdev)
15501550
goto unlock_free;
15511551
}
15521552

1553-
ret = sst_main(auxdev, &pd_info[i]);
1554-
if (ret) {
1553+
if (sst_main(auxdev, &pd_info[i])) {
15551554
/*
15561555
* This entry is not valid, hardware can partially
15571556
* populate dies. In this case MMIO will have 0xFFs.

tools/power/x86/intel-speed-select/isst-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct process_cmd_struct {
1616
int arg;
1717
};
1818

19-
static const char *version_str = "v1.19";
19+
static const char *version_str = "v1.20";
2020

2121
static const int supported_api_ver = 3;
2222
static struct isst_if_platform_info isst_platform_info;

tools/power/x86/intel-speed-select/isst-core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ int isst_set_trl(struct isst_id *id, unsigned long long trl)
283283
return 0;
284284
}
285285

286+
#define MSR_TRL_FREQ_MULTIPLIER 100
287+
286288
int isst_set_trl_from_current_tdp(struct isst_id *id, unsigned long long trl)
287289
{
288290
unsigned long long msr_trl;
@@ -310,6 +312,10 @@ int isst_set_trl_from_current_tdp(struct isst_id *id, unsigned long long trl)
310312
for (i = 0; i < 8; ++i) {
311313
unsigned long long _trl = trl[i];
312314

315+
/* MSR is always in 100 MHz unit */
316+
if (isst_get_disp_freq_multiplier() == 1)
317+
_trl /= MSR_TRL_FREQ_MULTIPLIER;
318+
313319
msr_trl |= (_trl << (i * 8));
314320
}
315321
}

0 commit comments

Comments
 (0)