Re: [PATCH] usb/chipidea: fix oops on memory allocation failure
On Wed, Oct 16, 2013 at 01:45:15PM +0100, Russell King - ARM Linux wrote: When CMA fails to initialize in v3.12-rc4, the chipidea driver oopses the kernel while trying to remove and put the HCD which doesn't exist: WARNING: CPU: 0 PID: 6 at /home/rmk/git/linux-rmk/arch/arm/mm/dma-mapping.c:511 __dma_alloc+0x200/0x240() coherent pool not initialised! Modules linked in: CPU: 0 PID: 6 Comm: kworker/u2:0 Tainted: GW3.12.0-rc4+ #56 Workqueue: deferwq deferred_probe_work_func Backtrace: [c001218c] (dump_backtrace+0x0/0x10c) from [c0012328] (show_stack+0x18/0x1c) r6:c05fd9cc r5:01ff r4: r3:df86ad00 [c0012310] (show_stack+0x0/0x1c) from [c05f3a4c] (dump_stack+0x70/0x8c) [c05f39dc] (dump_stack+0x0/0x8c) from [c00230a8] (warn_slowpath_common+0x6c/0x8c) r4:df883a60 r3:df86ad00 [c002303c] (warn_slowpath_common+0x0/0x8c) from [c002316c] (warn_slowpath_fmt+0x38/0x40) r8: r7:1000 r6:c083b808 r5: r4:df2efe80 [c0023134] (warn_slowpath_fmt+0x0/0x40) from [c00196bc] (__dma_alloc+0x200/0x240) r3: r2:c05fda00 [c00194bc] (__dma_alloc+0x0/0x240) from [c001982c] (arm_dma_alloc+0x88/0xa0) [c00197a4] (arm_dma_alloc+0x0/0xa0) from [c03e2904] (ehci_setup+0x1f4/0x438) [c03e2710] (ehci_setup+0x0/0x438) from [c03cbd60] (usb_add_hcd+0x18c/0x664) [c03cbbd4] (usb_add_hcd+0x0/0x664) from [c03e89f4] (host_start+0xf0/0x180) [c03e8904] (host_start+0x0/0x180) from [c03e7c34] (ci_hdrc_probe+0x360/0x670 ) r6:df2ef410 r5: r4:df2c3010 r3:c03e8904 [c03e78d4] (ci_hdrc_probe+0x0/0x670) from [c0311044] (platform_drv_probe+0x20/0x24) [c0311024] (platform_drv_probe+0x0/0x24) from [c030fcac] (driver_probe_device+0x9c/0x234) ... ---[ end trace c88ccaf3969e8422 ]--- Unable to handle kernel NULL pointer dereference at virtual address 0028 pgd = c0004000 [0028] *pgd= Internal error: Oops: 17 [#1] SMP ARM Modules linked in: CPU: 0 PID: 6 Comm: kworker/u2:0 Tainted: GW3.12.0-rc4+ #56 Workqueue: deferwq deferred_probe_work_func task: df86ad00 ti: df882000 task.ti: df882000 PC is at usb_remove_hcd+0x10/0x150 LR is at host_stop+0x1c/0x3c pc : [c03cacec]lr : [c03e88e4]psr: 6013 sp : df883b50 ip : df883b78 fp : df883b74 r10: c11f4c54 r9 : c0836450 r8 : df30c400 r7 : fff4 r6 : df2ef410 r5 : r4 : df2c3010 r3 : r2 : r1 : df86b0a0 r0 : Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 2f29404a DAC: 0015 Process kworker/u2:0 (pid: 6, stack limit = 0xdf882240) Stack: (0xdf883b50 to 0xdf884000) ... Backtrace: [c03cacdc] (usb_remove_hcd+0x0/0x150) from [c03e88e4] (host_stop+0x1c/0x3c) r6:df2ef410 r5: r4:df2c3010 [c03e88c8] (host_stop+0x0/0x3c) from [c03e8aa0] (ci_hdrc_host_destroy+0x1c/0x20) r5: r4:df2c3010 [c03e8a84] (ci_hdrc_host_destroy+0x0/0x20) from [c03e7c80] (ci_hdrc_probe+0x3ac/0x670) [c03e78d4] (ci_hdrc_probe+0x0/0x670) from [c0311044] (platform_drv_probe+0x20/0x24) [c0311024] (platform_drv_probe+0x0/0x24) from [c030fcac] (driver_probe_device+0x9c/0x234) [c030fc10] (driver_probe_device+0x0/0x234) from [c030ff28] (__device_attach+0x44/0x48) ... ---[ end trace c88ccaf3969e8423 ]--- Fix this so at least we can continue booting and get to a shell prompt. Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk Tested-by: Russell King rmk+ker...@arm.linux.org.uk --- drivers/usb/chipidea/host.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 6f96795..64d7a6d 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -100,8 +100,10 @@ static void host_stop(struct ci_hdrc *ci) { struct usb_hcd *hcd = ci-hcd; - usb_remove_hcd(hcd); - usb_put_hcd(hcd); + if (hcd) { + usb_remove_hcd(hcd); + usb_put_hcd(hcd); + } if (ci-platdata-reg_vbus) regulator_disable(ci-platdata-reg_vbus); } Thanks for pointing it, the regulator_disable may still be called but the regulator_enable is not called due to hcd's allocation is failed at this case. For this error, the driver should not call .stop if .start has failed. Below is my proposal fix for this problem: diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 42a0bd4..c1d05c4 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -270,16 +270,18 @@ static void host_stop(struct ci_hdrc *ci) { struct usb_hcd *hcd = ci-hcd; - usb_remove_hcd(hcd); - usb_put_hcd(hcd); - if (ci-platdata-reg_vbus) - regulator_disable(ci-platdata-reg_vbus); + if (hcd) { + usb_remove_hcd(hcd); + usb_put_hcd(hcd); + if (ci-platdata-reg_vbus) +
[PATCH 2/5] usb: ohci-at91: Include linux/of.h header
'of_match_ptr' is defined in linux/of.h. Include it explicitly to avoid build breakage in the future. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org --- drivers/usb/host/ohci-at91.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 418444e..59735d7 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -14,6 +14,7 @@ #include linux/clk.h #include linux/dma-mapping.h +#include linux/of.h #include linux/of_platform.h #include linux/of_gpio.h #include linux/platform_device.h -- 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/5] usb: gadget: s3c-hsotg: Include linux/of.h header
'of_match_ptr' is defined in linux/of.h. Include it explicitly to avoid build breakage in the future. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org --- drivers/usb/gadget/s3c-hsotg.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7014d15..7a34bb4 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -29,6 +29,7 @@ #include linux/slab.h #include linux/clk.h #include linux/regulator/consumer.h +#include linux/of.h #include linux/of_platform.h #include linux/usb/ch9.h -- 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 4/5] usb: misc: usb3503: Include linux/of.h header
'of_match_ptr' is defined in linux/of.h. Include it explicitly to avoid build breakage in the future. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org --- drivers/usb/misc/usb3503.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c index a31641e..9244ead 100644 --- a/drivers/usb/misc/usb3503.c +++ b/drivers/usb/misc/usb3503.c @@ -23,6 +23,7 @@ #include linux/delay.h #include linux/slab.h #include linux/module.h +#include linux/of.h #include linux/of_gpio.h #include linux/platform_device.h #include linux/platform_data/usb3503.h -- 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 5/5] usb: phy: twl6030-usb: Include linux/of.h header
'of_match_ptr' is defined in linux/of.h. Include it explicitly to avoid build breakage in the future. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org --- drivers/usb/phy/phy-twl6030-usb.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c index 16dbc93..30e8a61 100644 --- a/drivers/usb/phy/phy-twl6030-usb.c +++ b/drivers/usb/phy/phy-twl6030-usb.c @@ -33,6 +33,7 @@ #include linux/err.h #include linux/slab.h #include linux/delay.h +#include linux/of.h /* usb register definitions */ #define USB_VENDOR_ID_LSB 0x00 -- 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 3/5] usb: ohci-pxa27x: Include linux/of.h header
'of_match_ptr' is defined in linux/of.h. Include it explicitly to avoid build breakage in the future. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org --- drivers/usb/host/ohci-pxa27x.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index e89ac4d..14d4b7b 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -24,6 +24,7 @@ #include linux/io.h #include linux/kernel.h #include linux/module.h +#include linux/of.h #include linux/of_platform.h #include linux/of_gpio.h #include linux/platform_data/usb-ohci-pxa27x.h -- 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
Re: device enumeration fail (only?) on ehci
On Wednesday 16 October 2013 15:29:53, Alan Stern wrote: I'm experiencing problems with our USB-CAN-hardware in a test scenario only when being attached to the ehci root-hub. When the device is enumerated and has its USB address the driver is bound and the can interface is started. So far so good. If there is a status request timeout the module firmware disconnects itself from the bus, thus reattaching to the bus, getting a new USB device address and so on... Doing this in a loops lead eventually to this error messages: Do you have any idea why a status request timeout would occur? Can you capture a usbmon trace showing one of these timeouts and the following errors? I hope status request timeout does not interfere with some USB standard stuff. In my case this is a safety mechanism in case the host driver could not get the current status from the device. So the driver needs to poll from a specific endpoint once a second. I see. So the device itself forces the disconnect if it doesn't receive this status poll sufficiently often, right? Exactly! There is no need for usbmon trace. This timeout is intentionally triggered within the test loop by simply removing the device driver without shutting down the CAN interfaces. Those dis-/reconnects are part of the problem I described. BTW: There is no shutdown callback for USB device drivers so this 'problem' even occurs during system reboot when the CAN interface is not shutdown beforehand. That's true. We could add a shutdown callback, if necessary. Or just unbind all the drivers. So the problem seems to occur only when the hub is connected with high-speed to any hub on an ehci bus. Has somebody an idea what might have gone wrong here? It seems the internal hub has problems with Transaction Translators. But why does this only happen when attached to ehci? Is this maybe a driver problem? I did some tests on 3.11.4 and some on 3.10.7 and both showed same results. I doubt that it is a driver problem. Much more likely is a bug in the internal hub, as you guessed. This doesn't explain why it works under xHCI but not under EHCI. Do you not get any status request timeouts under xHCI? Those timeouts are provoked on purpose, so, yes, there also exist in the xHCI case. But with xHCI and OHCI, the reconnect succeeds whereas with EHCI it fails? Yep. But it even works on EHCI if there is a full-speed-hub somewhere before that device. It's hard to guess why. The behavior under xHCI is slightly different from the other two, which behave the same. You can force EHCI and OHCI to work more like xHCI by doing: echo 1 /sys/module/usbcore/parameters/old_scheme_first I tried that but there wasn't any difference. Maybe it's a data toggle issue involving the internal hub, but the only way to find out for sure is to use a bus analyzer. We tried that but didn't see any USB traffic for those USB device numbers where enumeration failed. One thing about the error log: [249741.159104] usb 2-1.6.1: new full-speed USB device number 109 using ehci-pci [249751.565047] usb 2-1.6.1: device not accepting address 109, error -110 [249751.638197] usb 2-1.6.1: new full-speed USB device number 110 using ehci-pci [249762.044199] usb 2-1.6.1: device not accepting address 110, error -110 [249762.117273] usb 2-1.6.1: new full-speed USB device number 111 using ehci-pci [249777.196292] usb 2-1.6.1: device descriptor read/64, error -110 [249792.376349] usb 2-1.6.1: device descriptor read/64, error -110 [249792.550467] usb 2-1.6.1: new full-speed USB device number 112 using ehci-pci [249807.629330] usb 2-1.6.1: device descriptor read/64, error -110 [249822.809391] usb 2-1.6.1: device descriptor read/64, error -110 [249822.910435] hub 2-1.6:1.0: unable to enumerate USB device on port 1 There are different errors device not accepting address xxx and device descriptor read/64, error -110. Does that mean that reading the device descriptor succeeded when the USB device address shall be set? Alexander -- 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] usb/chipidea: fix oops on memory allocation failure
On Thu, Oct 17, 2013 at 01:50:17PM +0800, Peter Chen wrote: Below is my proposal fix for this problem: diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 42a0bd4..c1d05c4 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -270,16 +270,18 @@ static void host_stop(struct ci_hdrc *ci) { struct usb_hcd *hcd = ci-hcd; - usb_remove_hcd(hcd); - usb_put_hcd(hcd); - if (ci-platdata-reg_vbus) - regulator_disable(ci-platdata-reg_vbus); + if (hcd) { + usb_remove_hcd(hcd); + usb_put_hcd(hcd); + if (ci-platdata-reg_vbus) + regulator_disable(ci-platdata-reg_vbus); + } } void ci_hdrc_host_destroy(struct ci_hdrc *ci) { - if (ci-role == CI_ROLE_HOST) + if (ci-role == CI_ROLE_HOST ci-hcd) host_stop(ci); If you're not calling host_stop() unless ci-hcd is setup, then you don't need to check for that in host_stop() ? Note that my oopsing path is through the above function. Anyway, Greg has already taken my patch from yesterday. -- 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] usb/chipidea: fix oops on memory allocation failure
On Thu, Oct 17, 2013 at 10:43:17AM +0100, Russell King - ARM Linux wrote: On Thu, Oct 17, 2013 at 01:50:17PM +0800, Peter Chen wrote: Below is my proposal fix for this problem: diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 42a0bd4..c1d05c4 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -270,16 +270,18 @@ static void host_stop(struct ci_hdrc *ci) { struct usb_hcd *hcd = ci-hcd; - usb_remove_hcd(hcd); - usb_put_hcd(hcd); - if (ci-platdata-reg_vbus) - regulator_disable(ci-platdata-reg_vbus); + if (hcd) { + usb_remove_hcd(hcd); + usb_put_hcd(hcd); + if (ci-platdata-reg_vbus) + regulator_disable(ci-platdata-reg_vbus); + } } void ci_hdrc_host_destroy(struct ci_hdrc *ci) { - if (ci-role == CI_ROLE_HOST) + if (ci-role == CI_ROLE_HOST ci-hcd) host_stop(ci); If you're not calling host_stop() unless ci-hcd is setup, then you don't need to check for that in host_stop() ? Note that my oopsing path is through the above function. Mine is just double check, this host_stop is called from ci_hdrc_host_destroy For your oops, your fix is enough since regulator_enable has already been called. But if the host_start fails at the beginning, eg usb_create_hcd returns NULL, you need to consider regulator mismatch case. -- Best Regards, Peter Chen -- 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] ehci: remove old TT sched code
On Wed, Oct 16, 2013 at 5:09 PM, Alan Stern st...@rowland.harvard.edu wrote: On Wed, 16 Oct 2013, Dan Streetman wrote: On Wed, Oct 16, 2013 at 10:34 AM, Alan Stern st...@rowland.harvard.edu wrote: On Tue, 15 Oct 2013, Dan Streetman wrote: Until the new scheduler is fixed up to work properly, I prefer to keep both options available. Ok, no hurry. With the work you've done on it before and the new stuff in usb-next it should be working very well soon :-) Dear me, no... The changes I have made so far amount to perhaps 25% of the work needed to make it truly reliable. It has so many bugs, I wouldn't even try to list them all. Heh, well I guess I wrote it when I was young and coded sloppily ;-) I'll review it all again and try to help fix the bugs. -- 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/5] usb: gadget: s3c-hsotg: support configurable UTMI PHY width
On Fri, Oct 11, 2013 at 08:37:31AM -0500, Felipe Balbi wrote: Hi, On Thu, Oct 10, 2013 at 11:21:30PM -0400, Matt Porter wrote: On 10/10/2013 03:07 PM, Matt Porter wrote: On 10/10/2013 01:57 PM, Paul Zimmerman wrote: From: Felipe Balbi [mailto:ba...@ti.com] Sent: Thursday, October 10, 2013 10:46 AM On Thu, Oct 10, 2013 at 12:54:40PM -0400, Matt Porter wrote: On 10/10/2013 11:29 AM, Felipe Balbi wrote: On Mon, Oct 07, 2013 at 06:12:29AM -0400, Matt Porter wrote: Extend dwc2 binding with an optional utmi phy width property. Enable the s3c-hsotg.c driver to use standard dwc2 binding and enable configuration of the UTMI phy width based on the property. Signed-off-by: Matt Porter matt.por...@linaro.org Reviewed-by: Markus Mayer markus.ma...@linaro.org Reviewed-by: Tim Kryger tim.kry...@linaro.org --- Documentation/devicetree/bindings/staging/dwc2.txt | 4 drivers/usb/gadget/s3c-hsotg.c | 18 +- drivers/usb/gadget/s3c-hsotg.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt b/Documentation/devicetree/bindings/staging/dwc2.txt index 1a1b7cf..fb6b8ee 100644 --- a/Documentation/devicetree/bindings/staging/dwc2.txt +++ b/Documentation/devicetree/bindings/staging/dwc2.txt @@ -6,10 +6,14 @@ Required properties: - reg : Should contain 1 register range (address and length) - interrupts : Should contain 1 interrupt +Optional properties: +- snps,phy-utmi-width: Must contain the UTMI data width (either 8 or 16) isn't this available in any of the configuration registers ? Yes and no. HWCFG4 has a UTMI data width field. However, it has 3 valid states, 8, 16, or 8 or 16. The BCM281xx implementation is set to the latter and the attached phy is 8-bit. Looking at dwc2 prior to Matthijs Kooijman's patch [1] which starts validating the value of phy_utmi_width in that driver, the pci.c dwc2_module_params .phy_utmi_width field there even had the comment, /* 16 bits - NOT DETECTABLE */. The autodetect code in dwc2_set_param_phy_utmi_width() will fail if HWCFG4 has the 8 or 16 option as it just decides to default to a phy width of 16 if nothing is configured by the platform glue. This property would also allow this issue to be addressed in that driver. fair enough, but I'd really like to hear from DT folks if your suggested binding is acceptable. It seems like we can equally argue that it's a SW configuration or HW description. It's definitely a HW description - the width of the UTMI data connection. But, which PHY is this? Does it have a register that could tell what the data width is? The dwc2 core has an (optional) PHY Vendor Control Register that allows reading the PHY registers. This is the integrated PHY on the bcm28155 part (the entire bcm281xx/11351 family shares it). My register doc doesn't show the optional PHY vendor control register as being present in this dwc2 implementation. I'll track down with the design team if this is accurate...but it appears we can't go that route. The design team confirmed that we do not have any registers that can be accessed via the PHY Vendor Control Register. All PHY control registers are implemented in the MMIO control block which is supported in the PHY control driver later in this series.They also confirmed there's no other way to detect that it's an 8-bit data path. then we need the DT binding, let's see what DT maintainers say. I've reworked all of this against the generic phy layer. Things are simplified, of course, but this needs to be clarified to move forward on either the phy driver or the s3c-hsotg support. DT maintainers: can you weigh in here please? Summary is that we have a 8-bit data path UTMI phy attached to a dwc2. The width is undetectable and a fixed h/w configuration. I would actually view this as a property of the phy itself. It's 8-bit only and thus puts the constraint on the controller it's attached to (internally) to operate in 8-bit UTMI mode. However, I see no way with the generic phy binding to provide this information to the controller h/w. The original approach above adds a phy-utmi-width property to the dwc2 binding which is simple, but in retrospect may not reflect where that constraint actually comes into play. -Matt -- 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
MUSB: some questions, 1, why there is no ZLP(zero length packet) when enable DMA?
I use the case testusb -a -t 1 -s 4096 -c 10 and find there is no ZLP after a transfer(4096 bytes), I use the Mentor's own DMA (CONFIG_USB_INVENTRA_DMA). but when just use PIO, there is ZLP. In the musb_host_tx, the transfer will end with the case } else if (dma urb-transfer_buffer_length == qh-offset) { done = true; and don't check the URB_ZERO_PACKET like PIO. please correct me if I am wrong. 2, Why clear the RX toggle bit every time enable a endpoint? In the function musb_ep_program, when endpoint is IN, it will do musb_rx_reinit--musb_h_flush_rxfifo and force clear the RXCSR's toggle bit(MUSB_RXCSR_CLRDATATOG), this may cause data toggle mismatch. and In my SOC, it will break the transfer, because the SOC will silently discard the data if there is a data toggle mismatch. 3, Is it possible for sharing the same irq line between MUSB and DMA? My SOC shares the two interrupt with same irq line, so I fix the request_irq with the flag IRQF_SHARED. I do some basic test, seems it works, but I am not so sure, please give me some advice. -- 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 V3 2/6] USB: OHCI: Properly handle ohci-at91 suspend
Suspend scenario in case of ohci-at91 glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-at91 suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_at91_drv_suspend() will ensure proper handling of suspend scenario. This task is sugested by Alan Stern. V1-V2: Due to version mismatch and build failure on ep93xx reverted this patch. This is a proper patch for ohci-at91 suspend as Alan Stern mentioned. V2-V3: No changes. As a the build failure on ep93xx proper suspend patch and Linaro id bounced. Rewrote this patch on top of latest Greg usb-next branch. This patch not gives any build error. Patch is required for ohci-at91 proper suspending as Alan mentioned. Initially when I wrote this patch I was working in Linaro, now I am not part of Linaro that is why Linaro id is bouncing. Sending this patch from personal mail id. Signed-off-by: Manjunath Goudar csmanjuvi...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Arnd Bergmann a...@arndb.de Cc: Greg KH g...@kroah.com Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-at91.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 476b5a5..f2d8403 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -636,8 +636,14 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + booldo_wakeup = device_may_wakeup(pdev-dev); + int ret; - if (device_may_wakeup(pdev-dev)) + ret = ohci_suspend(hcd, do_wakeup); + if (ret) + return ret; + + if (do_wakeup) enable_irq_wake(hcd-irq); /* @@ -658,7 +664,7 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) at91_stop_clock(); } - return 0; + return ret; } static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) -- 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 V3 1/6] USB: OHCI: Properly handle OHCI controller suspend
Suspend scenario in case of OHCI was not properly handled in ochi_suspend()routine. Alan Stern suggested, properly handle OHCI suspend scenario. This does generic proper handling of suspend scenario to all OHCI SOC. V1-V2: - No change. Due to build failure on ep93xx reverted this patch. This patch is needed as Alan mentioned, it is having common ohci suspend features w/o this following patches(still in usb-next) are not useful. Commit id 10abfa13[PATCH 7/11] Properly handle ohci-omap suspend. Commit id 39dbd7df[PATCH 8/11] Properly handle ohci-platform suspend. Commit id 4ceaa893[PATCH 9/11] Properly handle ohci-pxa suspend. Commit id f3c60599[PATCH 10/11] Properly handle ohci-sm501 suspend. V2-V3 : - No changes. As a build failure on ep93xx patch, reverted this patch(reveart commit id 476e4b). Rewrote this patch on top of latest Greg usb-next branch. This patch not gives any build error. patch is required for proper suspending as Alan mentioned. It is having common ohci suspend features w/o this following patches(still in usb-next) are not useful. Commit id 10abfa13[PATCH 7/11] Properly handle ohci-omap suspend. Commit id 39dbd7df[PATCH 8/11] Properly handle ohci-platform suspend. Commit id 4ceaa893[PATCH 9/11] Properly handle ohci-pxa suspend. Commit id f3c60599[PATCH 10/11] Properly handle ohci-sm501 suspend. Initially when I wrote this patch I was working in Linaro, now I am not part of Linaro that is why Linaro id is bouncing. Sending this patch from personal mail id. Signed-off-by: Manjunath Goudar csmanjuvi...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Greg KH g...@kroah.com Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-hcd.c |9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 8ada13f..310bcfe 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1036,6 +1036,7 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); unsigned long flags; + int rc = 0; /* Disable irq emission and mark HW unaccessible. Use * the spinlock to properly synchronize with possible pending @@ -1048,7 +1049,13 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) clear_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags); spin_unlock_irqrestore (ohci-lock, flags); - return 0; + synchronize_irq(hcd-irq); + + if (do_wakeup HCD_WAKEUP_PENDING(hcd)) { + ohci_resume(hcd, false); + rc = -EBUSY; + } + return rc; } EXPORT_SYMBOL_GPL(ohci_suspend); -- 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 V3 6/6] USB: OHCI: Properly handle ohci-spear suspend
Suspend scenario in case of ohci-spear glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-spear suspend scenario. Calling explicitly the ohci_suspend() routine in spear_ohci_hcd_drv_suspend() will ensure proper handling of suspend scenario. V1-V2: -No changes. Due to the build failure on ep93xx reverted this patch. This patch is needed as Alan Stern suggestion. V2-V3: -No changes. As a build failure on ep93xx proper suspend patch and Linaro id bounced. Rewrote this patch on top of latest Greg usb-next branch. This patch not gives any build error. Patch is required for ohci-spear proper suspending as Alan mentioned. Initially when I wrote this patch I was working in Linaro, now I am not part of Linaro that is why Linaro id is bouncing. Sending this patch from personal mail id. Signed-off-by: Manjunath Goudar csmanjuvi...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Arnd Bergmann a...@arndb.de Cc: Greg KH g...@kroah.com Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-spear.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c index 31ff3fc..41148f8 100644 --- a/drivers/usb/host/ohci-spear.c +++ b/drivers/usb/host/ohci-spear.c @@ -130,20 +130,26 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev) } #if defined(CONFIG_PM) -static int spear_ohci_hcd_drv_suspend(struct platform_device *dev, +static int spear_ohci_hcd_drv_suspend(struct platform_device *pdev, pm_message_t message) { - struct usb_hcd *hcd = platform_get_drvdata(dev); + struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct spear_ohci *sohci_p = to_spear_ohci(hcd); + bool do_wakeup = device_may_wakeup(pdev-dev); + int ret; if (time_before(jiffies, ohci-next_statechange)) msleep(5); ohci-next_statechange = jiffies; + ret = ohci_suspend(hcd, do_wakeup); + if (ret) + return ret; + clk_disable_unprepare(sohci_p-clk); - return 0; + return ret; } static int spear_ohci_hcd_drv_resume(struct platform_device *dev) -- 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 V3 3/6] USB: OHCI: Properly handle ohci-s3c2410 suspend
Suspend scenario in case of ohci-s3c2410 glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-s3c2410 suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_s3c2410_drv_suspend() will ensure proper handling of suspend scenario. V1-V2: -No changes. Due to the build failure on ep93xx reverted this patch. This patch is needed as Alan Stern suggestion. V2-V3: -No changes. As a build failure on ep93xx proper suspend patch and Linaro id bounced. Rewrote this patch on top of latest Greg usb-next branch. This patch not gives any build error. Patch is required for ohci-s3c2410 proper suspending as Alan mentioned. Initially when I wrote this patch I was working in Linaro, now I am not part of Linaro that is why Linaro id is bouncing. Sending this patch from personal mail id. Signed-off-by: Manjunath Goudar csmanjuvi...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Greg KH g...@kroah.com Cc: Ben Dooks ben-li...@fluff.org Cc: Kukjin Kim kgene@samsung.com Cc: linux-arm-ker...@lists.infradead.org Cc: linux-samsung-...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-s3c2410.c | 21 - 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index be3429e..b5bf9b7 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -426,28 +426,15 @@ static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) static int ohci_hcd_s3c2410_drv_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); - struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct platform_device *pdev = to_platform_device(dev); - unsigned long flags; + bool do_wakeup = device_may_wakeup(dev); int rc = 0; - /* -* Root hub was already suspended. Disable irq emission and -* mark HW unaccessible, bail out if RH has been resumed. Use -* the spinlock to properly synchronize with possible pending -* RH suspend or resume activity. -*/ - spin_lock_irqsave(ohci-lock, flags); - if (ohci-rh_state != OHCI_RH_SUSPENDED) { - rc = -EINVAL; - goto bail; - } - - clear_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags); + rc = ohci_suspend(hcd, do_wakeup); + if (rc) + return rc; s3c2410_stop_hc(pdev); -bail: - spin_unlock_irqrestore(ohci-lock, flags); return rc; } -- 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 V3 5/6] USB: OHCI: Properly handle ohci-exynos suspend
Suspend scenario in case of ohci-exynos glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-exynos suspend scenario. Calling explicitly the ohci_suspend() routine in exynos_ohci_suspend() will ensure proper handling of suspend scenario. V1-V2: -No changes. Due to the build failure on ep93xx reverted this patch. This patch is needed as Alan Stern suggestion. V2-V3: -No changes. As a build failure on ep93xx proper suspend patch and Linaro id bounced. Rewrote this patch on top of latest Greg usb-next branch. This patch not gives any build error. Patch is required for ohci-exynos proper suspending as Alan mentioned. Initially when I wrote this patch I was working in Linaro, now I am not part of Linaro that is why Linaro id is bouncing. Sending this patch from personal mail id. Signed-off-by: Manjunath Goudar csmanjuvi...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Arnd Bergmann a...@arndb.de Cc: Greg KH g...@kroah.com Cc: Kukjin Kim kgene@samsung.com Cc: linux-arm-ker...@lists.infradead.org Cc: linux-samsung-...@vger.kernel.org Cc: linux-ker...@vger.kernel.org Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-exynos.c | 22 ++ 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index a87baed..4b5c8bd 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -192,23 +192,14 @@ static int exynos_ohci_suspend(struct device *dev) struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct platform_device *pdev = to_platform_device(dev); + bool do_wakeup = device_may_wakeup(dev); unsigned long flags; - int rc = 0; + int rc = ohci_suspend(hcd, do_wakeup); - /* -* Root hub was already suspended. Disable irq emission and -* mark HW unaccessible, bail out if RH has been resumed. Use -* the spinlock to properly synchronize with possible pending -* RH suspend or resume activity. -*/ - spin_lock_irqsave(ohci-lock, flags); - if (ohci-rh_state != OHCI_RH_SUSPENDED - ohci-rh_state != OHCI_RH_HALTED) { - rc = -EINVAL; - goto fail; - } + if (rc) + return rc; - clear_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags); + spin_lock_irqsave(ohci-lock, flags); if (exynos_ohci-otg) exynos_ohci-otg-set_host(exynos_ohci-otg, hcd-self); @@ -217,10 +208,9 @@ static int exynos_ohci_suspend(struct device *dev) clk_disable_unprepare(exynos_ohci-clk); -fail: spin_unlock_irqrestore(ohci-lock, flags); - return rc; + return 0; } static int exynos_ohci_resume(struct device *dev) -- 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 2/2] dma: cppi41: return code 0 of pm_runtime_get_sync() is not an error
Return code of pm_runtime_get_sync() 0 is not an error and may happen. Noticed during rmmod modprobe testing. Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- drivers/dma/cppi41.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 272969c..42134f9 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -957,7 +957,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) pm_runtime_enable(dev); ret = pm_runtime_get_sync(dev); - if (ret) + if (ret 0) goto err_get_sync; cdd-queues_rx = glue_info-queues_rx; -- 1.8.4.rc3 -- 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/2] dma: cppi41: redo descriptor collection in abort case
On 10/17/2013 04:19 PM, Sebastian Andrzej Siewior wrote: This patch changes the logic here to look on both queues for the descriptor. Daniel, could please look if this solves your suspend / resume warnings? Sebastian -- 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] dma: cppi41: redo descriptor collection in abort case
Most of the logic here is try and error since what actually happens does not match the trm or I miss read it. My first assumption was that the queue on which the tear-down descriptor completes (their own complete queue vs active descriptor complete queue) depends on the transfer direction. This seems not to be true because I manage to trigger | WARN_ON(c-desc_phys != desc_phys); and the other few were fine means the tear-down descriptor was valid but on different queue. This patch changes the logic here to look on both queues for the descriptor. Cc: Daniel Mack zon...@gmail.com Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de --- drivers/dma/cppi41.c | 41 - 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 42d1c58..272969c 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -563,36 +563,27 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c) c-td_retry = 100; } - if (!c-td_seen) { + if (!c-td_seen || !c-td_desc_seen) { unsigned td_comp_queue; - if (c-is_tx) - td_comp_queue = cdd-td_queue.complete; - else - td_comp_queue = c-q_comp_num; + desc_phys = cppi41_pop_desc(cdd, cdd-td_queue.complete); + if (!desc_phys) + desc_phys = cppi41_pop_desc(cdd, c-q_comp_num); - desc_phys = cppi41_pop_desc(cdd, td_comp_queue); - if (desc_phys) { - __iormb(); + if (desc_phys == c-desc_phys) { + c-td_desc_seen = 1; + + } else if (desc_phys == td_desc_phys) { + u32 pd0; - if (desc_phys == td_desc_phys) { - u32 pd0; - pd0 = td-pd0; - WARN_ON((pd0 DESC_TYPE) != DESC_TYPE_TEARD); - WARN_ON(!c-is_tx !(pd0 TD_DESC_IS_RX)); - WARN_ON((pd0 0x1f) != c-port_num); - } else { - WARN_ON_ONCE(1); - } - c-td_seen = 1; - } - } - if (!c-td_desc_seen) { - desc_phys = cppi41_pop_desc(cdd, c-q_comp_num); - if (desc_phys) { __iormb(); - WARN_ON(c-desc_phys != desc_phys); - c-td_desc_seen = 1; + pd0 = td-pd0; + WARN_ON((pd0 DESC_TYPE) != DESC_TYPE_TEARD); + WARN_ON(!c-is_tx !(pd0 TD_DESC_IS_RX)); + WARN_ON((pd0 0x1f) != c-port_num); + c-td_seen = 1; + } else if (desc_phys) { + WARN_ON_ONCE(1); } } c-td_retry--; -- 1.8.4.rc3 -- 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/2] dma: cppi41: redo descriptor collection in abort case
On 10/17/2013 04:20 PM, Sebastian Andrzej Siewior wrote: On 10/17/2013 04:19 PM, Sebastian Andrzej Siewior wrote: This patch changes the logic here to look on both queues for the descriptor. Daniel, could please look if this solves your suspend / resume warnings? Will do (hopefully) tomorrow. So this is a replacement for my dma: cppi41: move -EAGAIN in tear_down patch, or does it go on top of it? How does your patch queue look like? Someone should probably re-collect all necessary patches for the next merge window eventually, so Vinod knows what to apply :) Thanks, Daniel -- 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 v2] xhci: fix usb3 streams
On Wed, 16 Oct 2013, Sarah Sharp wrote: xhci maintains a radix tree for each stream endpoint because it must be able to map a trb address to the stream ring. Each ring segment must be added to the ring for this to work. Currently xhci sticks only the first segment of each stream ring into the radix tree. There may be a simpler approach to this problem. When using a new ring segment, keep the first TRB entry in reserve. Don't put a normal TRB in there, instead leave it as a no-op entry containing a pointer to the stream ring. (Make the prior Link TRB point to the second entry in the new segment instead of the first.) Then you won't have to add to or remove anything from the radix tree. I don't understand how this would help. Are you advocating a different way of mapping TRB DMA addresses to stream rings that would allow us to ditch the radix tree all together? Ok, so with your solution, we have a virtual stream ring pointer as the first TRB of the segment. We get an event with the DMA address of a TRB in one of many stream rings on an endpoint. From that, I think we can infer the DMA address of the first TRB on the segment, due to the alignment requirements and ring size. And then what do we do with that? We don't have the virtual address of that first TRB, so the xHCI driver can't read the ring pointer from it. I'm confused as to what the next steps would be to solve this. My mistake; I misunderstood the original description of the problem. I didn't realize that map a trb address referred to the TRB's DMA address. BTW, ohci-hcd faces the same problem (of mapping DMA addresses to kernel addresses). It solves the problem with a hash table rather than a radix tree. 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 9/9] usbfs: Add support for allocating / freeing streams
On Wed, 16 Oct 2013, Sarah Sharp wrote: Alan, do you have any more feedback on this patchset? No, it looks like Hans has addressed all the issues I could think of. 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: transmit lockup using smsc95xx ethernet on usb3
From: Sarah Sharp [mailto:sarah.a.sh...@linux.intel.com] Thanks for taking an interest. On Tue, Oct 15, 2013 at 10:59:18AM +0100, David Laight wrote: We are seeing complete lockups of the transmit side when using the smsc95xx driver connected to a USB3 port on an i7 (Ivybridge) cpu. These errors are very intermittent - less than once a day, and it isn't actually clear that they are related to traffic load. Most of the systems are running the 3.2 kernel from Ubuntu 12.04 but I've seen the same problem when running a 3.4 kernel. Have you tried the latest stable kernel or the latest -rc kernel? No. Although I've written a lot of device driver and comms protocol stack code over the years I've not had to work out how to build linux kernels - this may be the time I start! Given the difficulty (or rather the infrequency) of reproducing the problem I'd like to sort out the failing code path before changing kernels so that I can then verify that a more recent kernel fixes it. ... We are also seeing similar problems if we connect to a USB2 header. Do you mean a USB 2.0 port under the xHCI host controller? What does `lsusb -t` show as the parent host controller in that case? To clarify the fail trace below is from an xhci controller, but I'm pretty sure we've seen a tx lockup when using ohci. The usbmon trace when the tx locks up starts with: Two Bo 'fail -71', 6 succeed, one fails -32 the rest fail -104. done:9871:6913:60 88020ea16a80 293818155 C Bo:3:003:2 -71 EPROTO 512 done:9872:6927:59 88020ea16f00 293818235 C Bo:3:003:2 -71 EPROTO 0 done:9873:6875:58 88020ea16480 293818313 C Bo:3:003:2 0 1514 done:9874:6786:57 88020c7c83c0 293818353 C Bo:3:003:2 0 1514 done:9875:6794:56 88020c7c80c0 293818470 C Bo:3:003:2 0 1514 done:9876:6789:55 88020c7c8e40 293818589 C Bo:3:003:2 0 1514 done:9877:6775:54 88020c7c8240 293818702 C Bo:3:003:2 0 1090 done:9878:6751:53 88020c7c8180 293818803 C Bo:3:003:2 0 1514 done:9879:6735:52 88020c7c89c0 293818885 C Bo:3:003:2 -32 EPIPE 0 done:9880:6671:51 88020c7c8900 293818925 C Bo:3:003:2 -104 ECONNRESET 0 ... the ring is cleared in a software loop done:9927:1292:4 88020cf0c480 293819015 C Bo:3:003:2 -104 0 done:9928:1170:3 88020ea160c0 293819016 C Bo:3:003:2 -104 0 Something is known to be wrong... start:9931 88020ea160c0 293819037 S Co:3:003:0 s 02 01 0002 0 done:9929:1080:3 88020ea16780 293819044 C Bo:3:003:2 -104 0 done:9930:945:2 88020ea16000 293819044 C Bo:3:003:2 -104 0 done:9931:48:1 88020ea160c0 293819085 C Co:3:003:0 0 0 I've also seen resets that start with an interrupt from device 1. In this case the ring is cleared with ESHUTDOWN and dmesg traces what looks like an unplug-plug action. Last successful ethernet transmit 88020c4870c0 701760986 C Bo:3:018:2 0 1090 88020c4870c0 701760992 S Bo:3:018:2 -115 1090 = 3a34 3a44 22003200 00224d98 d8460002 1f0057d7 08004500 042879ca Interrupt - I think from the root hub. 88020c8570c0 701761038 C Ii:3:001:1 0:2048 1 = 02 88020c8570c0 701761042 S Ii:3:001:1 -115:2048 4 88020ea16840 701761046 C Ii:3:018:3 -71:1 0 EPROTO 88020ea16840 701761047 S Ii:3:018:3 -115:1 16 88020c53c480 701761051 C Bi:3:018:1 -71 0 88020c487180 701761054 C Bo:3:018:2 -71 1024 880210570240 701761063 S Ci:3:001:0 s a3 00 0001 0004 4 880210570240 701761071 C Ci:3:001:0 0 4 = 00010100 880210570240 701761074 S Co:3:001:0 s 23 01 0010 0001 0 88020c53c540 701761076 C Bi:3:018:1 -71 0 880210570240 701761078 C Co:3:001:0 0 0 88020c487240 701761117 C Bo:3:018:2 -71 0 88020c53cd80 701761156 C Bi:3:018:1 -108 0 ESHITDOWN 88020c53c9c0 701761158 C Bi:3:018:1 -108 0 88020c487840 701761196 C Bo:3:018:2 -108 0 88020c487900 701761201 C Bo:3:018:2 -108 0 ... lots of similar lines deleted 88020c487540 701761299 C Bo:3:018:2 -108 0 88020c4870c0 701761300 C Bo:3:018:2 -108 0 88020ea16840 701761304 C Ii:3:018:3 -71:1 0 88020c8570c0 701782179 C Ii:3:001:1 0:2048 1 = 02 88020c8570c0 701782183 S Ii:3:001:1 -115:2048 4 88020c95be40 703089906 C Ii:3:020:1 -108:8 0 device 17 will be the hub on the smsc95xx chip 88020c95b240 703427572 C Ii:3:017:1 -108:2048 0 88020c487540 703427788 S Ci:3:001:0 s a3 00 0001 0004 4 88020c487540 703427803 C Ci:3:001:0 0 4 = 01010100 ... I would suggest you try with the latest stable kernel, with CONFIG_USB_DEBUG and CONFIG_USB_XHCI_HCD_DEBUGGING enabled. If you try the latest 3.12-rc, you will only need the CONFIG_USB_DEBUG. Or, if that output is too much (it will spew on short packets, which may be an issue with your ethernet adapter), The only way I've got the above usbmon trace is by reading 100 lines (with dd) and saving the
Re: [PATCH 1/2] dma: cppi41: redo descriptor collection in abort case
On 10/17/2013 04:23 PM, Daniel Mack wrote: Daniel, could please look if this solves your suspend / resume warnings? Will do (hopefully) tomorrow. So this is a replacement for my dma: cppi41: move -EAGAIN in tear_down patch, or does it go on top of it? I applied your three patches and manage to break 2 of 4 tests I had. It was still the same without your patch. So I made this change and merged it back into your patch so this patch should apply ontop of your 2/3. How does your patch queue look like? Someone should probably re-collect all necessary patches for the next merge window eventually, so Vinod knows what to apply :) dma: cppi41: add support for suspend and resume dma: cppi41: restore more registers dma: cppi41: use cppi41_pop_desc() where possible dma: cppi41: redo descriptor collection in abort case dma: cppi41: return code 0 of pm_runtime_get_sync() is not an error The first one is in Vinod's tree. Thanks, Daniel Sebastian -- 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: device enumeration fail (only?) on ehci
On Thu, 17 Oct 2013, Alexander Stein wrote: But with xHCI and OHCI, the reconnect succeeds whereas with EHCI it fails? Yep. But it even works on EHCI if there is a full-speed-hub somewhere before that device. It's hard to guess why. The behavior under xHCI is slightly different from the other two, which behave the same. You can force EHCI and OHCI to work more like xHCI by doing: echo 1 /sys/module/usbcore/parameters/old_scheme_first I tried that but there wasn't any difference. Maybe it's a data toggle issue involving the internal hub, but the only way to find out for sure is to use a bus analyzer. We tried that but didn't see any USB traffic for those USB device numbers where enumeration failed. Did you compare the analyzer results for xHCI and EHCI? In theory, since the device behaves differently under the two controllers, there must be something different happening on the bus. One thing about the error log: [249741.159104] usb 2-1.6.1: new full-speed USB device number 109 using ehci-pci [249751.565047] usb 2-1.6.1: device not accepting address 109, error -110 [249751.638197] usb 2-1.6.1: new full-speed USB device number 110 using ehci-pci [249762.044199] usb 2-1.6.1: device not accepting address 110, error -110 [249762.117273] usb 2-1.6.1: new full-speed USB device number 111 using ehci-pci [249777.196292] usb 2-1.6.1: device descriptor read/64, error -110 [249792.376349] usb 2-1.6.1: device descriptor read/64, error -110 [249792.550467] usb 2-1.6.1: new full-speed USB device number 112 using ehci-pci [249807.629330] usb 2-1.6.1: device descriptor read/64, error -110 [249822.809391] usb 2-1.6.1: device descriptor read/64, error -110 [249822.910435] hub 2-1.6:1.0: unable to enumerate USB device on port 1 There are different errors device not accepting address xxx and device descriptor read/64, error -110. Does that mean that reading the device descriptor succeeded when the USB device address shall be set? No. The USB core tries four times to initialize a newly detected device. Two of those times, it sends Set-Address before Get-Descriptor (called the old scheme). The other two times, it sends Get-Descriptor before Set-Address (called the new scheme). The old scheme is recommended in the USB spec, and the new scheme is used by Windows. The idea is that by trying both, we have a better chance of working with all devices. 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] ehci: remove old TT sched code
On Thu, 17 Oct 2013, Dan Streetman wrote: On Wed, Oct 16, 2013 at 5:09 PM, Alan Stern st...@rowland.harvard.edu wrote: On Wed, 16 Oct 2013, Dan Streetman wrote: On Wed, Oct 16, 2013 at 10:34 AM, Alan Stern st...@rowland.harvard.edu wrote: On Tue, 15 Oct 2013, Dan Streetman wrote: Until the new scheduler is fixed up to work properly, I prefer to keep both options available. Ok, no hurry. With the work you've done on it before and the new stuff in usb-next it should be working very well soon :-) Dear me, no... The changes I have made so far amount to perhaps 25% of the work needed to make it truly reliable. It has so many bugs, I wouldn't even try to list them all. Heh, well I guess I wrote it when I was young and coded sloppily ;-) I'll review it all again and try to help fix the bugs. It's not a matter of sloppy coding but of design. The main issues are: We don't handle siTD back link pointers. Therefore we can't allow full-speed isochronous IN transfers to be scheduled in B-uframe 4 or later. We don't handle FSTN nodes in the schedule. Therefore we can't allow full- or low-speed interrupt transfers to be scheduled in B-uframe 4 or later. (In principle, that is -- in practice we do allow uframes 4 and 5, at the cost of having too few CSPLIT packets.) We don't compute the full-speed budget according to the USB spec. The spec says that budgets are to be computed in terms of best-case full-speed bytes, not worst-case microseconds. If an URB's bandwidth can't be accomodated in the current schedule, we don't try to rebalance the schedule to make the bandwidth fit. We don't obey various restrictions on allowable schedules. For example, the EHCI spec says that any full-speed isochronous transfer of length = 588 bytes must be the first one in its frame, but we don't enforce this. We reserve an endpoint's bandwidth when the first URB is submitted rather than when the alternate setting is installed. There's a bunch of smaller issues under each of those categories, but those are the biggies. 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 v2 1/7] usb: dwc3: get usb_phy only if the platform indicates the presence of PHY's
On Wed, Oct 16, 2013 at 04:27:26PM +0300, Roger Quadros wrote: On 10/16/2013 04:10 PM, Kishon Vijay Abraham I wrote: Hi roger, On Wednesday 16 October 2013 06:33 PM, Roger Quadros wrote: Hi Kishon, On 10/15/2013 10:54 PM, Kishon Vijay Abraham I wrote: There can be systems which does not have a external usb_phy, so get usb_phy only if dt data indicates the presence of PHY in the case of dt boot or if platform_data indicates the presence of PHY. Also remove checking if return value is -ENXIO since it's now changed to always enable usb_phy layer. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com --- In usb_get_phy_by_phandle, index 0 always refers to usb2 phy and index 1 always refers to usb3 phy. Since we've lived so long with this, this patch will make an assumption that if only one entry is populated in *usb-phy* property, it will be usb2 phy and the next entry will be usb3 phy. drivers/usb/dwc3/Kconfig |1 + drivers/usb/dwc3/core.c | 72 -- drivers/usb/dwc3/platform_data.h |2 ++ 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 70fc430..8e385b4 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -1,6 +1,7 @@ config USB_DWC3 tristate DesignWare USB3 DRD Core Support depends on (USB || USB_GADGET) HAS_DMA + select USB_PHY select USB_XHCI_PLATFORM if USB_SUPPORT USB_XHCI_HCD help Say Y or M here if your system has a Dual Role SuperSpeed diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 474162e..cb91d70 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -354,6 +354,7 @@ static int dwc3_probe(struct platform_device *pdev) struct device_node *node = dev-of_node; struct resource *res; struct dwc3 *dwc; + int count; int ret = -ENOMEM; @@ -387,16 +388,49 @@ static int dwc3_probe(struct platform_device *pdev) if (node) { dwc-maximum_speed = of_usb_get_maximum_speed(node); - dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0); - dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1); + count = of_count_phandle_with_args(node, usb-phy, NULL); + switch (count) { + case 2: + dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, + usb-phy, 1); + if (IS_ERR(dwc-usb3_phy)) { + dev_err(dev, usb3 phy not found\n); + return PTR_ERR(dwc-usb3_phy); + } + case 1: + dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, + usb-phy, 0); + if (IS_ERR(dwc-usb2_phy)) { + dev_err(dev, usb2 phy not found\n); + return PTR_ERR(dwc-usb2_phy); + } + break; In the Exynos case, there is only 1 phy and it is the USB3 phy. This code will wrongly treat it as usb2_phy. That was the case even before this patch no? Unfortunately the old USB PHY library doesn't have APIs to get PHYs in a better way. If we try modifying the USB PHY library, it'll be kind of duplicating what is already there in the Generic PHY library. I'd rather prefer Exynos guys to use the new framework. OK. I agree with you. Do you know if there are users of dwc3 other than exynos5250 and omap5? If not, we should get rid of the old USB PHY altogether. Intel's Baytrail, at least. But they don't use DT. -- balbi signature.asc Description: Digital signature
Re: [PATCH 1/2] xhci: fix reset for not halted endpoints
On Wed, 16 Oct 2013, Sarah Sharp wrote: I think there's some nasty race conditions here. There's several different structures this code and other functions are manipulating: - the endpoint ring contents - the endpoint ring dequeue pointer - the endpoint's cur_td and cancelled_td lists The other functions you need to look at are xhci_urb_enqueue, xhci_urb_dequeue, and xhci_handle_cmd_stop_ep. Arguably, we should be doing something about drivers attempting to change alternate interface settings at the same time they're resetting endpoints, but I think the solution should be that drivers just shouldn't do that. However, we do need to handle the case where the reset endpoint races with URB cancellation and enqueue. You can simplify part of the problem by not allowing an endpoint to be reset if it has any pending URBs. Just fail the reset in this case. Also, while you're going through the whole remove-and-add procedure for endpoints that aren't halted, do you want to hold the bandwidth mutex? If the procedure isn't atomic, there's a possibility that some other device could change configs in the middle. This would also prevent concurrent altsetting changes. 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] xhci: Fix sparse warnings caused by: For streams the dequeue ptr must be read from the stream ctx
Note this patch is probably best squashed into the original For streams the dequeue ptr must be read from the stream ctx patch. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/host/xhci-ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 111c619..38f64d2 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1146,7 +1146,7 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, * cancelling URBs, which might not be an error... */ } else { - __le64 deq; + u64 deq; /* 4.6.10 deq ptr is written to the stream ctx for streams */ if (ep-ep_state EP_HAS_STREAMS) { struct xhci_stream_ctx *ctx = -- 1.8.3.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
[PATCH 1/2] usb.h: Document new usb_host_endpoint streams member
Note this patch is probably best squashed into my usb-core: Track if an endpoint has streams patch. Signed-off-by: Hans de Goede hdego...@redhat.com --- include/linux/usb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/usb.h b/include/linux/usb.h index 1c924eb..a4c8406 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -57,6 +57,7 @@ struct ep_device; * @extra: descriptors following this endpoint in the configuration * @extralen: how many bytes of extra are valid * @enabled: URBs may be submitted to this endpoint + * @streams: number of USB-3 streams allocated on the endpoint * * USB requests are always queued to a given endpoint, identified by a * descriptor within an active interface in a given USB configuration. -- 1.8.3.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
Re: [PATCH v4 03/17] clk: at91: add PMC base support
On 11/10/2013 09:37, Boris BREZILLON : This patch adds at91 PMC (Power Management Controller) base support. All at91 clocks managed by the PMC unit will use this framework. This framework provides the following fonctionalities: - define a new struct at91_pmc to hide PMC internals (lock, PMC memory mapping, irq domain, ...) - read/write helper functions (pmc_read/write) to access PMC registers - lock/unlock helper functions (pmc_lock/unlock) to lock/unlock access to pmc registers - a new irq domain and its associated irq chip to request PMC specific interrupts (useful for clk prepare callbacks) The PMC unit is declared as a dt clk provider (CLK_OF_DECLARE), and every clk using this framework will declare a table of of_at91_clk_init_cb_t and add it to the pmc_clk_ids table. When the pmc dt clock setup function is called (by of_clk_init function), it triggers the registration of every supported child clk (those matching the definitions in pmc_clk_ids). This patch copies at91_pmc_base (memory mapping) and at91sam9_idle (function) from arch/arm/mach-at91/clock.c (which is not compiled if COMMON_CLK_AT91 is enabled). Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/Makefile |1 + drivers/clk/at91/Makefile |5 + drivers/clk/at91/pmc.c| 283 + drivers/clk/at91/pmc.h| 58 ++ 4 files changed, 347 insertions(+) create mode 100644 drivers/clk/at91/Makefile create mode 100644 drivers/clk/at91/pmc.c create mode 100644 drivers/clk/at91/pmc.h diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 7b11106..28c2678 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_ARCH_ZYNQ) += zynq/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_PLAT_SAMSUNG)+= samsung/ +obj-$(CONFIG_COMMON_CLK_AT91) += at91/ obj-$(CONFIG_X86) += x86/ diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile new file mode 100644 index 000..1d4fb21 --- /dev/null +++ b/drivers/clk/at91/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for at91 specific clk +# + +obj-y += pmc.o diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c new file mode 100644 index 000..d92e46c --- /dev/null +++ b/drivers/clk/at91/pmc.c @@ -0,0 +1,283 @@ +/* + * drivers/clk/at91/pmc.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/io.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/irqchip/chained_irq.h +#include linux/irqdomain.h +#include linux/of_irq.h + +#include asm/proc-fns.h + +#include pmc.h + +void __iomem *at91_pmc_base; +EXPORT_SYMBOL_GPL(at91_pmc_base); + +void at91sam9_idle(void) +{ + at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK); + cpu_do_idle(); +} + +static void pmc_irq_mask(struct irq_data *d) +{ + struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); + + pmc_write(pmc, AT91_PMC_IDR, 1 d-hwirq); +} + +static void pmc_irq_unmask(struct irq_data *d) +{ + struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); + + pmc_write(pmc, AT91_PMC_IER, 1 d-hwirq); +} + +static int pmc_irq_set_type(struct irq_data *d, unsigned type) +{ + if (type != IRQ_TYPE_LEVEL_HIGH) { + pr_warn(PMC: type not supported (support only IRQ_TYPE_LEVEL_HIGH type)\n); + return -EINVAL; + } + + return 0; +} + +static struct irq_chip pmc_irq = { + .name = PMC, + .irq_disable = pmc_irq_mask, + .irq_mask = pmc_irq_mask, + .irq_unmask = pmc_irq_unmask, + .irq_set_type = pmc_irq_set_type, +}; + +static struct lock_class_key pmc_lock_class; + +static int pmc_irq_map(struct irq_domain *h, unsigned int virq, + irq_hw_number_t hw) +{ + struct at91_pmc *pmc = h-host_data; + + irq_set_lockdep_class(virq, pmc_lock_class); + + irq_set_chip_and_handler(virq, pmc_irq, +handle_level_irq); + set_irq_flags(virq, IRQF_VALID); + irq_set_chip_data(virq, pmc); + + return 0; +} + +static int pmc_irq_domain_xlate(struct irq_domain *d, + struct device_node *ctrlr, + const u32 *intspec, unsigned int intsize, + irq_hw_number_t *out_hwirq, + unsigned int *out_type) +{ + struct at91_pmc *pmc = d-host_data; + const
Re: [PATCH v4 04/17] clk: at91: add PMC macro file for dt definitions
On 11/10/2013 10:41, Boris BREZILLON : This patch adds a new macro file for PMC macros. This macro file includes the definitions of SR (status register) bit offsets and will be use to reference PMC irqs. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- include/dt-bindings/clk/at91.h | 22 ++ 1 file changed, 22 insertions(+) create mode 100644 include/dt-bindings/clk/at91.h diff --git a/include/dt-bindings/clk/at91.h b/include/dt-bindings/clk/at91.h new file mode 100644 index 000..0b4cb99 --- /dev/null +++ b/include/dt-bindings/clk/at91.h @@ -0,0 +1,22 @@ +/* + * This header provides constants for AT91 pmc status. + * + * The constants defined in this header are being used in dts. + * + * Licensed under GPLv2 or later. + */ + +#ifndef _DT_BINDINGS_CLK_AT91_H +#define _DT_BINDINGS_CLK_AT91_H + +#define AT91_PMC_MOSCS 0 /* MOSCS Flag */ +#define AT91_PMC_LOCKA 1 /* PLLA Lock */ +#define AT91_PMC_LOCKB 2 /* PLLB Lock */ +#define AT91_PMC_MCKRDY3 /* Master Clock */ +#define AT91_PMC_LOCKU 6 /* UPLL Lock */ +#define AT91_PMC_PCKRDY(id)(8 + (id)) /* Programmable Clock */ +#define AT91_PMC_MOSCSELS 16 /* Main Oscillator Selection */ +#define AT91_PMC_MOSCRCS 17 /* Main On-Chip RC */ +#define AT91_PMC_CFDEV 18 /* Clock Failure Detector Event */ + +#endif -- Nicolas Ferre -- 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 v4 05/17] clk: at91: add PMC main clock
On 11/10/2013 10:44, Boris BREZILLON : This patch adds new at91 main oscillator clock implementation using common clk framework. If rate is not provided during clock registration it is calculated using the slow clock (main clk parent in this case) rate and MCFR register. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/at91/Makefile |1 + drivers/clk/at91/clk-main.c | 189 +++ drivers/clk/at91/pmc.c |5 ++ drivers/clk/at91/pmc.h |3 + 4 files changed, 198 insertions(+) create mode 100644 drivers/clk/at91/clk-main.c diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 1d4fb21..44105bd 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -3,3 +3,4 @@ # obj-y += pmc.o +obj-y += clk-main.o diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c new file mode 100644 index 000..905ceff --- /dev/null +++ b/drivers/clk/at91/clk-main.c @@ -0,0 +1,189 @@ +/* + * drivers/clk/at91/clk-main.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/delay.h +#include linux/of.h +#include linux/of_address.h +#include linux/of_irq.h +#include linux/io.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/sched.h +#include linux/wait.h + +#include pmc.h + +#define SLOW_CLOCK_FREQ32768 +#define MAINF_DIV 16 +#define MAINFRDY_TIMEOUT (((MAINF_DIV + 1) * USEC_PER_SEC) / \ +SLOW_CLOCK_FREQ) +#define MAINF_LOOP_MIN_WAIT(USEC_PER_SEC / SLOW_CLOCK_FREQ) +#define MAINF_LOOP_MAX_WAITMAINFRDY_TIMEOUT + +struct clk_main { + struct clk_hw hw; + struct at91_pmc *pmc; + unsigned long rate; + unsigned int irq; + wait_queue_head_t wait; +}; + +#define to_clk_main(hw) container_of(hw, struct clk_main, hw) + +static irqreturn_t clk_main_irq_handler(int irq, void *dev_id) +{ + struct clk_main *clkmain = (struct clk_main *)dev_id; + + wake_up(clkmain-wait); + disable_irq_nosync(clkmain-irq); + + return IRQ_HANDLED; +} + +static int clk_main_prepare(struct clk_hw *hw) +{ + struct clk_main *clkmain = to_clk_main(hw); + struct at91_pmc *pmc = clkmain-pmc; + unsigned long halt_time, timeout; + u32 tmp; + + while (!(pmc_read(pmc, AT91_PMC_SR) AT91_PMC_MOSCS)) { + enable_irq(clkmain-irq); + wait_event(clkmain-wait, + pmc_read(pmc, AT91_PMC_SR) AT91_PMC_MOSCS); + } + + if (clkmain-rate) + return 0; + + timeout = jiffies + usecs_to_jiffies(MAINFRDY_TIMEOUT); + do { + halt_time = jiffies; + tmp = pmc_read(pmc, AT91_CKGR_MCFR); + if (tmp AT91_PMC_MAINRDY) + return 0; + usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT); + } while (time_before(halt_time, timeout)); + + return 0; +} + +static int clk_main_is_prepared(struct clk_hw *hw) +{ + struct clk_main *clkmain = to_clk_main(hw); + + return !!(pmc_read(clkmain-pmc, AT91_PMC_SR) AT91_PMC_MOSCS); +} + +static unsigned long clk_main_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + u32 tmp; + struct clk_main *clkmain = to_clk_main(hw); + struct at91_pmc *pmc = clkmain-pmc; + + if (clkmain-rate) + return clkmain-rate; + + tmp = pmc_read(pmc, AT91_CKGR_MCFR) AT91_PMC_MAINF; + clkmain-rate = (tmp * parent_rate) / MAINF_DIV; + + return clkmain-rate; +} + +static const struct clk_ops main_ops = { + .prepare = clk_main_prepare, + .is_prepared = clk_main_is_prepared, + .recalc_rate = clk_main_recalc_rate, +}; + +static struct clk * __init +at91_clk_register_main(struct at91_pmc *pmc, + unsigned int irq, + const char *name, + const char *parent_name, + unsigned long rate) +{ + int ret; + struct clk_main *clkmain; + struct clk *clk = NULL; + struct clk_init_data init; + + if (!pmc || !irq || !name) + return ERR_PTR(-EINVAL); + + if (!rate !parent_name) + return ERR_PTR(-EINVAL); + + clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL); + if (!clkmain) + return ERR_PTR(-ENOMEM); + + init.name = name; + init.ops = main_ops; + init.parent_names
Re: [PATCH v4 07/17] clk: at91: add PMC master clock
On 11/10/2013 10:51, Boris BREZILLON : This patch adds new at91 master clock implementation using common clk framework. The master clock layout describe the MCKR register layout. There are 2 master clock layouts: - at91rm9200 - at91sam9x5 Master clocks are given characteristics: - min/max clock output rate These characteristics are checked during rate change to avoid over/underclocking. These characteristics are described in atmel's SoC datasheet in Electrical Characteristics paragraph. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/at91/Makefile |2 +- drivers/clk/at91/clk-master.c | 278 + drivers/clk/at91/clk-pll.c| 10 +- drivers/clk/at91/pmc.c|9 ++ drivers/clk/at91/pmc.h|5 + 5 files changed, 295 insertions(+), 9 deletions(-) create mode 100644 drivers/clk/at91/clk-master.c diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 902bbf1..e28fb2b 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -3,4 +3,4 @@ # obj-y += pmc.o -obj-y += clk-main.o clk-pll.o clk-plldiv.o +obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c new file mode 100644 index 000..58af23d --- /dev/null +++ b/drivers/clk/at91/clk-master.c @@ -0,0 +1,278 @@ +/* + * drivers/clk/at91/clk-master.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/of_irq.h +#include linux/io.h +#include linux/wait.h +#include linux/sched.h +#include linux/interrupt.h +#include linux/irq.h + +#include pmc.h + +#define MASTER_SOURCE_MAX 4 + +#define MASTER_PRES_MASK 0x7 +#define MASTER_PRES_MAXMASTER_PRES_MASK +#define MASTER_DIV_SHIFT 8 +#define MASTER_DIV_MASK0x3 + +struct clk_master_characteristics { + struct clk_range output; + u32 divisors[4]; + u8 have_div3_pres; +}; + +struct clk_master_layout { + u32 mask; + u8 pres_shift; +}; + +#define to_clk_master(hw) container_of(hw, struct clk_master, hw) + +struct clk_master { + struct clk_hw hw; + struct at91_pmc *pmc; + unsigned int irq; + wait_queue_head_t wait; + const struct clk_master_layout *layout; + const struct clk_master_characteristics *characteristics; +}; + +static irqreturn_t clk_master_irq_handler(int irq, void *dev_id) +{ + struct clk_master *master = (struct clk_master *)dev_id; + + wake_up(master-wait); + disable_irq_nosync(master-irq); + + return IRQ_HANDLED; +} +static int clk_master_prepare(struct clk_hw *hw) +{ + struct clk_master *master = to_clk_master(hw); + struct at91_pmc *pmc = master-pmc; + + while (!(pmc_read(pmc, AT91_PMC_SR) AT91_PMC_MCKRDY)) { + enable_irq(master-irq); + wait_event(master-wait, + pmc_read(pmc, AT91_PMC_SR) AT91_PMC_MCKRDY); + } + + return 0; +} + +static int clk_master_is_prepared(struct clk_hw *hw) +{ + struct clk_master *master = to_clk_master(hw); + + return !!(pmc_read(master-pmc, AT91_PMC_SR) AT91_PMC_MCKRDY); +} + +static unsigned long clk_master_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + u8 pres; + u8 div; + unsigned long rate = parent_rate; + struct clk_master *master = to_clk_master(hw); + struct at91_pmc *pmc = master-pmc; + const struct clk_master_layout *layout = master-layout; + const struct clk_master_characteristics *characteristics = + master-characteristics; + u32 tmp; + + pmc_lock(pmc); + tmp = pmc_read(pmc, AT91_PMC_MCKR) layout-mask; + pmc_unlock(pmc); + + pres = (tmp layout-pres_shift) MASTER_PRES_MASK; + div = (tmp MASTER_DIV_SHIFT) MASTER_DIV_MASK; + + if (characteristics-have_div3_pres pres == MASTER_PRES_MAX) + rate /= 3; + else + rate = pres; + + rate /= characteristics-divisors[div]; + + if (rate characteristics-output.min) + pr_warn(master clk is underclocked); + else if (rate characteristics-output.max) + pr_warn(master clk is overclocked); + + return rate; +} + +static u8 clk_master_get_parent(struct clk_hw *hw) +{ + struct clk_master *master = to_clk_master(hw); + struct
Re: [PATCH v4 08/17] clk: at91: add PMC system clocks
On 11/10/2013 11:41, Boris BREZILLON : This patch adds new at91 system clock implementation using common clk framework. Some peripherals need to enable a system clock in order to work properly. Each system clock is given an id based on the bit position in SCER/SCDR registers. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/at91/Makefile |1 + drivers/clk/at91/clk-system.c | 193 + drivers/clk/at91/pmc.c|5 ++ drivers/clk/at91/pmc.h|3 + 4 files changed, 202 insertions(+) create mode 100644 drivers/clk/at91/clk-system.c diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index e28fb2b..c2b7068 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -4,3 +4,4 @@ obj-y += pmc.o obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o +obj-y += clk-system.o diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c new file mode 100644 index 000..603b4b1 --- /dev/null +++ b/drivers/clk/at91/clk-system.c @@ -0,0 +1,193 @@ +/* + * drivers/clk/at91/clk-system.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/io.h + +#include pmc.h + +#define SYSTEM_MAX_ID 31 + +#define to_clk_system(hw) container_of(hw, struct clk_system, hw) +struct clk_system { + struct clk_hw hw; + struct at91_pmc *pmc; + u8 id; +}; + +static int clk_system_enable(struct clk_hw *hw) +{ + struct clk_system *sys = to_clk_system(hw); + struct at91_pmc *pmc = sys-pmc; + + pmc_write(pmc, AT91_PMC_SCER, 1 sys-id); + return 0; +} + +static void clk_system_disable(struct clk_hw *hw) +{ + struct clk_system *sys = to_clk_system(hw); + struct at91_pmc *pmc = sys-pmc; + + pmc_write(pmc, AT91_PMC_SCDR, 1 sys-id); +} + +static int clk_system_is_enabled(struct clk_hw *hw) +{ + struct clk_system *sys = to_clk_system(hw); + struct at91_pmc *pmc = sys-pmc; + + return !!(pmc_read(pmc, AT91_PMC_SCSR) (1 sys-id)); +} + +static const struct clk_ops system_ops = { + .enable = clk_system_enable, + .disable = clk_system_disable, + .is_enabled = clk_system_is_enabled, +}; + +static struct clk * __init +at91_clk_register_system(struct at91_pmc *pmc, const char *name, +const char *parent_name, u8 id) +{ + struct clk_system *sys; + struct clk *clk = NULL; + struct clk_init_data init; + + if (!parent_name || id SYSTEM_MAX_ID) + return ERR_PTR(-EINVAL); + + sys = kzalloc(sizeof(*sys), GFP_KERNEL); + if (!sys) + return ERR_PTR(-ENOMEM); + + init.name = name; + init.ops = system_ops; + init.parent_names = parent_name; + init.num_parents = 1; + /* +* CLK_IGNORE_UNUSED is used to avoid ddrck switch off. +* TODO : we should implement a driver supporting at91 ddr controller +* (see drivers/memory) which would request and enable the ddrck clock. +* When this is done we will be able to remove CLK_IGNORE_UNUSED flag. +*/ + init.flags = CLK_IGNORE_UNUSED; + + sys-id = id; + sys-hw.init = init; + sys-pmc = pmc; + + clk = clk_register(NULL, sys-hw); + if (IS_ERR(clk)) + kfree(sys); + + return clk; +} + +struct clk_system_data { + struct clk **clks; + u8 *ids; + unsigned int clk_num; +}; + +static struct clk * __init +of_clk_src_system_get(struct of_phandle_args *clkspec, void *data) +{ + struct clk_system_data *clk_data = data; + unsigned int id = clkspec-args[0]; + int i; + + if (id SYSTEM_MAX_ID) + goto err; + + for (i = 0; i clk_data-clk_num; i++) { + if (clk_data-ids[i] == id) + return clk_data-clks[i]; + } + +err: + pr_err(%s: invalid clock id %d\n, __func__, id); + return ERR_PTR(-EINVAL); +} + +static void __init +of_at91_clk_sys_setup(struct device_node *np, struct at91_pmc *pmc) +{ + int i; + int num; + u32 id; + struct clk *clk; + u8 *ids; + struct clk **clks; + struct clk_system_data *clktab; + const char *name; + struct device_node *sysclknp; + const char *parent_name; + + num = of_get_child_count(np); + if (num (SYSTEM_MAX_ID + 1)) + return; + + clktab = kzalloc(sizeof(*clktab), GFP_KERNEL); +
Re: [PATCH v4 06/17] clk: at91: add PMC pll clocks
On 11/10/2013 10:48, Boris BREZILLON : This patch adds new at91 pll clock implementation using common clk framework. The pll clock layout describe the PLLX register layout. There are four pll clock layouts: - at91rm9200 - at91sam9g20 - at91sam9g45 - sama5d3 PLL clocks are given characteristics: - min/max clock source rate - ranges of valid clock output rates - values to set in out and icpll fields for each supported output range These characteristics are checked during rate change to avoid over/underclocking. These characteristics are described in atmel's SoC datasheet in Electrical Characteristics paragraph. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/at91/Makefile |2 +- drivers/clk/at91/clk-pll.c| 545 + drivers/clk/at91/clk-plldiv.c | 137 +++ drivers/clk/at91/pmc.c| 21 ++ drivers/clk/at91/pmc.h| 11 + include/linux/clk/at91_pmc.h |2 + 6 files changed, 717 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/at91/clk-pll.c create mode 100644 drivers/clk/at91/clk-plldiv.c diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 44105bd..902bbf1 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -3,4 +3,4 @@ # obj-y += pmc.o -obj-y += clk-main.o +obj-y += clk-main.o clk-pll.o clk-plldiv.o diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c new file mode 100644 index 000..44caddf --- /dev/null +++ b/drivers/clk/at91/clk-pll.c @@ -0,0 +1,545 @@ +/* + * drivers/clk/at91/clk-pll.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/of_irq.h +#include linux/io.h +#include linux/wait.h +#include linux/sched.h +#include linux/interrupt.h +#include linux/irq.h + +#include pmc.h + +#define PLL_STATUS_MASK(id)(1 (1 + (id))) +#define PLL_REG(id)(AT91_CKGR_PLLAR + ((id) * 4)) +#define PLL_DIV_MASK 0xff +#define PLL_DIV_MAXPLL_DIV_MASK +#define PLL_DIV(reg) ((reg) PLL_DIV_MASK) +#define PLL_MUL(reg, layout) (((reg) (layout)-mul_shift) \ +(layout)-mul_mask) +#define PLL_ICPR_SHIFT(id) ((id) * 16) +#define PLL_ICPR_MASK(id) (0x PLL_ICPR_SHIFT(id)) +#define PLL_MAX_COUNT 0x3ff +#define PLL_COUNT_SHIFT8 +#define PLL_OUT_SHIFT 14 +#define PLL_MAX_ID 1 + +struct clk_pll_characteristics { + struct clk_range input; + int num_output; + struct clk_range *output; + u16 *icpll; + u8 *out; +}; + +struct clk_pll_layout { + u32 pllr_mask; + u16 mul_mask; + u8 mul_shift; +}; + +#define to_clk_pll(hw) container_of(hw, struct clk_pll, hw) + +struct clk_pll { + struct clk_hw hw; + struct at91_pmc *pmc; + unsigned int irq; + wait_queue_head_t wait; + u8 id; + u8 div; + u8 range; + u16 mul; + const struct clk_pll_layout *layout; + const struct clk_pll_characteristics *characteristics; +}; + +static irqreturn_t clk_pll_irq_handler(int irq, void *dev_id) +{ + struct clk_pll *pll = (struct clk_pll *)dev_id; + + wake_up(pll-wait); + disable_irq_nosync(pll-irq); + + return IRQ_HANDLED; +} + +static int clk_pll_prepare(struct clk_hw *hw) +{ + struct clk_pll *pll = to_clk_pll(hw); + struct at91_pmc *pmc = pll-pmc; + const struct clk_pll_layout *layout = pll-layout; + u8 id = pll-id; + u32 mask = PLL_STATUS_MASK(id); + int offset = PLL_REG(id); + u8 out = 0; + u32 pllr, icpr; + u8 div; + u16 mul; + + pllr = pmc_read(pmc, offset); + div = PLL_DIV(pllr); + mul = PLL_MUL(pllr, layout); + + if ((pmc_read(pmc, AT91_PMC_SR) mask) + (div == pll-div mul == pll-mul)) + return 0; + + if (characteristics-out) + out = characteristics-out[pll-range]; + if (characteristics-icpll) { + icpr = pmc_read(pmc, AT91_PMC_PLLICPR) ~PLL_ICPR_MASK(id); + icpr |= (characteristics-icpll[pll-range] + PLL_ICPR_SHIFT(id)); + pmc_write(pmc, AT91_PMC_PLLICPR, icpr); + } + + pllr = ~layout-pllr_mask; + pllr |= layout-pllr_mask + (pll-div | (PLL_MAX_COUNT PLL_COUNT_SHIFT) | + (out PLL_OUT_SHIFT) | + ((pll-mul layout-mul_mask) layout-mul_shift)); +
Re: [PATCH v4 09/17] clk: at91: add PMC peripheral clocks
On 11/10/2013 11:44, Boris BREZILLON : This patch adds new at91 peripheral clock implementation using common clk framework. Almost all peripherals provided by at91 SoCs need a clock to work properly. This clock is enabled/disabled using PCER/PCDR resgisters. Each peripheral is given an id (see atmel's datasheets) which is used to define and reference peripheral clocks. Some new SoCs (at91sam9x5 and sama5d3) provide a new register (PCR) where you can configure the peripheral clock as a division of the master clock. This will help reducing the peripherals power comsumption. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/at91/Makefile |2 +- drivers/clk/at91/clk-peripheral.c | 407 + drivers/clk/at91/pmc.c|9 + drivers/clk/at91/pmc.h|5 + 4 files changed, 422 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/at91/clk-peripheral.c diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index c2b7068..04deba3 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -4,4 +4,4 @@ obj-y += pmc.o obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o -obj-y += clk-system.o +obj-y += clk-system.o clk-peripheral.o diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c new file mode 100644 index 000..2dce2e2 --- /dev/null +++ b/drivers/clk/at91/clk-peripheral.c @@ -0,0 +1,407 @@ +/* + * drivers/clk/at91/clk-peripheral.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/io.h + +#include pmc.h + +#define PERIPHERAL_MAX 64 + +#define PERIPHERAL_AT91RM9200 0 +#define PERIPHERAL_AT91SAM9X5 1 + +#define PERIPHERAL_ID_MIN 2 +#define PERIPHERAL_ID_MAX 31 +#define PERIPHERAL_MASK(id)(1 ((id) PERIPHERAL_ID_MAX)) + +#define PERIPHERAL_RSHIFT_MASK 0x3 +#define PERIPHERAL_RSHIFT(val) (((val) 16) PERIPHERAL_RSHIFT_MASK) + +struct clk_peripheral { + struct clk_hw hw; + struct at91_pmc *pmc; + u32 id; +}; + +#define to_clk_peripheral(hw) container_of(hw, struct clk_peripheral, hw) + +struct clk_sam9x5_peripheral { + struct clk_hw hw; + struct at91_pmc *pmc; + u32 id; + u8 div; + u8 have_div_support; +}; + +#define to_clk_sam9x5_peripheral(hw) \ + container_of(hw, struct clk_sam9x5_peripheral, hw) + +static int clk_peripheral_enable(struct clk_hw *hw) +{ + struct clk_peripheral *periph = to_clk_peripheral(hw); + struct at91_pmc *pmc = periph-pmc; + int offset = AT91_PMC_PCER; + u32 id = periph-id; + + if (id PERIPHERAL_ID_MIN) + return 0; + if (id PERIPHERAL_ID_MAX) + offset = AT91_PMC_PCER1; + pmc_write(pmc, offset, PERIPHERAL_MASK(id)); + return 0; +} + +static void clk_peripheral_disable(struct clk_hw *hw) +{ + struct clk_peripheral *periph = to_clk_peripheral(hw); + struct at91_pmc *pmc = periph-pmc; + int offset = AT91_PMC_PCDR; + u32 id = periph-id; + + if (id PERIPHERAL_ID_MIN) + return; + if (id PERIPHERAL_ID_MAX) + offset = AT91_PMC_PCDR1; + pmc_write(pmc, offset, PERIPHERAL_MASK(id)); +} + +static int clk_peripheral_is_enabled(struct clk_hw *hw) +{ + struct clk_peripheral *periph = to_clk_peripheral(hw); + struct at91_pmc *pmc = periph-pmc; + int offset = AT91_PMC_PCSR; + u32 id = periph-id; + + if (id PERIPHERAL_ID_MIN) + return 1; + if (id PERIPHERAL_ID_MAX) + offset = AT91_PMC_PCSR1; + return !!(pmc_read(pmc, offset) PERIPHERAL_MASK(id)); +} + +static const struct clk_ops peripheral_ops = { + .enable = clk_peripheral_enable, + .disable = clk_peripheral_disable, + .is_enabled = clk_peripheral_is_enabled, +}; + +static struct clk * __init +at91_clk_register_peripheral(struct at91_pmc *pmc, const char *name, +const char *parent_name, u32 id) +{ + struct clk_peripheral *periph; + struct clk *clk = NULL; + struct clk_init_data init; + + if (!pmc || !name || !parent_name || id PERIPHERAL_ID_MAX) + return ERR_PTR(-EINVAL); + + periph = kzalloc(sizeof(*periph), GFP_KERNEL); + if (!periph) + return ERR_PTR(-ENOMEM); + + init.name = name; + init.ops = peripheral_ops; + init.parent_names = (parent_name ? parent_name : NULL); +
Re: [PATCH v4 10/17] clk: at91: add peripheral clk macros for peripheral clk dt bindings
On 11/10/2013 11:53, Boris BREZILLON : This patch adds the peripheral divisors macros (for sam9x5 compatible IPs) which will be used by peripheral clk dt definitions. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- include/dt-bindings/clk/at91.h |6 ++ 1 file changed, 6 insertions(+) diff --git a/include/dt-bindings/clk/at91.h b/include/dt-bindings/clk/at91.h index 0b4cb99..a3b07ca 100644 --- a/include/dt-bindings/clk/at91.h +++ b/include/dt-bindings/clk/at91.h @@ -19,4 +19,10 @@ #define AT91_PMC_MOSCRCS 17 /* Main On-Chip RC */ #define AT91_PMC_CFDEV18 /* Clock Failure Detector Event */ +/* sam9x5 peripheral divisors */ +#define AT91SAM9X5_PERIPH_CLK_DIV1 0 +#define AT91SAM9X5_PERIPH_CLK_DIV2 1 +#define AT91SAM9X5_PERIPH_CLK_DIV4 2 +#define AT91SAM9X5_PERIPH_CLK_DIV8 3 + #endif -- Nicolas Ferre -- 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 v4 11/17] clk: at91: add PMC programmable clocks
On 11/10/2013 11:57, Boris BREZILLON : This patch adds new at91 programmable clocks implementation using common clk framework. A programmable clock is a clock which can be exported on a given pin to clock external devices. Each programmable clock is given an id (from 0 to 8). The number of available programmable clocks depends on the SoC you're using. Programmable clock driver only implements the clock setting (clock rate and parent setting). It must be chained to a system clock in order to enable/disable the generated clock. The PCKX pins used to output the clock signals must be assigned to the appropriate peripheral (see atmel's datasheets). Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- drivers/clk/at91/Makefile |2 + drivers/clk/at91/clk-programmable.c | 423 +++ drivers/clk/at91/pmc.c | 15 ++ drivers/clk/at91/pmc.h |9 + 4 files changed, 449 insertions(+) create mode 100644 drivers/clk/at91/clk-programmable.c diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 04deba3..3873b62 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -5,3 +5,5 @@ obj-y += pmc.o obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o obj-y += clk-system.o clk-peripheral.o + +obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS) += clk-programmable.o diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c new file mode 100644 index 000..b34f80b --- /dev/null +++ b/drivers/clk/at91/clk-programmable.c @@ -0,0 +1,423 @@ +/* + * drivers/clk/at91/clk-programmable.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/of_irq.h +#include linux/io.h +#include linux/wait.h +#include linux/sched.h +#include linux/interrupt.h +#include linux/irq.h + +#include pmc.h + +#define PROG_SOURCE_MAX5 +#define PROG_ID_MAX7 + +#define PROG_STATUS_MASK(id) (1 ((id) + 8)) +#define PROG_PRES_MASK 0x7 +#define PROG_MAX_RM9200_CSS3 + +struct clk_programmable_layout { + u8 pres_shift; + u8 css_mask; + u8 have_slck_mck; +}; + +struct clk_programmable { + struct clk_hw hw; + struct at91_pmc *pmc; + unsigned int irq; + wait_queue_head_t wait; + u8 id; + u8 css; + u8 pres; + u8 slckmck; + const struct clk_programmable_layout *layout; +}; + +#define to_clk_programmable(hw) container_of(hw, struct clk_programmable, hw) + + +static irqreturn_t clk_programmable_irq_handler(int irq, void *dev_id) +{ + struct clk_programmable *prog = (struct clk_programmable *)dev_id; + + wake_up(prog-wait); + + return IRQ_HANDLED; +} + +static int clk_programmable_prepare(struct clk_hw *hw) +{ + u32 tmp; + struct clk_programmable *prog = to_clk_programmable(hw); + struct at91_pmc *pmc = prog-pmc; + const struct clk_programmable_layout *layout = prog-layout; + u8 id = prog-id; + u32 mask = PROG_STATUS_MASK(id); + + tmp = prog-css | (prog-pres layout-pres_shift); + if (layout-have_slck_mck prog-slckmck) + tmp |= AT91_PMC_CSSMCK_MCK; + + pmc_write(pmc, AT91_PMC_PCKR(id), tmp); + + while (!(pmc_read(pmc, AT91_PMC_SR) mask)) + wait_event(prog-wait, pmc_read(pmc, AT91_PMC_SR) mask); + + return 0; +} + +static int clk_programmable_is_ready(struct clk_hw *hw) +{ + struct clk_programmable *prog = to_clk_programmable(hw); + struct at91_pmc *pmc = prog-pmc; + + return !!(pmc_read(pmc, AT91_PMC_SR) AT91_PMC_PCKR(prog-id)); +} + +static unsigned long clk_programmable_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + u32 tmp; + struct clk_programmable *prog = to_clk_programmable(hw); + struct at91_pmc *pmc = prog-pmc; + const struct clk_programmable_layout *layout = prog-layout; + + tmp = pmc_read(pmc, AT91_PMC_PCKR(prog-id)); + prog-pres = (tmp layout-pres_shift) PROG_PRES_MASK; + + return parent_rate prog-pres; +} + +static long clk_programmable_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) +{ + unsigned long best_rate = *parent_rate; + unsigned long best_diff; + unsigned long new_diff; + unsigned long cur_rate; + int shift = shift; + + if (rate *parent_rate) +
Re: [PATCH v4 12/17] clk: at91: add PMC utmi clock
On 11/10/2013 12:22, Boris BREZILLON : This adds new at91 utmi clock implementation using common clk framework. This clock is a pll with a fixed factor (x40). It is used as a source for usb clock. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- arch/arm/mach-at91/Kconfig |7 ++ drivers/clk/at91/Makefile |1 + drivers/clk/at91/clk-utmi.c | 162 +++ drivers/clk/at91/pmc.c |7 ++ drivers/clk/at91/pmc.h |5 ++ 5 files changed, 182 insertions(+) create mode 100644 drivers/clk/at91/clk-utmi.c diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 85b53a4..6ad37da 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -1,5 +1,8 @@ if ARCH_AT91 +config HAVE_AT91_UTMI + bool + config HAVE_AT91_DBGU0 bool @@ -78,6 +81,7 @@ config SOC_SAMA5D3 select HAVE_FB_ATMEL select HAVE_AT91_DBGU1 select AT91_USE_OLD_CLK + select HAVE_AT91_UTMI help Select this if you are using one of Atmel's SAMA5D3 family SoC. This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35. @@ -124,6 +128,7 @@ config SOC_AT91SAM9RL select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_UTMI config SOC_AT91SAM9G45 bool AT91SAM9G45 or AT91SAM9M10 families @@ -131,6 +136,7 @@ config SOC_AT91SAM9G45 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_UTMI help Select this if you are using one of Atmel's AT91SAM9G45 family SoC. This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11. @@ -141,6 +147,7 @@ config SOC_AT91SAM9X5 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_UTMI help Select this if you are using one of Atmel's AT91SAM9x5 family SoC. This means that your SAM9 name finishes with a '5' (except if it is diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 3873b62..a824883 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -7,3 +7,4 @@ obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o obj-y += clk-system.o clk-peripheral.o obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)+= clk-programmable.o +obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c new file mode 100644 index 000..9a133df --- /dev/null +++ b/drivers/clk/at91/clk-utmi.c @@ -0,0 +1,162 @@ +/* + * drivers/clk/at91/clk-utmi.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/interrupt.h +#include linux/irq.h +#include linux/of.h +#include linux/of_address.h +#include linux/of_irq.h +#include linux/io.h +#include linux/sched.h +#include linux/wait.h + +#include pmc.h + +#define UTMI_FIXED_MUL 40 + +struct clk_utmi { + struct clk_hw hw; + struct at91_pmc *pmc; + unsigned int irq; + wait_queue_head_t wait; +}; + +#define to_clk_utmi(hw) container_of(hw, struct clk_utmi, hw) + +static irqreturn_t clk_utmi_irq_handler(int irq, void *dev_id) +{ + struct clk_utmi *utmi = (struct clk_utmi *)dev_id; + + wake_up(utmi-wait); + disable_irq_nosync(utmi-irq); + + return IRQ_HANDLED; +} + +static int clk_utmi_prepare(struct clk_hw *hw) +{ + struct clk_utmi *utmi = to_clk_utmi(hw); + struct at91_pmc *pmc = utmi-pmc; + u32 tmp = at91_pmc_read(AT91_CKGR_UCKR) | AT91_PMC_UPLLEN | + AT91_PMC_UPLLCOUNT | AT91_PMC_BIASEN; + + pmc_write(pmc, AT91_CKGR_UCKR, tmp); + + while (!(pmc_read(pmc, AT91_PMC_SR) AT91_PMC_LOCKU)) { + enable_irq(utmi-irq); + wait_event(utmi-wait, + pmc_read(pmc, AT91_PMC_SR) AT91_PMC_LOCKU); + } + + return 0; +} + +static int clk_utmi_is_ready(struct clk_hw *hw) +{ + struct clk_utmi *utmi = to_clk_utmi(hw); + struct at91_pmc *pmc = utmi-pmc; + + return !!(pmc_read(pmc, AT91_PMC_SR) AT91_PMC_LOCKU); +} + +static void clk_utmi_disable(struct clk_hw *hw) +{ + struct clk_utmi *utmi = to_clk_utmi(hw); + struct at91_pmc *pmc = utmi-pmc; + u32 tmp = at91_pmc_read(AT91_CKGR_UCKR) ~AT91_PMC_UPLLEN; + + pmc_write(pmc, AT91_CKGR_UCKR, tmp); +} + +static unsigned long clk_utmi_recalc_rate(struct clk_hw *hw, +
Re: [PATCH v4 13/17] clk: at91: add PMC usb clock
On 11/10/2013 13:15, Boris BREZILLON : This patch adds new at91 usb clock implementation using common clk framework. This clock is used to clock usb ports (ohci, ehci and udc). Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Didn't you missed some 9n12 initialization? See below... --- arch/arm/mach-at91/Kconfig | 11 ++ drivers/clk/at91/Makefile |1 + drivers/clk/at91/clk-usb.c | 400 drivers/clk/at91/pmc.c | 11 ++ drivers/clk/at91/pmc.h |9 + 5 files changed, 432 insertions(+) create mode 100644 drivers/clk/at91/clk-usb.c diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 6ad37da..b76dc4c 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -3,6 +3,9 @@ if ARCH_AT91 config HAVE_AT91_UTMI bool +config HAVE_AT91_USB_CLK + bool + config HAVE_AT91_DBGU0 bool @@ -82,6 +85,7 @@ config SOC_SAMA5D3 select HAVE_AT91_DBGU1 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's SAMA5D3 family SoC. This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35. @@ -96,12 +100,14 @@ config SOC_AT91RM9200 select MULTI_IRQ_HANDLER select SPARSE_IRQ select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK config SOC_AT91SAM9260 bool AT91SAM9260, AT91SAM9XE or AT91SAM9G20 select HAVE_AT91_DBGU0 select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE or AT91SAM9G20 SoC. @@ -112,6 +118,7 @@ config SOC_AT91SAM9261 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9261 or AT91SAM9G10 SoC. @@ -121,6 +128,7 @@ config SOC_AT91SAM9263 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK config SOC_AT91SAM9RL bool AT91SAM9RL @@ -137,6 +145,7 @@ config SOC_AT91SAM9G45 select SOC_AT91SAM9 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9G45 family SoC. This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11. @@ -148,6 +157,7 @@ config SOC_AT91SAM9X5 select SOC_AT91SAM9 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9x5 family SoC. This means that your SAM9 name finishes with a '5' (except if it is @@ -161,6 +171,7 @@ config SOC_AT91SAM9N12 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK help Select this if you are using Atmel's AT91SAM9N12 SoC. diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index a824883..61db058 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -8,3 +8,4 @@ obj-y += clk-system.o clk-peripheral.o obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)+= clk-programmable.o obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o +obj-$(CONFIG_HAVE_AT91_USB_CLK)+= clk-usb.o diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c new file mode 100644 index 000..0454555 --- /dev/null +++ b/drivers/clk/at91/clk-usb.c @@ -0,0 +1,400 @@ +/* + * drivers/clk/at91/clk-usb.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/io.h + +#include pmc.h + +#define USB_SOURCE_MAX 2 + +#define SAM9X5_USB_DIV_SHIFT 8 +#define SAM9X5_USB_MAX_DIV 0xf + +#define RM9200_USB_DIV_SHIFT 28 +#define RM9200_USB_DIV_TAB_SIZE4 + +struct at91sam9x5_clk_usb { + struct clk_hw hw; + struct at91_pmc *pmc; +}; + +#define to_at91sam9x5_clk_usb(hw) \ + container_of(hw, struct at91sam9x5_clk_usb, hw) + +struct at91rm9200_clk_usb { + struct clk_hw hw; + struct at91_pmc *pmc; + u32 divisors[4]; +}; + +#define to_at91rm9200_clk_usb(hw) \ + container_of(hw, struct at91rm9200_clk_usb, hw) + +static unsigned long at91sam9x5_clk_usb_recalc_rate(struct clk_hw *hw, + unsigned long
Re: [PATCH v4 14/17] clk: at91: add PMC smd clock
On 11/10/2013 13:27, Boris BREZILLON : This patch adds at91 smd (Soft Modem) clock implementation using common clk framework. Not used by any driver right now. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- arch/arm/mach-at91/Kconfig |5 ++ drivers/clk/at91/Makefile |1 + drivers/clk/at91/clk-smd.c | 173 drivers/clk/at91/pmc.c |7 ++ drivers/clk/at91/pmc.h |5 ++ 5 files changed, 191 insertions(+) create mode 100644 drivers/clk/at91/clk-smd.c diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index b76dc4c..97033f7 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -39,6 +39,9 @@ config AT91_SAM9G45_RESET config AT91_SAM9_TIME bool +config HAVE_AT91_SMD + bool + config SOC_AT91SAM9 bool select AT91_SAM9_TIME @@ -85,6 +88,7 @@ config SOC_SAMA5D3 select HAVE_AT91_DBGU1 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_SMD select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's SAMA5D3 family SoC. @@ -157,6 +161,7 @@ config SOC_AT91SAM9X5 select SOC_AT91SAM9 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_SMD select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9x5 family SoC. diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 61db058..0e92b71 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -9,3 +9,4 @@ obj-y += clk-system.o clk-peripheral.o obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)+= clk-programmable.o obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o obj-$(CONFIG_HAVE_AT91_USB_CLK) += clk-usb.o +obj-$(CONFIG_HAVE_AT91_SMD)+= clk-smd.o diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c new file mode 100644 index 000..9f3fa39 --- /dev/null +++ b/drivers/clk/at91/clk-smd.c @@ -0,0 +1,173 @@ +/* + * drivers/clk/at91/clk-smd.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/io.h + +#include pmc.h + +#define SMD_SOURCE_MAX 2 + +#define SMD_DIV_SHIFT 8 +#define SMD_MAX_DIV0xf + +struct at91sam9x5_clk_smd { + struct clk_hw hw; + struct at91_pmc *pmc; +}; + +#define to_at91sam9x5_clk_smd(hw) \ + container_of(hw, struct at91sam9x5_clk_smd, hw) + +static unsigned long at91sam9x5_clk_smd_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + u32 tmp; + u8 smddiv; + struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); + struct at91_pmc *pmc = smd-pmc; + + tmp = pmc_read(pmc, AT91_PMC_SMD); + smddiv = (tmp AT91_PMC_SMD_DIV) SMD_DIV_SHIFT; + return parent_rate / (smddiv + 1); +} + +static long at91sam9x5_clk_smd_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) +{ + unsigned long div; + unsigned long bestrate; + unsigned long tmp; + + if (rate = *parent_rate) + return *parent_rate; + + div = *parent_rate / rate; + if (div SMD_MAX_DIV) + return *parent_rate / (SMD_MAX_DIV + 1); + + bestrate = *parent_rate / div; + tmp = *parent_rate / (div + 1); + if (bestrate - rate rate - tmp) + bestrate = tmp; + + return bestrate; +} + +static int at91sam9x5_clk_smd_set_parent(struct clk_hw *hw, u8 index) +{ + u32 tmp; + struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); + struct at91_pmc *pmc = smd-pmc; + + if (index 1) + return -EINVAL; + tmp = pmc_read(pmc, AT91_PMC_SMD) ~AT91_PMC_SMDS; + if (index) + tmp |= AT91_PMC_SMDS; + pmc_write(pmc, AT91_PMC_SMD, tmp); + return 0; +} + +static u8 at91sam9x5_clk_smd_get_parent(struct clk_hw *hw) +{ + struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); + struct at91_pmc *pmc = smd-pmc; + + return pmc_read(pmc, AT91_PMC_SMD) AT91_PMC_SMDS; +} + +static int at91sam9x5_clk_smd_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + u32 tmp; + struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); + struct at91_pmc *pmc =
Re: [PATCH] usb/gadget: f_mass_storage: style corrections, cleanup simplification
Hi, On Wed, Oct 16, 2013 at 02:56:20PM -0700, Michal Nazarewicz wrote: On Tue, Oct 15 2013, Andrzej Pietrasiewicz wrote: Fix spacing, improve error code returned, remove unused #define, use strtobool() instead of kstrtou8(). Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Ackedy-by: Michal Nazarewicz min...@mina86.com joke nice, maybe I should start using Signedy-off-by: Felipe Balbi :-) /joke thanks -- balbi signature.asc Description: Digital signature
Re: [PATCH v4 15/17] clk: at91: add PMC clk device tree binding doc.
On 11/10/2013 13:38, Boris BREZILLON : This patch adds new at91 clks dt bindings documentation. Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com It seems good Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- .../devicetree/bindings/clock/at91-clock.txt | 328 1 file changed, 328 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt diff --git a/Documentation/devicetree/bindings/clock/at91-clock.txt b/Documentation/devicetree/bindings/clock/at91-clock.txt new file mode 100644 index 000..360d8fe --- /dev/null +++ b/Documentation/devicetree/bindings/clock/at91-clock.txt @@ -0,0 +1,328 @@ +Device Tree Clock bindings for arch-at91 + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +Required properties: +- compatible : shall be one of the following: + atmel,at91rm9200-pmc or + atmel,at91sam9g45-pmc or + atmel,at91sam9n12-pmc or + atmel,at91sam9x5-pmc or + atmel,sama5d3-pmc: + at91 PMC (Power Management Controller) + All at91 specific clocks (clocks defined below) must be child + node of the PMC node. + + atmel,at91rm9200-clk-main: + at91 main oscillator + + atmel,at91rm9200-clk-master or + atmel,at91sam9x5-clk-master: + at91 master clock + + atmel,at91sam9x5-clk-peripheral or + atmel,at91rm9200-clk-peripheral: + at91 peripheral clocks + + atmel,at91rm9200-clk-pll or + atmel,at91sam9g45-clk-pll or + atmel,at91sam9g20-clk-pllb or + atmel,sama5d3-clk-pll: + at91 pll clocks + + atmel,at91sam9x5-clk-plldiv: + at91 plla divisor + + atmel,at91rm9200-clk-programmable or + atmel,at91sam9g45-clk-programmable or + atmel,at91sam9x5-clk-programmable: + at91 programmable clocks + + atmel,at91sam9x5-clk-smd: + at91 SMD (Soft Modem) clock + + atmel,at91rm9200-clk-system: + at91 system clocks + + atmel,at91rm9200-clk-usb or + atmel,at91sam9x5-clk-usb or + atmel,at91sam9n12-clk-usb: + at91 usb clock + + atmel,at91sam9x5-clk-utmi: + at91 utmi clock + +Required properties for PMC node: +- reg : defines the IO memory reserved for the PMC. +- interrupts : shall be set to PMC interrupt line. +- interrupt-controller : tell that the PMC is an interrupt controller. +- #interrupt-cells : must be set to 1. The first cell encodes the interrupt id, + and reflect the bit position in the PMC_ER/DR/SR registers. + You can use the dt macros defined in dt-bindings/clk/at91.h. + 0 (AT91_PMC_MOSCS) - main oscillator ready + 1 (AT91_PMC_LOCKA) - PLL A ready + 2 (AT91_PMC_LOCKB) - PLL B ready + 3 (AT91_PMC_MCKRDY) - master clock ready + 6 (AT91_PMC_LOCKU) - UTMI PLL clock ready + 8 .. 15 (AT91_PMC_PCKRDY(id)) - programmable clock ready + 16 (AT91_PMC_MOSCSELS) - main oscillator selected + 17 (AT91_PMC_MOSCRCS) - RC main oscillator stabilized + 18 (AT91_PMC_CFDEV) - clock failure detected + +For example: + pmc: pmc@fc00 { + compatible = atmel,sama5d3-pmc; + interrupts = 1 4 7; + interrupt-controller; + #interrupt-cells = 2; + + /* put at91 clocks here */ + }; + +Required properties for main clock: +- interrupt-parent : must reference the PMC node. +- interrupts : shall be set to 0. +- #clock-cells : from common clock binding; shall be set to 0. +- clocks (optional if clock-frequency is provided) : shall be the slow clock + phandle. This clock is used to calculate the main clock rate if + clock-frequency is not provided. +- clock-frequency : the main oscillator frequency.Prefer the use of + clock-frequency over automatic clock rate calculation. + +For example: + main: mainck { + compatible = atmel,at91rm9200-clk-main; + interrupt-parent = pmc; + interrupts = 0; + #clock-cells = 0; + clocks = ck32k; + clock-frequency = 18432000; + }; + +Required properties for master clock: +- interrupt-parent : must reference the PMC node. +- interrupts : shall be set to 3. +- #clock-cells : from common clock binding; shall be set to 0. +- clocks : shall be the master clock sources (see atmel datasheet) phandles. + e.g. ck32k, main, plla, pllb. +- atmel,clk-output-range : minimum and maximum clock frequency (two u32 + fields). + e.g. output = 0 13300; = 0 to 133MHz. +- atmel,clk-divisors : master clock divisors table (four u32 fields). + 0 = reserved value. + e.g. divisors = 1 2 4 6; +- atmel,master-clk-have-div3-pres : some SoC use the reserved value 7 in the +
Re: [PATCH v2 1/7] usb: dwc3: get usb_phy only if the platform indicates the presence of PHY's
Hi, On Wed, Oct 16, 2013 at 01:24:11AM +0530, Kishon Vijay Abraham I wrote: There can be systems which does not have a external usb_phy, so get usb_phy only if dt data indicates the presence of PHY in the case of dt boot or if platform_data indicates the presence of PHY. Also remove checking if return value is -ENXIO since it's now changed to always enable usb_phy layer. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com I'm fine with this patch, but one comment below: @@ -387,16 +388,49 @@ static int dwc3_probe(struct platform_device *pdev) if (node) { dwc-maximum_speed = of_usb_get_maximum_speed(node); - dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0); - dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1); + count = of_count_phandle_with_args(node, usb-phy, NULL); + switch (count) { + case 2: + dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, + usb-phy, 1); + if (IS_ERR(dwc-usb3_phy)) { + dev_err(dev, usb3 phy not found\n); + return PTR_ERR(dwc-usb3_phy); + } + case 1: + dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, + usb-phy, 0); + if (IS_ERR(dwc-usb2_phy)) { + dev_err(dev, usb2 phy not found\n); + return PTR_ERR(dwc-usb2_phy); + } + break; + default: + dev_err(dev, usb phy nodes not configured\n); + } dwc-needs_fifo_resize = of_property_read_bool(node, tx-fifo-resize); dwc-dr_mode = of_usb_get_dr_mode(node); } else if (pdata) { dwc-maximum_speed = pdata-maximum_speed; - dwc-usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); - dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); + if (pdata-usb2_phy) { + dwc-usb2_phy = devm_usb_get_phy(dev, + USB_PHY_TYPE_USB2); + if (IS_ERR(dwc-usb2_phy)) { + dev_err(dev, usb2 phy not found\n); + return PTR_ERR(dwc-usb2_phy); + } + } + + if (pdata-usb3_phy) { + dwc-usb3_phy = devm_usb_get_phy(dev, + USB_PHY_TYPE_USB3); + if (IS_ERR(dwc-usb3_phy)) { + dev_err(dev, usb3 phy not found\n); + return PTR_ERR(dwc-usb3_phy); + } + } dwc-needs_fifo_resize = pdata-tx_fifo_resize; dwc-dr_mode = pdata-dr_mode; @@ -409,36 +443,6 @@ static int dwc3_probe(struct platform_device *pdev) if (dwc-maximum_speed == USB_SPEED_UNKNOWN) dwc-maximum_speed = USB_SPEED_SUPER; - if (IS_ERR(dwc-usb2_phy)) { - ret = PTR_ERR(dwc-usb2_phy); - - /* - * if -ENXIO is returned, it means PHY layer wasn't - * enabled, so it makes no sense to return -EPROBE_DEFER - * in that case, since no PHY driver will ever probe. - */ - if (ret == -ENXIO) - return ret; - - dev_err(dev, no usb2 phy configured\n); - return -EPROBE_DEFER; - } - - if (IS_ERR(dwc-usb3_phy)) { - ret = PTR_ERR(dwc-usb3_phy); - - /* - * if -ENXIO is returned, it means PHY layer wasn't - * enabled, so it makes no sense to return -EPROBE_DEFER - * in that case, since no PHY driver will ever probe. - */ - if (ret == -ENXIO) - return ret; - - dev_err(dev, no usb3 phy configured\n); - return -EPROBE_DEFER; - } the idea for doing the error checking here was actually to avoid duplicating it in all previous cases, as you did. Please keep the error checking here and you're good to go. - dwc-xhci_resources[0].start = res-start; dwc-xhci_resources[0].end = dwc-xhci_resources[0].start + DWC3_XHCI_REGS_END; diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h index 7db34f0..49ffa6d 100644 --- a/drivers/usb/dwc3/platform_data.h +++ b/drivers/usb/dwc3/platform_data.h @@ -24,4 +24,6 @@ struct dwc3_platform_data { enum usb_device_speed maximum_speed; enum usb_dr_mode dr_mode; bool tx_fifo_resize; + bool usb2_phy; + bool usb3_phy; This would look better as a quirks flag, then we could: unsigned long quirks; #define DWC3_QUIRK_NO_USB3_PHY BIT(0)
Re: [xhci:fun-streams-fixes 33/48] drivers/usb/host/xhci-ring.c:1154:29: sparse: incorrect type in assignment (different base types)
All right, so we have a couple sparse warnings with this patch. On Thu, Oct 17, 2013 at 01:40:15PM +0800, kbuild test robot wrote: tree: git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git fun-streams-fixes head: e79db70b0f7d028cb9e9cf8ee424a1e92b7d232f commit: 0f899d55a18ce75eed9dccd2cc2cd6d333f9ff16 [33/48] xhci: For streams the dequeue ptr must be read from the stream ctx reproduce: make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by ) drivers/usb/host/xhci-ring.c:1154:29: sparse: incorrect type in assignment (different base types) drivers/usb/host/xhci-ring.c:1154:29:expected restricted __le64 [usertype] deq drivers/usb/host/xhci-ring.c:1154:29:got unsigned long long drivers/usb/host/xhci-ring.c:1156:29: sparse: incorrect type in assignment (different base types) drivers/usb/host/xhci-ring.c:1156:29:expected restricted __le64 [usertype] deq drivers/usb/host/xhci-ring.c:1156:29:got unsigned long long drivers/usb/host/xhci-ring.c:1161:65: sparse: restricted __le64 degrades to integer drivers/usb/host/xhci-ring.c:1674:19: sparse: restricted __le32 degrades to integer vim +1154 drivers/usb/host/xhci-ring.c 1148} else { 1149__le64 deq; 1150/* 4.6.10 deq ptr is written to the stream ctx for streams */ 1151if (ep-ep_state EP_HAS_STREAMS) { 1152struct xhci_stream_ctx *ctx = 1153 ep-stream_info-stream_ctx_array[stream_id]; 1154deq = le64_to_cpu(ctx-stream_ring) SCTX_DEQ_MASK; 1155} else { 1156deq = le64_to_cpu(ep_ctx-deq) ~EP_CTX_CYCLE_MASK; 1157} 1158xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 1159Successful Set TR Deq Ptr cmd, deq = @%08llx, deq); 1160if (xhci_trb_virt_to_dma(ep-queued_deq_seg, 1161 ep-queued_deq_ptr) == deq) { 1162/* Update the ring's dequeue segment and dequeue pointer 1163 * to reflect the new position. 1164 */ --- 0-DAY kernel build testing backend Open Source Technology Center http://lists.01.org/mailman/listinfo/kbuild Intel Corporation Looking at the patch itself: + __le64 deq; + /* 4.6.10 deq ptr is written to the stream ctx for streams */ + if (ep-ep_state EP_HAS_STREAMS) { + struct xhci_stream_ctx *ctx = + ep-stream_info-stream_ctx_array[stream_id]; + deq = le64_to_cpu(ctx-stream_ring) SCTX_DEQ_MASK; + } else { + deq = le64_to_cpu(ep_ctx-deq) ~EP_CTX_CYCLE_MASK; + } xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, - Successful Set TR Deq Ptr cmd, deq = @%08llx, -le64_to_cpu(ep_ctx-deq)); - if (xhci_trb_virt_to_dma(dev-eps[ep_index].queued_deq_seg, -dev-eps[ep_index].queued_deq_ptr) == - (le64_to_cpu(ep_ctx-deq) ~(EP_CTX_CYCLE_MASK))) { + Successful Set TR Deq Ptr cmd, deq = @%08llx, deq); + if (xhci_trb_virt_to_dma(ep-queued_deq_seg, +ep-queued_deq_ptr) == deq) { /* Update the ring's dequeue segment and dequeue pointer * to reflect the new position. */ I don't think it makes sense to use __le64 for the deq variable. It should probably be dma_addr_t, which is what xhci_trb_virt_to_dma returns. Can you fix this? I also wondered if we could have multiple Set TR dequeue commands pending for different stream rings, and thus overwrite the endpoint queued_deq_seg and queued_dequeue_ptr fields. However, I convinced myself that isn't possible. When the Stop Endpoint command completes, all stream rings will stop, but the host will indicate the stream ring that it was in the middle of processing. That will get stored in xhci_virt_ep-stopped_td, and thus only one of the stream rings could possibly need a Set TR Dequeue command at a time. The rest will have canceled TDs get turned into no-ops. Sarah Sharp -- 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: [xhci:fun-streams-fixes 33/48] drivers/usb/host/xhci-ring.c:1154:29: sparse: incorrect type in assignment (different base types)
Hi, On 10/17/2013 06:42 PM, Sarah Sharp wrote: All right, so we have a couple sparse warnings with this patch. On Thu, Oct 17, 2013 at 01:40:15PM +0800, kbuild test robot wrote: tree: git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git fun-streams-fixes head: e79db70b0f7d028cb9e9cf8ee424a1e92b7d232f commit: 0f899d55a18ce75eed9dccd2cc2cd6d333f9ff16 [33/48] xhci: For streams the dequeue ptr must be read from the stream ctx reproduce: make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by ) drivers/usb/host/xhci-ring.c:1154:29: sparse: incorrect type in assignment (different base types) drivers/usb/host/xhci-ring.c:1154:29:expected restricted __le64 [usertype] deq drivers/usb/host/xhci-ring.c:1154:29:got unsigned long long drivers/usb/host/xhci-ring.c:1156:29: sparse: incorrect type in assignment (different base types) drivers/usb/host/xhci-ring.c:1156:29:expected restricted __le64 [usertype] deq drivers/usb/host/xhci-ring.c:1156:29:got unsigned long long drivers/usb/host/xhci-ring.c:1161:65: sparse: restricted __le64 degrades to integer drivers/usb/host/xhci-ring.c:1674:19: sparse: restricted __le32 degrades to integer vim +1154 drivers/usb/host/xhci-ring.c 1148 } else { 1149 __le64 deq; 1150 /* 4.6.10 deq ptr is written to the stream ctx for streams */ 1151 if (ep-ep_state EP_HAS_STREAMS) { 1152 struct xhci_stream_ctx *ctx = 1153 ep-stream_info-stream_ctx_array[stream_id]; 1154deq = le64_to_cpu(ctx-stream_ring) SCTX_DEQ_MASK; 1155 } else { 1156 deq = le64_to_cpu(ep_ctx-deq) ~EP_CTX_CYCLE_MASK; 1157 } 1158 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 1159 Successful Set TR Deq Ptr cmd, deq = @%08llx, deq); 1160 if (xhci_trb_virt_to_dma(ep-queued_deq_seg, 1161 ep-queued_deq_ptr) == deq) { 1162 /* Update the ring's dequeue segment and dequeue pointer 1163 * to reflect the new position. 1164 */ --- 0-DAY kernel build testing backend Open Source Technology Center http://lists.01.org/mailman/listinfo/kbuild Intel Corporation Looking at the patch itself: + __le64 deq; + /* 4.6.10 deq ptr is written to the stream ctx for streams */ + if (ep-ep_state EP_HAS_STREAMS) { + struct xhci_stream_ctx *ctx = + ep-stream_info-stream_ctx_array[stream_id]; + deq = le64_to_cpu(ctx-stream_ring) SCTX_DEQ_MASK; + } else { + deq = le64_to_cpu(ep_ctx-deq) ~EP_CTX_CYCLE_MASK; + } xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, - Successful Set TR Deq Ptr cmd, deq = @%08llx, -le64_to_cpu(ep_ctx-deq)); - if (xhci_trb_virt_to_dma(dev-eps[ep_index].queued_deq_seg, -dev-eps[ep_index].queued_deq_ptr) == - (le64_to_cpu(ep_ctx-deq) ~(EP_CTX_CYCLE_MASK))) { + Successful Set TR Deq Ptr cmd, deq = @%08llx, deq); + if (xhci_trb_virt_to_dma(ep-queued_deq_seg, +ep-queued_deq_ptr) == deq) { /* Update the ring's dequeue segment and dequeue pointer * to reflect the new position. */ I don't think it makes sense to use __le64 for the deq variable. It should probably be dma_addr_t, which is what xhci_trb_virt_to_dma returns. Can you fix this? You already have a patch for this further down in your inbox :) (I used u64 rather then dma_addr_t) I also wondered if we could have multiple Set TR dequeue commands pending for different stream rings, and thus overwrite the endpoint queued_deq_seg and queued_dequeue_ptr fields. However, I convinced myself that isn't possible. When the Stop Endpoint command completes, all stream rings will stop, but the host will indicate the stream ring that it was in the middle of processing. That will get stored in xhci_virt_ep-stopped_td, and thus only one of the stream rings could possibly need a Set TR Dequeue command at a time. The rest will have canceled TDs get turned into no-ops. Right, note their already is a check against this + an xhci_warn in queue_set_tr_deq, so if it does somehow happen at least we will get a warning (and the second set_deq will be ignored). Regards, Hans -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo
[PATCH] usb: fix misc/usb3503.c build error
From: Randy Dunlap rdun...@infradead.org Fix usb3503 build error - it uses an interface that is provided by REGMAP_I2C, so it needs to select that symbol. drivers/built-in.o: In function `usb3503_i2c_probe': usb3503.c:(.text+0x1b2519): undefined reference to `devm_regmap_init_i2c' Reported-by: JP P jpli...@jppozzi.dyndns.org Signed-off-by: Randy Dunlap rdun...@infradead.org --- drivers/usb/misc/Kconfig |1 + 1 file changed, 1 insertion(+) --- lnx-312-rc5.orig/drivers/usb/misc/Kconfig +++ lnx-312-rc5/drivers/usb/misc/Kconfig @@ -247,5 +247,6 @@ config USB_HSIC_USB3503 tristate USB3503 HSIC to USB20 Driver depends on I2C select REGMAP + select REGMAP_I2C help This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver. -- 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] usb: fix misc/usb3503.c build error
On Thu, Oct 17, 2013 at 10:09:00AM -0700, Randy Dunlap wrote: From: Randy Dunlap rdun...@infradead.org Fix usb3503 build error - it uses an interface that is provided by REGMAP_I2C, so it needs to select that symbol. drivers/built-in.o: In function `usb3503_i2c_probe': usb3503.c:(.text+0x1b2519): undefined reference to `devm_regmap_init_i2c' Reported-by: JP P jpli...@jppozzi.dyndns.org Signed-off-by: Randy Dunlap rdun...@infradead.org --- drivers/usb/misc/Kconfig |1 + 1 file changed, 1 insertion(+) I already took a fix for this in my tree, so it will show up in Linus's soon. thanks, greg k-h -- 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] usb: usb_phy_gen: refine conditional declaration of usb_nop_xceiv_register
On Wed, Oct 16, 2013 at 07:18:41PM -0700, Guenter Roeck wrote: Commit 3fa4d734 (usb: phy: rename nop_usb_xceiv = usb_phy_gen_xceiv) changed the conditional around the declaration of usb_nop_xceiv_register from #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) defined(MODULE)) to #if IS_ENABLED(CONFIG_NOP_USB_XCEIV) While that looks the same, it is semantically different. The first expression is true if CONFIG_NOP_USB_XCEIV is built as module and if the including code is built as module. The second expression is true if code depending on CONFIG_NOP_USB_XCEIV if built as module or into the kernel. As a result, the arm:allmodconfig build fails with arch/arm/mach-omap2/built-in.o: In function `omap3_evm_init': arch/arm/mach-omap2/board-omap3evm.c:703: undefined reference to `usb_nop_xceiv_register' Fix the problem by reverting to the old conditional. Cc: Josh Boyer jwbo...@redhat.com Signed-off-by: Guenter Roeck li...@roeck-us.net I'm not entirely sure why I was CC'd on this one, but the patch looks good to me. I do wonder how many other uses of IS_ENABLED aren't taking this into account though. josh --- include/linux/usb/usb_phy_gen_xceiv.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/usb/usb_phy_gen_xceiv.h b/include/linux/usb/usb_phy_gen_xceiv.h index f9a7e7b..11d85b9 100644 --- a/include/linux/usb/usb_phy_gen_xceiv.h +++ b/include/linux/usb/usb_phy_gen_xceiv.h @@ -12,7 +12,7 @@ struct usb_phy_gen_xceiv_platform_data { unsigned int needs_reset:1; }; -#if IS_ENABLED(CONFIG_NOP_USB_XCEIV) +#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) defined(MODULE)) /* sometimes transceivers are accessed only through e.g. ULPI */ extern void usb_nop_xceiv_register(void); extern void usb_nop_xceiv_unregister(void); -- 1.7.9.7 -- 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 fixes for 3.12-rc6
The following changes since commit d0e639c9e06d44e713170031fe05fb60ebe680af: Linux 3.12-rc4 (2013-10-06 14:00:20 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ tags/usb-3.12-rc6 for you to fetch changes up to 94468783cd960aa14b22503dd59afd14efb785aa: usb: usb_phy_gen: refine conditional declaration of usb_nop_xceiv_register (2013-10-17 09:34:30 -0700) USB fixes for 3.12-rc6 Here are some USB fixes and new device ids for 3.12-rc6 The largest change here is a bunch of new device ids for the option USB serial driver for new Huawei devices. Other than that, just some small bug fixes for issues that people have reported (run-time and build-time), nothing major. Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org Diego Elio Pettenò (1): USB: serial: ti_usb_3410_5052: add Abbott strip port ID to combined table as well. Enrico Mioso (1): usb: serial: option: blacklist Olivetti Olicard200 Fangxiaozhi (Franko) (1): USB: support new huawei devices in option.c Greg Kroah-Hartman (4): Merge tag 'fixes-for-v3.12-rc5' of git://git.kernel.org/.../balbi/usb into usb-linus Merge tag 'for-usb-linus-2013-10-09' of git://git.kernel.org/.../sarah/xhci into usb-linus USB: serial: option: add support for Inovia SEW858 device Revert usb: musb: gadget: fix otg active status flag Guenter Roeck (1): usb: usb_phy_gen: refine conditional declaration of usb_nop_xceiv_register Matthew Dawson (1): usb: misc: usb3503: Fix compile error due to incorrect regmap depedency Oliver Neukum (4): xhci: quirk for extra long delay for S4 USB: quirks.c: add one device that cannot deal with suspension USB: quirks: add touchscreen that is dazzeled by remote wakeup usb-storage: add quirk for mandatory READ_CAPACITY_16 Russell King - ARM Linux (1): usb/chipidea: fix oops on memory allocation failure Sarah Sharp (1): xhci: Don't enable/disable RWE on bus suspend/resume. Sebastian Andrzej Siewior (1): usb: musb: start musb on the udc side, too Takashi Iwai (1): xhci: Fix spurious wakeups after S5 on Haswell Xenia Ragiadakou (1): xhci: fix write to USB3_PSSEN and XUSB2PRM pci config registers drivers/usb/chipidea/host.c | 6 +- drivers/usb/core/quirks.c | 6 + drivers/usb/host/pci-quirks.c | 4 +- drivers/usb/host/xhci-hub.c | 26 drivers/usb/host/xhci-pci.c | 25 drivers/usb/host/xhci.c | 14 ++- drivers/usb/host/xhci.h | 2 + drivers/usb/misc/Kconfig | 2 +- drivers/usb/musb/musb_core.c | 46 +++ drivers/usb/musb/musb_core.h | 1 + drivers/usb/musb/musb_gadget.c| 3 + drivers/usb/musb/musb_virthub.c | 46 --- drivers/usb/serial/option.c | 225 +- drivers/usb/serial/ti_usb_3410_5052.c | 1 + drivers/usb/storage/scsiglue.c| 5 +- drivers/usb/storage/unusual_devs.h| 7 ++ include/linux/usb/usb_phy_gen_xceiv.h | 2 +- include/linux/usb_usual.h | 4 +- 18 files changed, 343 insertions(+), 82 deletions(-) -- 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 v2 4/5] usb: xhci: change enumeration scheme to 'new scheme' by default
On Wed, Oct 16, 2013 at 3:58 PM, Sarah Sharp sarah.a.sh...@linux.intel.com wrote: Hi Dan, I'm attempting to put my queue together for usb-next, and this patch doesn't apply, due to conflicts in the USB core. Can you rebase this patchset on top of my for-usb-next-queue branch, and resend the last two patches? The first three applied fine. Hooray for whitespace fix collisions. git am is very strict by default. We collided with: commit 469271f8c48f12efc63a49b5bb388a754c957a0b Author: Matthias Beyer m...@beyermatthias.de Date: Thu Oct 10 23:41:27 2013 +0200 drivers: usb: core: {file,hub,sysfs,usb}.c: Whitespace fixes including: - removing of trailing whitespace - removing spaces before array indexing (foo [] to foo[]) - reindention of a switch-case block - spaces to tabs Signed-off-by: Matthias Beyer m...@beyermatthias.de Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org ...and my tree was based on usb-next. The rebase only made this change to patch 4 (diff of the diffs) -@@ -4167,7 +4203,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, +@@ -4158,7 +4194,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, * - read ep0 maxpacket even for high and low speed, */ msleep(10); - if (USE_NEW_SCHEME(retry_counter) !(hcd-driver-flags HCD_USB3)) + if (did_new_scheme) break; - } + } ...to spare the list I just attached the updated set. -- Dan xhci-new-scheme-v3.tar.gz Description: GNU Zip compressed data
Re: transmit lockup using smsc95xx ethernet on usb3
On Thu, Oct 17, 2013 at 03:30:56PM +0100, David Laight wrote: From: Sarah Sharp [mailto:sarah.a.sh...@linux.intel.com] Thanks for taking an interest. On Tue, Oct 15, 2013 at 10:59:18AM +0100, David Laight wrote: We are seeing complete lockups of the transmit side when using the smsc95xx driver connected to a USB3 port on an i7 (Ivybridge) cpu. These errors are very intermittent - less than once a day, and it isn't actually clear that they are related to traffic load. Most of the systems are running the 3.2 kernel from Ubuntu 12.04 but I've seen the same problem when running a 3.4 kernel. Have you tried the latest stable kernel or the latest -rc kernel? No. Although I've written a lot of device driver and comms protocol stack code over the years I've not had to work out how to build linux kernels - this may be the time I start! It's not too hard. Here's some directions: http://kernelnewbies.org/KernelBuild Try building the latest stable tree, and let me know if you still have issues. If so, we'll figure out a plan to add some pretty small debugging to the xHCI driver. Given the difficulty (or rather the infrequency) of reproducing the problem I'd like to sort out the failing code path before changing kernels so that I can then verify that a more recent kernel fixes it. The problem is that -ESHUTDOWN usually means there's a driver or host controller issue. Numerous bug fixes have gone in since 3.4 to avoid such host controller issues. It would be a waste of time for me to attempt debug your issue, only to discover it had been fixed in a more recent kernel. So I would really rather you test on a stable kernel, see if the issue still occurs, and then we can work from a known good base to figure out where the problem is. ... We are also seeing similar problems if we connect to a USB2 header. Do you mean a USB 2.0 port under the xHCI host controller? What does `lsusb -t` show as the parent host controller in that case? To clarify the fail trace below is from an xhci controller, but I'm pretty sure we've seen a tx lockup when using ohci. Then it might not be an xHCI host specific issue. The usbmon trace when the tx locks up starts with: Two Bo 'fail -71', 6 succeed, one fails -32 the rest fail -104. done:9871:6913:60 88020ea16a80 293818155 C Bo:3:003:2 -71 EPROTO 512 done:9872:6927:59 88020ea16f00 293818235 C Bo:3:003:2 -71 EPROTO 0 done:9873:6875:58 88020ea16480 293818313 C Bo:3:003:2 0 1514 done:9874:6786:57 88020c7c83c0 293818353 C Bo:3:003:2 0 1514 done:9875:6794:56 88020c7c80c0 293818470 C Bo:3:003:2 0 1514 done:9876:6789:55 88020c7c8e40 293818589 C Bo:3:003:2 0 1514 done:9877:6775:54 88020c7c8240 293818702 C Bo:3:003:2 0 1090 done:9878:6751:53 88020c7c8180 293818803 C Bo:3:003:2 0 1514 done:9879:6735:52 88020c7c89c0 293818885 C Bo:3:003:2 -32 EPIPE 0 done:9880:6671:51 88020c7c8900 293818925 C Bo:3:003:2 -104 ECONNRESET 0 ... the ring is cleared in a software loop done:9927:1292:4 88020cf0c480 293819015 C Bo:3:003:2 -104 0 done:9928:1170:3 88020ea160c0 293819016 C Bo:3:003:2 -104 0 Something is known to be wrong... start:9931 88020ea160c0 293819037 S Co:3:003:0 s 02 01 0002 0 done:9929:1080:3 88020ea16780 293819044 C Bo:3:003:2 -104 0 done:9930:945:2 88020ea16000 293819044 C Bo:3:003:2 -104 0 done:9931:48:1 88020ea160c0 293819085 C Co:3:003:0 0 0 I've also seen resets that start with an interrupt from device 1. In this case the ring is cleared with ESHUTDOWN and dmesg traces what looks like an unplug-plug action. I really care a lot more about dmesg than a usbmon trace. Last successful ethernet transmit 88020c4870c0 701760986 C Bo:3:018:2 0 1090 88020c4870c0 701760992 S Bo:3:018:2 -115 1090 = 3a34 3a44 22003200 00224d98 d8460002 1f0057d7 08004500 042879ca Interrupt - I think from the root hub. 88020c8570c0 701761038 C Ii:3:001:1 0:2048 1 = 02 88020c8570c0 701761042 S Ii:3:001:1 -115:2048 4 88020ea16840 701761046 C Ii:3:018:3 -71:1 0 EPROTO 88020ea16840 701761047 S Ii:3:018:3 -115:1 16 88020c53c480 701761051 C Bi:3:018:1 -71 0 88020c487180 701761054 C Bo:3:018:2 -71 1024 880210570240 701761063 S Ci:3:001:0 s a3 00 0001 0004 4 880210570240 701761071 C Ci:3:001:0 0 4 = 00010100 880210570240 701761074 S Co:3:001:0 s 23 01 0010 0001 0 88020c53c540 701761076 C Bi:3:018:1 -71 0 880210570240 701761078 C Co:3:001:0 0 0 88020c487240 701761117 C Bo:3:018:2 -71 0 88020c53cd80 701761156 C Bi:3:018:1 -108 0 ESHITDOWN I assume you meant ESHUTDOWN instead of ESHITDOWN. :) 88020c53c9c0 701761158 C Bi:3:018:1 -108 0 88020c487840 701761196 C Bo:3:018:2 -108
Re: Linux USB file storage gadget with new UDC
On Thu, 17 Oct 2013, Victor Yeo wrote: Here's another experiment you can try. In do_set_config(), just after the rc = do_set_interface(fsg, -1); line, add a statement saying INFO(fsg, fsg-config %d new_config %d\n, fsg-config, new_config); In standard_setup_req(), change the VDBG(fsg, get configuration\n); line to INFO(fsg, get configuration %d\n, fsg-config); Then let's see what shows up in the device's system log. I have added in the INFO statements. You added the second INFO statement in the wrong place. I said to change the line that says VDBG(fsg, get configuration\n); but instead you changed the line that says VDBG(fsg, get configuration descriptor\n); After that, the log files are captured during device enumeration. After i made the modification for the second test, the USBCV software cannot see the device. However, enumeration can be completed. The analyzer log and device log of enumeration for the second test are attached. What does and NAK endpoint on line 73 of the device log mean? From the log, i still cannot find out who call the UDC driver queue function when Set-Config request is received. Add a dump_stack(); statement to the UDC driver queue function, for the case where the function was called for endpoint 0. That will tell you where the call came from. Follow-up on USBCV test using the normal UDC driver. The analyzer log and device log are attached. This is even more mysterious. In the analyzer log, the Get-Config-Descriptor transfer starting with packet 46548 (line 70) doesn't correspond to anything in the device log. But the device clearly did send a reply, shown in packet 52406 (line 81). Following that, the transfer starting with packet 52415 (line 94 in the analyzer log) corresponds to line 2129 in the device log. But the device log shows a 32-byte response was sent (lines 2133-2134) whereas the analyzer log shows a 0-byte response (packet 142758, line 105). Notice the large jump in the packet numbers: 52415 to 142758. I wonder why the device took so long to reply? There's also a 0.13-second jump in the timestamps between those two packets, but the device log doesn't show this delay. In addition, the analyzer timestamps show a 6-second jump between packets 142762 and 194829, but the device log shows less than 1.5 seconds between lines 2134 and and 2138. In device log, line 2152, host sends Get-Config request, line 2156, host sends Set-Config request. Before Set-Config request is completed, in line 2158, host sends Get-Config request again. Yep. In between is another one of those and NAK endpoint lines. However, in analyzer log, we can see that: Set-Config request status stage is completed before host sends Get-Config request again. There is inconsistency between device and analyzer log. Some unknown code completes the Set-Config status stage. You have to find out what that unknown code really is. 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: transmit lockup using smsc95xx ethernet on usb3
On Thu, 17 Oct 2013, Sarah Sharp wrote: Given the difficulty (or rather the infrequency) of reproducing the problem I'd like to sort out the failing code path before changing kernels so that I can then verify that a more recent kernel fixes it. The problem is that -ESHUTDOWN usually means there's a driver or host controller issue. Numerous bug fixes have gone in since 3.4 to avoid such host controller issues. It would be a waste of time for me to attempt debug your issue, only to discover it had been fixed in a more recent kernel. So I would really rather you test on a stable kernel, see if the issue still occurs, and then we can work from a known good base to figure out where the problem is. -ESHUTDOWN really indicates either that the system believes the device has been disconnected from the USB bus or that the host controller itself has stopped working. To clarify the fail trace below is from an xhci controller, but I'm pretty sure we've seen a tx lockup when using ohci. Then it might not be an xHCI host specific issue. Undoubtedly not. The usbmon trace when the tx locks up starts with: Two Bo 'fail -71', 6 succeed, one fails -32 the rest fail -104. done:9871:6913:60 88020ea16a80 293818155 C Bo:3:003:2 -71 EPROTO 512 done:9872:6927:59 88020ea16f00 293818235 C Bo:3:003:2 -71 EPROTO 0 Those -71 errors indicate a low-level problem. It generally means that the device has stopped sending packets. Perhaps its firmware has crashed, or perhaps it has disconnected itself electrically from the bus. Last successful ethernet transmit 88020c4870c0 701760986 C Bo:3:018:2 0 1090 88020c4870c0 701760992 S Bo:3:018:2 -115 1090 = 3a34 3a44 22003200 00224d98 d8460002 1f0057d7 08004500 042879ca Interrupt - I think from the root hub. 88020c8570c0 701761038 C Ii:3:001:1 0:2048 1 = 02 88020c8570c0 701761042 S Ii:3:001:1 -115:2048 4 88020ea16840 701761046 C Ii:3:018:3 -71:1 0 EPROTO 88020ea16840 701761047 S Ii:3:018:3 -115:1 16 88020c53c480 701761051 C Bi:3:018:1 -71 0 88020c487180 701761054 C Bo:3:018:2 -71 1024 880210570240 701761063 S Ci:3:001:0 s a3 00 0001 0004 4 880210570240 701761071 C Ci:3:001:0 0 4 = 00010100 These last two lines show the host controller telling the system that the device has disconnected. Once that happens, any future communication with the device is hopeless. 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 0/2 v3] usb: ohci: remove ep93xx bus glue driver
Refresh the ep93xx_defconfig then remove the ep93xx OHCI bus glue driver in favor of the Generic OHCI driver for a platform device. v3: split patch to refresh the ep93xx_defconfig before removing ohci-ep93xx.c in favor of the Generic OHCI driver for a platform device. v2: Use the (*power_off) callback for (*power_suspend), as suggested by Alan Stern. Remove the Kconfig change to USB_OHCI_HCD_PLATFORM and refresh the ep93xx_defconfig to enable this option, as suggested by Alan Stern. H Hartley Sweeten (2): ARM: ep93xx_defconfig: cleanup ep93xx_defconfig usb: ohci: remove ep93xx bus glue platform driver arch/arm/configs/ep93xx_defconfig | 17 +--- arch/arm/mach-ep93xx/clock.c | 2 +- arch/arm/mach-ep93xx/core.c | 40 - drivers/usb/host/ohci-ep93xx.c| 184 -- drivers/usb/host/ohci-hcd.c | 18 5 files changed, 40 insertions(+), 221 deletions(-) delete mode 100644 drivers/usb/host/ohci-ep93xx.c -- 1.8.3.2 -- 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 v3] usb: ohci: remove ep93xx bus glue platform driver
Convert ep93xx to use the OHCI platform driver and remove the ohci-ep93xx bus glue driver. Enable CONFIG_OHCI_HCD_PLATFORM in the ep93xx_defconfig so that USB is still enabled by default on the EP93xx platform. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ryan Mallon rmal...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Lennert Buytenhek ker...@wantstofly.org Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Olof Johansson o...@lixom.net Cc: Russell King li...@arm.linux.org.uk --- arch/arm/configs/ep93xx_defconfig | 1 + arch/arm/mach-ep93xx/clock.c | 2 +- arch/arm/mach-ep93xx/core.c | 40 - drivers/usb/host/ohci-ep93xx.c| 184 -- drivers/usb/host/ohci-hcd.c | 18 5 files changed, 38 insertions(+), 207 deletions(-) delete mode 100644 drivers/usb/host/ohci-ep93xx.c diff --git a/arch/arm/configs/ep93xx_defconfig b/arch/arm/configs/ep93xx_defconfig index 8eccbcb..6ac5ea7 100644 --- a/arch/arm/configs/ep93xx_defconfig +++ b/arch/arm/configs/ep93xx_defconfig @@ -83,6 +83,7 @@ CONFIG_USB=y CONFIG_USB_DEBUG=y CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_HCD_PLATFORM=y CONFIG_USB_STORAGE=y CONFIG_USB_SERIAL=y CONFIG_USB_SERIAL_CONSOLE=y diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c index c95dbce..39ef3b6 100644 --- a/arch/arm/mach-ep93xx/clock.c +++ b/arch/arm/mach-ep93xx/clock.c @@ -212,7 +212,7 @@ static struct clk_lookup clocks[] = { INIT_CK(NULL, hclk, clk_h), INIT_CK(NULL, apb_pclk, clk_p), INIT_CK(NULL, pll2, clk_pll2), - INIT_CK(ep93xx-ohci, NULL, clk_usb_host), + INIT_CK(ohci-platform,NULL, clk_usb_host), INIT_CK(ep93xx-keypad,NULL, clk_keypad), INIT_CK(ep93xx-fb,NULL, clk_video), INIT_CK(ep93xx-spi.0, NULL, clk_spi), diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index 3f12b88..92d59c4 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c @@ -36,6 +36,7 @@ #include linux/export.h #include linux/irqchip/arm-vic.h #include linux/reboot.h +#include linux/usb/ohci_pdriver.h #include mach/hardware.h #include linux/platform_data/video-ep93xx.h @@ -297,22 +298,53 @@ static struct platform_device ep93xx_rtc_device = { .resource = ep93xx_rtc_resource, }; +/* + * EP93xx OHCI USB Host + */ + +static struct clk *ep93xx_ohci_host_clock; + +static int ep93xx_ohci_power_on(struct platform_device *pdev) +{ + if (!ep93xx_ohci_host_clock) { + ep93xx_ohci_host_clock = devm_clk_get(pdev-dev, NULL); + if (IS_ERR(ep93xx_ohci_host_clock)) + return PTR_ERR(ep93xx_ohci_host_clock); + } + + clk_enable(ep93xx_ohci_host_clock); + + return 0; +} + +static void ep93xx_ohci_power_off(struct platform_device *pdev) +{ + clk_disable(ep93xx_ohci_host_clock); +} + +static struct usb_ohci_pdata ep93xx_ohci_pdata = { + .power_on = ep93xx_ohci_power_on, + .power_off = ep93xx_ohci_power_off, + .power_suspend = ep93xx_ohci_power_off, +}; static struct resource ep93xx_ohci_resources[] = { DEFINE_RES_MEM(EP93XX_USB_PHYS_BASE, 0x1000), DEFINE_RES_IRQ(IRQ_EP93XX_USB), }; +static u64 ep93xx_ohci_dma_mask = DMA_BIT_MASK(32); static struct platform_device ep93xx_ohci_device = { - .name = ep93xx-ohci, + .name = ohci-platform, .id = -1, + .num_resources = ARRAY_SIZE(ep93xx_ohci_resources), + .resource = ep93xx_ohci_resources, .dev= { - .dma_mask = ep93xx_ohci_device.dev.coherent_dma_mask, + .dma_mask = ep93xx_ohci_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = ep93xx_ohci_pdata, }, - .num_resources = ARRAY_SIZE(ep93xx_ohci_resources), - .resource = ep93xx_ohci_resources, }; diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c deleted file mode 100644 index 84a20d5..000 --- a/drivers/usb/host/ohci-ep93xx.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * OHCI HCD (Host Controller Driver) for USB. - * - * (C) Copyright 1999 Roman Weissgaerber wei...@vienna.at - * (C) Copyright 2000-2002 David Brownell dbrown...@users.sourceforge.net - * (C) Copyright 2002 Hewlett-Packard Company - * - * Bus Glue for ep93xx. - * - * Written by Christopher Hoover c...@hpl.hp.com - * Based on fragments of previous driver by Russell King et al. - * - * Modified for LH7A404 from
[PATCH 1/2 v3] ARM: ep93xx_defconfig: cleanup ep93xx_defconfig
Generate ep93xx_defconfig by doing: make ep93xx_defconfig make savedefconfig mv defconfig arch/arm/configs/ep93xx_defconfig No functional change. This just refreshes the ep93xx_defconfig to make it easier and cleaner when adding new entries. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Cc: Ryan Mallon rmal...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Lennert Buytenhek ker...@wantstofly.org Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Olof Johansson o...@lixom.net Cc: Russell King li...@arm.linux.org.uk --- arch/arm/configs/ep93xx_defconfig | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/arch/arm/configs/ep93xx_defconfig b/arch/arm/configs/ep93xx_defconfig index 806005a..8eccbcb 100644 --- a/arch/arm/configs/ep93xx_defconfig +++ b/arch/arm/configs/ep93xx_defconfig @@ -1,15 +1,14 @@ -CONFIG_EXPERIMENTAL=y CONFIG_SYSVIPC=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=14 -CONFIG_SYSFS_DEPRECATED_V2=y CONFIG_EXPERT=y CONFIG_SLAB=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_MODULE_FORCE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y # CONFIG_IOSCHED_CFQ is not set CONFIG_ARCH_EP93XX=y CONFIG_CRUNCH=y @@ -47,11 +46,8 @@ CONFIG_IPV6=y CONFIG_UEVENT_HELPER_PATH=/sbin/hotplug # CONFIG_FW_LOADER is not set CONFIG_MTD=y -CONFIG_MTD_CONCAT=y -CONFIG_MTD_PARTITIONS=y CONFIG_MTD_REDBOOT_PARTS=y CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_ADV_OPTIONS=y @@ -67,15 +63,14 @@ CONFIG_SCSI=y # CONFIG_SCSI_PROC_FS is not set CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y -CONFIG_NET_ETHERNET=y CONFIG_EP93XX_ETH=y CONFIG_USB_RTL8150=y # CONFIG_INPUT is not set # CONFIG_SERIO is not set # CONFIG_VT is not set +# CONFIG_LEGACY_PTYS is not set CONFIG_SERIAL_AMBA_PL010=y CONFIG_SERIAL_AMBA_PL010_CONSOLE=y -# CONFIG_LEGACY_PTYS is not set # CONFIG_HW_RANDOM is not set CONFIG_I2C=y CONFIG_I2C_CHARDEV=y @@ -86,7 +81,6 @@ CONFIG_WATCHDOG=y CONFIG_EP93XX_WATCHDOG=y CONFIG_USB=y CONFIG_USB_DEBUG=y -CONFIG_USB_DEVICEFS=y CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y @@ -100,24 +94,18 @@ CONFIG_RTC_DRV_EP93XX=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y # CONFIG_EXT3_FS_XATTR is not set -CONFIG_INOTIFY=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_JFFS2_FS=y CONFIG_NFS_FS=y -CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y -CONFIG_PARTITION_ADVANCED=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y CONFIG_MAGIC_SYSRQ=y -CONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_SLAB=y CONFIG_DEBUG_SPINLOCK=y CONFIG_DEBUG_MUTEXES=y -# CONFIG_RCU_CPU_STALL_DETECTOR is not set CONFIG_DEBUG_USER=y -CONFIG_DEBUG_ERRORS=y CONFIG_DEBUG_LL=y # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_LIBCRC32C=y -- 1.8.3.2 -- 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 v2] usb: ohci: remove ep93xx bus glue platform driver
On Wednesday, October 16, 2013 2:13 PM, Alan Stern wrote: Sure, that's what I meant. All that churn was caused by re-minimizing the defconfig file, not by adding USB_OHCI_HCD_PLATFORM. As requested, I have split this patch to: 1) refresh the ep93xx_defconfig 2) remove the ep93xx bus glue driver I just posted the new patch series as v3. If there are any other issues I will happily fix them. Greg KH and I can take both patches. Thanks, Hartley -- 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 v2] xhci: fix usb3 streams
The more I look at this patch, the more I hate it for the failure cases it doesn't cover. What happens if the radix_tree_insert fails in the middle of adding a set of ring segments? We leave those segments that were inserted in the radix tree, which is a problem, since we could allocate those segments out of the DMA pool later for a different stream ID. That's OK for the initial stream ring allocation, since the xhci_ring itself will get freed. It's not ok for ring expansion through, since the xhci_ring remains in tact, and we simply fail the URB submission. I'm working on a patch to fix this, but may not get it done today. Sarah Sharp On Mon, Oct 14, 2013 at 06:54:24PM -0700, Gerd Hoffmann wrote: Gerd, Hans, any objections to this updated patch? The warning is fixed with it. The patch probably still needs to address the case where the ring expansion fails because we can't insert the new segments into the radix tree. The patch should probably allocate the segments, attempt to add them to the radix tree, and fail without modifying the link TRBs of the ring. I'd have to look more deeply into the code to see what exactly should be done there. I would like that issue fixed before I merge these patches, so if you want to take a stab at fixing it, please do. Sarah Sharp 88 xhci maintains a radix tree for each stream endpoint because it must be able to map a trb address to the stream ring. Each ring segment must be added to the ring for this to work. Currently xhci sticks only the first segment of each stream ring into the radix tree. Result is that things work initially, but as soon as the first segment is full xhci can't map the trb address from the completion event to the stream ring any more - BOOM. You'll find this message in the logs: ERROR Transfer event for disabled endpoint or incorrect stream ring This patch adds a helper function to update the radix tree, and a function to remove ring segments from the tree. Both functions loop over the segment list and handles all segments instead of just the first. [Note: Sarah changed this patch to add radix_tree_maybe_preload() and radix_tree_preload_end() calls around the radix tree insert, since we can now insert entries in interrupt context. There are now two helper functions to make the code cleaner, and those functions are moved to make them static.] Signed-off-by: Gerd Hoffmann kra...@redhat.com Signed-off-by: Hans de Goede hdego...@redhat.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-mem.c | 132 +--- drivers/usb/host/xhci.h | 1 + 2 files changed, 90 insertions(+), 43 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 83bcd13..8b1ba5b 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -149,14 +149,95 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, } } +/* + * We need a radix tree for mapping physical addresses of TRBs to which stream + * ID they belong to. We need to do this because the host controller won't tell + * us which stream ring the TRB came from. We could store the stream ID in an + * event data TRB, but that doesn't help us for the cancellation case, since the + * endpoint may stop before it reaches that event data TRB. + * + * The radix tree maps the upper portion of the TRB DMA address to a ring + * segment that has the same upper portion of DMA addresses. For example, say I + * have segments of size 1KB, that are always 64-byte aligned. A segment may + * start at 0x10c91000 and end at 0x10c913f0. If I use the upper 10 bits, the + * key to the stream ID is 0x43244. I can use the DMA address of the TRB to + * pass the radix tree a key to get the right stream ID: + * + * 0x10c90fff 10 = 0x43243 + * 0x10c912c0 10 = 0x43244 + * 0x10c91400 10 = 0x43245 + * + * Obviously, only those TRBs with DMA addresses that are within the segment + * will make the radix tree return the stream ID for that ring. + * + * Caveats for the radix tree: + * + * The radix tree uses an unsigned long as a key pair. On 32-bit systems, an + * unsigned long will be 32-bits; on a 64-bit system an unsigned long will be + * 64-bits. Since we only request 32-bit DMA addresses, we can use that as the + * key on 32-bit or 64-bit systems (it would also be fine if we asked for 64-bit + * PCI DMA addresses on a 64-bit system). There might be a problem on 32-bit + * extended systems (where the DMA address can be bigger than 32-bits), + * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. + */ +static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags) +{ + struct xhci_segment *seg; + unsigned long key; + int ret; + +
[PATCH 2/5] uas: Urbs must be anchored before submitting them
Otherwise they may complete before they get anchored and thus never get unanchored (as the unanchoring is done by the usb core on completion). This commit also remove the usb_get_urb / usb_put_urb around cmd submission + anchoring, since if done in the proper order this is not necessary. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 080851d..11e3679 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -531,10 +531,12 @@ static int uas_submit_task_urb(struct scsi_cmnd *cmnd, gfp_t gfp, usb_free_urb, NULL); urb-transfer_flags |= URB_FREE_BUFFER; + usb_anchor_urb(urb, devinfo-cmd_urbs); err = usb_submit_urb(urb, gfp); - if (err) + if (err) { + usb_unanchor_urb(urb); goto err; - usb_anchor_urb(urb, devinfo-cmd_urbs); + } return 0; @@ -558,13 +560,14 @@ static int uas_submit_sense_urb(struct Scsi_Host *shost, urb = uas_alloc_sense_urb(devinfo, gfp, shost, stream); if (!urb) return SCSI_MLQUEUE_DEVICE_BUSY; + usb_anchor_urb(urb, devinfo-sense_urbs); if (usb_submit_urb(urb, gfp)) { + usb_unanchor_urb(urb); shost_printk(KERN_INFO, shost, sense urb submission failure\n); usb_free_urb(urb); return SCSI_MLQUEUE_DEVICE_BUSY; } - usb_anchor_urb(urb, devinfo-sense_urbs); return 0; } @@ -594,14 +597,15 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, } if (cmdinfo-state SUBMIT_DATA_IN_URB) { + usb_anchor_urb(cmdinfo-data_in_urb, devinfo-data_urbs); if (usb_submit_urb(cmdinfo-data_in_urb, gfp)) { + usb_unanchor_urb(cmdinfo-data_in_urb); scmd_printk(KERN_INFO, cmnd, data in urb submission failure\n); return SCSI_MLQUEUE_DEVICE_BUSY; } cmdinfo-state = ~SUBMIT_DATA_IN_URB; cmdinfo-state |= DATA_IN_URB_INFLIGHT; - usb_anchor_urb(cmdinfo-data_in_urb, devinfo-data_urbs); } if (cmdinfo-state ALLOC_DATA_OUT_URB) { @@ -614,14 +618,15 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, } if (cmdinfo-state SUBMIT_DATA_OUT_URB) { + usb_anchor_urb(cmdinfo-data_out_urb, devinfo-data_urbs); if (usb_submit_urb(cmdinfo-data_out_urb, gfp)) { + usb_unanchor_urb(cmdinfo-data_out_urb); scmd_printk(KERN_INFO, cmnd, data out urb submission failure\n); return SCSI_MLQUEUE_DEVICE_BUSY; } cmdinfo-state = ~SUBMIT_DATA_OUT_URB; cmdinfo-state |= DATA_OUT_URB_INFLIGHT; - usb_anchor_urb(cmdinfo-data_out_urb, devinfo-data_urbs); } if (cmdinfo-state ALLOC_CMD_URB) { @@ -633,14 +638,13 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, } if (cmdinfo-state SUBMIT_CMD_URB) { - usb_get_urb(cmdinfo-cmd_urb); + usb_anchor_urb(cmdinfo-cmd_urb, devinfo-cmd_urbs); if (usb_submit_urb(cmdinfo-cmd_urb, gfp)) { + usb_unanchor_urb(cmdinfo-cmd_urb); scmd_printk(KERN_INFO, cmnd, cmd urb submission failure\n); return SCSI_MLQUEUE_DEVICE_BUSY; } - usb_anchor_urb(cmdinfo-cmd_urb, devinfo-cmd_urbs); - usb_put_urb(cmdinfo-cmd_urb); cmdinfo-cmd_urb = NULL; cmdinfo-state = ~SUBMIT_CMD_URB; cmdinfo-state |= COMMAND_INFLIGHT; -- 1.8.3.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
[PATCH 3/5] uas: Properly set interface to altsetting 0 on probe failure
- Rename labels to properly reflect this - Don't skip free-ing the streams when scsi_init_shared_tag_map fails Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 11e3679..6436486 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -1002,8 +1002,8 @@ static void uas_free_streams(struct uas_dev_info *devinfo) */ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) { - int result; - struct Scsi_Host *shost; + int result = -ENOMEM; + struct Scsi_Host *shost = NULL; struct uas_dev_info *devinfo; struct usb_device *udev = interface_to_usbdev(intf); @@ -1012,12 +1012,11 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) devinfo = kmalloc(sizeof(struct uas_dev_info), GFP_KERNEL); if (!devinfo) - return -ENOMEM; + goto set_alt0; - result = -ENOMEM; shost = scsi_host_alloc(uas_host_template, sizeof(void *)); if (!shost) - goto free; + goto set_alt0; shost-max_cmd_len = 16 + 252; shost-max_id = 1; @@ -1039,11 +1038,11 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) result = scsi_init_shared_tag_map(shost, devinfo-qdepth - 3); if (result) - goto free; + goto free_streams; result = scsi_add_host(shost, intf-dev); if (result) - goto deconfig_eps; + goto free_streams; shost-hostdata[0] = (unsigned long)devinfo; @@ -1051,9 +1050,10 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) usb_set_intfdata(intf, shost); return result; -deconfig_eps: +free_streams: uas_free_streams(devinfo); - free: +set_alt0: + usb_set_interface(udev, intf-altsetting[0].desc.bInterfaceNumber, 0); kfree(devinfo); if (shost) scsi_host_put(shost); -- 1.8.3.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
[PATCH 5/5] uas: uas_alloc_cmd_urb: drop unused stream_id parameter
The cmd endpoint never has streams, so the stream_id parameter is unused. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 286225e..bf80ef1 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -454,7 +454,7 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, } static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp, - struct scsi_cmnd *cmnd, u16 stream_id) + struct scsi_cmnd *cmnd) { struct usb_device *udev = devinfo-udev; struct scsi_device *sdev = cmnd-device; @@ -626,8 +626,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, } if (cmdinfo-state ALLOC_CMD_URB) { - cmdinfo-cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd, -cmdinfo-stream); + cmdinfo-cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd); if (!cmdinfo-cmd_urb) return SCSI_MLQUEUE_DEVICE_BUSY; cmdinfo-state = ~ALLOC_CMD_URB; -- 1.8.3.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
[PATCH 1/5] uas: Deal with externally triggered reset, and fix reset locking
The uas driver is only capable of dealing with an usb-reset it has triggered itself, fix the pre and post reset return values to reflect this. Also fix the uas_eh_bus_reset_handler not properly taking the usbdev lock before calling usb_device_reset, the usb-core expects this lock to be taken when usb_device_reset is called, and taking this lock will also protect the usage of the resetting flag in the pre and post reset handlers. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 046eedf..080851d 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -807,6 +807,13 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd) struct usb_device *udev = devinfo-udev; int err; + err = usb_lock_device_for_reset(udev, devinfo-intf); + if (err) { + shost_printk(KERN_INFO, sdev-host, +%s FAILED to get lock err %d\n, __func__, err); + return FAILED; + } + shost_printk(KERN_INFO, sdev-host, %s start\n, __func__); devinfo-resetting = 1; uas_abort_work(devinfo); @@ -820,6 +827,8 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd) uas_configure_endpoints(devinfo); devinfo-resetting = 0; + usb_unlock_device(udev); + if (err) { shost_printk(KERN_INFO, sdev-host, %s FAILED\n, __func__); return FAILED; @@ -1049,14 +1058,18 @@ deconfig_eps: static int uas_pre_reset(struct usb_interface *intf) { -/* XXX: Need to return 1 if it's not our device in error handling */ - return 0; + struct Scsi_Host *shost = usb_get_intfdata(intf); + struct uas_dev_info *devinfo = (void *)shost-hostdata[0]; + + return !devinfo-resetting; } static int uas_post_reset(struct usb_interface *intf) { -/* XXX: Need to return 1 if it's not our device in error handling */ - return 0; + struct Scsi_Host *shost = usb_get_intfdata(intf); + struct uas_dev_info *devinfo = (void *)shost-hostdata[0]; + + return !devinfo-resetting; } static void uas_disconnect(struct usb_interface *intf) -- 1.8.3.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
[PATCH 4/5] uas: Avoid unnecessary unlock / lock calls around unlink_data_urbs
All callers of unlink_data_urbs drop devinfo-lock before calling it, and then immediately take it again after the call. And the first thing unlink_data_urbs does is take the lock again, and the last thing it does is drop it. This commit removes all the unnecessary lock dropping and taking. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 20 +++- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 6436486..286225e 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -93,28 +93,26 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo); static void uas_free_streams(struct uas_dev_info *devinfo); static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *caller); +/* Must be called with devinfo-lock held, will temporary unlock the lock */ static void uas_unlink_data_urbs(struct uas_dev_info *devinfo, -struct uas_cmd_info *cmdinfo) +struct uas_cmd_info *cmdinfo, +unsigned long *lock_flags) { - unsigned long flags; - /* * The UNLINK_DATA_URBS flag makes sure uas_try_complete * (called by urb completion) doesn't release cmdinfo * underneath us. */ - spin_lock_irqsave(devinfo-lock, flags); cmdinfo-state |= UNLINK_DATA_URBS; - spin_unlock_irqrestore(devinfo-lock, flags); + spin_unlock_irqrestore(devinfo-lock, *lock_flags); if (cmdinfo-data_in_urb) usb_unlink_urb(cmdinfo-data_in_urb); if (cmdinfo-data_out_urb) usb_unlink_urb(cmdinfo-data_out_urb); - spin_lock_irqsave(devinfo-lock, flags); + spin_lock_irqsave(devinfo-lock, *lock_flags); cmdinfo-state = ~UNLINK_DATA_URBS; - spin_unlock_irqrestore(devinfo-lock, flags); } static void uas_do_work(struct work_struct *work) @@ -361,9 +359,7 @@ static void uas_stat_cmplt(struct urb *urb) uas_sense(urb, cmnd); if (cmnd-result != 0) { /* cancel data transfers on error */ - spin_unlock_irqrestore(devinfo-lock, flags); - uas_unlink_data_urbs(devinfo, cmdinfo); - spin_lock_irqsave(devinfo-lock, flags); + uas_unlink_data_urbs(devinfo, cmdinfo, flags); } cmdinfo-state = ~COMMAND_INFLIGHT; uas_try_complete(cmnd, __func__); @@ -787,9 +783,7 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) spin_unlock_irqrestore(devinfo-lock, flags); ret = uas_eh_task_mgmt(cmnd, ABORT TASK, TMF_ABORT_TASK); } else { - spin_unlock_irqrestore(devinfo-lock, flags); - uas_unlink_data_urbs(devinfo, cmdinfo); - spin_lock_irqsave(devinfo-lock, flags); + uas_unlink_data_urbs(devinfo, cmdinfo, flags); uas_try_complete(cmnd, __func__); spin_unlock_irqrestore(devinfo-lock, flags); ret = SUCCESS; -- 1.8.3.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
Re: [PATCH 2/2 v3] usb: ohci: remove ep93xx bus glue platform driver
On Thu, 17 Oct 2013, H Hartley Sweeten wrote: Convert ep93xx to use the OHCI platform driver and remove the ohci-ep93xx bus glue driver. Enable CONFIG_OHCI_HCD_PLATFORM in the ep93xx_defconfig so that USB is still enabled by default on the EP93xx platform. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com +/* + * EP93xx OHCI USB Host + */ + +static struct clk *ep93xx_ohci_host_clock; + +static int ep93xx_ohci_power_on(struct platform_device *pdev) +{ + if (!ep93xx_ohci_host_clock) { + ep93xx_ohci_host_clock = devm_clk_get(pdev-dev, NULL); + if (IS_ERR(ep93xx_ohci_host_clock)) + return PTR_ERR(ep93xx_ohci_host_clock); + } + + clk_enable(ep93xx_ohci_host_clock); + + return 0; Wasn't this supposed to be changed to: return clk_enable(ep93xx_ohci_host_clock); ? Otherwise it looks fine. After fixing this, you can add Acked-by: Alan Stern st...@rowland.harvard.edu 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
[ANNOUNCE] Tree Closed
Hi guys, I have finally closed my tree for the merge window. Nothing will go in anymore and I'll sending a pull request for Greg very soon (tomorrow). cheers -- balbi signature.asc Description: Digital signature
Re: Annoying USB3.0 issue :-(
On Thu, Oct 17, 2013 at 03:45:24AM +0200, bjoern.glaess...@googlemail.com wrote: Hi Sarah... Sorry, that I contact you directly via email address. But our pain with this bug is so annoying, that - after a bunch of web searches without a solution - I came to the conclusion to ask you in personal. You are the developer and no one knows more about USB3.0 under Linux. First, I wanna recall a bug report from an other user: http://www.spinics.net/lists/linux-usb/msg93401.html This is pretty the same issue and I only want to mention, that there are a lot of other users, who suffer this in our Linux community. No, that's not the same issue. That's the same error message, but their report does not match yours at all. So, now to the hardware setup: - LogiLink USB3.0 Dual SATA HDD Docking Station http://i01.twenga.com/computer/externe-festplattengehaeuse/logilink-quickport-usb-3.0-p_33593001vb.jpg - 2 x 3TB TOSHIBA DT01ABA300 - Retail Kit (PA4293E-1HN0) hard disk drives, formatted with EXT4 Linux: Ubuntu 13.04 with kernel 3.8.0-31-generic - Mainboard: ASRock Z86M/USB3 http://www.asrock.com/mb/Intel/Z68MUSB3/index.de.asp What kernel are you running? Please run `uname -a`. Harddisks working like charm, until they were not needed for a time (aprox. 15 minutes). After this, the harddisks BOTH umount COMPLETELY from system and are NOT recoverable. Only possibility is to unplug the USB3.0 cable and re-plug it to mainboard USB3.0 port or shutting down power and repower the harddisk docking station. Yeah, it looks like from the log that they disconnect from the bus. lsusb or fdisk doesn't show any device after umount. dmesg looks like this: = I really need the parts of the log before this. [45446.007668] xhci_hcd :03:00.0: Timeout while waiting for address device command [45446.007720] xhci_hcd :03:00.0: WARN Set TR deq ptr command for freed stream ID 0 It looks like you're using the uas driver. Can you verify that you are by running `lsmod | grep uas`? That driver has been marked as BROKEN for a long time. What happens if you blacklist it in /etc/modprobe.d/ and use the usb-storage driver instead? Can you send me the output of `sudo lsusb -v` when the devices are plugged in (and hopefully before they freeze?). I want to see if the device supports UAS. [45451.211534] xhci_hcd :03:00.0: Timeout while waiting for address device command [45451.415500] usb 4-1: device not accepting address 2, error -62 [45451.503598] usb 4-1: USB disconnect, device number 2 [45451.503612] sd 5:0:0:1: Device offlined - not ready after error recovery [45451.815345] Buffer I/O error on device sdc1, logical block 365985792 [45451.815348] lost page write due to I/O error on sdc1 [45451.815349] JBD2: Error -5 detected when updating journal superblock for sdc1-8. [45452.062727] xhci_hcd :03:00.0: xHCI xhci_drop_endpoint called with disabled ep 880086843b00 [45452.062730] xhci_hcd :03:00.0: xHCI xhci_drop_endpoint called with disabled ep 880086843b40 [45452.064017] Buffer I/O error on device sdd1, logical block 121667584 [45452.064019] lost page write due to I/O error on sdd1 [45452.064021] JBD2: Error -5 detected when updating journal superblock for sdd1-8. [45452.187552] xhci_hcd :03:00.0: Bad Slot ID 1 [45452.187554] xhci_hcd :03:00.0: Could not allocate xHCI USB device data structures [45452.187559] hub 4-0:1.0: couldn't allocate port 1 usb_device = In my opinion the APM was shutting down the hard disks after a few minutes. But why the umount completely ? I have no idea what you mean by APM. Wouldn't it be better to stay connected to the mount points and re-activate them once the were used ?? Is there a way to tell the system NOT to shut down or to deactivate power management for this specal USB3.0 device ??? The only power management I know of for USB devices is auto-suspend, which is controlled through /sys/bus/usb/devices/../power/control. It's set to 'disabled' by default, and even if it was enabled, the USB device doesn't go into suspend while the hard drive is mounted. Best regards and have a nice weekend ! Please let me know if you need further or detailed information. Can you compile a kernel from my fun-streams-branch? Just follow these directions http://kernelnewbies.org/KernelBuild, and instead of cloning Linus' tree, run git clone git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git Once that finishes: cd xhci git checkout -b fun-streams-fixes origin/fun-streams-fixes And compile and install that kernel. That branch contains a lot of fixes for the UAS driver. To test them, make sure you're not blacklisting the uas driver, and reboot into your new kernel. Sarah Sharp -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More
Re: [PATCH V3 1/6] USB: OHCI: Properly handle OHCI controller suspend
On Thu, 17 Oct 2013, Majunath Goudar wrote: Suspend scenario in case of OHCI was not properly handled in ochi_suspend()routine. Alan Stern suggested, properly handle OHCI suspend scenario. This does generic proper handling of suspend scenario to all OHCI SOC. V1-V2: - No change. Due to build failure on ep93xx reverted this patch. This patch is needed as Alan mentioned, it is having common ohci suspend features w/o this following patches(still in usb-next) are not useful. Commit id 10abfa13[PATCH 7/11] Properly handle ohci-omap suspend. Commit id 39dbd7df[PATCH 8/11] Properly handle ohci-platform suspend. Commit id 4ceaa893[PATCH 9/11] Properly handle ohci-pxa suspend. Commit id f3c60599[PATCH 10/11] Properly handle ohci-sm501 suspend. V2-V3 : - No changes. As a build failure on ep93xx patch, reverted this patch(reveart commit id 476e4b). Rewrote this patch on top of latest Greg usb-next branch. This patch not gives any build error. patch is required for proper suspending as Alan mentioned. It is having common ohci suspend features w/o this following patches(still in usb-next) are not useful. Commit id 10abfa13[PATCH 7/11] Properly handle ohci-omap suspend. Commit id 39dbd7df[PATCH 8/11] Properly handle ohci-platform suspend. Commit id 4ceaa893[PATCH 9/11] Properly handle ohci-pxa suspend. Commit id f3c60599[PATCH 10/11] Properly handle ohci-sm501 suspend. Initially when I wrote this patch I was working in Linaro, now I am not part of Linaro that is why Linaro id is bouncing. Sending this patch from personal mail id. For all of the patches in this series, the version-change descriptions should go after the --- line following the Signed-off-by and CC tags. After all, you don't want those descriptions of older patch versions to appear in the final commit log. Signed-off-by: Manjunath Goudar csmanjuvi...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Greg KH g...@kroah.com Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-hcd.c |9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 8ada13f..310bcfe 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1036,6 +1036,7 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); unsigned long flags; + int rc = 0; /* Disable irq emission and mark HW unaccessible. Use * the spinlock to properly synchronize with possible pending @@ -1048,7 +1049,13 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) clear_bit(HCD_FLAG_HW_ACCESSIBLE, hcd-flags); spin_unlock_irqrestore (ohci-lock, flags); - return 0; + synchronize_irq(hcd-irq); + + if (do_wakeup HCD_WAKEUP_PENDING(hcd)) { + ohci_resume(hcd, false); + rc = -EBUSY; + } + return rc; } EXPORT_SYMBOL_GPL(ohci_suspend); For all the patches except 2/6, after moving the version change descriptions you can add: Acked-by: Alan Stern st...@rowland.harvard.edu See the my next email for comments on the 2/6 patch. 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 2/6] USB: OHCI: Properly handle ohci-at91 suspend
On Thu, 17 Oct 2013, Majunath Goudar wrote: Suspend scenario in case of ohci-at91 glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-at91 suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_at91_drv_suspend() will ensure proper handling of suspend scenario. This task is sugested by Alan Stern. --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -636,8 +636,14 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + booldo_wakeup = device_may_wakeup(pdev-dev); + int ret; - if (device_may_wakeup(pdev-dev)) + ret = ohci_suspend(hcd, do_wakeup); + if (ret) + return ret; + + if (do_wakeup) enable_irq_wake(hcd-irq); I believe the ohci_suspend call should come after the enable_irq_wake part, not before it. (Have we discussed this before? I can't remember.) Of course, this means you may have to call disable_irq_wake if ohci_suspend fails. 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] xhci: Remove segments from radix tree on failed insert.
If we're expanding a stream ring, we want to make sure we can add those ring segments to the radix tree that maps segments to ring pointers. Try the radix tree insert after the new ring segments have been allocated (the last segment in the new ring chunk will point to the first newly allocated segment), but before the new ring segments are linked into the old ring. If insert fails on any one segment, remove each segment from the radix tree, deallocate the new segments, and return. Otherwise, link the new segments into the tree. Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- Something like this. It's ugly, but it compiles. I haven't tested it. Hans, can you review and test this? Sarah Sharp drivers/usb/host/xhci-mem.c | 106 +--- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a455c56..6ce8d31 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -180,53 +180,98 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, * extended systems (where the DMA address can be bigger than 32-bits), * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. */ -static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags) +static int xhci_insert_segment_mapping(struct radix_tree_root *trb_address_map, + struct xhci_ring *ring, + struct xhci_segment *seg, + gfp_t mem_flags) { - struct xhci_segment *seg; unsigned long key; int ret; - if (WARN_ON_ONCE(ring-trb_address_map == NULL)) + key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); + /* Skip any segments that were already added. */ + if (radix_tree_lookup(trb_address_map, key)) return 0; - seg = ring-first_seg; - do { - key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); - /* Skip any segments that were already added. */ - if (radix_tree_lookup(ring-trb_address_map, key)) - continue; + ret = radix_tree_maybe_preload(mem_flags); + if (ret) + return ret; + ret = radix_tree_insert(trb_address_map, + key, ring); + radix_tree_preload_end(); + return ret; +} - ret = radix_tree_maybe_preload(mem_flags); - if (ret) - return ret; - ret = radix_tree_insert(ring-trb_address_map, - key, ring); - radix_tree_preload_end(); +static void xhci_remove_segment_mapping(struct radix_tree_root *trb_address_map, + struct xhci_segment *seg) +{ + unsigned long key; + + key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); + if (radix_tree_lookup(trb_address_map, key)) + radix_tree_delete(trb_address_map, key); +} + +static int xhci_update_stream_segment_mapping( + struct radix_tree_root *trb_address_map, + struct xhci_ring *ring, + struct xhci_segment *first_seg, + struct xhci_segment *last_seg, + gfp_t mem_flags) +{ + struct xhci_segment *seg; + struct xhci_segment *failed_seg; + int ret; + + if (WARN_ON_ONCE(trb_address_map == NULL)) + return 0; + + seg = first_seg; + do { + ret = xhci_insert_segment_mapping(trb_address_map, + ring, seg, mem_flags); if (ret) - return ret; + goto remove_streams; + if (seg == last_seg) + return 0; seg = seg-next; - } while (seg != ring-first_seg); + } while (seg != first_seg); return 0; + +remove_streams: + failed_seg = seg; + seg = first_seg; + do { + xhci_remove_segment_mapping(trb_address_map, seg); + if (seg == failed_seg) + return ret; + seg = seg-next; + } while (seg != first_seg); + + return ret; } static void xhci_remove_stream_mapping(struct xhci_ring *ring) { struct xhci_segment *seg; - unsigned long key; if (WARN_ON_ONCE(ring-trb_address_map == NULL)) return; seg = ring-first_seg; do { - key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); - if (radix_tree_lookup(ring-trb_address_map, key)) - radix_tree_delete(ring-trb_address_map, key); + xhci_remove_segment_mapping(ring-trb_address_map, seg); seg = seg-next; } while (seg != ring-first_seg); } +static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags) +{ + return
Re: [PATCH] usbnet: fix error return code in usbnet_probe()
From: Wei Yongjun weiyj...@gmail.com Date: Sat, 12 Oct 2013 14:24:08 +0800 From: Wei Yongjun yongjun_...@trendmicro.com.cn Fix to return -ENOMEM in the padding pkt alloc fail error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn Applied, thanks Wei. -- 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] usb/gadget: f_mass_storage: style corrections, cleanup simplification
On Thu, Oct 17 2013, Felipe Balbi wrote: Hi, On Wed, Oct 16, 2013 at 02:56:20PM -0700, Michal Nazarewicz wrote: On Tue, Oct 15 2013, Andrzej Pietrasiewicz wrote: Fix spacing, improve error code returned, remove unused #define, use strtobool() instead of kstrtou8(). Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Ackedy-by: Michal Nazarewicz min...@mina86.com joke nice, maybe I should start using Signedy-off-by: Felipe Balbi :-) Just wait for the talk like a pirate day. ;) /joke -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz(o o) ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo-- signature.asc Description: PGP signature
Re: [PATCH] net: qmi_wwan: Olivetti Olicard 200 support
From: Enrico Mioso mrkiko...@gmail.com Date: Tue, 15 Oct 2013 15:06:48 +0200 This is a QMI device, manufactured by TCT Mobile Phones. A companion patch blacklisting this device's QMI interface in the option.c driver has been sent. Signed-off-by: Enrico Mioso mrkiko...@gmail.com Signed-off-by: Antonella Pellizzari anto.pellizzar...@gmail.com Applied, 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
[PATCH v5 13/17] clk: at91: add PMC usb clock
This patch adds new at91 usb clock implementation using common clk framework. This clock is used to clock usb ports (ohci, ehci and udc). Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com --- arch/arm/mach-at91/Kconfig | 11 ++ drivers/clk/at91/Makefile |1 + drivers/clk/at91/clk-usb.c | 400 drivers/clk/at91/pmc.c | 15 ++ drivers/clk/at91/pmc.h |9 + 5 files changed, 436 insertions(+) create mode 100644 drivers/clk/at91/clk-usb.c diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 6ad37da..b76dc4c 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -3,6 +3,9 @@ if ARCH_AT91 config HAVE_AT91_UTMI bool +config HAVE_AT91_USB_CLK + bool + config HAVE_AT91_DBGU0 bool @@ -82,6 +85,7 @@ config SOC_SAMA5D3 select HAVE_AT91_DBGU1 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's SAMA5D3 family SoC. This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35. @@ -96,12 +100,14 @@ config SOC_AT91RM9200 select MULTI_IRQ_HANDLER select SPARSE_IRQ select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK config SOC_AT91SAM9260 bool AT91SAM9260, AT91SAM9XE or AT91SAM9G20 select HAVE_AT91_DBGU0 select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE or AT91SAM9G20 SoC. @@ -112,6 +118,7 @@ config SOC_AT91SAM9261 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9261 or AT91SAM9G10 SoC. @@ -121,6 +128,7 @@ config SOC_AT91SAM9263 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK config SOC_AT91SAM9RL bool AT91SAM9RL @@ -137,6 +145,7 @@ config SOC_AT91SAM9G45 select SOC_AT91SAM9 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9G45 family SoC. This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11. @@ -148,6 +157,7 @@ config SOC_AT91SAM9X5 select SOC_AT91SAM9 select AT91_USE_OLD_CLK select HAVE_AT91_UTMI + select HAVE_AT91_USB_CLK help Select this if you are using one of Atmel's AT91SAM9x5 family SoC. This means that your SAM9 name finishes with a '5' (except if it is @@ -161,6 +171,7 @@ config SOC_AT91SAM9N12 select HAVE_FB_ATMEL select SOC_AT91SAM9 select AT91_USE_OLD_CLK + select HAVE_AT91_USB_CLK help Select this if you are using Atmel's AT91SAM9N12 SoC. diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index a824883..61db058 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile @@ -8,3 +8,4 @@ obj-y += clk-system.o clk-peripheral.o obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS) += clk-programmable.o obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o +obj-$(CONFIG_HAVE_AT91_USB_CLK)+= clk-usb.o diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c new file mode 100644 index 000..0454555 --- /dev/null +++ b/drivers/clk/at91/clk-usb.c @@ -0,0 +1,400 @@ +/* + * drivers/clk/at91/clk-usb.c + * + * Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include linux/clk-provider.h +#include linux/clkdev.h +#include linux/clk/at91_pmc.h +#include linux/of.h +#include linux/of_address.h +#include linux/io.h + +#include pmc.h + +#define USB_SOURCE_MAX 2 + +#define SAM9X5_USB_DIV_SHIFT 8 +#define SAM9X5_USB_MAX_DIV 0xf + +#define RM9200_USB_DIV_SHIFT 28 +#define RM9200_USB_DIV_TAB_SIZE4 + +struct at91sam9x5_clk_usb { + struct clk_hw hw; + struct at91_pmc *pmc; +}; + +#define to_at91sam9x5_clk_usb(hw) \ + container_of(hw, struct at91sam9x5_clk_usb, hw) + +struct at91rm9200_clk_usb { + struct clk_hw hw; + struct at91_pmc *pmc; + u32 divisors[4]; +}; + +#define to_at91rm9200_clk_usb(hw) \ + container_of(hw, struct at91rm9200_clk_usb, hw) + +static unsigned long at91sam9x5_clk_usb_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + u32 tmp; + u8 usbdiv; + struct
Re: [PATCH 1/2 v3] ARM: ep93xx_defconfig: cleanup ep93xx_defconfig
On 18/10/13 05:25, H Hartley Sweeten wrote: Generate ep93xx_defconfig by doing: make ep93xx_defconfig make savedefconfig mv defconfig arch/arm/configs/ep93xx_defconfig No functional change. This just refreshes the ep93xx_defconfig to make it easier and cleaner when adding new entries. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Acked-by: Ryan Mallon rmal...@gmail.com Cc: Ryan Mallon rmal...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Lennert Buytenhek ker...@wantstofly.org Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Olof Johansson o...@lixom.net Cc: Russell King li...@arm.linux.org.uk --- arch/arm/configs/ep93xx_defconfig | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/arch/arm/configs/ep93xx_defconfig b/arch/arm/configs/ep93xx_defconfig index 806005a..8eccbcb 100644 --- a/arch/arm/configs/ep93xx_defconfig +++ b/arch/arm/configs/ep93xx_defconfig @@ -1,15 +1,14 @@ -CONFIG_EXPERIMENTAL=y CONFIG_SYSVIPC=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=14 -CONFIG_SYSFS_DEPRECATED_V2=y CONFIG_EXPERT=y CONFIG_SLAB=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_MODULE_FORCE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y # CONFIG_IOSCHED_CFQ is not set CONFIG_ARCH_EP93XX=y CONFIG_CRUNCH=y @@ -47,11 +46,8 @@ CONFIG_IPV6=y CONFIG_UEVENT_HELPER_PATH=/sbin/hotplug # CONFIG_FW_LOADER is not set CONFIG_MTD=y -CONFIG_MTD_CONCAT=y -CONFIG_MTD_PARTITIONS=y CONFIG_MTD_REDBOOT_PARTS=y CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_ADV_OPTIONS=y @@ -67,15 +63,14 @@ CONFIG_SCSI=y # CONFIG_SCSI_PROC_FS is not set CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y -CONFIG_NET_ETHERNET=y CONFIG_EP93XX_ETH=y CONFIG_USB_RTL8150=y # CONFIG_INPUT is not set # CONFIG_SERIO is not set # CONFIG_VT is not set +# CONFIG_LEGACY_PTYS is not set CONFIG_SERIAL_AMBA_PL010=y CONFIG_SERIAL_AMBA_PL010_CONSOLE=y -# CONFIG_LEGACY_PTYS is not set # CONFIG_HW_RANDOM is not set CONFIG_I2C=y CONFIG_I2C_CHARDEV=y @@ -86,7 +81,6 @@ CONFIG_WATCHDOG=y CONFIG_EP93XX_WATCHDOG=y CONFIG_USB=y CONFIG_USB_DEBUG=y -CONFIG_USB_DEVICEFS=y CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y @@ -100,24 +94,18 @@ CONFIG_RTC_DRV_EP93XX=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y # CONFIG_EXT3_FS_XATTR is not set -CONFIG_INOTIFY=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_JFFS2_FS=y CONFIG_NFS_FS=y -CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y -CONFIG_PARTITION_ADVANCED=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y CONFIG_MAGIC_SYSRQ=y -CONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_SLAB=y CONFIG_DEBUG_SPINLOCK=y CONFIG_DEBUG_MUTEXES=y -# CONFIG_RCU_CPU_STALL_DETECTOR is not set CONFIG_DEBUG_USER=y -CONFIG_DEBUG_ERRORS=y CONFIG_DEBUG_LL=y # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_LIBCRC32C=y -- 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 v4] ARM: ep93xx_defconfig: cleanup ep93xx_defconfig
Generate ep93xx_defconfig by doing: make ep93xx_defconfig make savedefconfig mv defconfig arch/arm/configs/ep93xx_defconfig No function change. This just refreshes the ep93xx_defconfig to make it easier and cleaner when adding new entries. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Acked-by: Ryan Mallon rmal...@gmail.com Cc: Alan Stern st...@rowland.harvard.edu Cc: Lennert Buytenhek ker...@wantstofly.org Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Olof Johansson o...@lixom.net Cc: Russell King li...@arm.linux.org.uk --- arch/arm/configs/ep93xx_defconfig | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/arch/arm/configs/ep93xx_defconfig b/arch/arm/configs/ep93xx_defconfig index 806005a..8eccbcb 100644 --- a/arch/arm/configs/ep93xx_defconfig +++ b/arch/arm/configs/ep93xx_defconfig @@ -1,15 +1,14 @@ -CONFIG_EXPERIMENTAL=y CONFIG_SYSVIPC=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_LOG_BUF_SHIFT=14 -CONFIG_SYSFS_DEPRECATED_V2=y CONFIG_EXPERT=y CONFIG_SLAB=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_MODULE_FORCE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y # CONFIG_IOSCHED_CFQ is not set CONFIG_ARCH_EP93XX=y CONFIG_CRUNCH=y @@ -47,11 +46,8 @@ CONFIG_IPV6=y CONFIG_UEVENT_HELPER_PATH=/sbin/hotplug # CONFIG_FW_LOADER is not set CONFIG_MTD=y -CONFIG_MTD_CONCAT=y -CONFIG_MTD_PARTITIONS=y CONFIG_MTD_REDBOOT_PARTS=y CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_ADV_OPTIONS=y @@ -67,15 +63,14 @@ CONFIG_SCSI=y # CONFIG_SCSI_PROC_FS is not set CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y -CONFIG_NET_ETHERNET=y CONFIG_EP93XX_ETH=y CONFIG_USB_RTL8150=y # CONFIG_INPUT is not set # CONFIG_SERIO is not set # CONFIG_VT is not set +# CONFIG_LEGACY_PTYS is not set CONFIG_SERIAL_AMBA_PL010=y CONFIG_SERIAL_AMBA_PL010_CONSOLE=y -# CONFIG_LEGACY_PTYS is not set # CONFIG_HW_RANDOM is not set CONFIG_I2C=y CONFIG_I2C_CHARDEV=y @@ -86,7 +81,6 @@ CONFIG_WATCHDOG=y CONFIG_EP93XX_WATCHDOG=y CONFIG_USB=y CONFIG_USB_DEBUG=y -CONFIG_USB_DEVICEFS=y CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y @@ -100,24 +94,18 @@ CONFIG_RTC_DRV_EP93XX=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y # CONFIG_EXT3_FS_XATTR is not set -CONFIG_INOTIFY=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_JFFS2_FS=y CONFIG_NFS_FS=y -CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y -CONFIG_PARTITION_ADVANCED=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y CONFIG_MAGIC_SYSRQ=y -CONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_SLAB=y CONFIG_DEBUG_SPINLOCK=y CONFIG_DEBUG_MUTEXES=y -# CONFIG_RCU_CPU_STALL_DETECTOR is not set CONFIG_DEBUG_USER=y -CONFIG_DEBUG_ERRORS=y CONFIG_DEBUG_LL=y # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_LIBCRC32C=y -- 1.8.3.2 -- 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 v4] usb: ohci: remove ep93xx bus glue platform driver
Convert ep93xx to use the OHCI platform driver and remove the ohci-ep93xx bus glue driver. Enable CONFIG_OHCI_HCD_PLATFORM in the ep93xx_defconfig so that USB is still enabled by default on the EP93xx platform. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Acked-by: Alan Stern st...@rowland.harvard.edu Cc: Ryan Mallon rmal...@gmail.com Cc: Lennert Buytenhek ker...@wantstofly.org Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Olof Johansson o...@lixom.net Cc: Russell King li...@arm.linux.org.uk --- arch/arm/configs/ep93xx_defconfig | 1 + arch/arm/mach-ep93xx/clock.c | 2 +- arch/arm/mach-ep93xx/core.c | 38 +++- drivers/usb/host/ohci-ep93xx.c| 184 -- drivers/usb/host/ohci-hcd.c | 18 5 files changed, 36 insertions(+), 207 deletions(-) delete mode 100644 drivers/usb/host/ohci-ep93xx.c diff --git a/arch/arm/configs/ep93xx_defconfig b/arch/arm/configs/ep93xx_defconfig index 8eccbcb..6ac5ea7 100644 --- a/arch/arm/configs/ep93xx_defconfig +++ b/arch/arm/configs/ep93xx_defconfig @@ -83,6 +83,7 @@ CONFIG_USB=y CONFIG_USB_DEBUG=y CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_HCD_PLATFORM=y CONFIG_USB_STORAGE=y CONFIG_USB_SERIAL=y CONFIG_USB_SERIAL_CONSOLE=y diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c index c95dbce..39ef3b6 100644 --- a/arch/arm/mach-ep93xx/clock.c +++ b/arch/arm/mach-ep93xx/clock.c @@ -212,7 +212,7 @@ static struct clk_lookup clocks[] = { INIT_CK(NULL, hclk, clk_h), INIT_CK(NULL, apb_pclk, clk_p), INIT_CK(NULL, pll2, clk_pll2), - INIT_CK(ep93xx-ohci, NULL, clk_usb_host), + INIT_CK(ohci-platform,NULL, clk_usb_host), INIT_CK(ep93xx-keypad,NULL, clk_keypad), INIT_CK(ep93xx-fb,NULL, clk_video), INIT_CK(ep93xx-spi.0, NULL, clk_spi), diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index 3f12b88..9408fde 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c @@ -36,6 +36,7 @@ #include linux/export.h #include linux/irqchip/arm-vic.h #include linux/reboot.h +#include linux/usb/ohci_pdriver.h #include mach/hardware.h #include linux/platform_data/video-ep93xx.h @@ -297,22 +298,51 @@ static struct platform_device ep93xx_rtc_device = { .resource = ep93xx_rtc_resource, }; +/* + * EP93xx OHCI USB Host + */ + +static struct clk *ep93xx_ohci_host_clock; + +static int ep93xx_ohci_power_on(struct platform_device *pdev) +{ + if (!ep93xx_ohci_host_clock) { + ep93xx_ohci_host_clock = devm_clk_get(pdev-dev, NULL); + if (IS_ERR(ep93xx_ohci_host_clock)) + return PTR_ERR(ep93xx_ohci_host_clock); + } + + return clk_enable(ep93xx_ohci_host_clock); +} + +static void ep93xx_ohci_power_off(struct platform_device *pdev) +{ + clk_disable(ep93xx_ohci_host_clock); +} + +static struct usb_ohci_pdata ep93xx_ohci_pdata = { + .power_on = ep93xx_ohci_power_on, + .power_off = ep93xx_ohci_power_off, + .power_suspend = ep93xx_ohci_power_off, +}; static struct resource ep93xx_ohci_resources[] = { DEFINE_RES_MEM(EP93XX_USB_PHYS_BASE, 0x1000), DEFINE_RES_IRQ(IRQ_EP93XX_USB), }; +static u64 ep93xx_ohci_dma_mask = DMA_BIT_MASK(32); static struct platform_device ep93xx_ohci_device = { - .name = ep93xx-ohci, + .name = ohci-platform, .id = -1, + .num_resources = ARRAY_SIZE(ep93xx_ohci_resources), + .resource = ep93xx_ohci_resources, .dev= { - .dma_mask = ep93xx_ohci_device.dev.coherent_dma_mask, + .dma_mask = ep93xx_ohci_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = ep93xx_ohci_pdata, }, - .num_resources = ARRAY_SIZE(ep93xx_ohci_resources), - .resource = ep93xx_ohci_resources, }; diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c deleted file mode 100644 index 84a20d5..000 --- a/drivers/usb/host/ohci-ep93xx.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * OHCI HCD (Host Controller Driver) for USB. - * - * (C) Copyright 1999 Roman Weissgaerber wei...@vienna.at - * (C) Copyright 2000-2002 David Brownell dbrown...@users.sourceforge.net - * (C) Copyright 2002 Hewlett-Packard Company - * - * Bus Glue for ep93xx. - * - * Written by Christopher Hoover c...@hpl.hp.com - * Based on fragments of previous driver by Russell King et al. - * - * Modified for LH7A404 from
Re: [PATCH] usb: usb_phy_gen: refine conditional declaration of usb_nop_xceiv_register
On Thu, Oct 17, 2013 at 01:25:48PM -0400, Josh Boyer wrote: On Wed, Oct 16, 2013 at 07:18:41PM -0700, Guenter Roeck wrote: Commit 3fa4d734 (usb: phy: rename nop_usb_xceiv = usb_phy_gen_xceiv) changed the conditional around the declaration of usb_nop_xceiv_register from #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) defined(MODULE)) to #if IS_ENABLED(CONFIG_NOP_USB_XCEIV) While that looks the same, it is semantically different. The first expression is true if CONFIG_NOP_USB_XCEIV is built as module and if the including code is built as module. The second expression is true if code depending on CONFIG_NOP_USB_XCEIV if built as module or into the kernel. As a result, the arm:allmodconfig build fails with arch/arm/mach-omap2/built-in.o: In function `omap3_evm_init': arch/arm/mach-omap2/board-omap3evm.c:703: undefined reference to `usb_nop_xceiv_register' Fix the problem by reverting to the old conditional. Cc: Josh Boyer jwbo...@redhat.com Signed-off-by: Guenter Roeck li...@roeck-us.net I'm not entirely sure why I was CC'd on this one, but the patch looks good to me. I do wonder how many other uses of IS_ENABLED aren't taking this into account though. Unless I am wrong, you submitted a different patch to fix the same problem, which went nowhere, so I figured it was appropriate to Cc: you on this one. If not, my apologies. As for other use cases of IS_ENABLED, agreed, that may be an ongoing concern. That will have to be addressed individually, though. Thanks, Guenter -- 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 v4] usb: ohci: remove ep93xx bus glue platform driver
Refresh the ep93xx_defconfig then remove the ep93xx OHCI bus glue driver in favor of the Generic OHCI driver for a platform device. v4: propagate errno from clk_enable() in ep93xx_ohci_power_on(). v3: split patch to refresh the ep93xx_defconfig before removing ohci-ep93xx.c in favor of the Generic OHCI driver for a platform device. v2: Use the (*power_off) callback for (*power_suspend), as suggested by Alan Stern. Remove the Kconfig change to USB_OHCI_HCD_PLATFORM and refresh the ep93xx_defconfig to enable this option, as suggested by Alan Stern. H Hartley Sweeten (2): ARM: ep93xx_defconfig: cleanup ep93xx_defconfig usb: ohci: remove ep93xx bus glue platform driver arch/arm/configs/ep93xx_defconfig | 17 +--- arch/arm/mach-ep93xx/clock.c | 2 +- arch/arm/mach-ep93xx/core.c | 38 +++- drivers/usb/host/ohci-ep93xx.c| 184 -- drivers/usb/host/ohci-hcd.c | 18 5 files changed, 38 insertions(+), 221 deletions(-) delete mode 100644 drivers/usb/host/ohci-ep93xx.c -- 1.8.3.2 -- 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/2 v4] usb: ohci: remove ep93xx bus glue platform driver
On Thu, 17 Oct 2013, H Hartley Sweeten wrote: Convert ep93xx to use the OHCI platform driver and remove the ohci-ep93xx bus glue driver. Enable CONFIG_OHCI_HCD_PLATFORM in the ep93xx_defconfig so that USB is still enabled by default on the EP93xx platform. Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com Acked-by: Alan Stern st...@rowland.harvard.edu Cc: Ryan Mallon rmal...@gmail.com Cc: Lennert Buytenhek ker...@wantstofly.org Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Olof Johansson o...@lixom.net Cc: Russell King li...@arm.linux.org.uk Good work; thanks a lot for doing this. Greg, please merge both of these v4 patches. 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] xhci: Remove segments from radix tree on failed insert.
Hi, On 10/17/2013 09:44 PM, Sarah Sharp wrote: If we're expanding a stream ring, we want to make sure we can add those ring segments to the radix tree that maps segments to ring pointers. Try the radix tree insert after the new ring segments have been allocated (the last segment in the new ring chunk will point to the first newly allocated segment), but before the new ring segments are linked into the old ring. If insert fails on any one segment, remove each segment from the radix tree, deallocate the new segments, and return. Otherwise, link the new segments into the tree. Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- Something like this. Thanks for working on this. It's ugly, but it compiles. I haven't tested it. Hans, can you review and test this? Reviewed, I've one small nitpick, see inline comments, other then that it looks good, and I don't find it all that ugly :) I've also run various tests and it seems to work as advertised (I've not managed to trigger the error path though AFAIK). Acked-by: Hans de Goede hdego...@redhat.com Sarah Sharp drivers/usb/host/xhci-mem.c | 106 +--- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a455c56..6ce8d31 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -180,53 +180,98 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, * extended systems (where the DMA address can be bigger than 32-bits), * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. */ -static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags) +static int xhci_insert_segment_mapping(struct radix_tree_root *trb_address_map, + struct xhci_ring *ring, + struct xhci_segment *seg, + gfp_t mem_flags) { - struct xhci_segment *seg; unsigned long key; int ret; - if (WARN_ON_ONCE(ring-trb_address_map == NULL)) + key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); + /* Skip any segments that were already added. */ + if (radix_tree_lookup(trb_address_map, key)) return 0; - seg = ring-first_seg; - do { - key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); - /* Skip any segments that were already added. */ - if (radix_tree_lookup(ring-trb_address_map, key)) - continue; + ret = radix_tree_maybe_preload(mem_flags); + if (ret) + return ret; + ret = radix_tree_insert(trb_address_map, + key, ring); + radix_tree_preload_end(); + return ret; +} - ret = radix_tree_maybe_preload(mem_flags); - if (ret) - return ret; - ret = radix_tree_insert(ring-trb_address_map, - key, ring); - radix_tree_preload_end(); +static void xhci_remove_segment_mapping(struct radix_tree_root *trb_address_map, + struct xhci_segment *seg) +{ + unsigned long key; + + key = (unsigned long)(seg-dma TRB_SEGMENT_SHIFT); + if (radix_tree_lookup(trb_address_map, key)) + radix_tree_delete(trb_address_map, key); +} + +static int xhci_update_stream_segment_mapping( + struct radix_tree_root *trb_address_map, + struct xhci_ring *ring, + struct xhci_segment *first_seg, + struct xhci_segment *last_seg, + gfp_t mem_flags) +{ + struct xhci_segment *seg; + struct xhci_segment *failed_seg; + int ret; + + if (WARN_ON_ONCE(trb_address_map == NULL)) + return 0; + + seg = first_seg; + do { + ret = xhci_insert_segment_mapping(trb_address_map, + ring, seg, mem_flags); if (ret) - return ret; + goto remove_streams; + if (seg == last_seg) + return 0; seg = seg-next; - } while (seg != ring-first_seg); + } while (seg != first_seg); The while here tests for looping round, but that should never happen, IMHO using do {} while (true); here would be more clear, and also consistent with how the tear-down is done in the error case in xhci_ring_expansion. return 0; + +remove_streams: + failed_seg = seg; + seg = first_seg; + do { + xhci_remove_segment_mapping(trb_address_map, seg); + if (seg == failed_seg) + return ret; + seg = seg-next; + } while (seg != first_seg); And I would also prefer } while (true}; here for the same reasons. + + return ret; } static void xhci_remove_stream_mapping(struct xhci_ring *ring) { struct
[PATCH] uas: Fix uas not working when plugged into an ehci port
I thought it would be a good idea to also test uas with usb-2, and it turns out it ws, as it did not work. The problem is that the uas driver was passing the bEndpointAddress' direction bit to usb_rcvbulkpipe, the xhci code seems to not care about this, but with the ehci code this causes usb_submit_urb failure. With this fixed the uas code works nicely with an uas device plugged into an ehci port. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index bf80ef1..ba7c48d 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -594,10 +594,10 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, if (cmdinfo-state SUBMIT_DATA_IN_URB) { usb_anchor_urb(cmdinfo-data_in_urb, devinfo-data_urbs); - if (usb_submit_urb(cmdinfo-data_in_urb, gfp)) { + if ((err = usb_submit_urb(cmdinfo-data_in_urb, gfp))) { usb_unanchor_urb(cmdinfo-data_in_urb); scmd_printk(KERN_INFO, cmnd, - data in urb submission failure\n); + data in urb submission failure %d\n, err); return SCSI_MLQUEUE_DEVICE_BUSY; } cmdinfo-state = ~SUBMIT_DATA_IN_URB; @@ -957,13 +957,13 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo) eps[3] = usb_pipe_endpoint(udev, devinfo-data_out_pipe); } else { devinfo-cmd_pipe = usb_sndbulkpipe(udev, - eps[0]-desc.bEndpointAddress); + eps[0]-desc.bEndpointAddress 0xf); devinfo-status_pipe = usb_rcvbulkpipe(udev, - eps[1]-desc.bEndpointAddress); + eps[1]-desc.bEndpointAddress 0xf); devinfo-data_in_pipe = usb_rcvbulkpipe(udev, - eps[2]-desc.bEndpointAddress); + eps[2]-desc.bEndpointAddress 0xf); devinfo-data_out_pipe = usb_sndbulkpipe(udev, - eps[3]-desc.bEndpointAddress); + eps[3]-desc.bEndpointAddress 0xf); } devinfo-qdepth = usb_alloc_streams(devinfo-intf, eps + 1, 3, 256, -- 1.8.3.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
Re: [PATCH] uas: Fix uas not working when plugged into an ehci port
Hi, Ignore please I accidentally left some debugging in here, expect a v2 shortly. Regards, Hans On 10/17/2013 11:22 PM, Hans de Goede wrote: I thought it would be a good idea to also test uas with usb-2, and it turns out it ws, as it did not work. The problem is that the uas driver was passing the bEndpointAddress' direction bit to usb_rcvbulkpipe, the xhci code seems to not care about this, but with the ehci code this causes usb_submit_urb failure. With this fixed the uas code works nicely with an uas device plugged into an ehci port. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index bf80ef1..ba7c48d 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -594,10 +594,10 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, if (cmdinfo-state SUBMIT_DATA_IN_URB) { usb_anchor_urb(cmdinfo-data_in_urb, devinfo-data_urbs); - if (usb_submit_urb(cmdinfo-data_in_urb, gfp)) { + if ((err = usb_submit_urb(cmdinfo-data_in_urb, gfp))) { usb_unanchor_urb(cmdinfo-data_in_urb); scmd_printk(KERN_INFO, cmnd, - data in urb submission failure\n); + data in urb submission failure %d\n, err); return SCSI_MLQUEUE_DEVICE_BUSY; } cmdinfo-state = ~SUBMIT_DATA_IN_URB; @@ -957,13 +957,13 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo) eps[3] = usb_pipe_endpoint(udev, devinfo-data_out_pipe); } else { devinfo-cmd_pipe = usb_sndbulkpipe(udev, - eps[0]-desc.bEndpointAddress); + eps[0]-desc.bEndpointAddress 0xf); devinfo-status_pipe = usb_rcvbulkpipe(udev, - eps[1]-desc.bEndpointAddress); + eps[1]-desc.bEndpointAddress 0xf); devinfo-data_in_pipe = usb_rcvbulkpipe(udev, - eps[2]-desc.bEndpointAddress); + eps[2]-desc.bEndpointAddress 0xf); devinfo-data_out_pipe = usb_sndbulkpipe(udev, - eps[3]-desc.bEndpointAddress); + eps[3]-desc.bEndpointAddress 0xf); } devinfo-qdepth = usb_alloc_streams(devinfo-intf, eps + 1, 3, 256, -- 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] uas: Fix uas not working when plugged into an ehci port
I thought it would be a good idea to also test uas with usb-2, and it turns out it ws, as it did not work. The problem is that the uas driver was passing the bEndpointAddress' direction bit to usb_rcvbulkpipe, the xhci code seems to not care about this, but with the ehci code this causes usb_submit_urb failure. With this fixed the uas code works nicely with an uas device plugged into an ehci port. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/storage/uas.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index bf80ef1..078e962 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -957,13 +957,13 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo) eps[3] = usb_pipe_endpoint(udev, devinfo-data_out_pipe); } else { devinfo-cmd_pipe = usb_sndbulkpipe(udev, - eps[0]-desc.bEndpointAddress); + eps[0]-desc.bEndpointAddress 0xf); devinfo-status_pipe = usb_rcvbulkpipe(udev, - eps[1]-desc.bEndpointAddress); + eps[1]-desc.bEndpointAddress 0xf); devinfo-data_in_pipe = usb_rcvbulkpipe(udev, - eps[2]-desc.bEndpointAddress); + eps[2]-desc.bEndpointAddress 0xf); devinfo-data_out_pipe = usb_sndbulkpipe(udev, - eps[3]-desc.bEndpointAddress); + eps[3]-desc.bEndpointAddress 0xf); } devinfo-qdepth = usb_alloc_streams(devinfo-intf, eps + 1, 3, 256, -- 1.8.3.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
[Pull Request] xhci: Final patches for 3.13
The following changes since commit c00809d330cfe42469fcd1cfd63f0690b47ea9bb: USB: ohci-exynos: Remove non-DT support (2013-10-14 11:09:13 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git tags/for-usb-next-2013-10-17 for you to fetch changes up to a2cdc3432c361bb885476d1c625e22b518e0bc07: usb: xhci: remove the unused -address field (2013-10-16 15:49:49 -0700) xhci: Final patches for 3.13 Hi Greg, Here's my pull request for usb-next and 3.13. My xHCI tree is closed after this point, since I won't be able to run my full tests while I'm in Scotland. After Kernel Summit, I'll be on vacation with access to email from Oct 26th to Nov 6th. Here's what's in this request: - Patches to fix USB 2.0 Link PM issues that cause USB 3.0 devices to not enumerate or misbehave when plugged into a USB 2.0 port. Those are marked for stable. - A msec vs jiffies bug fix by xiao jin, which results in fairly harmless behavior, and thus isn't marked for stable. - Xenia's patches to refactor the xHCI command handling code, which makes it much more readable and consistent. - Misc cleanup patches, one by Sachin Kamat and three from Dan Williams. Here's what's not in this request: - Dan's two patches to allow the xHCI host to use the Windows or new enumeration scheme. I did not have time to test those, and I want to run them with as many USB devices as I can get a hold of. That will have to wait for 3.14. - Xenia's patches to remove xhci_readl in favor of readl. I'll queue those for 3.14 after I test them. - The xHCI streams update, UAS fixes, and usbfs streams support. I'm not comfortable with changes and fixes to that patchset coming in this late. I would rather wait for 3.14 and be really sure the streams support is stable before we add new userspace API and remove CONFIG_BROKEN from the uas driver. - Julius' patch to clear the port reset bit on hub resume that came in a couple days ago. It looks harmless, but I would rather take the time to test and queue it for usb-linus and the stable trees once 3.13-rc1 is out. Sarah Sharp Dan Williams (3): usb: hub_activate kill an 'else' usb: xhci: kill a conditional when toggling cycle usb: xhci: remove the unused -address field Mathias Nyman (1): xhci: Enable LPM support only for hardwired or BESL devices Sachin Kamat (1): usb: xhci: Staticize xhci_del_comp_mod_timer Sarah Sharp (4): usb: Disable USB 2.0 Link PM before device reset. xhci: Set L1 device slot on USB2 LPM enable/disable. usb: Don't enable USB 2.0 Link PM by default. usb: Push USB2 LPM disable on disconnect into USB core. Xenia Ragiadakou (17): xhci: remove unused argument from xhci_giveback_urb_in_irq() xhci: rename existing Command Completion Event handlers xhci: refactor TRB_ENABLE_SLOT case into function xhci: refactor TRB_DISABLE_SLOT case into function xhci: refactor TRB_ADDR_DEV case into function xhci: use completion event's slot id rather than dig it out of command xhci: refactor TRB_RESET_DEV case into function xhci: refactor TRB_NEC_GET_FW case into function xhci: refactor TRB_EVAL_CONTEXT case into function xhci: remove unused 'ep_ring' variable in handle_cmd_completion() xhci: refactor TRB_CONFIG_EP case into function xhci: add variable 'cmd_comp_code' in handle_cmd_completion() xhci: add variable 'cmd_trb' in handle_cmd_completion() xhci: add variable 'cmd_type' in handle_cmd_completion() xhci: replace 'xhci-cmd_ring-dequeue' with 'trb' in stop_ep cmd handler xhci: add argument 'slot_id' in stop_ep, set_deq and reset_ep cmd handlers xhci: replace 'event' with 'cmd_comp_code' in set_deq and reset_ep handlers xiao jin (1): xhci: correct the usage of USB_CTRL_SET_TIMEOUT drivers/usb/core/driver.c|3 + drivers/usb/core/hub.c | 45 +- drivers/usb/core/message.c |4 + drivers/usb/core/sysfs.c |6 +- drivers/usb/host/xhci-hub.c |5 +- drivers/usb/host/xhci-mem.c | 10 -- drivers/usb/host/xhci-ring.c | 324 -- drivers/usb/host/xhci.c | 182 +++- drivers/usb/host/xhci.h |3 +- include/linux/usb.h |4 +- 10 files changed, 263 insertions(+), 323 deletions(-) -- 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 01/27] usb: Disable USB 2.0 Link PM before device reset.
Before the USB core resets a device, we need to disable the L1 timeout for the roothub, if USB 2.0 Link PM is enabled. Otherwise the port may transition into L1 in between descriptor fetches, before we know if the USB device descriptors changed. LPM will be re-enabled after the full device descriptors are fetched, and we can confirm the device still supports USB 2.0 LPM after the reset. We don't need to wait for the USB device to exit L1 before resetting the device, since the xHCI roothub port diagrams show a transition to the Reset state from any of the Ux states (see Figure 34 in the 2012-08-14 xHCI specification update). This patch should be backported to kernels as old as 3.2, that contain the commit 65580b4321eb36f16ae8b5987bfa1bb948fc5112 xHCI: set USB2 hardware LPM. That was the first commit to enable USB 2.0 hardware-driven Link Power Management. Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: sta...@vger.kernel.org --- drivers/usb/core/hub.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 3f8933f..d3a1d79 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -5090,6 +5090,12 @@ static int usb_reset_and_verify_device(struct usb_device *udev) } parent_hub = usb_hub_to_struct_hub(parent_hdev); + /* Disable USB2 hardware LPM. +* It will be re-enabled by the enumeration process. +*/ + if (udev-usb2_hw_lpm_enabled == 1) + usb_set_usb2_hardware_lpm(udev, 0); + bos = udev-bos; udev-bos = NULL; -- 1.8.3.3 -- 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 08/27] xhci: remove unused argument from xhci_giveback_urb_in_irq()
From: Xenia Ragiadakou burzalod...@gmail.com This patch removes the adjective argument from xhci_giveback_urb_in_irq(), since it is not used in the function anymore. Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Acked-by: Sarah Sharp sarah.a.sh...@linux.intel.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 6bfbd80..9a6b18e 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -726,7 +726,7 @@ static void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci, /* Must be called with xhci-lock held in interrupt context */ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci, - struct xhci_td *cur_td, int status, char *adjective) + struct xhci_td *cur_td, int status) { struct usb_hcd *hcd; struct urb *urb; @@ -891,7 +891,7 @@ remove_finished_td: /* Doesn't matter what we pass for status, since the core will * just overwrite it (because the URB has been unlinked). */ - xhci_giveback_urb_in_irq(xhci, cur_td, 0, cancelled); + xhci_giveback_urb_in_irq(xhci, cur_td, 0); /* Stop processing the cancelled list if the watchdog timer is * running. @@ -1001,7 +1001,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) if (!list_empty(cur_td-cancelled_td_list)) list_del_init(cur_td-cancelled_td_list); xhci_giveback_urb_in_irq(xhci, cur_td, - -ESHUTDOWN, killed); + -ESHUTDOWN); } while (!list_empty(temp_ep-cancelled_td_list)) { cur_td = list_first_entry( @@ -1010,7 +1010,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) cancelled_td_list); list_del_init(cur_td-cancelled_td_list); xhci_giveback_urb_in_irq(xhci, cur_td, - -ESHUTDOWN, killed); + -ESHUTDOWN); } } } -- 1.8.3.3 -- 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 05/27] usb: Push USB2 LPM disable on disconnect into USB core.
The USB core currently handles enabling and disabling optional USB power management features during device transitions (device suspend/resume, driver bind/unbind, device reset, and device disconnect). Those optional power features include Latency Tolerance Messaging (LTM), USB 3.0 Link PM, and USB 2.0 Link PM. The USB core currently enables LPM on device enumeration and disables USB 2.0 Link PM when the device is reset. However, the xHCI driver disables LPM when the device is disconnected and the device context is freed. Push the call up into the USB core, in order to be consistent with the core handling all power management enabling and disabling. Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/core/message.c | 4 drivers/usb/host/xhci.c| 5 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 82927e1..bb31597 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1182,8 +1182,12 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) put_device(dev-actconfig-interface[i]-dev); dev-actconfig-interface[i] = NULL; } + + if (dev-usb2_hw_lpm_enabled == 1) + usb_set_usb2_hardware_lpm(dev, 0); usb_unlocked_disable_lpm(dev); usb_disable_ltm(dev); + dev-actconfig = NULL; if (dev-state == USB_STATE_CONFIGURED) usb_set_device_state(dev, USB_STATE_ADDRESS); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 0ea253e..e7571c9 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3571,11 +3571,6 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) del_timer_sync(virt_dev-eps[i].stop_cmd_timer); } - if (udev-usb2_hw_lpm_enabled) { - xhci_set_usb2_hardware_lpm(hcd, udev, 0); - udev-usb2_hw_lpm_enabled = 0; - } - spin_lock_irqsave(xhci-lock, flags); /* Don't disable the slot if the host controller is dead. */ state = xhci_readl(xhci, xhci-op_regs-status); -- 1.8.3.3 -- 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 06/27] usb: xhci: Staticize xhci_del_comp_mod_timer
From: Sachin Kamat sachin.ka...@linaro.org 'xhci_del_comp_mod_timer' is local to this file. Signed-off-by: Sachin Kamat sachin.ka...@linaro.org Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-hub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 773a6b28..5dd7b7d 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -524,7 +524,8 @@ static void xhci_hub_report_usb3_link_state(u32 *status, u32 status_reg) * the compliance mode timer is deleted. A port won't enter * compliance mode if it has previously entered U0. */ -void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, u16 wIndex) +static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, + u16 wIndex) { u32 all_ports_seen_u0 = ((1 xhci-num_usb3_ports)-1); bool port_in_u0 = ((status PORT_PLS_MASK) == XDEV_U0); -- 1.8.3.3 -- 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 04/27] xhci: Enable LPM support only for hardwired or BESL devices
From: Mathias Nyman mathias.ny...@linux.intel.com Some usb3 devices falsely claim they support usb2 hardware Link PM when connected to a usb2 port. We only trust hardwired devices or devices with the later BESL LPM support to be LPM enabled as default. [Note: Sarah re-worked the original patch to move the code into the USB core, and updated it to check whether the USB device supports BESL, instead of checking if the xHCI port it's connected to supports BESL encoding.] This patch should be backported to kernels as old as 3.11, that contain the commit a558ccdcc71c7770c5e80c926a31cfe8a3892a09 usb: xhci: add USB2 Link power management BESL support. Without this fix, some USB 3.0 devices will not enumerate or work properly under USB 2.0 ports on Haswell-ULT systems. Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: sta...@vger.kernel.org --- drivers/usb/core/hub.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 9be1a2d..566ac55 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3953,6 +3953,32 @@ static int hub_set_address(struct usb_device *udev, int devnum) return retval; } +/* + * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM + * when they're plugged into a USB 2.0 port, but they don't work when LPM is + * enabled. + * + * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the + * device says it supports the new USB 2.0 Link PM errata by setting the BESL + * support bit in the BOS descriptor. + */ +static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) +{ + int connect_type; + + if (!udev-usb2_hw_lpm_capable) + return; + + connect_type = usb_get_hub_port_connect_type(udev-parent, + udev-portnum); + + if ((udev-bos-ext_cap-bmAttributes USB_BESL_SUPPORT) || + connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { + udev-usb2_hw_lpm_allowed = 1; + usb_set_usb2_hardware_lpm(udev, 1); + } +} + /* Reset device, (re)assign address, get device descriptor. * Device connection must be stable, no more debouncing needed. * Returns device in USB_STATE_ADDRESS, except on error. @@ -4246,6 +4272,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, /* notify HCD that we have a device connected and addressed */ if (hcd-driver-update_device) hcd-driver-update_device(hcd, udev); + hub_set_initial_usb2_lpm_policy(udev); fail: if (retval) { hub_port_disable(hub, port1, 0); -- 1.8.3.3 -- 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 07/27] xhci: correct the usage of USB_CTRL_SET_TIMEOUT
From: xiao jin jin.x...@intel.com The usage of USB_CTRL_SET_TIMEOUT in xhci is incorrect. The definition of USB_CTRL_SET_TIMEOUT is 5000ms. The input timeout to wait_for_completion_interruptible_timeout is jiffies. That makes the timeout be longer than what we want, such as 50s in some platform. The patch is to use XHCI_CMD_DEFAULT_TIMEOUT instead of USB_CTRL_SET_TIMEOUT as command completion event timeout. Signed-off-by: xiao jin jin.x...@intel.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 5dd7b7d..0c80208 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -296,7 +296,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) /* Wait for last stop endpoint command to finish */ timeleft = wait_for_completion_interruptible_timeout( cmd-completion, - USB_CTRL_SET_TIMEOUT); + XHCI_CMD_DEFAULT_TIMEOUT); if (timeleft = 0) { xhci_warn(xhci, %s while waiting for stop endpoint command\n, timeleft == 0 ? Timeout : Signal); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index e7571c9..d3f6abb 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3447,7 +3447,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev) /* Wait for the Reset Device command to finish */ timeleft = wait_for_completion_interruptible_timeout( reset_device_cmd-completion, - USB_CTRL_SET_TIMEOUT); + XHCI_CMD_DEFAULT_TIMEOUT); if (timeleft = 0) { xhci_warn(xhci, %s while waiting for reset device command\n, timeleft == 0 ? Timeout : Signal); -- 1.8.3.3 -- 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 11/27] xhci: refactor TRB_DISABLE_SLOT case into function
From: Xenia Ragiadakou burzalod...@gmail.com The function that handles xHCI command completion is much too long and there is need to be broken up into individual functions for each command completion to improve code readablity. This patch refactors the code in TRB_DISABLE_SLOT switch case in handle_cmd_completion() into a fuction named xhci_handle_cmd_disable_slot(). Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 4cad420..0a4c86e 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1394,6 +1394,19 @@ static void xhci_handle_cmd_enable_slot(struct xhci_hcd *xhci, int slot_id, complete(xhci-addr_dev); } +static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) +{ + struct xhci_virt_device *virt_dev; + + virt_dev = xhci-devs[slot_id]; + if (!virt_dev) + return; + if (xhci-quirks XHCI_EP_LIMIT_QUIRK) + /* Delete default control endpoint resources */ + xhci_free_device_endpoint_resources(xhci, virt_dev, true); + xhci_free_virt_device(xhci, slot_id); +} + static void handle_cmd_completion(struct xhci_hcd *xhci, struct xhci_event_cmd *event) { @@ -1451,13 +1464,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, GET_COMP_CODE(le32_to_cpu(event-status))); break; case TRB_TYPE(TRB_DISABLE_SLOT): - if (xhci-devs[slot_id]) { - if (xhci-quirks XHCI_EP_LIMIT_QUIRK) - /* Delete default control endpoint resources */ - xhci_free_device_endpoint_resources(xhci, - xhci-devs[slot_id], true); - xhci_free_virt_device(xhci, slot_id); - } + xhci_handle_cmd_disable_slot(xhci, slot_id); break; case TRB_TYPE(TRB_CONFIG_EP): virt_dev = xhci-devs[slot_id]; -- 1.8.3.3 -- 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 02/27] xhci: Set L1 device slot on USB2 LPM enable/disable.
To enable USB 2.0 Link Power Management (LPM), the xHCI host controller needs the device slot ID to generate the device address used in L1 entry tokens. That information is set in the L1 device slot ID field of the USB 2.0 LPM registers. Currently, the L1 device slot ID is overwritten when the xHCI driver initiates the software test of USB 2.0 Link PM in xhci_usb2_software_lpm_test. It is never cleared when USB 2.0 Link PM is disabled for the device. That should be harmless, because the Hardware LPM Enable (HLE) bit is cleared when USB 2.0 Link PM is disabled, so the host should not pay attention to the slot ID. This patch should have no effect on host behavior, but since xhci_usb2_software_lpm_test is going away in an upcoming bug fix patch, we need to move that code to the function that enables and disables USB 2.0 Link PM. This patch should be backported to kernels as old as 3.11, that contain the commit a558ccdcc71c7770c5e80c926a31cfe8a3892a09 usb: xhci: add USB2 Link power management BESL support. The upcoming bug fix patch is also marked for that stable kernel. Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com Cc: sta...@vger.kernel.org --- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/host/xhci.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1e36dbb..2983e5d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4216,7 +4216,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, } pm_val = ~PORT_HIRD_MASK; - pm_val |= PORT_HIRD(hird) | PORT_RWE; + pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev-slot_id); xhci_writel(xhci, pm_val, pm_addr); pm_val = xhci_readl(xhci, pm_addr); pm_val |= PORT_HLE; @@ -4224,7 +4224,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, /* flush write */ xhci_readl(xhci, pm_addr); } else { - pm_val = ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK); + pm_val = ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK | PORT_L1DS_MASK); xhci_writel(xhci, pm_val, pm_addr); /* flush write */ xhci_readl(xhci, pm_addr); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 289fbfb..4660819 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -383,6 +383,7 @@ struct xhci_op_regs { #definePORT_RWE(1 3) #definePORT_HIRD(p)(((p) 0xf) 4) #definePORT_HIRD_MASK (0xf 4) +#definePORT_L1DS_MASK (0xff 8) #definePORT_L1DS(p)(((p) 0xff) 8) #definePORT_HLE(1 16) -- 1.8.3.3 -- 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 10/27] xhci: refactor TRB_ENABLE_SLOT case into function
From: Xenia Ragiadakou burzalod...@gmail.com The function that handles xHCI command completion is much too long and there is need to be broken up into individual functions for each command completion to improve code readablity. This patch refactors the code in TRB_ENABLE_SLOT switch case in handle_cmd_completion() into a fuction named xhci_handle_cmd_enable_slot(). Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index f5d5047..4cad420 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1384,6 +1384,16 @@ static int handle_stopped_cmd_ring(struct xhci_hcd *xhci, return cur_trb_is_good; } +static void xhci_handle_cmd_enable_slot(struct xhci_hcd *xhci, int slot_id, + u32 cmd_comp_code) +{ + if (cmd_comp_code == COMP_SUCCESS) + xhci-slot_id = slot_id; + else + xhci-slot_id = 0; + complete(xhci-addr_dev); +} + static void handle_cmd_completion(struct xhci_hcd *xhci, struct xhci_event_cmd *event) { @@ -1437,11 +1447,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, switch (le32_to_cpu(xhci-cmd_ring-dequeue-generic.field[3]) TRB_TYPE_BITMASK) { case TRB_TYPE(TRB_ENABLE_SLOT): - if (GET_COMP_CODE(le32_to_cpu(event-status)) == COMP_SUCCESS) - xhci-slot_id = slot_id; - else - xhci-slot_id = 0; - complete(xhci-addr_dev); + xhci_handle_cmd_enable_slot(xhci, slot_id, + GET_COMP_CODE(le32_to_cpu(event-status))); break; case TRB_TYPE(TRB_DISABLE_SLOT): if (xhci-devs[slot_id]) { -- 1.8.3.3 -- 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 18/27] xhci: refactor TRB_CONFIG_EP case into function
From: Xenia Ragiadakou burzalod...@gmail.com The function that handles xHCI command completion is much too long and there is need to be broken up into individual functions for each command completion to improve code readablity. This patch refactors the code in TRB_CONFIG_EP switch case, in handle_cmd_completion(), into a fuction named xhci_handle_cmd_config_ep(). There were added two additional variables, 'add_flags' and 'drop_flags', to reduce line length below 80 chars and improve code readability. Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 114 +++ 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0bef11b..3e80532 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1407,6 +1407,66 @@ static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) xhci_free_virt_device(xhci, slot_id); } +static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id, + struct xhci_event_cmd *event, u32 cmd_comp_code) +{ + struct xhci_virt_device *virt_dev; + struct xhci_input_control_ctx *ctrl_ctx; + unsigned int ep_index; + unsigned int ep_state; + u32 add_flags, drop_flags; + + virt_dev = xhci-devs[slot_id]; + if (handle_cmd_in_cmd_wait_list(xhci, virt_dev, event)) + return; + /* +* Configure endpoint commands can come from the USB core +* configuration or alt setting changes, or because the HW +* needed an extra configure endpoint command after a reset +* endpoint command or streams were being configured. +* If the command was for a halted endpoint, the xHCI driver +* is not waiting on the configure endpoint command. +*/ + ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev-in_ctx); + if (!ctrl_ctx) { + xhci_warn(xhci, Could not get input context, bad type.\n); + return; + } + + add_flags = le32_to_cpu(ctrl_ctx-add_flags); + drop_flags = le32_to_cpu(ctrl_ctx-drop_flags); + /* Input ctx add_flags are the endpoint index plus one */ + ep_index = xhci_last_valid_endpoint(add_flags) - 1; + + /* A usb_set_interface() call directly after clearing a halted +* condition may race on this quirky hardware. Not worth +* worrying about, since this is prototype hardware. Not sure +* if this will work for streams, but streams support was +* untested on this prototype. +*/ + if (xhci-quirks XHCI_RESET_EP_QUIRK + ep_index != (unsigned int) -1 + add_flags - SLOT_FLAG == drop_flags) { + ep_state = virt_dev-eps[ep_index].ep_state; + if (!(ep_state EP_HALTED)) + goto bandwidth_change; + xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, + Completed config ep cmd - + last ep index = %d, state = %d, + ep_index, ep_state); + /* Clear internal halted state and restart ring(s) */ + virt_dev-eps[ep_index].ep_state = ~EP_HALTED; + ring_doorbell_for_active_rings(xhci, slot_id, ep_index); + return; + } +bandwidth_change: + xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, + Completed config ep cmd); + virt_dev-cmd_status = cmd_comp_code; + complete(virt_dev-cmd_completion); + return; +} + static void xhci_handle_cmd_eval_ctx(struct xhci_hcd *xhci, int slot_id, struct xhci_event_cmd *event, u32 cmd_comp_code) { @@ -1459,10 +1519,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, int slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event-flags)); u64 cmd_dma; dma_addr_t cmd_dequeue_dma; - struct xhci_input_control_ctx *ctrl_ctx; - struct xhci_virt_device *virt_dev; - unsigned int ep_index; - unsigned int ep_state; cmd_dma = le64_to_cpu(event-cmd_trb); cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci-cmd_ring-deq_seg, @@ -1512,54 +1568,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, xhci_handle_cmd_disable_slot(xhci, slot_id); break; case TRB_TYPE(TRB_CONFIG_EP): - virt_dev = xhci-devs[slot_id]; - if (handle_cmd_in_cmd_wait_list(xhci, virt_dev, event)) - break; - /* -* Configure endpoint commands can come from the USB core -* configuration or alt setting changes, or because the HW -* needed an extra configure endpoint command after a reset -* endpoint
[PATCH 13/27] xhci: use completion event's slot id rather than dig it out of command
From: Xenia Ragiadakou burzalod...@gmail.com Since the slot id retrieved from the Reset Device TRB matches the slot id in the command completion event, which is available, there is no need to determine it again. This patch removes the uneccessary reassignment to slot id and adds a WARN_ON in case the two Slot ID fields differ (although according xhci spec rev1.0 they should not differ). Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e3b61b83..88939b7 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1547,9 +1547,9 @@ bandwidth_change: xhci_handle_cmd_reset_ep(xhci, event, xhci-cmd_ring-dequeue); break; case TRB_TYPE(TRB_RESET_DEV): + WARN_ON(slot_id != TRB_TO_SLOT_ID( + le32_to_cpu(xhci-cmd_ring-dequeue-generic.field[3]))); xhci_dbg(xhci, Completed reset device command.\n); - slot_id = TRB_TO_SLOT_ID( - le32_to_cpu(xhci-cmd_ring-dequeue-generic.field[3])); virt_dev = xhci-devs[slot_id]; if (virt_dev) handle_cmd_in_cmd_wait_list(xhci, virt_dev, event); -- 1.8.3.3 -- 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 12/27] xhci: refactor TRB_ADDR_DEV case into function
From: Xenia Ragiadakou burzalod...@gmail.com The function that handles xHCI command completion is much too long and there is need to be broken up into individual functions for each command completion to improve code readablity. This patch refactors the code in TRB_ADDR_DEV switch case in handle_cmd_completion() into a fuction named xhci_handle_cmd_addr_dev(). Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0a4c86e..e3b61b83 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1407,6 +1407,13 @@ static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) xhci_free_virt_device(xhci, slot_id); } +static void xhci_handle_cmd_addr_dev(struct xhci_hcd *xhci, int slot_id, + u32 cmd_comp_code) +{ + xhci-devs[slot_id]-cmd_status = cmd_comp_code; + complete(xhci-addr_dev); +} + static void handle_cmd_completion(struct xhci_hcd *xhci, struct xhci_event_cmd *event) { @@ -1525,8 +1532,8 @@ bandwidth_change: complete(xhci-devs[slot_id]-cmd_completion); break; case TRB_TYPE(TRB_ADDR_DEV): - xhci-devs[slot_id]-cmd_status = GET_COMP_CODE(le32_to_cpu(event-status)); - complete(xhci-addr_dev); + xhci_handle_cmd_addr_dev(xhci, slot_id, + GET_COMP_CODE(le32_to_cpu(event-status))); break; case TRB_TYPE(TRB_STOP_RING): xhci_handle_cmd_stop_ep(xhci, xhci-cmd_ring-dequeue, event); -- 1.8.3.3 -- 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 09/27] xhci: rename existing Command Completion Event handlers
From: Xenia Ragiadakou burzalod...@gmail.com This patch renames the function handlers of a triggered Command Completion Event that correspond to each command type into 'xhci_handle_cmd_type'. That is done to give a consistent naming space to all the functions that handle Command Completion Events and that will permit the code reader to reference to them more easily. Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com Acked-by: Sarah Sharp sarah.a.sh...@linux.intel.com Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 9a6b18e..f5d5047 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -765,7 +765,7 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci, * 2. Otherwise, we turn all the TRBs in the TD into No-op TRBs (with the chain * bit cleared) so that the HW will skip over them. */ -static void handle_stopped_endpoint(struct xhci_hcd *xhci, +static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, union xhci_trb *trb, struct xhci_event_cmd *event) { unsigned int slot_id; @@ -1077,9 +1077,8 @@ static void update_ring_for_set_deq_completion(struct xhci_hcd *xhci, * endpoint doorbell to restart the ring, but only if there aren't more * cancellations pending. */ -static void handle_set_deq_completion(struct xhci_hcd *xhci, - struct xhci_event_cmd *event, - union xhci_trb *trb) +static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, + struct xhci_event_cmd *event, union xhci_trb *trb) { unsigned int slot_id; unsigned int ep_index; @@ -1171,9 +1170,8 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, ring_doorbell_for_active_rings(xhci, slot_id, ep_index); } -static void handle_reset_ep_completion(struct xhci_hcd *xhci, - struct xhci_event_cmd *event, - union xhci_trb *trb) +static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, + struct xhci_event_cmd *event, union xhci_trb *trb) { int slot_id; unsigned int ep_index; @@ -1517,15 +1515,15 @@ bandwidth_change: complete(xhci-addr_dev); break; case TRB_TYPE(TRB_STOP_RING): - handle_stopped_endpoint(xhci, xhci-cmd_ring-dequeue, event); + xhci_handle_cmd_stop_ep(xhci, xhci-cmd_ring-dequeue, event); break; case TRB_TYPE(TRB_SET_DEQ): - handle_set_deq_completion(xhci, event, xhci-cmd_ring-dequeue); + xhci_handle_cmd_set_deq(xhci, event, xhci-cmd_ring-dequeue); break; case TRB_TYPE(TRB_CMD_NOOP): break; case TRB_TYPE(TRB_RESET_EP): - handle_reset_ep_completion(xhci, event, xhci-cmd_ring-dequeue); + xhci_handle_cmd_reset_ep(xhci, event, xhci-cmd_ring-dequeue); break; case TRB_TYPE(TRB_RESET_DEV): xhci_dbg(xhci, Completed reset device command.\n); -- 1.8.3.3 -- 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