Skip to contentSkip to conversation

acer-wmi: two Bugs fixed and set device state by access new wmi method

PATCH In review Lee, Chun-Yi 4 participants 16 messages May 21, 2011 – May 25, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover acer-wmi: two Bugs fixed and set device state by access new wmi method

Here have 4 patches, from first to third patches fixed bko#32862, bko#34142, the 3 patches will check negative number before set initial devices state, make sure 3G device exist before generate 3G rfkill and allow 64-bits return buffer from 2 old wmi methods.

And, the fourth patch improve to set communication device state by evaluate new WMID_GUID3 method, it's good to avoid potential problem if we still use old wmi method on new Acer machines.

Changed after last posted:
+ Add negative number check in commandline_init() before set initial state. bko#32862
+ Add check 3G device exist flag in WMID_set_capabilities(). bko#32862
+ Allow u64 result buffer in WMI_execute_u32(). bko#34142
+ Add wmid3_set_device_status() then access it in set_block.

Next step for acer-wmi:
+ Dig more old wmi event in DSDT, try to remove devices state polling on more machines.
+ Already found some old wmi event, can be used by sync devices state.
+ Clear up acer-wmi driver base on different wmi interface on different time frame.

Lee, Chun-Yi (4):
acer-wmi: does not allow negative number set to initial device state
acer-wmi: check the existence of internal 3G device when set
capability
acer-wmi: allow 64-bits return buffer from WMI methods
acer-wmi: support to set communication device state by new wmid
method

 drivers/platform/x86/acer-wmi.c |  131 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 123 insertions(+), 8 deletions(-)
#1 lore raw

PATCH 1/4 acer-wmi: does not allow negative number set to initial device state

The driver set module parameter value: mailled, threeg and brightness to BIOS by evaluate wmi method when driver was initialled. The default values for those parameters are -1, so, that will be better don't set negative value to BIOS.

Reference: bko#32862

        https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

Cc Carlos Corbacho <[email protected]>
Cc Matthew Garrett <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Corentin Chary <[email protected]>
Cc Thomas Renninger <[email protected]>
---
 drivers/platform/x86/acer-wmi.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/platform/x86/acer-wmi.c +5 -3
index ac4e7f8..c3cb603 100644
@@ -961,10 +961,12 @@ static void __init acer_commandline_init(void)
 	 * These will all fail silently if the value given is invalid, or the
 	 * capability isn't available on the given interface
 	 */
-	set_u32(mailled, ACER_CAP_MAILLED);
-	if (!has_type_aa)
+	if (mailled >= 0)
+		set_u32(mailled, ACER_CAP_MAILLED);
+	if (!has_type_aa && threeg >= 0)
 		set_u32(threeg, ACER_CAP_THREEG);
