Skip to contentSkip to conversation

platform/x86: bitland-mifs-wmi: Only check the function id of GET responses

PATCH In review Chris Taraszka 2 participants 2 messages Sep 28 – Sep 30 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: bitland-mifs-wmi: Only check the function id of GET responses

Commit 23cc56f6dea6 ("platform/x86: bitland-mifs-wmi: Detect failed function calls") rejects every response whose function id does not match the request.

The Xiaomi Book Pro 14 firmware (BIOS XMAPT4B0P0909) only fills in the function id for GET operations. Its SET handlers clear the output buffer and set only the return code, so a successful SystemPerMode SET returns

00 80 00 00 ...

instead of 00 80 00 08. The new mode is applied, but the driver returns -ENOMSG, so every platform profile change is reported as failed:

Failed to write to acpi_platform_profile: Error writing '/sys/firmware/acpi/platform_profile': No message of desired type

SET callers pass no output buffer and do not use the response, so only validate the echoed function id when the caller asks for the output.

Fixes 23cc56f6dea6 ("platform/x86: bitland-mifs-wmi: Detect failed function calls")
Cc Armin Wolf <[email protected]>

---

Notes:
This is the separate fix mentioned in "[PATCH] platform/x86:
bitland-mifs-wmi: Add Xiaomi Book Pro 14 platform profile values".

All SET handlers in this firmware's WMAA method behave the same way:
only the GET handlers set the function id field. 23cc56f6dea6 is only in pdx86 for-next so far, so no stable Cc.

Tested on the Xiaomi Book Pro 14 on AC with bitland-mifs-wmi from pdx86 for-next plus this patch and the Xiaomi profile values patch, loaded on v7.3-rc5: every profile change through power-profiles-daemon succeeds, where before each one failed with -ENOMSG despite being applied.

 drivers/platform/x86/bitland-mifs-wmi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/platform/x86/bitland-mifs-wmi.c +5 -2
index dd1648b7de77..f4817b59dcac 100644
@@ -189,11 +189,14 @@ static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
 		return -EIO;
 	}
 
+	if (!output)
+		return 0;
+
+	/* Some firmware only echoes the function id for GET operations */
 	if (result->function != input->function)
 		return -ENOMSG;
 
-	if (output)
-		memcpy(output, result, sizeof(*output));
+	memcpy(output, result, sizeof(*output));
 
 	return 0;
 }

base-commit: fe5030c8cc7156223f48530e9b49aa87c0305bcd

Signature · 1 line
2.55.0
Tested-by on v1 1/1
#1 lore raw

Hi Chris,

The Redmi Book Pro 16 2024 (DMI XIAOMI / TM2309, BIOS RMAMT6B0P0B0B) behaves the same way: its WMAA SET branches only set the return code, and only the GET branches fill in the function id.

Tested on that machine, kernel 7.2.7, with bitland-mifs-wmi from for-next ("Detect failed function calls" and "Treat WMI_FN_SYSTEM_AC_TYPE as optional" applied) built out of tree, on AC, writing /sys/firmware/acpi/platform_profile directly:

- without this patch, every write of low-power, balanced and performance failed with -ENOMSG, although the EC mode changed each time (QFAN 2, 0 and 3 read back from the EC);
- with this patch, all of them succeed, and reading the profile back still works.

Thanks,
Anton Karasev