Skip to content

Commit eb26cbb

Browse files
committed
Merge tag 'platform-drivers-x86-v6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver fixes from Hans de Goede: "Misc small fixes and hw-id additions" * tag 'platform-drivers-x86-v6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: platform/x86: touchscreen_dmi: Add info for the Archos 101 Cesium Educ tablet platform/x86: dell-ddv: Fix mangled list in documentation platform/x86: dell-ddv: Improve error handling platform/x86/amd: pmf: Add new ACPI ID AMDI0103 platform/x86/amd: pmc: Add new ACPI ID AMDI000A platform/x86/amd: pmc: Apply nvme quirk to HP 15s-eq2xxx platform/x86: Move s2idle quirk from thinkpad-acpi to amd-pmc platform/x86: int3472/discrete: set variable skl_int3472_regulator_second_sensor storage-class-specifier to static platform/x86/intel/tpmi: Prevent overflow for cap_offset platform/x86: wmi: Replace open coded guid_parse_and_compare() platform/x86: wmi: Break possible infinite loop when parsing GUID
2 parents 9a3236c + 6b293a8 commit eb26cbb

File tree

12 files changed

+276
-190
lines changed

12 files changed

+276
-190
lines changed

Documentation/wmi/devices/dell-wmi-ddv.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ WMI method BatteryeRawAnalytics()
187187

188188
Returns a buffer usually containg 12 blocks of analytics data.
189189
Those blocks contain:
190-
- block number starting with 0 (u8)
190+
191+
- a block number starting with 0 (u8)
191192
- 31 bytes of unknown data
192193

193194
.. note::

drivers/platform/x86/amd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# AMD x86 Platform-Specific Drivers
55
#
66

7-
amd-pmc-y := pmc.o
7+
amd-pmc-y := pmc.o pmc-quirks.o
88
obj-$(CONFIG_AMD_PMC) += amd-pmc.o
99
amd_hsmp-y := hsmp.o
1010
obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o

