Skip to contentSkip to conversation

Hang on new mac laptops

Bugfix phcoder 4 participants 11 messages Feb 3, 2009 – Mar 11, 2009

lore
Share & tools
lore

phcoder

author
#0 lore raw

Hello. On new mac laptops waiting for keyboard event causes random hangs. Bugfix attached Thanks
Vladimir 'phcoder' Serbinenko

ChangeLog +7 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,10 @@
+2009-02-03  Vladimir Serbinenko <[email protected]>
+
+	Don't rely on event for keyboard on EFI. It causes random hangs
+	Great thanks to Florian Idelberger for testing and helping finding this bug
+
+	* term/efi/console.c: Replace wait for event with grub_millisleep (10)
+	
 2009-02-01  Felix Zielcke  <[email protected]>
 
 	* INSTALL: Note that we now require at least autconf 2.59 and that LZO
efi/console.c +3 -2
Index: term/efi/console.c
===================================================================
@@ -226,9 +226,10 @@
 
   do
     {
-      status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key), &index);
+      /*      status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key), &index);
       if (status != GRUB_EFI_SUCCESS)
-        return -1;
+        return -1;*/
+      grub_millisleep (10);
 
       grub_console_checkkey ();
     }
#1 lore raw

efi/console.c line 232

Quoted 8 lines · phcoder

- status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key),
&index);
+ /* status = efi_call_3 (b->wait_for_event, 1,

&(i->wait_for_key), &index);
        if (status != GRUB_EFI_SUCCESS)
efi/console.c +2 -1
-        return -1;
+        return -1;*/
+      grub_millisleep (10);

Please don't leave commented out code. If you want a comment to be there, you can write something. If you want to preserve the file history, Subversion does it already.

Signature · 2 lines
Regards,
Pavel Roskin
author
#2 lore raw

Fixed

Quoted 10 lines · Pavel Roskin

Review

Quoted 8 lines · phcoder

- status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key),
&index);
+ /* status = efi_call_3 (b->wait_for_event, 1,

&(i->wait_for_key), &index);
        if (status != GRUB_EFI_SUCCESS)
(quoted diff) +2 -1
-        return -1;
+        return -1;*/
+      grub_millisleep (10);
Quoted 4 lines

Please don't leave commented out code. If you want a comment to be there, you can write something. If you want to preserve the file history, Subversion does it already.

ChangeLog +7 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,10 @@
+2009-02-04  Vladimir Serbinenko <[email protected]>
+
+	Don't rely on event for keyboard on EFI. It causes random hangs
+	Great thanks to Florian Idelberger for testing and helping finding this bug 
+
+	* term/efi/console.c: Replace wait for event with grub_millisleep (10)
+	
 2009-02-01  Felix Zielcke  <[email protected]>
 
 	* INSTALL: Note that we now require at least autconf 2.59 and that LZO
efi/console.c +3 -3
Index: term/efi/console.c
===================================================================
@@ -226,9 +226,9 @@
 
   do
     {
-      status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key), &index);
-      if (status != GRUB_EFI_SUCCESS)
-        return -1;
+      /* Don't use wait_for_event it's known 
+	 to cause hangs on some mac models */
+      grub_millisleep (10);
       
       grub_console_checkkey ();
     }
#3 lore raw

efi/console.c line 231

Quoted 6 lines · phcoder
efi/console.c +3 -3
-      status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key), &index);
-      if (status != GRUB_EFI_SUCCESS)
-        return -1;
+      /* Don't use wait_for_event it's known 
+	 to cause hangs on some mac models */
+      grub_millisleep (10);

I'm fine with the workaround, but please could you check if at_keyboard.mod works there? It's not the first time we have trouble due to buggy keyboard drivers, I'd be very happy if we could avoid more of the same.

insmod at_keyboard
terminal_input at_keyboard

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw

I made an *.efi with a few modules (for convenience and cause the minimal build somehow didn't want to load anything, but that could have been me) Then I loaded at_keyboard with "insmod at_keyboard" that worked. Then when I do "terminal_input at_keyboard" it doesn't give me a new prompt and seems to "hang".
How to further debug this? What is expected behaviour?

Quoted 29 lines · Robert Millan
Quoted 1 line · phcoder

- status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key),

&index);

efi/console.c line 231

Quoted 5 lines
efi/console.c +3 -2
-      if (status != GRUB_EFI_SUCCESS)
-        return -1;
+      /* Don't use wait_for_event it's known
+      to cause hangs on some mac models */
+      grub_millisleep (10);

