Skip to content

Commit 259b897

Browse files
committed
Merge tag 'platform-drivers-x86-v5.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
Pull x86 platform driver fixes from Hans de Goede: "Highlights: - asus-wmi bug-fixes - intel-sdsu bug-fixes - build (warning) fixes - couple of hw-id additions" * tag 'platform-drivers-x86-v5.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: platform/x86/intel: pmc/core: change pmc_lpm_modes to static platform/x86/intel/sdsi: Fix bug in multi packet reads platform/x86/intel/sdsi: Poll on ready bit for writes platform/x86/intel/sdsi: Handle leaky bucket platform/x86: intel-uncore-freq: Prevent driver loading in guests platform/x86: gigabyte-wmi: added support for B660 GAMING X DDR4 motherboard platform/x86: dell-laptop: Add quirk entry for Latitude 7520 platform/x86: asus-wmi: Fix driver not binding when fan curve control probe fails platform/x86: asus-wmi: Potential buffer overflow in asus_wmi_evaluate_method_buf() tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed
2 parents fd5a4c7 + eb2fd9b commit 259b897

File tree

7 files changed

+59
-21
lines changed

7 files changed

+59
-21
lines changed

drivers/platform/x86/asus-wmi.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,14 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,
371371

372372
switch (obj->type) {
373373
case ACPI_TYPE_BUFFER:
374-
if (obj->buffer.length > size)
374+
if (obj->buffer.length > size) {
375375
err = -ENOSPC;
376-
if (obj->buffer.length == 0)
376+
break;
377+
}
378+
if (obj->buffer.length == 0) {
377379
err = -ENODATA;
380+
break;
381+
}
378382

379383
memcpy(ret_buffer, obj->buffer.pointer, obj->buffer.length);
380384
break;
@@ -2223,9 +2227,10 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
22232227

22242228
err = fan_curve_get_factory_default(asus, fan_dev);
22252229
if (err) {
2226-
if (err == -ENODEV || err == -ENODATA)
2227-
return 0;
2228-
return err;
2230+
pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
2231+
fan_dev, err);
2232+
/* Don't cause probe to fail on devices without fan-curves */
2233+
return 0;
22292234
}
22302235

22312236
*available = true;

drivers/platform/x86/dell/dell-laptop.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ static struct quirk_entry quirk_dell_inspiron_1012 = {
8080
.kbd_led_not_present = true,
8181
};
8282

83+
static struct quirk_entry quirk_dell_latitude_7520 = {
84+
.kbd_missing_ac_tag = true,
85+
};
86+
8387
static struct platform_driver platform_driver = {
8488
.driver = {
8589
.name = "dell-laptop",
@@ -336,6 +340,15 @@ static const struct dmi_system_id dell_quirks[] __initconst = {
336340
},
337341
.driver_data = &quirk_dell_inspiron_1012,
338342
},
343+
{
344+
.callback = dmi_matched,
345+
.ident = "Dell Latitude 7520",
346+
.matches = {
347+
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
348+
DMI_MATCH(DMI_PRODUCT_NAME, "Latitude 7520"),
349+
},
350+
.driver_data = &quirk_dell_latitude_7520,
351+
},
339352
{ }
340353
};
341354

