Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
On Fri, Jun 26, 2015 at 01:01:12PM +0200, Hans de Goede wrote: Hi, On 26-06-15 12:20, Maxime Ripard wrote: Hi, On Sun, Jun 14, 2015 at 12:40:11PM +0200, Hans de Goede wrote: Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? So, I was affected by this issue on a SinA33, even when not switching roles (since the SinA33 is peripheral only). The issue I was seeing what that when I was two subsequent use of any gadget (fastboot, USB ethernet traffic), the second would silently fail on U-boot side with the host failing to enumerate the device. Paul pointed me to that thread, and your suggestion on EP0 seems like a good lead, since the ugly http://pastebin.com/9Y6S9Hpw makes it work. Ah, that is not that ugly actually, I can take that as is if you want me too just submit it to the u-boot list with me in the Cc and I'll pick it up and put it in u-boot-sunxi/next I don't know, it felt quick and dirty while doing it :) I haven't tested it with host though, so you'll probably want to give that a test run, I'll submit it some time this week. Maxime -- Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Hi, On Sun, Jun 14, 2015 at 12:40:11PM +0200, Hans de Goede wrote: Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? So, I was affected by this issue on a SinA33, even when not switching roles (since the SinA33 is peripheral only). The issue I was seeing what that when I was two subsequent use of any gadget (fastboot, USB ethernet traffic), the second would silently fail on U-boot side with the host failing to enumerate the device. Paul pointed me to that thread, and your suggestion on EP0 seems like a good lead, since the ugly http://pastebin.com/9Y6S9Hpw makes it work. Thanks, Maxime -- Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Hi, On 26-06-15 12:20, Maxime Ripard wrote: Hi, On Sun, Jun 14, 2015 at 12:40:11PM +0200, Hans de Goede wrote: Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? So, I was affected by this issue on a SinA33, even when not switching roles (since the SinA33 is peripheral only). The issue I was seeing what that when I was two subsequent use of any gadget (fastboot, USB ethernet traffic), the second would silently fail on U-boot side with the host failing to enumerate the device. Paul pointed me to that thread, and your suggestion on EP0 seems like a good lead, since the ugly http://pastebin.com/9Y6S9Hpw makes it work. Ah, that is not that ugly actually, I can take that as is if you want me too just submit it to the u-boot list with me in the Cc and I'll pick it up and put it in u-boot-sunxi/next Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Hi, On 26-06-15 12:20, Maxime Ripard wrote: Hi, On Sun, Jun 14, 2015 at 12:40:11PM +0200, Hans de Goede wrote: Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? So, I was affected by this issue on a SinA33, even when not switching roles (since the SinA33 is peripheral only). Missed this the first reply, are you sure, that is somewhat weird. I mean it is possible if they did not hook up the id pin, or do not allow you to send out +5v, but it is weird. I guess they did route the real usb-host to an USB-A receptacle on that board, so it is not a big deal, right ? Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
On Fri, Jun 26, 2015 at 01:02:51PM +0200, Hans de Goede wrote: Hi, On 26-06-15 12:20, Maxime Ripard wrote: Hi, On Sun, Jun 14, 2015 at 12:40:11PM +0200, Hans de Goede wrote: Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? So, I was affected by this issue on a SinA33, even when not switching roles (since the SinA33 is peripheral only). Missed this the first reply, are you sure, that is somewhat weird. I mean it is possible if they did not hook up the id pin, or do not allow you to send out +5v, but it is weird. I guess they did route the real usb-host to an USB-A receptacle on that board, so it is not a big deal, right ? Yeah, I'm sure, or at least that's what the schematics say. VBUS comes straight from the DC-5V (without any GPIO in between), goes through a jumper (you read me right), which is even un-populated on the boards Chen-Yu and I got. So it seems like while the board has the ID pin routed, it's actually not able to provide VBUS (which is kind of weird, but anyway). Maxime -- Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
On Friday, June 19, 2015 at 03:07:04 PM, Hans de Goede wrote: Hi, On 19-06-15 14:35, Marek Vasut wrote: On Sunday, June 14, 2015 at 12:40:11 PM, Hans de Goede wrote: Hi Ian, Paul, Here is a patch to fix the problems where most usb devices will no longer work after a usb reset , when connected to the otg controller in host mode + a related cleanup patch. Ian I would like to send out a PR with these 2 as fixed for v2015.07, can you review them please? Note I've not tested this with the otg in gadget mode, but we do not have gadget mode enabled by default anywhere atm, so I still consider this suitable as a bugfix for v2015.07. Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? From my experience sofar we should avoid doing a full reset from musb_stop / sunxi_musb_disable as musb_init_controller never gets re-run, so doing a full reset leaves things in a bad state where only ep0 still seems to work, this may be what you were seeing before. Hi, do you want me to pick this via u-boot-usb/master ? No, I've already send a pull-req for them via u-boot-sunxi/master and they are already merged :) OK, roger. Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Hi, On 19-06-15 14:35, Marek Vasut wrote: On Sunday, June 14, 2015 at 12:40:11 PM, Hans de Goede wrote: Hi Ian, Paul, Here is a patch to fix the problems where most usb devices will no longer work after a usb reset , when connected to the otg controller in host mode + a related cleanup patch. Ian I would like to send out a PR with these 2 as fixed for v2015.07, can you review them please? Note I've not tested this with the otg in gadget mode, but we do not have gadget mode enabled by default anywhere atm, so I still consider this suitable as a bugfix for v2015.07. Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? From my experience sofar we should avoid doing a full reset from musb_stop / sunxi_musb_disable as musb_init_controller never gets re-run, so doing a full reset leaves things in a bad state where only ep0 still seems to work, this may be what you were seeing before. Hi, do you want me to pick this via u-boot-usb/master ? No, I've already send a pull-req for them via u-boot-sunxi/master and they are already merged :) Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
On Sunday, June 14, 2015 at 12:40:11 PM, Hans de Goede wrote: Hi Ian, Paul, Here is a patch to fix the problems where most usb devices will no longer work after a usb reset , when connected to the otg controller in host mode + a related cleanup patch. Ian I would like to send out a PR with these 2 as fixed for v2015.07, can you review them please? Note I've not tested this with the otg in gadget mode, but we do not have gadget mode enabled by default anywhere atm, so I still consider this suitable as a bugfix for v2015.07. Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? From my experience sofar we should avoid doing a full reset from musb_stop / sunxi_musb_disable as musb_init_controller never gets re-run, so doing a full reset leaves things in a bad state where only ep0 still seems to work, this may be what you were seeing before. Hi, do you want me to pick this via u-boot-usb/master ? Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Le mercredi 17 juin 2015 à 15:39 +0200, Hans de Goede a écrit : Hi, On 15-06-15 21:21, Paul Kocialkowski wrote: Le dimanche 14 juin 2015 à 12:40 +0200, Hans de Goede a écrit : Hi Ian, Paul, Here is a patch to fix the problems where most usb devices will no longer work after a usb reset , when connected to the otg controller in host mode + a related cleanup patch. This works fine for an USB storage device and an USB2 keyboard but does not work with an USB1 keyboard, with error: sunxi# usb reset resetting USB... USB0: scanning bus 0 for devices... USB device descriptor short read (expected 8, got 0) No USB Device found Hmm, did you test my sunxi-wip branch perhaps? This bug does exist there, but it is the result of me refactoring things so that the musb code can use the device-model when build in host mode, which will allow enabling both the otg port in host mode and regular usb hosts in a single build, which is esp. useful for boards which have the otg hooked up in host-only mode (e.g. connected to an usb-a receptacle, or usb - sata bridge). This is nice, thanks a lot for all your work! I did however test on top of the regular U-Boot tree. I'll try again in a few days to see if it still happens. -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: http://www.replicant.us/ Blog: http://blog.replicant.us/ Wiki/tracker/forums: http://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Hi, On 15-06-15 21:21, Paul Kocialkowski wrote: Le dimanche 14 juin 2015 à 12:40 +0200, Hans de Goede a écrit : Hi Ian, Paul, Here is a patch to fix the problems where most usb devices will no longer work after a usb reset , when connected to the otg controller in host mode + a related cleanup patch. This works fine for an USB storage device and an USB2 keyboard but does not work with an USB1 keyboard, with error: sunxi# usb reset resetting USB... USB0: scanning bus 0 for devices... USB device descriptor short read (expected 8, got 0) No USB Device found Hmm, did you test my sunxi-wip branch perhaps? This bug does exist there, but it is the result of me refactoring things so that the musb code can use the device-model when build in host mode, which will allow enabling both the otg port in host mode and regular usb hosts in a single build, which is esp. useful for boards which have the otg hooked up in host-only mode (e.g. connected to an usb-a receptacle, or usb - sata bridge). I've just retested current u-boot/master with just this patch and the problem you are describing does not happen then. Sorry about my sunxi-wip being broken atm I try to always keep it 100% functional, but well it is a wip tree after all. Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/2] sunxi: musb: Fix usb reset handling
Le dimanche 14 juin 2015 à 12:40 +0200, Hans de Goede a écrit : Hi Ian, Paul, Here is a patch to fix the problems where most usb devices will no longer work after a usb reset , when connected to the otg controller in host mode + a related cleanup patch. This works fine for an USB storage device and an USB2 keyboard but does not work with an USB1 keyboard, with error: sunxi# usb reset resetting USB... USB0: scanning bus 0 for devices... USB device descriptor short read (expected 8, got 0) No USB Device found Paul, can you test these with gadget mode? Specifically if they help the problem you were seeing when switching roles? It doesn't fix the problem as-is, I still get enumerating problems from the host. Also, note that musb_stop is not called from the gadget code, so sunxi_musb_disable (musb_platform_disable) is not called either. I had to add a dirty call in usb_gadget_unregister_driver to test the code. Also this bit from the kernel code for the sunxi glue may be relevant to your problems: if ((musb-int_usb MUSB_INTR_RESET) !is_host_active(musb)) { /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); } This is from the interrupt handler in the sunxi-musb glue in the kernel, maybe we can do the same, and/or maybe we need to do: /* ep0 FADDR must be 0 when (re)entering peripheral mode */ musb_ep_select(musb-mregs, 0); musb_writeb(musb-mregs, MUSB_FADDR, 0); From sunxi_musb_disable? Thanks for those pointers, I'll try to look into that when I have time to properly debug the issue. From my experience sofar we should avoid doing a full reset from musb_stop / sunxi_musb_disable as musb_init_controller never gets re-run, so doing a full reset leaves things in a bad state where only ep0 still seems to work, this may be what you were seeing before. That makes sense, but what is done currently doesn't seem to be enough to bring everything back up. Hopefully, setting the EP0 FADDR will help. Thanks a lot for your work, as usual! -- Paul Kocialkowski, Replicant developer Replicant is a fully free Android distribution running on several devices, a free software mobile operating system putting the emphasis on freedom and privacy/security. Website: http://www.replicant.us/ Blog: http://blog.replicant.us/ Wiki/tracker/forums: http://redmine.replicant.us/ signature.asc Description: This is a digitally signed message part ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot