2013-04-13 01:31:23

by Pali Rohár

[permalink] [raw]
Subject: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

Hello,

all Fn keys, wifi switch, web and mute buttons not working anymore
on my notebook HP EliteBook 8460p. I bisected git commit which
broke all above keys: fabf85e3ca15d5b94058f391dac8df870cdd427a

When I reverted that commit after reboot buttons started working
again. Can you fix it or revert that broken commit? This is
critical problem, which caused my notebook to be unusable...

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2013-04-13 01:35:14

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Sat, 2013-04-13 at 03:31 +0200, Pali Rohár wrote:

> all Fn keys, wifi switch, web and mute buttons not working anymore
> on my notebook HP EliteBook 8460p. I bisected git commit which
> broke all above keys: fabf85e3ca15d5b94058f391dac8df870cdd427a
>
> When I reverted that commit after reboot buttons started working
> again. Can you fix it or revert that broken commit? This is
> critical problem, which caused my notebook to be unusable...

Sure, I'll revert that. Kyle, can you look into figuring out a way to
only run this on machines that need it?

--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-04-13 12:37:11

by Kyle Evans

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

Sure, sorry about that. I was hoping the GUID would be enough. I'll see
what I can come up with.

On 04/12/2013 09:35 PM, Matthew Garrett wrote:
> On Sat, 2013-04-13 at 03:31 +0200, Pali Rohár wrote:
>
>> all Fn keys, wifi switch, web and mute buttons not working anymore
>> on my notebook HP EliteBook 8460p. I bisected git commit which
>> broke all above keys: fabf85e3ca15d5b94058f391dac8df870cdd427a
>>
>> When I reverted that commit after reboot buttons started working
>> again. Can you fix it or revert that broken commit? This is
>> critical problem, which caused my notebook to be unusable...
> Sure, I'll revert that. Kyle, can you look into figuring out a way to
> only run this on machines that need it?
>

2013-04-13 16:21:35

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Sat, 2013-04-13 at 08:36 -0400, Kyle Evans wrote:
> Sure, sorry about that. I was hoping the GUID would be enough. I'll see
> what I can come up with.

Sure there's no WMI method that makes the EC write? It's a little weird
for WMI drivers to have to hit the EC directly.

--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-04-13 17:39:29

by Kyle Evans

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On 04/13/2013 12:21 PM, Matthew Garrett wrote:
> On Sat, 2013-04-13 at 08:36 -0400, Kyle Evans wrote:
>> Sure, sorry about that. I was hoping the GUID would be enough. I'll see
>> what I can come up with.
> Sure there's no WMI method that makes the EC write? It's a little weird
> for WMI drivers to have to hit the EC directly.
>
I have no idea, I didn't know what a DSDT was before trying to get these
buttons working.

...A quick grep reveals acpi_wmi_ec_space_handler, is that what I should
use? It calls ec_write itself, but has more function parameters and of
course error checking to make sure you don't screw up those extra
parameters. Seems inefficient to me. Or, maybe like it was designed for
an automated code routine.

Looking further, I don't see any other drivers that use it, ec_write
seems to be the standard.

Your call though, you are the master in this domain and you wrote the
driver.



static acpi_status
acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address,
u32 bits, u64 *value,
void *handler_context, void *region_context)
{
int result = 0, i = 0;
u8 temp = 0;

if ((address > 0xFF) || !value)
return AE_BAD_PARAMETER;

if (function != ACPI_READ && function != ACPI_WRITE)
return AE_BAD_PARAMETER;

if (bits != 8)
return AE_BAD_PARAMETER;

if (function == ACPI_READ) {
result = ec_read(address, &temp);
(*value) |= ((u64)temp) << i;
} else {
temp = 0xff & ((*value) >> i);
result = ec_write(address, temp);
}

switch (result) {
case -EINVAL:
return AE_BAD_PARAMETER;
break;
case -ENODEV:
return AE_NOT_FOUND;
break;
case -ETIME:
return AE_TIME;
break;
default:
return AE_OK;
}
}

