Re: [PATCH 1/2] ARM: OMAP2+: Introduce local usb.h
On Thu, Oct 18, 2012 at 07:20:05PM -0700, Tony Lindgren wrote: > Let's move what we can from plat/usb.h to the local usb.h > for ARM common zImage support. > > This is needed so we can remove plat/usb.h for ARM common > zImage support. > > Cc: Felipe Balbi Acked-by: Felipe Balbi > Cc: Samuel Ortiz > Cc: Alan Stern > Cc: Greg Kroah-Hartman > Cc: Partha Basak > Cc: Keshava Munegowda > Cc: linux-usb@vger.kernel.org > Signed-off-by: Tony Lindgren > --- > arch/arm/mach-omap1/clock.c |1 > arch/arm/mach-omap2/board-2430sdp.c |1 > arch/arm/mach-omap2/board-3430sdp.c |1 > arch/arm/mach-omap2/board-3630sdp.c |1 > arch/arm/mach-omap2/board-4430sdp.c |1 > arch/arm/mach-omap2/board-am3517crane.c |1 > arch/arm/mach-omap2/board-am3517evm.c|1 > arch/arm/mach-omap2/board-cm-t35.c |1 > arch/arm/mach-omap2/board-cm-t3517.c |1 > arch/arm/mach-omap2/board-devkit8000.c |1 > arch/arm/mach-omap2/board-igep0020.c |1 > arch/arm/mach-omap2/board-ldp.c |1 > arch/arm/mach-omap2/board-omap3beagle.c |1 > arch/arm/mach-omap2/board-omap3evm.c |1 > arch/arm/mach-omap2/board-omap3logic.c |1 > arch/arm/mach-omap2/board-omap3pandora.c |1 > arch/arm/mach-omap2/board-omap3stalker.c |1 > arch/arm/mach-omap2/board-omap3touchbook.c |1 > arch/arm/mach-omap2/board-omap4panda.c |1 > arch/arm/mach-omap2/board-overo.c|1 > arch/arm/mach-omap2/board-rm680.c|1 > arch/arm/mach-omap2/board-rx51.c |1 > arch/arm/mach-omap2/board-ti8168evm.c|1 > arch/arm/mach-omap2/board-zoom-peripherals.c |1 > arch/arm/mach-omap2/board-zoom.c |1 > arch/arm/mach-omap2/common.h |2 > arch/arm/mach-omap2/omap_phy_internal.c |4 - > arch/arm/mach-omap2/twl-common.c |1 > arch/arm/mach-omap2/usb-host.c |2 > arch/arm/mach-omap2/usb-musb.c |2 > arch/arm/mach-omap2/usb.h| 82 > arch/arm/plat-omap/include/plat/usb.h| 106 > -- > 32 files changed, 88 insertions(+), 136 deletions(-) > create mode 100644 arch/arm/mach-omap2/usb.h > > diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c > index 638f407..1e49eda 100644 > --- a/arch/arm/mach-omap1/clock.c > +++ b/arch/arm/mach-omap1/clock.c > @@ -22,7 +22,6 @@ > #include > > #include > -#include > #include > #include > #include > diff --git a/arch/arm/mach-omap2/board-2430sdp.c > b/arch/arm/mach-omap2/board-2430sdp.c > index 95b384d..df561ad 100644 > --- a/arch/arm/mach-omap2/board-2430sdp.c > +++ b/arch/arm/mach-omap2/board-2430sdp.c > @@ -35,7 +35,6 @@ > > #include "common.h" > #include > -#include > #include "gpmc-smc91x.h" > > #include > diff --git a/arch/arm/mach-omap2/board-3430sdp.c > b/arch/arm/mach-omap2/board-3430sdp.c > index 96cd369..14c07ee 100644 > --- a/arch/arm/mach-omap2/board-3430sdp.c > +++ b/arch/arm/mach-omap2/board-3430sdp.c > @@ -30,7 +30,6 @@ > #include > #include > > -#include > #include "common.h" > #include > #include > diff --git a/arch/arm/mach-omap2/board-3630sdp.c > b/arch/arm/mach-omap2/board-3630sdp.c > index fc224ad..f8e6288 100644 > --- a/arch/arm/mach-omap2/board-3630sdp.c > +++ b/arch/arm/mach-omap2/board-3630sdp.c > @@ -18,7 +18,6 @@ > > #include "common.h" > #include "gpmc-smc91x.h" > -#include > > #include > > diff --git a/arch/arm/mach-omap2/board-4430sdp.c > b/arch/arm/mach-omap2/board-4430sdp.c > index 3669c12..5700fc5 100644 > --- a/arch/arm/mach-omap2/board-4430sdp.c > +++ b/arch/arm/mach-omap2/board-4430sdp.c > @@ -34,7 +34,6 @@ > #include > > #include "common.h" > -#include > #include > #include "omap4-keypad.h" > #include > diff --git a/arch/arm/mach-omap2/board-am3517crane.c > b/arch/arm/mach-omap2/board-am3517crane.c > index 318fead..603503c 100644 > --- a/arch/arm/mach-omap2/board-am3517crane.c > +++ b/arch/arm/mach-omap2/board-am3517crane.c > @@ -26,7 +26,6 @@ > #include > > #include "common.h" > -#include > > #include "am35xx-emac.h" > #include "mux.h" > diff --git a/arch/arm/mach-omap2/board-am3517evm.c > b/arch/arm/mach-omap2/board-am3517evm.c > index e162897..0dbeb77 100644 > --- a/arch/arm/mach-omap2/board-am3517evm.c > +++ b/arch/arm/mach-omap2/board-am3517evm.c > @@ -33,7 +33,6 @@ > #include > > #include "common.h" > -#include > #include > #include > #include > diff --git a/arch/arm/mach-omap2/board-cm-t35.c > b/arch/arm/mach-omap2/board-cm-t35.c > index 376d26e..435c7be 100644 > --- a/arch/arm/mach-omap2/board-cm-t35.c > +++ b/arch/arm/mach-omap2/board-cm-t35.c > @@ -41,7 +41,6 @@ > #include "common.h" > #include > #include > -#include > #include >
[PATCH] usb: host: xhci: move HC_STATE_SUSPENDED check to xhci_suspend()
that check will have to be done by all users of xhci_suspend() so it sounds a lot better to move the check to xhci_suspend() in order to avoid code duplication. Signed-off-by: Felipe Balbi --- drivers/usb/host/xhci-pci.c | 9 + drivers/usb/host/xhci.c | 4 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 8345d7c..aeb3973 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -218,15 +218,8 @@ static void xhci_pci_remove(struct pci_dev *dev) static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - int retval = 0; - if (hcd->state != HC_STATE_SUSPENDED || - xhci->shared_hcd->state != HC_STATE_SUSPENDED) - return -EINVAL; - - retval = xhci_suspend(xhci); - - return retval; + return xhci_suspend(xhci); } static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 8d7fcbb..b85029e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -879,6 +879,10 @@ int xhci_suspend(struct xhci_hcd *xhci) struct usb_hcd *hcd = xhci_to_hcd(xhci); u32 command; + if (hcd->state != HC_STATE_SUSPENDED || + xhci->shared_hcd->state != HC_STATE_SUSPENDED) + return -EINVAL; + spin_lock_irq(&xhci->lock); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); -- 1.8.0.rc0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: question regarding delay between bus states in EHCI driver
On Thu, Oct 18, 2012 at 10:37 PM, Alan Stern wrote: > On Thu, 18 Oct 2012, Pavan Kondeti wrote: > >> Hi Alan, >> >> I have a theoretical question in EHCI driver. We ensure that there is >> 5 msec window between suspend and next resume by keeping time_before() >> check in ehci_bus_resume function. If the next_statechange update in >> suspend occur just before the next timer tick (say 1 jiffies = 10 >> msec), then time_before() return false even when the resume is >> initiated <5 msec after suspend. I am not seeing any issue with this. >> Just would like to get a clarification from you. should we replace >> time_before with time_before_eq? > > In fact the whole thing shouldn't be using jiffies at all. We should > use ktime_t instead. And instead of having a fixed 5-ms delay at the > start of ehci_bus_suspend/resume, we should delay only by the amount of > time remaining. Likewise for ehci_suspend/resume. > Okay. Why are we having this check in ehci_suspend()? By the time ehci_suspend() is called, ehci_bus_suspend() is already called in which next_statechange is updated. we might end up giving 10msec delay in ehci_suspend(). why is 100 msec delay in ehci_resume? ehci_bus_resume has only 5 msec delay. > Would you like to write a patch to do this? > I will submit a patch next week. Thanks, Pavan -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: dwc3: drop HAVE_CLK dependency from Exynos glue layer
commit 93abe8e (clk: add non CONFIG_HAVE_CLK routines) added clk API stubs when !defined(CONFIG_HAVE_CLK). This allows us to remove the HAVE_CLK dependency from Exynos' glue layer and let it compile always. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/Makefile | 14 +- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index d441fe4..4502648 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -27,19 +27,7 @@ endif ## obj-$(CONFIG_USB_DWC3) += dwc3-omap.o - -## -# REVISIT Samsung Exynos platform needs the clk API which isn't -# defined on all architectures. If we allow dwc3-exynos.c compile -# always we will fail the linking phase on those architectures -# which don't provide clk api implementation and that's unnaceptable. -# -# When Samsung's platform start supporting pm_runtime, this check -# for HAVE_CLK should be removed. -## -ifneq ($(CONFIG_HAVE_CLK),) - obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o -endif +obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o ifneq ($(CONFIG_PCI),) obj-$(CONFIG_USB_DWC3) += dwc3-pci.o -- 1.8.0.rc0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] USB: PHY: Re-organize Tegra USB PHY driver
Hi Venu, > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. > In order to support USB PHY drivers on these SoCs, existing > PHY driver is split into SoC agnostic common USB PHY driver > and Tegra20-specific USB phy driver. This will facilitate > easy addition and deletion of phy drivers for Tegra SoCs. > > Signed-off-by: Venu Byravarasu unfortunately this patch doesn't apply cleanly to my xceiv branch: $ patch -p1 --dry-run < apply.diff patching file drivers/usb/host/ehci-tegra.c patching file drivers/usb/phy/Makefile patching file drivers/usb/phy/tegra_usb_phy.c Hunk #2 succeeded at 35 with fuzz 2 (offset 2 lines). Hunk #3 succeeded at 67 (offset 2 lines). Hunk #4 succeeded at 94 (offset 2 lines). Hunk #5 succeeded at 124 (offset 2 lines). Hunk #6 succeeded at 134 (offset 2 lines). Hunk #7 succeeded at 161 (offset 2 lines). Hunk #8 succeeded at 189 (offset 2 lines). Hunk #9 succeeded at 247 (offset 2 lines). Hunk #10 succeeded at 304 (offset 2 lines). Hunk #11 succeeded at 315 (offset 2 lines). Hunk #12 succeeded at 347 (offset 2 lines). Hunk #13 succeeded at 360 (offset 2 lines). Hunk #14 succeeded at 370 (offset 2 lines). Hunk #15 succeeded at 391 (offset 2 lines). Hunk #16 succeeded at 402 (offset 2 lines). Hunk #17 succeeded at 471 (offset 2 lines). Hunk #18 succeeded at 488 (offset 2 lines). patching file drivers/usb/phy/tegra2_usb_phy.h patching file drivers/usb/phy/tegra_usb_phy.c Hunk #1 FAILED at 30. Hunk #2 succeeded at 208 (offset 2 lines). Hunk #3 succeeded at 224 (offset 2 lines). Hunk #4 succeeded at 271 (offset 2 lines). Hunk #5 succeeded at 285 (offset 2 lines). Hunk #6 succeeded at 300 (offset 2 lines). 1 out of 6 hunks FAILED -- saving rejects to file drivers/usb/phy/tegra_usb_phy.c.rej patching file include/linux/usb/tegra_usb_phy.h Also, I need Alan's ack because you're changing ehci-tegra.c -- balbi signature.asc Description: Digital signature
Re: [PATCH v3] USB: PHY: Re-organize Tegra USB PHY driver
Hi, On Fri, Oct 19, 2012 at 11:36:19AM +0300, Felipe Balbi wrote: > Hi Venu, > > > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. > > In order to support USB PHY drivers on these SoCs, existing > > PHY driver is split into SoC agnostic common USB PHY driver > > and Tegra20-specific USB phy driver. This will facilitate > > easy addition and deletion of phy drivers for Tegra SoCs. > > > > Signed-off-by: Venu Byravarasu > > unfortunately this patch doesn't apply cleanly to my xceiv branch: > > $ patch -p1 --dry-run < apply.diff > patching file drivers/usb/host/ehci-tegra.c > patching file drivers/usb/phy/Makefile > patching file drivers/usb/phy/tegra_usb_phy.c > Hunk #2 succeeded at 35 with fuzz 2 (offset 2 lines). > Hunk #3 succeeded at 67 (offset 2 lines). > Hunk #4 succeeded at 94 (offset 2 lines). > Hunk #5 succeeded at 124 (offset 2 lines). > Hunk #6 succeeded at 134 (offset 2 lines). > Hunk #7 succeeded at 161 (offset 2 lines). > Hunk #8 succeeded at 189 (offset 2 lines). > Hunk #9 succeeded at 247 (offset 2 lines). > Hunk #10 succeeded at 304 (offset 2 lines). > Hunk #11 succeeded at 315 (offset 2 lines). > Hunk #12 succeeded at 347 (offset 2 lines). > Hunk #13 succeeded at 360 (offset 2 lines). > Hunk #14 succeeded at 370 (offset 2 lines). > Hunk #15 succeeded at 391 (offset 2 lines). > Hunk #16 succeeded at 402 (offset 2 lines). > Hunk #17 succeeded at 471 (offset 2 lines). > Hunk #18 succeeded at 488 (offset 2 lines). > patching file drivers/usb/phy/tegra2_usb_phy.h > patching file drivers/usb/phy/tegra_usb_phy.c > Hunk #1 FAILED at 30. > Hunk #2 succeeded at 208 (offset 2 lines). > Hunk #3 succeeded at 224 (offset 2 lines). > Hunk #4 succeeded at 271 (offset 2 lines). > Hunk #5 succeeded at 285 (offset 2 lines). > Hunk #6 succeeded at 300 (offset 2 lines). > 1 out of 6 hunks FAILED -- saving rejects to file > drivers/usb/phy/tegra_usb_phy.c.rej > patching file include/linux/usb/tegra_usb_phy.h > > Also, I need Alan's ack because you're changing ehci-tegra.c now replying to correct thread. sorry -- balbi signature.asc Description: Digital signature
Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
Bjørn Mork writes: > Alexey Orishko writes: > >> Vendor has to fix firmware. > > I agree in principle, and I'll report the problem to them. But as usual > I believe we have to support any weird firmware we encounter, if at all > possible. OK, I did some more experiments, and I am wondering if the real firmware problem is in the MBIM descriptor. It is CDC MBIM: bcdMBIMVersion 1.00 wMaxControlMessage 1536 bNumberFilters 16 bMaxFilterSize 40 wMaxSegmentSize 4096 bmNetworkCapabilities 0x20 8-byte ntb input size so we use the 8-byte version of USB_CDC_SET_NTB_INPUT_SIZE, which fails with -EPIPE. But forcing the 4-byte version seems to work. Hmm, I also see that the device returns 4 bytes in response to at USB_CDC_GET_NTB_INPUT_SIZE with an 8-byte buffer. Maybe we can auto-quirk based on that? I.e., if USB_CDC_GET_NTB_INPUT_SIZE returns only 4 bytes then we assume that the bmNetworkCapabilities flag is wrong. Is that acceptable? Then it seems we are able to inform this device of the reduced buffer, and the other problems can be ignored. Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Tons of issues with xhci
On Thu, Oct 18, 2012 at 9:54 PM, Alan Stern wrote: > On Thu, 18 Oct 2012, Felipe Contreras wrote: > >> On Thu, Oct 18, 2012 at 8:03 PM, Felipe Contreras >> wrote: >> > On Thu, Oct 18, 2012 at 7:26 PM, Alan Stern >> > wrote: >> >> On Thu, 18 Oct 2012, Felipe Contreras wrote: >> >> >> >>> Nope, still fails. >> >>> >> >>> http://felipec.org/dmesg.txt.xz >> >>> >> >>> I had some issues booting, probably not related to your patches, so I >> >>> rebased them on top of 3.6.2. >> >> >> >> A usbmon trace (starting from before the non-working device is plugged >> >> in) might shed some light on the problem. >> > >> > Here: >> > http://felipec.org/dmesg.txt.xz >> > >> > I simply plugged it in, mounted a fs, checked a directory, waited a >> > couple minutes, checked another. >> >> Sigh >> http://felipec.org/usbmon.txt.xz > > Unfortunately the trace isn't termendously helpful. It shows a bunch > of reads with a few writes sprinkled among them. Then for no apparent > reason, in the middle of a read the device was disconnected. > > Oddly, the bulk-IN URB that was in progress when the disconnect > occurred did not complete immediately with an error. Instead it timed > out after 30 seconds and was cancelled. Sarah, I thought you had fixed > that? > > The drive reconnected, was re-enumerated, and a few seconds later > disconnected again. No way to know the reason for these disconnects; > they could be symptoms of a bad connection, hardware/firmware bugs, or > even possibly a bug in xhci-hcd. So I tried everything, eventually updated the firmware, but in the end it turns out it was the cable. With the bad cable it seems when operating in USB2 mode it tends to work fine, which explains a lot. Anyway, I went back to 3.6.2 without the lpm patches and it still works fine :) Thanks for pointing me in the right direction. Cheers. -- Felipe Contreras -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Tons of issues with xhci
> So I tried everything, eventually updated the firmware, but in the end > it turns out it was the cable. With the bad cable it seems when > operating in USB2 mode it tends to work fine, which explains a lot. > > Anyway, I went back to 3.6.2 without the lpm patches and it still works fine > :) > > Thanks for pointing me in the right direction. > > Cheers. > Doesn't this look alot like the problems I had ? :| Altough I still find weird the fact that the connection to my laptop worked just fine, but not in the asrock ! :| -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
On Fri, Oct 19, 2012 at 11:30 AM, Bjørn Mork wrote: > Bjørn Mork writes: >> Alexey Orishko writes: >> > OK, I did some more experiments, and I am wondering if the real firmware > problem is in the MBIM descriptor. It is > > CDC MBIM: > bcdMBIMVersion 1.00 > wMaxControlMessage 1536 > bNumberFilters 16 > bMaxFilterSize 40 > wMaxSegmentSize 4096 > bmNetworkCapabilities 0x20 > 8-byte ntb input size > > > so we use the 8-byte version of USB_CDC_SET_NTB_INPUT_SIZE, which fails > with -EPIPE. But forcing the 4-byte version seems to work. Hmm, I also > see that the device returns 4 bytes in response to at > USB_CDC_GET_NTB_INPUT_SIZE with an 8-byte buffer. Maybe we can > auto-quirk based on that? I.e., if USB_CDC_GET_NTB_INPUT_SIZE returns > only 4 bytes then we assume that the bmNetworkCapabilities flag is > wrong. > > Is that acceptable? Then it seems we are able to inform this device of > the reduced buffer, and the other problems can be ignored. > Based on NCM errata, NCM functional descriptor: if Bit 5 is set, then device can (must) handle 8-byte form of Set/GetNtbInputSize. If they set a flag, but don't support the feature, hm.. is it a prototype device or commercially available one? At least device must support Set request, but for GetNtbInputSize we could happily live without wNtbInMaxDatagrams (i.e. use 4 byte variant) on Linux. Since we must anyway receive a complete NTB and making any number of skb buffers from received NTB is not a problem at all. regards, alexey -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Tons of issues with xhci
On Fri, Oct 19, 2012 at 11:53 AM, Adrian Sandu wrote: >> So I tried everything, eventually updated the firmware, but in the end >> it turns out it was the cable. With the bad cable it seems when >> operating in USB2 mode it tends to work fine, which explains a lot. >> >> Anyway, I went back to 3.6.2 without the lpm patches and it still works fine >> :) >> >> Thanks for pointing me in the right direction. >> >> Cheers. >> > Doesn't this look alot like the problems I had ? :| > Altough I still find weird the fact that the connection to my laptop > worked just fine, but not in the asrock ! :| The same happened to me in another laptop, which only has USB2 ports. I still see problems on this laptop on the USB2 port though (with that cable), so it might depend on the hardware whether you see problems with a bad cable or not. -- Felipe Contreras -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Tons of issues with xhci
>> Doesn't this look alot like the problems I had ? :| >> Altough I still find weird the fact that the connection to my laptop >> worked just fine, but not in the asrock ! :| > > The same happened to me in another laptop, which only has USB2 ports. > I still see problems on this laptop on the USB2 port though (with that > cable), so it might depend on the hardware whether you see problems > with a bad cable or not. > On my vaio laptop when I tested, I tested with an usb3 port (tested on both ports actually) :| Same thing on the asrock though, usb2 was ok, usb3 was not. Bought the best cables I could get my hands on ( just to be sure ) and everything was ok since then .. ( it happened again once (can't remember exactly when) though .. but that's about it ). -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/7] update USB gadget driver fsl-usb2-udc
This series updates USB gadget driver fsl-usb2-udc. Christoph Fritz (7): usb: gadget: fsl_udc: simplify driver init usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock usb: gadget: fsl_udc: convert to new ulc style usb: gadget: fsl_udc: drop ARCH dependency usb: gadget: fsl_udc: postpone freeing current dTD usb: gadget: fsl_udc: purge global pointer usb_sys_regs usb: gadget: fsl_udc: purge global pointer dr_regs drivers/usb/gadget/fsl_udc_core.c | 755 - drivers/usb/gadget/fsl_usb2_udc.h |4 + 2 files changed, 322 insertions(+), 437 deletions(-) -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/7] usb: gadget: fsl_udc: simplify driver init
To initialize this driver use 'module_platform_driver' instead of '__init' and '__exit'. Signed-off-by: Christoph Fritz --- drivers/usb/gadget/fsl_udc_core.c | 37 +++-- 1 files changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 6ae70cb..340451d 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -49,13 +49,14 @@ #include "fsl_usb2_udc.h" +#defineDRIVER_NAME "fsl-usb2-udc" #defineDRIVER_DESC "Freescale High-Speed USB SOC Device Controller driver" #defineDRIVER_AUTHOR "Li Yang/Jiang Bo" #defineDRIVER_VERSION "Apr 20, 2007" #defineDMA_ADDR_INVALID(~(dma_addr_t)0) -static const char driver_name[] = "fsl-usb2-udc"; +static const char driver_name[] = DRIVER_NAME; static const char driver_desc[] = DRIVER_DESC; static struct usb_dr_device *dr_regs; @@ -2761,35 +2762,19 @@ static int fsl_udc_otg_resume(struct device *dev) Register entry point for the peripheral controller driver --*/ -static struct platform_driver udc_driver = { - .remove = __exit_p(fsl_udc_remove), - /* these suspend and resume are not usb suspend and resume */ - .suspend = fsl_udc_suspend, - .resume = fsl_udc_resume, - .driver = { - .name = (char *)driver_name, - .owner = THIS_MODULE, - /* udc suspend/resume called from OTG driver */ +static struct platform_driver fsl_udc_driver = { + .probe = fsl_udc_probe, + .remove = __devexit_p(fsl_udc_remove), + .suspend= fsl_udc_suspend, + .resume = fsl_udc_resume, + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, .suspend = fsl_udc_otg_suspend, .resume = fsl_udc_otg_resume, }, }; - -static int __init udc_init(void) -{ - printk(KERN_INFO "%s (%s)\n", driver_desc, DRIVER_VERSION); - return platform_driver_probe(&udc_driver, fsl_udc_probe); -} - -module_init(udc_init); - -static void __exit udc_exit(void) -{ - platform_driver_unregister(&udc_driver); - printk(KERN_WARNING "%s unregistered\n", driver_desc); -} - -module_exit(udc_exit); +module_platform_driver(fsl_udc_driver); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_AUTHOR(DRIVER_AUTHOR); -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/7] usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock
This patch reworks fsl_pullup() against the background of switching over to udc_start()/udc_stop() style: Protect function fsl_pullup() with a spin_lock. Also set vbus_active as default to true. This prevents disabling USB controller if there is no driver support for an external transceiver (or GPIO) that detects a VBUS power session starting. Signed-off-by: Christoph Fritz --- drivers/usb/gadget/fsl_udc_core.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 340451d..0a0d6a6 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -1242,8 +1242,10 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA) static int fsl_pullup(struct usb_gadget *gadget, int is_on) { struct fsl_udc *udc; + unsigned long flags; udc = container_of(gadget, struct fsl_udc, gadget); + spin_lock_irqsave(&udc->lock, flags); udc->softconnect = (is_on != 0); if (can_pullup(udc)) fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), @@ -1251,6 +1253,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on) else fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP), &dr_regs->usbcmd); + spin_unlock_irqrestore(&udc->lock, flags); return 0; } @@ -2557,6 +2560,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) INIT_LIST_HEAD(&udc_controller->gadget.ep_list); udc_controller->gadget.speed = USB_SPEED_UNKNOWN; udc_controller->gadget.name = driver_name; + udc->vbus_active = true; /* Setup gadget.dev and register with kernel */ dev_set_name(&udc_controller->gadget.dev, "gadget"); -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/7] usb: gadget: fsl_udc: convert to new ulc style
Convert to new UDC style registration and remove global 'udc_controller' pointer. Signed-off-by: Christoph Fritz --- drivers/usb/gadget/fsl_udc_core.c | 289 + 1 files changed, 131 insertions(+), 158 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 0a0d6a6..d113f39 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -63,9 +63,6 @@ static struct usb_dr_device *dr_regs; static struct usb_sys_interface *usb_sys_regs; -/* it is initialized in probe() */ -static struct fsl_udc *udc_controller = NULL; - static const struct usb_endpoint_descriptor fsl_ep0_desc = { .bLength = USB_DT_ENDPOINT_SIZE, @@ -783,12 +780,14 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) } /* Fill in the dTD structure + * @udc: driver private data * @req: request that the transfer belongs to * @length: return actually data length of the dTD * @dma: return dma address of the dTD * @is_last: return flag if it is the last dTD of the request * return: pointer to the built dTD */ -static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, +static struct ep_td_struct *fsl_build_dtd(struct fsl_udc *udc, + struct fsl_req *req, unsigned *length, dma_addr_t *dma, int *is_last, gfp_t gfp_flags) { u32 swap_temp; @@ -798,7 +797,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, *length = min(req->req.length - req->req.actual, (unsigned)EP_MAX_LENGTH_TRANSFER); - dtd = dma_pool_alloc(udc_controller->td_pool, gfp_flags, dma); + dtd = dma_pool_alloc(udc->td_pool, gfp_flags, dma); if (dtd == NULL) return dtd; @@ -848,7 +847,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, } /* Generate dtd chain for a request */ -static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags) +static int fsl_req_to_dtd(struct fsl_udc *udc, struct fsl_req *req, + gfp_t gfp_flags) { unsignedcount; int is_last; @@ -857,7 +857,8 @@ static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags) dma_addr_t dma; do { - dtd = fsl_build_dtd(req, &count, &dma, &is_last, gfp_flags); + dtd = fsl_build_dtd(udc, req, &count, &dma, &is_last, + gfp_flags); if (dtd == NULL) return -ENOMEM; @@ -932,7 +933,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) req->dtd_count = 0; /* build dtds and push them to device queue */ - if (!fsl_req_to_dtd(req, gfp_flags)) { + if (!fsl_req_to_dtd(udc, req, gfp_flags)) { spin_lock_irqsave(&udc->lock, flags); fsl_queue_td(ep, req); } else { @@ -1258,9 +1259,10 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on) return 0; } -static int fsl_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); -static int fsl_stop(struct usb_gadget_driver *driver); +static int fsl_udc_start(struct usb_gadget *gadget, + struct usb_gadget_driver *driver); +static int fsl_udc_stop(struct usb_gadget *gadget, + struct usb_gadget_driver *driver); /* defined in gadget.h */ static struct usb_gadget_ops fsl_gadget_ops = { .get_frame = fsl_get_frame, @@ -1269,8 +1271,8 @@ static struct usb_gadget_ops fsl_gadget_ops = { .vbus_session = fsl_vbus_session, .vbus_draw = fsl_vbus_draw, .pullup = fsl_pullup, - .start = fsl_start, - .stop = fsl_stop, + .udc_start = fsl_udc_start, + .udc_stop = fsl_udc_stop, }; /* Set protocol stall on ep0, protocol stall will automatically be cleared @@ -1314,7 +1316,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); req->mapped = 1; - if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0) + if (fsl_req_to_dtd(udc, req, GFP_ATOMIC) == 0) fsl_queue_td(ep, req); else return -ENOMEM; @@ -1398,7 +1400,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, req->mapped = 1; /* prime the data phase */ - if ((fsl_req_to_dtd(req, GFP_ATOMIC) == 0)) + if ((fsl_req_to_dtd(udc, req, GFP_ATOMIC) == 0)) fsl_queue_td(ep, req); else/* no mem */ goto stall; @@ -1422,7 +1424,7 @@ static void setup_received_irq(struct fsl_udc *udc, udc_reset_ep_queue(udc, 0); - /* We process some stardard setup requests here */ + /* We process some standard setup requests here
[PATCH 4/7] usb: gadget: fsl_udc: drop ARCH dependency
Drop the big-/little-endian helpers and make use of generic writel()/readl() routines. Signed-off-by: Christoph Fritz --- drivers/usb/gadget/fsl_udc_core.c | 331 + 1 files changed, 118 insertions(+), 213 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index d113f39..53df9c0 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -20,32 +20,14 @@ #undef VERBOSE #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include -#include #include #include #include #include #include #include -#include - -#include -#include -#include -#include #include "fsl_usb2_udc.h" @@ -74,78 +56,6 @@ fsl_ep0_desc = { static void fsl_ep_fifo_flush(struct usb_ep *_ep); -#ifdef CONFIG_PPC32 -/* - * On some SoCs, the USB controller registers can be big or little endian, - * depending on the version of the chip. In order to be able to run the - * same kernel binary on 2 different versions of an SoC, the BE/LE decision - * must be made at run time. _fsl_readl and fsl_writel are pointers to the - * BE or LE readl() and writel() functions, and fsl_readl() and fsl_writel() - * call through those pointers. Platform code for SoCs that have BE USB - * registers should set pdata->big_endian_mmio flag. - * - * This also applies to controller-to-cpu accessors for the USB descriptors, - * since their endianness is also SoC dependant. Platform code for SoCs that - * have BE USB descriptors should set pdata->big_endian_desc flag. - */ -static u32 _fsl_readl_be(const unsigned __iomem *p) -{ - return in_be32(p); -} - -static u32 _fsl_readl_le(const unsigned __iomem *p) -{ - return in_le32(p); -} - -static void _fsl_writel_be(u32 v, unsigned __iomem *p) -{ - out_be32(p, v); -} - -static void _fsl_writel_le(u32 v, unsigned __iomem *p) -{ - out_le32(p, v); -} - -static u32 (*_fsl_readl)(const unsigned __iomem *p); -static void (*_fsl_writel)(u32 v, unsigned __iomem *p); - -#define fsl_readl(p) (*_fsl_readl)((p)) -#define fsl_writel(v, p) (*_fsl_writel)((v), (p)) - -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) -{ - if (pdata->big_endian_mmio) { - _fsl_readl = _fsl_readl_be; - _fsl_writel = _fsl_writel_be; - } else { - _fsl_readl = _fsl_readl_le; - _fsl_writel = _fsl_writel_le; - } -} - -static inline u32 cpu_to_hc32(const u32 x) -{ - return udc_controller->pdata->big_endian_desc - ? (__force u32)cpu_to_be32(x) - : (__force u32)cpu_to_le32(x); -} - -static inline u32 hc32_to_cpu(const u32 x) -{ - return udc_controller->pdata->big_endian_desc - ? be32_to_cpu((__force __be32)x) - : le32_to_cpu((__force __le32)x); -} -#else /* !CONFIG_PPC32 */ -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {} - -#define fsl_readl(addr)readl(addr) -#define fsl_writel(val32, addr) writel(val32, addr) -#define cpu_to_hc32(x) cpu_to_le32(x) -#define hc32_to_cpu(x) le32_to_cpu(x) -#endif /* CONFIG_PPC32 */ / * Internal Used Function @@ -248,7 +158,7 @@ static int dr_controller_setup(struct fsl_udc *udc) #define FSL_UDC_RESET_TIMEOUT 1000 /* Config PHY interface */ - portctrl = fsl_readl(&dr_regs->portsc1); + portctrl = readl(&dr_regs->portsc1); portctrl &= ~(PORTSCX_PHY_TYPE_SEL | PORTSCX_PORT_WIDTH); switch (udc->phy_mode) { case FSL_USB2_PHY_ULPI: @@ -286,20 +196,20 @@ static int dr_controller_setup(struct fsl_udc *udc) default: return -EINVAL; } - fsl_writel(portctrl, &dr_regs->portsc1); + writel(portctrl, &dr_regs->portsc1); /* Stop and reset the usb controller */ - tmp = fsl_readl(&dr_regs->usbcmd); + tmp = readl(&dr_regs->usbcmd); tmp &= ~USB_CMD_RUN_STOP; - fsl_writel(tmp, &dr_regs->usbcmd); + writel(tmp, &dr_regs->usbcmd); - tmp = fsl_readl(&dr_regs->usbcmd); + tmp = readl(&dr_regs->usbcmd); tmp |= USB_CMD_CTRL_RESET; - fsl_writel(tmp, &dr_regs->usbcmd); + writel(tmp, &dr_regs->usbcmd); /* Wait for reset to complete */ timeout = jiffies + FSL_UDC_RESET_TIMEOUT; - while (fsl_readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { + while (readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { if (time_after(jiffies, timeout)) { ERR("udc reset timeout!\n"); return -ETIMEDOUT; @@ -308,33 +218,33 @@ static int dr_controller_setup(struct fsl_udc *udc) } /* Set the controller as device mode */ - tmp = fsl_readl(&dr_regs->us
[PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD
USB controller may access a wrong address for the dTD (endpoint transfer descriptor) and then hang. This happens a lot when doing tests with g_ether module and iperf, a tool for measuring maximum TCP and UDP bandwidth. This hardware bug is explained in detail by errata number 2858 for i.MX23: http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf All (?) SOCs with an IP from chipidea suffer from this problem. mv_udc_core fixes this bug by commit daec765. There still may be unfixed drivers. Signed-off-by: Christoph Fritz Signed-off-by: Christian Hemp Reviewed-by: Peter Chen --- drivers/usb/gadget/fsl_udc_core.c | 12 +++- drivers/usb/gadget/fsl_usb2_udc.h |2 ++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 53df9c0..deaab62 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -88,8 +88,13 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status) curr_td = next_td; if (j != req->dtd_count - 1) { next_td = curr_td->next_td_virt; + dma_pool_free(udc->td_pool, curr_td, curr_td->td_dma); + } else { + if (udc->last_free_td != NULL) + dma_pool_free(udc->td_pool, udc->last_free_td, + udc->last_free_td->td_dma); + udc->last_free_td = curr_td; } - dma_pool_free(udc->td_pool, curr_td, curr_td->td_dma); } if (req->mapped) { @@ -2439,6 +2444,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) udc->gadget.speed = USB_SPEED_UNKNOWN; udc->gadget.name = driver_name; udc->vbus_active = true; + udc->last_free_td = NULL; /* Setup gadget.dev and register with kernel */ dev_set_name(&udc->gadget.dev, "gadget"); @@ -2533,6 +2539,10 @@ static int __exit fsl_udc_remove(struct platform_device *pdev) kfree(udc->status_req); kfree(udc->eps); + if (udc->last_free_td != NULL) + dma_pool_free(udc->td_pool, udc->last_free_td, + udc->last_free_td->td_dma); + dma_pool_destroy(udc->td_pool); free_irq(udc->irq, udc); iounmap(dr_regs); diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index f61a967..a0123ae 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h @@ -497,6 +497,8 @@ struct fsl_udc { size_t ep_qh_size; /* size after alignment adjustment*/ dma_addr_t ep_qh_dma; /* dma address of QH */ + struct ep_td_struct *last_free_td; + u32 max_pipes; /* Device max pipes */ u32 bus_reset; /* Device is bus resetting */ u32 resume_state; /* USB state to resume */ -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/7] usb: gadget: fsl_udc: purge global pointer usb_sys_regs
Move global driver pointer usb_sys_regs to private struct fsl_udc. Signed-off-by: Christoph Fritz Reviewed-by: Teresa Gamez --- drivers/usb/gadget/fsl_udc_core.c | 26 -- drivers/usb/gadget/fsl_usb2_udc.h |1 + 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index deaab62..35ebcd4 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -43,8 +43,6 @@ static const char driver_desc[] = DRIVER_DESC; static struct usb_dr_device *dr_regs; -static struct usb_sys_interface *usb_sys_regs; - static const struct usb_endpoint_descriptor fsl_ep0_desc = { .bLength = USB_DT_ENDPOINT_SIZE, @@ -170,10 +168,10 @@ static int dr_controller_setup(struct fsl_udc *udc) if (udc->pdata->have_sysif_regs) { if (udc->pdata->controller_ver) { /* controller version 1.6 or above */ - ctrl = __raw_readl(&usb_sys_regs->control); + ctrl = readl(&udc->usb_sys_regs->control); ctrl &= ~USB_CTRL_UTMI_PHY_EN; ctrl |= USB_CTRL_USB_EN; - __raw_writel(ctrl, &usb_sys_regs->control); + writel(ctrl, &udc->usb_sys_regs->control); } } portctrl |= PORTSCX_PTS_ULPI; @@ -185,10 +183,10 @@ static int dr_controller_setup(struct fsl_udc *udc) if (udc->pdata->have_sysif_regs) { if (udc->pdata->controller_ver) { /* controller version 1.6 or above */ - ctrl = __raw_readl(&usb_sys_regs->control); + ctrl = readl(&udc->usb_sys_regs->control); ctrl |= (USB_CTRL_UTMI_PHY_EN | USB_CTRL_USB_EN); - __raw_writel(ctrl, &usb_sys_regs->control); + writel(ctrl, &udc->usb_sys_regs->control); mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to become stable - 10ms*/ } @@ -254,9 +252,9 @@ static int dr_controller_setup(struct fsl_udc *udc) /* Config control enable i/o output, cpu endian register */ #ifndef CONFIG_ARCH_MXC if (udc->pdata->have_sysif_regs) { - ctrl = __raw_readl(&usb_sys_regs->control); + ctrl = readl(&udc->usb_sys_regs->control); ctrl |= USB_CTRL_IOENB; - __raw_writel(ctrl, &usb_sys_regs->control); + writel(ctrl, &udc->usb_sys_regs->control); } #endif @@ -267,9 +265,9 @@ static int dr_controller_setup(struct fsl_udc *udc) if (udc->pdata->have_sysif_regs) { /* Setup Snooping for all the 4GB space */ tmp = SNOOP_SIZE_2GB; /* starts from 0x0, size 2G */ - __raw_writel(tmp, &usb_sys_regs->snoop1); + writel(tmp, &udc->usb_sys_regs->snoop1); tmp |= 0x8000; /* starts from 0x800, size 2G */ - __raw_writel(tmp, &usb_sys_regs->snoop2); + writel(tmp, &udc->usb_sys_regs->snoop2); } #endif @@ -326,7 +324,7 @@ static void dr_controller_stop(struct fsl_udc *udc) udc->stopped = 1; /* disable IO output */ -/* usb_sys_regs->control = 0; */ +/* udc->usb_sys_regs->control = 0; */ /* set controller to Stop */ tmp = readl(&dr_regs->usbcmd); @@ -2130,12 +2128,12 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, #ifndef CONFIG_ARCH_MXC if (udc->pdata->have_sysif_regs) { - tmp_reg = usb_sys_regs->snoop1; + tmp_reg = udc->usb_sys_regs->snoop1; t = scnprintf(next, size, "Snoop1 Reg : = [0x%x]\n\n", tmp_reg); size -= t; next += t; - tmp_reg = usb_sys_regs->control; + tmp_reg = udc->usb_sys_regs->control; t = scnprintf(next, size, "General Control Reg : = [0x%x]\n\n", tmp_reg); size -= t; @@ -2388,7 +2386,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) #ifndef CONFIG_ARCH_MXC if (pdata->have_sysif_regs) - usb_sys_regs = (void *)dr_regs + USB_DR_SYS_OFFSET; + udc->usb_sys_regs = (void *)dr_regs + USB_DR_SYS_OFFSET; #endif /* Initialize USB clocks */ diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index a0123ae..0d888f4 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h @@ -498,6 +498,7 @@ struct fsl_udc { dma_addr_t ep_
[PATCH 7/7] usb: gadget: fsl_udc: purge global pointer dr_regs
Move global driver pointer dr_regs to private struct fsl_udc. Signed-off-by: Christoph Fritz --- drivers/usb/gadget/fsl_udc_core.c | 252 +++-- drivers/usb/gadget/fsl_usb2_udc.h |1 + 2 files changed, 130 insertions(+), 123 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 35ebcd4..f9c4eb9 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -41,8 +41,6 @@ static const char driver_name[] = DRIVER_NAME; static const char driver_desc[] = DRIVER_DESC; -static struct usb_dr_device *dr_regs; - static const struct usb_endpoint_descriptor fsl_ep0_desc = { .bLength = USB_DT_ENDPOINT_SIZE, @@ -161,7 +159,7 @@ static int dr_controller_setup(struct fsl_udc *udc) #define FSL_UDC_RESET_TIMEOUT 1000 /* Config PHY interface */ - portctrl = readl(&dr_regs->portsc1); + portctrl = readl(&udc->dr_regs->portsc1); portctrl &= ~(PORTSCX_PHY_TYPE_SEL | PORTSCX_PORT_WIDTH); switch (udc->phy_mode) { case FSL_USB2_PHY_ULPI: @@ -199,20 +197,20 @@ static int dr_controller_setup(struct fsl_udc *udc) default: return -EINVAL; } - writel(portctrl, &dr_regs->portsc1); + writel(portctrl, &udc->dr_regs->portsc1); /* Stop and reset the usb controller */ - tmp = readl(&dr_regs->usbcmd); + tmp = readl(&udc->dr_regs->usbcmd); tmp &= ~USB_CMD_RUN_STOP; - writel(tmp, &dr_regs->usbcmd); + writel(tmp, &udc->dr_regs->usbcmd); - tmp = readl(&dr_regs->usbcmd); + tmp = readl(&udc->dr_regs->usbcmd); tmp |= USB_CMD_CTRL_RESET; - writel(tmp, &dr_regs->usbcmd); + writel(tmp, &udc->dr_regs->usbcmd); /* Wait for reset to complete */ timeout = jiffies + FSL_UDC_RESET_TIMEOUT; - while (readl(&dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { + while (readl(&udc->dr_regs->usbcmd) & USB_CMD_CTRL_RESET) { if (time_after(jiffies, timeout)) { ERR("udc reset timeout!\n"); return -ETIMEDOUT; @@ -221,33 +219,33 @@ static int dr_controller_setup(struct fsl_udc *udc) } /* Set the controller as device mode */ - tmp = readl(&dr_regs->usbmode); + tmp = readl(&udc->dr_regs->usbmode); tmp &= ~USB_MODE_CTRL_MODE_MASK;/* clear mode bits */ tmp |= USB_MODE_CTRL_MODE_DEVICE; /* Disable Setup Lockout */ tmp |= USB_MODE_SETUP_LOCK_OFF; if (udc->pdata->es) tmp |= USB_MODE_ES; - writel(tmp, &dr_regs->usbmode); + writel(tmp, &udc->dr_regs->usbmode); /* Clear the setup status */ - writel(0, &dr_regs->usbsts); + writel(0, &udc->dr_regs->usbsts); tmp = udc->ep_qh_dma; tmp &= USB_EP_LIST_ADDRESS_MASK; - writel(tmp, &dr_regs->endpointlistaddr); + writel(tmp, &udc->dr_regs->endpointlistaddr); VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x", udc->ep_qh, (int)tmp, - readl(&dr_regs->endpointlistaddr)); + readl(&udc->dr_regs->endpointlistaddr)); - max_no_of_ep = (0x001F & readl(&dr_regs->dccparams)); + max_no_of_ep = (0x001F & readl(&udc->dr_regs->dccparams)); for (ep_num = 1; ep_num < max_no_of_ep; ep_num++) { - tmp = readl(&dr_regs->endptctrl[ep_num]); + tmp = readl(&udc->dr_regs->endptctrl[ep_num]); tmp &= ~(EPCTRL_TX_TYPE | EPCTRL_RX_TYPE); tmp |= (EPCTRL_EP_TYPE_BULK << EPCTRL_TX_EP_TYPE_SHIFT) | (EPCTRL_EP_TYPE_BULK << EPCTRL_RX_EP_TYPE_SHIFT); - writel(tmp, &dr_regs->endptctrl[ep_num]); + writel(tmp, &udc->dr_regs->endptctrl[ep_num]); } /* Config control enable i/o output, cpu endian register */ #ifndef CONFIG_ARCH_MXC @@ -284,20 +282,20 @@ static void dr_controller_run(struct fsl_udc *udc) | USB_INTR_PTC_DETECT_EN | USB_INTR_RESET_EN | USB_INTR_DEVICE_SUSPEND | USB_INTR_SYS_ERR_EN; - writel(temp, &dr_regs->usbintr); + writel(temp, &udc->dr_regs->usbintr); /* Clear stopped bit */ udc->stopped = 0; /* Set the controller as device mode */ - temp = readl(&dr_regs->usbmode); + temp = readl(&udc->dr_regs->usbmode); temp |= USB_MODE_CTRL_MODE_DEVICE; - writel(temp, &dr_regs->usbmode); + writel(temp, &udc->dr_regs->usbmode); /* Set controller to Run */ - temp = readl(&dr_regs->usbcmd); + temp = readl(&udc->dr_regs->usbcmd); temp |= USB_CMD_RUN_STOP; - writel(temp, &dr_regs->usbcmd); + writel(temp, &udc->dr_regs->usbcmd); } static void dr_controller_stop(struct fsl_udc *udc) @@ -311,14 +309,14 @@ static void dr_controller_stop(struct fsl_udc *udc) * ehci driver
Re: [PATCH 1/7] usb: gadget: fsl_udc: simplify driver init
Hi, On Fri, Oct 19, 2012 at 12:24:39PM +0200, Christoph Fritz wrote: > To initialize this driver use 'module_platform_driver' instead > of '__init' and '__exit'. > > Signed-off-by: Christoph Fritz > --- > drivers/usb/gadget/fsl_udc_core.c | 37 > +++-- > 1 files changed, 11 insertions(+), 26 deletions(-) > > diff --git a/drivers/usb/gadget/fsl_udc_core.c > b/drivers/usb/gadget/fsl_udc_core.c > index 6ae70cb..340451d 100644 > --- a/drivers/usb/gadget/fsl_udc_core.c > +++ b/drivers/usb/gadget/fsl_udc_core.c > @@ -49,13 +49,14 @@ > > #include "fsl_usb2_udc.h" > > +#define DRIVER_NAME "fsl-usb2-udc" > #define DRIVER_DESC "Freescale High-Speed USB SOC Device Controller > driver" > #define DRIVER_AUTHOR "Li Yang/Jiang Bo" > #define DRIVER_VERSION "Apr 20, 2007" > > #define DMA_ADDR_INVALID(~(dma_addr_t)0) > > -static const char driver_name[] = "fsl-usb2-udc"; > +static const char driver_name[] = DRIVER_NAME; > static const char driver_desc[] = DRIVER_DESC; > > static struct usb_dr_device *dr_regs; > @@ -2761,35 +2762,19 @@ static int fsl_udc_otg_resume(struct device *dev) > Register entry point for the peripheral controller driver > --*/ > > -static struct platform_driver udc_driver = { > - .remove = __exit_p(fsl_udc_remove), > - /* these suspend and resume are not usb suspend and resume */ > - .suspend = fsl_udc_suspend, > - .resume = fsl_udc_resume, > - .driver = { > - .name = (char *)driver_name, > - .owner = THIS_MODULE, > - /* udc suspend/resume called from OTG driver */ > +static struct platform_driver fsl_udc_driver = { > + .probe = fsl_udc_probe, NAK, probe() lies in .init.text section. You need to change __init to __devinit. Likewise for all functions which are only called during probe() and for remove() which needs s/__exit/__devexit. -- balbi signature.asc Description: Digital signature
Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
Alexey Orishko writes: > On Fri, Oct 19, 2012 at 11:30 AM, Bjørn Mork wrote: >> Bjørn Mork writes: >>> Alexey Orishko writes: >>> >> OK, I did some more experiments, and I am wondering if the real firmware >> problem is in the MBIM descriptor. It is >> >> CDC MBIM: >> bcdMBIMVersion 1.00 >> wMaxControlMessage 1536 >> bNumberFilters 16 >> bMaxFilterSize 40 >> wMaxSegmentSize 4096 >> bmNetworkCapabilities 0x20 >> 8-byte ntb input size >> >> >> so we use the 8-byte version of USB_CDC_SET_NTB_INPUT_SIZE, which fails >> with -EPIPE. But forcing the 4-byte version seems to work. Hmm, I also >> see that the device returns 4 bytes in response to at >> USB_CDC_GET_NTB_INPUT_SIZE with an 8-byte buffer. Maybe we can >> auto-quirk based on that? I.e., if USB_CDC_GET_NTB_INPUT_SIZE returns >> only 4 bytes then we assume that the bmNetworkCapabilities flag is >> wrong. >> >> Is that acceptable? Then it seems we are able to inform this device of >> the reduced buffer, and the other problems can be ignored. >> > > Based on NCM errata, NCM functional descriptor: if Bit 5 is set, then > device can (must) handle 8-byte form of Set/GetNtbInputSize. Yes, and this flag is copied with the same requirements in MBIM. So it is definitely a firmware bug. > If they set a flag, but don't support the feature, hm.. is it a > prototype device or > commercially available one? The firmware is not commercially availabe AFAIK, but based on experience I believe we should assume that any firmware bug ever seen will live forever. There are likely other devices with the same bug even if this firmware and this device, and all other devices from the same vendor, are fixed. I believe the problem here is that the USB descriptors are somewhat decoupled from the firmware functions. The firmware functions are usually implemented in firmware originating from the chipset vendor, while the descriptors are up to the device vendor. This has led to interesting situations before. But for us, I believe it means that we should put more trust in the responses to control messages than in functional descriptors. So if we can detect a mismatch like this one, then we do that and use the control message. > At least device must support Set request, but for GetNtbInputSize we > could happily > live without wNtbInMaxDatagrams (i.e. use 4 byte variant) on Linux. > Since we must anyway receive a complete NTB and making any number of skb > buffers from received NTB is not a problem at all. Yes, it doesn't matter to us whether we get the 8 byte variant or not. We are prepared to handle the 4 byte variant in any case, if the functional descriptor flag is not set. So I believe a fallback to 4 byte should not pose any problem. The only difference will be that we need to do the USB_CDC_GET_NTB_INPUT_SIZE to detect the bug in the first place. I'll cook up an alternative patch implementing this so you can evaluate the impact. Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock
Hi, On Fri, Oct 19, 2012 at 12:24:40PM +0200, Christoph Fritz wrote: > This patch reworks fsl_pullup() against the background of switching over > to udc_start()/udc_stop() style: > > Protect function fsl_pullup() with a spin_lock. Also set vbus_active as > default to true. This prevents disabling USB controller if there is no the vbus_active part should be in a separate patch as it has no relation with $SUBJECT > driver support for an external transceiver (or GPIO) that detects a VBUS > power session starting. > > Signed-off-by: Christoph Fritz > --- > drivers/usb/gadget/fsl_udc_core.c |4 > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/drivers/usb/gadget/fsl_udc_core.c > b/drivers/usb/gadget/fsl_udc_core.c > index 340451d..0a0d6a6 100644 > --- a/drivers/usb/gadget/fsl_udc_core.c > +++ b/drivers/usb/gadget/fsl_udc_core.c > @@ -1242,8 +1242,10 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, > unsigned mA) > static int fsl_pullup(struct usb_gadget *gadget, int is_on) > { > struct fsl_udc *udc; > + unsigned long flags; > > udc = container_of(gadget, struct fsl_udc, gadget); > + spin_lock_irqsave(&udc->lock, flags); > udc->softconnect = (is_on != 0); > if (can_pullup(udc)) > fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), > @@ -1251,6 +1253,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int > is_on) > else > fsl_writel((fsl_readl(&dr_regs->usbcmd) & ~USB_CMD_RUN_STOP), > &dr_regs->usbcmd); > + spin_unlock_irqrestore(&udc->lock, flags); > > return 0; > } > @@ -2557,6 +2560,7 @@ static int __init fsl_udc_probe(struct platform_device > *pdev) > INIT_LIST_HEAD(&udc_controller->gadget.ep_list); > udc_controller->gadget.speed = USB_SPEED_UNKNOWN; > udc_controller->gadget.name = driver_name; > + udc->vbus_active = true; > > /* Setup gadget.dev and register with kernel */ > dev_set_name(&udc_controller->gadget.dev, "gadget"); > -- > 1.7.2.5 > -- balbi signature.asc Description: Digital signature
Re: [PATCH 3/7] usb: gadget: fsl_udc: convert to new ulc style
Hi, typo on Subject. Should be udc, not ulc. On Fri, Oct 19, 2012 at 12:24:41PM +0200, Christoph Fritz wrote: > Convert to new UDC style registration and remove > global 'udc_controller' pointer. > > Signed-off-by: Christoph Fritz > --- > drivers/usb/gadget/fsl_udc_core.c | 289 > + > 1 files changed, 131 insertions(+), 158 deletions(-) > > diff --git a/drivers/usb/gadget/fsl_udc_core.c > b/drivers/usb/gadget/fsl_udc_core.c > index 0a0d6a6..d113f39 100644 > --- a/drivers/usb/gadget/fsl_udc_core.c > +++ b/drivers/usb/gadget/fsl_udc_core.c > @@ -63,9 +63,6 @@ static struct usb_dr_device *dr_regs; > > static struct usb_sys_interface *usb_sys_regs; > > -/* it is initialized in probe() */ > -static struct fsl_udc *udc_controller = NULL; > - > static const struct usb_endpoint_descriptor > fsl_ep0_desc = { > .bLength = USB_DT_ENDPOINT_SIZE, > @@ -783,12 +780,14 @@ static void fsl_queue_td(struct fsl_ep *ep, struct > fsl_req *req) > } > > /* Fill in the dTD structure > + * @udc: driver private data > * @req: request that the transfer belongs to > * @length: return actually data length of the dTD > * @dma: return dma address of the dTD > * @is_last: return flag if it is the last dTD of the request > * return: pointer to the built dTD */ > -static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned > *length, > +static struct ep_td_struct *fsl_build_dtd(struct fsl_udc *udc, > + struct fsl_req *req, unsigned *length, > dma_addr_t *dma, int *is_last, gfp_t gfp_flags) I would split this patch a little. First I would patch the missing arguments to these functions under the excuse that a later patch will get rid of the udc_controller pointer, then the next patch would do the conversion to new style. It will be a lot easier to review ;-) > { > u32 swap_temp; > @@ -798,7 +797,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req > *req, unsigned *length, > *length = min(req->req.length - req->req.actual, > (unsigned)EP_MAX_LENGTH_TRANSFER); > > - dtd = dma_pool_alloc(udc_controller->td_pool, gfp_flags, dma); > + dtd = dma_pool_alloc(udc->td_pool, gfp_flags, dma); > if (dtd == NULL) > return dtd; > > @@ -848,7 +847,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req > *req, unsigned *length, > } > > /* Generate dtd chain for a request */ > -static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags) > +static int fsl_req_to_dtd(struct fsl_udc *udc, struct fsl_req *req, > + gfp_t gfp_flags) > { > unsignedcount; > int is_last; > @@ -857,7 +857,8 @@ static int fsl_req_to_dtd(struct fsl_req *req, gfp_t > gfp_flags) > dma_addr_t dma; > > do { > - dtd = fsl_build_dtd(req, &count, &dma, &is_last, gfp_flags); > + dtd = fsl_build_dtd(udc, req, &count, &dma, &is_last, > + gfp_flags); > if (dtd == NULL) > return -ENOMEM; > > @@ -932,7 +933,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request > *_req, gfp_t gfp_flags) > req->dtd_count = 0; > > /* build dtds and push them to device queue */ > - if (!fsl_req_to_dtd(req, gfp_flags)) { > + if (!fsl_req_to_dtd(udc, req, gfp_flags)) { > spin_lock_irqsave(&udc->lock, flags); > fsl_queue_td(ep, req); > } else { > @@ -1258,9 +1259,10 @@ static int fsl_pullup(struct usb_gadget *gadget, int > is_on) > return 0; > } > > -static int fsl_start(struct usb_gadget_driver *driver, > - int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); > -static int fsl_stop(struct usb_gadget_driver *driver); > +static int fsl_udc_start(struct usb_gadget *gadget, > + struct usb_gadget_driver *driver); > +static int fsl_udc_stop(struct usb_gadget *gadget, > + struct usb_gadget_driver *driver); > /* defined in gadget.h */ > static struct usb_gadget_ops fsl_gadget_ops = { > .get_frame = fsl_get_frame, > @@ -1269,8 +1271,8 @@ static struct usb_gadget_ops fsl_gadget_ops = { > .vbus_session = fsl_vbus_session, > .vbus_draw = fsl_vbus_draw, > .pullup = fsl_pullup, > - .start = fsl_start, > - .stop = fsl_stop, > + .udc_start = fsl_udc_start, > + .udc_stop = fsl_udc_stop, > }; > > /* Set protocol stall on ep0, protocol stall will automatically be cleared > @@ -1314,7 +1316,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int > direction) > ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); > req->mapped = 1; > > - if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0) > + if (fsl_req_to_dtd(udc, req, GFP_ATOMIC) == 0) > fsl_queue_td(ep, req); > else > return -ENOMEM; > @@ -1398,7 +1400,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8
[PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. In order to support USB PHY drivers on these SoCs, existing PHY driver is split into SoC agnostic common USB PHY driver and Tegra20-specific USB phy driver. This will facilitate easy addition and deletion of phy drivers for Tegra SoCs. Signed-off-by: Venu Byravarasu --- delta from v3: Rebased the v3 changes on top of xceiv branch. delta from v2: Added an if condition to check for device_node to be not NULL, before dereferencing it. --- drivers/usb/host/ehci-tegra.c | 20 +- drivers/usb/phy/Makefile |1 + .../usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} | 372 ++- drivers/usb/phy/tegra2_usb_phy.h | 178 + drivers/usb/phy/tegra_usb_phy.c| 725 +--- include/linux/usb/tegra_usb_phy.h | 34 +- 6 files changed, 304 insertions(+), 1026 deletions(-) copy drivers/usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} (57%) create mode 100644 drivers/usb/phy/tegra2_usb_phy.h diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 6223d17..e08aea3 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) int err = 0; int irq; int instance = pdev->id; + struct device_node *np = pdev->dev.of_node; + struct phy_params params; + int phy_type; pdata = pdev->dev.platform_data; if (!pdata) { @@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device *pdev) } } + phy_type = of_property_match_string(np, "phy_type", "utmi"); + if (phy_type >= 0) + params.type = TEGRA_USB_PHY_TYPE_UTMI; + else { + phy_type = of_property_match_string(np, "phy_type", "ulpi"); + if (phy_type >= 0) + params.type = TEGRA_USB_PHY_TYPE_ULPI; + else + params.type = TEGRA_USB_PHY_TYPE_INVALID; + } + + params.mode = TEGRA_USB_PHY_MODE_HOST; + params.config = pdata->phy_config; + tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs, - pdata->phy_config, - TEGRA_USB_PHY_MODE_HOST); + ¶ms); if (IS_ERR(tegra->phy)) { dev_err(&pdev->dev, "Failed to open USB phy\n"); err = -ENXIO; diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index b069f29..21872e1 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o obj-$(CONFIG_USB_ISP1301) += isp1301.o obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o +obj-$(CONFIG_USB_EHCI_TEGRA) += tegra2_usb_phy.o diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra2_usb_phy.c similarity index 57% copy from drivers/usb/phy/tegra_usb_phy.c copy to drivers/usb/phy/tegra2_usb_phy.c index 9d13c81..2ff6dcb 100644 --- a/drivers/usb/phy/tegra_usb_phy.c +++ b/drivers/usb/phy/tegra2_usb_phy.c @@ -1,9 +1,11 @@ /* * Copyright (C) 2010 Google, Inc. + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. * * Author: * Erik Gilling * Benoit Goby + * Venu Byravarasu * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -29,191 +31,20 @@ #include #include #include +#include -#define TEGRA_USB_BASE 0xC500 -#define TEGRA_USB_SIZE SZ_16K - -#define ULPI_VIEWPORT 0x170 - -#define USB_PORTSC10x184 -#define USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) -#define USB_PORTSC1_PSPD(x) (((x) & 0x3) << 26) -#define USB_PORTSC1_PHCD (1 << 23) -#define USB_PORTSC1_WKOC (1 << 22) -#define USB_PORTSC1_WKDS (1 << 21) -#define USB_PORTSC1_WKCN (1 << 20) -#define USB_PORTSC1_PTC(x) (((x) & 0xf) << 16) -#define USB_PORTSC1_PP (1 << 12) -#define USB_PORTSC1_SUSP (1 << 7) -#define USB_PORTSC1_PE (1 << 2) -#define USB_PORTSC1_CCS (1 << 0) - -#define USB_SUSP_CTRL 0x400 -#define USB_WAKE_ON_CNNT_EN_DEV (1 << 3) -#define USB_WAKE_ON_DISCON_EN_DEV(1 << 4) -#define USB_SUSP_CLR (1 << 5) -#define USB_PHY_CLK_VALID(1 << 7) -#define UTMIP_RESET (1 << 11) -#define UHSIC_RESET (1 << 11) -#define UTMIP_PHY_ENABLE (1 << 12) -#define ULPI_PHY_ENABLE (1 << 13) -#define USB_SUSP_SET (1 << 14) -#define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16) - -#define USB1_LEGACY_CTRL 0x410 -#define USB1_NO_LEGACY_MODE (1 << 0) -#define U
Re: [PATCH 4/7] usb: gadget: fsl_udc: drop ARCH dependency
On Fri, Oct 19, 2012 at 12:24:42PM +0200, Christoph Fritz wrote: > Drop the big-/little-endian helpers and make use of generic > writel()/readl() routines. > > Signed-off-by: Christoph Fritz > --- > drivers/usb/gadget/fsl_udc_core.c | 331 > + > 1 files changed, 118 insertions(+), 213 deletions(-) > > diff --git a/drivers/usb/gadget/fsl_udc_core.c > b/drivers/usb/gadget/fsl_udc_core.c > index d113f39..53df9c0 100644 > --- a/drivers/usb/gadget/fsl_udc_core.c > +++ b/drivers/usb/gadget/fsl_udc_core.c > @@ -20,32 +20,14 @@ > #undef VERBOSE > > #include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include you don't mention removal of these registers anywhere. Why are you doing this ? Are those really unnecessary or are you now depending on indirect inclusion of the headers ? Also, $SUBJECT is a bit misleading since you don't touch Kconfig to actually drop the ARCH dependency. Maybe rephrase $SUBJECT a little ? > #include > #include > -#include > -#include > -#include > -#include > #include > #include > #include > #include > #include > #include > -#include > - > -#include > -#include > -#include > -#include > > #include "fsl_usb2_udc.h" > > @@ -74,78 +56,6 @@ fsl_ep0_desc = { > > static void fsl_ep_fifo_flush(struct usb_ep *_ep); > > -#ifdef CONFIG_PPC32 > -/* > - * On some SoCs, the USB controller registers can be big or little endian, > - * depending on the version of the chip. In order to be able to run the > - * same kernel binary on 2 different versions of an SoC, the BE/LE decision > - * must be made at run time. _fsl_readl and fsl_writel are pointers to the > - * BE or LE readl() and writel() functions, and fsl_readl() and fsl_writel() > - * call through those pointers. Platform code for SoCs that have BE USB > - * registers should set pdata->big_endian_mmio flag. > - * > - * This also applies to controller-to-cpu accessors for the USB descriptors, > - * since their endianness is also SoC dependant. Platform code for SoCs that > - * have BE USB descriptors should set pdata->big_endian_desc flag. > - */ > -static u32 _fsl_readl_be(const unsigned __iomem *p) > -{ > - return in_be32(p); > -} > - > -static u32 _fsl_readl_le(const unsigned __iomem *p) > -{ > - return in_le32(p); > -} > - > -static void _fsl_writel_be(u32 v, unsigned __iomem *p) > -{ > - out_be32(p, v); > -} > - > -static void _fsl_writel_le(u32 v, unsigned __iomem *p) > -{ > - out_le32(p, v); > -} > - > -static u32 (*_fsl_readl)(const unsigned __iomem *p); > -static void (*_fsl_writel)(u32 v, unsigned __iomem *p); > - > -#define fsl_readl(p) (*_fsl_readl)((p)) > -#define fsl_writel(v, p) (*_fsl_writel)((v), (p)) > - > -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) > -{ > - if (pdata->big_endian_mmio) { > - _fsl_readl = _fsl_readl_be; > - _fsl_writel = _fsl_writel_be; > - } else { > - _fsl_readl = _fsl_readl_le; > - _fsl_writel = _fsl_writel_le; > - } > -} > - > -static inline u32 cpu_to_hc32(const u32 x) > -{ > - return udc_controller->pdata->big_endian_desc > - ? (__force u32)cpu_to_be32(x) > - : (__force u32)cpu_to_le32(x); > -} > - > -static inline u32 hc32_to_cpu(const u32 x) > -{ > - return udc_controller->pdata->big_endian_desc > - ? be32_to_cpu((__force __be32)x) > - : le32_to_cpu((__force __le32)x); > -} > -#else /* !CONFIG_PPC32 */ > -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {} > - > -#define fsl_readl(addr) readl(addr) > -#define fsl_writel(val32, addr) writel(val32, addr) > -#define cpu_to_hc32(x) cpu_to_le32(x) > -#define hc32_to_cpu(x) le32_to_cpu(x) > -#endif /* CONFIG_PPC32 */ > > / > * Internal Used Function > @@ -248,7 +158,7 @@ static int dr_controller_setup(struct fsl_udc *udc) > #define FSL_UDC_RESET_TIMEOUT 1000 > > /* Config PHY interface */ > - portctrl = fsl_readl(&dr_regs->portsc1); > + portctrl = readl(&dr_regs->portsc1); > portctrl &= ~(PORTSCX_PHY_TYPE_SEL | PORTSCX_PORT_WIDTH); > switch (udc->phy_mode) { > case FSL_USB2_PHY_ULPI: > @@ -286,20 +196,20 @@ static int dr_controller_setup(struct fsl_udc *udc) > default: > return -EINVAL; > } > - fsl_writel(portctrl, &dr_regs->portsc1); > + writel(portctrl, &dr_regs->portsc1); > > /* Stop and reset the usb controller */ > - tmp = fsl_readl(&dr_regs->usbcmd); > + tmp = readl(&dr_regs->usbcmd); > tmp &= ~USB_CMD_RUN_STOP; > - fsl_writel(tmp, &dr_regs->usbcmd); > + writel(tmp, &dr_regs->usbcmd); > > - tmp = fsl_readl(&dr_regs->usbcmd); > + tmp = readl(&dr_regs->usbcmd); > tmp |= USB_CMD_CTRL_RESET; > - fs
Re: [PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD
On Fri, Oct 19, 2012 at 12:24:43PM +0200, Christoph Fritz wrote: > USB controller may access a wrong address for the dTD (endpoint transfer > descriptor) and then hang. This happens a lot when doing tests with > g_ether module and iperf, a tool for measuring maximum TCP and UDP > bandwidth. > > This hardware bug is explained in detail by errata number 2858 for i.MX23: > http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf > > All (?) SOCs with an IP from chipidea suffer from this problem. > mv_udc_core fixes this bug by commit daec765. There still may be > unfixed drivers. why aren't you using that driver instead ? Is it really necessary to keep this driver around ? I would really like to see uniformization towards that, if you use the same IP, then the same driver ought to suffice. What's the reason for not using drivers/usb/chipidea ? -- balbi signature.asc Description: Digital signature
Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
Hi, On Fri, Oct 19, 2012 at 04:03:26PM +0530, Venu Byravarasu wrote: > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. > In order to support USB PHY drivers on these SoCs, existing > PHY driver is split into SoC agnostic common USB PHY driver > and Tegra20-specific USB phy driver. This will facilitate > easy addition and deletion of phy drivers for Tegra SoCs. > > Signed-off-by: Venu Byravarasu you mail ID is wrong here... > --- > delta from v3: > > Rebased the v3 changes on top of xceiv branch. > > delta from v2: > > Added an if condition to check for device_node to be not NULL, > before dereferencing it. > --- > drivers/usb/host/ehci-tegra.c | 20 +- > drivers/usb/phy/Makefile |1 + > .../usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} | 372 ++- > drivers/usb/phy/tegra2_usb_phy.h | 178 + > drivers/usb/phy/tegra_usb_phy.c| 725 > +--- > include/linux/usb/tegra_usb_phy.h | 34 +- > 6 files changed, 304 insertions(+), 1026 deletions(-) > copy drivers/usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} (57%) > create mode 100644 drivers/usb/phy/tegra2_usb_phy.h > > diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c > index 6223d17..e08aea3 100644 > --- a/drivers/usb/host/ehci-tegra.c > +++ b/drivers/usb/host/ehci-tegra.c > @@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) > int err = 0; > int irq; > int instance = pdev->id; > + struct device_node *np = pdev->dev.of_node; > + struct phy_params params; > + int phy_type; > > pdata = pdev->dev.platform_data; > if (!pdata) { > @@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device *pdev) > } > } > > + phy_type = of_property_match_string(np, "phy_type", "utmi"); > + if (phy_type >= 0) > + params.type = TEGRA_USB_PHY_TYPE_UTMI; > + else { > + phy_type = of_property_match_string(np, "phy_type", "ulpi"); > + if (phy_type >= 0) > + params.type = TEGRA_USB_PHY_TYPE_ULPI; > + else > + params.type = TEGRA_USB_PHY_TYPE_INVALID; > + } > + > + params.mode = TEGRA_USB_PHY_MODE_HOST; > + params.config = pdata->phy_config; > + > tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs, > - pdata->phy_config, > - TEGRA_USB_PHY_MODE_HOST); > + ¶ms); > if (IS_ERR(tegra->phy)) { > dev_err(&pdev->dev, "Failed to open USB phy\n"); > err = -ENXIO; Alan, if you're ok with the ehci-tegra changes, I can carry this patch by myself. > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > index b069f29..21872e1 100644 > --- a/drivers/usb/phy/Makefile > +++ b/drivers/usb/phy/Makefile > @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o > obj-$(CONFIG_USB_ISP1301)+= isp1301.o > obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o > obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o > +obj-$(CONFIG_USB_EHCI_TEGRA) += tegra2_usb_phy.o > diff --git a/drivers/usb/phy/tegra_usb_phy.c > b/drivers/usb/phy/tegra2_usb_phy.c > similarity index 57% > copy from drivers/usb/phy/tegra_usb_phy.c > copy to drivers/usb/phy/tegra2_usb_phy.c > index 9d13c81..2ff6dcb 100644 > --- a/drivers/usb/phy/tegra_usb_phy.c > +++ b/drivers/usb/phy/tegra2_usb_phy.c > @@ -1,9 +1,11 @@ > /* > * Copyright (C) 2010 Google, Inc. > + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. > * > * Author: > * Erik Gilling > * Benoit Goby > + * Venu Byravarasu > * > * This software is licensed under the terms of the GNU General Public > * License version 2, as published by the Free Software Foundation, and > @@ -29,191 +31,20 @@ > #include > #include > #include > +#include > > -#define TEGRA_USB_BASE 0xC500 > -#define TEGRA_USB_SIZE SZ_16K > - > -#define ULPI_VIEWPORT0x170 > - > -#define USB_PORTSC1 0x184 > -#define USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) > -#define USB_PORTSC1_PSPD(x)(((x) & 0x3) << 26) > -#define USB_PORTSC1_PHCD (1 << 23) > -#define USB_PORTSC1_WKOC (1 << 22) > -#define USB_PORTSC1_WKDS (1 << 21) > -#define USB_PORTSC1_WKCN (1 << 20) > -#define USB_PORTSC1_PTC(x) (((x) & 0xf) << 16) > -#define USB_PORTSC1_PP (1 << 12) > -#define USB_PORTSC1_SUSP (1 << 7) > -#define USB_PORTSC1_PE (1 << 2) > -#define USB_PORTSC1_CCS(1 << 0) > - > -#define USB_SUSP_CTRL0x400 > -#define USB_WAKE_ON_CNNT_EN_DEV(1 << 3) > -#define USB_WAKE_ON_DISCON_EN_DEV (1 << 4) > -#define USB_SUSP_CLR (1 << 5) > -#define USB_PHY_CLK_VALID (1 << 7) > -#define UTMIP_RESET
[PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. In order to support USB PHY drivers on these SoCs, existing PHY driver is split into SoC agnostic common USB PHY driver and Tegra20-specific USB phy driver. This will facilitate easy addition and deletion of phy drivers for Tegra SoCs. Signed-off-by: Venu Byravarasu --- delta from v3 resend: For unknown reasons, email-id in signed-off-by got corrupted. Hence re-sending the patch, after fixing it. delta from v3: Rebased the v3 changes on top of xceiv branch. delta from v2: Added an if condition to check for device_node to be not NULL, before dereferencing it. drivers/usb/host/ehci-tegra.c | 20 +- drivers/usb/phy/Makefile |1 + .../usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} | 372 ++- drivers/usb/phy/tegra2_usb_phy.h | 178 + drivers/usb/phy/tegra_usb_phy.c| 725 +--- include/linux/usb/tegra_usb_phy.h | 34 +- 6 files changed, 304 insertions(+), 1026 deletions(-) copy drivers/usb/phy/{tegra_usb_phy.c => tegra2_usb_phy.c} (57%) create mode 100644 drivers/usb/phy/tegra2_usb_phy.h diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 6223d17..e08aea3 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) int err = 0; int irq; int instance = pdev->id; + struct device_node *np = pdev->dev.of_node; + struct phy_params params; + int phy_type; pdata = pdev->dev.platform_data; if (!pdata) { @@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device *pdev) } } + phy_type = of_property_match_string(np, "phy_type", "utmi"); + if (phy_type >= 0) + params.type = TEGRA_USB_PHY_TYPE_UTMI; + else { + phy_type = of_property_match_string(np, "phy_type", "ulpi"); + if (phy_type >= 0) + params.type = TEGRA_USB_PHY_TYPE_ULPI; + else + params.type = TEGRA_USB_PHY_TYPE_INVALID; + } + + params.mode = TEGRA_USB_PHY_MODE_HOST; + params.config = pdata->phy_config; + tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs, - pdata->phy_config, - TEGRA_USB_PHY_MODE_HOST); + ¶ms); if (IS_ERR(tegra->phy)) { dev_err(&pdev->dev, "Failed to open USB phy\n"); err = -ENXIO; diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index b069f29..21872e1 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o obj-$(CONFIG_USB_ISP1301) += isp1301.o obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o +obj-$(CONFIG_USB_EHCI_TEGRA) += tegra2_usb_phy.o diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra2_usb_phy.c similarity index 57% copy from drivers/usb/phy/tegra_usb_phy.c copy to drivers/usb/phy/tegra2_usb_phy.c index 9d13c81..2ff6dcb 100644 --- a/drivers/usb/phy/tegra_usb_phy.c +++ b/drivers/usb/phy/tegra2_usb_phy.c @@ -1,9 +1,11 @@ /* * Copyright (C) 2010 Google, Inc. + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. * * Author: * Erik Gilling * Benoit Goby + * Venu Byravarasu * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -29,191 +31,20 @@ #include #include #include +#include -#define TEGRA_USB_BASE 0xC500 -#define TEGRA_USB_SIZE SZ_16K - -#define ULPI_VIEWPORT 0x170 - -#define USB_PORTSC10x184 -#define USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) -#define USB_PORTSC1_PSPD(x) (((x) & 0x3) << 26) -#define USB_PORTSC1_PHCD (1 << 23) -#define USB_PORTSC1_WKOC (1 << 22) -#define USB_PORTSC1_WKDS (1 << 21) -#define USB_PORTSC1_WKCN (1 << 20) -#define USB_PORTSC1_PTC(x) (((x) & 0xf) << 16) -#define USB_PORTSC1_PP (1 << 12) -#define USB_PORTSC1_SUSP (1 << 7) -#define USB_PORTSC1_PE (1 << 2) -#define USB_PORTSC1_CCS (1 << 0) - -#define USB_SUSP_CTRL 0x400 -#define USB_WAKE_ON_CNNT_EN_DEV (1 << 3) -#define USB_WAKE_ON_DISCON_EN_DEV(1 << 4) -#define USB_SUSP_CLR (1 << 5) -#define USB_PHY_CLK_VALID(1 << 7) -#define UTMIP_RESET (1 << 11) -#define UHSIC_RESET (1 << 11) -#define UTMIP_PHY_ENABLE (1 << 12) -#define ULPI_PHY_ENABLE (1 << 13) -#define USB_SUSP_SET (1 << 14) -#define USB_WAKEUP_DEBOUNCE_COUNT(x) (((
Re: [PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD
On Fri, 2012-10-19 at 13:30 +0300, Felipe Balbi wrote: > On Fri, Oct 19, 2012 at 12:24:43PM +0200, Christoph Fritz wrote: > > USB controller may access a wrong address for the dTD (endpoint transfer > > descriptor) and then hang. This happens a lot when doing tests with > > g_ether module and iperf, a tool for measuring maximum TCP and UDP > > bandwidth. > > > > This hardware bug is explained in detail by errata number 2858 for i.MX23: > > http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf > > > > All (?) SOCs with an IP from chipidea suffer from this problem. > > mv_udc_core fixes this bug by commit daec765. There still may be > > unfixed drivers. > > why aren't you using that driver instead ? Is it really necessary to > keep this driver around ? I would really like to see uniformization > towards that, if you use the same IP, then the same driver ought to > suffice. > > What's the reason for not using drivers/usb/chipidea ? > I thought about this too but wasn't able to use chipidea with MXC_EHCI_INTERNAL_PHY as it's called in fsl_udc. Sascha, do you know if i.mx35 works with usb/chipidea? Thanks -- Christoph -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD
Hi, On Fri, Oct 19, 2012 at 12:46:48PM +0200, Christoph Fritz wrote: > On Fri, 2012-10-19 at 13:30 +0300, Felipe Balbi wrote: > > On Fri, Oct 19, 2012 at 12:24:43PM +0200, Christoph Fritz wrote: > > > USB controller may access a wrong address for the dTD (endpoint transfer > > > descriptor) and then hang. This happens a lot when doing tests with > > > g_ether module and iperf, a tool for measuring maximum TCP and UDP > > > bandwidth. > > > > > > This hardware bug is explained in detail by errata number 2858 for i.MX23: > > > http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf > > > > > > All (?) SOCs with an IP from chipidea suffer from this problem. > > > mv_udc_core fixes this bug by commit daec765. There still may be > > > unfixed drivers. > > > > why aren't you using that driver instead ? Is it really necessary to > > keep this driver around ? I would really like to see uniformization > > towards that, if you use the same IP, then the same driver ought to > > suffice. > > > > What's the reason for not using drivers/usb/chipidea ? > > > > I thought about this too but wasn't able to use chipidea with > MXC_EHCI_INTERNAL_PHY as it's called in fsl_udc. that's a matter of writing the PHY driver, right ;-) It has nothing to do with chipidea, actually :-) -- balbi signature.asc Description: Digital signature
[RFC] net: cdc_ncm: workaround NTB input size firmware bug
Some devices do not support the 8 byte variants of the NTB input size control messages despite announcing such support in the functional descriptor. This can be detected by reading the current input size, looking at how many bytes the device returns. Signed-off-by: Bjørn Mork --- Bjørn Mork writes: > I'll cook up an alternative patch implementing this so you can evaluate > the impact. So how about something like this? I couldn't help myself not combining the two paths here while at it. But I have intentionally not done the other obvious cleanups, like using the standard timeout constants and using dev_xxx for instead of pr_xxx, because they must and should be done separately over the whole driver. This works for me: Oct 19 13:19:43 nemi kernel: [304987.350138] dwNtbInMaxSize=131072 dwNtbOutMaxSize=32768 wNdpOutPayloadRemainder=0 wNdpOutDivisor=4 wNdpOutAlignment=4 wNtbOutMaxDatagrams=0 flags=0x20 Oct 19 13:19:43 nemi kernel: [304987.350144] Using default maximum receive length=32768 Oct 19 13:19:43 nemi kernel: [304987.350507] firmware bug: flags=0x20, but USB_CDC_GET_NTB_INPUT_SIZE returned 4 bytes Bjørn drivers/net/usb/cdc_ncm.c | 64 +++-- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 4cd582a..26d31d7 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -215,44 +215,46 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx) /* inform device about NTB input size changes */ if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) { + struct usb_cdc_ncm_ndp_input_size *ndp_in_sz; + size_t request_len = 4; + ndp_in_sz = kzalloc(sizeof(*ndp_in_sz), GFP_KERNEL); + if (!ndp_in_sz) { + err = -ENOMEM; + goto size_err; + } if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) { - struct usb_cdc_ncm_ndp_input_size *ndp_in_sz; - - ndp_in_sz = kzalloc(sizeof(*ndp_in_sz), GFP_KERNEL); - if (!ndp_in_sz) { - err = -ENOMEM; - goto size_err; - } - err = usb_control_msg(ctx->udev, - usb_sndctrlpipe(ctx->udev, 0), - USB_CDC_SET_NTB_INPUT_SIZE, - USB_TYPE_CLASS | USB_DIR_OUT -| USB_RECIP_INTERFACE, - 0, iface_no, ndp_in_sz, 8, 1000); - kfree(ndp_in_sz); - } else { - __le32 *dwNtbInMaxSize; - dwNtbInMaxSize = kzalloc(sizeof(*dwNtbInMaxSize), - GFP_KERNEL); - if (!dwNtbInMaxSize) { - err = -ENOMEM; - goto size_err; + usb_rcvctrlpipe(ctx->udev, 0), + USB_CDC_GET_NTB_INPUT_SIZE, + USB_TYPE_CLASS | USB_DIR_OUT + | USB_RECIP_INTERFACE, + 0, iface_no, ndp_in_sz, 8, 1000); + switch (err) { + case 4: + pr_debug("firmware bug: flags=0x%02x, but USB_CDC_GET_NTB_INPUT_SIZE returned 4 bytes\n", flags); + break; + case 8: + /* bmNetworkCapabilities is correct */ + request_len = 8; + break; + default: + goto size_err_free; } - *dwNtbInMaxSize = cpu_to_le32(ctx->rx_max); - - err = usb_control_msg(ctx->udev, - usb_sndctrlpipe(ctx->udev, 0), - USB_CDC_SET_NTB_INPUT_SIZE, - USB_TYPE_CLASS | USB_DIR_OUT -| USB_RECIP_INTERFACE, - 0, iface_no, dwNtbInMaxSize, 4, 1000); - kfree(dwNtbInMaxSize); } + ndp_in_sz->dwNtbInMaxSize = cpu_to_le32(ctx->rx_max); + ndp_in_sz->wNtbInMaxDatagrams = 0; /* unlimited */ + err = usb_control_msg(ctx->udev, + usb_sndctrlpipe(ctx->udev, 0), + USB_CDC_SET_NTB_INPUT_SIZE, + USB_TYPE_CLASS | USB_DIR_OUT + | USB_REC
Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
Alexey Orishko writes: > Based on NCM errata, NCM functional descriptor: if Bit 5 is set, then > device can (must) handle 8-byte form of Set/GetNtbInputSize. > If they set a flag, but don't support the feature, hm.. is it a > prototype device or > commercially available one? > > At least device must support Set request, but for GetNtbInputSize we > could happily > live without wNtbInMaxDatagrams (i.e. use 4 byte variant) on Linux. > Since we must anyway receive a complete NTB and making any number of skb > buffers from received NTB is not a problem at all. OK, I may have misunderstood you here. Quoting the errata text: If bit D5 is set in the bmNetworkCapabilities field of function’s NCM Functional Descriptor, the host may set wLength either to 4 or to 8. If wLength is 4, the function shall assume that wNtbInMaxDatagrams is to be set to zero. If wLength is 8, then the function shall use the provided value as the limit. The function shall return an error response (a STALL PID) if wLength is set to any other value. So the 4 byte variant is always supported and we might as well just use it unconditionally because we don't set, or need to set, the wNtbInMaxDatagrams. Is that right? It will simplify the code even more without any loss of functionality, except for the possibility of failing on some other buggy device not supporting the 4 byte variant... Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] USB: whiteheat: fix memory leak in error path
Make sure command buffer is deallocated in case of errors during attach. Cc: Signed-off-by: Johan Hovold --- drivers/usb/serial/whiteheat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 346c7ef..cfd155e 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -333,6 +333,7 @@ no_firmware: "%s: please contact supp...@connecttech.com\n", serial->type->description); kfree(result); + kfree(command); return -ENODEV; no_command_private: -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] USB: metro-usb: fix port-data memory leak
Fix port-data memory leak by moving port data allocation and deallocation to port_probe and port_remove. Since commit 0998d0631001288 (device-core: Ensure drvdata = NULL when no driver is bound) the port private data is no longer freed at release as it is no longer accessible. Note that the call to metrousb_clean (close) in shutdown was redundant. Compile-only tested. Cc: Signed-off-by: Johan Hovold --- drivers/usb/serial/metro-usb.c | 50 +++--- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 0b257dd..25cb97c 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c @@ -271,51 +271,27 @@ static int metrousb_set_modem_ctrl(struct usb_serial *serial, unsigned int contr return retval; } -static void metrousb_shutdown(struct usb_serial *serial) +static int metrousb_port_probe(struct usb_serial_port *port) { - int i = 0; + struct metrousb_private *metro_priv; - dev_dbg(&serial->dev->dev, "%s\n", __func__); + metro_priv = kzalloc(sizeof(*metro_priv), GFP_KERNEL); + if (!metro_priv) + return -ENOMEM; - /* Stop reading and writing on all ports. */ - for (i = 0; i < serial->num_ports; ++i) { - /* Close any open urbs. */ - metrousb_cleanup(serial->port[i]); + spin_lock_init(&metro_priv->lock); - /* Free memory. */ - kfree(usb_get_serial_port_data(serial->port[i])); - usb_set_serial_port_data(serial->port[i], NULL); + usb_set_serial_port_data(port, metro_priv); - dev_dbg(&serial->dev->dev, "%s - freed port number=%d\n", - __func__, serial->port[i]->number); - } + return 0; } -static int metrousb_startup(struct usb_serial *serial) +static int metrousb_port_remove(struct usb_serial_port *port) { struct metrousb_private *metro_priv; - struct usb_serial_port *port; - int i = 0; - - dev_dbg(&serial->dev->dev, "%s\n", __func__); - /* Loop through the serial ports setting up the private structures. -* Currently we only use one port. */ - for (i = 0; i < serial->num_ports; ++i) { - port = serial->port[i]; - - /* Declare memory. */ - metro_priv = kzalloc(sizeof(struct metrousb_private), GFP_KERNEL); - if (!metro_priv) - return -ENOMEM; - - /* Initialize memory. */ - spin_lock_init(&metro_priv->lock); - usb_set_serial_port_data(port, metro_priv); - - dev_dbg(&serial->dev->dev, "%s - port number=%d\n ", - __func__, port->number); - } + metro_priv = usb_get_serial_port_data(port); + kfree(metro_priv); return 0; } @@ -414,8 +390,8 @@ static struct usb_serial_driver metrousb_device = { .close = metrousb_cleanup, .read_int_callback = metrousb_read_int_callback, .write_int_callback = metrousb_write_int_callback, - .attach = metrousb_startup, - .release= metrousb_shutdown, + .port_probe = metrousb_port_probe, + .port_remove= metrousb_port_remove, .throttle = metrousb_throttle, .unthrottle = metrousb_unthrottle, .tiocmget = metrousb_tiocmget, -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] USB: whiteheat: fix port-data memory leak
Fix port-data memory leak by moving port data allocation and deallocation to port_probe and port_remove. Since commit 0998d0631001288 (device-core: Ensure drvdata = NULL when no driver is bound) the port private data is no longer freed at release as it is no longer accessible. Note that the fifth port (command port) is never registered as a port device and thus should be handled in attach and release. Compile-only tested. Cc: Signed-off-by: Johan Hovold --- drivers/usb/serial/whiteheat.c | 59 +++--- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index cfd155e..b9fca35 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -83,6 +83,8 @@ static int whiteheat_firmware_attach(struct usb_serial *serial); /* function prototypes for the Connect Tech WhiteHEAT serial converter */ static int whiteheat_attach(struct usb_serial *serial); static void whiteheat_release(struct usb_serial *serial); +static int whiteheat_port_probe(struct usb_serial_port *port); +static int whiteheat_port_remove(struct usb_serial_port *port); static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port); static void whiteheat_close(struct usb_serial_port *port); @@ -117,6 +119,8 @@ static struct usb_serial_driver whiteheat_device = { .num_ports =4, .attach = whiteheat_attach, .release = whiteheat_release, + .port_probe = whiteheat_port_probe, + .port_remove = whiteheat_port_remove, .open = whiteheat_open, .close =whiteheat_close, .ioctl =whiteheat_ioctl, @@ -218,15 +222,12 @@ static int whiteheat_attach(struct usb_serial *serial) { struct usb_serial_port *command_port; struct whiteheat_command_private *command_info; - struct usb_serial_port *port; - struct whiteheat_private *info; struct whiteheat_hw_info *hw_info; int pipe; int ret; int alen; __u8 *command; __u8 *result; - int i; command_port = serial->port[COMMAND_PORT]; @@ -285,22 +286,6 @@ static int whiteheat_attach(struct usb_serial *serial) serial->type->description, hw_info->sw_major_rev, hw_info->sw_minor_rev); - for (i = 0; i < serial->num_ports; i++) { - port = serial->port[i]; - - info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); - if (info == NULL) { - dev_err(&port->dev, - "%s: Out of memory for port structures\n", - serial->type->description); - goto no_private; - } - - info->mcr = 0; - - usb_set_serial_port_data(port, info); - } - command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); if (command_info == NULL) { @@ -337,13 +322,6 @@ no_firmware: return -ENODEV; no_command_private: - for (i = serial->num_ports - 1; i >= 0; i--) { - port = serial->port[i]; - info = usb_get_serial_port_data(port); - kfree(info); -no_private: - ; - } kfree(result); no_result_buffer: kfree(command); @@ -351,21 +329,36 @@ no_command_buffer: return -ENOMEM; } - static void whiteheat_release(struct usb_serial *serial) { struct usb_serial_port *command_port; - struct whiteheat_private *info; - int i; /* free up our private data for our command port */ command_port = serial->port[COMMAND_PORT]; kfree(usb_get_serial_port_data(command_port)); +} - for (i = 0; i < serial->num_ports; i++) { - info = usb_get_serial_port_data(serial->port[i]); - kfree(info); - } +static int whiteheat_port_probe(struct usb_serial_port *port) +{ + struct whiteheat_private *info; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + usb_set_serial_port_data(port, info); + + return 0; +} + +static int whiteheat_port_remove(struct usb_serial_port *port) +{ + struct whiteheat_private *info; + + info = usb_get_serial_port_data(port); + kfree(info); + + return 0; } static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port) -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/4] USB: metro-usb: fix io after disconnect
Make sure no control urb is submitted during close after a disconnect by checking the disconnected flag. Cc: Signed-off-by: Johan Hovold --- drivers/usb/serial/metro-usb.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 25cb97c..6f29c74 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c @@ -179,16 +179,13 @@ static void metrousb_cleanup(struct usb_serial_port *port) { dev_dbg(&port->dev, "%s\n", __func__); - if (port->serial->dev) { - /* Shutdown any interrupt in urbs. */ - if (port->interrupt_in_urb) { - usb_unlink_urb(port->interrupt_in_urb); - usb_kill_urb(port->interrupt_in_urb); - } - - /* Send deactivate cmd to device */ + usb_unlink_urb(port->interrupt_in_urb); + usb_kill_urb(port->interrupt_in_urb); + + mutex_lock(&port->serial->disc_mutex); + if (!port->serial->disconnected) metrousb_send_unidirectional_cmd(UNI_CMD_CLOSE, port); - } + mutex_unlock(&port->serial->disc_mutex); } static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port) -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
On Fri, Oct 19, 2012 at 2:18 PM, Bjørn Mork wrote: > > OK, I may have misunderstood you here. Quoting the errata text: > > > If bit D5 is set in the bmNetworkCapabilities field of function’s NCM > Functional Descriptor, the host may set wLength either to 4 or to > 8. If wLength is 4, the function shall assume that wNtbInMaxDatagrams > is to be set to zero. If wLength is 8, then the function shall use the > provided value as the limit. The function shall return an error > response (a STALL PID) if wLength is set to any other value. > > > So the 4 byte variant is always supported and we might as well just use > it unconditionally because we don't set, or need to set, the > wNtbInMaxDatagrams. > > Is that right? It will simplify the code even more without any loss of > functionality, except for the possibility of failing on some other buggy > device not supporting the 4 byte variant... Agree, since 4-byte version must be supported by all devices, we can drop 8-byte variant /alexey -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 02/14] net: cdc_ncm: use device rx_max value if update failed
Alexey Orishko writes: > On Fri, Oct 19, 2012 at 2:18 PM, Bjørn Mork wrote: >> >> OK, I may have misunderstood you here. Quoting the errata text: >> >> >> If bit D5 is set in the bmNetworkCapabilities field of function’s NCM >> Functional Descriptor, the host may set wLength either to 4 or to >> 8. If wLength is 4, the function shall assume that wNtbInMaxDatagrams >> is to be set to zero. If wLength is 8, then the function shall use the >> provided value as the limit. The function shall return an error >> response (a STALL PID) if wLength is set to any other value. >> >> >> So the 4 byte variant is always supported and we might as well just use >> it unconditionally because we don't set, or need to set, the >> wNtbInMaxDatagrams. >> >> Is that right? It will simplify the code even more without any loss of >> functionality, except for the possibility of failing on some other buggy >> device not supporting the 4 byte variant... > > Agree, since 4-byte version must be supported by all devices, > we can drop 8-byte variant Thanks. I'll implement that in the next version then, and drop the first patch as it is no longer needed. But I will hold off posting the updated series for a few more days to allow you all some time to digest the rest of this. There should be more issues to comment on here than this simple firmware bug workaround ;-) Bjørn -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: question regarding delay between bus states in EHCI driver
On Fri, 19 Oct 2012, Pavan Kondeti wrote: > Why are we having this check in ehci_suspend()? By the time > ehci_suspend() is called, ehci_bus_suspend() is already called in > which next_statechange is updated. we might end up giving 10msec delay > in ehci_suspend(). Yes. I don't know the reason for the check in ehci_suspend; I didn't write it originally. Probably we can get rid of the checks in ehci_suspend and ehci_resume. I don't know of any reason why a controller can't be switched back to full power immediately after going to low power. > why is 100 msec delay in ehci_resume? ehci_bus_resume has only 5 msec delay. It's probably a typo. > > Would you like to write a patch to do this? > > > > I will submit a patch next week. Okay, good. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
On Fri, 19 Oct 2012, Venu Byravarasu wrote: > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. > In order to support USB PHY drivers on these SoCs, existing > PHY driver is split into SoC agnostic common USB PHY driver > and Tegra20-specific USB phy driver. This will facilitate > easy addition and deletion of phy drivers for Tegra SoCs. > > Signed-off-by: Venu Byravarasu > --- > delta from v3 resend: > For unknown reasons, email-id in signed-off-by got corrupted. > Hence re-sending the patch, after fixing it. > > delta from v3: > Rebased the v3 changes on top of xceiv branch. > > delta from v2: > Added an if condition to check for device_node to be not NULL, > before dereferencing it. For the changes to drivers/usb/host/ehci-tegra.c: Acked-by: Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] USB: digi_acceleport: fix port-data memory leak
Fix port-data memory leak by moving port data deallocation to port_remove for regular ports. Since commit 0998d0631001288 (device-core: Ensure drvdata = NULL when no driver is bound) the port private data is no longer freed at release as it is no longer accessible. Note that the oob port is never registered as a port device and it's port data should thus be dellocated in release as before. Compile-only tested. Cc: Signed-off-by: Johan Hovold --- drivers/usb/serial/digi_acceleport.c | 26 -- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index c86f68c..d94bff4 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -244,6 +244,7 @@ static int digi_startup_device(struct usb_serial *serial); static int digi_startup(struct usb_serial *serial); static void digi_disconnect(struct usb_serial *serial); static void digi_release(struct usb_serial *serial); +static int digi_port_remove(struct usb_serial_port *port); static void digi_read_bulk_callback(struct urb *urb); static int digi_read_inb_callback(struct urb *urb); static int digi_read_oob_callback(struct urb *urb); @@ -294,6 +295,7 @@ static struct usb_serial_driver digi_acceleport_2_device = { .attach = digi_startup, .disconnect = digi_disconnect, .release = digi_release, + .port_remove = digi_port_remove, }; static struct usb_serial_driver digi_acceleport_4_device = { @@ -320,6 +322,7 @@ static struct usb_serial_driver digi_acceleport_4_device = { .attach = digi_startup, .disconnect = digi_disconnect, .release = digi_release, + .port_remove = digi_port_remove, }; static struct usb_serial_driver * const serial_drivers[] = { @@ -1313,15 +1316,26 @@ static void digi_disconnect(struct usb_serial *serial) static void digi_release(struct usb_serial *serial) { - int i; + struct digi_serial *serial_priv; + struct digi_port *priv; - /* free the private data structures for all ports */ - /* number of regular ports + 1 for the out-of-band port */ - for (i = 0; i < serial->type->num_ports + 1; i++) - kfree(usb_get_serial_port_data(serial->port[i])); - kfree(usb_get_serial_data(serial)); + serial_priv = usb_get_serial_data(serial); + + priv = usb_get_serial_port_data(serial_priv->ds_oob_port); + kfree(priv); + + kfree(serial_priv); } +static int digi_port_remove(struct usb_serial_port *port) +{ + struct digi_port *priv; + + priv = usb_get_serial_port_data(port); + kfree(priv); + + return 0; +} static void digi_read_bulk_callback(struct urb *urb) { -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] USB: ch341: fix port-data memory leak
Fix port-data memory leak by moving port data allocation to port_probe and actually implementing deallocation. Note that this driver has never even bothered to try to deallocate it's port data... Compile-only tested. Cc: Signed-off-by: Johan Hovold --- drivers/usb/serial/ch341.c | 23 --- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index e9c7046..d255f66 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -242,13 +242,11 @@ out: kfree(buffer); return r; } -/* allocate private data */ -static int ch341_attach(struct usb_serial *serial) +static int ch341_port_probe(struct usb_serial_port *port) { struct ch341_private *priv; int r; - /* private data */ priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -258,17 +256,27 @@ static int ch341_attach(struct usb_serial *serial) priv->baud_rate = DEFAULT_BAUD_RATE; priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; - r = ch341_configure(serial->dev, priv); + r = ch341_configure(port->serial->dev, priv); if (r < 0) goto error; - usb_set_serial_port_data(serial->port[0], priv); + usb_set_serial_port_data(port, priv); return 0; error: kfree(priv); return r; } +static int ch341_port_remove(struct usb_serial_port *port) +{ + struct ch341_private *priv; + + priv = usb_get_serial_port_data(port); + kfree(priv); + + return 0; +} + static int ch341_carrier_raised(struct usb_serial_port *port) { struct ch341_private *priv = usb_get_serial_port_data(port); @@ -304,7 +312,7 @@ static void ch341_close(struct usb_serial_port *port) static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) { struct usb_serial *serial = port->serial; - struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); + struct ch341_private *priv = usb_get_serial_port_data(port); int r; priv->baud_rate = DEFAULT_BAUD_RATE; @@ -608,7 +616,8 @@ static struct usb_serial_driver ch341_device = { .tiocmget = ch341_tiocmget, .tiocmset = ch341_tiocmset, .read_int_callback = ch341_read_int_callback, - .attach= ch341_attach, + .port_probe= ch341_port_probe, + .port_remove = ch341_port_remove, .reset_resume = ch341_reset_resume, }; -- 1.7.12.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] USB: hub_for_each_child should skip unconnected ports
This patch (as1619) improves the interface to the "hub_for_each_child" macro. The name clearly suggests that the macro iterates over child devices; it does not suggest that the loop will also iterate over unnconnected ports. The patch changes the macro so that it will skip over unconnected ports and iterate only the actual child devices. The two existing call sites are updated to avoid testing for a NULL child pointer, which is now unnecessary. Signed-off-by: Alan Stern --- drivers/usb/core/devices.c | 18 -- drivers/usb/host/r8a66597-hcd.c |6 ++ include/linux/usb.h |5 +++-- 3 files changed, 13 insertions(+), 16 deletions(-) Index: usb-3.6/include/linux/usb.h === --- usb-3.6.orig/include/linux/usb.h +++ usb-3.6/include/linux/usb.h @@ -588,8 +588,9 @@ extern struct usb_device *usb_hub_find_c */ #define usb_hub_for_each_child(hdev, port1, child) \ for (port1 = 1, child = usb_hub_find_child(hdev, port1); \ - port1 <= hdev->maxchild; \ - child = usb_hub_find_child(hdev, ++port1)) + port1 <= hdev->maxchild; \ + child = usb_hub_find_child(hdev, ++port1)) \ + if (!child) continue; else /* USB device locking */ #define usb_lock_device(udev) device_lock(&(udev)->dev) Index: usb-3.6/drivers/usb/core/devices.c === --- usb-3.6.orig/drivers/usb/core/devices.c +++ usb-3.6/drivers/usb/core/devices.c @@ -591,16 +591,14 @@ static ssize_t usb_device_dump(char __us /* Now look at all of this device's children. */ usb_hub_for_each_child(usbdev, chix, childdev) { - if (childdev) { - usb_lock_device(childdev); - ret = usb_device_dump(buffer, nbytes, skip_bytes, - file_offset, childdev, bus, - level + 1, chix - 1, ++cnt); - usb_unlock_device(childdev); - if (ret == -EFAULT) - return total_written; - total_written += ret; - } + usb_lock_device(childdev); + ret = usb_device_dump(buffer, nbytes, skip_bytes, + file_offset, childdev, bus, + level + 1, chix - 1, ++cnt); + usb_unlock_device(childdev); + if (ret == -EFAULT) + return total_written; + total_written += ret; } return total_written; } Index: usb-3.6/drivers/usb/host/r8a66597-hcd.c === --- usb-3.6.orig/drivers/usb/host/r8a66597-hcd.c +++ usb-3.6/drivers/usb/host/r8a66597-hcd.c @@ -2036,10 +2036,8 @@ static void collect_usb_address_map(stru udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) map[udev->devnum/32] |= (1 << (udev->devnum % 32)); - usb_hub_for_each_child(udev, chix, childdev) { - if (childdev) - collect_usb_address_map(childdev, map); - } + usb_hub_for_each_child(udev, chix, childdev) + collect_usb_address_map(childdev, map); } /* this function must be called with interrupt disabled */ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] USB: speed up usb_bus_resume()
This patch (as1620) speeds up USB root-hub resumes in the common case where every enabled port has its suspend feature set (which currently will be true for every runtime resume of the root hub). If all the enabled ports are suspended then resuming the root hub won't resume any of the downstream devices. In this case there's no need for a Resume Recovery delay, because that delay is meant to give devices a chance to get ready for active use. To keep track of the port suspend features, the patch adds a "port_is_suspended" flag to struct usb_device. This has to be tracked separately from the device's state; it's entirely possible for a USB-2 device to be suspended while the suspend feature on its parent port is clear. The reason is that devices will go into suspend whenever their parent hub does. Signed-off-by: Alan Stern Reviewed-by: Peter Chen Tested-by: Peter Chen --- drivers/usb/core/hcd.c | 19 +-- drivers/usb/core/hub.c |2 ++ include/linux/usb.h|2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) Index: usb-3.6/include/linux/usb.h === --- usb-3.6.orig/include/linux/usb.h +++ usb-3.6/include/linux/usb.h @@ -482,6 +482,7 @@ struct usb3_lpm_parameters { * @connect_time: time device was first connected * @do_remote_wakeup: remote wakeup should be enabled * @reset_resume: needs reset instead of resume + * @port_is_suspended: the upstream port is suspended (L2 or U3) * @wusb_dev: if this is a Wireless USB device, link to the WUSB * specific data for the device. * @slot_id: Slot ID assigned by xHCI @@ -560,6 +561,7 @@ struct usb_device { unsigned do_remote_wakeup:1; unsigned reset_resume:1; + unsigned port_is_suspended:1; #endif struct wusb_dev *wusb_dev; int slot_id; Index: usb-3.6/drivers/usb/core/hub.c === --- usb-3.6.orig/drivers/usb/core/hub.c +++ usb-3.6/drivers/usb/core/hub.c @@ -2876,6 +2876,7 @@ int usb_port_suspend(struct usb_device * (PMSG_IS_AUTO(msg) ? "auto-" : ""), udev->do_remote_wakeup); usb_set_device_state(udev, USB_STATE_SUSPENDED); + udev->port_is_suspended = 1; msleep(10); } usb_mark_last_busy(hub->hdev); @@ -3040,6 +3041,7 @@ int usb_port_resume(struct usb_device *u SuspendCleared: if (status == 0) { + udev->port_is_suspended = 0; if (hub_is_superspeed(hub->hdev)) { if (portchange & USB_PORT_STAT_C_LINK_STATE) clear_port_feature(hub->hdev, port1, Index: usb-3.6/drivers/usb/core/hcd.c === --- usb-3.6.orig/drivers/usb/core/hcd.c +++ usb-3.6/drivers/usb/core/hcd.c @@ -2039,8 +2039,9 @@ int hcd_bus_resume(struct usb_device *rh status = hcd->driver->bus_resume(hcd); clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); if (status == 0) { - /* TRSMRCY = 10 msec */ - msleep(10); + struct usb_device *udev; + int port1; + spin_lock_irq(&hcd_root_hub_lock); if (!HCD_DEAD(hcd)) { usb_set_device_state(rhdev, rhdev->actconfig @@ -2050,6 +2051,20 @@ int hcd_bus_resume(struct usb_device *rh hcd->state = HC_STATE_RUNNING; } spin_unlock_irq(&hcd_root_hub_lock); + + /* +* Check whether any of the enabled ports on the root hub are +* unsuspended. If they are then a TRSMRCY delay is needed +* (this is what the USB-2 spec calls a "global resume"). +* Otherwise we can skip the delay. +*/ + usb_hub_for_each_child(rhdev, port1, udev) { + if (udev->state != USB_STATE_NOTATTACHED && + !udev->port_is_suspended) { + usleep_range(1, 11000); /* TRSMRCY */ + break; + } + } } else { hcd->state = old_state; dev_dbg(&rhdev->dev, "bus %s fail, err %d\n", -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC v3][PATCH 1/2] usb: gadget: Add USB Functions Gadget
Hi, On Thu, Oct 18, 2012 at 05:12:48PM +0200, Andrzej Pietrasiewicz wrote: > Hello Felipe, > > On Wednesday, October 17, 2012 3:56 PM Felipe Balbi wrote: > > > > > On Wed, Oct 17, 2012 at 11:43:11AM +0200, Andrzej Pietrasiewicz wrote: > > > Demonstrate a USB gadget configured entirely through configfs. > > > This is a work in progress. > > > > > > > > > > this is wrong. we don't want *another* gadget driver. We want to get rid > > of the ones we have. The end goal is to keep only f_* files in kernel. > > > > I definitely agree about f_* files. However, I think we need... something? > While Sebastian's recent patch series shows how to remove #include .c > lines from gadget code, it does not do anything about the gadgets in > the meaning that if we had e.g. g_zero module before, we _still_ have > the g_zero, _plus_ we have f_sourcesink and f_loopback modules. that's one step. We can't get to configfs-based gadget binding if we don't cleanup the problems we have now. > In other words, one must still insmod g_zero (f_sourcesink and f_loopback > being automatically requested), possibly setting some parameters like > vendor id, product id and so on. The g_zero here contains > a usb_composite_driver which, after it gets probed, takes one udc. > > I think what we want here is a possibility to configure multiple functions > in one gadget (under one udc, in other words). eventually, but not until we do the ground work/housekeeping to get there. We definitely don't want to hack something together which nobody will in the future. > So the "something" I mentioned earlier should be the place where the > usb_composite_driver is defined and probed. And I called this kind of > entity a "gadget". Any better name? > > Does this sound reasonable to you? Or do you think about something > completely different? Sorry but you seem to be way off :-s. I continue to say that we don't want any "temporary" solutions, we want to take all steps necessary towards our goal of deleting all g_* files and keeping only the functions in kernel. This means that will not accept a gadget driver which is built based on configfs, while that does the whole "configfs-based binding" it does it in the wrong way and I will not let that go into the kernel. If it takes two more merge windows to get to the end goal, so be it, but no temporary solutions meanwhile because "temporary" tends to last for at least 10 years in real life. cheers -- balbi signature.asc Description: Digital signature
Re: [PATCH 0/7] update USB gadget driver fsl-usb2-udc
Hi Christoph, What system are you working on? If it's i.MX you should use/work on the chipidea driver instead. Sascha On Fri, Oct 19, 2012 at 12:22:36PM +0200, Christoph Fritz wrote: > This series updates USB gadget driver fsl-usb2-udc. > > Christoph Fritz (7): > usb: gadget: fsl_udc: simplify driver init > usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock > usb: gadget: fsl_udc: convert to new ulc style > usb: gadget: fsl_udc: drop ARCH dependency > usb: gadget: fsl_udc: postpone freeing current dTD > usb: gadget: fsl_udc: purge global pointer usb_sys_regs > usb: gadget: fsl_udc: purge global pointer dr_regs > > drivers/usb/gadget/fsl_udc_core.c | 755 > - > drivers/usb/gadget/fsl_usb2_udc.h |4 + > 2 files changed, 322 insertions(+), 437 deletions(-) > > -- > 1.7.2.5 > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
Hi, On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote: > NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. > In order to support USB PHY drivers on these SoCs, existing > PHY driver is split into SoC agnostic common USB PHY driver > and Tegra20-specific USB phy driver. This will facilitate > easy addition and deletion of phy drivers for Tegra SoCs. > > Signed-off-by: Venu Byravarasu I was reading this "driver" more closely and I have a bunch of questions about it, but the most important of all of them is: "why isn't that a real PHY driver ?". It doesn't have a probe() function, it doesn't use struct usb_phy to represent the PHY, it has a bunch of tegra-specific APIs and we can't let those continue. Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually, should be phy-omap-usb2.c so we have a common prefix) to see how your PHY driver should look like and which sort of functionality if should expose to the rest of the kernel. Please comment on the above. cheers -- balbi signature.asc Description: Digital signature
Re: [RFC 3/4] usb: Send Set SEL before enabling parent U1/U2 timeout.
Hi, On Mon, Oct 08, 2012 at 03:47:35PM -0700, Sarah Sharp wrote: > On Mon, Oct 08, 2012 at 04:05:00PM -0400, Alan Stern wrote: > > On Mon, 8 Oct 2012, Sarah Sharp wrote: > > > > > The Set SEL control transfer tells a device the exit latencies > > > associated with a device-initated U1 or U2 exit. Since a parent hub may > > > initiate a transition to U1 soon after a downstream port's U1 timeout is > > > set, we need to make sure the device receives the Set SEL transfer > > > before the parent hub timeout is set. > > > > Just a question, not a comment on the patch. Why is "Set SEL" needed? > > Doesn't the device already know its own exit latencies? After all, the > > values come from descriptors that were originally provided by the > > device. > > The device knows its own exit latency, but it doesn't know the exit > latencies for the path above it. It could be directly attached to the > roothub (which may have a bigger exit latency than the device) or a > couple tiers deep in the tree. If the device wants to be smart about > when it requests to come out of U1 or U2, then it needs to know the > whole path exit latency. > > For example, maybe there's an interrupt endpoint on a self-powered radio > device. As soon as the device doesn't have any data to send, it > transmits an NRDY (Not Ready) response to the request for data. Then it > puts its link into U1 or U2 (or maybe the host controller does this when > the U1/U2 timeouts expire). > > Later, the device starts receiving a packet. Let's assume it takes some > time to process that packet. If the device knows how long it takes to > wake up the link and send an ERDY to the host, it can parallelize the > link wakeup and the packet processing. It doesn't want to send an ERDY > too soon, because the host could ask for the data before it's ready. So > the device needs to know the time it takes for the link to come out of > U1 or U2, the time it takes for the host to process the ERDY, and the > time it takes for the request for data to reach the device. That's what > the Set SEL request does. > > Of course, I'm not a USB device designer, so I don't know how the Set > SEL command is really used. Felipe, do we use it at all in any of the > Linux USB 3.0 gadget drivers? sorry for the delay. Currently we're not using Set SEL at all, but we could use, eventually, to pass it to pm_qos ?!? Just a thought. -- balbi signature.asc Description: Digital signature
Re: [PATCH v4 1/1] usb: phy: change phy notify functions
Hi, On Tue, Oct 16, 2012 at 09:36:46AM +0800, Peter Chen wrote: > The patch includes both API change and caller change. > The main changes like below: > > - add notify_suspend/notify_resume callback > > This let usb phy driver has the chance to change hw settings during > the controller suspend/resume procedure. > > Besides, old parameter "port" is useless for phy notify, as one usb > phy is only for one usb port. New parameter "speed" stands for > the device's speed which is on the port. > > - implement notify_suspend/notify_resume callback for mxs phy driver > These notify will be called during the bus suspend/resume procedure. > > - Add phy notify at suspend/resume procedure for chipidea host driver > > - refine phy notify operation during connection and disconnection > > The history of this problem like below: > At some i.mx SoCs, when controller works at host mode, the PHY > register needs to be changed at device connect, disconnect, bus > suspend and resume due to the SoC limitations. > > The phy notification should be added according to below rules: > > 1. Only set HW_USBPHY_CTRL.ENHOSTDISCONDETECT > during high speed host mode. > 2. Do not set HW_USBPHY_CTRL.ENHOSTDISCONDETECT > during the reset and speed negotiation period. > 3. Do not set HW_USBPHY_CTRL.ENHOSTDISCONDETECT > during host suspend/resume sequence. > > Please refer: i.mx23RM(page 413) for detail. > http://www.freescale.com/files/dsp/doc/ref_manual/IMX23RM.pdf > > Freescale i.MX SoC, i.mx23, i.mx28 and i.mx6(i.mx6SL does not > need to follow the 3rd rule) need to follow above rules. > > The correct notification setting method should be: > 1. Set connect notify after the second bus reset. > 2. Set disconnect notify after disconnection. > 3. Set suspend nofity after bus goes to suspend (portsc.suspendM=1). > 4. Set resume notify after resume (portsc.fpr=0). > > Signed-off-by: Peter Chen > Tested-by: Mike Thompson sorry but you're doing too much in a single patch. Please split the patch before I review it any further. cheers -- balbi signature.asc Description: Digital signature
Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
On 10/19/2012 09:35 AM, Felipe Balbi wrote: > Hi, > > On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote: >> NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc. In >> order to support USB PHY drivers on these SoCs, existing PHY >> driver is split into SoC agnostic common USB PHY driver and >> Tegra20-specific USB phy driver. This will facilitate easy >> addition and deletion of phy drivers for Tegra SoCs. >> >> Signed-off-by: Venu Byravarasu > > I was reading this "driver" more closely and I have a bunch of > questions about it, but the most important of all of them is: "why > isn't that a real PHY driver ?". It doesn't have a probe() > function, it doesn't use struct usb_phy to represent the PHY, it > has a bunch of tegra-specific APIs and we can't let those > continue. One question here: If the PHY "driver" API changes, there will need to be a bunch of ehci-tegra.c changes too. Will you take all those through the PHY tree? If you expect to do that, then I'd like to request you also take: usb: host: tegra remove include of http://www.spinics.net/lists/linux-usb/msg72429.html ... since that should get merged before any large changes to ehci-tegra.c; it's the EHCI equivalent of the PHY patch you already merged. (The same request applies to put that into a branch I can pull into the Tegra tree as a basis for cleanup in the Tegra tree) Thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware
Hi, On Fri, Oct 19, 2012 at 06:19:26PM +0100, Simon Haggett wrote: > Some gadget drivers may attempt to dequeue requests for an endpoint that has > already been disabled. For example, in the UVC gadget driver, > uvc_function_set_alt() > will call usb_ep_disable() when alt setting 0 is selected. When the userspace > application subsequently issues the VIDIOC_STREAMOFF ioctl, uvc_video_enable() > invokes usb_ep_dequeue() to ensure that all requests have been cancelled. bug is on uvc gadget, then. Laurent ? Also, fsl should be removed from the tree, I'm trying to persuade iMX folks to use drivers/usb/chipidea instead. > For the Freescale High Speed Dual-Role USB controller, fsl_ep_dequeue() > provides > the implementation of usb_ep_dequeue(). If this is called for a disabled > endpoint, > a kernel oops will occur when the ep->ep.desc field is dereferenced (by > ep_index()). > fsl_ep_disable() sets this field to NULL, as well as deleting all pending > requests > for the endpoint. > > This patch adds an additional check to fsl_ep_dequeue() to ensure that the > endpoint has not already been disabled before attempting to dequeue requests. > > Signed-off-by: Simon Haggett > --- > drivers/usb/gadget/fsl_udc_core.c |5 - > 1 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/gadget/fsl_udc_core.c > b/drivers/usb/gadget/fsl_udc_core.c > index 6ae70cb..acd513b 100644 > --- a/drivers/usb/gadget/fsl_udc_core.c > +++ b/drivers/usb/gadget/fsl_udc_core.c > @@ -955,7 +955,10 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct > usb_request *_req) > int ep_num, stopped, ret = 0; > u32 epctrl; > > - if (!_ep || !_req) > + /* Ensure that the ep and request are valid, and the ep is not > + * disabled > + */ > + if (!_ep || !_req || !ep->ep.desc) > return -EINVAL; > > spin_lock_irqsave(&ep->udc->lock, flags); > -- > 1.7.4.1 > -- balbi signature.asc Description: Digital signature
[PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware
Some gadget drivers may attempt to dequeue requests for an endpoint that has already been disabled. For example, in the UVC gadget driver, uvc_function_set_alt() will call usb_ep_disable() when alt setting 0 is selected. When the userspace application subsequently issues the VIDIOC_STREAMOFF ioctl, uvc_video_enable() invokes usb_ep_dequeue() to ensure that all requests have been cancelled. For the Freescale High Speed Dual-Role USB controller, fsl_ep_dequeue() provides the implementation of usb_ep_dequeue(). If this is called for a disabled endpoint, a kernel oops will occur when the ep->ep.desc field is dereferenced (by ep_index()). fsl_ep_disable() sets this field to NULL, as well as deleting all pending requests for the endpoint. This patch adds an additional check to fsl_ep_dequeue() to ensure that the endpoint has not already been disabled before attempting to dequeue requests. Signed-off-by: Simon Haggett --- drivers/usb/gadget/fsl_udc_core.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 6ae70cb..acd513b 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -955,7 +955,10 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) int ep_num, stopped, ret = 0; u32 epctrl; - if (!_ep || !_req) + /* Ensure that the ep and request are valid, and the ep is not +* disabled +*/ + if (!_ep || !_req || !ep->ep.desc) return -EINVAL; spin_lock_irqsave(&ep->udc->lock, flags); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[GIT PATCH] USB patches for 3.7-rc2
The following changes since commit ddffeb8c4d0331609ef2581d84de4d763607bd37: Linux 3.7-rc1 (2012-10-14 14:41:04 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ tags/usb-3.7-rc1 for you to fetch changes up to 4b35f1c52943851b310afb09047bfe991ac8f5ae: USB: option: add more ZTE devices (2012-10-18 08:27:21 -0700) USB fixes for 3.7-rc2 Here are the USB patches against your 3.7-rc1 tree. There are the usual UABI header file movements, and we finally are now able to remove the dbg() macro that is over 15 years old (that had to wait for after some other trees got merged into yours during the big 3.7-rc1 merge window.) Other than that, nothing major, just a number of bugfixes and new device ids. It turns out that almost all of the usb-serial drivers had bugs in how they were handling their internal data, leaking memory, hence all of those fixups. Signed-off-by: Greg Kroah-Hartman Alan Stern (1): USB: fix port probing and removal in garmin_gps Alexandre Pereira da Silva (1): usb: gadget: lpc32xx_udc: Fix compatibility with STOTG04 Alexis R. Cortes (1): usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP Bjørn Mork (2): USB: option: blacklist net interface on ZTE devices USB: option: add more ZTE devices David Howells (1): UAPI: (Scripted) Disintegrate include/linux/usb Felipe Balbi (1): usb: dwc3: gadget: fix 'endpoint always busy' bug Greg Kroah-Hartman (5): Merge tag 'for-usb-linus-2012-10-11' of git://git.kernel.org/.../sarah/xhci into usb-linus Merge tag 'disintegrate-usb-20121009' of git://git.infradead.org/users/dhowells/linux-headers into usb-linus Merge 3.7-rc1 usb-linus USB: usb.h: remove dbg() macro Merge tag 'fixes-for-v3.7-rc2' of git://git.kernel.org/.../balbi/usb into usb-linus Henrik Rydberg (1): usbdevfs: Fix broken scatter-gather transfer Johan Hovold (19): USB: ark3116: fix NULL-pointer dereference USB: cyberjack: fix port-data memory leak USB: belkin_sa: fix port-data memory leak USB: cp210x: fix port-data memory leak USB: pl2303: fix port-data memory leak USB: cypress_m8: fix port-data memory leak USB: kobil_sct: fix port-data memory leak USB: io_edgeport: fix port-data memory leak USB: f81232: fix port-data memory leak USB: keyspan_pda: fix port-data memory leak USB: io_ti: fix port-data memory leak USB: kl5kusb105: fix port-data memory leak USB: iuu_phoenix: fix port-data memory leak USB: oti6858: fix port-data memory leak USB: ti_usb_3410_5052: fix port-data memory leak USB: ssu100: fix port-data memory leak USB: spcp8x5: fix port-data memory leak USB: iuu_phoenix: fix sysfs-attribute creation USB: io_ti: fix sysfs-attribute creation Kuninori Morimoto (2): usb: renesas_usbhs: fixup __usbhs_for_each_pipe 1st pos usb: renesas_usbhs: fixup interrupt status clear method Laurent Pinchart (2): usb: gadget: Make webcam gadget select USB_LIBCOMPOSITE MAINTAINERS: Add maintainer entry for the USB webcam gadget Ming Lei (1): USB: cdc-acm: fix pipe type of write endpoint Nicolas Boullis (1): usb: acm: fix the computation of the number of data bits Sarah Sharp (4): USB: Enable LPM after a failed probe. usb: Don't enable LPM if the exit latency is zero. usb: Send Set SEL before enabling parent U1/U2 timeout. usb: trival: Fix debugging units mistake. Stefano Babic (1): usb: musb: am35xx: drop spurious unplugging a device Tony Prisk (2): usb: Missing dma_mask in uhci-platform.c when probed from device-tree usb: Missing dma_mask in ehci-vt8500.c when probed from device-tree Vivek Gautam (1): usb: dwc3: shutdown usb_phy when removing the device MAINTAINERS | 7 + drivers/usb/class/cdc-acm.c | 22 ++- drivers/usb/core/devio.c | 1 + drivers/usb/core/driver.c| 4 + drivers/usb/core/hub.c | 36 ++-- drivers/usb/dwc3/core.c | 4 + drivers/usb/dwc3/gadget.c| 2 +- drivers/usb/gadget/Kconfig | 1 + drivers/usb/gadget/lpc32xx_udc.c | 4 +- drivers/usb/host/ehci-vt8500.c | 10 ++ drivers/usb/host/uhci-platform.c | 9 + drivers/usb/host/xhci.c | 3 +- drivers/usb/musb/am35x.c | 6 + drivers/usb/renesas_usbhs/mod.c | 6 +- drivers/usb/renesas_usbhs/pipe.h | 2 +- drivers/usb/serial/ark3116.c | 26 +-- drivers/usb/serial/belkin_sa.c | 31 ++-- drivers/usb/serial/cp210x.c | 40 ++--- drivers/usb/serial/cyberjack.c
Re: usb audio race at disconnect time
At Thu, 18 Oct 2012 17:39:05 +0200, Matthieu CASTET wrote: > > Takashi Iwai a écrit : > > At Tue, 16 Oct 2012 18:01:13 +0200, > > Matthieu CASTET wrote: > >> Takashi Iwai a écrit : > >>> At Mon, 15 Oct 2012 19:41:40 +0200, > >>> Matthieu CASTET wrote: > Hi Takashi, > > But I believe I found other races in the alsa char device handling. With > the > attached patch, if you disconnect the usb audio device between "msleep > o" and > "msleep o+", you will free the card resource (snd_card_do_free) and then > use it [1]. > > I did in in snd_ctl_open, but the same thing could be done in > snd_pcm_open, ... > >>> OK, we'd need a generic open/close protection. > >>> For PCM, there is already a fix in my last patchset, so it should > >>> work, but for other devices, the paths are still uncovered. > >>> > >> I don't think it will work for pcm : the begin of snd_pcm_open is not > >> protected > >> by any lock even with your patch > >> In snd_open we release sound_mutex before calling file->f_op->open. > >> > >> The snd_lookup_minor_data and snd_card_file_add should be protected by a > >> lock. > >> Attached a patch (pcm.crash) that help to trigger [1]. > > > > Check out my latest patches in topic/usb-disconnect-fix branch. > > It's been fixed there. > > > Thanks, > > the first tests seems ok. > We will do more strees test. OK, thanks! I seem to have forgotten to send two patches in that branch to ML. Will follow soon. Takashi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] Yet more USB-audio disconnection race fixes
Hi, these two patches are applied on the top of previous four patches for fixing races at disconnection of USB-audio devices. These rather cover the core codes than USB-specific. The whole six patches are found in topic/usb-disconnect-fix branch of sound-unstable git tree, too. git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable.git Takashi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] ALSA: Add a reference counter to card instance
For more strict protection for wild disconnections, a refcount is introduced to the card instance, and let it up/down when an object is referred via snd_lookup_*() in the open ops. The free-after-last-close check is also changed to check this refcount instead of the empty list, too. Signed-off-by: Takashi Iwai --- include/sound/core.h | 3 +++ sound/core/compress_offload.c | 9 ++-- sound/core/control.c | 3 +++ sound/core/hwdep.c| 5 - sound/core/init.c | 50 ++- sound/core/oss/mixer_oss.c| 10 +++-- sound/core/oss/pcm_oss.c | 2 ++ sound/core/pcm_native.c | 9 ++-- sound/core/rawmidi.c | 6 +- sound/core/sound.c| 11 -- sound/core/sound_oss.c| 10 +++-- 11 files changed, 86 insertions(+), 32 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index bc05668..93896ad 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -132,6 +132,7 @@ struct snd_card { int shutdown; /* this card is going down */ int free_on_last_close; /* free in context of file_release */ wait_queue_head_t shutdown_sleep; + atomic_t refcount; /* refcount for disconnection */ struct device *dev; /* device assigned to this card */ struct device *card_dev;/* cardX object for sysfs */ @@ -189,6 +190,7 @@ struct snd_minor { const struct file_operations *f_ops;/* file operations */ void *private_data; /* private data for f_ops->open */ struct device *dev; /* device for sysfs */ + struct snd_card *card_ptr; /* assigned card instance */ }; /* return a device pointer linked to each sound device as a parent */ @@ -295,6 +297,7 @@ int snd_card_info_done(void); int snd_component_add(struct snd_card *card, const char *component); int snd_card_file_add(struct snd_card *card, struct file *file); int snd_card_file_remove(struct snd_card *card, struct file *file); +void snd_card_unref(struct snd_card *card); #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index c40ae57..ad11dc9 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -100,12 +100,15 @@ static int snd_compr_open(struct inode *inode, struct file *f) if (dirn != compr->direction) { pr_err("this device doesn't support this direction\n"); + snd_card_unref(compr->card); return -EINVAL; } data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) + if (!data) { + snd_card_unref(compr->card); return -ENOMEM; + } data->stream.ops = compr->ops; data->stream.direction = dirn; data->stream.private_data = compr->private_data; @@ -113,6 +116,7 @@ static int snd_compr_open(struct inode *inode, struct file *f) runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); if (!runtime) { kfree(data); + snd_card_unref(compr->card); return -ENOMEM; } runtime->state = SNDRV_PCM_STATE_OPEN; @@ -126,7 +130,8 @@ static int snd_compr_open(struct inode *inode, struct file *f) kfree(runtime); kfree(data); } - return ret; + snd_card_unref(compr->card); + return 0; } static int snd_compr_free(struct inode *inode, struct file *f) diff --git a/sound/core/control.c b/sound/core/control.c index 7e86a5b..9768a39 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -86,6 +86,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) write_lock_irqsave(&card->ctl_files_rwlock, flags); list_add_tail(&ctl->list, &card->ctl_files); write_unlock_irqrestore(&card->ctl_files_rwlock, flags); + snd_card_unref(card); return 0; __error: @@ -93,6 +94,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file) __error2: snd_card_file_remove(card, file); __error1: + if (card) + snd_card_unref(card); return err; } diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 75ea16f..53a6ba5 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -100,8 +100,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) if (hw == NULL) return -ENODEV; - if (!try_module_get(hw->card->module)) + if (!try_module_get(hw->card->module)) { + snd_card_unref(hw->card); return -EFAULT; + } init_waitqueue_entry(&wait, current); add_wait_queue(&hw->open_wait, &wait); @@ -148,6 +150,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
[PATCH 2/2] ALSA: Avoid endless sleep after disconnect
When disconnect callback is called, each component should wake up sleepers and check card->shutdown flag for avoiding the endless sleep blocking the proper resource release. Signed-off-by: Takashi Iwai --- sound/core/control.c | 2 ++ sound/core/hwdep.c | 7 +++ sound/core/oss/pcm_oss.c | 4 sound/core/pcm.c | 6 +- sound/core/pcm_native.c | 8 sound/core/rawmidi.c | 20 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/sound/core/control.c b/sound/core/control.c index 9768a39..8c7c2c9 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1437,6 +1437,8 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer, spin_unlock_irq(&ctl->read_lock); schedule(); remove_wait_queue(&ctl->change_sleep, &wait); + if (ctl->card->shutdown) + return -ENODEV; if (signal_pending(current)) return -ERESTARTSYS; spin_lock_irq(&ctl->read_lock); diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 53a6ba5..3f7f662 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -131,6 +131,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) mutex_unlock(&hw->open_mutex); schedule(); mutex_lock(&hw->open_mutex); + if (hw->card->shutdown) { + err = -ENODEV; + break; + } if (signal_pending(current)) { err = -ERESTARTSYS; break; @@ -462,12 +466,15 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device) mutex_unlock(®ister_mutex); return -EINVAL; } + mutex_lock(&hwdep->open_mutex); + wake_up(&hwdep->open_wait); #ifdef CONFIG_SND_OSSEMUL if (hwdep->ossreg) snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device); #endif snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); list_del_init(&hwdep->list); + mutex_unlock(&hwdep->open_mutex); mutex_unlock(®ister_mutex); return 0; } diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 2529e01..f337b66 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2441,6 +2441,10 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) mutex_unlock(&pcm->open_mutex); schedule(); mutex_lock(&pcm->open_mutex); + if (pcm->card->shutdown) { + err = -ENODEV; + break; + } if (signal_pending(current)) { err = -ERESTARTSYS; break; diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 993b240..030102c 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1087,12 +1087,16 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) goto unlock; mutex_lock(&pcm->open_mutex); + wake_up(&pcm->open_wait); list_del_init(&pcm->list); for (cidx = 0; cidx < 2; cidx++) for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) { snd_pcm_stream_lock_irq(substream); - if (substream->runtime) + if (substream->runtime) { substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED; + wake_up(&substream->runtime->sleep); + wake_up(&substream->runtime->tsleep); + } snd_pcm_stream_unlock_irq(substream); } list_for_each_entry(notify, &snd_pcm_notify_list, list) { diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 48c6a70..6e8872d 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1518,6 +1518,10 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream, down_read(&snd_pcm_link_rwsem); snd_pcm_stream_lock_irq(substream); remove_wait_queue(&to_check->sleep, &wait); + if (card->shutdown) { + result = -ENODEV; + break; + } if (tout == 0) { if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) result = -ESTRPIPE; @@ -2169,6 +2173,10 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) mutex_unlock(&pcm->open_mutex); schedule(); mutex_lock(&pcm->open_mutex); +
[RFC PATCH 0/2] Update ehci-platform driver to support devicetree
This patchset updates the ehci-platform.c driver to allow device tree probing. I have dropped support for the three function pointers (power_on, power_off and power_suspend). If someone has knowledge of the power sequence functions that are being implemented, these functions could be replaced (Sorry, I don't know anything about implementing it). port_power_(on_off) properties are not supported in DT as Alan Stern indicated they are going to be removed. I have included a binding document, but must admit most of the descriptions for the properties are guessed. Quite likely some of these descriptions are incorrect and/or need to be clarified. Tony Prisk (2): USB: Update EHCI-platform driver to devicetree. USB: doc: Binding document for ehci-platform driver .../devicetree/bindings/usb/ehci-platform.txt | 22 +++ drivers/usb/host/ehci-hcd.c|5 - drivers/usb/host/ehci-platform.c | 46 ++ drivers/usb/host/ehci-vt8500.c | 171 4 files changed, 68 insertions(+), 176 deletions(-) create mode 100644 Documentation/devicetree/bindings/usb/ehci-platform.txt delete mode 100644 drivers/usb/host/ehci-vt8500.c -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] USB: Update EHCI-platform driver to devicetree.
This patch adds devicetree support to the EHCI-platform driver, and removes the now unneeded ehci-vt8500.c Existing platform properties are maintained, with the exception the power_(on/off) and suspend function pointers. Signed-off-by: Tony Prisk --- drivers/usb/host/ehci-hcd.c |5 -- drivers/usb/host/ehci-platform.c | 46 ++ drivers/usb/host/ehci-vt8500.c | 171 -- 3 files changed, 46 insertions(+), 176 deletions(-) delete mode 100644 drivers/usb/host/ehci-vt8500.c diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 6bf6c42..42c8e84 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1274,11 +1274,6 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVERcns3xxx_ehci_driver #endif -#ifdef CONFIG_ARCH_VT8500 -#include "ehci-vt8500.c" -#definePLATFORM_DRIVER vt8500_ehci_driver -#endif - #ifdef CONFIG_PLAT_SPEAR #include "ehci-spear.c" #define PLATFORM_DRIVERspear_ehci_hcd_driver diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 764e010..7f962dc 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -19,6 +19,7 @@ * Licensed under the GNU/GPL. See COPYING for details. */ #include +#include #include static int ehci_platform_reset(struct usb_hcd *hcd) @@ -78,14 +79,48 @@ static const struct hc_driver ehci_platform_hc_driver = { .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, }; +static u64 ehci_dma_mask = DMA_BIT_MASK(32); + static int __devinit ehci_platform_probe(struct platform_device *dev) { struct usb_hcd *hcd; struct resource *res_mem; struct usb_ehci_pdata *pdata = dev->dev.platform_data; + struct device_node *np = dev->dev.of_node; int irq; int err = -ENOMEM; + /* Are we being initialized from a DT-probed device? */ + if (np) { + /* +* No platform data is being passed, so initalize pdata. +* Limitation: we can't support power_on, power_off or +* power_suspend function pointers from DT. +* TODO: The missing functions could be replaced with +* power sequence handlers. +*/ + pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); + dev->dev.platform_data = pdata; + + /* Read the optional properties from DT node */ + of_property_read_u32(np, "caps-offset", &pdata->caps_offset); + if (of_property_read_bool(np, "has-tt")) + pdata->has_tt = 1; + if (of_property_read_bool(np, "has-synopsys-hc-bug")) + pdata->has_synopsys_hc_bug = 1; + if (of_property_read_bool(np, "big-endian-desc")) + pdata->big_endian_desc = 1; + if (of_property_read_bool(np, "big-endian-mmio")) + pdata->big_endian_mmio = 1; + + /* Right now device-tree probed devices don't get dma_mask set. +* Since shared usb code relies on it, set it here for now. +* Once we have dma capability bindings this can go away. +*/ + if (!dev->dev.dma_mask) + dev->dev.dma_mask = &ehci_dma_mask; + } + if (!pdata) { WARN_ON(1); return -ENODEV; @@ -215,6 +250,16 @@ static const struct platform_device_id ehci_platform_table[] = { { "ehci-platform", 0 }, { } }; + +#ifdef CONFIG_OF +static const struct of_device_id ehci_platform_ids[] = { + { .compatible = "ehci-platform", }, + {} +}; + +MODULE_DEVICE_TABLE(of, ehci_platform_ids); +#endif + MODULE_DEVICE_TABLE(platform, ehci_platform_table); static const struct dev_pm_ops ehci_platform_pm_ops = { @@ -231,5 +276,6 @@ static struct platform_driver ehci_platform_driver = { .owner = THIS_MODULE, .name = "ehci-platform", .pm = &ehci_platform_pm_ops, + .of_match_table = of_match_ptr(ehci_platform_ids), } }; diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c deleted file mode 100644 index d3c9a3e..000 --- a/drivers/usb/host/ehci-vt8500.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * drivers/usb/host/ehci-vt8500.c - * - * Copyright (C) 2010 Alexey Charkov - * - * Based on ehci-au1xxx.c - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Publi
[PATCH 2/2] USB: doc: Binding document for ehci-platform driver
Add a binding document for ehci-platform driver. Signed-off-by: Tony Prisk --- .../devicetree/bindings/usb/ehci-platform.txt | 22 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ehci-platform.txt diff --git a/Documentation/devicetree/bindings/usb/ehci-platform.txt b/Documentation/devicetree/bindings/usb/ehci-platform.txt new file mode 100644 index 000..faeffe4 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/ehci-platform.txt @@ -0,0 +1,22 @@ +Generic Platform EHCI Controller +- + +Required properties: +- compatible : "ehci-platform" +- reg : Should contain 1 register ranges(address and length) +- interrupts : EHCI controller interrupt + +Optional properties: +- caps-offset : offset to the capabilities register (default = 0) +- has-tt : controller has transaction translator(s). +- big-endian-desc : descriptors are in big-endian format +- big-endian-mmio : mmio is in big-endian format +- has-synopsys-hc-bug : controller has the synopsys hc bug + +Example: + ehci@d8007c00 { + compatible = "ehci-platform"; + reg = <0xd8007c00 0x200>; + interrupts = <43>; + has-tt; + }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html