Skip to content

Commit 1a2f6a3

Browse files
committed
Merge tag 'platform-drivers-x86-v6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver fixes from Hans de Goede: "Various small fixes and hardware-id additions" * tag 'platform-drivers-x86-v6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: platform/x86: p2sb: Fix UAF when caller uses resource name platform/x86: asus-wmi: Increase FAN_CURVE_BUF_LEN to 32 platform/mellanox: Remove redundant 'NULL' check platform/mellanox: Remove unnecessary code platform/mellanox: mlxreg-lc: Fix locking issue platform/mellanox: mlxreg-lc: Fix coverity warning platform/x86: acer-wmi: Acer Aspire One AOD270/Packard Bell Dot keymap fixes platform/x86: thinkpad_acpi: Explicitly set to balanced mode on startup platform/x86: asus-wmi: Fix the name of the mic-mute LED classdev platform/surface: aggregator_registry: Add HID devices for sensors and UCSI client to SP8 platform/surface: aggregator_registry: Rename HID device nodes based on new findings platform/surface: aggregator_registry: Rename HID device nodes based on their function platform/surface: aggregator_registry: Add support for Surface Laptop Go 2 platform/x86: x86-android-tablets: Fix broken touchscreen on Chuwi Hi8 with Windows BIOS platform/x86: pmc_atom: Fix SLP_TYPx bitfield mask
2 parents cf3488f + 647e82d commit 1a2f6a3

9 files changed

Lines changed: 108 additions & 59 deletions

File tree

drivers/platform/mellanox/mlxreg-lc.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,6 @@ static int mlxreg_lc_power_on_off(struct mlxreg_lc *mlxreg_lc, u8 action)
460460
u32 regval;
461461
int err;
462462

463-
mutex_lock(&mlxreg_lc->lock);
464-
465463
err = regmap_read(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_pwr, &regval);
466464
if (err)
467465
goto regmap_read_fail;
@@ -474,7 +472,6 @@ static int mlxreg_lc_power_on_off(struct mlxreg_lc *mlxreg_lc, u8 action)
474472
err = regmap_write(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_pwr, regval);
475473

476474
regmap_read_fail:
477-
mutex_unlock(&mlxreg_lc->lock);
478475
return err;
479476
}
480477

@@ -491,8 +488,6 @@ static int mlxreg_lc_enable_disable(struct mlxreg_lc *mlxreg_lc, bool action)
491488
* line card which is already has been enabled. Disabling does not affect the disabled line
492489
* card.
493490
*/
494-
mutex_lock(&mlxreg_lc->lock);
495-
496491
err = regmap_read(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_ena, &regval);
497492
if (err)
498493
goto regmap_read_fail;
@@ -505,7 +500,6 @@ static int mlxreg_lc_enable_disable(struct mlxreg_lc *mlxreg_lc, bool action)
505500
err = regmap_write(mlxreg_lc->par_regmap, mlxreg_lc->data->reg_ena, regval);
506501

507502
regmap_read_fail:
508-
mutex_unlock(&mlxreg_lc->lock);
509503
return err;
510504
}
511505