2013-04-13 17:42:27

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Sat, 2013-04-13 at 13:39 -0400, Kyle Evans wrote:
> On 04/13/2013 12:21 PM, Matthew Garrett wrote:
> > On Sat, 2013-04-13 at 08:36 -0400, Kyle Evans wrote:
> >> Sure, sorry about that. I was hoping the GUID would be enough. I'll see
> >> what I can come up with.
> > Sure there's no WMI method that makes the EC write? It's a little weird
> > for WMI drivers to have to hit the EC directly.
> >
> I have no idea, I didn't know what a DSDT was before trying to get these
> buttons working.

Got a copy of your ACPI tables?

--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-04-16 16:27:54

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

Can you try this patch?

diff --git a/drivers/platform/x86/hp-wmi.c
b/drivers/platform/x86/hp-wmi.c
index 45cacf7..91cc5df 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -53,6 +53,7 @@
MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
#define HPWMI_ALS_QUERY 0x3
#define HPWMI_HARDWARE_QUERY 0x4
#define HPWMI_WIRELESS_QUERY 0x5
+#define HPWMI_BIOS_QUERY 0x8
#define HPWMI_HOTKEY_QUERY 0xc
#define HPWMI_WIRELESS2_QUERY 0x1b

@@ -284,6 +285,18 @@ static int hp_wmi_tablet_state(void)
return (state & 0x4) ? 1 : 0;
}

+static int hp_wmi_enable_hotkeys()
+{
+ int ret;
+ int query = 1;
+
+ ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query, sizeof(query),
+ 0);
+ if (ret)
+ return -EINVAL;
+ return 0;
+}
+
static int hp_wmi_set_block(void *data, bool blocked)
{
enum hp_wmi_radio r = (enum hp_wmi_radio) data;
@@ -925,9 +938,7 @@ static int __init hp_wmi_init(void)
err = hp_wmi_input_setup();
if (err)
return err;
-
- //Enable magic for hotkeys that run on the SMBus
- ec_write(0xe6,0x6e);
+ hp_wmi_enable_hotkeys();
}

