Skip to content

Commit 1c0a50d

Browse files
committed
Merge tag 'platform-drivers-x86-v6.8-4' into pdx86/for-next
Merge tag 'platform-drivers-x86-v6.8-4' fixes into pdx86/for-next to resolve amd/pmf conflicts.
2 parents 30f96b2 + 0314ceb commit 1c0a50d

File tree

14 files changed

+194
-114
lines changed

14 files changed

+194
-114
lines changed

drivers/platform/x86/amd/pmf/core.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ static int amd_pmf_suspend_handler(struct device *dev)
297297
{
298298
struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
299299

300-
kfree(pdev->buf);
300+
if (pdev->smart_pc_enabled)
301+
cancel_delayed_work_sync(&pdev->pb_work);
301302

302303
if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
303304
amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_SUSPEND);
@@ -319,6 +320,9 @@ static int amd_pmf_resume_handler(struct device *dev)
319320
if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
320321
amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_RESUME);
321322

323+
if (pdev->smart_pc_enabled)
324+
schedule_delayed_work(&pdev->pb_work, msecs_to_jiffies(2000));
325+
322326
return 0;
323327
}
324328

@@ -337,9 +341,14 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)
337341
dev_dbg(dev->dev, "SPS enabled and Platform Profiles registered\n");
338342
}
339343

340-
if (!amd_pmf_init_smart_pc(dev)) {
344+
amd_pmf_init_smart_pc(dev);
345+
if (dev->smart_pc_enabled) {
341346
dev_dbg(dev->dev, "Smart PC Solution Enabled\n");
342-
} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
347+
/* If Smart PC is enabled, no need to check for other features */
348+
return;
349+
}
350+
351+
if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
343352
amd_pmf_init_auto_mode(dev);
344353
dev_dbg(dev->dev, "Auto Mode Init done\n");
345354
} else if (is_apmf_func_supported(dev, APMF_FUNC_DYN_SLIDER_AC) ||
@@ -358,7 +367,7 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev)
358367
amd_pmf_deinit_sps(dev);
359368
}
360369

361-
if (!dev->smart_pc_enabled) {
370+
if (dev->smart_pc_enabled) {
362371
amd_pmf_deinit_smart_pc(dev);
363372
} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
364373
amd_pmf_deinit_auto_mode(dev);

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,6 @@ struct apmf_dyn_slider_output {
524524
struct apmf_cnqf_power_set ps[APMF_CNQF_MAX];
525525
} __packed;
526526

527-
enum smart_pc_status {
528-
PMF_SMART_PC_ENABLED,
529-
PMF_SMART_PC_DISABLED,
530-
};
531-
532527
/* Smart PC - TA internals */
533528
enum system_state {
534529
SYSTEM_STATE_S0i3,

drivers/platform/x86/amd/pmf/tee-if.c

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,10 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
254254

255255
header = (struct cookie_header *)(dev->policy_buf + POLICY_COOKIE_OFFSET);
256256

257-
if (header->sign != POLICY_SIGN_COOKIE || !header->length)
257+
if (header->sign != POLICY_SIGN_COOKIE || !header->length) {
258+
dev_dbg(dev->dev, "cookie doesn't match\n");
258259
return -EINVAL;
260+
}
259261

260262
if (dev->policy_sz < header->length + 512)
261263
return -EINVAL;
@@ -265,15 +267,15 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
265267
res = amd_pmf_invoke_cmd_init(dev);
266268
if (res == TA_PMF_TYPE_SUCCESS) {
267269
/* Now its safe to announce that smart pc is enabled */
268-
dev->smart_pc_enabled = PMF_SMART_PC_ENABLED;
270+
dev->smart_pc_enabled = true;
269271
/*
270272
* Start collecting the data from TA FW after a small delay
271273
* or else, we might end up getting stale values.
272274
*/
273275
schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms * 3));
274276
} else {
275277
dev_err(dev->dev, "ta invoke cmd init failed err: %x\n", res);
276-
dev->smart_pc_enabled = PMF_SMART_PC_DISABLED;
278+
dev->smart_pc_enabled = false;
277279
return -EIO;
278280
}
279281