drivers/platform/x86/amd/pmc-quirks.c

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* AMD SoC Power Management Controller Driver Quirks
4+
*
5+
* Copyright (c) 2023, Advanced Micro Devices, Inc.
6+
* All Rights Reserved.
7+
*
8+
* Author: Mario Limonciello <[email protected]>
9+
*/
10+
11+
#include <linux/dmi.h>
12+
#include <linux/io.h>
13+
#include <linux/ioport.h>
14+
#include <linux/slab.h>
15+
16+
#include "pmc.h"
17+
18+
struct quirk_entry {
19+
u32 s2idle_bug_mmio;
20+
};
21+
22+
static struct quirk_entry quirk_s2idle_bug = {
23+
.s2idle_bug_mmio = 0xfed80380,
24+
};
25+
26+
static const struct dmi_system_id fwbug_list[] = {
27+
{
28+
.ident = "L14 Gen2 AMD",
29+
.driver_data = &quirk_s2idle_bug,
30+
.matches = {
31+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
32+
DMI_MATCH(DMI_PRODUCT_NAME, "20X5"),
33+
}
34+
},
35+
{
36+
.ident = "T14s Gen2 AMD",
37+
.driver_data = &quirk_s2idle_bug,
38+
.matches = {
39+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
40+
DMI_MATCH(DMI_PRODUCT_NAME, "20XF"),
41+
}
42+
},
43+
{
44+
.ident = "X13 Gen2 AMD",
45+
.driver_data = &quirk_s2idle_bug,
46+
.matches = {
47+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
48+
DMI_MATCH(DMI_PRODUCT_NAME, "20XH"),
49+
}
50+
},
51+
{
52+
.ident = "T14 Gen2 AMD",
53+
.driver_data = &quirk_s2idle_bug,
54+
.matches = {
55+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
56+
DMI_MATCH(DMI_PRODUCT_NAME, "20XK"),
57+
}
58+
},
59+
{
60+
.ident = "T14 Gen1 AMD",
61+
.driver_data = &quirk_s2idle_bug,
62+
.matches = {
63+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
64+
DMI_MATCH(DMI_PRODUCT_NAME, "20UD"),
65+
}
66+
},
67+
{
68+
.ident = "T14 Gen1 AMD",
69+
.driver_data = &quirk_s2idle_bug,
70+
.matches = {
71+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
72+
DMI_MATCH(DMI_PRODUCT_NAME, "20UE"),
73+
}
74+
},
75+
{
76+
.ident = "T14s Gen1 AMD",
77+
.driver_data = &quirk_s2idle_bug,
78+
.matches = {
79+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
80+
DMI_MATCH(DMI_PRODUCT_NAME, "20UH"),
81+
}
82+
},
83+
{
84+
.ident = "T14s Gen1 AMD",
85+
.driver_data = &quirk_s2idle_bug,
86+
.matches = {
87+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
88+
DMI_MATCH(DMI_PRODUCT_NAME, "20UJ"),
89+
}
90+
},
91+
{
92+
.ident = "P14s Gen1 AMD",
93+
.driver_data = &quirk_s2idle_bug,
94+
.matches = {
95+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
96+
DMI_MATCH(DMI_PRODUCT_NAME, "20Y1"),
97+
}
98+
},
99+
{
100+
.ident = "P14s Gen2 AMD",
101+
.driver_data = &quirk_s2idle_bug,
102+
.matches = {
103+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
104+
DMI_MATCH(DMI_PRODUCT_NAME, "21A0"),
105+
}
106+
},
107+
{
108+
.ident = "P14s Gen2 AMD",
109+
.driver_data = &quirk_s2idle_bug,
110+
.matches = {
111+
DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"),
112+
DMI_MATCH(DMI_PRODUCT_NAME, "21A1"),
113+
}
114+
},
115+
/* https://gitlab.freedesktop.org/drm/amd/-/issues/2684 */
116+
{
117+
.ident = "HP Laptop 15s-eq2xxx",
118+
.driver_data = &quirk_s2idle_bug,
119+
.matches = {
120+
DMI_MATCH(DMI_SYS_VENDOR, "HP"),
121+
DMI_MATCH(DMI_PRODUCT_NAME, "HP Laptop 15s-eq2xxx"),
122+
}
123+
},
124+
{}
125+
};
126+
127+
/*
128+
* Laptops that run a SMI handler during the D3->D0 transition that occurs
129+
* specifically when exiting suspend to idle which can cause
130+
* large delays during resume when the IOMMU translation layer is enabled (the default
131+
* behavior) for NVME devices:
132+
*
133+
* To avoid this firmware problem, skip the SMI handler on these machines before the
134+
* D0 transition occurs.
135+
*/
136+
static void amd_pmc_skip_nvme_smi_handler(u32 s2idle_bug_mmio)
137+
{
138+
struct resource *res;
139+
void __iomem *addr;
140+
u8 val;
141+
142+
res = request_mem_region_muxed(s2idle_bug_mmio, 1, "amd_pmc_pm80");
143+
if (!res)
144+
return;
145+
146+
addr = ioremap(s2idle_bug_mmio, 1);
147+
if (!addr)
148+
goto cleanup_resource;
149+
150+
val = ioread8(addr);
151+
iowrite8(val & ~BIT(0), addr);
152+
153+
iounmap(addr);
154+
cleanup_resource:
155+
release_resource(res);
156+
kfree(res);
157+
}
158+
159+
void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev)
160+
{
161+
if (dev->quirks && dev->quirks->s2idle_bug_mmio)
162+
amd_pmc_skip_nvme_smi_handler(dev->quirks->s2idle_bug_mmio);
163+
}
164+
165+
void amd_pmc_quirks_init(struct amd_pmc_dev *dev)
166+
{
167+
const struct dmi_system_id *dmi_id;
168+
169+
dmi_id = dmi_first_match(fwbug_list);
170+
if (!dmi_id)
171+
return;
172+
dev->quirks = dmi_id->driver_data;
173+
if (dev->quirks->s2idle_bug_mmio)
174+
pr_info("Using s2idle quirk to avoid %s platform firmware bug\n",
175+
dmi_id->ident);
176+
}