drivers/platform/x86/gigabyte-wmi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static const struct dmi_system_id gigabyte_wmi_known_working_platforms[] = {
148148
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550I AORUS PRO AX"),
149149
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M AORUS PRO-P"),
150150
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550M DS3H"),
151+
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B660 GAMING X DDR4"),
151152
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("Z390 I AORUS PRO WIFI-CF"),
152153
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 AORUS ELITE"),
153154
DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("X570 GAMING X"),

drivers/platform/x86/intel/pmc/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ enum ppfear_regs {
236236
#define ADL_LPM_STATUS_LATCH_EN_OFFSET 0x1704
237237
#define ADL_LPM_LIVE_STATUS_OFFSET 0x1764
238238

239-
const char *pmc_lpm_modes[] = {
239+
static const char *pmc_lpm_modes[] = {
240240
"S0i2.0",
241241
"S0i2.1",
242242
"S0i2.2",

drivers/platform/x86/intel/sdsi.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
#define MBOX_TIMEOUT_US 2000
5252
#define MBOX_TIMEOUT_ACQUIRE_US 1000
5353
#define MBOX_POLLING_PERIOD_US 100
54+
#define MBOX_ACQUIRE_NUM_RETRIES 5
55+
#define MBOX_ACQUIRE_RETRY_DELAY_MS 500
5456
#define MBOX_MAX_PACKETS 4
5557

5658
#define MBOX_OWNER_NONE 0x00
@@ -81,7 +83,7 @@ enum sdsi_command {
8183

8284
struct sdsi_mbox_info {
8385
u64 *payload;
84-
u64 *buffer;
86+
void *buffer;
8587
int size;
8688
};
8789

@@ -163,9 +165,7 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf
163165
total = 0;
164166
loop = 0;
165167
do {
166-
int offset = SDSI_SIZE_MAILBOX * loop;
167-
void __iomem *addr = priv->mbox_addr + offset;
168-
u64 *buf = info->buffer + offset / SDSI_SIZE_CMD;
168+
void *buf = info->buffer + (SDSI_SIZE_MAILBOX * loop);
169169
u32 packet_size;
170170

171171
/* Poll on ready bit */
@@ -196,7 +196,7 @@ static int sdsi_mbox_cmd_read(struct sdsi_priv *priv, struct sdsi_mbox_info *inf
196196
break;
197197
}
198198

199-
sdsi_memcpy64_fromio(buf, addr, round_up(packet_size, SDSI_SIZE_CMD));
199+
sdsi_memcpy64_fromio(buf, priv->mbox_addr, round_up(packet_size, SDSI_SIZE_CMD));
200200

201201
total += packet_size;
202202

@@ -243,8 +243,8 @@ static int sdsi_mbox_cmd_write(struct sdsi_priv *priv, struct sdsi_mbox_info *in
243243
FIELD_PREP(CTRL_PACKET_SIZE, info->size);
244244
writeq(control, priv->control_addr);
245245

246-
/* Poll on run_busy bit */
247-
ret = readq_poll_timeout(priv->control_addr, control, !(control & CTRL_RUN_BUSY),
246+
/* Poll on ready bit */
247+
ret = readq_poll_timeout(priv->control_addr, control, control & CTRL_READY,
248248
MBOX_POLLING_PERIOD_US, MBOX_TIMEOUT_US);
249249

250250
if (ret)
@@ -263,7 +263,7 @@ static int sdsi_mbox_acquire(struct sdsi_priv *priv, struct sdsi_mbox_info *info
263263
{
264264
u64 control;
265265
u32 owner;
266-
int ret;
266+
int ret, retries = 0;
267267

268268
lockdep_assert_held(&priv->mb_lock);
269269

@@ -273,13 +273,29 @@ static int sdsi_mbox_acquire(struct sdsi_priv *priv, struct sdsi_mbox_info *info
273273
if (owner != MBOX_OWNER_NONE)
274274
return -EBUSY;
275275

276-
/* Write first qword of payload */
277-
writeq(info->payload[0], priv->mbox_addr);
276+
/*
277+
* If there has been no recent transaction and no one owns the mailbox,
278+
* we should acquire it in under 1ms. However, if we've accessed it
279+
* recently it may take up to 2.1 seconds to acquire it again.
280+
*/
281+
do {
282+
/* Write first qword of payload */
283+
writeq(info->payload[0], priv->mbox_addr);
284+
285+
/* Check for ownership */
286+
ret = readq_poll_timeout(priv->control_addr, control,
287+
FIELD_GET(CTRL_OWNER, control) == MBOX_OWNER_INBAND,
288+
MBOX_POLLING_PERIOD_US, MBOX_TIMEOUT_ACQUIRE_US);
289+
290+
if (FIELD_GET(CTRL_OWNER, control) == MBOX_OWNER_NONE &&
291+
retries++ < MBOX_ACQUIRE_NUM_RETRIES) {
292+
msleep(MBOX_ACQUIRE_RETRY_DELAY_MS);
293+
continue;
294+
}
278295

279-
/* Check for ownership */
280-
ret = readq_poll_timeout(priv->control_addr, control,
281-
FIELD_GET(CTRL_OWNER, control) & MBOX_OWNER_INBAND,
282-
MBOX_POLLING_PERIOD_US, MBOX_TIMEOUT_ACQUIRE_US);
296+
/* Either we got it or someone else did. */
297+
break;
298+
} while (true);
283299

284300
return ret;
285301
}

drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ static int __init intel_uncore_init(void)
212212
const struct x86_cpu_id *id;
213213
int ret;
214214

215+
if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
216+
return -ENODEV;
217+
215218
id = x86_match_cpu(intel_uncore_cpu_ids);
216219
if (!id)
217220
return -ENODEV;

tools/power/x86/intel-speed-select/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ISST_IN := $(OUTPUT)intel-speed-select-in.o
4242
$(ISST_IN): prepare FORCE
4343
$(Q)$(MAKE) $(build)=intel-speed-select
4444
$(OUTPUT)intel-speed-select: $(ISST_IN)
45-
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
45+
$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
4646

4747
clean:
4848
rm -f $(ALL_PROGRAMS)

0 commit comments

Comments
 (0)