Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deepin Kernel SIG] [Intel] Tpmi based drivers backport from 6.11 #541

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1fc03f8
platform/x86/intel/tpmi: Add debugfs support for read/write blocked
spandruvada Sep 25, 2023
ef491e6
platform/x86/intel/tpmi: Don't create devices for disabled features
spandruvada Dec 4, 2023
d61249b
platform/x86/intel/tpmi: Modify external interface to get read/write …
spandruvada Dec 4, 2023
35da922
platform/x86/intel/tpmi: Move TPMI ID definition
spandruvada Dec 4, 2023
00269f6
platform/x86/intel/tpmi: Check major version change for TPMI Information
spandruvada Apr 23, 2024
99bfc23
platform/x86/intel/tpmi: Align comments in kernel-doc
spandruvada Apr 23, 2024
bc1b0b0
platform/x86/intel/tpmi: Add additional TPMI header fields
spandruvada Apr 23, 2024
c728988
platform/x86: ISST: Use fuse enabled mask instead of allowed levels
spandruvada Oct 3, 2023
4ae7d8f
platform/x86: ISST: Allow level 0 to be not present
spandruvada Oct 3, 2023
60f4cb0
platform/x86: intel_speed_select_if: Remove hardcoded map size
spandruvada Oct 3, 2023
3962d08
platform/x86: intel_speed_select_if: Use devm_ioremap_resource
spandruvada Oct 3, 2023
fda6751
platform/x86: ISST: Ignore minor version change
spandruvada Oct 3, 2023
65d19e8
platform/x86: ISST: Process read/write blocked feature status
spandruvada Dec 4, 2023
b2369f8
platform/x86: ISST: Allow reading core-power state on HWP disabled sy…
spandruvada Feb 29, 2024
6c837ae
platform/x86: ISST: Use local variable for auxdev->dev
spandruvada Apr 23, 2024
aeab204
platform/x86: ISST: Shorten the assignments for power_domain_info
spandruvada Apr 23, 2024
3ce9102
platform/x86: ISST: Support partitioned systems
spandruvada Apr 23, 2024
2cc7892
platform/x86: ISST: Use in_range() to check package ID validity
spandruvada Apr 23, 2024
c339ce5
platform/x86: ISST: Add dev_fmt
spandruvada Apr 23, 2024
aeaa423
platform/x86: ISST: Add missing MODULE_DESCRIPTION
spandruvada Apr 23, 2024
107437e
platform/x86: ISST: Support SST-BF and SST-TF per level
spandruvada Apr 30, 2024
4c14fa1
platform/x86: ISST: fix use-after-free in tpmi_sst_dev_remove()
harshimogalapalli May 17, 2024
ac7a554
platform/x86: ISST: Add model specific loading for common module
spandruvada May 31, 2024
e4259c5
platform/x86: ISST: Avoid some SkyLake server models
spandruvada May 31, 2024
36f67ad
platform/x86: ISST: Use only TPMI interface when present
spandruvada May 31, 2024
b91a713
platform/x86: ISST: Fix return value on last invalid resource
spandruvada Aug 16, 2024
9bd20f9
platform/x86: ISST: Simplify isst_misc_reg() and isst_misc_unreg()
spandruvada Jul 31, 2024
855c00b
platform/x86/intel-uncore-freq: Ignore minor version change
spandruvada Oct 3, 2023
bf2f53a
platform/x86/intel-uncore-freq: Process read/write blocked feature st…
spandruvada Dec 4, 2023
0b33c4c
platform/x86/intel-uncore-freq: Increase minor number support
spandruvada Apr 15, 2024
cd1db53
platform/x86/intel-uncore-freq: Re-arrange bit masks
Jun 17, 2024
cce4b58
platform/x86/intel-uncore-freq: Get rid of magic values
Jun 17, 2024
687a100
platform/x86/intel-uncore-freq: Get rid of magic min_max argument
Jun 17, 2024
14b66d2
platform/x86/intel-uncore-freq: Use uncore_index with read_control_freq
Jun 17, 2024
781ecab
platform/x86/intel-uncore-freq: Get rid of uncore_read_freq driver API
Jun 17, 2024
2495c64
platform/x86/intel-uncore-freq: Rename the sysfs helper macro names
Jun 17, 2024
8bb6ec2
platform/x86/intel-uncore-freq: Use generic helpers for current frequ…
Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 60 additions & 56 deletions drivers/platform/x86/intel/speed_select_if/isst_if_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,6 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd,