if (bios_capable) {


--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-04-17 13:56:45

by Pali Rohár

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Tuesday 16 April 2013 18:26:26 Matthew Garrett wrote:
> Can you try this patch?
>
> diff --git a/drivers/platform/x86/hp-wmi.c
> b/drivers/platform/x86/hp-wmi.c
> index 45cacf7..91cc5df 100644
> --- a/drivers/platform/x86/hp-wmi.c
> +++ b/drivers/platform/x86/hp-wmi.c
> @@ -53,6 +53,7 @@
> MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
> #define HPWMI_ALS_QUERY 0x3
> #define HPWMI_HARDWARE_QUERY 0x4
> #define HPWMI_WIRELESS_QUERY 0x5
> +#define HPWMI_BIOS_QUERY 0x8
> #define HPWMI_HOTKEY_QUERY 0xc
> #define HPWMI_WIRELESS2_QUERY 0x1b
>
> @@ -284,6 +285,18 @@ static int hp_wmi_tablet_state(void)
> return (state & 0x4) ? 1 : 0;
> }
>
> +static int hp_wmi_enable_hotkeys()
> +{
> + int ret;
> + int query = 1;
> +
> + ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query,
> sizeof(query), + 0);
> + if (ret)
> + return -EINVAL;
> + return 0;
> +}
> +
> static int hp_wmi_set_block(void *data, bool blocked)
> {
> enum hp_wmi_radio r = (enum hp_wmi_radio) data;
> @@ -925,9 +938,7 @@ static int __init hp_wmi_init(void)
> err = hp_wmi_input_setup();
> if (err)
> return err;
> -
> - //Enable magic for hotkeys that run on the SMBus
> - ec_write(0xe6,0x6e);
> + hp_wmi_enable_hotkeys();
> }
>
> if (bios_capable) {

Hello,
I tested above patch and it fixing my problem. Now Fn keys working
again on my HP EliteBook 8460p.

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2013-04-17 15:37:14

by Kyle Evans

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On 04/16/2013 12:26 PM, Matthew Garrett wrote:
> Can you try this patch?
>

No dice. I have a dmi check patch that I will send in a day or two if
you don't find what you are looking for.

Currently, I am based on the torvalds master, but I can base off
something else if you'd like.

2013-04-17 17:59:26

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Wed, 2013-04-17 at 11:37 -0400, Kyle Evans wrote:
> On 04/16/2013 12:26 PM, Matthew Garrett wrote:
> > Can you try this patch?
> >
>
> No dice. I have a dmi check patch that I will send in a day or two if
> you don't find what you are looking for.

DMI's almost certainly the wrong solution. According to your DSDT, EC
register 0xe6 is called SFHK. That's written to by the SSHK method,
which in turn is executed by SHKS which should be called by the
hp_wmi_query call added there. Any chance you can try to figure out why
that's not happening?

--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-04-17 18:55:48

by Kyle Evans

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a


On 04/17/2013 01:59 PM, Matthew Garrett wrote:
> On Wed, 2013-04-17 at 11:37 -0400, Kyle Evans wrote:
>> On 04/16/2013 12:26 PM, Matthew Garrett wrote:
>>> Can you try this patch?
>>>
>> No dice. I have a dmi check patch that I will send in a day or two if
>> you don't find what you are looking for.
> DMI's almost certainly the wrong solution. According to your DSDT, EC
> register 0xe6 is called SFHK. That's written to by the SSHK method,
> which in turn is executed by SHKS which should be called by the
> hp_wmi_query call added there. Any chance you can try to figure out why
> that's not happening?
>

I see, I don't know how I missed that before. I think because I was
searching for e6 instead of E6. I'm sure we can crack this the right way
now. I'll do some digging.

2013-04-18 13:55:23

by Kyle Evans

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a


On 04/17/2013 01:59 PM, Matthew Garrett wrote:
> On Wed, 2013-04-17 at 11:37 -0400, Kyle Evans wrote:
>> On 04/16/2013 12:26 PM, Matthew Garrett wrote:
>>> Can you try this patch?
>>>
>> No dice. I have a dmi check patch that I will send in a day or two if
>> you don't find what you are looking for.
> DMI's almost certainly the wrong solution. According to your DSDT, EC
> register 0xe6 is called SFHK. That's written to by the SSHK method,
> which in turn is executed by SHKS which should be called by the
> hp_wmi_query call added there. Any chance you can try to figure out why
> that's not happening?
>

I am not fully understanding how the bios query ID gets translated into
the method. As far as I can tell this happens under HWMC. But, if I
trace through that, 0x8(write) and 0x9(read) do not exist. However,
0x9(read) does have a method that works when I query it, GHKS. I do not
find the method for 0x8(write).

0x9(write), or SHKS, is essentially ec_write(SFHK,Arg0). Arg0 turns out
to be whatever data is sent in the 0x9 buffer.
...
CreateDWordField (Arg1, 0x10, DDWD)

If (LEqual (CMDT, 0x09))
{
Store (SHKS (DDWD), Local2)
...

I tried writing 0x60, and I tried writing 0x0e just to see if it if a
subset of that register is needed to enable the keys and it seems I need
the full 0x6e. I only find two places in the DSDT with that value, both
in the WQAE buffer and I can't see how that is used.

2013-04-18 15:58:27

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Thu, 2013-04-18 at 09:55 -0400, Kyle Evans wrote:

> 0x9(write), or SHKS, is essentially ec_write(SFHK,Arg0). Arg0 turns out

Oh - try changing

int query = 1

to

int query=0x6e

--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-04-18 16:49:10

by Kyle Evans

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a


On 04/18/2013 11:58 AM, Matthew Garrett wrote:
> On Thu, 2013-04-18 at 09:55 -0400, Kyle Evans wrote:
>
>> 0x9(write), or SHKS, is essentially ec_write(SFHK,Arg0). Arg0 turns out
> Oh - try changing
>
> int query = 1
>
> to
>
> int query=0x6e
>
That only works if I also change:

-#define HPWMI_BIOS_QUERY 0x8
+#define HPWMI_BIOS_QUERY 0x9

But then we are still faced with a hardware detection problem I would assume.

2013-04-18 16:54:52

by Matthew Garrett

[permalink] [raw]
Subject: Re: BUG: Fn keys not working on EliteBook 8460p after fabf85e3ca15d5b94058f391dac8df870cdd427a

On Thu, 2013-04-18 at 12:48 -0400, Kyle Evans wrote:

> That only works if I also change:
>
> -#define HPWMI_BIOS_QUERY 0x8
> +#define HPWMI_BIOS_QUERY 0x9
>
> But then we are still faced with a hardware detection problem I would assume.

Heh. That's actually what it should have been in the first place - I
just screwed it up. So, looks like that's a good starting point. I'll
push the revert to Linux and queue this up for 3.10.

--
Matthew Garrett | [email protected]
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-08-14 08:20:04

by Pali Rohár

[permalink] [raw]
Subject: BUG: Again: Fn keys not working on EliteBook 8460p after b253c9d1d858a3f115f791ee4fe2b9399ae7dbbd

On Saturday 13 April 2013 03:31:17 Pali Rohár wrote:
> Hello,
>
> all Fn keys, wifi switch, web and mute buttons not working
> anymore on my notebook HP EliteBook 8460p. I bisected git
> commit which broke all above keys:
> fabf85e3ca15d5b94058f391dac8df870cdd427a
>
> When I reverted that commit after reboot buttons started
> working again. Can you fix it or revert that broken commit?
> This is critical problem, which caused my notebook to be
> unusable...

Hello, same problem happen again on my notebook. Problematic
commit is now: b253c9d1d858a3f115f791ee4fe2b9399ae7dbbd
hp-wmi: Enable hotkeys on some systems

When I disabled calling function hp_wmi_enable_hotkeys() from
hp_wmi_init() keys started working again after reboot.

This problem is present in 3.11 rc5. Please can you do something
so keys on my notebook will work again and it will not be broken
again in next kernel release? If you need some debug data or
something else, I can help.

In mail from 16.04.2013 you provided similar patch but with
#define HPWMI_BIOS_QUERY 0x8
I tested that patch and that does not broke keys.

But commit b253c9d1d858a3f115f791ee4fe2b9399ae7dbbd have
#define HPWMI_BIOS_QUERY 0x9
which broke keys again...

--
Pali Rohár
[email protected]


Attachments:
signature.asc (198.00 B)
This is a digitally signed message part.

2013-08-14 14:18:31

by Kyle Evans

[permalink] [raw]
Subject: [PATCH] hp-wmi; Limit hotkey enable funtion

This patch is a supplement to commit
b253c9d1d858a3f115f791ee4fe2b9399ae7dbbd

Signed-off-by: Kyle Evans <[email protected]>
---
drivers/platform/x86/hp-wmi.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 97bb05e..b65014f 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -35,6 +35,7 @@
#include <linux/input/sparse-keymap.h>
#include <linux/platform_device.h>
#include <linux/acpi.h>
+#include <linux/dmi.h>
#include <linux/rfkill.h>
#include <linux/string.h>

@@ -996,6 +997,17 @@ static struct platform_driver hp_wmi_driver = {
.remove = __exit_p(hp_wmi_bios_remove),
};

+static struct dmi_system_id __initdata tx2_dmi_table[] = {
+ {
+ .ident = "tx2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "tx2"),
+ },
+ },
+ { }
+};
+
static int __init hp_wmi_init(void)
{
int err;
@@ -1010,7 +1022,9 @@ static int __init hp_wmi_init(void)
if (err)
return err;

- hp_wmi_enable_hotkeys();
+ if (dmi_check_system(tx2_dmi_table)) {
+ hp_wmi_enable_hotkeys();
+ {
}

if (bios_capable) {
--
1.7.3.4