RE: [PATCH]: xHCI/EHCI - Windows - BIOS bug interaction.

2014-01-03 Thread Melki Christian (consultant)
Aleš,

Sorry for the late reply. Holliday vaccation. :)

> Hi Christian,
> 
> I think - generally, if OS is able to work with this Intel chipset, then
> it should handle change of XUSB2PR and USB3_PSSEN registers state during
> reboot (or sleep/resume).
> In opposite case, when OS is not able to work with this chipset, then OS
> will not touch these registers - and routing to EHCI is the default
> state, so no problem should happen.

Yes. I think this is the case with Windows if Intel drivers are used.
Otherwise I think generic Microsoft xHCI drivers are used, and they don't know 
anything about Intel specific bugs.

> 
> But I am little bit confused:
> 
> I searched XUSB2PR and USB3_PSSEN PCI registers in official xHCI
> specification "eXtensible Host Controller Interafce for Universal Serial
> Bus (xHCI)", Revision 1.0, 5/21/10 (downloaded from www.intel.com) - and
> I didn't find them.
> Additionally, as far as I understood xHCI specification, xHCI concept is
> to avoid such port switching (similar to EHCI ports switching to
> companion OHCI/UHCI controllers).

Maybe I did not clarify my late findings properly.
This is not a xHCI spec problem, but rather an Intel PantherPoint chipset 
problem.

 > Then I tried to find datasheet of Intel pantherpoint chipset - and I
> found document "Intel 7 Series / C216 Chipset Family Platform Controller
> Hub (PCH)", June 2012. And this document includes description of XUSB2PR
> and USB3_PSSEN PCI registers.

Ah, yes. Correct. :)

> So:
> Are these PCI registers some only Intel-specific special "non-official"
> extension? (It looks like that - according to comments in Linux kernel
> source.)
> Or are them some new "official" xHCI add-on mentioned in some newer
> version of xHCI specification, unknown for us yet?
> How can I distinguish if xHCI contains these (possibly non-official -
> but very important) special PCI registers or not? Only by Vendor/Device
> IDs? Or is there some system, e.g. similar to PCI Capabilities etc?

These registers are Intel Pantherpoint specific as far as I understand. By 
deviceid only.

I did this before you sent your patch last time. It includes the Panterpoint 
chipset id.
(local changes only). They still fit better in a separate quirk or xhci-driver 
module as you suggested.

Index: grub-core/bus/usb/ehci.c
===
--- grub-core/bus/usb/ehci.c(revision 6012)
+++ grub-core/bus/usb/ehci.c(revision 6013)
@@ -41,6 +41,9 @@
  */

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

 /* Capability registers offsets */
 enum
@@ -458,6 +461,41 @@
   return GRUB_USB_ERR_NONE;
 }

+static int
+grub_xhci_quirk_fix (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+  grub_uint32_t class_code;
+  grub_uint32_t interf;
+  grub_uint32_t subclass;
+  grub_uint32_t class;
+  grub_pci_address_t addr;
+
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+  class_code = grub_pci_read (addr) >> 8;
+  interf = class_code & 0xFF;
+  subclass = (class_code >> 8) & 0xFF;
+  class = class_code >> 16;
+
+  /* This is an Intel Pantherpoint xHCI controller.
+   * Quirk fix to put all ports in 2.0 mode.
+   * To be removed when xHCI is properly introduced.
+   */
+  if (class == 0x0c && subclass == 0x03 && interf == 0x30 &&
+  pciid == GRUB_XHCI_INTEL_PPT_PCIID)
+{
+  grub_dprintf("ehci", "Intel PPT, applying quirk fix.\n");
+  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);
+}
+
+  return 0;
+}
+
 /* PCI iteration function... */
 static int
 grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
@@ -1844,6 +1882,12 @@
   grub_pci_iterate (grub_ehci_pci_iter, NULL);
 }

+static void
+grub_xhci_quirk (void)
+{
+  grub_pci_iterate (grub_xhci_quirk_fix, NULL);
+}
+
 static grub_err_t
 grub_ehci_restore_hw (void)
 {
@@ -1967,6 +2011,7 @@
   COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_qh) == 96);

   grub_boot_time ("Initing EHCI hardware");
+  grub_xhci_quirk ();
   grub_ehci_inithw ();
   grub_boot_time ("Registering EHCI driver");
   grub_usb_controller_dev_register (&usb_controller);

> Answers of these questions will be important in case when we will try to
> support xHCI in GRUB.