drivers/platform/x86/amd/pmc.c

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <linux/seq_file.h>
2929
#include <linux/uaccess.h>
3030

31+
#include "pmc.h"
32+
3133
/* SMU communication registers */
3234
#define AMD_PMC_REGISTER_MESSAGE 0x538
3335
#define AMD_PMC_REGISTER_RESPONSE 0x980
@@ -94,6 +96,7 @@
9496
#define AMD_CPU_ID_CB 0x14D8
9597
#define AMD_CPU_ID_PS 0x14E8
9698
#define AMD_CPU_ID_SP 0x14A4
99+
#define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507
97100

98101
#define PMC_MSG_DELAY_MIN_US 50
99102
#define RESPONSE_REGISTER_LOOP_MAX 20000
@@ -146,29 +149,6 @@ static const struct amd_pmc_bit_map soc15_ip_blk[] = {
146149
{}
147150
};
148151

149-
struct amd_pmc_dev {
150-
void __iomem *regbase;
151-
void __iomem *smu_virt_addr;
152-
void __iomem *stb_virt_addr;
153-
void __iomem *fch_virt_addr;
154-
bool msg_port;
155-
u32 base_addr;
156-
u32 cpu_id;
157-
u32 active_ips;
158-
u32 dram_size;
159-
u32 num_ips;
160-
u32 s2d_msg_id;
161-
/* SMU version information */
162-
u8 smu_program;
163-
u8 major;
164-
u8 minor;
165-
u8 rev;
166-
struct device *dev;
167-
struct pci_dev *rdev;
168-
struct mutex lock; /* generic mutex lock */
169-
struct dentry *dbgfs_dir;
170-
};
171-
172152
static bool enable_stb;
173153
module_param(enable_stb, bool, 0644);
174154
MODULE_PARM_DESC(enable_stb, "Enable the STB debug mechanism");
@@ -891,6 +871,8 @@ static void amd_pmc_s2idle_restore(void)
891871

892872
/* Notify on failed entry */
893873
amd_pmc_validate_deepest(pdev);
874+
875+
amd_pmc_process_restore_quirks(pdev);
894876
}
895877

896878
static struct acpi_s2idle_dev_ops amd_pmc_s2idle_dev_ops = {
@@ -926,6 +908,7 @@ static const struct pci_device_id pmc_pci_ids[] = {
926908
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PCO) },
927909
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RV) },
928910
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_SP) },
911+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_ROOT) },
929912
{ }
930913
};
931914

@@ -1087,6 +1070,8 @@ static int amd_pmc_probe(struct platform_device *pdev)
10871070
err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
10881071
if (err)
10891072
dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n");
1073+
if (!disable_workarounds)
1074+
amd_pmc_quirks_init(dev);
10901075
}
10911076

10921077
amd_pmc_dbgfs_register(dev);
@@ -1115,6 +1100,7 @@ static const struct acpi_device_id amd_pmc_acpi_ids[] = {
11151100
{"AMDI0007", 0},
11161101
{"AMDI0008", 0},
11171102
{"AMDI0009", 0},
1103+
{"AMDI000A", 0},
11181104
{"AMD0004", 0},
11191105
{"AMD0005", 0},
11201106
{ }

drivers/platform/x86/amd/pmc.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* AMD SoC Power Management Controller Driver
4+
*
5+
* Copyright (c) 2023, Advanced Micro Devices, Inc.
6+
* All Rights Reserved.
7+
*
8+
* Author: Mario Limonciello <[email protected]>
9+
*/
10+
11+
#ifndef PMC_H
12+
#define PMC_H
13+
14+
#include <linux/types.h>
15+
#include <linux/mutex.h>
16+
17+
struct amd_pmc_dev {
18+
void __iomem *regbase;
19+
void __iomem *smu_virt_addr;
20+
void __iomem *stb_virt_addr;
21+
void __iomem *fch_virt_addr;
22+
bool msg_port;
23+
u32 base_addr;
24+
u32 cpu_id;
25+
u32 active_ips;
26+
u32 dram_size;
27+
u32 num_ips;
28+
u32 s2d_msg_id;
29+
/* SMU version information */
30+
u8 smu_program;
31+
u8 major;
32+
u8 minor;
33+
u8 rev;
34+
struct device *dev;
35+
struct pci_dev *rdev;
36+
struct mutex lock; /* generic mutex lock */
37+
struct dentry *dbgfs_dir;
38+
struct quirk_entry *quirks;
39+
};
40+
41+
void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev);
42+
void amd_pmc_quirks_init(struct amd_pmc_dev *dev);
43+
44+
#endif /* PMC_H */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
/* List of supported CPU ids */
4141
#define AMD_CPU_ID_RMB 0x14b5
4242
#define AMD_CPU_ID_PS 0x14e8
43+
#define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507
4344