@@ -537,6 +531,15 @@ mlxreg_lc_sn4800_c16_config_init(struct mlxreg_lc *mlxreg_lc, void *regmap,
537531

538532
static void
539533
mlxreg_lc_state_update(struct mlxreg_lc *mlxreg_lc, enum mlxreg_lc_state state, u8 action)
534+
{
535+
if (action)
536+
mlxreg_lc->state |= state;
537+
else
538+
mlxreg_lc->state &= ~state;
539+
}
540+
541+
static void
542+
mlxreg_lc_state_update_locked(struct mlxreg_lc *mlxreg_lc, enum mlxreg_lc_state state, u8 action)
540543
{
541544
mutex_lock(&mlxreg_lc->lock);
542545

@@ -560,8 +563,11 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
560563
dev_info(mlxreg_lc->dev, "linecard#%d state %d event kind %d action %d\n",
561564
mlxreg_lc->data->slot, mlxreg_lc->state, kind, action);
562565

563-
if (!(mlxreg_lc->state & MLXREG_LC_INITIALIZED))
566+
mutex_lock(&mlxreg_lc->lock);
567+
if (!(mlxreg_lc->state & MLXREG_LC_INITIALIZED)) {
568+
mutex_unlock(&mlxreg_lc->lock);
564569
return 0;
570+
}
565571

566572
switch (kind) {
567573
case MLXREG_HOTPLUG_LC_SYNCED:
@@ -574,7 +580,7 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
574580
if (!(mlxreg_lc->state & MLXREG_LC_POWERED) && action) {
575581
err = mlxreg_lc_power_on_off(mlxreg_lc, 1);
576582
if (err)
577-
return err;
583+
goto mlxreg_lc_power_on_off_fail;
578584
}
579585
/* In case line card is configured - enable it. */
580586
if (mlxreg_lc->state & MLXREG_LC_CONFIGURED && action)
@@ -588,12 +594,13 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
588594
/* In case line card is configured - enable it. */
589595
if (mlxreg_lc->state & MLXREG_LC_CONFIGURED)
590596
err = mlxreg_lc_enable_disable(mlxreg_lc, 1);
597+
mutex_unlock(&mlxreg_lc->lock);
591598
return err;
592599
}
593600
err = mlxreg_lc_create_static_devices(mlxreg_lc, mlxreg_lc->main_devs,
594601
mlxreg_lc->main_devs_num);
595602
if (err)
596-
return err;
603+
goto mlxreg_lc_create_static_devices_fail;
597604

598605
/* In case line card is already in ready state - enable it. */
599606
if (mlxreg_lc->state & MLXREG_LC_CONFIGURED)
@@ -620,6 +627,10 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
620627
break;
621628
}
622629

630+
mlxreg_lc_power_on_off_fail:
631+
mlxreg_lc_create_static_devices_fail:
632+
mutex_unlock(&mlxreg_lc->lock);
633+
623634
return err;
624635
}
625636

@@ -665,7 +676,7 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
665676
if (err)
666677
goto mlxreg_lc_create_static_devices_failed;
667678

668-
mlxreg_lc_state_update(mlxreg_lc, MLXREG_LC_POWERED, 1);
679+
mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_POWERED, 1);
669680
}
670681

671682
/* Verify if line card is synchronized. */
@@ -676,15 +687,15 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
676687
/* Power on line card if necessary. */
677688
if (regval & mlxreg_lc->data->mask) {
678689
mlxreg_lc->state |= MLXREG_LC_SYNCED;
679-
mlxreg_lc_state_update(mlxreg_lc, MLXREG_LC_SYNCED, 1);
690+
mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_SYNCED, 1);
680691
if (mlxreg_lc->state & ~MLXREG_LC_POWERED) {
681692
err = mlxreg_lc_power_on_off(mlxreg_lc, 1);
682693
if (err)
683694
goto mlxreg_lc_regmap_power_on_off_fail;
684695
}
685696
}
686697

687-
mlxreg_lc_state_update(mlxreg_lc, MLXREG_LC_INITIALIZED, 1);
698+
mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_INITIALIZED, 1);
688699

689700
return 0;
690701

@@ -814,10 +825,9 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
814825