@@ -341,25 +343,6 @@ static void amd_pmf_remove_pb(struct amd_pmf_dev *dev) {}
341343
static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev) {}
342344
#endif
343345

344-
static int amd_pmf_get_bios_buffer(struct amd_pmf_dev *dev)
345-
{
346-
dev->policy_buf = kzalloc(dev->policy_sz, GFP_KERNEL);
347-
if (!dev->policy_buf)
348-
return -ENOMEM;
349-
350-
dev->policy_base = devm_ioremap(dev->dev, dev->policy_addr, dev->policy_sz);
351-
if (!dev->policy_base)
352-
return -ENOMEM;
353-
354-
memcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);
355-
356-
amd_pmf_hex_dump_pb(dev);
357-
if (pb_side_load)
358-
amd_pmf_open_pb(dev, dev->dbgfs_dir);
359-
360-
return amd_pmf_start_policy_engine(dev);
361-
}
362-
363346
static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, const void *data)
364347
{
365348
return ver->impl_id == TEE_IMPL_ID_AMDTEE;
@@ -458,22 +441,59 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
458441
return ret;
459442

460443
INIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd);
461-
amd_pmf_set_dram_addr(dev, true);
462-
amd_pmf_get_bios_buffer(dev);
444+
445+
ret = amd_pmf_set_dram_addr(dev, true);
446+
if (ret)
447+
goto error;
448+
449+
dev->policy_base = devm_ioremap(dev->dev, dev->policy_addr, dev->policy_sz);
450+
if (!dev->policy_base) {
451+
ret = -ENOMEM;
452+
goto error;
453+
}
454+
455+
dev->policy_buf = kzalloc(dev->policy_sz, GFP_KERNEL);
456+
if (!dev->policy_buf) {
457+
ret = -ENOMEM;
458+
goto error;
459+
}
460+
461+
memcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);
462+
463+
amd_pmf_hex_dump_pb(dev);
464+
463465
dev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL);
464-
if (!dev->prev_data)
465-
return -ENOMEM;
466+
if (!dev->prev_data) {
467+
ret = -ENOMEM;
468+
goto error;
469+
}
470+
471+
ret = amd_pmf_start_policy_engine(dev);
472+
if (ret)
473+
goto error;
474+
475+
if (pb_side_load)
476+
amd_pmf_open_pb(dev, dev->dbgfs_dir);
477+
478+
return 0;
466479

467-
return dev->smart_pc_enabled;
480+
error:
481+
amd_pmf_deinit_smart_pc(dev);
482+
483+
return ret;
468484
}
469485

470486
void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev)
471487
{
472-
if (pb_side_load)
488+
if (pb_side_load && dev->esbin)
473489
amd_pmf_remove_pb(dev);
474490

491+
cancel_delayed_work_sync(&dev->pb_work);
475492
kfree(dev->prev_data);
493+
dev->prev_data = NULL;
476494
kfree(dev->policy_buf);
477-
cancel_delayed_work_sync(&dev->pb_work);
495+
dev->policy_buf = NULL;
496+
kfree(dev->buf);
497+
dev->buf = NULL;
478498
amd_pmf_tee_deinit(dev);
479499
}

drivers/platform/x86/intel/int0002_vgpio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int int0002_probe(struct platform_device *pdev)
196196
* IRQs into gpiolib.
197197
*/
198198
ret = devm_request_irq(dev, irq, int0002_irq,
199-
IRQF_SHARED, "INT0002", chip);
199+
IRQF_ONESHOT | IRQF_SHARED, "INT0002", chip);
200200
if (ret) {
201201
dev_err(dev, "Error requesting IRQ %d: %d\n", irq, ret);
202202
return ret;

drivers/platform/x86/intel/vbtn.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
200200
autorelease = val && (!ke_rel || ke_rel->type == KE_IGNORE);
201201

202202
sparse_keymap_report_event(input_dev, event, val, autorelease);
203-
204-
/* Some devices need this to report further events */
205-
acpi_evaluate_object(handle, "VBDL", NULL, NULL);
206203
}
207204

