Skip to contentSkip to conversation

i8042 access timings

DISCUSSION Jaco Kroon 9 participants 24 messages Jan 27, 2005 – Feb 4, 2005 1 message not in the archive Input drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jaco Kroon

author
#1 lore raw
Quoted 1 line · Sebastian Piechocki

As I said I'm sending you mails from kernel masters:)

Thanks.

Quoted 1 line

If you haven't such a problem, please send them your dmesg with i8042.debug and acpi=off.

I made an alternative plan. I applied a custom patch that gives me far less output and prevents scrolling and gets what I hope is what is required.

With acpi=on I get the following output:
i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
i8042_check_aux()
i8042_flush()
i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0 i8042_allocate_kbd_port()
i8042_port_register()

With acpi=off I get this:
i8042_init()
i8042: ACPI detection disabled i8042_controller_init()
i8042_flush()
i8042_check_aux()
i8042_flush()
i8042_check_aux: passed
i8042_check_mux()
i8042_enable_mux_mode()
i8042_flush()
i8042_open(): mux_version==19
i8042.c: Detected active multiplexing controller, rev 1.9. i8042_enable_mux_ports() i8042_allocate_mux_port()
i8042_port_register()

Ok, some explanation is probably in order, I just put a printk(KERN_INFO "function_name()\n" at the top of practically every function and then I filled up i8042_check_aux() because that is where the error is detected.
In the first case (the interesting one) these lines pop up:

i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

Which indicates (as far as my understanding goes) that the command times out, as such the param value stays the same (ready for re-use in the second command). The second commands succeeds but does not return one of the expected (0x00, 0xff, 0xfa) values, instead it returns the value as expected by the first command (0xa5). The last value on both lines is the return value. From the second snippet:

i8042_flush()
i8042_check_aux: passed

Indicates that the outer test passed first time round, ie, exit code 0 and return param of 0xa5. What I have done to get mine working with acpi=on is applied the following patch (apologies if mozilla breaks this):

======================

drivers/input/serio/i8042.c 2005-01-24 21:44:33.790291480 +0200 renamed from drivers/input/serio/i8042.c 2004-12-24 23:33:52.000000000 +0200 +1 -1
@@ -595,7 +595,7 @@
  */
 
                if (i8042_command(&param, I8042_CMD_AUX_TEST)
-                       || (param && param != 0xfa && param != 0xff))
+                       || (param && param != 0xfa  && param != 0xa5 && param != 0xff))
                                return -1;
        }
 

======================

Which I don't think is the proper solution, more likely the problem lies in the i8042_command function. Unfortunately I don't have time right now to add more debug code (to possibly only issue those dbg statements upto a certain point in order to reduce the amount of output).

Quoted 3 lines

As I remember with acpi=off i8042 detects multplexer MUX with four ports! I tried to make a hack for mux detection, but mux was detected and touchpad was not:(

Yes. This seems correct, however the touchoad worked "perfectly" for me when I booted with acpi=off.

Quoted 7 lines

Dmitry,
did you see this one?

Since everything but the I8042_CMD_AUX_LOOP/AUX_TEST thing apparently
works, this is not the case of ACPI setting the wrong ports or something fundamental like that. It looks like some state of the keyboard controller just disables the loopback command and/or the AUX_TEST command.

Might the "no KBD" case be something similar?

I'm probably a bit off here, but what "no KBD" case? On these particular notebooks we both had to compile in specifically USB1.1 support in order to have keyboard support, but since I want USB support in any case this is not a problem for me (although I would love to know what caused this).

Quoted 1 line

Sebastian, can you make your hack also print out what the errors were (in particular, was it "i8042_command()" that failed, or was it that the return value was different from the expected ones, and if so - what?)

I hope my debug did exactly that.

From the orriginal mail sent to me by Sebastian:

Quoted 21 lines
Quoted 21 lines

In method:
i8042_check_aux

There is:

param = 0x5a;
       if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xa5) 

{

/*
* External connection test - filters out AT-soldered PS/2 i8042's
* 0x00 - no error, 0x01-0x03 - clock/data stuck, 0xff - general error
* 0xfa - no error on some notebooks which ignore the spec
* Because it's common for chipsets to return error on perfectly functioning
* AUX ports, we test for this only when the LOOP command failed. */

               if (i8042_command(&param, I8042_CMD_AUX_TEST)
                       || (param && param != 0xfa && param != 0xff))
                               return -1;
       }
Quoted 5 lines
Quoted 5 lines

I have commented the line with return -1.
I know that this solution is very stupid, but works fine. I use 2.6.11-rc1-mm1 kernel, and my touchpad is detected as ALPS.

I think this is some special situation, that need extra detection possibility? Am I right?

Not sure yet. It could be that the patch I've got covers all cases but highly unlikely.

Quoted 3 lines
Quoted 3 lines

I can imagine a new chipset (I don't have the ATI IXP handy) that wouldn't care to implement the loopback and test commands on the AUX port. But what really surprises me here that disabling ACPI actually helps.

But I do. So if you have any ideas I could try, or documentation to point me at, now is the time.

Quoted 3 lines
Quoted 3 lines

Since Sebastian writes that the AUX check ends with a timeout, we also know that it never returns any datam so adding the printk() is probably pointless.

From the above - isn't it simply that the timeout is too short? Somehow enabling ACPI makes the timer go weird? Will disabling HPET make a difference?

Quoted 4 lines
Quoted 4 lines

Sebastian, here are a few shots in the dark: Does disabling Legacy USB emulation in the BIOS help? It might. Could you enable i8042.c DEBUG and compare the traces in the working and non-working cases side by side whether there is anything different prior to this failure point?

It doesn't look like there is any "legacy USB" options in the BIOS. I might just be missing it though :).

Right, long mail, sorry about that.

Jaco

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#2 lore raw
Quoted 9 lines · Jaco Kroon
Quoted 1 line · Sebastian Piechocki

As I said I'm sending you mails from kernel masters:)

Thanks.

Quoted 2 lines

If you haven't such a problem, please send them your dmesg with i8042.debug and acpi=off.

I made an alternative plan. I applied a custom patch that gives me far less output and prevents scrolling and gets what I hope is what is required.

... could you just increase the timeout value to some insane amount? That should take care of the AUX_LOOP output getting back only after issuing the next command.

Also, can you check if adding 'usb-handoff' to the kernel command line helps you as well as it helped Sebastian?

Quoted 165 lines

With acpi=on I get the following output:
i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
i8042_check_aux()
i8042_flush()
i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0 i8042_allocate_kbd_port()
i8042_port_register()

With acpi=off I get this:
i8042_init()
i8042: ACPI detection disabled i8042_controller_init()
i8042_flush()
i8042_check_aux()
i8042_flush()
i8042_check_aux: passed
i8042_check_mux()
i8042_enable_mux_mode()
i8042_flush()
i8042_open(): mux_version==19
i8042.c: Detected active multiplexing controller, rev 1.9. i8042_enable_mux_ports() i8042_allocate_mux_port()
i8042_port_register()

Ok, some explanation is probably in order, I just put a printk(KERN_INFO "function_name()\n" at the top of practically every function and then I filled up i8042_check_aux() because that is where the error is detected.
In the first case (the interesting one) these lines pop up:

i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

Which indicates (as far as my understanding goes) that the command times out, as such the param value stays the same (ready for re-use in the second command). The second commands succeeds but does not return one of the expected (0x00, 0xff, 0xfa) values, instead it returns the value as expected by the first command (0xa5). The last value on both lines is the return value. From the second snippet:

i8042_flush()
i8042_check_aux: passed

Indicates that the outer test passed first time round, ie, exit code 0 and return param of 0xa5. What I have done to get mine working with acpi=on is applied the following patch (apologies if mozilla breaks this):

======================
--- linux-2.6.10/drivers/input/serio/i8042.c 2004-12-24
23:33:52.000000000 +0200
+++ linux-2.6.10-patched/drivers/input/serio/i8042.c 2005-01-24
21:44:33.790291480 +0200

drivers/input/serio/i8042.c 2005-01-24 21:44:33.790291480 +0200 renamed from drivers/input/serio/i8042.c 2004-12-24 23:33:52.000000000 +0200 +1 -1
@@ -595,7 +595,7 @@
  */
 
                if (i8042_command(&param, I8042_CMD_AUX_TEST)
-                       || (param && param != 0xfa && param != 0xff))
+                       || (param && param != 0xfa  && param != 0xa5 && 
 param != 0xff))
                                return -1;
        }

======================

Which I don't think is the proper solution, more likely the problem lies in the i8042_command function. Unfortunately I don't have time right now to add more debug code (to possibly only issue those dbg statements upto a certain point in order to reduce the amount of output).

Quoted 2 lines

As I remember with acpi=off i8042 detects multplexer MUX with four ports! I tried to make a hack for mux detection, but mux was detected and

touchpad

Quoted 1 line

was not:(

Yes. This seems correct, however the touchoad worked "perfectly" for me when I booted with acpi=off.

Quoted 9 lines

Dmitry,
did you see this one?

Since everything but the I8042_CMD_AUX_LOOP/AUX_TEST thing apparently works, this is not the case of ACPI setting the wrong ports or something fundamental like that. It looks like some state of the keyboard controller just disables the loopback command and/or the AUX_TEST command.

Might the "no KBD" case be something similar?

I'm probably a bit off here, but what "no KBD" case? On these particular notebooks we both had to compile in specifically USB1.1 support in order to have keyboard support, but since I want USB support in any case this is not a problem for me (although I would love to know what caused this).

Quoted 3 lines

Sebastian, can you make your hack also print out what the errors were (in particular, was it "i8042_command()" that failed, or was it that the return value was different from the expected ones, and if so - what?)

I hope my debug did exactly that.

From the orriginal mail sent to me by Sebastian:

Quoted 22 lines
Quoted 22 lines

In method:
i8042_check_aux

There is:

param = 0x5a;
      if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xa5) 

{

/*
* External connection test - filters out AT-soldered PS/2 i8042's
* 0x00 - no error, 0x01-0x03 - clock/data stuck, 0xff - general error
* 0xfa - no error on some notebooks which ignore the spec
* Because it's common for chipsets to return error on perfectly functioning
* AUX ports, we test for this only when the LOOP command failed. */

              if (i8042_command(&param, I8042_CMD_AUX_TEST)
                      || (param && param != 0xfa && param != 0xff))
                              return -1;
      }
Quoted 6 lines
Quoted 6 lines

I have commented the line with return -1.
I know that this solution is very stupid, but works fine. I use 2.6.11-rc1-mm1 kernel, and my touchpad is detected as ALPS.

I think this is some special situation, that need extra detection possibility? Am I right?

Not sure yet. It could be that the patch I've got covers all cases but highly unlikely.

Quoted 4 lines
Quoted 4 lines