815826
mutex_init(&mlxreg_lc->lock);
816827
/* Set event notification callback. */
817-
if (data->notifier) {
818-
data->notifier->user_handler = mlxreg_lc_event_handler;
819-
data->notifier->handle = mlxreg_lc;
820-
}
828+
data->notifier->user_handler = mlxreg_lc_event_handler;
829+
data->notifier->handle = mlxreg_lc;
830+
821831
data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr);
822832
if (!data->hpdev.adapter) {
823833
dev_err(&pdev->dev, "Failed to get adapter for bus %d\n",
@@ -863,7 +873,6 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
863873
if (err) {
864874
dev_err(&pdev->dev, "Failed to sync regmap for client %s at bus %d at addr 0x%02x\n",
865875
data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr);
866-
err = PTR_ERR(regmap);
867876
goto regcache_sync_fail;
868877
}
869878

@@ -878,16 +887,14 @@ static int mlxreg_lc_probe(struct platform_device *pdev)
878887
if (err)
879888
goto mlxreg_lc_config_init_fail;
880889

881-
return err;
890+
return 0;
882891

883892
mlxreg_lc_config_init_fail:
884893
regcache_sync_fail:
885894
regmap_write_fail:
886895
devm_regmap_init_i2c_fail:
887-
if (data->hpdev.client) {
888-
i2c_unregister_device(data->hpdev.client);
889-
data->hpdev.client = NULL;
890-
}
896+
i2c_unregister_device(data->hpdev.client);
897+
data->hpdev.client = NULL;
891898
i2c_new_device_fail:
892899
i2c_put_adapter(data->hpdev.adapter);
893900
data->hpdev.adapter = NULL;
@@ -905,6 +912,8 @@ static int mlxreg_lc_remove(struct platform_device *pdev)
905912
struct mlxreg_core_data *data = dev_get_platdata(&pdev->dev);
906913
struct mlxreg_lc *mlxreg_lc = platform_get_drvdata(pdev);
907914

915+
mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_INITIALIZED, 0);
916+
908917
/*
909918
* Probing and removing are invoked by hotplug events raised upon line card insertion and
910919
* removing. If probing procedure fails all data is cleared. However, hotplug event still

drivers/platform/surface/surface_aggregator_registry.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,38 +86,38 @@ static const struct software_node ssam_node_bas_dtx = {
8686
.parent = &ssam_node_root,
8787
};
8888

89-
/* HID keyboard (TID1). */
90-
static const struct software_node ssam_node_hid_tid1_keyboard = {
89+
/* HID keyboard (SAM, TID=1). */
90+
static const struct software_node ssam_node_hid_sam_keyboard = {
9191
.name = "ssam:01:15:01:01:00",
9292
.parent = &ssam_node_root,
9393
};
9494

95-
/* HID pen stash (TID1; pen taken / stashed away evens). */
96-
static const struct software_node ssam_node_hid_tid1_penstash = {
95+
/* HID pen stash (SAM, TID=1; pen taken / stashed away evens). */
96+
static const struct software_node ssam_node_hid_sam_penstash = {
9797
.name = "ssam:01:15:01:02:00",
9898
.parent = &ssam_node_root,
9999
};
100100

101-
/* HID touchpad (TID1). */
102-
static const struct software_node ssam_node_hid_tid1_touchpad = {
101+
/* HID touchpad (SAM, TID=1). */
102+
static const struct software_node ssam_node_hid_sam_touchpad = {
103103
.name = "ssam:01:15:01:03:00",
104104
.parent = &ssam_node_root,
105105
};
106106

107-
/* HID device instance 6 (TID1, unknown HID device). */
108-
static const struct software_node ssam_node_hid_tid1_iid6 = {
107+
/* HID device instance 6 (SAM, TID=1, HID sensor collection). */
108+
static const struct software_node ssam_node_hid_sam_sensors = {
109109
.name = "ssam:01:15:01:06:00",
110110
.parent = &ssam_node_root,
111111
};
112112

113-
/* HID device instance 7 (TID1, unknown HID device). */
114-
static const struct software_node ssam_node_hid_tid1_iid7 = {
113+
/* HID device instance 7 (SAM, TID=1, UCM UCSI HID client). */
114+
static const struct software_node ssam_node_hid_sam_ucm_ucsi = {
115115
.name = "ssam:01:15:01:07:00",
116116
.parent = &ssam_node_root,
117117
};
118118

119-
/* HID system controls (TID1). */
120-
static const struct software_node ssam_node_hid_tid1_sysctrl = {
119+
/* HID system controls (SAM, TID=1). */
120+
static const struct software_node ssam_node_hid_sam_sysctrl = {
121121
.name = "ssam:01:15:01:08:00",
122122
.parent = &ssam_node_root,
123123
};
@@ -182,8 +182,8 @@ static const struct software_node ssam_node_hid_kip_touchpad = {
182182
.parent = &ssam_node_hub_kip,
183183
};
184184

185-
/* HID device instance 5 (KIP hub, unknown HID device). */
186-
static const struct software_node ssam_node_hid_kip_iid5 = {
185+
/* HID device instance 5 (KIP hub, type-cover firmware update). */
186+
static const struct software_node ssam_node_hid_kip_fwupd = {
187187
.name = "ssam:01:15:02:05:00",
188188
.parent = &ssam_node_hub_kip,
189189
};
@@ -241,12 +241,12 @@ static const struct software_node *ssam_node_group_sls[] = {
241241
&ssam_node_bat_main,
242242
&ssam_node_tmp_pprof,
243243
&ssam_node_pos_tablet_switch,
244-
&ssam_node_hid_tid1_keyboard,
245-
&ssam_node_hid_tid1_penstash,
246-
&ssam_node_hid_tid1_touchpad,
247-
&ssam_node_hid_tid1_iid6,
248-
&ssam_node_hid_tid1_iid7,
249-
&ssam_node_hid_tid1_sysctrl,
244+
&ssam_node_hid_sam_keyboard,
245+
&ssam_node_hid_sam_penstash,
246+
&ssam_node_hid_sam_touchpad,
247+
&ssam_node_hid_sam_sensors,
248+
&ssam_node_hid_sam_ucm_ucsi,
249+
&ssam_node_hid_sam_sysctrl,
250250
NULL,
251251
};
252252

@@ -278,7 +278,9 @@ static const struct software_node *ssam_node_group_sp8[] = {
278278
&ssam_node_hid_kip_keyboard,
279279
&ssam_node_hid_kip_penstash,
280280
&ssam_node_hid_kip_touchpad,
281-
&ssam_node_hid_kip_iid5,
281+
&ssam_node_hid_kip_fwupd,
282+
&ssam_node_hid_sam_sensors,
283+
&ssam_node_hid_sam_ucm_ucsi,
282284
NULL,
283285
};
284286

@@ -325,6 +327,9 @@ static const struct acpi_device_id ssam_platform_hub_match[] = {
325327
/* Surface Laptop Go 1 */
326328
{ "MSHW0118", (unsigned long)ssam_node_group_slg1 },
327329

330+
/* Surface Laptop Go 2 */
331+
{ "MSHW0290", (unsigned long)ssam_node_group_slg1 },
332+
328333
/* Surface Laptop Studio */
329334
{ "MSHW0123", (unsigned long)ssam_node_group_sls },
330335

drivers/platform/x86/acer-wmi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static const struct key_entry acer_wmi_keymap[] __initconst = {
9999
{KE_KEY, 0x22, {KEY_PROG2} }, /* Arcade */
100100
{KE_KEY, 0x23, {KEY_PROG3} }, /* P_Key */
101101
{KE_KEY, 0x24, {KEY_PROG4} }, /* Social networking_Key */
102+
{KE_KEY, 0x27, {KEY_HELP} },
102103
{KE_KEY, 0x29, {KEY_PROG3} }, /* P_Key for TM8372 */
103104
{KE_IGNORE, 0x41, {KEY_MUTE} },
104105
{KE_IGNORE, 0x42, {KEY_PREVIOUSSONG} },
@@ -112,7 +113,13 @@ static const struct key_entry acer_wmi_keymap[] __initconst = {
112113
{KE_IGNORE, 0x48, {KEY_VOLUMEUP} },
113114
{KE_IGNORE, 0x49, {KEY_VOLUMEDOWN} },
114115
{KE_IGNORE, 0x4a, {KEY_VOLUMEDOWN} },
115-
{KE_IGNORE, 0x61, {KEY_SWITCHVIDEOMODE} },
116+
/*
117+
* 0x61 is KEY_SWITCHVIDEOMODE. Usually this is a duplicate input event
118+
* with the "Video Bus" input device events. But sometimes it is not
119+
* a dup. Map it to KEY_UNKNOWN instead of using KE_IGNORE so that
120+
* udev/hwdb can override it on systems where it is not a dup.
121+
*/
122+
{KE_KEY, 0x61, {KEY_UNKNOWN} },
116123
{KE_IGNORE, 0x62, {KEY_BRIGHTNESSUP} },
117124
{KE_IGNORE, 0x63, {KEY_BRIGHTNESSDOWN} },
118125
{KE_KEY, 0x64, {KEY_SWITCHVIDEOMODE} }, /* Display Switch */

drivers/platform/x86/asus-wmi.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module_param(fnlock_default, bool, 0444);
107107
#define WMI_EVENT_MASK 0xFFFF
108108

109109
#define FAN_CURVE_POINTS 8
110-
#define FAN_CURVE_BUF_LEN (FAN_CURVE_POINTS * 2)
110+
#define FAN_CURVE_BUF_LEN 32
111111
#define FAN_CURVE_DEV_CPU 0x00
112112
#define FAN_CURVE_DEV_GPU 0x01
113113
/* Mask to determine if setting temperature or percentage */
@@ -1118,7 +1118,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
11181118
}
11191119

11201120
if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MICMUTE_LED)) {
1121-
asus->micmute_led.name = "asus::micmute";
1121+
asus->micmute_led.name = "platform::micmute";
11221122
asus->micmute_led.max_brightness = 1;
11231123
asus->micmute_led.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
11241124
asus->micmute_led.brightness_set_blocking = micmute_led_set;
@@ -2233,8 +2233,10 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
22332233
curves = &asus->custom_fan_curves[fan_idx];
22342234
err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
22352235
FAN_CURVE_BUF_LEN);
2236-
if (err)
2236+
if (err) {
2237+
pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
22372238
return err;
2239+
}
22382240

22392241
fan_curve_copy_from_buf(curves, buf);
22402242
curves->device_id = fan_dev;
@@ -2252,9 +2254,6 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
22522254

22532255
err = fan_curve_get_factory_default(asus, fan_dev);
22542256
if (err) {
2255-
pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
2256-
fan_dev, err);
2257-
/* Don't cause probe to fail on devices without fan-curves */
22582257
return 0;
22592258
}
22602259

drivers/platform/x86/p2sb.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,24 @@ static int p2sb_get_devfn(unsigned int *devfn)
4242
return 0;
4343
}
4444

45+
/* Copy resource from the first BAR of the device in question */
4546
static int p2sb_read_bar0(struct pci_dev *pdev, struct resource *mem)
4647
{
47-
/* Copy resource from the first BAR of the device in question */
48-
*mem = pdev->resource[0];
48+
struct resource *bar0 = &pdev->resource[0];
49+
50+
/* Make sure we have no dangling pointers in the output */
51+
memset(mem, 0, sizeof(*mem));
52+
53+
/*
54+
* We copy only selected fields from the original resource.
55+
* Because a PCI device will be removed soon, we may not use
56+
* any allocated data, hence we may not copy any pointers.
57+
*/
58+
mem->start = bar0->start;
59+
mem->end = bar0->end;
60+
mem->flags = bar0->flags;
61+
mem->desc = bar0->desc;
62+
4963
return 0;
5064
}
5165

drivers/platform/x86/pmc_atom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void pmc_power_off(void)
232232
pm1_cnt_port = acpi_base_addr + PM1_CNT;
233233

234234
pm1_cnt_value = inl(pm1_cnt_port);
235-
pm1_cnt_value &= SLEEP_TYPE_MASK;
235+
pm1_cnt_value &= ~SLEEP_TYPE_MASK;
236236
pm1_cnt_value |= SLEEP_TYPE_S5;
237237
pm1_cnt_value |= SLEEP_ENABLE;
238238

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10592,10 +10592,9 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
1059210592
/* Ensure initial values are correct */
1059310593
dytc_profile_refresh();
1059410594

10595-
/* Set AMT correctly now we know current profile */
10596-
if ((dytc_capabilities & BIT(DYTC_FC_PSC)) &&
10597-
(dytc_capabilities & BIT(DYTC_FC_AMT)))
10598-
dytc_control_amt(dytc_current_profile == PLATFORM_PROFILE_BALANCED);
10595+
/* Workaround for https://bugzilla.kernel.org/show_bug.cgi?id=216347 */
10596+
if (dytc_capabilities & BIT(DYTC_FC_PSC))
10597+
dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED);
1059910598

1060010599
return 0;
1060110600
}

0 commit comments

Comments
 (0)