/* Lock to prevent module registration when already opened by user space */
static DEFINE_MUTEX(punit_misc_dev_open_lock);
/* Lock to allow one shared misc device for all ISST interfaces */
static DEFINE_MUTEX(punit_misc_dev_reg_lock);
static int misc_usage_count;
static int misc_device_ret;
static int misc_device_open;

static int isst_if_open(struct inode *inode, struct file *file)
Expand Down Expand Up @@ -720,55 +716,25 @@ 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_D, NULL),
X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, NULL),
X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT, NULL),
X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT_X, NULL),
{}
};

static int isst_misc_reg(void)
{
mutex_lock(&punit_misc_dev_reg_lock);
if (misc_device_ret)
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;
int ret;

misc_device_ret = misc_register(&isst_if_char_driver);
if (misc_device_ret) {
isst_if_cpu_info_exit();
goto unlock_exit;
}
}
misc_usage_count++;
ret = isst_if_cpu_info_init();
if (ret)
return ret;

unlock_exit:
mutex_unlock(&punit_misc_dev_reg_lock);
ret = misc_register(&isst_if_char_driver);
if (ret)
isst_if_cpu_info_exit();

return misc_device_ret;
return ret;
}

static void isst_misc_unreg(void)
{
mutex_lock(&punit_misc_dev_reg_lock);
if (misc_usage_count)
misc_usage_count--;
if (!misc_usage_count && !misc_device_ret) {
misc_deregister(&isst_if_char_driver);
isst_if_cpu_info_exit();
}
mutex_unlock(&punit_misc_dev_reg_lock);
misc_deregister(&isst_if_char_driver);
isst_if_cpu_info_exit();
}

/**
Expand All @@ -788,11 +754,12 @@ static void isst_misc_unreg(void)
*/
int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb)
{
int ret;

if (device_type >= ISST_IF_DEV_MAX)
return -EINVAL;

if (device_type < ISST_IF_DEV_TPMI && isst_hpm_support)
return -ENODEV;

mutex_lock(&punit_misc_dev_open_lock);
/* Device is already open, we don't want to add new callbacks */
if (misc_device_open) {
Expand All @@ -807,15 +774,6 @@ int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb)
punit_callbacks[device_type].registered = 1;
mutex_unlock(&punit_misc_dev_open_lock);

ret = isst_misc_reg();
if (ret) {
/*
* No need of mutex as the misc device register failed
* as no one can open device yet. Hence no contention.
*/
punit_callbacks[device_type].registered = 0;
return ret;
}
return 0;
}
EXPORT_SYMBOL_GPL(isst_if_cdev_register);
Expand All @@ -831,7 +789,6 @@ EXPORT_SYMBOL_GPL(isst_if_cdev_register);
*/
void isst_if_cdev_unregister(int device_type)
{
isst_misc_unreg();
mutex_lock(&punit_misc_dev_open_lock);
punit_callbacks[device_type].def_ioctl = NULL;
punit_callbacks[device_type].registered = 0;
Expand All @@ -841,4 +798,51 @@ void isst_if_cdev_unregister(int device_type)
}
EXPORT_SYMBOL_GPL(isst_if_cdev_unregister);

#define SST_HPM_SUPPORTED 0x01
#define SST_MBOX_SUPPORTED 0x02

static const struct x86_cpu_id isst_cpu_ids[] = {
X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT, SST_HPM_SUPPORTED),
X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT_X, SST_HPM_SUPPORTED),
X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X, 0),
X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_D, SST_HPM_SUPPORTED),
X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, SST_HPM_SUPPORTED),
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, 0),
X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0),
X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, 0),
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, SST_MBOX_SUPPORTED),
{}
};
MODULE_DEVICE_TABLE(x86cpu, isst_cpu_ids);