-	set_u32(brightness, ACER_CAP_BRIGHTNESS);
+	if (brightness >= 0)
+		set_u32(brightness, ACER_CAP_BRIGHTNESS);
 }
 
 /*
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/4 acer-wmi: check the existence of internal 3G device when set capability

That will be better to check the existence of internal 3G device when we set threeg capability and generate killswitch for threeg. It can avoid userland access 3G rfkill but the machine doesn't have internal 3G device.

Reference: bko#32862

	https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

Cc Carlos Corbacho <[email protected]>
Cc Matthew Garrett <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Corentin Chary <[email protected]>
Cc Thomas Renninger <[email protected]>
---
 drivers/platform/x86/acer-wmi.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/platform/x86/acer-wmi.c +2 -1
index c3cb603..6c4716d 100644
@@ -876,7 +876,8 @@ static acpi_status WMID_set_capabilities(void)
 	dmi_walk(type_aa_dmi_decode, NULL);
 	if (!has_type_aa) {
 		interface->capability |= ACER_CAP_WIRELESS;
-		interface->capability |= ACER_CAP_THREEG;
+		if (devices & 0x40)
+			interface->capability |= ACER_CAP_THREEG;
 		if (devices & 0x10)
 			interface->capability |= ACER_CAP_BLUETOOTH;
 	}
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/4 acer-wmi: allow 64-bits return buffer from WMI methods

Acer WMID_GUID1/2 method's return buffer was declared to 64-bits on some Acer notebook, but WMI method only use 32-bits in return buffer.
So, add this patch for allow 64-bits return buffer.

Reference: bko#34142

	https://bugzilla.kernel.org/show_bug.cgi?id=34142

Tested on Acer Travelmate 5735Z-452G32Mnss

Cc Carlos Corbacho <[email protected]>
Cc Matthew Garrett <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Corentin Chary <[email protected]>
Cc Thomas Renninger <[email protected]>
---
 drivers/platform/x86/acer-wmi.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/platform/x86/acer-wmi.c +6 -3
index 6c4716d..73a7b63 100644
@@ -737,7 +737,8 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out)
 
 	obj = (union acpi_object *) result.pointer;
 	if (obj && obj->type == ACPI_TYPE_BUFFER &&
-		obj->buffer.length == sizeof(u32)) {
+		(obj->buffer.length == sizeof(u32) ||
+		obj->buffer.length == sizeof(u64))) {
 		tmp = *((u32 *) obj->buffer.pointer);
 	} else {
 		tmp = 0;
@@ -866,7 +867,8 @@ static acpi_status WMID_set_capabilities(void)
 
 	obj = (union acpi_object *) out.pointer;
 	if (obj && obj->type == ACPI_TYPE_BUFFER &&
-		obj->buffer.length == sizeof(u32)) {
+		(obj->buffer.length == sizeof(u32) ||
+		obj->buffer.length == sizeof(u64))) {
 		devices = *((u32 *) obj->buffer.pointer);
 	} else {
 		kfree(out.pointer);
@@ -1509,7 +1511,8 @@ static u32 get_wmid_devices(void)
 
 	obj = (union acpi_object *) out.pointer;
 	if (obj && obj->type == ACPI_TYPE_BUFFER &&
-		obj->buffer.length == sizeof(u32)) {
+		(obj->buffer.length == sizeof(u32) ||
+		obj->buffer.length == sizeof(u64))) {
 		devices = *((u32 *) obj->buffer.pointer);
 	}
 
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/4 acer-wmi: support to set communication device state by new wmid method

Have many Acer notebooks' BIOS already support new WMID_GUID3 method. On those machines, that will be better set communication device by evaluate WMID_GUID3 method.

Tested on Acer Travelmate 8572

Cc Carlos Corbacho <[email protected]>
Cc Matthew Garrett <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Corentin Chary <[email protected]>
Cc Thomas Renninger <[email protected]>
---
 drivers/platform/x86/acer-wmi.c |  111 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 110 insertions(+), 1 deletions(-)
drivers/platform/x86/acer-wmi.c +110 -1
index 73a7b63..a36937c 100644
@@ -122,6 +122,7 @@ struct event_return_value {
  */
 #define ACER_WMID3_GDS_WIRELESS		(1<<0)	/* WiFi */
 #define ACER_WMID3_GDS_THREEG		(1<<6)	/* 3G */
+#define ACER_WMID3_GDS_WIMAX		(1<<7)	/* WiMAX */
 #define ACER_WMID3_GDS_BLUETOOTH	(1<<11)	/* BT */
 
 struct lm_input_params {
@@ -1129,6 +1130,114 @@ static acpi_status get_device_status(u32 *value, u32 cap)
 	}
 }
 
+static acpi_status wmid3_set_device_status(u32 value, u16 device)
+{
+	struct wmid3_gds_return_value return_value;
+	acpi_status status;
+	union acpi_object *obj;
+	u16 devices;
+	struct wmid3_gds_input_param params = {
+		.function_num = 0x1,
+		.hotkey_number = 0x01,
+		.devices = ACER_WMID3_GDS_WIRELESS &
+				ACER_WMID3_GDS_THREEG &
+				ACER_WMID3_GDS_WIMAX &
+				ACER_WMID3_GDS_BLUETOOTH,
+	};
+	struct acpi_buffer input = {
+		sizeof(struct wmid3_gds_input_param),
+		&params
+	};
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+	struct acpi_buffer output2 = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return AE_ERROR;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return AE_ERROR;
+	}
+	if (obj->buffer.length != 8) {
+		pr_warning("Unknown buffer length %d\n", obj->buffer.length);
+		kfree(obj);
+		return AE_ERROR;
+	}
+
+	return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	if (return_value.error_code || return_value.ec_return_value) {
+		pr_warning("Get Current Device Status failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+		return status;
+	}
+
+	devices = return_value.devices;
+	params.function_num = 0x2;
+	params.hotkey_number = 0x01;
+	params.devices = (value) ? (devices | device) : (devices & ~device);
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output2);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output2.pointer;
+
+	if (!obj)
+		return AE_ERROR;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return AE_ERROR;
+	}
+	if (obj->buffer.length != 4) {
+		pr_warning("Unknown buffer length %d\n", obj->buffer.length);
+		kfree(obj);
+		return AE_ERROR;
+	}
+
+	return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		pr_warning("Set Device Status failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+
+	return status;
+}
+
+static acpi_status set_device_status(u32 value, u32 cap)
+{
+	if (wmi_has_guid(WMID_GUID3)) {
+		u16 device;
+
+		switch (cap) {
+		case ACER_CAP_WIRELESS:
+			device = ACER_WMID3_GDS_WIRELESS;
+			break;
+		case ACER_CAP_BLUETOOTH:
+			device = ACER_WMID3_GDS_BLUETOOTH;
+			break;
+		case ACER_CAP_THREEG:
+			device = ACER_WMID3_GDS_THREEG;
+			break;
+		default:
+			return AE_ERROR;
+		}
+		return wmid3_set_device_status(value, device);
+
+	} else {
+		return set_u32(value, cap);
+	}
+}
+
 /*
  * Rfkill devices
  */