4445
#define PMF_MSG_DELAY_MIN_US 50
4546
#define RESPONSE_REGISTER_LOOP_MAX 20000
@@ -242,6 +243,7 @@ int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32
242243
static const struct pci_device_id pmf_pci_ids[] = {
243244
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RMB) },
244245
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) },
246+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_ROOT) },
245247
{ }
246248
};
247249

@@ -333,6 +335,7 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev)
333335
static const struct acpi_device_id amd_pmf_acpi_ids[] = {
334336
{"AMDI0100", 0x100},
335337
{"AMDI0102", 0},
338+
{"AMDI0103", 0},
336339
{ }
337340
};
338341
MODULE_DEVICE_TABLE(acpi, amd_pmf_acpi_ids);

drivers/platform/x86/dell/dell-wmi-ddv.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ static int dell_wmi_ddv_hwmon_add(struct dell_wmi_ddv_data *data)
616616
}
617617

618618
if (index < 2) {
619-
ret = -ENODEV;
619+
/* Finding no available sensors is not an error */
620+
ret = 0;
620621

621622
goto err_release;
622623
}
@@ -841,13 +842,13 @@ static int dell_wmi_ddv_probe(struct wmi_device *wdev, const void *context)
841842

842843
if (IS_REACHABLE(CONFIG_ACPI_BATTERY)) {
843844
ret = dell_wmi_ddv_battery_add(data);
844-
if (ret < 0 && ret != -ENODEV)
845+
if (ret < 0)
845846
dev_warn(&wdev->dev, "Unable to register ACPI battery hook: %d\n", ret);
846847
}
847848

848849
if (IS_REACHABLE(CONFIG_HWMON)) {
849850
ret = dell_wmi_ddv_hwmon_add(data);
850-
if (ret < 0 && ret != -ENODEV)
851+
if (ret < 0)
851852
dev_warn(&wdev->dev, "Unable to register hwmon interface: %d\n", ret);
852853
}
853854

drivers/platform/x86/intel/int3472/clk_and_regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static_assert(ARRAY_SIZE(skl_int3472_regulator_map_supplies) ==
260260
* This DMI table contains the name of the second sensor. This is used to add
261261
* entries for the second sensor to the supply_map.
262262
*/
263-
const struct dmi_system_id skl_int3472_regulator_second_sensor[] = {
263+
static const struct dmi_system_id skl_int3472_regulator_second_sensor[] = {
264264
{
265265
/* Lenovo Miix 510-12IKB */
266266
.matches = {

drivers/platform/x86/intel/tpmi.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
356356
if (!pfs_start)
357357
pfs_start = res_start;
358358

359-
pfs->pfs_header.cap_offset *= TPMI_CAP_OFFSET_UNIT;
360-
361-
pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset;
359+
pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset * TPMI_CAP_OFFSET_UNIT;
362360

363361
/*
364362
* Process TPMI_INFO to get PCI device to CPU package ID.

0 commit comments

Comments
 (0)