static int __init isst_if_common_init(void)
{
const struct x86_cpu_id *id;

id = x86_match_cpu(isst_cpu_ids);
if (!id)
return -ENODEV;

if (id->driver_data == SST_HPM_SUPPORTED) {
isst_hpm_support = true;
} else if (id->driver_data == SST_MBOX_SUPPORTED) {
u64 data;

/* Can fail only on some Skylake-X generations */
if (rdmsrl_safe(MSR_OS_MAILBOX_INTERFACE, &data) ||
rdmsrl_safe(MSR_OS_MAILBOX_DATA, &data))
return -ENODEV;
}

return isst_misc_reg();
}
module_init(isst_if_common_init)

static void __exit isst_if_common_exit(void)
{
isst_misc_unreg();
}
module_exit(isst_if_common_exit)

MODULE_DESCRIPTION("ISST common interface module");
MODULE_LICENSE("GPL v2");
3 changes: 3 additions & 0 deletions drivers/platform/x86/intel/speed_select_if/isst_if_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#define PCI_DEVICE_ID_INTEL_RAPL_PRIO_DEVID_1 0x3251
#define PCI_DEVICE_ID_INTEL_CFG_MBOX_DEVID_1 0x3259

#define MSR_OS_MAILBOX_INTERFACE 0xB0
#define MSR_OS_MAILBOX_DATA 0xB1

/*
* Validate maximum commands in a single request.
* This is enough to handle command to every core in one ioctl, or all
Expand Down
2 changes: 0 additions & 2 deletions drivers/platform/x86/intel/speed_select_if/isst_if_mbox_msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "isst_if_common.h"

#define MSR_OS_MAILBOX_INTERFACE 0xB0
#define MSR_OS_MAILBOX_DATA 0xB1
#define MSR_OS_MAILBOX_BUSY_BIT 31

/*
Expand Down
21 changes: 13 additions & 8 deletions drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
struct isst_mmio_range {
int beg;
int end;
int size;
};

static struct isst_mmio_range mmio_range_devid_0[] = {
{0x04, 0x14},
{0x20, 0xD0},
{0x04, 0x14, 0x18},
{0x20, 0xD0, 0xD4},
};

static struct isst_mmio_range mmio_range_devid_1[] = {
{0x04, 0x14},
{0x20, 0x11C},
{0x04, 0x14, 0x18},
{0x20, 0x11C, 0x120},
};

struct isst_if_device {
Expand Down Expand Up @@ -93,6 +94,7 @@ static int isst_if_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct isst_if_device *punit_dev;
struct isst_if_cmd_cb cb;
u32 mmio_base, pcu_base;
struct resource r;
u64 base_addr;
int ret;

Expand All @@ -114,13 +116,16 @@ static int isst_if_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

pcu_base &= GENMASK(10, 0);
base_addr = (u64)mmio_base << 23 | (u64) pcu_base << 12;
punit_dev->punit_mmio = devm_ioremap(&pdev->dev, base_addr, 256);
if (!punit_dev->punit_mmio)
return -ENOMEM;

punit_dev->mmio_range = (struct isst_mmio_range *) ent->driver_data;

r = DEFINE_RES_MEM(base_addr, punit_dev->mmio_range[1].size);
punit_dev->punit_mmio = devm_ioremap_resource(&pdev->dev, &r);
if (IS_ERR(punit_dev->punit_mmio))
return PTR_ERR(punit_dev->punit_mmio);

mutex_init(&punit_dev->mutex);
pci_set_drvdata(pdev, punit_dev);
punit_dev->mmio_range = (struct isst_mmio_range *) ent->driver_data;

memset(&cb, 0, sizeof(cb));
cb.cmd_size = sizeof(struct isst_if_io_reg);
Expand Down
Loading
Loading