All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH fix for v2014.10 2/5] usb: kbd: On a "usb reset" call usb_kbd_deregister() before calling usb_stop()
Date: Tue, 23 Sep 2014 11:10:34 +0200	[thread overview]
Message-ID: <5421390A.3050804@redhat.com> (raw)
In-Reply-To: <201409221401.34745.marex@denx.de>

Hi,

On 09/22/2014 02:01 PM, Marek Vasut wrote:
> On Saturday, September 20, 2014 at 04:54:35 PM, Hans de Goede wrote:
>> We need to call usb_kbd_deregister() before calling usb_stop().
>>
>> usbkbd's stdio_dev->priv points to the usb_device, and usb_kbd_testc
>> dereferences usb_device->privptr.
>>
>> usb_stop zeros usb_device, leaving usb_device->privptr NULL, causing
>> bad things (tm) to happen once control returns to the main loop and
>> usb_kbd_testc gets called.
>>
>> Calling usb_kbd_deregister() avoids this. Note that we do not allow
>> the "usb reset" to continue when the deregister fails. This will be fixed
>> in a later patch.
>>
>> For the same reasons always fail "usb stop" if the usb_kbd_deregister()
>> fails, even in the force path. This can happen when
>> CONFIG_SYS_STDIO_DEREGISTER is not set.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  common/cmd_usb.c | 27 +++++++++++++++------------
>>  1 file changed, 15 insertions(+), 12 deletions(-)
>>
>> diff --git a/common/cmd_usb.c b/common/cmd_usb.c
>> index 2519497..b2aa44c 100644
>> --- a/common/cmd_usb.c
>> +++ b/common/cmd_usb.c
>> @@ -430,6 +430,16 @@ static int do_usbboot(cmd_tbl_t *cmdtp, int flag, int
>> argc, char * const argv[]) }
>>  #endif /* CONFIG_USB_STORAGE */
>>
>> +static int do_usb_stop_keyboard(void)
>> +{
>> +#ifdef CONFIG_USB_KEYBOARD
>> +	if (usb_kbd_deregister() != 0) {
>> +		printf("USB not stopped: usbkbd still using USB\n");
> 
> I tried this set of patches with the DWC2 driver on RPI just now and i get this 
> message and 'usb start' fails and doesn't scan bus. I suspect we have a problem 
> here, can you check and post a fix ?

Do you have the entire set applied ? This is a known regression as mentioned
in the commit msg. Once the force parameter is in place this should go
away for a start/reset.

Also is usb start being called twice ? The first deregister should never fail,
since then no device is registered.

Regards,

Hans

  reply	other threads:[~2014-09-23  9:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-20 14:54 [U-Boot] [PATCH fix for v2014.10 0/5] USB keyboard: don't crash on "usb reset" Hans de Goede
2014-09-20 14:54 ` [U-Boot] [PATCH fix for v2014.10 1/5] usb: kbd: Do not treat -ENODEV as an error for usb_kbd_deregister Hans de Goede
2014-09-20 14:54 ` [U-Boot] [PATCH fix for v2014.10 2/5] usb: kbd: On a "usb reset" call usb_kbd_deregister() before calling usb_stop() Hans de Goede
2014-09-22 12:01   ` Marek Vasut
2014-09-23  9:10     ` Hans de Goede [this message]
2014-09-23 12:15       ` Marek Vasut
2014-09-23 12:51         ` Hans de Goede
2014-09-20 14:54 ` [U-Boot] [PATCH fix for v2014.10 3/5] usb: kbd: Remove check for already being registered Hans de Goede
2014-09-20 14:54 ` [U-Boot] [PATCH fix for v2014.10 4/5] stdio: Add force parameter to stdio_deregister Hans de Goede
2014-10-09  2:18   ` Rommel Custodio
2014-10-09  6:18   ` Simon Glass
2014-10-09 15:12     ` Marek Vasut
2014-10-09 16:14       ` Simon Glass
2014-10-09 16:27         ` Marek Vasut
2014-10-09 17:03           ` Simon Glass
2014-10-09 17:32             ` Marek Vasut
2014-10-09 18:04               ` Simon Glass
2014-10-09 23:59                 ` Marek Vasut
2014-10-10  2:00                   ` Simon Glass
2014-10-10  2:23                     ` Marek Vasut
2014-10-10  2:26                       ` Fabio Estevam
2014-10-10  2:35                         ` Simon Glass
2014-10-10 10:42                           ` Marek Vasut
2014-10-10  2:06                   ` Fabio Estevam
2014-10-10  2:07                     ` Simon Glass
2014-10-10  2:16                       ` Fabio Estevam
2014-10-09 16:23       ` Tom Rini
2014-10-09 17:03         ` Simon Glass
2014-10-09 17:26           ` Tom Rini
2014-09-20 14:54 ` [U-Boot] [PATCH fix for v2014.10 5/5] usb: kbd: Allow "usb reset" to continue when an usb kbd is used Hans de Goede
2014-09-21 10:26 ` [U-Boot] [PATCH fix for v2014.10 0/5] USB keyboard: don't crash on "usb reset" Marek Vasut

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=5421390A.3050804@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=u-boot@lists.denx.de \
    /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.