208205
/*

drivers/platform/x86/p2sb.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#define P2SBC_HIDE BIT(8)
2121

2222
#define P2SB_DEVFN_DEFAULT PCI_DEVFN(31, 1)
23+
#define P2SB_DEVFN_GOLDMONT PCI_DEVFN(13, 0)
24+
#define SPI_DEVFN_GOLDMONT PCI_DEVFN(13, 2)
2325

2426
static const struct x86_cpu_id p2sb_cpu_ids[] = {
25-
X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, PCI_DEVFN(13, 0)),
27+
X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, P2SB_DEVFN_GOLDMONT),
2628
{}
2729
};
2830

@@ -98,21 +100,12 @@ static void p2sb_scan_and_cache_devfn(struct pci_bus *bus, unsigned int devfn)
98100

99101
static int p2sb_scan_and_cache(struct pci_bus *bus, unsigned int devfn)
100102
{
101-
unsigned int slot, fn;
102-
103-
if (PCI_FUNC(devfn) == 0) {
104-
/*
105-
* When function number of the P2SB device is zero, scan it and
106-
* other function numbers, and if devices are available, cache
107-
* their BAR0s.
108-
*/
109-
slot = PCI_SLOT(devfn);
110-
for (fn = 0; fn < NR_P2SB_RES_CACHE; fn++)
111-
p2sb_scan_and_cache_devfn(bus, PCI_DEVFN(slot, fn));
112-
} else {
113-
/* Scan the P2SB device and cache its BAR0 */
114-
p2sb_scan_and_cache_devfn(bus, devfn);
115-
}
103+
/* Scan the P2SB device and cache its BAR0 */
104+
p2sb_scan_and_cache_devfn(bus, devfn);
105+
106+
/* On Goldmont p2sb_bar() also gets called for the SPI controller */
107+
if (devfn == P2SB_DEVFN_GOLDMONT)
108+
p2sb_scan_and_cache_devfn(bus, SPI_DEVFN_GOLDMONT);
116109

117110
if (!p2sb_valid_resource(&p2sb_resources[PCI_FUNC(devfn)].res))
118111
return -ENOENT;