@@ -1165,7 +1274,7 @@ static int acer_rfkill_set(void *data, bool blocked)
 	u32 cap = (unsigned long)data;
 
 	if (rfkill_inited) {
-		status = set_u32(!blocked, cap);
+		status = set_device_status(!blocked, cap);
 		if (ACPI_FAILURE(status))
 			return -ENODEV;
 	}
Signature · 1 line
1.6.0.2
Acked-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

In reply to Lee, Chun-Yi
Quoted 11 lines · Chun-Yi

That will be better to check the existence of internal 3G device when we set threeg capability and generate killswitch for threeg. It can avoid userland access 3G rfkill but the machine doesn't have internal 3G device.

Reference: bko#32862

	https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

If you can now autodetect 3G and already have the relevant rfkill device, then you should also rip out the remaining sysfs support for it as it's no longer necessary.

-Carlos

#6 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

於 日,2011-05-22 於 00:43 +0100,Carlos Corbacho 提到:

Quoted 13 lines · Chun-Yi
Quoted 11 lines

That will be better to check the existence of internal 3G device when we set threeg capability and generate killswitch for threeg. It can avoid userland access 3G rfkill but the machine doesn't have internal 3G device.

Reference: bko#32862

	https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

Quoted 7 lines

If you can now autodetect 3G and already have the relevant rfkill device, then you should also rip out the remaining sysfs support for it as it's no longer necessary.

-Carlos

Got it!
I will send another patch to remove threeg sysfs file.

Thank's a lot!
Joey Lee

#7 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

Quoted 16 lines · Joey Lee

於 日,2011-05-22 於 00:43 +0100,Carlos Corbacho 提到:

Quoted 15 lines · Chun-Yi
Quoted 11 lines

That will be better to check the existence of internal 3G device when we set threeg capability and generate killswitch for threeg. It can avoid userland access 3G rfkill but the machine doesn't have internal 3G device.

Reference: bko#32862
    https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

Quoted 8 lines
Quoted 5 lines

If you can now autodetect 3G and already have the relevant rfkill device, then you should also rip out the remaining sysfs support for it as it's no longer necessary.

-Carlos

Got it!
I will send another patch to remove threeg sysfs file.

I'm not sure you can drop sysfs files like that, as it will break the ABI.

Could you document acer-wmi in Documentation/ABI/testing/sysfs-platform-acer-wmi.txt ? This allows to check when a sysfs file was added, who use it, etc...

Thanks,

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#8 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

Hi Corentin,

於 一,2011-05-23 於 08:25 +0200,Corentin Chary 提到:

Quoted 21 lines · Joey Lee
Quoted 20 lines

於 日,2011-05-22 於 00:43 +0100,Carlos Corbacho 提到:

Quoted 19 lines · Chun-Yi
Quoted 11 lines

That will be better to check the existence of internal 3G device when we set threeg capability and generate killswitch for threeg. It can avoid userland access 3G rfkill but the machine doesn't have internal 3G device.

Reference: bko#32862

    https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

If you can now autodetect 3G and already have the relevant rfkill device, then you should also rip out the remaining sysfs support for it as it's no longer necessary.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

-Carlos

Got it!
I will send another patch to remove threeg sysfs file.

I'm not sure you can drop sysfs files like that, as it will break the ABI.

Yes, you are right.

Quoted 6 lines

Could you document acer-wmi in Documentation/ABI/testing/sysfs-platform-acer-wmi.txt ? This allows to check when a sysfs file was added, who use it, etc...

Thanks,

Thank's for your suggestion, I will maintain the ABI document like sysfs-platform-asus-wmi.

But, when can I remove threeg sysfs file?

Thank's
Joey Lee

#9 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

Quoted 6 lines · On Monday 23 May 2011 07:39:36 Joey Lee wrote:
Quoted 6 lines

I'm not sure you can drop sysfs files like that, as it will break the ABI.

Could you document acer-wmi in Documentation/ABI/testing/sysfs-platform-acer-wmi.txt ? This allows to check when a sysfs file was added, who use it, etc...

I don't agree, the 3G sysfs interface should just be dropped as it's the only remaining sysfs stuff for this driver - it's not worth documenting as it's already exposed as an rfkill device, and we've already dropped all the remaining sysfs interfaces a long time ago without going through any of this.

Besides, anybody who used it (and I never could find any 3G users of Acer laptops on Linux) was never guaranteed it wouldn't break horribly anyway as we couldn't properly autodetect 3G in the past or knew much about it other than Acer's WMI API suggested it existed.

