grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

USB controller hand-back (original thread: Missing USB devices.)


From: Aleš Nesrsta
Subject: USB controller hand-back (original thread: Missing USB devices.)
Date: Mon, 02 Sep 2013 23:33:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130806 Thunderbird/17.0.8

2.9.2013 09:01, Melki Christian (consultant) wrote:
Exactly.
The EHCI handback is provided by the EHCI spec handover state machine. Problem 
is, most BIOS:es don't implement it, or just screw it up trying.
The scenario is like this:
Load grub2 with EHCI usb.
Grub2 loads windows 7 or something.
Windows 7 goes b0rk and requests input (diskcheck etc).
User only has USB-keyboard.
Eeep, can't enter anything because windows 7 has not loaded usb-stuff yet.

It is surprising for me that Windows does not load USB drivers in such case and the above described situation can happen. I never saw such situation in Linux, but in fact it can probably also happen in some (badly) customized kernels/images etc.

I've played with setting the correct smi-bits and then just flip the OS_OWNED 
flag. This should make the BIOS take over control again. I did it in the 
fini-hook and that function gets run when the loader starts running. Patch 
attach. It is just for toying, not final work or anything. :)
The patch works for some BIOS:es. Most of the time it does nothing to help. 
Some BIOS:es screw it up when trying to reclaim ownership however. :(

Interesting. According to results of your experiments it looks like really black magic... But maybe it is correct even if we will possibly don't like it - see next...

Your patch fits exactly the EHCI specification.
Maybe the patch should include some loop with timeout - waiting for finish of "reverse" handover (or, as you say - hand-back). (And possibly there should be some cosmetic changes related to GRUB coding etc., but don't care yet...)

But, anyway, the patch should work in the case when BIOS is correctly following EHCI specification "OS Ownership State Machine" in reverse direction (OS -> BIOS) together with restarting of legacy USB support. So, there is question for the Vladimir, if GRUB will take care about "hand-back". If yes, something like that should be implemented also into OHCI and UHCI driver.

But, there are at least two questions:
- What happens if BIOS doesn't work correctly during hand-back? Can it freeze/crash PC in some way, make it unstable etc.? Can this situation prevent ownership handover in driver of booted OS? - As I don't know details about BIOSes and SMM etc., I am little bit afraid of one thing: couldn't happen something wrong with loaded OS kernel when BIOS takes ownership of USB controller? I mean e.g. if in the case of hand-back cannot happen some memory collision between BIOS and loaded/booted kernel/image etc.

Additionally, EHCI specification doesn't say that BIOS (SMM) really must implement hand-back and immediately start again legacy support - EHCI specifies only handover mechanism. So, in fact, BIOS which does nothing in the hand-back case is probably correct - at least according to EHCI specification...

If hand-back could be dangerous in some way or could have some unexpected/unwanted behavior in some cases, I expect it will be better to don't implement it (or implement it only as some very special option for experts - but I have no idea in which way...).

What is Vladimir's opinion?

BR,
Ales



reply via email to

[Prev in Thread] Current Thread [Next in Thread]