All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aleš Nesrsta" <starous@volny.cz>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: USB controller hand-back (original thread: Missing USB devices.)
Date: Mon, 02 Sep 2013 23:33:35 +0200	[thread overview]
Message-ID: <5225042F.50906@volny.cz> (raw)
In-Reply-To: <BBCDB0B9B472124D9EED8CB900AA04CA1F91C568@corpappl747.corp.saab.se>

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	other threads:[~2013-09-02 21:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07  8:16 Missing USB devices Melki Christian (consultant)
2013-08-07 16:11 ` Andrey Borzenkov
2013-08-08  7:22   ` Melki Christian (consultant)
2013-08-09 18:27     ` Aleš Nesrsta
2013-08-09 22:24       ` Aleš Nesrsta
2013-08-27 11:37         ` Melki Christian (consultant)
2013-08-27 20:21           ` Aleš Nesrsta
2013-08-27 21:38             ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-08-30 22:07               ` Aleš Nesrsta
2013-09-02  7:01                 ` Melki Christian (consultant)
2013-09-02 21:33                   ` Aleš Nesrsta [this message]
2013-09-02 22:52                     ` USB controller hand-back (original thread: Missing USB devices.) Vladimir 'φ-coder/phcoder' Serbinenko
2013-09-03  6:52                     ` Melki Christian (consultant)
2013-08-28  6:59             ` Missing USB devices Melki Christian (consultant)
2013-08-31 18:10               ` Aleš Nesrsta
2013-08-31 18:14                 ` [PATCH] " Aleš Nesrsta
2013-08-31 21:12                   ` Aleš Nesrsta
2013-09-02  7:17                     ` Melki Christian (consultant)
2013-09-23 12:47                     ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-09-23 18:38                       ` Aleš Nesrsta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5225042F.50906@volny.cz \
    --to=starous@volny.cz \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.