-Carlos

#10 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

Quoted 13 lines · Carlos Corbacho
Quoted 6 lines · On Monday 23 May 2011 07:39:36 Joey Lee wrote:
Quoted 6 lines

I'm not sure you can drop sysfs files like that, as it will break the ABI.

Could you document acer-wmi in Documentation/ABI/testing/sysfs-platform-acer-wmi.txt ? This allows to check when a sysfs file was added, who use it, etc...

I don't agree, the 3G sysfs interface should just be dropped as it's the only remaining sysfs stuff for this driver - it's not worth documenting as it's already exposed as an rfkill device, and we've already dropped all the remaining sysfs interfaces a long time ago without going through any of this.

Quoted 4 lines

Besides, anybody who used it (and I never could find any 3G users of Acer laptops on Linux) was never guaranteed it wouldn't break horribly anyway as we couldn't properly autodetect 3G in the past or knew much about it other than Acer's WMI API suggested it existed.

I asked for documentation because I didn't check if there were other sysfs files remaining, if it's the last, we don't really care. I did a quick search, and you're right, this file doesn't seems to have a lot of user, but it would still break the ABI without any notice.
I would be more confortable with one or two cycle with this feature marked as deprecated and scheduled for removal.

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#11 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

In reply to Carlos Corbacho

Hi Carlos,

於 一,2011-05-23 於 07:41 +0100,Carlos Corbacho 提到:

Quoted 13 lines · On Monday 23 May 2011 07:39:36 Joey Lee wrote:
Quoted 6 lines
Quoted 6 lines

I'm not sure you can drop sysfs files like that, as it will break the ABI.

Could you document acer-wmi in Documentation/ABI/testing/sysfs-platform-acer-wmi.txt ? This allows to check when a sysfs file was added, who use it, etc...

I don't agree, the 3G sysfs interface should just be dropped as it's the only remaining sysfs stuff for this driver - it's not worth documenting as it's already exposed as an rfkill device, and we've already dropped all the remaining sysfs interfaces a long time ago without going through any of this.

After removed threeg sysfs file, there still have the latest one sysfs file the name is "interface". It provide a interface to know which WMI interface was used currently.

Should we also direct drop it from acer-wmi or move to debugfs?

Thank's a lot!
Joey Lee

#12 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

Quoted 5 lines · On Monday 23 May 2011 08:33:10 Joey Lee wrote:

After removed threeg sysfs file, there still have the latest one sysfs file the name is "interface". It provide a interface to know which WMI interface was used currently.

Should we also direct drop it from acer-wmi or move to debugfs?

I'd say drop it, the logs are more useful anyway and I doubt it's been updated to be useful with your recent work either.

-Carlos

#13 lore raw

Re: [PATCH 2/4] acer-wmi: check the existence of internal 3G device when set capability

Hi Carlos,

於 一,2011-05-23 於 19:54 +0100,Carlos Corbacho 提到:

Quoted 11 lines · On Monday 23 May 2011 08:33:10 Joey Lee wrote:
Quoted 5 lines

After removed threeg sysfs file, there still have the latest one sysfs file the name is "interface". It provide a interface to know which WMI interface was used currently.

Should we also direct drop it from acer-wmi or move to debugfs?

I'd say drop it, the logs are more useful anyway and I doubt it's been updated to be useful with your recent work either.

-Carlos

You are right, just need add a log when acer-wmi probed but don't need maintain a sysfs file.
I will send out patch to drop it and add log.

Thank's
Joey Lee

Acked-by on v1 1/4
#14 lore raw

Re: [PATCH 1/4] acer-wmi: does not allow negative number set to initial device state

In reply to Lee, Chun-Yi
Quoted 11 lines · Chun-Yi

The driver set module parameter value: mailled, threeg and brightness to BIOS by evaluate wmi method when driver was initialled. The default values for those parameters are -1, so, that will be better don't set negative value to BIOS.

Reference: bko#32862

        https://bugzilla.kernel.org/show_bug.cgi?id=32862

Tested on Acer Aspire 8930G, Acer Travelmate 8572

-Carlos

#15 lore raw

Re: [PATCH 1/4] acer-wmi: does not allow negative number set to initial device state

於 日,2011-05-22 於 00:38 +0100,Carlos Corbacho 提到:

Quoted 9 lines · Chun-Yi
Quoted 8 lines

The driver set module parameter value: mailled, threeg and brightness to BIOS by evaluate wmi method when driver was initialled. The default values for those parameters are -1, so, that will be better don't set negative value to BIOS.

Reference: bko#32862

        https://bugzilla.kernel.org/show_bug.cgi?id=32862
Quoted 7 lines
Quoted 3 lines

Tested on Acer Aspire 8930G, Acer Travelmate 8572

-Carlos

Thank's for Carlos's acked.

Joey Lee