I can imagine a new chipset (I don't have the ATI IXP handy) that wouldn't care to implement the loopback and test commands on the AUX port. But what really surprises me here that disabling ACPI actually helps.

But I do. So if you have any ideas I could try, or documentation to point me at, now is the time.

Quoted 3 lines
Quoted 3 lines

Since Sebastian writes that the AUX check ends with a timeout, we also know that it never returns any datam so adding the printk() is probably pointless.

From the above - isn't it simply that the timeout is too short? Somehow enabling ACPI makes the timer go weird? Will disabling HPET make a difference?

Quoted 4 lines
Quoted 4 lines

Sebastian, here are a few shots in the dark: Does disabling Legacy USB emulation in the BIOS help? It might. Could you enable i8042.c DEBUG and compare the traces in the working and non-working cases side by side whether there is anything different prior to this failure point?

It doesn't look like there is any "legacy USB" options in the BIOS. I might just be missing it though :).

Right, long mail, sorry about that.

Jaco

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#3 lore raw
Quoted 9 lines · Vojtech Pavlik
Quoted 8 lines · Jaco Kroon
Quoted 1 line · Sebastian Piechocki

As I said I'm sending you mails from kernel masters:)

Thanks.

Quoted 2 lines

If you haven't such a problem, please send them your dmesg with i8042.debug and acpi=off.

Quoted 7 lines
Quoted 3 lines

I made an alternative plan. I applied a custom patch that gives me far less output and prevents scrolling and gets what I hope is what is required.

... could you just increase the timeout value to some insane amount? That should take care of the AUX_LOOP output getting back only after issuing the next command.

Increasing the timeout doesn't help. I've increased timout ten times and the result is the same.

Signature · 2 lines
Sebastian Piechocki
[email protected]
#4 lore raw
Quoted 14 lines · Sebastian Piechocki
Quoted 13 lines · Vojtech Pavlik
Quoted 11 lines · Jaco Kroon
Quoted 1 line · Sebastian Piechocki

As I said I'm sending you mails from kernel masters:)

Thanks.

Quoted 2 lines

If you haven't such a problem, please send them your dmesg with i8042.debug and acpi=off.

I made an alternative plan. I applied a custom patch that gives me far less output and prevents scrolling and gets what I hope is what is required.

Quoted 6 lines
Quoted 3 lines

... could you just increase the timeout value to some insane amount? That should take care of the AUX_LOOP output getting back only after issuing the next command.

Increasing the timeout doesn't help. I've increased timout ten times and the result is the same.

OK, in that case the BIOS i8042 emulation just interferes badly with the real i8042 and I doubt we can do much else than keep the BIOS from interfering.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
author
#5 lore raw
Quoted 24 lines · Vojtech Pavlik
Quoted 22 lines · Sebastian Piechocki
Quoted 19 lines · Vojtech Pavlik
Quoted 7 lines · Jaco Kroon
Quoted 1 line · Sebastian Piechocki

As I said I'm sending you mails from kernel masters:)

Thanks.

Quoted 6 lines
Quoted 2 lines

If you haven't such a problem, please send them your dmesg with i8042.debug and acpi=off.

I made an alternative plan. I applied a custom patch that gives me far less output and prevents scrolling and gets what I hope is what is required.

... could you just increase the timeout value to some insane amount? That should take care of the AUX_LOOP output getting back only after issuing the next command.

Quoted 7 lines
Quoted 1 line

Increasing the timeout doesn't help. I've increased timout ten times and the result is the same.

OK, in that case the BIOS i8042 emulation just interferes badly with the real i8042 and I doubt we can do much else than keep the BIOS from interfering.

And just how do we do that?

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#6 lore raw
In reply to Jaco Kroon
Quoted 7 lines · Jaco Kroon

Which indicates (as far as my understanding goes) that the command times out, as such the param value stays the same (ready for re-use in the second command). The second commands succeeds but does not return one of the expected (0x00, 0xff, 0xfa) values, instead it returns the value as expected by the first command (0xa5). The last value on both lines is the return value. From the second snippet:

No, I think the 0x5a you see is the 0x5a that is _still_ there, because we never got any reply at all from the i8042_command(I8042_CMD_AUX_LOOP) case, nor did the I8042_CMD_AUX_TEST thing do anything at all.

I have a suspicion: these commands are also one of the few ones that write a data byte to the data port immediately after writing the command byte to the status port.

It so happens that if the hardware is slow to reach to the command byte, we might read the status word _before_ the hardware has had time to even say "ok, my input port is now full". We have a "udelay()" there in i8042_wait_write(), but we have it _after_ we've done the i8042_read_status(), so effectively the i8042_read_status() happens immediately after the i8042_write_command().

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

The IO delay should be _before_ the read of the status, not after it.

So how about adding an extra "udelay(50)" to either the top of i8042_wait_write(), or to the bottom of "i8042_write_command()"? Does that make any difference?

(50 usec is probably overkill, and an alternative is to just make the write_data/write_command inline functions in i8042-io.h use the "inb_p/outb_p" versions that put a serializing IO instruction in between, which should give you a nice 1us delay even on modern hardware.)

Linus

#7 lore raw
Quoted 4 lines · Linus Torvalds

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

Hmm - I just answered the same post and concluded that I didnt understand, so you have progressed further. I considered the same possibility, but the data was not lost since we read it again later.
Only the ready flag was lost.

Quoted 1 line

The IO delay should be _before_ the read of the status, not after it.

Andries

maintainer
#8 lore raw
Quoted 7 lines · Andries Brouwer
Quoted 4 lines · Linus Torvalds

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

Quoted 5 lines

Hmm - I just answered the same post and concluded that I didnt understand, so you have progressed further. I considered the same possibility, but the data was not lost since we read it again later.
Only the ready flag was lost.

No, note that if there was valid data we would dee 0xa5 instead of 0x5a that was in the buffer - because in i8042_command we invert data coming from AUX port. So Linus's theory seems feasible.

Signature · 1 line
Dmitry
#9 lore raw
Quoted 5 lines
Quoted 1 line

Only the ready flag was lost.

No, note that if there was valid data we would see 0xa5 instead of 0x5a that was in the buffer - because in i8042_command we invert data coming from AUX port.

We misunderstand each other.

Let me repeat. The following happens:
We wait, then write d3, wait, then write 5a, wait for input, timeout. We wait, then write a9, wait for input, read 5a from AUXB. (That 5a is inverted to a5 to signal that it came from AUXB.)

Of course, that 5a is the result of the 5a that we sent via the d3 command. But why does that command time out? For some reason the information that there is a byte ready to be read was not transmitted to the status register. But as soon as we gave another command, a9 in this case, this system remembered that something was ready, and set the appropriate status bit.

One might experiment a little - see for example whether other commands than a9 suffice in "waking the kbd controller".

All is fine, only the flag was lost, nobody knows why. Maybe just because the d3 implementation is buggy. That has been seen more often.

But there is another part that we must think about - the fragment

i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [9] i8042_flush()

Andries

By the way, we should remove this silly response byte inversion and just store a separate bit.

#10 lore raw
In reply to Andries Brouwer
Quoted 9 lines · Andries Brouwer
Quoted 4 lines

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

Hmm - I just answered the same post and concluded that I didnt understand, so you have progressed further. I considered the same possibility, but the data was not lost since we read it again later.
Only the ready flag was lost.

What I believe is happening is that we're talking to SMM emulation of the i8042, which doesn't have a clue about these commands, while the underlying real hardware implementation does. And because of that they disagree on what should happen when the command is issued, and since the SMM emulation lazily synchronizes with the real HW, we only get the data back with the next command.

I still don't have an explanation why both 'usb-handoff' and 'acpi=off' help, I'd expect only the first to, but it might be related to the SCI interrupt routing which isn't done when 'acpi=off'. Just a wild guess.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
author
#11 lore raw
Quoted 18 lines · Vojtech Pavlik
Quoted 6 lines · Andries Brouwer
Quoted 1 line

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

Hmm - I just answered the same post and concluded that I didnt understand, so you have progressed further. I considered the same possibility, but the data was not lost since we read it again later.
Only the ready flag was lost.

What I believe is happening is that we're talking to SMM emulation of the i8042, which doesn't have a clue about these commands, while the underlying real hardware implementation does. And because of that they disagree on what should happen when the command is issued, and since the SMM emulation lazily synchronizes with the real HW, we only get the data back with the next command.

Quoted 4 lines

I still don't have an explanation why both 'usb-handoff' and 'acpi=off' help, I'd expect only the first to, but it might be related to the SCI interrupt routing which isn't done when 'acpi=off'. Just a wild guess.

Ok, I'm not too clued up with recent hardware and the BIOS programming that goes with it (being a system admin/application programmer), what exactly is usb-handoff? acpi=off obviously just turns all acpi support in the kernel off. SCI is also a new abbreviation I haven't seen before. Whilst I've seen SMM before, I'm not sure what it stands for (I assume it's something to do with simulation of legacy devices for older operating systems)?

From the kernel-parameters documentation:

usb-handoff [HW] Enably early USB BIOS -> OS handoff

I guess this means the OS takes over control of the USB devices at an earlier stage than usual - possibly before ACPI gets initialised? I'm unable to determine much from looking at drivers/pci/quirks.c (which is where the usb-handoff parameter is defined).

usb-handoff=1 does however also fix the problem. Ok. This makes it even more confusing (and probably more complicated). The appropriate section from dmesg that shows that it is working correctly:

i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [4] drivers/input/serio/i8042.c: 47 <- i8042 (return) [4] drivers/input/serio/i8042.c: 60 -> i8042 (command) [4] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [4] i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [8] i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [13] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [13] drivers/input/serio/i8042.c: a5 <- i8042 (return) [13]
i8042_check_aux: passed

So as with acpi=off, we get a correct return. Now that usb is mentioned, I think either myself or Sebastian has mentioned that the keyboard does not work unless USB1.1 support is compiled in. Another clue possibly?

Another question - would it be usefull at all to see what happens if the AUX_LOOP test is never performed but only AUX_TEST? Or does AUX_TEST rely on the fact that AUX_LOOP must first fail/timeout somehow?

Jaco

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#12 lore raw
Quoted 22 lines · Jaco Kroon
Quoted 21 lines · Vojtech Pavlik
Quoted 9 lines · Andries Brouwer
Quoted 4 lines

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

Hmm - I just answered the same post and concluded that I didnt understand, so you have progressed further. I considered the same possibility, but the data was not lost since we read it again later.
Only the ready flag was lost.

What I believe is happening is that we're talking to SMM emulation of the i8042, which doesn't have a clue about these commands, while the underlying real hardware implementation does. And because of that they disagree on what should happen when the command is issued, and since the SMM emulation lazily synchronizes with the real HW, we only get the data back with the next command.

Quoted 8 lines
Quoted 4 lines

I still don't have an explanation why both 'usb-handoff' and 'acpi=off' help, I'd expect only the first to, but it might be related to the SCI interrupt routing which isn't done when 'acpi=off'. Just a wild guess.

Ok, I'm not too clued up with recent hardware and the BIOS programming that goes with it (being a system admin/application programmer), what exactly is usb-handoff?

usb-handoff is a kernel option that enables a PCI quirk routine that takes the USB controller out of BIOS's hands. Until that is done (the linux USB drivers also do it, only later), the BIOS owns the USB controller and tries to emulate a PS/2 mouse and keyboard for systems which can't handle USB.

Quoted 2 lines

acpi=off obviously just turns all acpi support
in the kernel off.

Indeed.

Quoted 2 lines

SCI is also a new abbreviation I haven't seen
before.

System Configuration Interrupt. In addition to SMI (System Management Interrupt), these are two interrupts the BIOS uses to do its job behind the operating system's back.

Quoted 1 line

Whilst I've seen SMM before, I'm not sure what it stands for (I

SMM is System Management Mode. It's a special mode of the CPU, which is entered when a SMI is triggered by some event, like an port write trap in the case of the emulated PS/2 mouse.

Using SMM the BIOS can emulate any device it wishes to, and the OS will think it's real. It's an even more privileged mode than what the OS runs in.

Quoted 2 lines

assume it's something to do with simulation of legacy devices for older operating systems)?

It also does thermal monitoring, often is used for turning the backlight off on notebooks, and handling various magic Fn- key combinations.

Quoted 6 lines

From the kernel-parameters documentation:

usb-handoff [HW] Enably early USB BIOS -> OS handoff

I guess this means the OS takes over control of the USB devices at an earlier stage than usual - possibly before ACPI gets initialised?

Before the i8042 keyboard driver gets initialized. That's the important part, because the handoff stops the BIOS from emulating a PS/2 mouse, and thus blocking access to the real PS/2 mouse controller.

Quoted 8 lines

I'm
unable to determine much from looking at drivers/pci/quirks.c (which is where the usb-handoff parameter is defined).

usb-handoff=1 does however also fix the problem. Ok. This makes it even more confusing (and probably more complicated). The appropriate section from dmesg that shows that it is working correctly:

Quoted 16 lines

i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [4] drivers/input/serio/i8042.c: 47 <- i8042 (return) [4] drivers/input/serio/i8042.c: 60 -> i8042 (command) [4] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [4] i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [8] i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [13] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [13] drivers/input/serio/i8042.c: a5 <- i8042 (return) [13]
i8042_check_aux: passed

I don't like the interrupt message, I'll check why it's enabled so early. It may have a good reason to, as well. Other than that, it looks very much OK.

Quoted 4 lines

So as with acpi=off, we get a correct return. Now that usb is mentioned, I think either myself or Sebastian has mentioned that the keyboard does not work unless USB1.1 support is compiled in. Another clue possibly?

Compiling USB 1.1 support does the very same thing as specifying usb-handoff on the command like - tells the BIOS to keep its hands off the USB _and_ PS/2 controllers.

Quoted 3 lines

Another question - would it be usefull at all to see what happens if the AUX_LOOP test is never performed but only AUX_TEST? Or does AUX_TEST rely on the fact that AUX_LOOP must first fail/timeout somehow?

No. You can use AUX_TEST event before AUX_LOOP. But I expect it to fail similarly when BIOS is active.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
author
#13 lore raw
Quoted 6 lines · Vojtech Pavlik
Quoted 6 lines
Quoted 6 lines

What I believe is happening is that we're talking to SMM emulation of the i8042, which doesn't have a clue about these commands, while the underlying real hardware implementation does. And because of that they disagree on what should happen when the command is issued, and since the SMM emulation lazily synchronizes with the real HW, we only get the data back with the next command.

This makes sense in a weird kind of way.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I still don't have an explanation why both 'usb-handoff' and 'acpi=off' help, I'd expect only the first to, but it might be related to the SCI interrupt routing which isn't done when 'acpi=off'. Just a wild guess.

SCI interrupt routing? I have tried with pci=routeirq and that hasn't helped either. IRQ balancing perhaps?

Quoted 3 lines

I don't like the interrupt message, I'll check why it's enabled so early. It may have a good reason to, as well. Other than that, it looks very much OK.

That was with usb-handoff. It also resulted in the black screen of bios-death upon reboot though :).

Quoted 6 lines
Quoted 1 line

So as with acpi=off, we get a correct return. Now that usb is mentioned, I think either myself or Sebastian has mentioned that the keyboard does not work unless USB1.1 support is compiled in. Another clue possibly?

Compiling USB 1.1 support does the very same thing as specifying usb-handoff on the command like - tells the BIOS to keep its hands off the USB _and_ PS/2 controllers.

I'm missing something, I have USB1.1 compiled in, then why does the touchpad not work if it does the very same thing as usb-handoff?

Quoted 3 lines
Quoted 1 line

Another question - would it be usefull at all to see what happens if the AUX_LOOP test is never performed but only AUX_TEST? Or does AUX_TEST rely on the fact that AUX_LOOP must first fail/timeout somehow?

No. You can use AUX_TEST event before AUX_LOOP. But I expect it to fail similarly when BIOS is active.

That is correct. It fails with timeout. This for me confirms the fact that it is responding one command too late. aka, we send a command, it times out, we send another, it sends the result of the first.

Right, any new (or variations of existing ones) theories that I can try out to make this touchpad work correctly? I can simply hack out the test for the touchpad but that doesn't solve the problem for others.

Jaco

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#14 lore raw
Quoted 6 lines · Jaco Kroon
Quoted 3 lines

Compiling USB 1.1 support does the very same thing as specifying usb-handoff on the command like - tells the BIOS to keep its hands off the USB _and_ PS/2 controllers.

I'm missing something, I have USB1.1 compiled in, then why does the touchpad not work if it does the very same thing as usb-handoff?

USB initializes very late, after i8042 and psmouse has already run their probes. So unless there is "usb-handoff" psmouse talks to a fake BIOS-emulated mouse, not a real touchpad.

Signature · 1 line
Dmitry
#15 lore raw
In reply to Vojtech Pavlik
Quoted 44 lines · Vojtech Pavlik
Quoted 21 lines · Jaco Kroon
Quoted 19 lines · Vojtech Pavlik
Quoted 6 lines · Andries Brouwer
Quoted 1 line

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

Hmm - I just answered the same post and concluded that I didnt understand, so you have progressed further. I considered the same possibility, but the data was not lost since we read it again later.
Only the ready flag was lost.

What I believe is happening is that we're talking to SMM emulation of the i8042, which doesn't have a clue about these commands, while the underlying real hardware implementation does. And because of that they disagree on what should happen when the command is issued, and since the SMM emulation lazily synchronizes with the real HW, we only get the data back with the next command.

Quoted 6 lines
Quoted 4 lines

I still don't have an explanation why both 'usb-handoff' and 'acpi=off' help, I'd expect only the first to, but it might be related to the SCI interrupt routing which isn't done when 'acpi=off'. Just a wild guess.

Ok, I'm not too clued up with recent hardware and the BIOS programming that goes with it (being a system admin/application programmer), what exactly is usb-handoff?

usb-handoff is a kernel option that enables a PCI quirk routine that takes the USB controller out of BIOS's hands. Until that is done (the linux USB drivers also do it, only later), the BIOS owns the USB controller and tries to emulate a PS/2 mouse and keyboard for systems which can't handle USB.

Quoted 1 line

acpi=off obviously just turns all acpi support in the kernel off.

Indeed.

Quoted 6 lines
Quoted 1 line

SCI is also a new abbreviation I haven't seen before.

System Configuration Interrupt. In addition to SMI (System Management Interrupt), these are two interrupts the BIOS uses to do its job behind the operating system's back.

ACPI 2.0 spec says:
System Control Interrupt (SCI)
A system interrupt used by hardware to notify the OS of ACPI events. The SCI is an active, low, shareable, level interrupt.

Signature · 1 line
~Randy
author
#16 lore raw
In reply to Linus Torvalds
Quoted 7 lines · Linus Torvalds
Quoted 1 line · Jaco Kroon

Which indicates (as far as my understanding goes) that the command times out, as such the param value stays the same (ready for re-use in the second command). The second commands succeeds but does not return one of the expected (0x00, 0xff, 0xfa) values, instead it returns the value as expected by the first command (0xa5). The last value on both lines is the return value. From the second snippet:

No, I think the 0x5a you see is the 0x5a that is _still_ there, because we never got any reply at all from the i8042_command(I8042_CMD_AUX_LOOP) case, nor did the I8042_CMD_AUX_TEST thing do anything at all.

I suspect I didn't explain clearly. Note that the outer test expects a 0xa5 (we pass 0x5a in). That is what made me suspect that the second request gets the first ones return value.

Quoted 2 lines

I have a suspicion: these commands are also one of the few ones that write a data byte to the data port immediately after writing the command byte to the status port.

Yes. The commands that write something is:

CTL_WCTR
KBD_LOOP (I quess this is what breaks if no USB1.1 present in kernel) AUX_SEND (obviously)
AUX_LOOP (the one that we think is breaking)
MIX_SEND (obviously).

All of them send exactly one byte.

Quoted 5 lines

It so happens that if the hardware is slow to reach to the command byte,
we might read the status word _before_ the hardware has had time to even
say "ok, my input port is now full". We have a "udelay()" there in
i8042_wait_write(), but we have it _after_ we've done the i8042_read_status(), so effectively the i8042_read_status() happens immediately after the i8042_write_command().

Hmm, just an idea, shouldn't the i8042_write_command be waiting until the device has asserted the pin to indicate that the buffer is busy? Ie, some nice and tight loop. This has the downside that if we check _just before_ the pin gets asserted, then delay and check again _after_ it has been cleared we will deadlock. So the udelay() before the loop (or rewriting the loop to do{}while(...)) is probably a better solution, although this will cause us to _always_ wait at least 50 microseconds (not that that is a long time).

Quoted 1 line

So what _might_ happen is that we write the command, and then i8042_wait_write() thinks that there is space to write the data immediately, and writes the data, but now the data got lost because the buffer was busy.

This makes a lot of sense.

Quoted 4 lines

The IO delay should be _before_ the read of the status, not after it.

So how about adding an extra "udelay(50)" to either the top of i8042_wait_write(), or to the bottom of "i8042_write_command()"? Does that make any difference?

No. No difference, still the same result.

Quoted 5 lines

(50 usec is probably overkill, and an alternative is to just make the write_data/write_command inline functions in i8042-io.h use the "inb_p/outb_p" versions that put a serializing IO instruction in between, which should give you a nice 1us delay even on modern hardware.)

ok, how would I try this? Where can I find an example to code it from?
Sorry, I should probably be grepping ...

Jaco

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#17 lore raw
Quoted 3 lines · Jaco Kroon

Hmm, just an idea, shouldn't the i8042_write_command be waiting until the device has asserted the pin to indicate that the buffer is busy?

No. Because then you might end up waiting forever for the _opposite_ reason, namely that the hardware was so fast that you never saw it busy.

Quoted 7 lines
Quoted 5 lines

The IO delay should be _before_ the read of the status, not after it.

So how about adding an extra "udelay(50)" to either the top of i8042_wait_write(), or to the bottom of "i8042_write_command()"? Does that make any difference?

No. No difference, still the same result.

Oh, well. It was such a good theory, especially as it works fine with ACPI off (if I understood your report correctly), so some other state is what seems to bring it on.

Quoted 7 lines
Quoted 4 lines

(50 usec is probably overkill, and an alternative is to just make the write_data/write_command inline functions in i8042-io.h use the "inb_p/outb_p" versions that put a serializing IO instruction in between, which should give you a nice 1us delay even on modern hardware.)

ok, how would I try this? Where can I find an example to code it from?
Sorry, I should probably be grepping ...

If the udelay() didn't work, then this one isn't worth worryign about either. Back to the drawing board.

Linus

author
#18 lore raw
Quoted 6 lines · Linus Torvalds
Quoted 1 line · Jaco Kroon

Hmm, just an idea, shouldn't the i8042_write_command be waiting until the device has asserted the pin to indicate that the buffer is busy?

No. Because then you might end up waiting forever for the _opposite_ reason, namely that the hardware was so fast that you never saw it busy.

I've tried it anyway:
static inline void i8042_write_command(int val)

{
    outb(val, I8042_COMMAND_REG);
    while(~i8042_read_status() & I8042_STR_IBF);
}

This to me just gives surety that we don't miss that asserted signal, but a udelay() before the test would do exactly the same thing. And yes, your argument for the lockup is very, very valid.

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

The IO delay should be _before_ the read of the status, not after it.

So how about adding an extra "udelay(50)" to either the top of i8042_wait_write(), or to the bottom of "i8042_write_command()"? Does that make any difference?

No. No difference, still the same result.

Oh, well. It was such a good theory, especially as it works fine with ACPI off (if I understood your report correctly), so some other state is what seems to bring it on.

Yes. You understand correctly. Booting with acpi=off though has deadly implications when rebooting though (bios gives you the black screen of void). So I would like to keep booting with acpi=off down to an absolute minimum.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

(50 usec is probably overkill, and an alternative is to just make the write_data/write_command inline functions in i8042-io.h use the "inb_p/outb_p" versions that put a serializing IO instruction in between, which should give you a nice 1us delay even on modern hardware.)

ok, how would I try this? Where can I find an example to code it from?
Sorry, I should probably be grepping ...

If the udelay() didn't work, then this one isn't worth worryign about either. Back to the drawing board.

Yea. But for interrests sake, what do you mean with a serializing IO instruction?

I also tried increasing the total timeout value to about 5 seconds (versus the default half second), still no success, so the device is simply not sending back the requested values.

I still stand with the theory that it is sending back the value we want for the first request on the second one (managed to get this one by explicitly turning i8042_debug on and off in the code):

i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [4] drivers/input/serio/i8042.c: 47 <- i8042 (return) [4] drivers/input/serio/i8042.c: 60 -> i8042 (command) [5] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [5] i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [9] i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [13] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [13]
drivers/input/serio/i8042.c: -- i8042 (timeout) [875]
i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1 drivers/input/serio/i8042.c: a9 -> i8042 (command) [879] drivers/input/serio/i8042.c: a5 <- i8042 (return) [879]
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

I've rebooted a couple of times and that interrupt is in exactly the same place every time. And int 12 is indeed the AUX device, could this be a clue? Ok, with acpi=off and i8042.debug=1 I get:

i8042_init()
i8042: ACPI detection disabled i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [0] drivers/input/serio/i8042.c: 47 <- i8042 (return) [0] drivers/input/serio/i8042.c: 60 -> i8042 (command) [1] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [1] i8042_check_aux()
i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [1] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [1] drivers/input/serio/i8042.c: a5 <- i8042 (return) [1]
i8042_check_aux: passed

At which point it makes no further sense to dump stuff out as with acpi=on this has already failed.

Note that we are sending in 0x5a and expecting back 0xa5, which is exactly what we get back from the second request. Also note that without ACPI we get the right value back first time round. ACPI imho is doing something wrong (or the test needs to change due to ACPI). Since it only breaks (to the best of my knowledge) on Toshiba Satellite P10-??? notebooks this seems to be a bug in the BIOS more likely.

Right, the message about ACPI detection being disabled can be tracked to i8042_x86ia64io.h, specifically i8042_acpi_init(). This function performs two acpi_bus_register_driver calls (Not sure what different return values means, suspect <0 == error, >=0 implies success but somehow reflect the number of devices detected since -ENODEV is returned should the call return 0?).

Here is however an oddity, in the case where the i8042_acpi_kbd_driver registration returns 0 the driver promptly gets unregistered, this is not the case for i8042_acpi_aux_driver. I don't think this has anything to do with our problem though.

Would it be helpfull to dump the entire i8042_read_status() value at various points?

Jaco

Signature · 3 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#19 lore raw
Quoted 7 lines · Jaco Kroon
Quoted 5 lines
Quoted 3 lines

ok, how would I try this? Where can I find an example to code it from?
Sorry, I should probably be grepping ...

If the udelay() didn't work, then this one isn't worth worryign about either. Back to the drawing board.

Yea. But for interrests sake, what do you mean with a serializing IO instruction?

If you use "outb_p()" instead of an "outb()", the regular IO instruction will be followed by another out to another port on the motherboard: that will not only cause a delay, it should also force at least the host bridge to have no outstanding posted writes (the host bridge shouldn't post IO port writes anyway, but hey, it won't hurt to try to make even more sure of that).

Quoted 3 lines

I also tried increasing the total timeout value to about 5 seconds (versus the default half second), still no success, so the device is simply not sending back the requested values.

If it was the other way around (that it works with ACPI _on_), I'd assume that ACPI just disables some broken BIOS SMM emulation code. But I just don't see ACPI _enabling_ SMM emulation. That would be just too strange, and against the whole point of the legacy keyboard emulation stuff - you want to do legacy keyboard emulation if the OS is old, not if it's new.

It may be that ACPI ends up enabling some silly power control SMM sequence that wakes up on keyboard accesses, and screws up the emulation. That sounds pretty strange too, I have to say - even if SMM/ACPI would like to trap keyboard command sequences, I'd have expected it to just pass them through after looking at them.

One option may be that SMM/ACPI traps the _received_ characters, and incorrectly eats the reply, because it thinks it's some special key sequence (and should cause SMM/ACPI to make the screen brighter or something silly like that).

Does anybody know/remember what the keycode 0xA5 means?

Quoted 24 lines

I still stand with the theory that it is sending back the value we want for the first request on the second one (managed to get this one by explicitly turning i8042_debug on and off in the code):

i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [4] drivers/input/serio/i8042.c: 47 <- i8042 (return) [4] drivers/input/serio/i8042.c: 60 -> i8042 (command) [5] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [5] i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [9] i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [13] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [13]
drivers/input/serio/i8042.c: -- i8042 (timeout) [875]
i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1 drivers/input/serio/i8042.c: a9 -> i8042 (command) [879] drivers/input/serio/i8042.c: a5 <- i8042 (return) [879]
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

Quoted 3 lines

I've rebooted a couple of times and that interrupt is in exactly the same place every time. And int 12 is indeed the AUX device, could this be a clue?

Does it change if you change the initial value of "param" (0x5a) to something else?

Linus

#20 lore raw
Quoted 9 lines · Linus Torvalds
Quoted 3 lines

I also tried increasing the total timeout value to about 5 seconds (versus the default half second), still no success, so the device is simply not sending back the requested values.

If it was the other way around (that it works with ACPI _on_), I'd assume that ACPI just disables some broken BIOS SMM emulation code. But I just don't see ACPI _enabling_ SMM emulation. That would be just too strange, and against the whole point of the legacy keyboard emulation stuff - you want to do legacy keyboard emulation if the OS is old, not if it's new.

It is my understanding that ACPI and legacy emulation are to a certain degree tangent to each other. You can work in ACPI mode and still use USB legacy emulation and you could be in legacy mode but with USB loaded and USB legacy emulation turned off.

Signature · 1 line
Dmitry
author
#21 lore raw
In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 6 lines · Jaco Kroon
Quoted 5 lines
Quoted 2 lines

ok, how would I try this? Where can I find an example to code it from? Sorry, I should probably be grepping ...

If the udelay() didn't work, then this one isn't worth worryign about either. Back to the drawing board.

Quoted 8 lines
Quoted 2 lines

Yea. But for interrests sake, what do you mean with a serializing IO instruction?

If you use "outb_p()" instead of an "outb()", the regular IO instruction will be followed by another out to another port on the motherboard: that will not only cause a delay, it should also force at least the host bridge to have no outstanding posted writes (the host bridge shouldn't post IO port writes anyway, but hey, it won't hurt to try to make even more sure of that).

No go. Does not help at all. Very nifty idea to force another character through the bus to cause a delay though.

Quoted 10 lines
Quoted 3 lines

I also tried increasing the total timeout value to about 5 seconds (versus the default half second), still no success, so the device is simply not sending back the requested values.

If it was the other way around (that it works with ACPI _on_), I'd assume that ACPI just disables some broken BIOS SMM emulation code. But I just don't see ACPI _enabling_ SMM emulation. That would be just too strange, and against the whole point of the legacy keyboard emulation stuff - you want to do legacy keyboard emulation if the OS is old, not if it's new.

I don't see this notebook running any non-ACPI enabled OS. It would just be too broken (consider the black screen of void if one boots with acpi=off). Some very old legacy OSs would not even have USB1.1 support which will kill the keyboard.

Quoted 6 lines

It may be that ACPI ends up enabling some silly power control SMM sequence that wakes up on keyboard accesses, and screws up the emulation. That sounds pretty strange too, I have to say - even if SMM/ACPI would like to trap keyboard command sequences, I'd have expected it to just pass them through after looking at them.

Why? If it is going to make the screen dimmer/brighter after pressing the keys - what is the use of passing them through to the OS? After all, the user has already seen the "effect" these keys caused and giving them to the OS to do something else with will end up being counter intuitive to the user.

Quoted 5 lines

One option may be that SMM/ACPI traps the _received_ characters, and incorrectly eats the reply, because it thinks it's some special key sequence (and should cause SMM/ACPI to make the screen brighter or something silly like that).

Interresting idea. The Fn+F6/F7 keys does indeed make the screen brighter and dimmer, and afaik these gets trapped by SMM/ACPI in the BIOS and never even gets to Linux.

Quoted 26 lines

Does anybody know/remember what the keycode 0xA5 means?

Quoted 24 lines

I still stand with the theory that it is sending back the value we want for the first request on the second one (managed to get this one by explicitly turning i8042_debug on and off in the code):

i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [4] drivers/input/serio/i8042.c: 47 <- i8042 (return) [4] drivers/input/serio/i8042.c: 60 -> i8042 (command) [5] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [5] i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [9] i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [13] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [13]
drivers/input/serio/i8042.c: -- i8042 (timeout) [875]
i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1 drivers/input/serio/i8042.c: a9 -> i8042 (command) [879] drivers/input/serio/i8042.c: a5 <- i8042 (return) [879]
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

Quoted 6 lines
Quoted 3 lines

I've rebooted a couple of times and that interrupt is in exactly the same place every time. And int 12 is indeed the AUX device, could this be a clue?

Does it change if you change the initial value of "param" (0x5a) to something else?

I've changed the initial input to 0xbb and the output from the second command changed to 0x44. So it does indeed look like my theory might be workable. Just a thought, the acpi_driver i8042_acpi_aux_driver struct has an .add option, that gets called when ACPI detects the AUX device. ic8042_acpi_aux_add() gets called *before* we attempt initialisation/detectiong of the device. Shouln't this be sufficient to say yes, there is such a device, this is it's port and irq numbers? As such, do we still need to go through the AUX_LOOP and AUX_TEST process to determine whether the device is installed or not? On the other hand, why would asking ACPI what the correct interrupt is break it?

In i8042_platform_init() (i8042-x86ia64io.h) there is a commented request_region() statement. Would this make a difference, and also, from the comment it would make sense to reserve that region, so why is it commented out in the first place?

Jaco

Signature · 8 lines
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/

-- 
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/
#22 lore raw
In reply to Linus Torvalds
Quoted 32 lines · Linus Torvalds
Quoted 7 lines · Jaco Kroon
Quoted 5 lines
Quoted 3 lines

ok, how would I try this? Where can I find an example to code it from?
Sorry, I should probably be grepping ...

If the udelay() didn't work, then this one isn't worth worryign about either. Back to the drawing board.

Yea. But for interrests sake, what do you mean with a serializing IO instruction?

If you use "outb_p()" instead of an "outb()", the regular IO instruction will be followed by another out to another port on the motherboard: that will not only cause a delay, it should also force at least the host bridge to have no outstanding posted writes (the host bridge shouldn't post IO port writes anyway, but hey, it won't hurt to try to make even more sure of that).

Quoted 3 lines

I also tried increasing the total timeout value to about 5 seconds (versus the default half second), still no success, so the device is simply not sending back the requested values.

If it was the other way around (that it works with ACPI _on_), I'd assume that ACPI just disables some broken BIOS SMM emulation code. But I just don't see ACPI _enabling_ SMM emulation. That would be just too strange, and against the whole point of the legacy keyboard emulation stuff - you want to do legacy keyboard emulation if the OS is old, not if it's new.

It may be that ACPI ends up enabling some silly power control SMM sequence that wakes up on keyboard accesses, and screws up the emulation. That sounds pretty strange too, I have to say - even if SMM/ACPI would like to trap keyboard command sequences, I'd have expected it to just pass them through after looking at them.

Quoted 6 lines

One option may be that SMM/ACPI traps the _received_ characters, and incorrectly eats the reply, because it thinks it's some special key sequence (and should cause SMM/ACPI to make the screen brighter or something silly like that).

Does anybody know/remember what the keycode 0xA5 means?

So far , the only place I can find a 0xA5 is under the PS/2 Keyboard numbers and scan codes.
KeyNumber Set 1 Make/Break Set 2 Make/Break Set 3 Make/Break Base Case Uppercase
38 25/A5 42/F0 42 42/F0 42 k K

I am not familiar with how PS/2 uses it scan code. Unlike the AT it only have one Scan code to a Key Number.

Quoted 39 lines
Quoted 26 lines

I still stand with the theory that it is sending back the value we want for the first request on the second one (managed to get this one by explicitly turning i8042_debug on and off in the code):

i8042_init()
ACPI: PS/2 Keyboard Controller [KBC0] at I/O 0x60, 0x64, irq 1
ACPI: PS/2 Mouse Controller [MSE0] at irq 12 i8042_controller_init()
i8042_flush()
drivers/input/serio/i8042.c: 20 -> i8042 (command) [4] drivers/input/serio/i8042.c: 47 <- i8042 (return) [4] drivers/input/serio/i8042.c: 60 -> i8042 (command) [5] drivers/input/serio/i8042.c: 56 -> i8042 (parameter) [5] i8042_check_aux()
drivers/input/serio/i8042.c: Interrupt 12, without any data [9] i8042_flush()
drivers/input/serio/i8042.c: d3 -> i8042 (command) [13] drivers/input/serio/i8042.c: 5a -> i8042 (parameter) [13]
drivers/input/serio/i8042.c: -- i8042 (timeout) [875]
i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1 drivers/input/serio/i8042.c: a9 -> i8042 (command) [879] drivers/input/serio/i8042.c: a5 <- i8042 (return) [879]
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

Quoted 3 lines

I've rebooted a couple of times and that interrupt is in exactly the same place every time. And int 12 is indeed the AUX device, could this be a clue?

Does it change if you change the initial value of "param" (0x5a) to something else?

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#23 lore raw
In reply to Jaco Kroon
Quoted 4 lines · Jaco Kroon

Yes. You understand correctly. Booting with acpi=off though has deadly implications when rebooting though (bios gives you the black screen of void). So I would like to keep booting with acpi=off down to an absolute minimum.

Did you ever try using "acpi=off" together with "i8042.nomux=1"? That could help with the rebooting problem (iirc, you had a multiplexing controller, didn't you?). Also, if you could try whether "usb-handoff" instead of "acpi-off" has the same effect, like it has for Sebastian, that'd be a good data point, too.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#24 lore raw
In reply to Jaco Kroon
Quoted 2 lines · Jaco Kroon

i8042_check_aux: param_in=0x5a, command=AUX_LOOP, param_out=5a <= -1
i8042_check_aux: param_in=??, command=AUX_TEST, param_out=a5 <= 0

The code is

        param = 0x5a;
        if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xa5) {
                if (i8042_command(&param, I8042_CMD_AUX_TEST)
                        || (param && param != 0xfa && param != 0xff))
                                return -1;
        }

where
#define I8042_CMD_AUX_LOOP 0x11d3: write d3, write 5a, read ->param #define I8042_CMD_AUX_TEST 0x01a9: write a9, read ->param

In my docs (http://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#ss10.3)
d3 is classified under "Obscure, probably obsolete, commands". The reason is that there is hardware that does not implement d3. Originally it was special to MCA. Later it was also used as part of the Synaptics multiplexing handshake.

Now you read one byte after the command a9 and get a5 - clearly the 5a that was written and complemented. So it looks like the d3 really worked.

The first i8042_command() returned -1, but it really wrote the 5a, so it did i8042_write_command(d3) and i8042_write_data(5a) and then the i8042_wait_read() returned -1, a timeout.

Since the byte was there to read, the flag was lost that indicated that data was available. Hmm. Sequence of actions:

	inb(64);	// until bit 1 clear
	outb(d3, 64);
	inb(64);	// until bit 1 clear
	outb(5a, 60);
	inb(64);	// until bit 0 set - timeout

	inb(64);	// until bit 1 clear
	outb(a9, 64);
	inb(64);	// until bit 0 set
	inb(64);	// test for AUX
	inb(60);

I am afraid I don't understand what happens.
One can imagine that the second inb(64) comes too quickly
so that we write the 5a too quickly. But all happens as it
should: the d3 is executed, the 5a is moved from input buffer to output buffer, the AUXB bit is set, only the ready flag never comes, not within I8042_CTL_TIMEOUT=10000 times 50 usec, that is 0.5 sec.

By the way, I have some old docs that describe sending a command by
repeat inb(64) until bit 1 clear
outb(cmd, 64)
repeat inb(64) until bit 1 set
and we only do the first half.

Andries