At first I too thought that these vere more xHCI specific than they were.
I have reduced this problem to "nice to have" from by behalf rather than
"must have bugfix".
I think this will only appear on this Intel chipset, possibly BIOS bug(?) 
selected OS (Win7+) without Intel specific xHCI driver...
Not so many users are likely to get bitten by this.

regards && late season greetings. :)
Christian

>

Re: [PATCH] Add apple_set_os command

2014-01-03 Thread SevenBits
On Friday, January 3, 2014, Vladimir 'φ-coder/phcoder' Serbinenko wrote:

> On 31.12.2013 00:11, SevenBits wrote:
> > On Monday, December 30, 2013, Andreas Heider wrote:
> >
> > The EFI on current macbooks configures hardware differently depending
> > on wether it is booting Mac OS X or a different os, for example
> > disabling the internal GPU completely on some models.
> >
> > Mac OS X identifies itself using a custom EFI protocol.
> >
> > This adds a command that fakes the os identification, making all
> > hardware accessible.
> >
> >
> > Just a question: I do a lot of booting Linux on MacBooks, and I
> > frequently suffer from this issue. How do we know that this code
> > actually works?
> Run on a mac with this code and without and compare results. The ship of
> "works by sane design" has long since sailed away. For most
> manufacturers it's somewhere in Moon orbit but for apple it has long
> since left solar system.


Believe me, I'm done quite a bit of work with Apple's EFI and it is
certainly a pain in the neck once you start digging underneath the surface
and doing anything more than really basic stuff. Some MacBooks for instance
are still running EFI 1.x while some newer ones implement 2.x... It's quite
a disaster considering those older machines are still in use.

I'll give the patch a try. Hopefully it will work. I'm personally fearful
that it won't make any difference, but you never know. I love Apple
products, I think they're great stuff, but the EFI implementation can drive
you crazy and OS X boots in a roundabout way, which gives Linux fans like
myself headaches when we try to boot Linux on the machines.

Anyway, I'll give it a go and report what I find.
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Add apple_set_os command

2014-01-03 Thread SevenBits
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/03/2014 01:46 AM, Vladimir '?-coder/phcoder' Serbinenko wrote:
> On 31.12.2013 00:11, SevenBits wrote:
>> On Monday, December 30, 2013, Andreas Heider wrote:
>> 
>> The EFI on current macbooks configures hardware differently
>> depending on wether it is booting Mac OS X or a different os, for
>> example disabling the internal GPU completely on some models.
>> 
>> Mac OS X identifies itself using a custom EFI protocol.
>> 
>> This adds a command that fakes the os identification, making all 
>> hardware accessible.
>> 
>> 
>> Just a question: I do a lot of booting Linux on MacBooks, and I 
>> frequently suffer from this issue. How do we know that this code 
>> actually works?
> Run on a mac with this code and without and compare results. The
> ship of "works by sane design" has long since sailed away. For
> most manufacturers it's somewhere in Moon orbit but for apple it
> has long since left solar system.
So, Andreas, I tried your patch, and... no dice. The Mac behaves
exactly as before. I'm afraid it didn't appear to do anything for me.

Furthermore, your patch didn't print any output. There wasn't any
error message returned (i.e your "Could not locate the apple set os
protocol." message on line 52-53). When I invoked your command from
the GRUB normal prompt, it DID print the message however. Perhaps it
doesn't fail if called from within a grub.cfg, or maybe it simply
doesn't print.

The Mac that I tested on was a MacBook Pro from early 2008. Clearly,
this function isn't present on all models. I can try it on others and
seeing if it works on them, however.

Also, why the if statements on lines 59 and 65, which indicate whether
the OS version and/or vendor was set. What is the point of them? Why
not just call the functions directly?
> 
> 
> 
> ___ Grub-devel mailing
> list Grub-devel@gnu.org 
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSxwOMAAoJEFbRvtGxmFPELWoH+QGu7aLuDam0vY+xW8h4TdFw
ckY51K8vgEGlpUNvK2fwQnnAt57W3jH14HBIRY1IaC+c9XA3mooqp748xh0jfoV/
D95lZJuYu3XP4iFYtCehcCVOiz+x4DNXMnT6WA6hd5FjPT9xqbBqf/9RxSpN9O+i
ZGbSe/ZQkOvTyLXJ11L3SeTlNi9jqA03mLaMrMi7Ehb7AU3hBkiSMpiiIcUjnP3o
ZskQrSkguqt9Kt+FlHheTJkpAitqqJR/GpHkegg3bNGLrflacVGITMFFw0EsJP4R
h0fsEocfYnvSVPrw07SJVFvt2TzPGB69p5QXy11cU1ZBYUhILcG7rDTAmVctZig=
=wKye
-END PGP SIGNATURE-

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel