Re: [PATCH] hid: fix bug destroying hidraw device files after parent

2014-02-26 Thread Nestor Lopez Casado
Hi Fernando,

Why are older kernels not affected ?

-nestor

On Wed, Feb 26, 2014 at 8:56 AM, Fernando Luis Vázquez Cao
 wrote:
> I forgot to mention that if the fix below is acceptable it
> should be queued for 3.13-stable (older kernels are not
> affected).
>
>
> On 02/26/2014 04:51 PM, Fernando Luis Vázquez Cao wrote:
>>
>> I noticed that after hot unplugging a Logitech unifying receiver
>> (drivers/hid/hid-logitech-dj.c) the kernel would occasionally spew a
>> stack trace similar to this:
>>
>> usb 1-1.1.2: USB disconnect, device number 7
>> WARNING: CPU: 0 PID: 2865 at fs/sysfs/group.c:216 device_del+0x40/0x1b0()
>> sysfs group 8187fa20 not found for kobject 'hidraw0'
>> [...]
>> CPU: 0 PID: 2865 Comm: upowerd Tainted: GW 3.14.0-rc4 #7
>> Hardware name: LENOVO 7783PN4/, BIOS 9HKT43AUS 07/11/2011
>>   0009 814cd684 880427ccfdf8 810616e7
>>   88041ec61800 880427ccfe48 88041e444d80 880426fab8e8
>>   880429359960 8106174c 81714b98 0028
>> Call Trace:
>>   [] ? dump_stack+0x41/0x51
>>   [] ? warn_slowpath_common+0x77/0x90
>>   [] ? warn_slowpath_fmt+0x4c/0x50
>>   [] ? device_del+0x40/0x1b0
>>   [] ? device_unregister+0x2f/0x50
>>   [] ? device_destroy+0x3a/0x40
>>   [] ? drop_ref+0x55/0x120 [hid]
>>   [] ? hidraw_release+0x96/0xb0 [hid]
>>   [] ? __fput+0xca/0x210
>>   [] ? task_work_run+0x97/0xd0
>>   [] ? do_notify_resume+0x69/0xa0
>>   [] ? int_signal+0x12/0x17
>> ---[ end trace 63f4a46f6566d737 ]---
>>
>> During device removal hid_disconnect() is called via hid_hw_stop() to
>> stop the device and free all its resources, including the sysfs
>> files. The problem is that if a user space process, such as upowerd,
>> holds a reference to a hidraw file the corresponding sysfs files will
>> be kept around (drop_ref() does not call device_destroy() if the open
>> counter is not 0) and it will be usb_disconnect() who, by calling
>> device_del() for the USB device, will indirectly remove the sysfs
>> files of the hidraw device (sysfs_remove_dir() is recursive these
>> days). Because of this, by the time user space releases the last
>> reference to the hidraw file and drop_ref() tries to destroy the
>> device the sysfs files are already gone and the kernel will print
>> the warning above.
>>
>> Fix this by calling device_destroy() at USB disconnect time.
>>
>> Cc: Nestor Lopez Casado 
>> Signed-off-by: Fernando Luis Vazquez Cao 
>> ---
>>
>> diff -urNp linux-3.14-rc4-orig/drivers/hid/hidraw.c
>> linux-3.14-rc4/drivers/hid/hidraw.c
>> --- linux-3.14-rc4-orig/drivers/hid/hidraw.c2014-02-26
>> 14:21:48.622980475 +0900
>> +++ linux-3.14-rc4/drivers/hid/hidraw.c 2014-02-26 14:22:17.990979556
>> +0900
>> @@ -320,13 +320,13 @@ static void drop_ref(struct hidraw *hidr
>> hid_hw_close(hidraw->hid);
>> wake_up_interruptible(&hidraw->wait);
>> }
>> +   device_destroy(hidraw_class,
>> +  MKDEV(hidraw_major, hidraw->minor));
>> } else {
>> --hidraw->open;
>> }
>> if (!hidraw->open) {
>> if (!hidraw->exist) {
>> -   device_destroy(hidraw_class,
>> -   MKDEV(hidraw_major,
>> hidraw->minor));
>> hidraw_table[hidraw->minor] = NULL;
>> kfree(hidraw);
>> } else {
>>
>>
>>
>
--
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] hid: fix bug destroying hidraw device files after parent

2014-02-26 Thread David Herrmann
Hi

On Wed, Feb 26, 2014 at 8:51 AM, Fernando Luis Vázquez Cao
 wrote:
> I noticed that after hot unplugging a Logitech unifying receiver
> (drivers/hid/hid-logitech-dj.c) the kernel would occasionally spew a
> stack trace similar to this:
>
> usb 1-1.1.2: USB disconnect, device number 7
> WARNING: CPU: 0 PID: 2865 at fs/sysfs/group.c:216 device_del+0x40/0x1b0()
> sysfs group 8187fa20 not found for kobject 'hidraw0'
> [...]
> CPU: 0 PID: 2865 Comm: upowerd Tainted: GW 3.14.0-rc4 #7
> Hardware name: LENOVO 7783PN4/, BIOS 9HKT43AUS 07/11/2011
>  0009 814cd684 880427ccfdf8 810616e7
>  88041ec61800 880427ccfe48 88041e444d80 880426fab8e8
>  880429359960 8106174c 81714b98 0028
> Call Trace:
>  [] ? dump_stack+0x41/0x51
>  [] ? warn_slowpath_common+0x77/0x90
>  [] ? warn_slowpath_fmt+0x4c/0x50
>  [] ? device_del+0x40/0x1b0
>  [] ? device_unregister+0x2f/0x50
>  [] ? device_destroy+0x3a/0x40
>  [] ? drop_ref+0x55/0x120 [hid]
>  [] ? hidraw_release+0x96/0xb0 [hid]
>  [] ? __fput+0xca/0x210
>  [] ? task_work_run+0x97/0xd0
>  [] ? do_notify_resume+0x69/0xa0
>  [] ? int_signal+0x12/0x17
> ---[ end trace 63f4a46f6566d737 ]---
>
> During device removal hid_disconnect() is called via hid_hw_stop() to
> stop the device and free all its resources, including the sysfs
> files. The problem is that if a user space process, such as upowerd,
> holds a reference to a hidraw file the corresponding sysfs files will
> be kept around (drop_ref() does not call device_destroy() if the open
> counter is not 0) and it will be usb_disconnect() who, by calling
> device_del() for the USB device, will indirectly remove the sysfs
> files of the hidraw device (sysfs_remove_dir() is recursive these
> days). Because of this, by the time user space releases the last
> reference to the hidraw file and drop_ref() tries to destroy the
> device the sysfs files are already gone and the kernel will print
> the warning above.
>
> Fix this by calling device_destroy() at USB disconnect time.

Reviewed-by: David Herrmann 

This actually also fixes the issue that the device-node is kept even
though the device is dead. By destroying the "struct device", we make
sure to send out a remove-uevent so udev can drop the node. We
correctly check ->exists during open(), but it is still nice to see
the node go away once that bit is set.

Thanks
David

> Cc: Nestor Lopez Casado 
> Signed-off-by: Fernando Luis Vazquez Cao 
> ---
>
> diff -urNp linux-3.14-rc4-orig/drivers/hid/hidraw.c 
> linux-3.14-rc4/drivers/hid/hidraw.c
> --- linux-3.14-rc4-orig/drivers/hid/hidraw.c2014-02-26 14:21:48.622980475 
> +0900
> +++ linux-3.14-rc4/drivers/hid/hidraw.c 2014-02-26 14:22:17.990979556 +0900
> @@ -320,13 +320,13 @@ static void drop_ref(struct hidraw *hidr
> hid_hw_close(hidraw->hid);
> wake_up_interruptible(&hidraw->wait);
> }
> +   device_destroy(hidraw_class,
> +  MKDEV(hidraw_major, hidraw->minor));
> } else {
> --hidraw->open;
> }
> if (!hidraw->open) {
> if (!hidraw->exist) {
> -   device_destroy(hidraw_class,
> -   MKDEV(hidraw_major, hidraw->minor));
> hidraw_table[hidraw->minor] = NULL;
> kfree(hidraw);
> } else {
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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] u_ether: move hardware transmit to RX workqueue

2014-02-26 Thread clanlab.proj
On Mon, Feb 24, 2014 at 10:57 PM, Manu Gautam  wrote:

> On 2/22/2014 11:11 AM, Clanlab (Taiwan) Linux Project wrote:
>> In order to reduce the interrupt times in the embedded system,
>> a receiving workqueue is introduced.
>> This modification also enhanced the overall throughput as the
>> benefits of reducing interrupt occurrence.
>
> This patch looks to be derived from:
> https://android.googlesource.com/kernel/msm/+/08eb78ebbee92e4f133fc75237cf6af6356c38b6

Hi Manu,

After checking your comment, I've found the patch we were referenced
from github could probably be derived from msm.git (according to the
time stamp of patch/commit)
Since I've already fix the patch according to the suggestion on the
mailing list and  for kernel 3.13 and later.
Do I need to add any git comment to list the earlier idea as a
reference before the 3rd version of the patch is sent?
How does the reference and the format should be looked like?
Dose any one could give me any suggestion? Thanks!

Best regards,
Weinn.
--
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/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread freddy
From: Freddy Xin 

Add VID:DID for Lenovo OneLinkDock Gigabit LAN

Signed-off-by: Freddy Xin 
---
 drivers/net/usb/ax88179_178a.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 955df81..460e823 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1421,6 +1421,19 @@ static const struct driver_info samsung_info = {
.tx_fixup = ax88179_tx_fixup,
 };
 
+static const struct driver_info lenovo_info = {
+   .description = "Lenovo OneLinkDock Gigabit LAN",
+   .bind = ax88179_bind,
+   .unbind = ax88179_unbind,
+   .status = ax88179_status,
+   .link_reset = ax88179_link_reset,
+   .reset = ax88179_reset,
+   .stop = ax88179_stop,
+   .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+   .rx_fixup = ax88179_rx_fixup,
+   .tx_fixup = ax88179_tx_fixup,
+};
+
 static const struct usb_device_id products[] = {
 {
/* ASIX AX88179 10/100/1000 */
@@ -1438,6 +1451,10 @@ static const struct usb_device_id products[] = {
/* Samsung USB Ethernet Adapter */
USB_DEVICE(0x04e8, 0xa100),
.driver_info = (unsigned long)&samsung_info,
+}, {
+   /* Lenovo OneLinkDock Gigabit LAN */
+   USB_DEVICE(0x17ef, 0x304b),
+   .driver_info = (unsigned long)&lenovo_info,
 },
{ },
 };
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] hid: fix bug destroying hidraw device files after parent

2014-02-26 Thread Jiri Kosina
On Wed, 26 Feb 2014, Fernando Luis Vázquez Cao wrote:

> I noticed that after hot unplugging a Logitech unifying receiver
> (drivers/hid/hid-logitech-dj.c) the kernel would occasionally spew a
> stack trace similar to this:
> 
> usb 1-1.1.2: USB disconnect, device number 7
> WARNING: CPU: 0 PID: 2865 at fs/sysfs/group.c:216 device_del+0x40/0x1b0()
> sysfs group 8187fa20 not found for kobject 'hidraw0'
> [...]
> CPU: 0 PID: 2865 Comm: upowerd Tainted: GW 3.14.0-rc4 #7
> Hardware name: LENOVO 7783PN4/, BIOS 9HKT43AUS 07/11/2011
>  0009 814cd684 880427ccfdf8 810616e7
>  88041ec61800 880427ccfe48 88041e444d80 880426fab8e8
>  880429359960 8106174c 81714b98 0028
> Call Trace:
>  [] ? dump_stack+0x41/0x51
>  [] ? warn_slowpath_common+0x77/0x90
>  [] ? warn_slowpath_fmt+0x4c/0x50
>  [] ? device_del+0x40/0x1b0
>  [] ? device_unregister+0x2f/0x50
>  [] ? device_destroy+0x3a/0x40
>  [] ? drop_ref+0x55/0x120 [hid]
>  [] ? hidraw_release+0x96/0xb0 [hid]
>  [] ? __fput+0xca/0x210
>  [] ? task_work_run+0x97/0xd0
>  [] ? do_notify_resume+0x69/0xa0
>  [] ? int_signal+0x12/0x17

Applied, thanks.

I have slightly modified the patch title to make sure that it's obvious 
that what it fixes is actually a WARN_ON() splat.

-- 
Jiri Kosina
SUSE Labs
--
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


gadgetfs: usb.c test application not working properly on i.mx6

2014-02-26 Thread Marco Zamponi
Hello!
I compiled usb.c for both an ARM cortex a5 (kernel 3.6.9) and a9 (3.0.35).
Both are connected to the same host when I run the binary with verbose output.
One of them (the one on the A5) appears very quickly as a USB device in
USB device tree viewer and has all the correct string descriptors set.

However the second one (i.mx6 board) takes a long time to show up and then
there are no string descriptors visible.
Only "*!*  string descriptors are not available because device is in
low power state"
 instead of iManufacturer, iProduct etc.
Also, under "Device Information" in USB device tree viewer it says
"Capabilities: Removable, UniqueID" on the Cortex A5 whereas UniqueID
is missing on the A9.

What could be the cause for this issue?

This is the verbose output on the A5:
/dev/gadget/atmel_usba_udc ep0 configured
serial="yyrczl3j39ido7t97zvv2s6l3tarb8t3r9whdjs5m2uffu8ww1sakk8i9qlwmm9"

** Thu Jan  1 00:38:19 1970
CONNECT high speed
DISCONNECT
CONNECT high speed
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0300 i 255
SETUP 80.06 v0302 i0409 255
SUSPEND
DISCONNECT
CONNECT high speed
DISCONNECT
CONNECT high speed
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0300 i 255
SETUP 80.06 v0302 i0409 255
SETUP 80.06 v0300 i 255
SETUP 80.06 v0301 i0409 255
SETUP 80.06 v0302 i0409 255
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0304 i0409 255
SETUP 80.06 v0305 i0409 255
SETUP 80.06 v0300 i 255
SETUP 80.06 v0301 i0409 255
SETUP 80.06 v0302 i0409 255
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0304 i0409 255
SETUP 80.06 v0305 i0409 255
SETUP 80.06 v0300 i 255
SETUP 80.06 v0301 i0409 255
SETUP 80.06 v0302 i0409 255
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0304 i0409 255
SETUP 80.06 v0305 i0409 255


This is from the one running ont he A9:
/dev/gadget/fsl-usb2-udc ep0 configured
serial="i73kaxk4afvigfp1nzpzsckbkv7ayl4znr4rfyc47k99mraqheuqs6w7ajeni18"

** Wed Feb 26 10:02:02 2014
SUSPEND
CONNECT high speed
DISCONNECT
CONNECT high speed
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0300 i 255
SUSPEND
DISCONNECT
CONNECT high speed
DISCONNECT
CONNECT high speed
SETUP 80.06 v0303 i0409 255
SETUP 80.06 v0300 i 255
--
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 00/11] usb: dwc3: more hibernation helpers

2014-02-26 Thread Pratyush Anand
On Wed, Feb 26, 2014 at 03:40:32AM +0800, Felipe Balbi wrote:

Adding Amit for whome it will be very useful as he was about to
start some work related to hibernation.

Regards
Pratyush
> Hi,
> 
> these series cleans up dwc3 a little bit and adds more
> boiler plate code for hibernation support. Note that
> we're still *not* enabling hibernation, mainly because
> I don't have a device with hibernation configured *and*
> because I didn't finish power management of this driver.
> 
> Still, this should help people who have been trying to get
> hibernation working on some of their devices.
> 
> Felipe Balbi (7):
>   usb: dwc3: cleanup struct dwc3
>   usb: dwc3: add has_hibernation flag
>   usb: dwc3: core: allocate scratch buffers
>   usb: dwc3: core: enable Suspend bit for USB2/3 PHYs
>   usb: dwc3: core: fix indentation
>   usb: dwc3: gadget: set KEEP_CONNECT in case of hibernation
>   usb: dwc3: gadget: make sure HIRD threshold is 0 in superspeed
> 
> Paul Zimmerman (4):
>   usb: dwc3: add 'saved_state' field to dwc3_ep structure
>   usb: dwc3: gadget: implement dwc3_gadget_get_link_state
>   usb: dwc3: gadget: add a 'restore' argument to set_ep_config
>   usb: dwc3: gadget: add 'force' argument to stop_active_transfer
> 
>  drivers/usb/dwc3/core.c   | 103 +
>  drivers/usb/dwc3/core.h   |  55 +++-
>  drivers/usb/dwc3/gadget.c | 105 
> --
>  drivers/usb/dwc3/gadget.h |   1 +
>  4 files changed, 223 insertions(+), 41 deletions(-)
> 
> -- 
> 1.9.0
> 
> --
> 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
--
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 04/11] usb: dwc3: gadget: implement dwc3_gadget_get_link_state

2014-02-26 Thread Pratyush Anand
On Wed, Feb 26, 2014 at 03:40:36AM +0800, Felipe Balbi wrote:
> From: Paul Zimmerman 
> 
> This function will be used during hibernation to get
> the current link state. It will be needed at least
> for Hibernation support.
> 

Since we do receive linksts_change_interrupt, where we already update
dwc->link_state. So, do we really need it.

Regards
Pratyush

> Signed-off-by: Paul Zimmerman 
> Signed-off-by: Felipe Balbi 
--
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: gadgetfs: usb.c test application not working properly on i.mx6

2014-02-26 Thread Fabio Estevam
On Wed, Feb 26, 2014 at 7:08 AM, Marco Zamponi  wrote:

> This is from the one running ont he A9:
> /dev/gadget/fsl-usb2-udc ep0 configured

I have already told you this on another thread, but here I go once again:
fsl-usb2-udc is the old driver from 3.0.35.

Recent imx kernel uses chipidea driver instead, so please use the
latest 3.13.5 or 3.14-rc4.

Regards,

Fabio Estevam
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread Bjørn Mork
fre...@asix.com.tw writes:

> From: Freddy Xin 
>
> Add VID:DID for Lenovo OneLinkDock Gigabit LAN

This is the same patch Keith Packard sent, but with a slighly different
description.  I take that as another proof that we should not attempt to
describe devices in these drivers.  Describe the driver instead.




Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: musb - high CPU load in DMA mode and dropouts during audio playback

2014-02-26 Thread Michal Šmucr

On 18.2.2014 2:18, Michal Šmucr wrote:


Hello,

i'm fighting with audio playback problem on Beaglebone Black AM-3358.
Class compilant USB soundcards with isochronous transfers.

With DMA enabled in kernels 3.13.2 and 3.14-rc2 it has following symptoms.
- it will stutter immediately after starts of playback
- kworker thread shows about 80-90% CPU usage during playback
- it presents with cppi41_dma_control warnings and traces, plus couple
of transfer errors
(i've enabled also CONFIG_DMADEVICES_DEBUG, so it dmesg is quite lengthy)
http://vpub.smucr.cz/pub/bbb/debug/dmesg.log

With force PIO at any tested kernel from 3.8.x to 3.14.x and DMA mode at
3.12.9 it is better, CPU load seems to be much lower, but it is not
completely solved. Still during high interrupt load from other devices
like NIC or second USB port, i'm having audio dropouts. Without any
messages this time.

I tested to apply following George Cherian's related patches

http://marc.info/?l=linux-usb&m=139081552015728&w=2
usb: musb: musb_host: Enable ISOCH IN handling for AM335x host
usb: musb: musb_cppi41: Make CPPI aware of high bandwidth transfers
usb: musb: musb_cppi41: Handle ISOCH differently and not use the hrtimer

and Adam Wozniak's
http://marc.info/?l=linux-usb&m=139101388408467&w=2
"high cpu load on omap3 using musb"



I also tried to find something related in TI git tree and compile 
linux-next, but without luck.

Any tips, what to do next? Does anybody experienced same issue?

Thanks,

Michal


--
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: HSIC on imx6

2014-02-26 Thread Rolf Evers-Fischer

> Rolf Evers-Fischer  hat am 25. Februar 2014 um
> 17:30 geschrieben:
>
>
> Dear Peter,
>
> > Peter Chen  hat am 20. Februar 2014 um 02:45
> > geschrieben:
> >
> >
> >
> >
> > > >
> > >
> > > Okay that makes sense. In theory the ehci core should do the reset. Is
> > > there anything special regarding reset and HSIC?
> > >
> >
> > After pcd interrupt occurs, hsic will be treated as a normal ehci host.
> >
> > > >>
> > > >> > It seems more and more guys are working at hsic controller, I will
> > > >> > try to submit hsic support asap.
> > > >> >
> > > >>
> > > >> If you have something working it would be really cool to get those
> > > >> patches. I am working some days on this topic but without much
> > > >> success and I am running out of time :/
> > > >>
> > > >
> > > > Will keep you posted.
> > > >
> > >
> > > Hope you soon will find some time.
> > >
> >
> > Since some chipidea code needs to change before adapting HSIC support,
> > I submit a temp version at my git, it is not suitable for upstream, but
> > can let the hsic work.
> >
> > github.com/hzpeterchen/linux-usb.git
> > branch: fsl-hsic-support
> >
> >
> > Peter
> >
> I did some backport or your patches to 3.13. Additionally I had to remove some
> other patches that we were using in previous kernel versions for the HSIC
> ports.
> 
> Now the HSIC ports themselves (Bus003 and Bus004) appear again with lsusb:
>   Bus 002 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
>   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
>   Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
>   Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
>   Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
>
> But unfortunately the devices, which are connected to the HSIC ports, do not
> appear. I would expect a USB4640-hub on Bus 003 and a Sierra Wireless card
> attached:
>   Bus 003 Device 002: ID 0424:2640 Standard Microsystems Corp. USB 2.0 Hub
>   Bus 003 Device 003: ID 0424:4040 Standard Microsystems Corp.
>   Bus 003 Device 004: ID 1199:68a3 Sierra Wireless, Inc.
>
> I will try to find out, why the other devices are not being found.
>
> Kind regards,
>  Rolf
> 
 
There was a mistake in my devicetree. The HSIC ports are working when I set the
dts entries like this:

&usbh2 {
    pinctrl-names = "idle", "active";
    pinctrl-0 = <&pinctrl_usbh2_1>;
    pinctrl-1 = <&pinctrl_usbh2_2>;
    osc-clkgate-delay = <0x3>;
    status = "okay";
};

&usbh3 {
    pinctrl-names = "idle", "active";
    pinctrl-0 = <&pinctrl_usbh3_1>;
    pinctrl-1 = <&pinctrl_usbh3_2>;
    osc-clkgate-delay = <0x3>;
    status = "okay";
};

&fec {
        #address-cells = <1>;
        #size-cells = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_enet_poc20>;
        phy-mode = "mii";
        status = "okay";
        phy = <&phy3>;

        phy3: ethernet-phy@3 {
                reg = <3>;
                device_type = "ethernet-phy";
        };
};

Best regards,
 Rolf
--
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: HSIC on imx6

2014-02-26 Thread Rolf Evers-Fischer
Hi Christian,

> Peter Chen  hat am 26. Februar 2014 um 03:05
> geschrieben:
>
>
>
> > >> >> patches. I am working some days on this topic but without much
> > >> >> success and I am running out of time :/
> > >> >>
> > >> >
> > >> > Will keep you posted.
> > >> >
> > >>
> > >> Hope you soon will find some time.
> > >>
> > >
> > > Since some chipidea code needs to change before adapting HSIC support,
> > > I submit a temp version at my git, it is not suitable for upstream,
> > > but can let the hsic work.
> > >
> > > github.com/hzpeterchen/linux-usb.git
> > > branch: fsl-hsic-support
> > >
> >
> > I did backport those patches to 3.13.4 but it does not work. Here you can
> > find a log http://dpaste.com/hold/1656798/ generated by this dts:
> >
> > &usdhc3 {
> > pinctrl-names = "default";
> > pinctrl-0 = <&pinctrl_usdhc3_1>;
> > bus-width = <8>;
> > non-removable;
> > status = "okay";
> > };
> >
> > &usbh1 {
> > status = "okay";
> > };
> >
> > &usbh2 {
> > pinctrl-names = "idle", "active";
> > pinctrl-0 = <&pinctrl_usbh2_1>;
> > pinctrl-1 = <&pinctrl_usbh2_2>;
> > osc-clkgate-delay = <0x3>;
> > status = "okay";
> > };
> >
> > &usbh3 {
> > pinctrl-names = "idle", "active";
> > pinctrl-0 = <&pinctrl_usbh3_1>;
> > pinctrl-1 = <&pinctrl_usbh3_2>;
> > osc-clkgate-delay = <0x3>;
> > status = "okay";
> > };
> >
> > &fec {
> > pinctrl-names = "default";
> > pinctrl-0 = <&pinctrl_enet_4>;
> > phy-mode = "mii";
> > status = "okay";
> > };
> >
> > greets
> > --
> > Christian Gmeiner, MSc
> >
> > https://soundcloud.com/christian-gmeiner
> >
>
> try to cherry-pick
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=73de93440186c595a031046e266f6caaac106aa0
>
were you successful with this patch?
If not: Have you already tried to disable the "&fec"? I'm asking, because I saw
this comment from Peter Chen:
"Since hsic has pin conflict with ethernet, we disable ethernet at this dts...".

I can also offer you to upload a bootlog of our IMX6Q board with HSIC working on
Bus 003, if it helps.

By the way: I was using the patch from
http://www.spinics.net/lists/arm-kernel/msg303287.html for my board in previous
kernel versions.

Best regards,
 Rolf
--
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 00/11] usb: dwc3: more hibernation helpers

2014-02-26 Thread Felipe Balbi
On Wed, Feb 26, 2014 at 03:38:23PM +0530, Pratyush Anand wrote:
> On Wed, Feb 26, 2014 at 03:40:32AM +0800, Felipe Balbi wrote:
> 
> Adding Amit for whome it will be very useful as he was about to
> start some work related to hibernation.

wait a bit on hibernation, there's a lot of ground work still to be done
before we can start adding hibernation support. I have some of that
cooking up in "dwc3-initial-pm-support" on my k.org git tree.

Once all of that is tested and stabilized, we can start thinking about
actually implementing hibernation.

Note that Hibernation is a rather complex feature and it'll need a lot
of careful testing before we can merge it upstream and, since I don't
have HW with hibernation support, I'll need you guys to help testing.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/6] usb: gadget: mv_udc: disable HW zlt for ep0

2014-02-26 Thread Felipe Balbi
Hi,

On Tue, Feb 25, 2014 at 05:48:17PM -0800, Neil Zhang wrote:
> > > > > > > > Hardware zlt will try to send the zero length packet
> > > > > > > > automatically when the data transferd is multiple times of
> > > > > > > > max packet, this will cause issues on Windows.
> > > > > > > > So let's disable HW zlt by default.
> > > > > > >
> > > > > > > Would you have description that what kinds of issue on Windows
> > > > > > > if zlt is is selected?
> > > > > > >
> > > > > >
> > > > > > Enumeration will fail.
> > > > > >
> > > > >
> > > > > What causes enumeration fail, why it does not occur before?
> > > > >
> > > > A unexpected zero packet cause enumeration fail.
> > > > It's not easy that the descriptor is actually 1024 bytes, so not
> > > > easy to be found.
> > > >
> > >
> > > Chipidea bug too? Does it follow ch 8.5.3.2 Variable-length Data Stage, 
> > > USB
> > 2.0 spec?
> > 
> > wait, this is a chipidea core ? Why aren't you guys using the chipidea 
> > driver
> > yet ? You need to switch over to that driver dude, we can't have duplicated
> > code in the tree.
> > 
> > I'm sorry, but I won't be taking this series, please use chipidea driver, 
> > it should
> > be very simple to add a glue layer for your core to the chipidea driver.
> > 
> 
> Yes, it use chipidea IP.
> But the driver is earlier than the chipidea one and we use it for our
> products.
> So it may be not that easy to switch to chipidea driver due to the
> stability.

that's nonsense, the average chipidea glue layer is ~80 LOCs. You can
write that in less than 2 hours and give it a try. We cannot have
duplicate drivers in the tree and development effort *must* be shared.

If you guys use the same IP, why wouldn't you use the same chipidea
driver ?

sorry, you didn't convince me.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/6] usb: gadget: mv_udc: disable HW zlt for ep0

2014-02-26 Thread Felipe Balbi
On Wed, Feb 26, 2014 at 02:36:19AM +, Peter Chen wrote:
>  
> > > > > easy to be found.
> > > > >
> > > >
> > > > Chipidea bug too? Does it follow ch 8.5.3.2 Variable-length Data
> > > > Stage, USB
> > > 2.0 spec?
> > >
> > > wait, this is a chipidea core ? Why aren't you guys using the chipidea
> > > driver yet ? You need to switch over to that driver dude, we can't
> > > have duplicated code in the tree.
> > >
> > > I'm sorry, but I won't be taking this series, please use chipidea
> > > driver, it should be very simple to add a glue layer for your core to
> > the chipidea driver.
> > >
> > 
> > Yes, it use chipidea IP.
> > But the driver is earlier than the chipidea one and we use it for our
> > products.
> > So it may be not that easy to switch to chipidea driver due to the
> > stability.
> > 
> 
> Freescale i.mx SoC used fsl_udc_core.c before which was the one of the
> oldest chipidea drivers, now, all i.mx SoC uses chipidea driver including
> old hardware.

Exactly, Freescale and Intel folks have shown that chipidea driver is
pretty good and ready for production.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/3] usb: dwc3: workaround: clock gating issues

2014-02-26 Thread Felipe Balbi
On Wed, Feb 26, 2014 at 02:19:38AM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 02/26/2014 12:36 AM, Felipe Balbi wrote:
> 
> >Revisions between 2.10a and 2.50a (included) have
> >a known issue which may cause xHCI compliance tests
> >to fail and/or quality issues with Isochronous
> >transactions.
> 
> >Note that this issue only impacts certain configurations
> >of those revisions, namely the ones which have clock
> >gating enabled.
> 
> >The suggested workaround is to disable clock gating in
> >known broken revisions, make sure HW LPM is disabled
> >and set GCTL.SOFITPSYNC to 1.
> 
> >Signed-off-by: Felipe Balbi 
> >---
> >  drivers/usb/dwc3/core.c | 37 -
> >  1 file changed, 28 insertions(+), 9 deletions(-)
> 
> >diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> >index 1cf1fb5..3270974 100644
> >--- a/drivers/usb/dwc3/core.c
> >+++ b/drivers/usb/dwc3/core.c
> >@@ -389,7 +389,26 @@ static int dwc3_core_init(struct dwc3 *dwc)
> >
> > switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
> > case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
> >-reg &= ~DWC3_GCTL_DSBLCLKGTNG;
> >+/**
> >+ * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
> >+ * issue which would cause xHCI compliance tests to fail.
> >+ *
> >+ * Because of that we cannot enable clock gating on such
> >+ * configurations.
> >+ *
> >+ * Refers to:
> >+ *
> >+ * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
> >+ * SOF/ITP Mode Used
> >+ */
> >+if ((dwc->dr_mode == USB_DR_MODE_HOST ||
> >+dwc->dr_mode == USB_DR_MODE_OTG) &&
> >+(dwc->revision >= DWC3_REVISION_210A &&
> >+dwc->revision <= DWC3_REVISION_250A)) {
> >+reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
> >+} else {
> >+reg &= ~DWC3_GCTL_DSBLCLKGTNG;
> >+}
> 
>I'm surprised checkpatch.pl doesn't protest about {} here. :-)

hehe, it was supposed to have more lines and then I figured it wouldn't
be needed. I'll remove those braces. Thanks for noticing.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/6] usb: gadget: mv_udc: disable HW zlt for ep0

2014-02-26 Thread Felipe Balbi
On Wed, Feb 26, 2014 at 02:36:19AM +, Peter Chen wrote:
>  
> > > > > easy to be found.
> > > > >
> > > >
> > > > Chipidea bug too? Does it follow ch 8.5.3.2 Variable-length Data
> > > > Stage, USB
> > > 2.0 spec?
> > >
> > > wait, this is a chipidea core ? Why aren't you guys using the chipidea
> > > driver yet ? You need to switch over to that driver dude, we can't
> > > have duplicated code in the tree.
> > >
> > > I'm sorry, but I won't be taking this series, please use chipidea
> > > driver, it should be very simple to add a glue layer for your core to
> > the chipidea driver.
> > >
> > 
> > Yes, it use chipidea IP.
> > But the driver is earlier than the chipidea one and we use it for our
> > products.
> > So it may be not that easy to switch to chipidea driver due to the
> > stability.
> > 
> 
> Freescale i.mx SoC used fsl_udc_core.c before which was the one of the

btw, when can I remove fsl_udc_core.c from the tree ?

-- 
balbi


signature.asc
Description: Digital signature


Re: Card reader not working properly with xHCI

2014-02-26 Thread Alan Stern
On Tue, 25 Feb 2014, Sarah Sharp wrote:

> On Tue, Feb 25, 2014 at 11:22:57PM +0100, Richard Sch�tz wrote:
> > Hi everybody!
> > 
> > I am experiencing a problem with my USB card reader and xHCI. Simply
> > using dd to write an image to a SD card results in USB resets after
> > a few seconds. Reading with dd or using cp after creating a
> > filesystem on the card also triggers the issue but usually not as
> > quick as writing to it with dd. All in all it is unusable. Sometimes
> > these resets also happen immediately after connecting the reader.
> > With EHCI everything just works fine.
> 
> Did it ever work under xHCI?  If so, which kernel version did it work
> on?
> 
> I'm Ccing the usb-storage developers, in case the usbmon trace provides
> some insight.

It doesn't.

> > usb 1-2: reset high-speed USB device number 19 using xhci_hcd
> > xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled
> > ep 8801b6837600
> > xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled
> > ep 8801b6837640
> > sd 22:0:0:0: [sdb] Media Changed
> > sd 22:0:0:0: [sdb]
> > Result: hostbyte=0x00 driverbyte=0x08
> > sd 22:0:0:0: [sdb]
> > Sense Key : 0x6 [current]
> > Info fld=0x0
> > sd 22:0:0:0: [sdb]
> > ASC=0x28 ASCQ=0x0
> > sd 22:0:0:0: [sdb] CDB:
> > cdb[0]=0x28: 28 00 00 00 1d 20 00 00 08 00
> > end_request: I/O error, dev sdb, sector 7456
> > sd 22:0:0:0: [sdb] No Caching mode page found
> > sd 22:0:0:0: [sdb] Assuming drive cache: write through
> > sd 22:0:0:0: [sdb] No Caching mode page found
> > sd 22:0:0:0: [sdb] Assuming drive cache: write through
> >  sdb: unknown partition table
> 
> It might help you to turn on CONFIG_USB_STORAGE_DEBUG, to see which SCSI
> command is failing.

CONFIG_USB_STORAGE_DEBUG is a lot less helpful for examining SCSI 
commands than a usbmon trace, because it includes lots of extraneous 
information.  It's meant more for debugging the usb-storage driver 
itself than for debugging device problems.

The command was an ordinary READ, same as a bunch of others that worked
fine.  And the failure occurred in the command phase, not the data
phase: The host doesn't receive an ACK response to the CBW packet.

> Can you blacklist the usb-storage driver, and get the lsusb output when
> the device is plugged into a USB 3.0 port?  I'd like to see the
> SuperSpeed Endpoint Companion Descriptor, to see what the Link PM U1/U2
> timeout values are.

Being a card reader, it is almost certainly a USB-2 device.  This is 
backed up by the fact that it ran at high speed, not SuperSpeed, when 
connected to an xHCI controller.  Therefore it doesn't have U1/U2 
timeouts.

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: 3.13.5, usb disappears sometimes and that results with sysfs being suprised

2014-02-26 Thread Alan Stern
On Wed, 26 Feb 2014, Arkadiusz Miskiewicz wrote:

> 
> Hi.
> 
> One of my dongles (logitech unifying) disappears sometimes. That results with 
> sysfs warning.
> 
> Shouldn't sysfs part be dealing with such scenario without a warning?

No, sysfs is doing the right thing.  But the HID subsystem isn't.

> [87068.076295] usb 6-1: USB disconnect, device number 5
> [87068.107659] [ cut here ]
> [87068.107680] WARNING: CPU: 0 PID: 4246 at fs/sysfs/group.c:214 
> sysfs_remove_group+0x4e/0xa7()
> [87068.107687] sysfs group 81a510c0 not found for kobject 'hidraw0'
> [87068.107691] Modules linked in: dccp_diag dccp tcp_diag udp_diag inet_diag 
> unix_diag xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter 
> xt_conntrack
>  nf_conntrack ip_tables x_tables sch_sfq ctr ccm joydev ext2 iTCO_wdt mbcache 
> iTCO_vendor_support pcmcia coretemp microcode psmouse sdhci_pci i2c_i801 
> pcspkr
>  sr_mod serio_raw yenta_socket arc4 firewire_ohci sdhci cdrom pcmcia_rsrc 
> cdc_ether lpc_ich usbnet firewire_core pcmcia_core mfd_core crc_itu_t mii 
> cdc_wdm m
> mc_core iwldvm mac80211 uvcvideo btusb videobuf2_vmalloc videobuf2_memops 
> cdc_acm videobuf2_core iwlwifi usbhid bluetooth videodev crc16 media cfg80211 
> think
> pad_acpi e1000e nvram wmi thermal snd_hda_codec_conexant ptp rfkill ac 
> battery evdev pps_core snd_hda_intel shpchp snd_hda_codec snd_hwdep snd_pcm 
> snd_page_a
> lloc snd_timer snd soundcore
> [87068.107867]  cpufreq_stats acpi_cpufreq processor vhost_net tun vhost 
> macvtap macvlan binfmt_misc kvm_intel tcp_illinois kvm ipv6 autofs4 xfs(F) 
> libcrc32c
> (F) crc32c(F) cbc(F) lrw(F) gf128mul(F) glue_helper(F) ablk_helper(F) 
> cryptd(F) aes_x86_64(F) dm_crypt(F) dm_mod(F) sd_mod(F) crc_t10dif(F) 
> crct10dif_generic
> (F) crct10dif_common(F) ahci(F) libahci(F) libata(F) scsi_mod(F) 
> hid_logitech_dj(F) hid(F) uhci_hcd(F) ehci_pci(F) ehci_hcd(F) usbcore(F) 
> usb_common(F)
> [87068.107957] CPU: 0 PID: 4246 Comm: upowerd Tainted: GF   W3.13.5 
> #90
> [87068.107963] Hardware name: LENOVO 2764CTO/2764CTO, BIOS 7UET94WW (3.24 ) 
> 10/17/2012
> [87068.107969]   8800bc68dd40 8140701a 
> 8800bc68dd88
> [87068.107979]  8800bc68dd78 81039024 8117e882 
> 
> [87068.107989]  81a510c0 88019040e410 880189b9d480 
> 8800bc68ddd8
> [87068.108053] Call Trace:
> [87068.108069]  [] dump_stack+0x4d/0x6f
> [87068.108080]  [] warn_slowpath_common+0x7a/0x93
> [87068.108089]  [] ? sysfs_remove_group+0x4e/0xa7
> [87068.108098]  [] warn_slowpath_fmt+0x47/0x49
> [87068.108110]  [] ? sysfs_get_dirent_ns+0x5e/0x66
> [87068.108118]  [] sysfs_remove_group+0x4e/0xa7
> [87068.108129]  [] dpm_sysfs_remove+0x37/0x3a
> [87068.108139]  [] device_del+0x3e/0x173
> [87068.108147]  [] device_unregister+0x42/0x4d
> [87068.108155]  [] device_destroy+0x33/0x37
> [87068.108185]  [] drop_ref.part.2+0x25/0x69 [hid]
> [87068.108209]  [] hidraw_release+0x9b/0xae [hid]
> [87068.108220]  [] __fput+0xd8/0x1b7
> [87068.108230]  [] fput+0x9/0xb
> [87068.108241]  [] task_work_run+0x78/0x8e
> [87068.108253]  [] do_notify_resume+0x5e/0x6d
> [87068.108263]  [] int_signal+0x12/0x17
> [87068.108270] ---[ end trace 74c570b0cc4e40c1 ]---
> [87068.344154] usb 6-1: new full-speed USB device number 6 using uhci_hcd
> [87068.524666] usb 6-1: New USB device found, idVendor=046d, idProduct=c52b
> [87068.524679] usb 6-1: New USB device strings: Mfr=1, Product=2, 
> SerialNumber=0
> [87068.524686] usb 6-1: Product: USB Receiver
> [87068.524694] usb 6-1: Manufacturer: Logitech
> [87068.542133] logitech-djreceiver 0003:046D:C52B.0013: hiddev0,hidraw0: USB 
> HID v1.11 Device [Logitech USB Receiver] on usb-:00:1d.0-1/input2
> [87068.555159] input: Logitech Unifying Device. Wireless PID:1028 as 
> /devices/pci:00/:00:1d.0/usb6/6-1/6-1:1.2/0003:046D:C52B.0013/input/input20
> [87068.555466] logitech-djdevice 0003:046D:C52B.0014: input,hidraw1: USB HID 
> v1.11 Mouse [Logitech Unifying Device. Wireless PID:1028] on 
> usb-:00:1d.0-1:1

See

http://marc.info/?l=linux-usb&m=139340147604136&w=2

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 04/11] usb: dwc3: gadget: implement dwc3_gadget_get_link_state

2014-02-26 Thread Felipe Balbi
Hi,

On Wed, Feb 26, 2014 at 03:34:43PM +0530, Pratyush Anand wrote:
> On Wed, Feb 26, 2014 at 03:40:36AM +0800, Felipe Balbi wrote:
> > From: Paul Zimmerman 
> > 
> > This function will be used during hibernation to get
> > the current link state. It will be needed at least
> > for Hibernation support.
> > 
> 
> Since we do receive linksts_change_interrupt, where we already update
> dwc->link_state. So, do we really need it.

I'll let Paul comment on this one.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v5 06/16] usb: defer suspension of superspeed port while peer is powered

2014-02-26 Thread Alan Stern
On Tue, 25 Feb 2014, Dan Williams wrote:

> > Look, we guarantee that the peer relation is dropped when either of the 
> > devices is unregistered.  Therefore there's no need to take a reference 
> > to the peer device.
> 
> Ugh, yes.  Reference counts alone don't save us from this scenario:
> 
> CPU1CPU2
> mutex_lock(peer_lock)
> unlink_peers(portA, portC)
> mutex_unlock(peer_lock)
> mutex_lock(peer_lock)
> device_unregister(portA)
> link_peers(portB, portA)
> mutex_unlock(peer_lock)
> 
> > This will cause a problem only if something else goes wrong.  That's
> > why I suggested, in patch 2, that when a peering error is detected, you
> > print out the erroneous pointer rather than assuming it points to a
> > valid port structure.
> 
> ...but even with the invalid port flag portA can theoretically still be
> a stale pointer.

I don't see how.

> > This is also why I suggested that you close the race in 
> > usb_hub_remove_port_device: to make sure that the guarantee really is 
> > enforced.
> 
> You proposed a flag on the port_dev once it goes invalid.  It seems to
> me the flag to check if a port is valid is parent_hub->disconnected.

Good suggestion.

> However, in the case above, I believe find_port_by_location() and
> find_default_peer() need to prevent the "link_peers(portB, portA)"
> event.  When these routines walk down the tree they should be taking
> usb_lock_device() to make sure they are not racing with disconnect
> operations.
> 
> Locking while traversing the list and otherwise checking for
> hub->disconnected closes the race.  We can't solve the race at the
> port_dev level alone.  Agreed?

No.  We already have the port_lock mutex; nothing else is needed.  
Simply make link_peers fail if either of the hub->disconnected flags is
set.  Then the scenario shown above can't happen, because link_peers
running on CPU2 will see that portA is stale.

However, it might be a good idea for usb_hub_create_port_device to hold 
the port_lock while doing

hub->ports[port1 - 1] = port_dev;

And perhaps this line should be moved down to just before the 
device_register call.  In fact, maybe that call should occur inside the 
scope of the mutex.

There may be other places where we have to be more careful about
assuming that hub->ports[port1 - 1] is non-NULL.  Even though checking
the disconnected flag will prevent races with port destruction, there
could be races with port creation.

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: usb audio breaks ohci-pci

2014-02-26 Thread Alan Stern
On Wed, 26 Feb 2014, Dennis New wrote:

> > That's weird.  Are you sure you were running the patched kernel?
> > There very definitely should have been a bunch of debugging output,
> > at the point where the headset was unplugged if not before.
> > 
> > > Should I enable CONFIG_DEBUG_KERNEL as well?
> > 
> > That's not necessary.
> 
> I'm still not getting any more debugging output after it crashes.
> 
> cat /proc/sys/kernel/printk = 8  4  1  7
> 
> I do however notice that I only get one of those timeout "still 3 active"
> messages, whereas before I'd get 3 in a row, about 1 second apart.

I think those messages are produced by the audio driver.  Its 
debugging output is exasperatingly limited.

Hmmm.  I guess the best thing would be to collect a usbmon trace.  
That at least will give me some idea about what's going on just before
and just after the problem occurs.  There are instructions in
Documentation/usb/usbmon.txt.

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: usb/serial/io_ti.c broken on BE systems

2014-02-26 Thread Johan Hovold
On Tue, Feb 25, 2014 at 03:55:07PM +, Ludovic wrote:
> Johan Hovold  writes:
> > 
> > Care to try the patch below?
> > 
> > This driver could use some cleaning up so I might rework the patch
> > somewhat, but let's find the bugs first.
> > 
> > Thanks,
> > Johan
> > 
> 
> Hi,
> 
> At 1st the driver detected the USB key and set-up the serial ports. But when
> trying to write I got a kernel panic on the router.

Are you able to get a stack trace?

> I finally found that it seems to work properly with 'debug=0', and I also
> added the patch below.

Hmm. The patch below is not correct, though (more below).

I assume you're still using an old kernel as the debug module parameter
doesn't exist anymore. Can you reproduce this on a recent kernel?

> So I need:
> 1- to find what cause the panic on my router with debug=1
> 2- to test the patch on a LE system.
> 
> Thanks for you time,

You're welcome.

>Ludovic.
> 
> --- io_ti.c.ok2002  2014-02-24 21:54:46.0 +0100
> +++ io_ti.c 2014-02-24 21:56:33.0 +0100
> @@ -2408,8 +2408,8 @@
> dbg("bUartMode:   %d", config->bUartMode);
>  
> /* move the word values into big endian mode */
> -   cpu_to_be16s(&config->wFlags);
> -   cpu_to_be16s(&config->wBaudRate);
> +   swab16s(&config->wFlags);
> +   swab16s(&config->wBaudRate);

This isn't right. The config buffer is transferred as data and only
needs to be byte-swapped on LE-systems (i.e. cpu_to_be16s is correct).

Could you verify that my patch works without those two additional
changes (with debug=0)?

> status = send_cmd(edge_port->port->serial->dev, UMPC_SET_CONFIG,
> (__u8)(UMPM_UART1_PORT + port_number),

Thanks,
Johan
--
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/2] usb: host: xhci-plat: Use module_platform_driver()

2014-02-26 Thread Sarah Sharp
On Fri, Feb 07, 2014 at 02:42:45PM -0800, Greg KH wrote:
> On Fri, Jan 31, 2014 at 02:29:52AM -0200, Fabio Estevam wrote:
> > From: Fabio Estevam 
> > 
> > Using module_platform_driver() can make the code simpler.
> > 
> > Signed-off-by: Fabio Estevam 
> > ---
> > Build-tested only
> 
> No you didn't:
>   drivers/usb/host/xhci-plat.o: In function `usb_xhci_driver_init':
>   xhci-plat.c:(.init.text+0x0): multiple definition of `init_module'
>   drivers/usb/host/xhci.o:xhci.c:(.init.text+0x0): first defined here
>   drivers/usb/host/xhci-plat.o: In function `usb_xhci_driver_exit':
>   xhci-plat.c:(.exit.text+0x0): multiple definition of `cleanup_module'
>   drivers/usb/host/xhci.o:xhci.c:(.exit.text+0x0): first defined here
> 
> Please be more careful...

Fabio, are you going to send a new version that fixes these build
errors?

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: [PATCH v2 1/2] usb: host: xhci-plat: Use module_platform_driver()

2014-02-26 Thread Fabio Estevam
Hi Sarah,

On Wed, Feb 26, 2014 at 2:39 PM, Sarah Sharp
 wrote:

> Fabio, are you going to send a new version that fixes these build
> errors?

Could you please discard this one and just apply 2/2 instead?

Thanks,

Fabio Estevam
--
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: usb audio breaks ohci-pci

2014-02-26 Thread Alan Stern
Dennis, please use Reply-To-All so that your messages get sent to the 
mailing list as well as to me.

On Wed, 26 Feb 2014, Dennis New wrote:

> Btw, I have noticed again that without the debugging patch, I get:
>  12:27:59 kernel: timeout: still 3 active urbs on EP #3
>  12:28:00 kernel: timeout: still 3 active urbs on EP #3
>  12:28:01 kernel: timeout: still 3 active urbs on EP #3
> 
> While with the patch, only one occurence. Any idea why the patch would
> produce this effect? :p

Nope, no idea.  Unless the patch caused a crash or a hang...  but all 
it should have done was add some debugging output to the kernel log.

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: USB kernel oops

2014-02-26 Thread Nicholas Leippe
More information:

Today I was still using it and noticed that I actually had another USB keyboard 
attached. (Since this is a wonky dell whose bios doesn't work with the Kinesis 
USB keyboard I had a generic USB keyboard plugged in also.)

That keyboard was unresponsive. Very soon after attempting to use that 
keyboard, my Kinesis USB keyboard also stopped responding.
The mouse was still responding.

lsusb hangs in D, and doesn't produce any output to dmesg.

dmesg has: (this is the same as the previous OOPs, I've added the surrounding 
USB output lines in case they help)

[  909.918507] usb 1-1.4: USB disconnect, device number 5
[  910.118476] usb 1-1.4: new low-speed USB device number 7 using ehci-pci
[  910.218494] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input18
[  910.218618] hid-generic 0003:1A2C:0002.0006: input: USB HID v1.10 Keyboard 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input0
[  910.220954] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.1/input/input19
[  910.221014] hid-generic 0003:1A2C:0002.0007: input: USB HID v1.10 Device 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input1
[ 1605.274576] usb 1-1.4: USB disconnect, device number 7
[ 1605.477007] usb 1-1.4: new low-speed USB device number 8 using ehci-pci
[ 1605.577477] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input20
[ 1605.577543] hid-generic 0003:1A2C:0002.0008: input: USB HID v1.10 Keyboard 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input0
[ 1605.580125] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.1/input/input21
[ 1605.580219] hid-generic 0003:1A2C:0002.0009: input: USB HID v1.10 Device 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input1
[ 1606.299002] usb 1-1.4: USB disconnect, device number 8
[ 1606.774686] usb 1-1.4: new low-speed USB device number 9 using ehci-pci
[ 1606.988696] usb 1-1.4: new low-speed USB device number 10 using ehci-pci
[ 1607.088419] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input22
[ 1607.088527] hid-generic 0003:1A2C:0002.000A: input: USB HID v1.10 Keyboard 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input0
[ 1607.090950] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.1/input/input23
[ 1607.091069] hid-generic 0003:1A2C:0002.000B: input: USB HID v1.10 Device 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input1
[ 1607.579586] usb 1-1.4: USB disconnect, device number 10
[ 1607.780075] usb 1-1.4: new low-speed USB device number 11 using ehci-pci
[ 1607.880753] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input24
[ 1607.880805] hid-generic 0003:1A2C:0002.000C: input: USB HID v1.10 Keyboard 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input0
[ 1607.883399] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.1/input/input25
[ 1607.883475] hid-generic 0003:1A2C:0002.000D: input: USB HID v1.10 Device 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input1
[ 4514.756902] usb 1-1.4: USB disconnect, device number 11
[ 4515.508463] usb 1-1.4: new low-speed USB device number 12 using ehci-pci
[ 4515.973646] usb 1-1.4: device not accepting address 12, error -32
[ 4516.172901] usb 1-1.4: new low-speed USB device number 14 using ehci-pci
[ 4516.273115] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input26
[ 4516.273241] hid-generic 0003:1A2C:0002.000E: input: USB HID v1.10 Keyboard 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input0
[ 4516.275778] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.1/input/input27
[ 4516.275842] hid-generic 0003:1A2C:0002.000F: input: USB HID v1.10 Device 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input1
[ 7660.634615] usb 1-1.4: USB disconnect, device number 14
[ 7660.913555] usb 1-1.4: new low-speed USB device number 15 using ehci-pci
[ 7661.378666] usb 1-1.4: device not accepting address 15, error -32
[ 7661.577815] usb 1-1.4: new low-speed USB device number 17 using ehci-pci
[ 7661.677145] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input28
[ 7661.677264] hid-generic 0003:1A2C:0002.0010: input: USB HID v1.10 Keyboard 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input0
[ 7661.679602] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.1/input/input29
[ 7661.679689] hid-generic 0003:1A2C:0002.0011: input: USB HID v1.10 Device 
[USB USB Keykoard] on usb-:00:1a.0-1.4/input1
[ 7663.195802] usb 1-1.4: USB disconnect, device number 17
[ 7663.628916] usb 1-1.4: new low-speed USB device number 19 using ehci-pci
[ 7663.728806] input: USB USB Keykoard as 
/devices/pci:00/:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input30
[ 7663.728875] hid-generic 0003:1A2C:0002.0012: input: USB HID v1.10 Keyboard 
[US

Re: [PATCH v5 06/16] usb: defer suspension of superspeed port while peer is powered

2014-02-26 Thread Dan Williams
On Wed, 2014-02-26 at 10:49 -0500, Alan Stern wrote:
> On Tue, 25 Feb 2014, Dan Williams wrote:
> 
> > > Look, we guarantee that the peer relation is dropped when either of the 
> > > devices is unregistered.  Therefore there's no need to take a reference 
> > > to the peer device.
> > 
> > Ugh, yes.  Reference counts alone don't save us from this scenario:
> > 
> > CPU1CPU2
> > mutex_lock(peer_lock)
> > unlink_peers(portA, portC)
> > mutex_unlock(peer_lock)
> > mutex_lock(peer_lock)
> > device_unregister(portA)
> > link_peers(portB, portA)
> > mutex_unlock(peer_lock)
> > 
> > > This will cause a problem only if something else goes wrong.  That's
> > > why I suggested, in patch 2, that when a peering error is detected, you
> > > print out the erroneous pointer rather than assuming it points to a
> > > valid port structure.
> > 
> > ...but even with the invalid port flag portA can theoretically still be
> > a stale pointer.
> 
> I don't see how.

When CPU2 takes the lock it will certainly be after hubA->disconnected
has been set, but I don't see what prevents de-referencing the hubA
pointer from crashing.  Continuing the above example:

CPU1CPU2
mutex_lock(peer_lock)
unlink_peers(portA, portC)
mutex_unlock(peer_lock)
mutex_lock(peer_lock)
device_unregister(portA)
hubA = to_usb_hub(portA)
kref_put(hubA)
free(hubA)
if (!hubA->disconnected) /* crash */
link_peers(portB, portA)
mutex_unlock(peer_lock)

I think this needs to be solved by portB not being able to lookup portA
in the first place.  Which I believe is addressed by wider synchronizing
usb_hub_create_port_device() vs setting hub->disconnected (as you
mention below).

> 
> > > This is also why I suggested that you close the race in 
> > > usb_hub_remove_port_device: to make sure that the guarantee really is 
> > > enforced.
> > 
> > You proposed a flag on the port_dev once it goes invalid.  It seems to
> > me the flag to check if a port is valid is parent_hub->disconnected.
> 
> Good suggestion.
> 
> > However, in the case above, I believe find_port_by_location() and
> > find_default_peer() need to prevent the "link_peers(portB, portA)"
> > event.  When these routines walk down the tree they should be taking
> > usb_lock_device() to make sure they are not racing with disconnect
> > operations.
> > 
> > Locking while traversing the list and otherwise checking for
> > hub->disconnected closes the race.  We can't solve the race at the
> > port_dev level alone.  Agreed?
> 
> No.  We already have the port_lock mutex; nothing else is needed.  
> Simply make link_peers fail if either of the hub->disconnected flags is
> set.  Then the scenario shown above can't happen, because link_peers
> running on CPU2 will see that portA is stale.
> 
> However, it might be a good idea for usb_hub_create_port_device to hold 
> the port_lock while doing
> 
>   hub->ports[port1 - 1] = port_dev;
> 
> And perhaps this line should be moved down to just before the 
> device_register call.  In fact, maybe that call should occur inside the 
> scope of the mutex.

Something along these lines, yes.  Would need to change the tier
mismatch code to assume the peer_lock is already held, but that may
work.  I'll take a look.

> 
> There may be other places where we have to be more careful about
> assuming that hub->ports[port1 - 1] is non-NULL.  Even though checking
> the disconnected flag will prevent races with port destruction, there
> could be races with port creation.

*nod*


--
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: HSIC on imx6

2014-02-26 Thread Christian Gmeiner
Hi Rolf

2014-02-26 15:48 GMT+01:00 Rolf Evers-Fischer :
> Hi Christian,
>
>> Peter Chen  hat am 26. Februar 2014 um 03:05
>> geschrieben:
>>
>>
>>
>> > >> >> patches. I am working some days on this topic but without much
>> > >> >> success and I am running out of time :/
>> > >> >>
>> > >> >
>> > >> > Will keep you posted.
>> > >> >
>> > >>
>> > >> Hope you soon will find some time.
>> > >>
>> > >
>> > > Since some chipidea code needs to change before adapting HSIC support,
>> > > I submit a temp version at my git, it is not suitable for upstream,
>> > > but can let the hsic work.
>> > >
>> > > github.com/hzpeterchen/linux-usb.git
>> > > branch: fsl-hsic-support
>> > >
>> >
>> > I did backport those patches to 3.13.4 but it does not work. Here you can
>> > find a log http://dpaste.com/hold/1656798/ generated by this dts:
>> >
>> > &usdhc3 {
>> > pinctrl-names = "default";
>> > pinctrl-0 = <&pinctrl_usdhc3_1>;
>> > bus-width = <8>;
>> > non-removable;
>> > status = "okay";
>> > };
>> >
>> > &usbh1 {
>> > status = "okay";
>> > };
>> >
>> > &usbh2 {
>> > pinctrl-names = "idle", "active";
>> > pinctrl-0 = <&pinctrl_usbh2_1>;
>> > pinctrl-1 = <&pinctrl_usbh2_2>;
>> > osc-clkgate-delay = <0x3>;
>> > status = "okay";
>> > };
>> >
>> > &usbh3 {
>> > pinctrl-names = "idle", "active";
>> > pinctrl-0 = <&pinctrl_usbh3_1>;
>> > pinctrl-1 = <&pinctrl_usbh3_2>;
>> > osc-clkgate-delay = <0x3>;
>> > status = "okay";
>> > };
>> >
>> > &fec {
>> > pinctrl-names = "default";
>> > pinctrl-0 = <&pinctrl_enet_4>;
>> > phy-mode = "mii";
>> > status = "okay";
>> > };
>> >
>> > greets
>> > --
>> > Christian Gmeiner, MSc
>> >
>> > https://soundcloud.com/christian-gmeiner
>> >
>>
>> try to cherry-pick
>> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=73de93440186c595a031046e266f6caaac106aa0
>>
> were you successful with this patch?
> If not: Have you already tried to disable the "&fec"? I'm asking, because I 
> saw
> this comment from Peter Chen:
> "Since hsic has pin conflict with ethernet, we disable ethernet at this 
> dts...".
>
> I can also offer you to upload a bootlog of our IMX6Q board with HSIC working 
> on
> Bus 003, if it helps.

That would be awesome. Could you enable regulator and chipidea debug
in the kernel. Would it be a problem to get the used
kernel configuration too?

>
> By the way: I was using the patch from
> http://www.spinics.net/lists/arm-kernel/msg303287.html for my board in 
> previous
> kernel versions.
>

That did not work - maybe its a hw problem in the design.

thanks
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: xhci: Use IS_ENABLED() macro

2014-02-26 Thread Fabio Estevam
From: Fabio Estevam 

Using the IS_ENABLED() macro can make the code shorter and easier to read.

Signed-off-by: Fabio Estevam 
---
 drivers/usb/host/xhci.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 58ed9d0..326a0d4 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1737,8 +1737,7 @@ static inline int xhci_register_pci(void) { return 0; }
 static inline void xhci_unregister_pci(void) {}
 #endif
 
-#if defined(CONFIG_USB_XHCI_PLATFORM) \
-   || defined(CONFIG_USB_XHCI_PLATFORM_MODULE)
+#if IS_ENABLED(CONFIG_USB_XHCI_PLATFORM)
 int xhci_register_plat(void);
 void xhci_unregister_plat(void);
 #else
-- 
1.8.1.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


[RFCv3 4/4] xhci: rework command timeout and cancellation,

2014-02-26 Thread Mathias Nyman
Use one timer to control command timeout.

start/kick the timer every time a command is completed and a
new command is waiting, or a new command is added to a empty list.

If the timer runs out, then tag the current command as "aborted", and
start the xhci command abortion process.

Previously each function that submitted a command had its own timer.
If that command timed out, a new command structure for
the command was created and it was put on a cancel_cmd_list list,
then a pci write to abort the command ring was issued.

when the ring was aborted, it checked if the current command
was the one to be canceled, later when the ring was stopped the
driver got ownership of the TRBs in the command ring,
compared then to the TRBs in the cancel_cmd_list,
and turned them into No-ops.

Now, instead, at timeout we tag the status of the command in the
command queue to be aborted, and start the ring abortion.
Ring abortion stops the command ring and gives control of the commands to us.
All the aborted commands are now turned into No-ops.

This allows us to remove the entire cancel_cmd_list code.

The functions waiting for a command to finish no longer have their own timeouts.
They will wait either until the command completes normally,
or until the whole command abortion is done.

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-hub.c  |  11 +-
 drivers/usb/host/xhci-mem.c  |  15 +-
 drivers/usb/host/xhci-ring.c | 335 +--
 drivers/usb/host/xhci.c  |  78 --
 drivers/usb/host/xhci.h  |   8 +-
 5 files changed, 138 insertions(+), 309 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 0a57d95..8350fd9 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -271,7 +271,6 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int 
slot_id, int suspend)
struct xhci_virt_device *virt_dev;
struct xhci_command *cmd;
unsigned long flags;
-   int timeleft;
int ret;
int i;
 
@@ -304,12 +303,10 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int 
slot_id, int suspend)
spin_unlock_irqrestore(&xhci->lock, flags);
 
/* Wait for last stop endpoint command to finish */
-   timeleft = wait_for_completion_interruptible_timeout(
-   cmd->completion,
-   XHCI_CMD_DEFAULT_TIMEOUT);
-   if (timeleft <= 0) {
-   xhci_warn(xhci, "%s while waiting for stop endpoint command\n",
-   timeleft == 0 ? "Timeout" : "Signal");
+   wait_for_completion(cmd->completion);
+
+   if (cmd->status == COMP_CMD_ABORT || cmd->status == COMP_CMD_STOP) {
+   xhci_warn(xhci, "Timeout while waiting for stop endpoint 
command\n");
ret = -ETIME;
}
xhci_free_command(xhci, cmd);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 81c2469..6baaaf5 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1692,7 +1692,6 @@ void xhci_free_command(struct xhci_hcd *xhci,
 void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
struct device   *dev = xhci_to_hcd(xhci)->self.controller;
-   struct xhci_cd  *cur_cd, *next_cd;
struct xhci_command *cur_cmd, *next_cmd;
int size;
int i, j, num_ports;
@@ -1712,15 +1711,13 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
if (xhci->lpm_command)
xhci_free_command(xhci, xhci->lpm_command);
xhci->cmd_ring_reserved_trbs = 0;
+
+   del_timer_sync(&xhci->cmd_timer);
+
if (xhci->cmd_ring)
xhci_ring_free(xhci, xhci->cmd_ring);
xhci->cmd_ring = NULL;
xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed command ring");
-   list_for_each_entry_safe(cur_cd, next_cd,
-   &xhci->cancel_cmd_list, cancel_cmd_list) {
-   list_del(&cur_cd->cancel_cmd_list);
-   kfree(cur_cd);
-   }
 
list_for_each_entry_safe(cur_cmd, next_cmd,
&xhci->cmd_list, cmd_list) {
@@ -2228,7 +2225,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
u32 page_size, temp;
int i;
 
-   INIT_LIST_HEAD(&xhci->cancel_cmd_list);
INIT_LIST_HEAD(&xhci->cmd_list);
 
page_size = readl(&xhci->op_regs->page_size);
@@ -2414,6 +2410,11 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
"Wrote ERST address to ir_set 0.");
xhci_print_ir_set(xhci, 0);
 
+   /* init command timeout timer */
+   init_timer(&xhci->cmd_timer);
+   xhci->cmd_timer.data = (unsigned long) xhci;
+   xhci->cmd_timer.function = xhci_handle_command_timeout;
+
/*
 * XXX: Might need to set the Interrupter Moderation Register to
 * something other than the default (~1ms minimum between interrupts).
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xh

[RFCv3 2/4] xhci: Add a global command queue

2014-02-26 Thread Mathias Nyman
Create a list to store command structures, add a structure to it every time
a command is submitted, and remove it from the list once we get a
command completion event matching the command.

Callers that wait for completion will free their command structures themselves.
The other command structures are freed in the command completion event handler.

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-mem.c  |  8 
 drivers/usb/host/xhci-ring.c | 21 +
 drivers/usb/host/xhci.c  |  2 --
 drivers/usb/host/xhci.h  |  1 +
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index bce4391..9df2aa0 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1694,6 +1694,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
struct device   *dev = xhci_to_hcd(xhci)->self.controller;
struct xhci_cd  *cur_cd, *next_cd;
+   struct xhci_command *cur_cmd, *next_cmd;
int size;
int i, j, num_ports;
 
@@ -1722,6 +1723,12 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
kfree(cur_cd);
}
 
+   list_for_each_entry_safe(cur_cmd, next_cmd,
+   &xhci->cmd_list, cmd_list) {
+   list_del(&cur_cmd->cmd_list);
+   kfree(cur_cmd);
+   }
+
for (i = 1; i < MAX_HC_SLOTS; ++i)
xhci_free_virt_device(xhci, i);
 
@@ -2223,6 +2230,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
int i;
 
INIT_LIST_HEAD(&xhci->cancel_cmd_list);
+   INIT_LIST_HEAD(&xhci->cmd_list);
 
page_size = readl(&xhci->op_regs->page_size);
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index fa34c9b..39d3ff7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1496,6 +1496,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
dma_addr_t cmd_dequeue_dma;
u32 cmd_comp_code;
union xhci_trb *cmd_trb;
+   struct xhci_command *cmd;
u32 cmd_type;
 
cmd_dma = le64_to_cpu(event->cmd_trb);
@@ -1513,6 +1514,13 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
return;
}
 
+   cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
+
+   if (cmd->command_trb != xhci->cmd_ring->dequeue) {
+   xhci_err(xhci,
+"Command completion event does not match command\n");
+   return;
+   }
trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
 
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
@@ -1582,6 +1590,12 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
xhci->error_bitmask |= 1 << 6;
break;
}
+
+   list_del(&cmd->cmd_list);
+
+   if (!cmd->completion)
+   kfree(cmd);
+
inc_deq(xhci, xhci->cmd_ring);
 }
 
@@ -3982,10 +3996,9 @@ static int queue_command(struct xhci_hcd *xhci, struct 
xhci_command *cmd,
"unfailable commands failed.\n");
return ret;
}
-   if (cmd->completion)
-   cmd->command_trb = xhci->cmd_ring->enqueue;
-   else
-   kfree(cmd);
+
+   cmd->command_trb = xhci->cmd_ring->enqueue;
+   list_add_tail(&cmd->cmd_list, &xhci->cmd_list);
 
queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
field4 | xhci->cmd_ring->cycle_state);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8bf2aa3..97de328 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3704,7 +3704,6 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device 
*udev)
timeleft == 0 ? "Timeout" : "Signal");
/* cancel the enable slot request */
ret = xhci_cancel_cmd(xhci, NULL, command->command_trb);
-   kfree(command);
return ret;
}
 
@@ -3860,7 +3859,6 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct 
usb_device *udev,
  timeleft == 0 ? "Timeout" : "Signal", act);
/* cancel the address device command */
ret = xhci_cancel_cmd(xhci, NULL, command->command_trb);
-   kfree(command);
if (ret < 0)
return ret;
return -ETIME;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 083ff11..7052b8c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1483,6 +1483,7 @@ struct xhci_hcd {
 #define CMD_RING_STATE_ABORTED (1 << 1)
 #define CMD_RING_STATE_STOPPED (1 << 2)
struct list_headcancel_cmd_list;
+   struct list_headcmd_list;
unsigned intcmd_ring_reserv

[RFCv3 3/4] xhci: Use completion and status in global command queue

2014-02-26 Thread Mathias Nyman
Remove the per-device command list and handle_cmd_in_cmd_wait_list()
and use the completion and status variables found in the
command structure in the global command list.

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-hub.c  | 11 ---
 drivers/usb/host/xhci-mem.c  |  1 -
 drivers/usb/host/xhci-ring.c | 78 +++-
 drivers/usb/host/xhci.c  | 16 ++---
 drivers/usb/host/xhci.h  |  3 --
 5 files changed, 14 insertions(+), 95 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index fb0f936..0a57d95 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -299,7 +299,6 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int 
slot_id, int suspend)
 suspend);
}
}
-   list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list);
xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend);
xhci_ring_cmd_db(xhci);
spin_unlock_irqrestore(&xhci->lock, flags);
@@ -311,18 +310,8 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int 
slot_id, int suspend)
if (timeleft <= 0) {
xhci_warn(xhci, "%s while waiting for stop endpoint command\n",
timeleft == 0 ? "Timeout" : "Signal");
-   spin_lock_irqsave(&xhci->lock, flags);
-   /* The timeout might have raced with the event ring handler, so
-* only delete from the list if the item isn't poisoned.
-*/
-   if (cmd->cmd_list.next != LIST_POISON1)
-   list_del(&cmd->cmd_list);
-   spin_unlock_irqrestore(&xhci->lock, flags);
ret = -ETIME;
-   goto command_cleanup;
}
-
-command_cleanup:
xhci_free_command(xhci, cmd);
return ret;
 }
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 9df2aa0..81c2469 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -919,7 +919,6 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int 
slot_id,
dev->num_rings_cached = 0;
 
init_completion(&dev->cmd_completion);
-   INIT_LIST_HEAD(&dev->cmd_list);
dev->udev = udev;
 
/* Point to output device context in dcbaa. */
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 39d3ff7..12bf467 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -69,10 +69,6 @@
 #include "xhci.h"
 #include "xhci-trace.h"
 
-static int handle_cmd_in_cmd_wait_list(struct xhci_hcd *xhci,
-   struct xhci_virt_device *virt_dev,
-   struct xhci_event_cmd *event);
-
 /*
  * Returns zero if the TRB isn't in this segment, otherwise it returns the DMA
  * address of the TRB.
@@ -755,7 +751,6 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, 
int slot_id,
union xhci_trb *trb, struct xhci_event_cmd *event)
 {
unsigned int ep_index;
-   struct xhci_virt_device *virt_dev;
struct xhci_ring *ep_ring;
struct xhci_virt_ep *ep;
struct list_head *entry;
@@ -765,11 +760,7 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, 
int slot_id,
struct xhci_dequeue_state deq_state;
 
if (unlikely(TRB_TO_SUSPEND_PORT(le32_to_cpu(trb->generic.field[3] {
-   virt_dev = xhci->devs[slot_id];
-   if (virt_dev)
-   handle_cmd_in_cmd_wait_list(xhci, virt_dev,
-   event);
-   else
+   if (!xhci->devs[slot_id])
xhci_warn(xhci, "Stop endpoint command "
"completion for disabled slot %u\n",
slot_id);
@@ -1197,29 +1188,6 @@ static void xhci_complete_cmd_in_cmd_wait_list(struct 
xhci_hcd *xhci,
 }
 
 
-/* Check to see if a command in the device's command queue matches this one.
- * Signal the completion or free the command, and return 1.  Return 0 if the
- * completed command isn't at the head of the command list.
- */
-static int handle_cmd_in_cmd_wait_list(struct xhci_hcd *xhci,
-   struct xhci_virt_device *virt_dev,
-   struct xhci_event_cmd *event)
-{
-   struct xhci_command *command;
-
-   if (list_empty(&virt_dev->cmd_list))
-   return 0;
-
-   command = list_entry(virt_dev->cmd_list.next,
-   struct xhci_command, cmd_list);
-   if (xhci->cmd_ring->dequeue != command->command_trb)
-   return 0;
-
-   xhci_complete_cmd_in_cmd_wait_list(xhci, command,
-   GET_COMP_CODE(le32_to_cpu(event->status)));
-   return 1;
-}
-
 /*
  * Finding the command trb need to be cancelled and modifying it to
  * NO OP command. And if the command is in device's command wait
@@ -1371,7 +1339,6 @@ static void xhci_handle_cmd_enable_slo

[RFCv3 1/4] xhci: Use command structures when queuing commands on the command ring

2014-02-26 Thread Mathias Nyman
To create a global command queue we require that each command put on the
command ring is submitted with a command structure.

Functions that queue commands and wait for completion need to allocate a command
before submitting it, and free it once completed. The following command queuing
functions need to be modified.

xhci_configure_endpoint()
xhci_address_device()
xhci_queue_slot_control()
xhci_queue_stop_endpoint()
xhci_queue_new_dequeue_state()
xhci_queue_reset_ep()
xhci_configure_endpoint()

xhci_configure_endpoint() could already be called with a command structure,
and only xhci_check_maxpacket and xhci_check_bandwidth did not do so. These
are changed and a command structure is now required. This change also simplifies
the configure endpoint command completion handling and the "goto 
bandwidth_change"
handling code can be removed.

In some cases the command queuing function is called in interrupt context.
These commands needs to be allocated atomically, and they can't wait for
completion. These commands will in this patch be freed directly after queuing,
but freeing will be moved to the command completion event handler in a later
patch once we get the global command queue up.(Just so that we won't leak
memory in the middle of the patch set)

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-hub.c  |  21 +++--
 drivers/usb/host/xhci-ring.c | 105 ---
 drivers/usb/host/xhci.c  | 194 ---
 drivers/usb/host/xhci.h  |  31 +++
 4 files changed, 214 insertions(+), 137 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 9992fbf..fb0f936 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -20,7 +20,8 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include 
+
+#include 
 #include 
 
 #include "xhci.h"
@@ -284,12 +285,22 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int 
slot_id, int suspend)
 
spin_lock_irqsave(&xhci->lock, flags);
for (i = LAST_EP_INDEX; i > 0; i--) {
-   if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue)
-   xhci_queue_stop_endpoint(xhci, slot_id, i, suspend);
+   if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) {
+   struct xhci_command *command;
+   command = xhci_alloc_command(xhci, false, false,
+GFP_NOIO);
+   if (!command) {
+   spin_unlock_irqrestore(&xhci->lock, flags);
+   xhci_free_command(xhci, cmd);
+   return -ENOMEM;
+
+   }
+   xhci_queue_stop_endpoint(xhci, command, slot_id, i,
+suspend);
+   }
}
-   cmd->command_trb = xhci_find_next_enqueue(xhci->cmd_ring);
list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list);
-   xhci_queue_stop_endpoint(xhci, slot_id, 0, suspend);
+   xhci_queue_stop_endpoint(xhci, cmd, slot_id, 0, suspend);
xhci_ring_cmd_db(xhci);
spin_unlock_irqrestore(&xhci->lock, flags);
 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 0ed64eb..fa34c9b 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -123,16 +123,6 @@ static int enqueue_is_link_trb(struct xhci_ring *ring)
return TRB_TYPE_LINK_LE32(link->control);
 }
 
-union xhci_trb *xhci_find_next_enqueue(struct xhci_ring *ring)
-{
-   /* Enqueue pointer can be left pointing to the link TRB,
-* we must handle that
-*/
-   if (TRB_TYPE_LINK_LE32(ring->enqueue->link.control))
-   return ring->enq_seg->next->trbs;
-   return ring->enqueue;
-}
-
 /* Updates trb to point to the next TRB in the ring, and updates seg if the 
next
  * TRB is in a new segment.  This does not skip over link TRBs, and it does not
  * effect the ring dequeue or enqueue pointers.
@@ -674,12 +664,14 @@ static void td_to_noop(struct xhci_hcd *xhci, struct 
xhci_ring *ep_ring,
}
 }
 
-static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id,
+static int queue_set_tr_deq(struct xhci_hcd *xhci,
+   struct xhci_command *cmd, int slot_id,
unsigned int ep_index, unsigned int stream_id,
struct xhci_segment *deq_seg,
union xhci_trb *deq_ptr, u32 cycle_state);
 
 void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
+   struct xhci_command *cmd,
unsigned int slot_id, unsigned int ep_index,
unsigned int stream_id,
struct xhci_dequeue_state *deq_state)
@@ -694,7 +686,7 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
deq_state->new_deq_ptr,
(unsigned long 
long)xhci_trb_virt_to_dma(deq_s

[RFCv3 0/4] xhci: re-work command queue management

2014-02-26 Thread Mathias Nyman
changes since v2:

squash first 7 patches together that all just created commands 
and avoid some nasty mid-patch series memory leaking  

changes since v1: 

Fixing smatch warnings and errors.
Check for null return from alloc_command, release lock in error path and
don't dereference possible null pointer in error path.

release lock in xhci_stop_dev() error path.

This is the third attempt to re-work and solve the issues in xhci command
queue management that Sarah has described earlier:

Right now, the command management in the xHCI driver is rather ad-hock.  
Different parts of the driver all submit commands, including interrupt 
handling routines, functions called from the USB core (with or without the
bus bandwidth mutex held).
Some times they need to wait for the command to complete, and sometimes 
they just issue the command and don't care about the result of the command.

The places that wait on a command all time the command for five seconds,
and then attempt to cancel the command.  
Unfortunately, that means if several commands are issued at once, and one of
them times out, all the commands timeout, even though the host hasn't gotten
a chance to service them yet.

This is apparent with some devices that take a long time to respond to the 
Set Address command during device enumeration (when the device is plugged in).
If a driver for a different device attempts to change alternate interface
settings at the same time (causing a Configure Endpoint command to be issued),
both commands timeout.

Instead of having each command timeout after five seconds, the driver should
wait indefinitely in an uninterruptible sleep on the command completion.  
A global command queue manager should time whatever command is currently
running, and cancel that command after five seconds.

If the commands were in a list, like TDs currently are, it may be easier to keep
track of where the command ring dequeue pointer is, and avoid racing with 
events.
We may need to have parts of the driver that issue commands without waiting on
them still put the commands in the command list.

The Implementation:
---

First step is to create a list of the commands submitted to the command queue.
To accomplish this each command is required to be submitted with a properly
filled command structure containing completion, status variable and a pointer to
the command TRB that will be used.

The first patch is all about creating these command structures and
submitting them when we queue commands.
The command structures are allocated on the fly, the commands that are submitted
in interrupt context are allocated with GFP_ATOMIC.

Next, the global command queue is introduced. Commands structures are added to 
the queue when trb's are queued, and removed when the command completes. 
Also switch to use the status variable and completion in the command struct.

A new timer handles command timeout, the timer is kicked every time when a 
command finishes and there's a new command waiting in the queue, or when a new
command is submitted to an _empty_ command queue.
Timer is deleted when the the last command on the queue finishes (empty queue)

The old cancel_cmd_list is removed. 
When the timer expires we simply tag the current command as "ABORTED" and start
the ring abortion process. Functions waiting for an aborted command to finish 
are
called after the command abortion is completed.

Mathias Nyman (4):
  xhci: Use command structures when queuing commands on the command ring
  xhci: Add a global command queue
  xhci: Use completion and status in global command queue
  xhci: rework command timeout and cancellation,

 drivers/usb/host/xhci-hub.c  |  43 ++--
 drivers/usb/host/xhci-mem.c  |  22 +-
 drivers/usb/host/xhci-ring.c | 529 ++-
 drivers/usb/host/xhci.c  | 264 +++--
 drivers/usb/host/xhci.h  |  43 ++--
 5 files changed, 373 insertions(+), 528 deletions(-)

-- 
1.8.1.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


EHCI threadirq

2014-02-26 Thread Stefani Seibold
Hi Alan,

i just checked the current linux git tree and the 3.13 kernel.

In both i miss your fix for the thread irq support in the ehci hcd which
you had promised.

- Stefani

--
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: EHCI threadirq

2014-02-26 Thread Alan Stern
On Wed, 26 Feb 2014, Stefani Seibold wrote:

> Hi Alan,
> 
> i just checked the current linux git tree and the 3.13 kernel.
> 
> In both i miss your fix for the thread irq support in the ehci hcd which
> you had promised.

The patch has not been merged yet.  It was submitted here:

http://marc.info/?l=linux-usb&m=139280201613876&w=2

Since it fixes a bug, it probably will appear in 3.14 and an upcoming 
3.13.stable release.

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: EHCI threadirq

2014-02-26 Thread Greg KH
On Wed, Feb 26, 2014 at 03:40:52PM -0500, Alan Stern wrote:
> On Wed, 26 Feb 2014, Stefani Seibold wrote:
> 
> > Hi Alan,
> > 
> > i just checked the current linux git tree and the 3.13 kernel.
> > 
> > In both i miss your fix for the thread irq support in the ehci hcd which
> > you had promised.
> 
> The patch has not been merged yet.  It was submitted here:
> 
>   http://marc.info/?l=linux-usb&m=139280201613876&w=2
> 
> Since it fixes a bug, it probably will appear in 3.14 and an upcoming 
> 3.13.stable release.

Yes, I should get to it later today, been catching up on other stuff
first...

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 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread David Miller
From: Bjørn Mork 
Date: Wed, 26 Feb 2014 13:13:12 +0100

> fre...@asix.com.tw writes:
> 
>> From: Freddy Xin 
>>
>> Add VID:DID for Lenovo OneLinkDock Gigabit LAN
> 
> This is the same patch Keith Packard sent, but with a slighly different
> description.  I take that as another proof that we should not attempt to
> describe devices in these drivers.  Describe the driver instead.

Are you saying that this patch needs to be implemented differently?
--
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 v8 06/14] CLK: TI: OMAP3: Get rid of unused USB Host dummy clocks

2014-02-26 Thread Mike Turquette
Quoting Roger Quadros (2014-02-25 01:32:19)
> Hi Mike,
> 
> On 02/25/2014 10:43 AM, Mike Turquette wrote:
> > Quoting Roger Quadros (2014-02-20 03:40:01)
> >> The OMAP USB Host MFD driver no longer expects these non-existing
> >> clocks from the OMAP3 platform, so get rid of them.
> > 
> > Looks good to me.
> 
> Is it OK if I squash this patch with [1] and take it through the MFD tree?
> Keeping them separate could break functionality if both don't go in together.

Acked-by: Mike Turquette 

> 
> [1] - http://article.gmane.org/gmane.linux.ports.arm.kernel/303266
> 
> cheers,
> -roger
> 
> > 
> >>
> >> CC: Tero Kristo 
> >> CC: Mike Turquette 
> >> Signed-off-by: Roger Quadros 
> >> ---
> >>  arch/arm/mach-omap2/cclock3xxx_data.c | 4 
> >>  drivers/clk/ti/clk-3xxx.c | 4 
> >>  2 files changed, 8 deletions(-)
> >>
> >> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c 
> >> b/arch/arm/mach-omap2/cclock3xxx_data.c
> >> index 3b05aea..4299a55 100644
> >> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
> >> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
> >> @@ -3495,10 +3495,6 @@ static struct omap_clk omap3xxx_clks[] = {
> >> CLK(NULL,   "dss_tv_fck",   &dss_tv_fck),
> >> CLK(NULL,   "dss_96m_fck",  &dss_96m_fck),
> >> CLK(NULL,   "dss2_alwon_fck",   &dss2_alwon_fck),
> >> -   CLK(NULL,   "utmi_p1_gfclk",&dummy_ck),
> >> -   CLK(NULL,   "utmi_p2_gfclk",&dummy_ck),
> >> -   CLK(NULL,   "xclk60mhsp1_ck",   &dummy_ck),
> >> -   CLK(NULL,   "xclk60mhsp2_ck",   &dummy_ck),
> >> CLK(NULL,   "init_60m_fclk",&dummy_ck),
> >> CLK(NULL,   "gpt1_fck", &gpt1_fck),
> >> CLK(NULL,   "aes2_ick", &aes2_ick),
> >> diff --git a/drivers/clk/ti/clk-3xxx.c b/drivers/clk/ti/clk-3xxx.c
> >> index d323023..0d1750a 100644
> >> --- a/drivers/clk/ti/clk-3xxx.c
> >> +++ b/drivers/clk/ti/clk-3xxx.c
> >> @@ -130,10 +130,6 @@ static struct ti_dt_clk omap3xxx_clks[] = {
> >> DT_CLK(NULL, "dss_tv_fck", "dss_tv_fck"),
> >> DT_CLK(NULL, "dss_96m_fck", "dss_96m_fck"),
> >> DT_CLK(NULL, "dss2_alwon_fck", "dss2_alwon_fck"),
> >> -   DT_CLK(NULL, "utmi_p1_gfclk", "dummy_ck"),
> >> -   DT_CLK(NULL, "utmi_p2_gfclk", "dummy_ck"),
> >> -   DT_CLK(NULL, "xclk60mhsp1_ck", "dummy_ck"),
> >> -   DT_CLK(NULL, "xclk60mhsp2_ck", "dummy_ck"),
> >> DT_CLK(NULL, "init_60m_fclk", "dummy_ck"),
> >> DT_CLK(NULL, "gpt1_fck", "gpt1_fck"),
> >> DT_CLK(NULL, "aes2_ick", "aes2_ick"),
> >> -- 
> >> 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 v5 06/16] usb: defer suspension of superspeed port while peer is powered

2014-02-26 Thread Alan Stern
On Wed, 26 Feb 2014, Dan Williams wrote:

> When CPU2 takes the lock it will certainly be after hubA->disconnected
> has been set, but I don't see what prevents de-referencing the hubA
> pointer from crashing.  Continuing the above example:
> 
> CPU1CPU2
> mutex_lock(peer_lock)
> unlink_peers(portA, portC)
> mutex_unlock(peer_lock)
> mutex_lock(peer_lock)
> device_unregister(portA)
> hubA = to_usb_hub(portA)
> kref_put(hubA)
> free(hubA)
> if (!hubA->disconnected) /* crash */
> link_peers(portB, portA)
> mutex_unlock(peer_lock)
> 
> I think this needs to be solved by portB not being able to lookup portA
> in the first place.  Which I believe is addressed by wider synchronizing
> usb_hub_create_port_device() vs setting hub->disconnected (as you
> mention below).

Right.  The routines that follow the hub and port pointers will need to
be very careful about this.  Each step is subject to a race: going from
port to hdev = port->child, to hub = usb_hub_to_struct_hub(hdev), to
port = hub->ports[port1 - 1].

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 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread Bjørn Mork
David Miller  writes:

> From: Bjørn Mork 
> Date: Wed, 26 Feb 2014 13:13:12 +0100
>
>> fre...@asix.com.tw writes:
>> 
>>> From: Freddy Xin 
>>>
>>> Add VID:DID for Lenovo OneLinkDock Gigabit LAN
>> 
>> This is the same patch Keith Packard sent, but with a slighly different
>> description.  I take that as another proof that we should not attempt to
>> describe devices in these drivers.  Describe the driver instead.
>
> Are you saying that this patch needs to be implemented differently?

No, sorry for being confusing.  The patch is fine.  But Keith sent it
first...

The other comment is more of a personal opinion on the driver style.  In
any case, it's something that can be fixed up later. If at all.


Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread David Miller
From: Bjørn Mork 
Date: Wed, 26 Feb 2014 22:14:10 +0100

> David Miller  writes:
> 
>> From: Bjørn Mork 
>> Date: Wed, 26 Feb 2014 13:13:12 +0100
>>
>>> fre...@asix.com.tw writes:
>>> 
 From: Freddy Xin 

 Add VID:DID for Lenovo OneLinkDock Gigabit LAN
>>> 
>>> This is the same patch Keith Packard sent, but with a slighly different
>>> description.  I take that as another proof that we should not attempt to
>>> describe devices in these drivers.  Describe the driver instead.
>>
>> Are you saying that this patch needs to be implemented differently?
> 
> No, sorry for being confusing.  The patch is fine.  But Keith sent it
> first...

Did I apply Keith's patch?  If not, should I apply it instead?
--
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 v5 04/16] usb: find internal hub tier mismatch via acpi

2014-02-26 Thread Alan Stern
On Fri, 21 Feb 2014, Dan Williams wrote:

> ACPI identifies peer ports by setting their 'group_token' and
> 'group_position' _PLD data to the same value.  If a platform has tier
> mismatch [1] , ACPI can override the default (USB3 defined) peer port
> association for internal hubs.  External hubs follow the default peer
> association scheme.
> 
> Location data is cached as an opaque cookie in usb_port_location data.
> 
> Note that we only consider the group_token and group_position attributes
> from the _PLD data as ACPI specifies that group_token is a unique
> identifier.
> 
> The bulk of the implementation is recursively fixing up peer
> associations once we detect tier mismatch.  Due to the way acpi data is
> associated to a usb_port device (via a callback triggered by

Is the callback _triggered_ (i.e., asynchronously) by device_register,
or is it simply _invoked_ (synchronously) by device_register?

> device_register()) we do not discover tier mismatch until after the port
> has been registered.

I've been thinking about this.  Maybe it isn't a problem, because now
you don't set up the peer matching until after the port has been 
registered.  All you have to do is allow the ACPI data to prevent a 
default match if the location data values don't agree.

That would simplify this patch an awful lot.

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: Card reader not working properly with xHCI

2014-02-26 Thread Richard Schütz

Am 26.02.2014 16:31, schrieb Alan Stern:

On Tue, 25 Feb 2014, Sarah Sharp wrote:


On Tue, Feb 25, 2014 at 11:22:57PM +0100, Richard Sch�tz wrote:

Hi everybody!

I am experiencing a problem with my USB card reader and xHCI. Simply
using dd to write an image to a SD card results in USB resets after
a few seconds. Reading with dd or using cp after creating a
filesystem on the card also triggers the issue but usually not as
quick as writing to it with dd. All in all it is unusable. Sometimes
these resets also happen immediately after connecting the reader.
With EHCI everything just works fine.


Did it ever work under xHCI?  If so, which kernel version did it work
on?


Unfortunately I am not quite sure, if I ever used that reader with xHCI 
on this machine. If so, it was some time ago and I do not remember the 
kernel version anymore. At least with longterm kernel 3.10.32 it is 
broken, too.



I'm Ccing the usb-storage developers, in case the usbmon trace provides
some insight.


It doesn't.


usb 1-2: reset high-speed USB device number 19 using xhci_hcd
xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled
ep 8801b6837600
xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled
ep 8801b6837640
sd 22:0:0:0: [sdb] Media Changed
sd 22:0:0:0: [sdb]
Result: hostbyte=0x00 driverbyte=0x08
sd 22:0:0:0: [sdb]
Sense Key : 0x6 [current]
Info fld=0x0
sd 22:0:0:0: [sdb]
ASC=0x28 ASCQ=0x0
sd 22:0:0:0: [sdb] CDB:
cdb[0]=0x28: 28 00 00 00 1d 20 00 00 08 00
end_request: I/O error, dev sdb, sector 7456
sd 22:0:0:0: [sdb] No Caching mode page found
sd 22:0:0:0: [sdb] Assuming drive cache: write through
sd 22:0:0:0: [sdb] No Caching mode page found
sd 22:0:0:0: [sdb] Assuming drive cache: write through
  sdb: unknown partition table


It might help you to turn on CONFIG_USB_STORAGE_DEBUG, to see which SCSI
command is failing.


CONFIG_USB_STORAGE_DEBUG is a lot less helpful for examining SCSI
commands than a usbmon trace, because it includes lots of extraneous
information.  It's meant more for debugging the usb-storage driver
itself than for debugging device problems.

The command was an ordinary READ, same as a bunch of others that worked
fine.  And the failure occurred in the command phase, not the data
phase: The host doesn't receive an ACK response to the CBW packet.


Can you blacklist the usb-storage driver, and get the lsusb output when
the device is plugged into a USB 3.0 port?  I'd like to see the
SuperSpeed Endpoint Companion Descriptor, to see what the Link PM U1/U2
timeout values are.


Being a card reader, it is almost certainly a USB-2 device.  This is
backed up by the fact that it ran at high speed, not SuperSpeed, when
connected to an xHCI controller.  Therefore it doesn't have U1/U2
timeouts.


The card reader itself is not a SuperSpeed device, but a Hi-Speed one 
that I am trying to use on a SuperSpeed port. Sorry for not pointing out 
that clearly enough.


--
Regards,
Richard Schütz
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread Bjørn Mork
David Miller  writes:
> From: Bjørn Mork 
>
>> No, sorry for being confusing.  The patch is fine.  But Keith sent it
>> first...
>
> Did I apply Keith's patch?

No, you didn't.  And when I went looking at it now, I see why: It was
posted to linux-usb and linux-kernel but not to netdev:
http://www.kernelhub.org/?msg=420289&p=2

> If not, should I apply it instead?

The patches are identical except for the author and a minor difference
in the device description string. 

It doesn't matter to me which patch you apply, and I absolutely don't
think it's my place to tell you which patches to apply or not :-)



Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 04/16] usb: find internal hub tier mismatch via acpi

2014-02-26 Thread Dan Williams
On Wed, Feb 26, 2014 at 1:35 PM, Alan Stern  wrote:
> On Fri, 21 Feb 2014, Dan Williams wrote:
>
>> ACPI identifies peer ports by setting their 'group_token' and
>> 'group_position' _PLD data to the same value.  If a platform has tier
>> mismatch [1] , ACPI can override the default (USB3 defined) peer port
>> association for internal hubs.  External hubs follow the default peer
>> association scheme.
>>
>> Location data is cached as an opaque cookie in usb_port_location data.
>>
>> Note that we only consider the group_token and group_position attributes
>> from the _PLD data as ACPI specifies that group_token is a unique
>> identifier.
>>
>> The bulk of the implementation is recursively fixing up peer
>> associations once we detect tier mismatch.  Due to the way acpi data is
>> associated to a usb_port device (via a callback triggered by
>
> Is the callback _triggered_ (i.e., asynchronously) by device_register,
> or is it simply _invoked_ (synchronously) by device_register?

Synchronously, we complete the acpi notification/registration before
device_register() for the port returns.

>> device_register()) we do not discover tier mismatch until after the port
>> has been registered.
>
> I've been thinking about this.  Maybe it isn't a problem, because now
> you don't set up the peer matching until after the port has been
> registered.  All you have to do is allow the ACPI data to prevent a
> default match if the location data values don't agree.
>
> That would simplify this patch an awful lot.

Hm, interesting.  It relies on the fact that the firmware must
identify both peers if it has location data for one, but I think that
is a reasonable constraint.

If a port has acpi data, don't permit a default matching... sounds good to me!
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread David Miller
From: Bjørn Mork 
Date: Wed, 26 Feb 2014 22:44:18 +0100

> David Miller  writes:
>> From: Bjørn Mork 
>>
>>> No, sorry for being confusing.  The patch is fine.  But Keith sent it
>>> first...
>>
>> Did I apply Keith's patch?
> 
> No, you didn't.  And when I went looking at it now, I see why: It was
> posted to linux-usb and linux-kernel but not to netdev:
> http://www.kernelhub.org/?msg=420289&p=2
> 
>> If not, should I apply it instead?
> 
> The patches are identical except for the author and a minor difference
> in the device description string. 
> 
> It doesn't matter to me which patch you apply, and I absolutely don't
> think it's my place to tell you which patches to apply or not :-)

Fair enough, I'll apply this one, thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 04/16] usb: find internal hub tier mismatch via acpi

2014-02-26 Thread Alan Stern
On Wed, 26 Feb 2014, Dan Williams wrote:

> > I've been thinking about this.  Maybe it isn't a problem, because now
> > you don't set up the peer matching until after the port has been
> > registered.  All you have to do is allow the ACPI data to prevent a
> > default match if the location data values don't agree.
> >
> > That would simplify this patch an awful lot.
> 
> Hm, interesting.  It relies on the fact that the firmware must
> identify both peers if it has location data for one, but I think that
> is a reasonable constraint.

If the firmware doesn't have location data for both peers in a
non-default matching (which presumably means there's a tier mismatch)  
then there's no way for us to match them up correctly anyhow.

> If a port has acpi data, don't permit a default matching... sounds good to me!

If the port's ACPI data agrees with the default matching, there's no 
issue.  But if they disagree, don't accept the default match.  That way 
you never have to correct a mistaken match.

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 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread Keith Packard
Bjørn Mork  writes:

> No, you didn't.  And when I went looking at it now, I see why: It was
> posted to linux-usb and linux-kernel but not to netdev:
> http://www.kernelhub.org/?msg=420289&p=2

I looked in MAINTAINERS and found linux-usb as a suitable address for
drivers/net/usb/. I'm sorry I didn't think to look for drivers/net/ as
well.

> It doesn't matter to me which patch you apply, and I absolutely don't
> think it's my place to tell you which patches to apply or not :-)

Doesn't matter to me either; just want to make sure the device works.

-- 
keith.pack...@intel.com


pgpgidpXnEGvR.pgp
Description: PGP signature


Re: [PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread Joe Perches
On Wed, 2014-02-26 at 14:23 -0800, Keith Packard wrote:
> Bjørn Mork  writes:
> 
> > No, you didn't.  And when I went looking at it now, I see why: It was
> > posted to linux-usb and linux-kernel but not to netdev:
> > http://www.kernelhub.org/?msg=420289&p=2
> 
> I looked in MAINTAINERS and found linux-usb as a suitable address for
> drivers/net/usb/. I'm sorry I didn't think to look for drivers/net/ as
> well.

Hi Keith.

You could use scripts/get_maintainer.pl next time.

$ ./scripts/get_maintainer.pl -f drivers/net/usb/ax88179_178a.c
"David S. Miller"  (commit_signer:13/13=100%)
Freddy Xin  
(commit_signer:4/13=31%,authored:4/13=31%,added_lines:1473/1504=98%,removed_lines:9/43=21%)
Eric Dumazet  
(commit_signer:3/13=23%,authored:2/13=15%,removed_lines:22/43=51%)
Ming Lei  
(commit_signer:3/13=23%,authored:3/13=23%,removed_lines:8/43=19%)
David Chang  (commit_signer:2/13=15%,authored:2/13=15%)
Emil Goode  (authored:1/13=8%)
linux-usb@vger.kernel.org (open list:USB NETWORKING DR...)
net...@vger.kernel.org (open list:NETWORKING DRIVERS)
linux-ker...@vger.kernel.org (open list)


Maybe there should be a MAINTAINERS entry added too?


--
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 04/11] usb: dwc3: gadget: implement dwc3_gadget_get_link_state

2014-02-26 Thread Paul Zimmerman
Hi Felipe,

Can you drop the part that checks the DCNRD bit, please? I made a
mistake when I originally submitted this. It is not necessary to check
the DCNRD bit every time before reading the link state, it should only
be checked the first time after coming out of hibernation. Doing it
every time is unnecessary overhead, and can even cause problems with a
hibernation-enabled controller.

So for now maybe just drop the entire patch, and instead call
DWC3_DSTS_USBLNKST() directly?

-- 
Paul

-Original Message-
From: Felipe Balbi [mailto:ba...@ti.com] 
Sent: Tuesday, February 25, 2014 11:41 AM
To: Linux USB Mailing List
Cc: Paul Zimmerman; Paul Zimmerman; Felipe Balbi
Subject: [PATCH 04/11] usb: dwc3: gadget: implement dwc3_gadget_get_link_state

From: Paul Zimmerman 

This function will be used during hibernation to get
the current link state. It will be needed at least
for Hibernation support.

Signed-off-by: Paul Zimmerman 
Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/gadget.c | 36 
 drivers/usb/dwc3/gadget.h |  1 +
 2 files changed, 37 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 31b13c2..ff10161 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -68,6 +68,42 @@ int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)
 }
 
 /**
+ * dwc3_gadget_get_lik_state - Gets current state of USB Link
+ * @dwc: pointer to our context structure
+ *
+ * Caller should take care of locking. This function will
+ * return the link state on success (>= 0) or -ETIMEDOUT.
+ */
+int dwc3_gadget_get_link_state(struct dwc3 *dwc)
+{
+   u32 reg;
+
+   reg = dwc3_readl(dwc->regs, DWC3_DSTS);
+
+   /*
+* Wait until device controller is ready.
+* (This only applied to 1.94a and later
+* RTL releases)
+*/
+   if (dwc->revision >= DWC3_REVISION_194A) {
+   int retries = 1;
+
+   do {
+   reg = dwc3_readl(dwc->regs, DWC3_DSTS);
+   if (!(reg & DWC3_DSTS_DCNRD))
+   break;
+
+   if (!retries)
+   return -ETIMEDOUT;
+
+   udelay(5);
+   } while (--retries);
+   }
+
+   return DWC3_DSTS_USBLNKST(reg);
+}
+
+/**
  * dwc3_gadget_set_link_state - Sets USB Link to a particular State
  * @dwc: pointer to our context structure
  * @state: the state to put link into
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index febe1aa..d101244 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -86,6 +86,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct 
dwc3_request *req,
int status);
 
 int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode);
+int dwc3_gadget_get_link_state(struct dwc3 *dwc);
 int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state);
 
 void dwc3_ep0_interrupt(struct dwc3 *dwc,
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] AX88179_178A: Add VID:DID for Lenovo OneLinkDock Gigabit LAN

2014-02-26 Thread Keith Packard
Joe Perches  writes:

> You could use scripts/get_maintainer.pl next time.

Yeah, good point. I always forget about that tool when I'm hacking
outside my normal areas.

-- 
keith.pack...@intel.com


pgpdEhsqthszc.pgp
Description: PGP signature


[PATCH] phy-rcar-gen2-usb: add device tree support

2014-02-26 Thread Sergei Shtylyov
Add support of the device tree probing for the Renesas R-Car generation 2 SoCs
documenting the device tree binding as necessary.

Signed-off-by: Sergei Shtylyov 

---
This patch is against the 'next' branch of Felipe Balbi's 'usb.git' repo.

 Documentation/devicetree/bindings/usb/rcar-gen2-phy.txt |   29 +++
 drivers/usb/phy/phy-rcar-gen2-usb.c |   64 ++--
 2 files changed, 85 insertions(+), 8 deletions(-)

Index: usb/Documentation/devicetree/bindings/usb/rcar-gen2-phy.txt
===
--- /dev/null
+++ usb/Documentation/devicetree/bindings/usb/rcar-gen2-phy.txt
@@ -0,0 +1,29 @@
+* Renesas R-Car generation 2 USB PHY
+
+This file provides information on what the device node for the R-Car generation
+2 USB PHY contains.
+
+Required properties:
+- compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC.
+ "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
+- reg: offset and length of the register block.
+- clocks: clock phandle and specifier pair.
+- clock-names: string, clock input name, must be "usbhs".
+
+Optional properties:
+- renesas,channel0-pci: boolean, specify when USB channel 0 should be connected
+   to PCI EHCI/OHCI; otherwise, it will be connected to the
+   USBHS controller.
+- renesas,channel2-pci: boolean, specify when USB channel 2 should be connected
+   to PCI EHCI/OHCI; otherwise, it will be connected to the
+   USBSS controller (xHCI).
+
+Example (Lager board):
+
+   usb-phy@e6590100 {
+   compatible = "renesas,usb-phy-r8a7790";
+   reg = <0 0xe6590100 0 0x100>;
+   clocks = <&mstp7_clks R8A7790_CLK_HSUSB>;
+   clock-names = "usbhs";
+   renesas,channel2-pci;
+   };
Index: usb/drivers/usb/phy/phy-rcar-gen2-usb.c
===
--- usb.orig/drivers/usb/phy/phy-rcar-gen2-usb.c
+++ usb/drivers/usb/phy/phy-rcar-gen2-usb.c
@@ -1,8 +1,8 @@
 /*
  * Renesas R-Car Gen2 USB phy driver
  *
- * Copyright (C) 2013 Renesas Solutions Corp.
- * Copyright (C) 2013 Cogent Embedded, Inc.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Cogent Embedded, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -167,9 +168,41 @@ out:
spin_unlock_irqrestore(&priv->lock, flags);
 }
 
+#ifdef CONFIG_OF
+static struct rcar_gen2_phy_platform_data *
+rcar_gen2_usb_phy_parse_dt(struct device *dev)
+{
+   struct device_node *np = dev->of_node;
+   struct rcar_gen2_phy_platform_data *pdata;
+
+   pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return NULL;
+
+   pdata->chan0_pci = of_property_read_bool(np, "renesas,channel0-pci");
+   pdata->chan2_pci = of_property_read_bool(np, "renesas,channel2-pci");
+
+   return pdata;
+}
+
+static const struct of_device_id rcar_gen2_usb_phy_match_table[] = {
+   { .compatible = "renesas,usb-phy-r8a7790" },
+   { .compatible = "renesas,usb-phy-r8a7791" },
+   { }
+};
+MODULE_DEVICE_TABLE(of, rcar_gen2_usb_phy_match_table);
+#else
+static inline struct rcar_gen2_phy_platform_data *
+rcar_gen2_usb_phy_parse_dt(struct device *dev)
+{
+   return NULL;
+}
+#endif
+
 static int rcar_gen2_usb_phy_probe(struct platform_device *pdev)
 {
struct device *dev = &pdev->dev;
+   struct device_node *np = dev->of_node;
struct rcar_gen2_phy_platform_data *pdata;
struct rcar_gen2_usb_phy_priv *priv;
struct resource *res;
@@ -177,13 +210,19 @@ static int rcar_gen2_usb_phy_probe(struc
struct clk *clk;
int retval;
 
-   pdata = dev_get_platdata(dev);
+   if (np)
+   pdata = rcar_gen2_usb_phy_parse_dt(dev);
+   else
+   pdata = dev_get_platdata(dev);
if (!pdata) {
dev_err(dev, "No platform data\n");
return -EINVAL;
}
 
-   clk = devm_clk_get(dev, "usbhs");
+   if (np)
+   clk = of_clk_get_by_name(np, "usbhs");
+   else
+   clk = clk_get(dev, "usbhs");
if (IS_ERR(clk)) {
dev_err(dev, "Can't get the clock\n");
return PTR_ERR(clk);
@@ -191,13 +230,16 @@ static int rcar_gen2_usb_phy_probe(struc
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   if (IS_ERR(base)) {
+   retval = PTR_ERR(base);
+   goto error;
+   }
 
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
   

[PATCH v3 00/13] Add USB OTG HNP and SRP support on Chipidea usb driver

2014-02-26 Thread Li Jun
From: b47624 

This patchset adds USB OTG HNP and SRP support on chipidea usb driver,
existing OTG port role swtich function by ID pin status kept unchanged,
based on that, if select CONFIG_USB_OTG_FSM, OTG HNP and SRP will be
supported.

Reference to:
"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification 
July 27, 2012
Revision 2.0 version 1.1a"

How to test HNP&SRP with 2 Freescale i.MX6Q sabre SD boards:
1. Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
   (e.g. g_mass_storage).

2. Connect 2 boards with usb cable with one end is micro A plug, the other end
   is micro B plug.

3. The A device with micro A plug inserted should enumrate B device.

4. Role switch.
   On B device:
   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req

   if HNP polling patchset is not applied, also need:
   On A device:
   echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req

   B device should take host role and enumrate A device(peripheral).

5. A device switch back to host.
   On B device:
   echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req

   A device should switch back to host and enumrate B device.

6. Remove B device and insert again in 10 seconds, A device should
   enumrate B device again.

7. Remove B device and insert again after 10 seconds, A device should
   NOT enumrate B device.

   if A device wants to use bus:
   On A device:
   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req

   if B device wants to use bus:
   On B device:
   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req

8. A device power down the bus.
   On A device:
   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop

9. B device do data pulse for SRP.
   On B device:
   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req

   A device usb bus should be resumed and enumrate B device.

Changes since v2:
- Add ABI document for sysfs input files description:
  Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
- Add a debug file for show some USB registers value.
- Split host driver change to be 2 patches, one for otg_port number init;
  the other one for vbus control change.
- Export interrupt enable and status read functions from udc driver.
- Only enable AVV irq in otg fsm init.
- Remove duplicated USBSTS bits definitions.
- typo correction.
- Add HowTo demo role switch with 2 Freescale i.MX6Q sabre SD boards
  in cover letter.

Changes since v1:
- Move out HNP polling patch from this series, which will be a seperated 
patchset
  followed this one
- Change fsm timers global variables to be a structure embeded in ci_hdrc,
  to make multiple OTG instances can exist in one system
- Change some otg fsm functions to be static
- Re-split timer init patch to avoid a later patch changing a previous one
  in the same series
- Change timer structure memory allocation to be devm_kzalloc
- Update some format alignment and spelling errors

Li Jun (13):
  usb: phy-fsm: update OTG HNP state transition conditions according to
OTG and EH 2.0 spec.
  usb: chipidea: usb OTG fsm initialization.
  usb: chipidea: host: vbus control change for OTG HNP.
  usb: chipidea: host: init otg port number.
  usb: chipidea: udc: driver update for OTG HNP.
  usb: chipidea: export interrupt enable and status register read
functions.
  usb: chipidea: add OTG fsm operation functions implemenation.
  usb: chipidea: OTG fsm timers initialization.
  usb: chipidea: OTG HNP and SRP fsm implementation.
  usb: chipidea: add sys inputs for OTG fsm input.
  usb: chipidea: debug: add debug file for OTG variables show.
  usb: chipidea: debug: add debug file for controller registers dump.
  Documentation: ABI: usb: chipidea USB OTG HNP sysfs interface
description.

 .../ABI/testing/sysfs-platform-chipidea-usb-otg|   55 ++
 drivers/usb/chipidea/Makefile  |1 +
 drivers/usb/chipidea/bits.h|   12 +
 drivers/usb/chipidea/ci.h  |6 +
 drivers/usb/chipidea/core.c|   30 +-
 drivers/usb/chipidea/debug.c   |  133 +++
 drivers/usb/chipidea/host.c|   13 +-
 drivers/usb/chipidea/host.h|9 +
 drivers/usb/chipidea/otg.c |   17 +-
 drivers/usb/chipidea/otg_fsm.c |  872 
 drivers/usb/chipidea/otg_fsm.h |  141 
 drivers/usb/chipidea/udc.c |   31 +-
 drivers/usb/phy/phy-fsm-usb.c  |9 +-
 13 files changed, 1297 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
 create mode 100644 drivers/usb/chipidea/otg_fsm.c
 create mode 100644 drivers/usb/chipidea/otg_fsm.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
Mor

[PATCH v3 01/13] usb: phy-fsm: update OTG HNP state transition conditions according to OTG and EH 2.0 spec.

2014-02-26 Thread Li Jun
According to:"On-The-Go and Embedded Host Supplement to the USB Revision 2.0
Specification July 27, 2012 Revision 2.0 version 1.1a"
- From a_host to a_wait_bcon if !b_conn
- Add transition from a_host to a_wait_vfall if id state is high or a_bus_drop
- From a_wait_vfall to a_idle if a_wait_vfall_tmout

Signed-off-by: Li Jun 
---
 drivers/usb/phy/phy-fsm-usb.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c
index 7aa314e..c47e5a6 100644
--- a/drivers/usb/phy/phy-fsm-usb.c
+++ b/drivers/usb/phy/phy-fsm-usb.c
@@ -317,10 +317,12 @@ int otg_statemachine(struct otg_fsm *fsm)
otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL);
break;
case OTG_STATE_A_HOST:
-   if ((!fsm->a_bus_req || fsm->a_suspend_req_inf) &&
+   if (fsm->id || fsm->a_bus_drop)
+   otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL);
+   else if ((!fsm->a_bus_req || fsm->a_suspend_req_inf) &&
fsm->otg->host->b_hnp_enable)
otg_set_state(fsm, OTG_STATE_A_SUSPEND);
-   else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop)
+   else if (!fsm->b_conn)
otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
else if (!fsm->a_vbus_vld)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
@@ -346,8 +348,7 @@ int otg_statemachine(struct otg_fsm *fsm)
otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
break;
case OTG_STATE_A_WAIT_VFALL:
-   if (fsm->a_wait_vfall_tmout || fsm->id || fsm->a_bus_req ||
-   (!fsm->a_sess_vld && !fsm->b_conn))
+   if (fsm->a_wait_vfall_tmout)
otg_set_state(fsm, OTG_STATE_A_IDLE);
break;
case OTG_STATE_A_VBUS_ERR:
-- 
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 06/13] usb: chipidea: export interrupt enable and status register read functions.

2014-02-26 Thread Li Jun
This patch move usb interrupt enable and status register read functions
from udc driver to core driver to use them in all ci drivers.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/ci.h   |4 
 drivers/usb/chipidea/core.c |   20 
 drivers/usb/chipidea/udc.c  |   20 
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 064770b..db6bf30 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -320,6 +320,10 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, 
enum ci_hw_regs reg,
return (val & mask) >> __ffs(mask);
 }
 
+u32 hw_read_intr_enable(struct ci_hdrc *ci);
+
+u32 hw_read_intr_status(struct ci_hdrc *ci);
+
 int hw_device_reset(struct ci_hdrc *ci, u32 mode);
 
 int hw_port_test_set(struct ci_hdrc *ci, u8 mode);
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ca6831c..b2e01a2 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -140,6 +140,26 @@ static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
 }
 
 /**
+ * hw_read_intr_enable: returns interrupt enable register
+ *
+ * This function returns register data
+ */
+u32 hw_read_intr_enable(struct ci_hdrc *ci)
+{
+   return hw_read(ci, OP_USBINTR, ~0);
+}
+
+/**
+ * hw_read_intr_status: returns interrupt status register
+ *
+ * This function returns register data
+ */
+u32 hw_read_intr_status(struct ci_hdrc *ci)
+{
+   return hw_read(ci, OP_USBSTS, ~0);
+}
+
+/**
  * hw_port_test_set: writes port test mode (execute without interruption)
  * @mode: new value
  *
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 602bbf3..534fa90 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -243,26 +243,6 @@ static int hw_port_is_high_speed(struct ci_hdrc *ci)
 }
 
 /**
- * hw_read_intr_enable: returns interrupt enable register
- *
- * This function returns register data
- */
-static u32 hw_read_intr_enable(struct ci_hdrc *ci)
-{
-   return hw_read(ci, OP_USBINTR, ~0);
-}
-
-/**
- * hw_read_intr_status: returns interrupt status register
- *
- * This function returns register data
- */
-static u32 hw_read_intr_status(struct ci_hdrc *ci)
-{
-   return hw_read(ci, OP_USBSTS, ~0);
-}
-
-/**
  * hw_test_and_clear_complete: test & clear complete status (execute without
  * interruption)
  * @n: endpoint number
-- 
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 03/13] usb: chipidea: host: vbus control change for OTG HNP.

2014-02-26 Thread Li Jun
Leave vbus on/off hanlded by OTG fsm if in OTG mode.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/host.c |6 +++---
 drivers/usb/chipidea/host.h |9 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index a8ac6c1..4b609bc 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -67,7 +67,7 @@ static int host_start(struct ci_hdrc *ci)
ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
ehci->imx28_write_fix = ci->imx28_write_fix;
 
-   if (ci->platdata->reg_vbus) {
+   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci)) {
ret = regulator_enable(ci->platdata->reg_vbus);
if (ret) {
dev_err(ci->dev,
@@ -89,7 +89,7 @@ static int host_start(struct ci_hdrc *ci)
return ret;
 
 disable_reg:
-   if (ci->platdata->reg_vbus)
+   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci))
regulator_disable(ci->platdata->reg_vbus);
 
 put_hcd:
@@ -105,7 +105,7 @@ static void host_stop(struct ci_hdrc *ci)
if (hcd) {
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
-   if (ci->platdata->reg_vbus)
+   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci))
regulator_disable(ci->platdata->reg_vbus);
}
 }
diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h
index 5707bf3..f98d084 100644
--- a/drivers/usb/chipidea/host.h
+++ b/drivers/usb/chipidea/host.h
@@ -6,6 +6,15 @@
 int ci_hdrc_host_init(struct ci_hdrc *ci);
 void ci_hdrc_host_destroy(struct ci_hdrc *ci);
 
+static inline bool ci_host_is_otg(struct ci_hdrc *ci)
+{
+#ifdef CONFIG_USB_OTG_FSM
+   return (ci->is_otg) && (ci->platdata->dr_mode == USB_DR_MODE_OTG);
+#else
+   return false;
+#endif
+}
+
 #else
 
 static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
-- 
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 05/13] usb: chipidea: udc: driver update for OTG HNP.

2014-02-26 Thread Li Jun
Add b_hnp_enable request handling and enable gadget->is_otg

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/udc.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index fe30dcc..602bbf3 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ci.h"
@@ -1098,6 +1099,14 @@ __acquires(ci->lock)
default:
break;
}
+   break;
+   case USB_DEVICE_B_HNP_ENABLE:
+   if (gadget_is_otg(&ci->gadget)) {
+   ci->gadget.b_hnp_enable = 1;
+   err = isr_setup_status_phase(
+   ci);
+   }
+   break;
default:
goto delegate;
}
@@ -1765,7 +1774,7 @@ static int udc_start(struct ci_hdrc *ci)
ci->gadget.ops  = &usb_gadget_ops;
ci->gadget.speed= USB_SPEED_UNKNOWN;
ci->gadget.max_speed= USB_SPEED_HIGH;
-   ci->gadget.is_otg   = 0;
+   ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
ci->gadget.name = ci->platdata->name;
 
INIT_LIST_HEAD(&ci->gadget.ep_list);
-- 
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 04/13] usb: chipidea: host: init otg port number.

2014-02-26 Thread Li Jun
Init otg_port number of otg capable host to be 1 at host start.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/host.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 4b609bc..5ec8ccd 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -80,8 +80,13 @@ static int host_start(struct ci_hdrc *ci)
ret = usb_add_hcd(hcd, 0, 0);
if (ret)
goto disable_reg;
-   else
+   else {
ci->hcd = hcd;
+   if (ci_host_is_otg(ci)) {
+   ci->transceiver->otg->host = &hcd->self;
+   ci->transceiver->otg->host->otg_port = 1;
+   }
+   }
 
if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
-- 
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 02/13] usb: chipidea: usb OTG fsm initialization.

2014-02-26 Thread Li Jun
This patch adds OTG fsm related initialization when do otg init,
add a seperate file for OTG fsm related utilities.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/Makefile  |1 +
 drivers/usb/chipidea/ci.h  |1 +
 drivers/usb/chipidea/otg.c |7 +
 drivers/usb/chipidea/otg_fsm.c |   68 
 drivers/usb/chipidea/otg_fsm.h |   29 +
 5 files changed, 106 insertions(+)

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 7345d21..5e1ecc5 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -6,6 +6,7 @@ ci_hdrc-y   := core.o otg.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)   += debug.o
+ci_hdrc-$(CONFIG_USB_OTG_FSM)  += otg_fsm.o
 
 # Glue/Bridge layers go here
 
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index e206406..064770b 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -174,6 +174,7 @@ struct ci_hdrc {
struct ci_role_driver   *roles[CI_ROLE_END];
enum ci_rolerole;
boolis_otg;
+   struct otg_fsm  *fsm;
struct work_struct  work;
struct workqueue_struct *wq;
 
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 39bd7ec..cbf0167 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -22,6 +22,7 @@
 #include "ci.h"
 #include "bits.h"
 #include "otg.h"
+#include "otg_fsm.h"
 
 /**
  * ci_otg_role - pick role based on ID pin state
@@ -95,6 +96,12 @@ static void ci_otg_work(struct work_struct *work)
  */
 int ci_hdrc_otg_init(struct ci_hdrc *ci)
 {
+   int retval = 0;
+
+   retval = ci_hdrc_otg_fsm_init(ci);
+   if (retval)
+   return retval;
+
INIT_WORK(&ci->work, ci_otg_work);
ci->wq = create_singlethread_workqueue("ci_otg");
if (!ci->wq) {
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
new file mode 100644
index 000..904381e
--- /dev/null
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -0,0 +1,68 @@
+/*
+ * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ *
+ * Author: Jun Li
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This file mainly handles OTG fsm, it includes OTG fsm operations
+ * for HNP and SRP.
+ */
+
+#include 
+#include 
+#include 
+
+#include "ci.h"
+#include "bits.h"
+#include "otg.h"
+#include "otg_fsm.h"
+
+int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
+{
+   if (ci->platdata->dr_mode != USB_DR_MODE_OTG)
+   return 0;
+
+   ci->transceiver->otg = devm_kzalloc(ci->dev,
+   sizeof(struct usb_otg), GFP_KERNEL);
+   if (!ci->transceiver->otg) {
+   dev_err(ci->dev,
+   "Failed to allocate usb_otg structure for ci hdrc otg!\n");
+   return -ENOMEM;
+   }
+
+   ci->fsm = devm_kzalloc(ci->dev,
+   sizeof(struct otg_fsm), GFP_KERNEL);
+   if (!ci->fsm) {
+   dev_err(ci->dev,
+   "Failed to allocate otg_fsm structure for ci hdrc otg!\n");
+   return -ENOMEM;
+   }
+
+   ci->fsm->power_up = 1;
+   ci->fsm->id = hw_read(ci, OP_OTGSC, OTGSC_ID);
+   ci->fsm->otg = ci->transceiver->otg;
+   ci->fsm->otg->phy = ci->transceiver;
+   ci->fsm->otg->gadget = &ci->gadget;
+   ci->transceiver->state = OTG_STATE_UNDEFINED;
+
+   mutex_init(&ci->fsm->lock);
+
+   /* Enable A vbus valid irq */
+   ci_enable_otg_interrupt(ci, OTGSC_AVVIE);
+
+   if (ci->fsm->id) {
+   ci->fsm->b_ssend_srp =
+   hw_read(ci, OP_OTGSC, OTGSC_BSV) ? 0 : 1;
+   ci->fsm->b_sess_vld =
+   hw_read(ci, OP_OTGSC, OTGSC_BSV) ? 1 : 0;
+   }
+
+   return 0;
+}
diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h
new file mode 100644
index 000..bf20a85
--- /dev/null
+++ b/drivers/usb/chipidea/otg_fsm.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ *
+ * Author: Jun Li
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
+#define __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
+
+#include 
+
+#ifdef CONFIG_USB_OTG_FSM
+
+int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);
+
+#else
+
+static inline int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
+{
+   return 0;
+}
+
+#endif
+
+#endif /* __DRIV

[PATCH v3 07/13] usb: chipidea: add OTG fsm operation functions implemenation.

2014-02-26 Thread Li Jun
Add OTG HNP and SRP operation functions implementation:
- charge vbus
- drive vbus
- connection signaling
- drive sof
- start data pulse
- add fsm timer
- delete fsm timer
- start host
- start gadget

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/bits.h|   11 ++
 drivers/usb/chipidea/ci.h  |1 +
 drivers/usb/chipidea/otg_fsm.c |  231 
 drivers/usb/chipidea/otg_fsm.h |   23 
 4 files changed, 266 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 83d06c1..c42eb35 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -44,9 +44,14 @@
 #define DEVICEADDR_USBADR (0x7FUL << 25)
 
 /* PORTSC */
+#define PORTSC_CCSBIT(0)
+#define PORTSC_CSCBIT(1)
+#define PORTSC_PECBIT(3)
+#define PORTSC_OCCBIT(5)
 #define PORTSC_FPRBIT(6)
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
+#define PORTSC_PP BIT(12)
 #define PORTSC_PTC(0x0FUL << 16)
 #define PORTSC_PHCD(d)   ((d) ? BIT(22) : BIT(23))
 /* PTS and PTW for non lpm version only */
@@ -56,6 +61,9 @@
 #define PORTSC_PTWBIT(28)
 #define PORTSC_STSBIT(29)
 
+#define PORTSC_W1C_BITS\
+   (PORTSC_CSC | PORTSC_PEC | PORTSC_OCC)
+
 /* DEVLC */
 #define DEVLC_PFSCBIT(23)
 #define DEVLC_PSPD(0x03UL << 25)
@@ -71,7 +79,10 @@
 #define PTS_HSIC  4
 
 /* OTGSC */
+#define OTGSC_VD BIT(0)
+#define OTGSC_VC BIT(1)
 #define OTGSC_IDPU   BIT(5)
+#define OTGSC_HADP   BIT(6)
 #define OTGSC_ID BIT(8)
 #define OTGSC_AVVBIT(9)
 #define OTGSC_ASVBIT(10)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index db6bf30..171b1d2 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -175,6 +175,7 @@ struct ci_hdrc {
enum ci_rolerole;
boolis_otg;
struct otg_fsm  *fsm;
+   struct ci_otg_fsm_timer_list*fsm_timer;
struct work_struct  work;
struct workqueue_struct *wq;
 
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 904381e..aa24466 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -18,12 +18,242 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ci.h"
 #include "bits.h"
 #include "otg.h"
 #include "otg_fsm.h"
 
+/* Add timer to active timer list */
+static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
+{
+   struct ci_otg_fsm_timer *tmp_timer;
+   struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
+   struct list_head *active_timers = &ci->fsm_timer->active_timers;
+
+   if (t >= NUM_CI_OTG_FSM_TIMERS)
+   return;
+
+   /*
+* Check if the timer is already in the active list,
+* if so update timer count
+*/
+   list_for_each_entry(tmp_timer, active_timers, list)
+   if (tmp_timer == timer) {
+   timer->count = timer->expires;
+   return;
+   }
+
+   timer->count = timer->expires;
+   list_add_tail(&timer->list, active_timers);
+
+   /* Enable 1ms irq */
+   if (!(hw_read(ci, OP_OTGSC, OTGSC_1MSIE)))
+   ci_enable_otg_interrupt(ci, OTGSC_1MSIE);
+}
+
+/* Remove timer from active timer list */
+static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
+{
+   struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
+   struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
+   struct list_head *active_timers = &ci->fsm_timer->active_timers;
+   int flag = 0;
+
+   if (t >= NUM_CI_OTG_FSM_TIMERS)
+   return;
+
+   list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list)
+   if (tmp_timer == timer) {
+   list_del(&timer->list);
+   flag = 1;
+   }
+
+   /* Disable 1ms irq if there is no any active timer */
+   if ((flag == 1) && list_empty(active_timers))
+   ci_disable_otg_interrupt(ci, OTGSC_1MSIE);
+}
+
+/* -*/
+/* Operations that will be called from OTG Finite State Machine */
+/* -*/
+static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
+{
+   struct ci_hdrc  *ci = container_of(fsm->otg->gadget,
+   struct ci_hdrc, gadget);
+
+   if (t < NUM_OTG_FSM_TIMERS)
+   ci_otg_add_timer(ci, t);
+   return;
+}
+
+static void ci_otg_fsm_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
+{
+   struct ci_hdrc  *

[PATCH v3 13/13] Documentation: ABI: usb: chipidea USB OTG HNP sysfs interface description.

2014-02-26 Thread Li Jun
This patch adds sysfs interface description for chipidea USB OTG role switch
in HNP.

Signed-off-by: Li Jun 
---
 .../ABI/testing/sysfs-platform-chipidea-usb-otg|   55 
 1 file changed, 55 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg 
b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
new file mode 100644
index 000..a05414c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
@@ -0,0 +1,55 @@
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Can be set and read.
+   Set a_bus_req(A-device bus request) input to be 1 if
+   the Application running on the A-device wants to use the bus,
+   and to be 0 when the Application no longer wants to use
+   the bus(or wants to work as peripheral). a_bus_req can also
+   be set to 1 by kernel in response to remote wakeup signaling
+   from the B-device, the A-device should decide to resume the bus.
+
+   Valid values are "1" and "0".
+
+   Reading: returns if the Application running on the A-device
+   is using the bus as host role.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Can be set and read
+   The a_bus_drop(A-device bus drop) input is 1 when the
+   Application running on the A-device wants to power down
+   the bus, and is 0 otherwise, When a_bus_drop is 1, then
+   the a_bus_req shall be 0.
+
+   Valid values are "1" and "0".
+
+   Reading: returns if the bus is off(vbus is turned off).
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_drop
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Can be set and read.
+   The b_bus_req(B-device bus request) input is 1 during the time
+   that the Application running on the B-device wants to use the
+   bus as host, and is 0 when the Application no longer wants to
+   work as host and decides to switch back to be peripheral.
+
+   Valid values are "1" and "0".
+
+   Reading: returns if the Application running on the B device
+   is using the bus as host role.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_clr_err
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Only can be set.
+   The a_clr_err(A-device Vbus error clear) input is used to clear
+   vbus error, then A device will power down the bus.
+
+   Valid value is "1"
-- 
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 09/13] usb: chipidea: OTG HNP and SRP fsm implementation.

2014-02-26 Thread Li Jun
USB OTG interrupt handling and fsm transition according to USB OTG
and EH 2.0, update otg timer timeout handlers.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/core.c|   10 ++-
 drivers/usb/chipidea/otg.c |9 +-
 drivers/usb/chipidea/otg_fsm.c |  191 
 drivers/usb/chipidea/otg_fsm.h |   18 
 4 files changed, 225 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index b2e01a2..cbc46c8 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -74,6 +74,7 @@
 #include "host.h"
 #include "debug.h"
 #include "otg.h"
+#include "otg_fsm.h"
 
 /* Controller register map */
 static const u8 ci_regs_nolpm[] = {
@@ -379,8 +380,12 @@ static irqreturn_t ci_irq(int irq, void *data)
irqreturn_t ret = IRQ_NONE;
u32 otgsc = 0;
 
-   if (ci->is_otg)
+   if (ci->is_otg) {
otgsc = hw_read(ci, OP_OTGSC, ~0);
+   ret = ci_otg_fsm_irq(ci);
+   if (ret == IRQ_HANDLED)
+   return ret;
+   }
 
/*
 * Handle id change interrupt, it indicates device/host function
@@ -668,6 +673,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (ret)
goto stop;
 
+   if (ci->is_otg)
+   ci_hdrc_otg_fsm_start(ci);
+
ret = dbg_create_files(ci);
if (!ret)
return 0;
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index cbf0167..4fb33a2 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -11,8 +11,8 @@
  */
 
 /*
- * This file mainly handles otgsc register, it may include OTG operation
- * in the future.
+ * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP
+ * are also included.
  */
 
 #include 
@@ -77,6 +77,11 @@ static void ci_otg_work(struct work_struct *work)
 {
struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
 
+   if (!ci_otg_fsm_work(ci)) {
+   enable_irq(ci->irq);
+   return;
+   }
+
if (ci->id_event) {
ci->id_event = false;
ci_handle_id_switch(ci);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index f9e536b..0601058 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -427,6 +427,197 @@ static struct otg_fsm_ops ci_otg_ops = {
.start_gadget = ci_otg_start_gadget,
 };
 
+int ci_otg_fsm_work(struct ci_hdrc *ci)
+{
+   if (!ci->transceiver->otg || !ci->fsm)
+   return -ENODEV;
+
+   if (otg_statemachine(ci->fsm)) {
+   if (ci->transceiver->state == OTG_STATE_A_IDLE) {
+   if (ci->fsm->id)
+   /* A idle to B idle */
+   otg_statemachine(ci->fsm);
+   else if ((ci->id_event) || (ci->fsm->power_up)) {
+   ci->id_event = false;
+   /* A idle to A wait vrise */
+   otg_statemachine(ci->fsm);
+   ci->fsm->power_up = false;
+   }
+   }
+   }
+   return 0;
+}
+
+static void ci_otg_fsm_event(struct ci_hdrc *ci, struct otg_fsm *fsm)
+{
+   u32 intr_sts, otg_bsess_vld, port_conn;
+
+   if ((ci == NULL) || (fsm == NULL))
+   return;
+
+   intr_sts = hw_read_intr_status(ci);
+   otg_bsess_vld = hw_read(ci, OP_OTGSC, OTGSC_BSV);
+   port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);
+
+   switch (ci->transceiver->state) {
+   case OTG_STATE_A_WAIT_BCON:
+   if (port_conn) {
+   fsm->b_conn = 1;
+   fsm->a_bus_req = 1;
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+   break;
+   case OTG_STATE_B_IDLE:
+   if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) {
+   fsm->b_sess_vld = 1;
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+   break;
+   case OTG_STATE_B_PERIPHERAL:
+   if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) {
+   fsm->a_bus_suspend = 1;
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   } else if (intr_sts & USBi_PCI) {
+   if (fsm->a_bus_suspend == 1)
+   fsm->a_bus_suspend = 0;
+   }
+   break;
+   case OTG_STATE_B_HOST:
+   if ((intr_sts & USBi_PCI) && !port_conn) {
+   fsm->a_conn = 0;
+   fsm->b_bus_req = 0;
+   disable_irq_nosync(ci->irq);
+   

[PATCH v3 10/13] usb: chipidea: add sys inputs for OTG fsm input.

2014-02-26 Thread Li Jun
This patch adds sys input to control and show OTG fsm inputs by application,
user can do host and preipheral role switch by change these inputs.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/otg.c |1 +
 drivers/usb/chipidea/otg_fsm.c |  192 
 drivers/usb/chipidea/otg_fsm.h |6 ++
 3 files changed, 199 insertions(+)

diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 4fb33a2..6c10b91 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -129,4 +129,5 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
}
ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS);
ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS);
+   ci_hdrc_otg_fsm_remove(ci);
 }
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 0601058..0e980f1 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -41,6 +41,185 @@ static struct ci_otg_fsm_timer *otg_timer_initializer
return timer;
 }
 
+/* Add for otg: interact with user space app */
+static ssize_t
+get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+
+   if (ci->transceiver && ci->transceiver->otg && ci->fsm) {
+   t = scnprintf(next, size, "%d\n", ci->fsm->a_bus_req);
+   size -= t;
+   next += t;
+   } else
+   dev_err(ci->dev, "error: otg setup is not completed!\n");
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_req(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1;
+
+   mutex_lock(&ci->fsm->lock);
+   if (ci->transceiver && ci->transceiver->otg && ci->fsm) {
+   if (buf[0] == '0') {
+   ci->fsm->a_bus_req = 0;
+   } else if (buf[0] == '1') {
+   /* If a_bus_drop is TRUE, a_bus_req can't be set */
+   if (ci->fsm->a_bus_drop)
+   goto end;
+   ci->fsm->a_bus_req = 1;
+   }
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   } else
+   dev_err(ci->dev, "error: otg setup is not completed!\n");
+end:
+   mutex_unlock(&ci->fsm->lock);
+
+   return count;
+}
+static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
+
+static ssize_t
+get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   if (ci->transceiver && ci->transceiver->otg && ci->fsm) {
+   t = scnprintf(next, size, "%d\n", ci->fsm->a_bus_drop);
+   size -= t;
+   next += t;
+   } else
+   dev_err(ci->dev, "error: otg setup is not completed!\n");
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_drop(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1;
+
+   mutex_lock(&ci->fsm->lock);
+   if (ci->transceiver && ci->transceiver->otg && ci->fsm) {
+   if (buf[0] == '0') {
+   ci->fsm->a_bus_drop = 0;
+   } else if (buf[0] == '1') {
+   ci->fsm->a_bus_drop = 1;
+   ci->fsm->a_bus_req = 0;
+   }
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+   mutex_unlock(&ci->fsm->lock);
+
+   return count;
+}
+static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop,
+   set_a_bus_drop);
+
+static ssize_t
+get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+
+   if (ci->transceiver && ci->transceiver->otg && ci->fsm) {
+   t = scnprintf(next, size, "%d\n", ci->fsm->b_bus_req);
+   size -= t;
+   next += t;
+   }
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_b_bus_req(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1

[PATCH v3 08/13] usb: chipidea: OTG fsm timers initialization.

2014-02-26 Thread Li Jun
This patch adds OTG fsm timers initialization, which use controller's 1ms
interrupt as timeout counter, also adds some local timers which are not
in otg_fsm_timer list.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/bits.h|1 +
 drivers/usb/chipidea/otg_fsm.c |  190 
 drivers/usb/chipidea/otg_fsm.h |   65 ++
 3 files changed, 256 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index c42eb35..302cde7 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -83,6 +83,7 @@
 #define OTGSC_VC BIT(1)
 #define OTGSC_IDPU   BIT(5)
 #define OTGSC_HADP   BIT(6)
+#define OTGSC_HABA   BIT(7)
 #define OTGSC_ID BIT(8)
 #define OTGSC_AVVBIT(9)
 #define OTGSC_ASVBIT(10)
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index aa24466..f9e536b 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -25,6 +25,22 @@
 #include "otg.h"
 #include "otg_fsm.h"
 
+static struct ci_otg_fsm_timer *otg_timer_initializer
+(struct ci_hdrc *ci, void (*function)(void *, unsigned long),
+   unsigned long expires, unsigned long data)
+{
+   struct ci_otg_fsm_timer *timer;
+
+   timer = devm_kzalloc(ci->dev, sizeof(struct ci_otg_fsm_timer),
+   GFP_KERNEL);
+   if (!timer)
+   return NULL;
+   timer->function = function;
+   timer->expires = expires;
+   timer->data = data;
+   return timer;
+}
+
 /* Add timer to active timer list */
 static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
 {
@@ -75,6 +91,163 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum 
ci_otg_fsm_timer_index t)
ci_disable_otg_interrupt(ci, OTGSC_1MSIE);
 }
 
+/*
+ * Reduce timer count by 1, and find timeout conditions.
+ * Called by otg 1ms timer interrupt
+ */
+static int ci_otg_tick_timer(struct ci_hdrc *ci)
+{
+   struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
+   struct list_head *active_timers = &ci->fsm_timer->active_timers;
+   int expired = 0;
+
+   list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) {
+   tmp_timer->count--;
+   /* check if timer expires */
+   if (!tmp_timer->count) {
+   list_del(&tmp_timer->list);
+   tmp_timer->function(ci, tmp_timer->data);
+   expired = 1;
+   }
+   }
+
+   /* disable 1ms irq if there is no any timer active */
+   if ((expired == 1) && list_empty(active_timers))
+   ci_disable_otg_interrupt(ci, OTGSC_1MSIE);
+
+   return expired;
+}
+
+/* The timeout callback function to set time out bit */
+static void set_tmout(void *ptr, unsigned long indicator)
+{
+   *(int *)indicator = 1;
+}
+
+static void set_tmout_and_fsm(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+
+   /* trans from a_wait_bcon to a_wait_vfall */
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+}
+
+static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+   set_tmout(ci, indicator);
+
+   /* only vbus fall below B_sess_vld in b_idle state */
+   if (ci->transceiver->state == OTG_STATE_B_IDLE) {
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+}
+
+static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   /* Check if A detached */
+   if (!(hw_read(ci, OP_OTGSC, OTGSC_BSV))) {
+   ci->fsm->b_sess_vld = 0;
+   ci_otg_add_timer(ci, B_SSEND_SRP);
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+}
+
+static void b_data_pulse_end(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   ci->fsm->b_srp_done = 1;
+   ci->fsm->b_bus_req = 0;
+   if (ci->fsm->power_up)
+   ci->fsm->power_up = 0;
+
+   hw_write(ci, OP_OTGSC, OTGSC_INT_STATUS_BITS | OTGSC_HABA, 0);
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+}
+
+/* Initialize timers */
+static int ci_otg_init_timers(struct ci_hdrc *ci)
+{
+   struct otg_fsm *fsm = ci->fsm;
+
+   /* FSM used timers */
+   ci->fsm_timer->timer_list[A_WAIT_VRISE] =
+   otg_timer_initializer(ci, &set_tmout, TA_WAIT_VRISE,
+   (unsigned long)&fsm->a_wait_vrise_tmout);
+   if (ci->fsm_timer->timer_list[A_WAIT_VRISE] == NULL)
+   return -ENOMEM;
+
+   ci->fsm_timer->timer_list[A_WAIT_VFALL] =
+

[PATCH v3 11/13] usb: chipidea: debug: add debug file for OTG variables show.

2014-02-26 Thread Li Jun
This patch adds a debug file for OTG vairables show.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/debug.c |   85 ++
 1 file changed, 85 insertions(+)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 96d899a..06be301 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -7,6 +7,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "ci.h"
 #include "udc.h"
@@ -204,6 +207,81 @@ static const struct file_operations ci_requests_fops = {
.release= single_release,
 };
 
+int ci_otg_show(struct seq_file *s, void *unused)
+{
+   struct ci_hdrc *ci = s->private;
+   struct otg_fsm *fsm;
+
+   if (!ci || !ci->is_otg || !ci->fsm)
+   return 0;
+
+   fsm = ci->fsm;
+
+   /* -- State - */
+   seq_printf(s,
+ "OTG state: %s\n\n",
+ usb_otg_state_string(ci->transceiver->state));
+
+   /* -- State Machine Variables - */
+   seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
+
+   seq_printf(s, "a_bus_req: %d\n", fsm->a_bus_req);
+
+   seq_printf(s, "a_srp_det: %d\n", fsm->a_srp_det);
+
+   seq_printf(s, "a_vbus_vld: %d\n", fsm->a_vbus_vld);
+
+   seq_printf(s, "b_conn: %d\n", fsm->b_conn);
+
+   seq_printf(s, "adp_change: %d\n", fsm->adp_change);
+
+   seq_printf(s, "power_up: %d\n", fsm->power_up);
+
+   seq_printf(s, "a_bus_resume: %d\n", fsm->a_bus_resume);
+
+   seq_printf(s, "a_bus_suspend: %d\n", fsm->a_bus_suspend);
+
+   seq_printf(s, "a_conn: %d\n", fsm->a_conn);
+
+   seq_printf(s, "b_bus_req: %d\n", fsm->b_bus_req);
+
+   seq_printf(s, "b_bus_suspend: %d\n", fsm->b_bus_suspend);
+
+   seq_printf(s, "b_se0_srp: %d\n", fsm->b_se0_srp);
+
+   seq_printf(s, "b_ssend_srp: %d\n", fsm->b_ssend_srp);
+
+   seq_printf(s, "b_sess_vld: %d\n", fsm->b_sess_vld);
+
+   seq_printf(s, "b_srp_done: %d\n", fsm->b_srp_done);
+
+   seq_printf(s, "drv_vbus: %d\n", fsm->drv_vbus);
+
+   seq_printf(s, "loc_conn: %d\n", fsm->loc_conn);
+
+   seq_printf(s, "loc_sof: %d\n", fsm->loc_sof);
+
+   seq_printf(s, "adp_prb: %d\n", fsm->adp_prb);
+
+   seq_printf(s, "id: %d\n", fsm->id);
+
+   seq_printf(s, "protocol: %d\n", fsm->protocol);
+
+   return 0;
+}
+
+static int ci_otg_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, ci_otg_show, inode->i_private);
+}
+
+static const struct file_operations ci_otg_fops = {
+   .open   = ci_otg_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release,
+};
+
 static int ci_role_show(struct seq_file *s, void *data)
 {
struct ci_hdrc *ci = s->private;
@@ -287,6 +365,13 @@ int dbg_create_files(struct ci_hdrc *ci)
if (!dent)
goto err;
 
+   if (ci->is_otg) {
+   dent = debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci,
+   &ci_otg_fops);
+   if (!dent)
+   goto err;
+   }
+
dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
   &ci_role_fops);
if (dent)
-- 
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 12/13] usb: chipidea: debug: add debug file for controller registers dump.

2014-02-26 Thread Li Jun
This patch adds below registers dump for debug:
- USBINTR
- USBSTS
- USBMODE
- USBCMD
- PORTSC
- OTGSC

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/debug.c |   48 ++
 1 file changed, 48 insertions(+)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 06be301..bcc7b8a 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -331,6 +331,48 @@ static const struct file_operations ci_role_fops = {
.release= single_release,
 };
 
+int ci_registers_show(struct seq_file *s, void *unused)
+{
+   struct ci_hdrc *ci = s->private;
+   u32 tmp_reg;
+
+   if (!ci)
+   return 0;
+
+   /* -- Registers - */
+   tmp_reg = hw_read_intr_enable(ci);
+   seq_printf(s, "USBINTR reg: %08x\n", tmp_reg);
+
+   tmp_reg = hw_read_intr_status(ci);
+   seq_printf(s, "USBSTS reg: %08x\n", tmp_reg);
+
+   tmp_reg = hw_read(ci, OP_USBMODE, ~0);
+   seq_printf(s, "USBMODE reg: %08x\n", tmp_reg);
+
+   tmp_reg = hw_read(ci, OP_USBCMD, ~0);
+   seq_printf(s, "USBCMD reg: %08x\n", tmp_reg);
+
+   tmp_reg = hw_read(ci, OP_PORTSC, ~0);
+   seq_printf(s, "PORTSC reg: %08x\n", tmp_reg);
+
+   tmp_reg = hw_read(ci, OP_OTGSC, ~0);
+   seq_printf(s, "OTGSC reg: %08x\n", tmp_reg);
+
+   return 0;
+}
+
+static int ci_registers_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, ci_registers_show, inode->i_private);
+}
+
+static const struct file_operations ci_registers_fops = {
+   .open   = ci_registers_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release,
+};
+
 /**
  * dbg_create_files: initializes the attribute interface
  * @ci: device
@@ -374,6 +416,12 @@ int dbg_create_files(struct ci_hdrc *ci)
 
dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
   &ci_role_fops);
+   if (!dent)
+   goto err;
+
+   dent = debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci,
+   &ci_registers_fops);
+
if (dent)
return 0;
 err:
-- 
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: [PATCH v2 7/9] usb: chipidea: OTG HNP and SRP fsm implementation.

2014-02-26 Thread Li Jun
On Mon, Feb 10, 2014 at 10:32:24AM +0800, Peter Chen wrote:
> On Mon, Jan 20, 2014 at 09:56:18AM +0800, Li Jun wrote:
> > USB OTG interrupt handling and fsm transition according to USB OTG
> > spec 2.0, update otg timer timeout handlers.
> 
> USB OTG and EH 2.0 
>

changed.

> > 
> > Signed-off-by: Li Jun 
> > ---
> >  drivers/usb/chipidea/bits.h|2 +
> >  drivers/usb/chipidea/core.c|   10 ++-
> >  drivers/usb/chipidea/otg.c |9 ++-
> >  drivers/usb/chipidea/otg_fsm.c |  193 
> > 
> >  drivers/usb/chipidea/otg_fsm.h |   18 
> >  5 files changed, 229 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
> > index 88136d1..5a74f9d 100644
> > --- a/drivers/usb/chipidea/bits.h
> > +++ b/drivers/usb/chipidea/bits.h
> > @@ -33,6 +33,8 @@
> >  #define USBCMD_ATDTW  BIT(14)
> >  
> >  /* USBSTS & USBINTR */
> > +#define USBSTS_PCIBIT(2)
> > +#define USBSTS_SLIBIT(8)
> >  #define USBi_UI   BIT(0)
> >  #define USBi_UEI  BIT(1)
> >  #define USBi_PCI  BIT(2)
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 33f22bc..6865451 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -73,6 +73,7 @@
> >  #include "host.h"
> >  #include "debug.h"
> >  #include "otg.h"
> > +#include "otg_fsm.h"
> >  
> >  /* Controller register map */
> >  static const u8 ci_regs_nolpm[] = {
> > @@ -351,8 +352,12 @@ static irqreturn_t ci_irq(int irq, void *data)
> > irqreturn_t ret = IRQ_NONE;
> > u32 otgsc = 0;
> >  
> > -   if (ci->is_otg)
> > +   if (ci->is_otg) {
> > otgsc = hw_read(ci, OP_OTGSC, ~0);
> > +   ret = ci_otg_fsm_irq(ci);
> > +   if (ret == IRQ_HANDLED)
> > +   return ret;
> > +   }
> >  
> > /*
> >  * Handle id change interrupt, it indicates device/host function
> > @@ -656,6 +661,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
> > if (ret)
> > goto stop;
> >  
> > +   if (ci->is_otg)
> > +   ci_hdrc_otg_fsm_start(ci);
> > +
> > ret = dbg_create_files(ci);
> > if (!ret)
> > return 0;
> > diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
> > index cbf0167..4fb33a2 100644
> > --- a/drivers/usb/chipidea/otg.c
> > +++ b/drivers/usb/chipidea/otg.c
> > @@ -11,8 +11,8 @@
> >   */
> >  
> >  /*
> > - * This file mainly handles otgsc register, it may include OTG operation
> > - * in the future.
> > + * This file mainly handles otgsc register, OTG fsm operations for HNP and 
> > SRP
> > + * are also included.
> >   */
> >  
> >  #include 
> > @@ -77,6 +77,11 @@ static void ci_otg_work(struct work_struct *work)
> >  {
> > struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
> >  
> > +   if (!ci_otg_fsm_work(ci)) {
> > +   enable_irq(ci->irq);
> > +   return;
> > +   }
> > +
> > if (ci->id_event) {
> > ci->id_event = false;
> > ci_handle_id_switch(ci);
> > diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> > index 5416fe3..e713b76 100644
> > --- a/drivers/usb/chipidea/otg_fsm.c
> > +++ b/drivers/usb/chipidea/otg_fsm.c
> > @@ -433,6 +433,199 @@ static struct otg_fsm_ops ci_otg_ops = {
> > .start_gadget = ci_otg_start_gadget,
> >  };
> >  
> > +int ci_otg_fsm_work(struct ci_hdrc *ci)
> > +{
> > +   if (!ci->transceiver->otg || !ci->fsm)
> > +   return -ENODEV;
> > +
> > +   if (otg_statemachine(ci->fsm)) {
> > +   if (ci->transceiver->state == OTG_STATE_A_IDLE) {
> > +   if (ci->fsm->id)
> > +   /* A idle to B idle */
> > +   otg_statemachine(ci->fsm);
> > +   else if ((ci->id_event) || (ci->fsm->power_up)) {
> > +   ci->id_event = false;
> > +   /* A idle to A wait vrise */
> > +   otg_statemachine(ci->fsm);
> > +   ci->fsm->power_up = false;
> > +   }
> > +   }
> > +   }
> > +   return 0;
> > +}
> > +
> > +static void ci_otg_fsm_event(struct ci_hdrc *ci, struct otg_fsm *fsm)
> > +{
> > +   if ((ci == NULL) || (fsm == NULL))
> > +   return;
> > +
> > +   switch (ci->transceiver->state) {
> > +   case OTG_STATE_A_WAIT_BCON:
> > +   if (hw_read(ci, OP_PORTSC, PORTSC_CCS)) {
> > +   fsm->b_conn = 1;
> > +   fsm->a_bus_req = 1;
> > +   disable_irq_nosync(ci->irq);
> > +   queue_work(ci->wq, &ci->work);
> > +   }
> > +   break;
> > +   case OTG_STATE_B_IDLE:
> > +   if (hw_read(ci, OP_OTGSC, OTGSC_BSV) &&
> > +   hw_read(ci, OP_USBSTS, USBSTS_PCI) &&
> > +   hw_read(ci, OP_PORTSC, PORTSC_CCS)) {
> > +   fsm->b

RE: [PATCH 2/6] usb: gadget: mv_udc: disable HW zlt for ep0

2014-02-26 Thread Peter Chen
 
> > > > >
> > > > > Chipidea bug too? Does it follow ch 8.5.3.2 Variable-length Data
> > > > > Stage, USB
> > > > 2.0 spec?
> > > >
> > > > wait, this is a chipidea core ? Why aren't you guys using the
> > > > chipidea driver yet ? You need to switch over to that driver dude,
> > > > we can't have duplicated code in the tree.
> > > >
> > > > I'm sorry, but I won't be taking this series, please use chipidea
> > > > driver, it should be very simple to add a glue layer for your core
> > > > to
> > > the chipidea driver.
> > > >
> > >
> > > Yes, it use chipidea IP.
> > > But the driver is earlier than the chipidea one and we use it for
> > > our products.
> > > So it may be not that easy to switch to chipidea driver due to the
> > > stability.
> > >
> >
> > Freescale i.mx SoC used fsl_udc_core.c before which was the one of the
> 
> btw, when can I remove fsl_udc_core.c from the tree ?
> 

Freescale has other processor group (PowerPC, etc) has used this code now.

Peter
--
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: musb - high CPU load in DMA mode and dropouts during audio playback

2014-02-26 Thread George Cherian

Hi Michal,
On 2/26/2014 7:07 PM, Michal Šmucr wrote:

On 18.2.2014 2:18, Michal Šmucr wrote:


Hello,

i'm fighting with audio playback problem on Beaglebone Black AM-3358.
Class compilant USB soundcards with isochronous transfers.


what is the application you are using for play back.
With DMA enabled in kernels 3.13.2 and 3.14-rc2 it has following 
symptoms.

- it will stutter immediately after starts of playback
- kworker thread shows about 80-90% CPU usage during playback
- it presents with cppi41_dma_control warnings and traces, plus couple
of transfer errors
(i've enabled also CONFIG_DMADEVICES_DEBUG, so it dmesg is quite 
lengthy)

http://vpub.smucr.cz/pub/bbb/debug/dmesg.log


I too see the backtraces will send a patch soon to fix the same.
During my testing am not seeing the CPU usage as you mention.
Could you please share you .config.

I used aplay for testing playback and arecord for recording using USB 
headsets.


With force PIO at any tested kernel from 3.8.x to 3.14.x and DMA mode at
3.12.9 it is better, CPU load seems to be much lower, but it is not
completely solved. Still during high interrupt load from other devices
like NIC or second USB port, i'm having audio dropouts. Without any
messages this time.

I tested to apply following George Cherian's related patches

http://marc.info/?l=linux-usb&m=139081552015728&w=2
usb: musb: musb_host: Enable ISOCH IN handling for AM335x host
usb: musb: musb_cppi41: Make CPPI aware of high bandwidth transfers
usb: musb: musb_cppi41: Handle ISOCH differently and not use the hrtimer

and Adam Wozniak's
http://marc.info/?l=linux-usb&m=139101388408467&w=2
"high cpu load on omap3 using musb"



I also tried to find something related in TI git tree and compile 
linux-next, but without luck.

Any tips, what to do next? Does anybody experienced same issue?

Thanks,

Michal





--
-George

--
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: start tear down only if channel is busy

2014-02-26 Thread George Cherian
Start the channel tear down only if the channel is busy, else just
bail out. In some cases its seen that by the time the tear down is
initiated the cppi completes the DMA, especially in ISOCH transfers.

Signed-off-by: George Cherian 
---
 drivers/dma/cppi41.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index c18aebf..d028f36 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -620,12 +620,15 @@ static int cppi41_stop_chan(struct dma_chan *chan)
u32 desc_phys;
int ret;
 
+   desc_phys = lower_32_bits(c->desc_phys);
+   desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
+   if (!cdd->chan_busy[desc_num])
+   return 0;
+
ret = cppi41_tear_down_chan(c);
if (ret)
return ret;
 
-   desc_phys = lower_32_bits(c->desc_phys);
-   desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc);
WARN_ON(!cdd->chan_busy[desc_num]);
cdd->chan_busy[desc_num] = NULL;
 
-- 
1.8.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 0/2] Fix CPPI Warnings during tear down after ISOCH transfers

2014-02-26 Thread George Cherian
Warinings are seen after  ISOCH transfers, during channel tear down.
This is mainly beacause we handle ISOCH differently as compared to 
other transfers. 

Patch 1: make sure we do channel tear down only if channel is busy.
 If not the tear down will never succeed.

Patch 2: ISOCH completions are done differently, so this might lead to 
reprogram of dma channel on which already a teardown is done.


George Cherian (2):
  dma: cppi41: start tear down only if channel is busy
  usb: musb: musb_cppi41: Dont reprogram DMA if tear down is initiated

 drivers/dma/cppi41.c   | 7 +--
 drivers/usb/musb/musb_cppi41.c | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

-- 
1.8.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 2/2] usb: musb: musb_cppi41: Dont reprogram DMA if tear down is initiated

2014-02-26 Thread George Cherian
Reprogramming the DMA after tear down is initiated leads to warning.
This is mainly seen with ISOCH since we do a delayed completion for
ISOCH transfers. In ISOCH transfers dma_completion should not reprogram
if the channel tear down is initiated.

Signed-off-by: George Cherian 
---
 drivers/usb/musb/musb_cppi41.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index f3ec7d2..e201b1e 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -132,7 +132,8 @@ static void cppi41_trans_done(struct cppi41_dma_channel 
*cppi41_channel)
struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
struct musb *musb = hw_ep->musb;
 
-   if (!cppi41_channel->prog_len) {
+   if (!cppi41_channel->prog_len ||
+   (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE)) {
 
/* done, complete */
cppi41_channel->channel.actual_len =
-- 
1.8.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] usb: gadget: return the right length in ffs_epfile_io()

2014-02-26 Thread Chuansheng Liu
When the request length is aligned to maxpacketsize, sometimes
the return length ret > the user space requested len.

At that time, we will use min_t(size_t, ret, len) to limit the
size in case of user data buffer overflow.

But we need return the min_t(size_t, ret, len) to tell the user
space rightly also.

Signed-off-by: Chuansheng Liu 
---
 drivers/usb/gadget/f_fs.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 2b43343..31ee7af 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -687,10 +687,12 @@ static ssize_t ffs_epfile_io(struct file *file,
 * space for.
 */
ret = ep->status;
-   if (read && ret > 0 &&
-   unlikely(copy_to_user(buf, data,
- min_t(size_t, ret, len
-   ret = -EFAULT;
+   if (read && ret > 0) {
+   ret = min_t(size_t, ret, len);
+
+   if (unlikely(copy_to_user(buf, data, ret)))
+   ret = -EFAULT;
+   }
}
}
 
-- 
1.9.rc0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html