drivers/platform/x86/serdev_helpers.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* In some cases UART attached devices which require an in kernel driver,
4+
* e.g. UART attached Bluetooth HCIs are described in the ACPI tables
5+
* by an ACPI device with a broken or missing UartSerialBusV2() resource.
6+
*
7+
* This causes the kernel to create a /dev/ttyS# char-device for the UART
8+
* instead of creating an in kernel serdev-controller + serdev-device pair
9+
* for the in kernel driver.
10+
*
11+
* The quirk handling in acpi_quirk_skip_serdev_enumeration() makes the kernel
12+
* create a serdev-controller device for these UARTs instead of a /dev/ttyS#.
13+
*
14+
* Instantiating the actual serdev-device to bind to is up to pdx86 code,
15+
* this header provides a helper for getting the serdev-controller device.
16+
*/
17+
#include <linux/acpi.h>
18+
#include <linux/device.h>
19+
#include <linux/err.h>
20+
#include <linux/printk.h>
21+
#include <linux/sprintf.h>
22+
#include <linux/string.h>
23+
24+
static inline struct device *
25+
get_serdev_controller(const char *serial_ctrl_hid,
26+
const char *serial_ctrl_uid,
27+
int serial_ctrl_port,
28+
const char *serdev_ctrl_name)
29+
{
30+
struct device *ctrl_dev, *child;
31+
struct acpi_device *ctrl_adev;
32+
char name[32];
33+
int i;
34+
35+
ctrl_adev = acpi_dev_get_first_match_dev(serial_ctrl_hid, serial_ctrl_uid, -1);
36+
if (!ctrl_adev) {
37+
pr_err("error could not get %s/%s serial-ctrl adev\n",
38+
serial_ctrl_hid, serial_ctrl_uid);
39+
return ERR_PTR(-ENODEV);
40+
}
41+
42+
/* get_first_physical_node() returns a weak ref */
43+
ctrl_dev = get_device(acpi_get_first_physical_node(ctrl_adev));
44+
if (!ctrl_dev) {
45+
pr_err("error could not get %s/%s serial-ctrl physical node\n",
46+
serial_ctrl_hid, serial_ctrl_uid);
47+
ctrl_dev = ERR_PTR(-ENODEV);
48+
goto put_ctrl_adev;
49+
}
50+
51+
/* Walk host -> uart-ctrl -> port -> serdev-ctrl */
52+
for (i = 0; i < 3; i++) {
53+
switch (i) {
54+
case 0:
55+
snprintf(name, sizeof(name), "%s:0", dev_name(ctrl_dev));
56+
break;
57+
case 1:
58+
snprintf(name, sizeof(name), "%s.%d",
59+
dev_name(ctrl_dev), serial_ctrl_port);
60+
break;
61+
case 2:
62+
strscpy(name, serdev_ctrl_name, sizeof(name));
63+
break;
64+
}
65+
66+
child = device_find_child_by_name(ctrl_dev, name);
67+
put_device(ctrl_dev);
68+
if (!child) {
69+
pr_err("error could not find '%s' device\n", name);
70+
ctrl_dev = ERR_PTR(-ENODEV);
71+
goto put_ctrl_adev;
72+
}
73+
74+
ctrl_dev = child;
75+
}
76+
77+
put_ctrl_adev:
78+
acpi_dev_put(ctrl_adev);
79+
return ctrl_dev;
80+
}

drivers/platform/x86/think-lmi.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,16 @@ static ssize_t current_value_store(struct kobject *kobj,
10091009
* Note - this sets the variable and then the password as separate
10101010
* WMI calls. Function tlmi_save_bios_settings will error if the
10111011
* password is incorrect.
1012+
* Workstation's require the opcode to be set before changing the
1013+
* attribute.
10121014
*/
1015+
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
1016+
ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin",
1017+
tlmi_priv.pwd_admin->password);
1018+
if (ret)
1019+
goto out;
1020+
}
1021+
10131022
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
10141023
new_setting);
10151024
if (!set_str) {
@@ -1021,17 +1030,10 @@ static ssize_t current_value_store(struct kobject *kobj,
10211030
if (ret)
10221031
goto out;
10231032

1024-
if (tlmi_priv.save_mode == TLMI_SAVE_BULK) {
1033+
if (tlmi_priv.save_mode == TLMI_SAVE_BULK)
10251034
tlmi_priv.save_required = true;
1026-
} else {
1027-
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
1028-
ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin",
1029-
tlmi_priv.pwd_admin->password);
1030-
if (ret)
1031-
goto out;
1032-
}
1035+
else
10331036
ret = tlmi_save_bios_settings("");
1034-
}
10351037
} else { /* old non-opcode based authentication method (deprecated) */
10361038
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
10371039
auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10379,6 +10379,7 @@ static int convert_dytc_to_profile(int funcmode, int dytcmode,
1037910379
return 0;
1038010380
default:
1038110381
/* Unknown function */
10382+
pr_debug("unknown function 0x%x\n", funcmode);
1038210383
return -EOPNOTSUPP;
1038310384
}
1038410385
return 0;
@@ -10564,8 +10565,8 @@ static void dytc_profile_refresh(void)
1056410565
return;
1056510566

1056610567
perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF;
10567-
convert_dytc_to_profile(funcmode, perfmode, &profile);
10568-
if (profile != dytc_current_profile) {
10568+
err = convert_dytc_to_profile(funcmode, perfmode, &profile);
10569+
if (!err && profile != dytc_current_profile) {
1056910570
dytc_current_profile = profile;
1057010571
platform_profile_notify();
1057110572
}

0 commit comments

Comments
 (0)