I'm fine with the workaround, but please could you check if at_keyboard.mod works there? It's not the first time we have trouble due to buggy keyboard drivers, I'd be very happy if we could avoid more of the same.

insmod at_keyboard
terminal_input at_keyboard

--
Robert Millan

The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
Quoted 6 lines · On Sun, Feb 08, 2009 at 06:02:27PM +0100, step21 wrote:

I made an *.efi with a few modules (for convenience and cause the minimal build somehow didn't want to load anything, but that could have been me) Then I loaded at_keyboard with "insmod at_keyboard" that worked. Then when I do "terminal_input at_keyboard" it doesn't give me a new prompt and seems to "hang".
How to further debug this?

Before insmod:

set debug=at_keyboard

and check the output (of both commands)

Quoted 1 line

What is expected behaviour?

Expected behaviour is that your prompt doesn't hang like you described, but lets you continue typing instead.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#6 lore raw

ok makes sense. I did set debug=at_keyboard (before insmod I think) but not output at all.

Quoted 34 lines · Robert Millan
Quoted 3 lines · On Sun, Feb 08, 2009 at 06:02:27PM +0100, step21 wrote:

I made an *.efi with a few modules (for convenience and cause the minimal build somehow didn't want to load anything, but that could have been me) Then I loaded at_keyboard with "insmod at_keyboard" that worked. Then

when I

Quoted 1 line

do "terminal_input at_keyboard" it doesn't give me a new prompt and seems

to

Quoted 2 lines

"hang".
How to further debug this?

Before insmod:

set debug=at_keyboard

and check the output (of both commands)

Quoted 1 line

What is expected behaviour?

Expected behaviour is that your prompt doesn't hang like you described, but lets you continue typing instead.

--
Robert Millan

The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
Quoted 2 lines · On Sun, Feb 08, 2009 at 07:52:39PM +0100, step21 wrote:

ok makes sense. I did set debug=at_keyboard (before insmod I think) but not output at all.

Sorry, it should have been debug=atkeyb.

Also, you need a #define DEBUG_AT_KEYBOARD line as mentioned on IRC.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#8 lore raw

Ok, confirmed that keyboard is attached with usb. lsusb wans't very helpful cause apart from wireless and bluetooth it only mentioned "apple devices" and "linux foundation devices" however os x has a similiar command line tool ioreg which with -p IOUSB can be restricted to usb. Output
http://pastebin.com/m4d3e9c83
I then updated to the usb patch with rev 1985, and compiled etc. debug still seemed to do nothing and as previously terminal_input at_keyboard forces to manually swithc the machine off.

Quoted 21 lines · Robert Millan
Quoted 2 lines · On Sun, Feb 08, 2009 at 07:52:39PM +0100, step21 wrote:

ok makes sense. I did set debug=at_keyboard (before insmod I think) but not output at all.

Sorry, it should have been debug=atkeyb.

Also, you need a #define DEBUG_AT_KEYBOARD line as mentioned on IRC.

--
Robert Millan

The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw
Quoted 8 lines · On Mon, Feb 09, 2009 at 02:46:01AM +0100, step21 wrote:

Ok, confirmed that keyboard is attached with usb. lsusb wans't very helpful cause apart from wireless and bluetooth it only mentioned "apple devices" and "linux foundation devices" however os x has a similiar command line tool ioreg which with -p IOUSB can be restricted to usb. Output
http://pastebin.com/m4d3e9c83
I then updated to the usb patch with rev 1985, and compiled etc. debug still seemed to do nothing and as previously terminal_input at_keyboard forces to manually swithc the machine off.

Use the following:

insmod uhci ; insmod usb_keyboard ; terminal_input usb_keyboard

It is important to use semicolons, since after "insmod uhci" your keyboard will stop working (and hopefully be restored with "terminal_input usb_keyboard")

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
author
#10 lore raw
In reply to phcoder

Hello this issue still persists and unfortunately usb keyboard didn't fix the issue. Perhaps we should commit this as at least temporary solution for the problem?

Quoted 17 lines · phcoder

Fixed

Quoted 14 lines · Pavel Roskin

efi/console.c line 231

Quoted 8 lines · phcoder

- status = efi_call_3 (b->wait_for_event, 1, &(i->wait_for_key),
&index);
+ /* status = efi_call_3 (b->wait_for_event, 1,

&(i->wait_for_key), &index);
        if (status != GRUB_EFI_SUCCESS)
efi/console.c +2 -1
-        return -1;
+        return -1;*/
+      grub_millisleep (10);

Please don't leave commented out code. If you want a comment to be there, you can write something. If you want to preserve the file history, Subversion does it already.

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko