All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: xHCI/EHCI - Windows - BIOS bug interaction.
@ 2013-12-19 10:01 Melki Christian (consultant)
  2013-12-19 11:33 ` Melki Christian (consultant)
  0 siblings, 1 reply; 6+ messages in thread
From: Melki Christian (consultant) @ 2013-12-19 10:01 UTC (permalink / raw)
  To: grub-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2298 bytes --]

Hi.

Request for comments (patch is a local repository patch) so far:

I noticed on some Dell 7010 machines the following behaviour with GRUB.

Machine is cold-booted. - > USB keyboard works in GRUB -> Windows boots -> Windows does warm reboot -> USB keyboard does not work in GRUB.
This only happens in the ports marked superspeed on the machine.
A quick dig into the subject revealed something of interest that Sarah Sharp added to Linux a while ago.
The problem is that Windows seems to leave the the SS ports in SS mode when rebooting and a BIOS bug(?) on warm boot leads to not setting the SS ports in 2.0 mode.
So in the ehci driver I identified the xHCI controller, disabled it and set all ports in 2.0 mode in the port routing register, much like Linux does.
This is a little odd, but I think GRUB needs this because it does not properly handle xHCI yet. GRUB needs to make sure that all ports are available as 2.0 mode ports.
It seems to fix my problems atleast.

Index: grub-core/bus/usb/ehci.c
===================================================================
--- grub-core/bus/usb/ehci.c    (revision 6009)
+++ grub-core/bus/usb/ehci.c    (working copy)
@@ -41,6 +41,8 @@
  */

 #define GRUB_EHCI_PCI_SBRN_REG  0x60
+#define GRUB_XHCI_PCI_XUSB2PR   0xD0
+#define GRUB_XHCI_PCI_USB3_PSSEN 0xD8

 /* Capability registers offsets */
 enum
@@ -507,6 +509,21 @@
       subclass = (class_code >> 8) & 0xFF;
       class = class_code >> 16;

+      /* This is an xHCI controller.
+       * Since GRUB does not currently handle xHCI we need
+       * to make sure it is disabled and the ports put in 2.0 mode.
+       * To be removed when xHCI is properly introduced.
+       */
+      if (class == 0x0c && subclass == 0x03 && interf == 0x30)
+        {
+          addr = grub_pci_make_address (dev, GRUB_XHCI_PCI_USB3_PSSEN);
+          grub_pci_write_word (addr, 0x0);
+          grub_pci_read_word(addr);
+          addr = grub_pci_make_address (dev, GRUB_XHCI_PCI_XUSB2PR);
+          grub_pci_write_word (addr, 0x0);
+          grub_pci_read_word(addr);
+        }
+
       /* If this is not an EHCI controller, just return.  */
       if (class != 0x0c || subclass != 0x03 || interf != 0x20)
        return 0;

Regards,
Christian



[-- Attachment #2: xhcifix.patch --]
[-- Type: application/octet-stream, Size: 2681 bytes --]

Index: grub-core/Makefile.core.def
===================================================================
--- grub-core/Makefile.core.def	(revision 6009)
+++ grub-core/Makefile.core.def	(working copy)
@@ -756,6 +756,17 @@
 };
 
 module = {
+  name = usbtest;
+  common = commands/usbtest.c;
+  enable = usb;
+};
+
+module = {
+  name = videoinfo;
+  common = commands/videoinfo.c;
+};
+
+module = {
   name = scsi;
   common = disk/scsi.c;
 };
Index: grub-core/soe/ee.c
===================================================================
--- grub-core/soe/ee.c	(revision 6009)
+++ grub-core/soe/ee.c	(working copy)
@@ -131,7 +131,7 @@
 static grub_err_t
 ee_test_ee(grub_disk_t disk)
 {
-    char buf[GRUB_DISK_SECTOR_SIZE];
+    char buf[GRUB_DISK_SECTOR_SIZE * 256];
     grub_uint16_t *idw;
     grub_uint16_t security;
 
Index: grub-core/normal/main.c
===================================================================
--- grub-core/normal/main.c	(revision 6009)
+++ grub-core/normal/main.c	(working copy)
@@ -354,15 +354,12 @@
 
 /* This starts the normal mode.  */
 void
-__attribute__((noreturn)) grub_enter_normal_mode (const char *config)
+grub_enter_normal_mode (const char *config)
 {
   grub_boot_time ("Entering normal mode");
   nested_level++;
   grub_normal_execute (config, 0, 0);
 
-  /* We dont want no stinkin' shell */
-  grub_reboot();
-
   grub_boot_time ("Entering shell");
   grub_cmdline_run (0);
   nested_level--;
Index: grub-core/bus/usb/ehci.c
===================================================================
--- grub-core/bus/usb/ehci.c	(revision 6009)
+++ grub-core/bus/usb/ehci.c	(working copy)
@@ -41,6 +41,8 @@
  */
 
 #define GRUB_EHCI_PCI_SBRN_REG  0x60
+#define GRUB_XHCI_PCI_XUSB2PR   0xD0
+#define GRUB_XHCI_PCI_USB3_PSSEN 0xD8
 
 /* Capability registers offsets */
 enum
@@ -507,6 +509,21 @@
       subclass = (class_code >> 8) & 0xFF;
       class = class_code >> 16;
 
+      /* This is an xHCI controller.
+       * Since GRUB does not currently handle xHCI we need
+       * to make sure it is disabled and the ports put in 2.0 mode.
+       * To be removed when xHCI is properly introduced.
+       */
+      if (class == 0x0c && subclass == 0x03 && interf == 0x30) 
+        {
+          addr = grub_pci_make_address (dev, GRUB_XHCI_PCI_USB3_PSSEN);
+          grub_pci_write_word (addr, 0x0);
+          grub_pci_read_word(addr);
+          addr = grub_pci_make_address (dev, GRUB_XHCI_PCI_XUSB2PR);
+          grub_pci_write_word (addr, 0x0);
+          grub_pci_read_word(addr);
+        }
+
       /* If this is not an EHCI controller, just return.  */
       if (class != 0x0c || subclass != 0x03 || interf != 0x20)
 	return 0;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-03  8:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19 10:01 [PATCH]: xHCI/EHCI - Windows - BIOS bug interaction Melki Christian (consultant)
2013-12-19 11:33 ` Melki Christian (consultant)
2013-12-19 20:50   ` Aleš Nesrsta
2013-12-20  7:38     ` Melki Christian (consultant)
2013-12-20 19:45       ` Aleš Nesrsta
2014-01-03  8:44         ` Melki Christian (consultant)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.