Re: 3.7.3, ttyUSB0 serial problem - devices stop working and only reboot helps (Inappropriate ioctl for device)

2013-01-20 Thread Arkadiusz Miskiewicz
On Sunday 20 of January 2013, Woody Suwalski wrote:
 Arkadiusz Miskiewicz wrote:
  On Saturday 19 of January 2013, Arkadiusz Miskiewicz wrote:
  On Saturday 19 of January 2013, Greg Kroah-Hartman wrote:
  On Fri, Jan 18, 2013 at 11:28:43PM +0100, Arkadiusz Miskiewicz wrote:
  Hi.
  
  Using 3.7.3 kernel and connecting two rs232 usb adapters, CP2102 and
  FT232RL, one after disconnecting another.
  
  After few cycles of reconnecting and using socat (below) I'm getting
  problems accessing ttyUSB0:
  ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
  TCGETS, 0x7fffb70c6ae0) = -1 ENOTTY (Inappropriate ioctl for device)
  
  Unloading and reloading (by udev) modules ftdio_sio, cp210x, usbserial
  doesn't help. I have to reboot to get ttyUSB0 working (regardless of
  which driver, ftdio_sio or cp210x is handling ttyUSB0 - both stop
  working).
  
  Any clues?
  
  The kernel log shows the device getting removed a bunch and then coming
  back, which implies electrical issues (flaky connection, low power,
  etc.)  Are you really removing it and plugging it back in?  Or is it
  doing it all by itself?
  
  I was doing plug in CP2102, remove it, plug in FT232RL after few
  seconds, remove it, plug in CP... (and various variations, several
  times) and testing with socat before removing devices. After some
  iteration the problem appears and only reboot helps.
  
  The issue is really weird. Machine is Thinkpad T400 2764CTO (latest
  bios). When the problem happened on 3.7.3 today I rebooted into 3.8rc4
  and ... freshly after reboot and plugging in PL2303 adapter the problem
  was already there. Didn't have to do unplug/plug cycle to make it
  happen.
  
  Looks like sometimes reboot cures the problem, sometimes it doesn't. Now
  powered off laptop and powered it on - problem gone.
  
  Connected PL2303, ran socat, disconnected PL2303 (while socat was
  running) - problem happened again. Looks like it doesn't depend on
  adapter chip type.
  
  So to reproduce here:
  - boot fresh 3.8rc4
  - plug in some adapter (PL2303 for example)
  - run socat -ddd -s -u
  /dev/ttyUSB0,raw,echo=0,b115200,crnl,noctty,nonblock -
  
  | logger - it should run fine, without any error
  
  - disconnect adapter; socat should exit with error W cannot restore
  terminal settings on fd 3: Input/output error
  - plug in adapter again
  - run socat again - this time error E tcgetattr(3, 0x7fff21411780):
  Inappropriate ioctl for device immediately always; regardless which
  adapter is used and if kernel module drivers for these adapters were
  reloaded
  
  dmesg:
  http://pastebin.com/r1Q5mmgt
  
  config:
  http://pastebin.com/8dpFFzuU
  
  lspci:
  http://pastebin.com/TBtUg1tW
  
  lsusb:
  http://pastebin.com/SueVw9CD
  
  [   53.776047] usb 4-1: new full-speed USB device number 2 using uhci_hcd
  [   53.938053] usb 4-1: New USB device found, idVendor=067b,
  idProduct=2303 [   53.938060] usb 4-1: New USB device strings: Mfr=1,
  Product=2, SerialNumber=0
  [   53.938065] usb 4-1: Product: USB-Serial Controller
  [   53.938068] usb 4-1: Manufacturer: Prolific Technology Inc.
  [   53.949924] usbcore: registered new interface driver usbserial
  [   53.950364] usbcore: registered new interface driver usbserial_generic
  [   53.951147] usbserial: USB Serial support registered for generic
  [   53.954268] usbcore: registered new interface driver pl2303
  [   53.955009] usbserial: USB Serial support registered for pl2303
  [   53.955039] pl2303 4-1:1.0: pl2303 converter detected
  [   53.967394] usb 4-1: pl2303 converter now attached to ttyUSB0
  [   64.492122] usb 4-1: USB disconnect, device number 2
  [   64.501748] pl2303 ttyUSB0: pl2303 converter now disconnected from
  ttyUSB0 [   64.502343] pl2303 4-1:1.0: device disconnected
  [   66.494930] usb 4-1: new full-speed USB device number 3 using uhci_hcd
  [   66.654247] usb 4-1: New USB device found, idVendor=067b,
  idProduct=2303 [   66.654261] usb 4-1: New USB device strings: Mfr=1,
  Product=2, SerialNumber=0
  [   66.654269] usb 4-1: Product: USB-Serial Controller
  [   66.654276] usb 4-1: Manufacturer: Prolific Technology Inc.
  [   66.659661] pl2303 4-1:1.0: pl2303 converter detected
  [   66.671587] usb 4-1: pl2303 converter now attached to ttyUSB0
  
  5722  munmap(0x7f1bfc0d7000, 4096)  = 0
  5722  write(2, 2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
  0x7fffeff64020): Inappropriate ioctl for device\n, 95) = 95
  5722  ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
  TCGETS, 0x7fffeff63e50) = -1 ENOTTY (Inappropriate ioctl for device)
  5722  write(2, 2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
  0x7fffeff63f90): Inappropriate ioctl for device\n, 95) = 95
  5722  ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
  TCGETS, 0x7fffeff63ec0) = -1 ENOTTY (Inappropriate ioctl for device)
  5722  write(2, 2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
  0x7fffeff64160): Inappropriate ioctl for device\n, 95) = 95
  5722  

Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2013-01-20 Thread Felipe Balbi
On Sun, Jan 20, 2013 at 03:58:13AM +0100, Pali Rohár wrote:
 Signed-off-by: Pali Rohár pali.ro...@gmail.com

NAK for two reasons:

a) the original Nokia kernel used a separate g_file_storage gadget to
use Mass Storage mode, use that

b) there is no commit log

-- 
balbi


signature.asc
Description: Digital signature


Re: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

2013-01-20 Thread Felipe Balbi
Hi,

On Fri, Jan 18, 2013 at 03:43:59PM -0800, Greg KH wrote:
 On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:
  
  From: fangxiaozhi huana...@huawei.com
  
  1. Optimize the matching rules with new macro for Huawei USB storage
 devices, to avoid to load USB storage driver for the modem interface
 with Huawei devices.
  2. Add to support new switch command for new Huawei USB dongles.
  
  Signed-off-by: fangxiaozhi huana...@huawei.com
 
 This patch breaks the build, did you test it out?
 
 I get the following errors:
 
 drivers/usb/storage/unusual_devs.h:1530:1: error: implicit declaration of 
 function ‘UNUSUAL_VENDOR_INTF’ [-Werror=implicit-function-declaration]
 drivers/usb/storage/unusual_devs.h:1534:3: warning: missing braces around 
 initializer [-Wmissing-braces]
 drivers/usb/storage/unusual_devs.h:1534:3: warning: (near initialization for 
 ‘us_unusual_dev_list[186]’) [-Wmissing-braces]
 drivers/usb/storage/unusual_devs.h:1534:3: error: initializer element is not 
 constant
 drivers/usb/storage/unusual_devs.h:1534:3: error: (near initialization for 
 ‘us_unusual_dev_list[186].vendorName’)
 drivers/usb/storage/unusual_devs.h:1537:1: warning: braces around scalar 
 initializer [enabled by default]
 
 And it goes on and on...
 
 Care to fix this up and resend it?

Before resending make sure to scripts/checkpatch.pl and compile with
make C=1 for your ARM platform and x86 with allyesconfig, allnoconfig
and allmodconfig. In summary, follow Documentation/SubmitChecklist.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2013-01-20 Thread Pali Rohár
On Sunday 20 January 2013 10:25:37 Felipe Balbi wrote:
 On Sun, Jan 20, 2013 at 03:58:13AM +0100, Pali Rohár wrote:
  Signed-off-by: Pali Rohár pali.ro...@gmail.com
 
 NAK for two reasons:
 
 a) the original Nokia kernel used a separate g_file_storage
 gadget to use Mass Storage mode, use that
 
 b) there is no commit log

Reason why add mass storage mode to g_nokia is to avoid switching 
between g_{file,mass}_storage and g_nokia and to have one gadget 
driver for Nokia N900. It is better to have usb network and mass 
storage mode in one driver (and not to unload  load another).

I tested this patch with 3.8-rc3 kernel on Nokia N900 and usb 
network with mass storage mode working without problems.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: Unable to reinsert the am35x MUSB module

2013-01-20 Thread Igor Grinberg
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/18/13 20:58, Felipe Balbi wrote:
 Hi,
 
 On Sun, Dec 02, 2012 at 05:33:36PM +0200, Dmitry Lifshitz wrote:
 Hi,

 We are running kernel v3.5.7 on am3517 based hardware (CM-T3517 module).
 Recently we faced with the following issue: am35x MUSB module fails
 when trying to reinsert it.
 It fails with the message musb-hdrc.0: failed to claim resource 1,
 see the console clip below:

 root@cm-debian:~# modprobe am35x
 musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
 6Waiting for PHY clock good...
 musb-hdrc: ConfigData=0x1e (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx,
 SoftConn)
 musb-hdrc: MHDRC RTL version 1.900
 musb-hdrc: setup fifo_mode 4
 musb-hdrc: 28/31 max ep, 16384/16384 memory
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~# modprobe -r am35x
 udc musb-hdrc.0: releasing 'musb-hdrc.0'
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~#
 root@cm-debian:~# modprobe am35x
 musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
 musb-hdrc.0: failed to claim resource 1
 musb-am35x musb-am35x: failed to register musb device
 musb-am35x: probe of musb-am35x failed with error -16
 root@cm-debian:~#

 The issue still exists even in the resent kernel v3.7.0-rc7.
 While searching for the resolution I found the similar issue with the
 davinci MUSB module:

 http://comments.gmane.org/gmane.linux.davinci/23781

 It was found almost a year ago. Does anybody know how it can be
 properly resolved?
 
 Can you try to figure which resource is getting a conflict ?

Yep:

# modprobe am35x
musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
-   ALLOCATED RESOURCES = 2
RESOURCE #0 of TYPE = 1024 NAME = mc
RESOURCE #1 of TYPE = 512 NAME = musb-am35x
musb-hdrc: failed to claim resource 1
musb-am35x musb-am35x: failed to register musb device
musb-am35x: probe of musb-am35x failed with error -16


- -- 
Regards,
Igor.
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJQ+9SqAAoJEBDE8YO64EfaBkIP/2RBZblkosGLyIhsycKN6SQK
PzgiOmVUIVItE1neTHrBfNo987uPTQJhkinEZ1zIBIA/kHZlKRTvjSbWRmi0XOeV
TiY07EuPt6QVJWKyZobneQ/M0lcAITMfgNA1bjvk08LoEqFvzStjTcuu6bw0la4K
cEv+xQgFE9UhpFQ3cT62es6Dnl5aP2Xktsbc3HwYfYc40Fr9qflzF06oaXQzq/SA
qdkNPh4S0882bdbbp/LcgifrmauF3ru9SpfyGmpC9Zp2GoHhHIAM+u9k46uCMZVm
L8FpBlWYckt2vs95dPr7vjkkf9bQ4mqhJ5xV6Sbzrz1HvkaWYMsBOloaLxL1o3zD
vieSd+VQqGdK2zVBDYoj7xl4Eo+4p8FWRBCtZUErEAUqQD7aLAuAjoF2Mjf0Is2e
mA4OPTVFLnDVA40ttg7Kr3Wfz2ijuzIQO8FtObQYE4PmVkPnvWQCc6BoP/y7oDle
f4l7HxEAH6/LaZCOBCcQmnKTtclwJLlrRpMuj0/0d0ZjsxD9lx6b1rgYDFpOocFu
67kYrabEa6TrrvGiH/V04/REOiBnPwOsxrO+cwOx53mQFW9+Rw9ct53+eKJsX5Ql
0IJDuhTFd83hgBY1uCMGsIEPEwr7Ty3uYLt8USkU9RPnPJHtLopSQdQma3eCSJv5
75DJe7De3TlTGvfEznIb
=QD4R
-END PGP SIGNATURE-
--
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.7.3, ttyUSB0 serial problem - devices stop working and only reboot helps (Inappropriate ioctl for device)

2013-01-20 Thread Arkadiusz Miskiewicz
On Sunday 20 of January 2013, Arkadiusz Miskiewicz wrote:
 On Sunday 20 of January 2013, Woody Suwalski wrote:
  Arkadiusz Miskiewicz wrote:
   On Saturday 19 of January 2013, Arkadiusz Miskiewicz wrote:
   On Saturday 19 of January 2013, Greg Kroah-Hartman wrote:
   On Fri, Jan 18, 2013 at 11:28:43PM +0100, Arkadiusz Miskiewicz wrote:
   Hi.
   
   Using 3.7.3 kernel and connecting two rs232 usb adapters, CP2102 and
   FT232RL, one after disconnecting another.
   
   After few cycles of reconnecting and using socat (below) I'm getting
   problems accessing ttyUSB0:
   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
   TCGETS, 0x7fffb70c6ae0) = -1 ENOTTY (Inappropriate ioctl for device)
   
   Unloading and reloading (by udev) modules ftdio_sio, cp210x,
   usbserial doesn't help. I have to reboot to get ttyUSB0 working
   (regardless of which driver, ftdio_sio or cp210x is handling
   ttyUSB0 - both stop working).
   
   Any clues?
   
   The kernel log shows the device getting removed a bunch and then
   coming back, which implies electrical issues (flaky connection, low
   power, etc.)  Are you really removing it and plugging it back in? 
   Or is it doing it all by itself?
   
   I was doing plug in CP2102, remove it, plug in FT232RL after few
   seconds, remove it, plug in CP... (and various variations, several
   times) and testing with socat before removing devices. After some
   iteration the problem appears and only reboot helps.
   
   The issue is really weird. Machine is Thinkpad T400 2764CTO (latest
   bios). When the problem happened on 3.7.3 today I rebooted into 3.8rc4
   and ... freshly after reboot and plugging in PL2303 adapter the problem
   was already there. Didn't have to do unplug/plug cycle to make it
   happen.
   
   Looks like sometimes reboot cures the problem, sometimes it doesn't.
   Now powered off laptop and powered it on - problem gone.
   
   Connected PL2303, ran socat, disconnected PL2303 (while socat was
   running) - problem happened again. Looks like it doesn't depend on
   adapter chip type.
   
   So to reproduce here:
   - boot fresh 3.8rc4
   - plug in some adapter (PL2303 for example)
   - run socat -ddd -s -u
   /dev/ttyUSB0,raw,echo=0,b115200,crnl,noctty,nonblock -
   
   | logger - it should run fine, without any error
   
   - disconnect adapter; socat should exit with error W cannot restore
   terminal settings on fd 3: Input/output error
   - plug in adapter again
   - run socat again - this time error E tcgetattr(3, 0x7fff21411780):
   Inappropriate ioctl for device immediately always; regardless which
   adapter is used and if kernel module drivers for these adapters were
   reloaded
   
   dmesg:
   http://pastebin.com/r1Q5mmgt
   
   config:
   http://pastebin.com/8dpFFzuU
   
   lspci:
   http://pastebin.com/TBtUg1tW
   
   lsusb:
   http://pastebin.com/SueVw9CD
   
   [   53.776047] usb 4-1: new full-speed USB device number 2 using
   uhci_hcd [   53.938053] usb 4-1: New USB device found, idVendor=067b,
   idProduct=2303 [   53.938060] usb 4-1: New USB device strings: Mfr=1,
   Product=2, SerialNumber=0
   [   53.938065] usb 4-1: Product: USB-Serial Controller
   [   53.938068] usb 4-1: Manufacturer: Prolific Technology Inc.
   [   53.949924] usbcore: registered new interface driver usbserial
   [   53.950364] usbcore: registered new interface driver
   usbserial_generic [   53.951147] usbserial: USB Serial support
   registered for generic [   53.954268] usbcore: registered new
   interface driver pl2303 [   53.955009] usbserial: USB Serial support
   registered for pl2303 [   53.955039] pl2303 4-1:1.0: pl2303 converter
   detected
   [   53.967394] usb 4-1: pl2303 converter now attached to ttyUSB0
   [   64.492122] usb 4-1: USB disconnect, device number 2
   [   64.501748] pl2303 ttyUSB0: pl2303 converter now disconnected from
   ttyUSB0 [   64.502343] pl2303 4-1:1.0: device disconnected
   [   66.494930] usb 4-1: new full-speed USB device number 3 using
   uhci_hcd [   66.654247] usb 4-1: New USB device found, idVendor=067b,
   idProduct=2303 [   66.654261] usb 4-1: New USB device strings: Mfr=1,
   Product=2, SerialNumber=0
   [   66.654269] usb 4-1: Product: USB-Serial Controller
   [   66.654276] usb 4-1: Manufacturer: Prolific Technology Inc.
   [   66.659661] pl2303 4-1:1.0: pl2303 converter detected
   [   66.671587] usb 4-1: pl2303 converter now attached to ttyUSB0
   
   5722  munmap(0x7f1bfc0d7000, 4096)  = 0
   5722  write(2, 2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
   0x7fffeff64020): Inappropriate ioctl for device\n, 95) = 95
   5722  ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
   TCGETS, 0x7fffeff63e50) = -1 ENOTTY (Inappropriate ioctl for device)
   5722  write(2, 2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
   0x7fffeff63f90): Inappropriate ioctl for device\n, 95) = 95
   5722  ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
   TCGETS, 0x7fffeff63ec0) = -1 ENOTTY 

Re: [PATCH v2] USB: prevent overlapping access by usb-storage and usbfs

2013-01-20 Thread Sergei Shtylyov

Hello.

On 19-01-2013 21:54, Alan Stern wrote:


Furthermore, the locking in usbfs doesn't look right.  A process should
be able to submit as many URBs as it wants, of whatever type, at any
time.



 You mean USBDEVFS_SUBMITURB ioctl()? That's indeed an issue with 2.4 patch
(and mine, of course) -- it still accounts this ioctl() as exclusive and so
only permits one instance of URB. I should have documented it internally as a
side effect of the v1 patch but I'm not really familiar with usbfs, and so
documented only what was fixed by Pete back in 2006 (USBDEVFS_BULK).



I also meant USBDEVFS_BULK and USBDEVFS_CONTROL.


   But those are synchronous, aren't they? I don't see a problem with them.


Now that I look more closely at the patch, I wonder why it adds a lock
in usbdev_do_ioctl?  Won't that lock still be held when proc_bulk is
called and tries to acquire its own lock?  Won't that cause a deadlock?


   Yes, I'm now seeing that I did a fatal mistake in my haste by not merging 
in the third patch which divided ioctl's into exclusive and non-exclusice 
groups. Stupid me, the v2/v3 patches are totally useless then.



Also, why add a lock to usb_dump_desc in devices.c?  None of the
routines in that file try to communicate with the device.


   That was a part of the original patch. I haven't gone into detail about 
what these functions are doing.



   The locking should be by file handle, not by read vs. write.



 You mean we still don't allow more than one URB per file handle? That
would probably require a lock in the 'struct dev_state'...



No, this is what I mean: There's no point preventing usbfs from sending
bulk URBs while usb-storage is using the device.  usbfs already
prevents that.  What you want to do is prevent usbfs from sending
control URBs at the wrong time.  But when usb-storage isn't using the
device, there's no reason to restrict how many URBs usbfs can send.


   OK, fair enough.


Therefore you probably should use an rwsem.  Have usb-storage lock it
for writing, and have usbfs lock it for reading in proc_control and
proc_submiturb (with matching unlocks at the right places).


   Thanks for your suggestion.


Alan Stern


WBR, Sergei

--
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: precedence bug in show_requests()

2013-01-20 Thread Dan Carpenter
The mod operation has higher precedence than the divide but the intent
was to divide first.  It's supposed to count through one time for RX
and a second time for TX but instead of doing 0 1 2 0 1 2 it does
0 0 1 1 2 2.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
---
Static checker stuff.  Untested.

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 3bc244d..3cd223c 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -709,7 +709,7 @@ static ssize_t show_requests(struct device *dev, struct 
device_attribute *attr,
 
n += scnprintf(buf + n, PAGE_SIZE - n,
EP=%02i: TD=%08X %s\n,
-   i % ci-hw_ep_max/2, (u32)req-dma,
+   i % (ci-hw_ep_max / 2), (u32)req-dma,
((i  ci-hw_ep_max/2) ? RX : TX));
 
for (j = 0; j  qSize; j++)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] USB: prevent overlapping access by usb-storage and usbfs

2013-01-20 Thread Sergei Shtylyov

On 20-01-2013 18:40, Sergei Shtylyov wrote:


Also, why add a lock to usb_dump_desc in devices.c?  None of the
routines in that file try to communicate with the device.



That was a part of the original patch. I haven't gone into detail about
what these functions are doing.


   In 2.4 usb_dump_device_strings() called usb_string() which called 
usb_get_string(). This doesn't happen in 2.6 anymore, so you're right, locking 
there is not needed anymore.


WBR, Sergei

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


Re: [patch] usb: gadget: precedence bug in show_requests()

2013-01-20 Thread Sergei Shtylyov

Hello.

On 20-01-2013 18:50, Dan Carpenter wrote:


The mod operation has higher precedence than the divide


  They are of the same priority AFAIR, but that doesn't matter since these 
operations are executed left to right.



but the intent
was to divide first.  It's supposed to count through one time for RX
and a second time for TX but instead of doing 0 1 2 0 1 2 it does
0 0 1 1 2 2.



Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
---
Static checker stuff.  Untested.



diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 3bc244d..3cd223c 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -709,7 +709,7 @@ static ssize_t show_requests(struct device *dev, struct 
device_attribute *attr,

n += scnprintf(buf + n, PAGE_SIZE - n,
EP=%02i: TD=%08X %s\n,
-   i % ci-hw_ep_max/2, (u32)req-dma,
+   i % (ci-hw_ep_max / 2), (u32)req-dma,
((i  ci-hw_ep_max/2) ? RX : TX));

for (j = 0; j  qSize; j++)


WBR, Sergei

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


Re: [PATCH 2/2] CDC_NCM: adding support FLAG_NOARP for Infineon modem platform

2013-01-20 Thread Sergei Shtylyov

Hello.

On 20-01-2013 10:12, Wei Shuai wrote:


Infineon(now Intel) HSPA Modem platform NCM cannot support ARP. we can define a 
new common structure wwan_noarp_info.


   Wrap your lines at 76-80 columns maximum please.


Then more similiar NO ARP devices can be handled easily




Signed-off-by: Wei Shuai cpuw...@gmail.com
---
  drivers/net/usb/cdc_ncm.c |   21 +
  1 files changed, 21 insertions(+), 0 deletions(-)



diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92..2d699b6 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1155,6 +1155,20 @@ static const struct driver_info wwan_info = {
.tx_fixup = cdc_ncm_tx_fixup,
  };

+/* Same as wwan_info, but with IFF_NOARP  */


   FLAG_NOARP, you mean?


+static const struct driver_info wwan_noarp_info = {
+   .description = Mobile Broadband Network Device (NO ARP),
+   .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
+   | FLAG_WWAN | FLAG_NOARP,


WBR, Sergei

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


Re: [patch] usb: gadget: precedence bug in show_requests()

2013-01-20 Thread Dan Carpenter
On Sun, Jan 20, 2013 at 09:10:24PM +0400, Sergei Shtylyov wrote:
 Hello.
 
 On 20-01-2013 18:50, Dan Carpenter wrote:
 
 The mod operation has higher precedence than the divide
 
   They are of the same priority AFAIR, but that doesn't matter since
 these operations are executed left to right.
 

Oh yeah, you're right.  I feel dumb now.  Let me resend with a
different changelog.

regards,
dan carpenter

--
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 v2] usb: gadget: precedence bug in show_requests()

2013-01-20 Thread Dan Carpenter
The intent here was to have parenthesis around the (ci-hw_ep_max / 2)
so that it counts like 0 1 2 0 1 2.  In the current code, the mod
operation happens first so it counts like 0 0 1 1 2 2.

Signed-off-by: Dan Carpenter dan.carpen...@oracle.com
---
v2: fixed the changelog.  mod and divide have the same precedence

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 3bc244d..3cd223c 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -709,7 +709,7 @@ static ssize_t show_requests(struct device *dev, struct 
device_attribute *attr,
 
n += scnprintf(buf + n, PAGE_SIZE - n,
EP=%02i: TD=%08X %s\n,
-   i % ci-hw_ep_max/2, (u32)req-dma,
+   i % (ci-hw_ep_max / 2), (u32)req-dma,
((i  ci-hw_ep_max/2) ? RX : TX));
 
for (j = 0; j  qSize; j++)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: xHCI immediately wakes up Asus P8Z68-V LX in S5

2013-01-20 Thread Ben Hutchings
I finally got enough email out of the way to get back to this:

On Wed, 2012-12-19 at 16:23 -0800, Sarah Sharp wrote:
 On Wed, Dec 19, 2012 at 03:15:09AM +, Ben Hutchings wrote:
[...]
  I set sysctl kernel.printk=8 and recorded the screen during shutdown,
  from which I transcribe the following:
  
  pcieport :00:1c.6: wake-up capability enabled by ACPI
  xhci_hcd :04:00.0: // Halt the HC
  xhci_hcd :04:00.0: xhci_shutdown completed - status = 1
 
 Ok, then the xHCI host controller reported that it did halt
 successfully.  It should not be sending any interrupts or PMEs when it's
 halted.
[...]
  So, as far as I can see this problem is specific to:
  - Sleep in S5
  - Driver loaded
  - Run-time power management disabled
  - No devices or super-speed device plugged in
  
  Any of these avoid the problem:
  - Sleep in S3 or S4
  - Driver unloaded
  - Run-time power management enabled
  - Low-speed device plugged in
 
 Is it any low speed device, or just a mouse?  Does a connected
 keyboard or a USB serial device make the system stay shutdown?

A keyboard has the same effect.  I don't think I have any USB serial
devices to test with.

 The symptoms are pretty bizarre, and I honestly don't know what could be
 the root cause.  I would suggest you try the BIOS update and see if it
 fixes the issue.

Now that I've worked out how to do the update (Asus's Windows utilities
fail to install, but there turns out to be a flash update program inside
the setup program) it does seem to be fixed in the current BIOS version
(version 4003 dated 2012-08-22).  I can't tell for sure whether that's
because of a code change or a configuration change, because *of course*
the flash update program has to erase the configuration sector too. :-/

Ben.

-- 
Ben Hutchings
Never attribute to conspiracy what can adequately be explained by stupidity.



signature.asc
Description: This is a digitally signed message part


Re: [PATCH v5 02/10] USB: Set usb port's DeviceRemovable according acpi information

2013-01-20 Thread Greg KH
On Sun, Jan 20, 2013 at 01:53:31AM +0800, Lan Tianyu wrote:
 ACPI provide _PLD and _UPC aml methods to describe usb port
 visibility and connectability. This patch is to add 
 usb_hub_adjust_DeviceRemovable()
 to adjust usb hub port's DeviceRemovable according ACPI information and 
 invoke it in
 the rh_call_control(). When hub descriptor request is issued at first time,
 usb port device isn't created and usb port is not bound with acpi. So first
 hub descriptor request is not changed based on ACPI information. After usb
 port devices being created, call usb_hub_adjust_DeviceRemovable in the 
 hub_configure()
 and then set hub port's DeviceRemovable according ACPI information and this 
 also works
 for non-root hub.
 
 Acked-by: Alan Stern st...@rowland.harvard.edu
 Signed-off-by: Lan Tianyu tianyu@intel.com
 ---
  drivers/usb/core/hcd.c |4 
  drivers/usb/core/hub.c |   43 +++
  drivers/usb/core/usb.h |3 +++
  3 files changed, 50 insertions(+)
 
 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
 index 5f6da8b..2459896 100644
 --- a/drivers/usb/core/hcd.c
 +++ b/drivers/usb/core/hcd.c
 @@ -619,6 +619,10 @@ nongeneric:
   status = hcd-driver-hub_control (hcd,
   typeReq, wValue, wIndex,
   tbuf, wLength);
 +
 + if (typeReq == GetHubDescriptor)
 + usb_hub_adjust_deviceremovable(hcd-self.root_hub,
 + (struct usb_hub_descriptor *)tbuf);
   break;
  error:
   /* protocol stall on error */
 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
 index f6ff130..f7e1402 100644
 --- a/drivers/usb/core/hub.c
 +++ b/drivers/usb/core/hub.c
 @@ -1513,6 +1513,8 @@ static int hub_configure(struct usb_hub *hub,
   dev_err(hub-intfdev,
   couldn't create port%d device.\n, i + 1);
  
 + usb_hub_adjust_deviceremovable(hdev, hub-descriptor);
 +
   hub_activate(hub, HUB_INIT);
   return 0;
  
 @@ -5193,6 +5195,47 @@ usb_get_hub_port_connect_type(struct usb_device *hdev, 
 int port1)
   return hub-ports[port1 - 1]-connect_type;
  }
  
 +void usb_hub_adjust_deviceremovable(struct usb_device *hdev,
 + struct usb_hub_descriptor *desc)
 +{
 + enum usb_port_connect_type connect_type;
 + int i;
 +
 + if (!hub_is_superspeed(hdev)) {
 + for (i = 1; i = hdev-maxchild; i++) {
 + connect_type = usb_get_hub_port_connect_type(hdev, i);
 +
 + if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
 + u8 mask = 1  (i%8);
 +
 + if (!(desc-u.hs.DeviceRemovable[i/8]  mask)) {
 + dev_dbg(hdev-dev, usb port%d's 
 DeviceRemovable is changed to 1 according to platform information.\n,
 + i);
 + desc-u.hs.DeviceRemovable[i/8] |= mask;
 + }
 + }
 + }
 + } else {
 + u16 port_removable = le16_to_cpu(desc-u.ss.DeviceRemovable);
 +
 + for (i = 1; i = hdev-maxchild; i++) {
 + connect_type = usb_get_hub_port_connect_type(hdev, i);
 +
 + if (connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
 + u16 mask = 1  i;
 +
 + if (!(port_removable  mask)) {
 + dev_dbg(hdev-dev, usb port%d's 
 DeviceRemovable is changed to 1 according to platform information.\n,
 + i);
 + port_removable |= mask;
 + }
 + }
 + }
 +
 + desc-u.ss.DeviceRemovable = cpu_to_le16(port_removable);
 + }
 +}
 +
  #ifdef CONFIG_ACPI
  /**
   * usb_get_hub_port_acpi_handle - Get the usb port's acpi handle
 diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
 index fb7d8fc..31f32cd 100644
 --- a/drivers/usb/core/usb.h
 +++ b/drivers/usb/core/usb.h
 @@ -1,5 +1,6 @@
  #include linux/pm.h
  #include linux/acpi.h
 +#include linux/usb/ch11.h

Minor nit, I hate having .h files include other .h files.

Please just predefine the structure you need here, instead of including
the .h file.

thanks,

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


Re: [PATCH v5 01/10] PM/Qos: Expose dev_pm_qos_flags symbol

2013-01-20 Thread Greg KH
On Sun, Jan 20, 2013 at 01:53:30AM +0800, Lan Tianyu wrote:
 The dev_pm_qos_flags() will be used in the usb core which could be
 compiled as a module. This patch is to export it.
 
 Acked-by: Alan Stern st...@rowland.harvard.edu
 Signed-off-by: Lan Tianyu tianyu@intel.com
 ---
  drivers/base/power/qos.c |1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
 index d213495..3d4d1f8 100644
 --- a/drivers/base/power/qos.c
 +++ b/drivers/base/power/qos.c
 @@ -91,6 +91,7 @@ enum pm_qos_flags_status dev_pm_qos_flags(struct device 
 *dev, s32 mask)
  
   return ret;
  }
 +EXPORT_SYMBOL_GPL(dev_pm_qos_flags);

Care to move this patch to the proper place in the sequence (i.e. right
before the patch that actually needs it?)

thanks,

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


Re: [PATCH V5 0/10] usb: usb port power off mechanism and expose usb port connect type

2013-01-20 Thread Greg KH
On Sun, Jan 20, 2013 at 01:53:29AM +0800, Lan Tianyu wrote:
 Change since v5:
   use EXPORT_SYMBOL_GPL to export dev_pm_qos_flags().
   correct some unnecessary link breaks.   
   Add CONFIG_USB_SUSPEND check around usb_port_runtime_resume() and 
 usb_port_runtime_suspend()

I've applied a few of these, care to redo the series based on the
feedback for the .h file issue?

thanks,

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


Re: [PATCH v2] drivers/usb/host/uhci-* : check buffer length to avoid memory overflow

2013-01-20 Thread Chen Gang
Hello Alan Stern

  When you have time, could you help checking this patch ?

  welcome any reasonable rejections, too.

  thanks.

gchen.


于 2013年01月19日 07:37, Greg KH 写道:
 On Sat, Jan 12, 2013 at 11:18:03PM +0800, Chen Gang wrote:

   for function uhci_sprint_schedule:
 the buffer len is MAX_OUTPUT: 64 * 1024, which may not be enough:
   may loop UHCI_NUMFRAMES times (UHCI_NUMFRAMES is 1024)
   each time of loop may get more than 64 bytes
 so need check the buffer length to avoid memory overflow

   this patch fix it like this:
 at first, make enough room for buffering the exceeding contents
 judge the contents which written whether bigger than buffer length
 if bigger (the exceeding contents will be in the exceeding buffer)
   break current work flow, and return.

   also let the const string contents not seperated in second line.



 Signed-off-by: Chen Gang gang.c...@asianux.com
 ---
  drivers/usb/host/uhci-debug.c |  178 
 +++--
  drivers/usb/host/uhci-hcd.c   |   31 ---
  drivers/usb/host/uhci-q.c |2 +-
  3 files changed, 136 insertions(+), 75 deletions(-)
 
 Alan, any objections to me taking this patch?
 
 thanks,
 
 greg k-h
 
 


-- 
Chen Gang

Asianux Corporation
--
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: [balbi-usb:gadget 19/61] drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct mv_usb_platform_data' has no member named 'phy_init'

2013-01-20 Thread Chao Xie
-Original Message-
From: Felipe Balbi [mailto:ba...@ti.com] 
Sent: Friday, January 18, 2013 8:05 PM
To: kbuild test robot
Cc: Chao Xie; linux-usb@vger.kernel.org; Felipe Balbi
Subject: Re: [balbi-usb:gadget 19/61] drivers/usb/gadget/mv_udc_core.c:1124:16: 
error: 'struct mv_usb_platform_data' has no member named 'phy_init'

On Fri, Jan 18, 2013 at 07:48:14PM +0800, kbuild test robot wrote:
 tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git gadget
 head:   7620f5f22e9317ab26c0fdbdd15c5e9ed972ef89
 commit: 84b140524c107fb4f4fe618509bc067245c9d878 [19/61] usb: phy: 
 mv_usb2: add PHY driver for marvell usb2 controller
 config: make ARCH=x86_64 allmodconfig
 
 All error/warnings:
 
drivers/usb/gadget/mv_udc_core.c: In function 'mv_udc_enable_internal':
  drivers/usb/gadget/mv_udc_core.c:1124:16: error: 'struct 
  mv_usb_platform_data' has no member named 'phy_init'
drivers/usb/gadget/mv_udc_core.c:1125:22: error: 'struct 
 mv_usb_platform_data' has no member named 'phy_init'
drivers/usb/gadget/mv_udc_core.c: In function 'mv_udc_disable_internal':
  drivers/usb/gadget/mv_udc_core.c:1150:17: error: 'struct 
  mv_usb_platform_data' has no member named 'phy_deinit'
drivers/usb/gadget/mv_udc_core.c:1151:14: error: 'struct 
 mv_usb_platform_data' has no member named 'phy_deinit'
 --
drivers/usb/phy/mv_usb2_phy.c: In function 'u2o_set':
drivers/usb/phy/mv_usb2_phy.c:151:2: error: implicit declaration of 
 function 'writel_relaxed' [-Werror=implicit-function-declaration]
drivers/usb/phy/mv_usb2_phy.c: In function 'usb_phy_parse_dt':
  drivers/usb/phy/mv_usb2_phy.c:350:17: warning: cast from pointer to 
  integer of different size [-Wpointer-to-int-cast]
cc1: some warnings being treated as errors

 Chao ? Next week's friday I will send my pull request to Greg with or without 
 your commits.

 cheers


I am formatting and re-test the patches. I will send out today. 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


[RESEND PATCH v5 0/7] Add fully tested id switch and vbus connect detect support for Chipidea

2013-01-20 Thread Peter Chen
Only one typo suggestion from Marek Vasut (change d to D) is added.
At this v5 version.
Anyone who have tested this patchset, please give a tested-by, thanks.

This patchset adds fully tested otg id switch function and
vbus connect/disconnect detection for chipidea driver.
The mainly design of id/vbus handling follows msm otg driver.
I hope the msm usb maintainer can have a look of this patchset,
and give some comments, and move the whole msm usb driver to
chipidea framework if possible in the future.

This patchset is fully tested at i.mx6Q saberlite board.

There is github repo for my chipdiea work:
https://github.com/hzpeterchen/linux-usb.git
branch: master

Peter Chen (7):
  Revert USB: chipidea: add vbus detect for udc
  usb: chipidea: add otg file
  usb: chipidea: add otg id switch and vbus connect/disconnect detect
  usb: chipidea: consolidate ci_role_driver's API for both roles
  usb: chipidea: udc: add pullup/pulldown dp at hw_device_state
  usb: chipidea: udc: retire the flag CI13_PULLUP_ON_VBUS
  usb: chipidea: imx: add internal vbus regulator control

 drivers/usb/chipidea/Makefile  |2 +-
 drivers/usb/chipidea/bits.h|   10 ++
 drivers/usb/chipidea/ci.h  |   30 ++-
 drivers/usb/chipidea/ci13xxx_imx.c |   81 +
 drivers/usb/chipidea/ci13xxx_msm.c |1 -
 drivers/usb/chipidea/core.c|  178 +++-
 drivers/usb/chipidea/host.c|2 +
 drivers/usb/chipidea/otg.c |   68 ++
 drivers/usb/chipidea/otg.h |9 ++
 drivers/usb/chipidea/udc.c |  101 ++---
 include/linux/usb/chipidea.h   |1 -
 11 files changed, 382 insertions(+), 101 deletions(-)
 create mode 100644 drivers/usb/chipidea/otg.c
 create mode 100644 drivers/usb/chipidea/otg.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


[RESEND PATCH v5 1/7] Revert USB: chipidea: add vbus detect for udc

2013-01-20 Thread Peter Chen
vbus register is at otgsc, and vbus detect does not belong
to device function. Revert this patch, and will move
vbus detect function to drivers/usb/chipidea/udc.c

This reverts commit 8c4fc031954b4eb72daf13d3c907a985a3eee208.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/ci.h  |1 -
 drivers/usb/chipidea/udc.c |   39 +--
 2 files changed, 1 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index e25d126..d738603 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -139,7 +139,6 @@ struct ci13xxx {
enum ci_rolerole;
boolis_otg;
struct work_struct  work;
-   struct work_struct  vbus_work;
struct workqueue_struct *wq;
 
struct dma_pool *qh_pool;
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 2f45bba..d214448 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -305,18 +305,6 @@ static u32 hw_test_and_clear_intr_active(struct ci13xxx 
*ci)
return reg;
 }
 
-static void hw_enable_vbus_intr(struct ci13xxx *ci)
-{
-   hw_write(ci, OP_OTGSC, OTGSC_AVVIS, OTGSC_AVVIS);
-   hw_write(ci, OP_OTGSC, OTGSC_AVVIE, OTGSC_AVVIE);
-   queue_work(ci-wq, ci-vbus_work);
-}
-
-static void hw_disable_vbus_intr(struct ci13xxx *ci)
-{
-   hw_write(ci, OP_OTGSC, OTGSC_AVVIE, 0);
-}
-
 /**
  * hw_test_and_clear_setup_guard: test  clear setup guard (execute without
  *interruption)
@@ -383,16 +371,6 @@ static int hw_usb_reset(struct ci13xxx *ci)
return 0;
 }
 
-static void vbus_work(struct work_struct *work)
-{
-   struct ci13xxx *ci = container_of(work, struct ci13xxx, vbus_work);
-
-   if (hw_read(ci, OP_OTGSC, OTGSC_AVV))
-   usb_gadget_vbus_connect(ci-gadget);
-   else
-   usb_gadget_vbus_disconnect(ci-gadget);
-}
-
 /**
  * UTIL block
  */
@@ -1392,7 +1370,6 @@ static int ci13xxx_vbus_session(struct usb_gadget 
*_gadget, int is_active)
if (is_active) {
pm_runtime_get_sync(_gadget-dev);
hw_device_reset(ci, USBMODE_CM_DC);
-   hw_enable_vbus_intr(ci);
hw_device_state(ci, ci-ep0out-qh.dma);
} else {
hw_device_state(ci, 0);
@@ -1567,10 +1544,8 @@ static int ci13xxx_start(struct usb_gadget *gadget,
pm_runtime_get_sync(ci-gadget.dev);
if (ci-platdata-flags  CI13XXX_PULLUP_ON_VBUS) {
if (ci-vbus_active) {
-   if (ci-platdata-flags  CI13XXX_REGS_SHARED) {
+   if (ci-platdata-flags  CI13XXX_REGS_SHARED)
hw_device_reset(ci, USBMODE_CM_DC);
-   hw_enable_vbus_intr(ci);
-   }
} else {
pm_runtime_put_sync(ci-gadget.dev);
goto done;
@@ -1676,13 +1651,6 @@ static irqreturn_t udc_irq(struct ci13xxx *ci)
} else {
retval = IRQ_NONE;
}
-
-   intr = hw_read(ci, OP_OTGSC, ~0);
-   hw_write(ci, OP_OTGSC, ~0, intr);
-
-   if (intr  (OTGSC_AVVIE  OTGSC_AVVIS))
-   queue_work(ci-wq, ci-vbus_work);
-
spin_unlock(ci-lock);
 
return retval;
@@ -1758,7 +1726,6 @@ static int udc_start(struct ci13xxx *ci)
retval = hw_device_reset(ci, USBMODE_CM_DC);
if (retval)
goto put_transceiver;
-   hw_enable_vbus_intr(ci);
}
 
retval = device_register(ci-gadget.dev);
@@ -1821,9 +1788,6 @@ static void udc_stop(struct ci13xxx *ci)
if (ci == NULL)
return;
 
-   hw_disable_vbus_intr(ci);
-   cancel_work_sync(ci-vbus_work);
-
usb_del_gadget_udc(ci-gadget);
 
destroy_eps(ci);
@@ -1864,7 +1828,6 @@ int ci_hdrc_gadget_init(struct ci13xxx *ci)
rdrv-irq   = udc_irq;
rdrv-name  = gadget;
ci-roles[CI_ROLE_GADGET] = rdrv;
-   INIT_WORK(ci-vbus_work, vbus_work);
 
return 0;
 }
-- 
1.7.0.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


[RESEND PATCH v5 2/7] usb: chipidea: add otg file

2013-01-20 Thread Peter Chen
Implement struct usb_otg, In that way, calling otg_set_peripheral
will not be failed at udc.c.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/Makefile |2 +-
 drivers/usb/chipidea/ci.h |2 +
 drivers/usb/chipidea/otg.c|   60 +
 drivers/usb/chipidea/otg.h|6 
 4 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index d92ca32..11f513c 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o
 
-ci_hdrc-y  := core.o
+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
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index d738603..8702871 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -129,6 +129,7 @@ struct hw_bank {
  * @vbus_active: is VBUS active
  * @transceiver: pointer to USB PHY, if any
  * @hcd: pointer to usb_hcd for ehci host driver
+ * @otg: for otg support
  */
 struct ci13xxx {
struct device   *dev;
@@ -164,6 +165,7 @@ struct ci13xxx {
boolglobal_phy;
struct usb_phy  *transceiver;
struct usb_hcd  *hcd;
+   struct usb_otg  otg;
 };
 
 static inline struct ci_role_driver *ci_role(struct ci13xxx *ci)
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
new file mode 100644
index 000..7dea3b3
--- /dev/null
+++ b/drivers/usb/chipidea/otg.c
@@ -0,0 +1,60 @@
+/*
+ * otg.c - ChipIdea USB IP core OTG driver
+ *
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * Author: Peter Chen
+ *
+ * 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.
+ */
+
+#include linux/platform_device.h
+#include linux/module.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/usb/gadget.h
+#include linux/usb/otg.h
+#include linux/usb/chipidea.h
+
+#include ci.h
+#include udc.h
+#include bits.h
+#include host.h
+#include debug.h
+
+static int ci_otg_set_peripheral(struct usb_otg *otg,
+   struct usb_gadget *periph)
+{
+   otg-gadget = periph;
+
+   return 0;
+}
+
+static int ci_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
+{
+   otg-host = host;
+
+   return 0;
+}
+
+/**
+ * ci_hdrc_otg_init - initialize device related bits
+ * ci: the controller
+ *
+ * This function create otg struct, if the device can switch between
+ * device and host.
+ */
+int ci_hdrc_otg_init(struct ci13xxx *ci)
+{
+   /* Useless at current */
+   ci-otg.set_peripheral = ci_otg_set_peripheral;
+   ci-otg.set_host = ci_otg_set_host;
+   if (!IS_ERR_OR_NULL(ci-transceiver))
+   ci-transceiver-otg = ci-otg;
+
+   return 0;
+}
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
new file mode 100644
index 000..b4c6b3e
--- /dev/null
+++ b/drivers/usb/chipidea/otg.h
@@ -0,0 +1,6 @@
+#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H
+#define __DRIVERS_USB_CHIPIDEA_OTG_H
+
+int ci_hdrc_otg_init(struct ci13xxx *ci);
+
+#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
-- 
1.7.0.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


[RESEND PATCH v5 3/7] usb: chipidea: add otg id switch and vbus connect/disconnect detect

2013-01-20 Thread Peter Chen
The main design flow is the same with msm otg driver, that is the id and
vbus interrupt are handled at core driver, others are handled by
individual drivers.

- At former design, when switch usb role from device-host, it will call
udc_stop, it will remove the gadget driver, so when switch role
from host-device, it can't add gadget driver any more.
At new design, when role switch occurs, the gadget just calls
usb_gadget_vbus_disconnect/usb_gadget_vbus_connect as well as
reset controller, it will not free any device/gadget structure

- Add vbus connect and disconnect to core interrupt handler, it can
notify udc driver by calling usb_gadget_vbus_disconnect
/usb_gadget_vbus_connect.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/bits.h |   10 +++
 drivers/usb/chipidea/ci.h   |8 ++-
 drivers/usb/chipidea/core.c |  177 ++
 drivers/usb/chipidea/otg.c  |   28 +---
 drivers/usb/chipidea/otg.h  |3 +
 drivers/usb/chipidea/udc.c  |2 +
 6 files changed, 200 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 050de85..ba9c6ef 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -65,11 +65,21 @@
 #define OTGSC_ASVIS  BIT(18)
 #define OTGSC_BSVIS  BIT(19)
 #define OTGSC_BSEIS  BIT(20)
+#define OTGSC_1MSIS  BIT(21)
+#define OTGSC_DPIS   BIT(22)
 #define OTGSC_IDIE   BIT(24)
 #define OTGSC_AVVIE  BIT(25)
 #define OTGSC_ASVIE  BIT(26)
 #define OTGSC_BSVIE  BIT(27)
 #define OTGSC_BSEIE  BIT(28)
+#define OTGSC_1MSIE  BIT(29)
+#define OTGSC_DPIE   BIT(30)
+#define OTGSC_INT_EN_BITS  (OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \
+   | OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \
+   | OTGSC_DPIE)
+#define OTGSC_INT_STATUS_BITS  (OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS \
+   | OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \
+   | OTGSC_DPIS)
 
 /* USBMODE */
 #define USBMODE_CM(0x03UL   0)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 8702871..325d790 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -130,6 +130,7 @@ struct hw_bank {
  * @transceiver: pointer to USB PHY, if any
  * @hcd: pointer to usb_hcd for ehci host driver
  * @otg: for otg support
+ * @events: events for otg, and handled at ci_role_work
  */
 struct ci13xxx {
struct device   *dev;
@@ -140,6 +141,7 @@ struct ci13xxx {
enum ci_rolerole;
boolis_otg;
struct work_struct  work;
+   struct delayed_work dwork;
struct workqueue_struct *wq;
 
struct dma_pool *qh_pool;
@@ -165,7 +167,9 @@ struct ci13xxx {
boolglobal_phy;
struct usb_phy  *transceiver;
struct usb_hcd  *hcd;
-   struct usb_otg  otg;
+   struct usb_otg  otg;
+   boolid_event;
+   boolb_sess_valid_event;
 };
 
 static inline struct ci_role_driver *ci_role(struct ci13xxx *ci)
@@ -314,4 +318,6 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode);
 
 u8 hw_port_test_get(struct ci13xxx *ci);
 
+void ci_handle_vbus_change(struct ci13xxx *ci);
+
 #endif /* __DRIVERS_USB_CHIPIDEA_CI_H */
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index aebf695..f8f8484 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -73,6 +73,7 @@
 #include bits.h
 #include host.h
 #include debug.h
+#include otg.h
 
 /* Controller register map */
 static uintptr_t ci_regs_nolpm[] = {
@@ -199,6 +200,14 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem 
*base)
if (ci-hw_ep_max  ENDPT_MAX)
return -ENODEV;
 
+   /* Disable all interrupts bits */
+   hw_write(ci, OP_USBINTR, 0x, 0);
+   ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS);
+
+   /* Clear all interrupts status bits*/
+   hw_write(ci, OP_USBSTS, 0x, 0x);
+   ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS);
+
dev_dbg(ci-dev, ChipIdea HDRC found, lpm: %d; cap: %p op: %p\n,
ci-hw_bank.lpm, ci-hw_bank.cap, ci-hw_bank.op);
 
@@ -265,24 +274,124 @@ static enum ci_role ci_otg_role(struct ci13xxx *ci)
 }
 
 /**
- * ci_role_work - perform role changing based on ID pin
- * @work: work struct
+ * hw_wait_reg: wait the register value
+ *
+ * Sometimes, it needs to wait register value before going on.
+ * Eg, when switch to device mode, the vbus value should be lower
+ * than OTGSC_BSV before connects to host.
+ *
+ * @ci: the controller
+ * @reg: register index
+ * @mask: mast bit
+ 

[RESEND PATCH v5 6/7] usb: chipidea: udc: retire the flag CI13_PULLUP_ON_VBUS

2013-01-20 Thread Peter Chen
(change CI13XXX to CI13 to avoid junk email check)
Now, we have handled vbus session in core driver when the
vbus interrupt occurs, so our pullup operations are all
according to vbus.
Of cource, the software can still call .pullup when device connects
to host if it wants to connect/disconnect with host.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/ci13xxx_imx.c |1 -
 drivers/usb/chipidea/ci13xxx_msm.c |1 -
 drivers/usb/chipidea/udc.c |   23 ---
 include/linux/usb/chipidea.h   |1 -
 4 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 8c29122..3b91ff4 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -88,7 +88,6 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 static struct ci13xxx_platform_data ci13xxx_imx_platdata  = {
.name   = ci13xxx_imx,
.flags  = CI13XXX_REQUIRE_TRANSCEIVER |
- CI13XXX_PULLUP_ON_VBUS |
  CI13XXX_DISABLE_STREAMING,
.capoffset  = DEF_CAPOFFSET,
 };
diff --git a/drivers/usb/chipidea/ci13xxx_msm.c 
b/drivers/usb/chipidea/ci13xxx_msm.c
index 7d16681..5755ee8 100644
--- a/drivers/usb/chipidea/ci13xxx_msm.c
+++ b/drivers/usb/chipidea/ci13xxx_msm.c
@@ -49,7 +49,6 @@ static struct ci13xxx_platform_data ci13xxx_msm_platdata = {
.name   = ci13xxx_msm,
.flags  = CI13XXX_REGS_SHARED |
  CI13XXX_REQUIRE_TRANSCEIVER |
- CI13XXX_PULLUP_ON_VBUS |
  CI13XXX_DISABLE_STREAMING,
 
.notify_event   = ci13xxx_msm_notify_event,
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index aab20bb..dcac77c 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1360,9 +1360,6 @@ static int ci13xxx_vbus_session(struct usb_gadget 
*_gadget, int is_active)
unsigned long flags;
int gadget_ready = 0;
 
-   if (!(ci-platdata-flags  CI13XXX_PULLUP_ON_VBUS))
-   return -EOPNOTSUPP;
-
spin_lock_irqsave(ci-lock, flags);
ci-vbus_active = is_active;
if (ci-driver)
@@ -1426,8 +1423,7 @@ static int ci13xxx_pullup(struct usb_gadget *_gadget, int 
is_on)
 {
struct ci13xxx *ci = container_of(_gadget, struct ci13xxx, gadget);
 
-   if ((ci-platdata-flags  CI13XXX_PULLUP_ON_VBUS) 
-   !ci-vbus_active)
+   if (!ci-vbus_active)
return -ENOTSUPP;
 
if (is_on)
@@ -1551,14 +1547,12 @@ static int ci13xxx_start(struct usb_gadget *gadget,
 
ci-driver = driver;
pm_runtime_get_sync(ci-gadget.dev);
-   if (ci-platdata-flags  CI13XXX_PULLUP_ON_VBUS) {
-   if (ci-vbus_active) {
-   if (ci-platdata-flags  CI13XXX_REGS_SHARED)
-   hw_device_reset(ci, USBMODE_CM_DC);
-   } else {
-   pm_runtime_put_sync(ci-gadget.dev);
-   goto done;
-   }
+   if (ci-vbus_active) {
+   if (ci-platdata-flags  CI13XXX_REGS_SHARED)
+   hw_device_reset(ci, USBMODE_CM_DC);
+   } else {
+   pm_runtime_put_sync(ci-gadget.dev);
+   goto done;
}
 
retval = hw_device_state(ci, ci-ep0out-qh.dma);
@@ -1581,8 +1575,7 @@ static int ci13xxx_stop(struct usb_gadget *gadget,
 
spin_lock_irqsave(ci-lock, flags);
 
-   if (!(ci-platdata-flags  CI13XXX_PULLUP_ON_VBUS) ||
-   ci-vbus_active) {
+   if (ci-vbus_active) {
hw_device_state(ci, 0);
if (ci-platdata-notify_event)
ci-platdata-notify_event(ci,
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 544825d..37821b3 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -17,7 +17,6 @@ struct ci13xxx_platform_data {
unsigned longflags;
 #define CI13XXX_REGS_SHAREDBIT(0)
 #define CI13XXX_REQUIRE_TRANSCEIVERBIT(1)
-#define CI13XXX_PULLUP_ON_VBUS BIT(2)
 #define CI13XXX_DISABLE_STREAMING  BIT(3)
 
 #define CI13XXX_CONTROLLER_RESET_EVENT 0
-- 
1.7.0.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 V5 0/10] usb: usb port power off mechanism and expose usb port connect type

2013-01-20 Thread Lan Tianyu
2013/1/21 Greg KH gre...@linuxfoundation.org

 On Sun, Jan 20, 2013 at 01:53:29AM +0800, Lan Tianyu wrote:
  Change since v5:
use EXPORT_SYMBOL_GPL to export dev_pm_qos_flags().
correct some unnecessary link breaks.
Add CONFIG_USB_SUSPEND check around usb_port_runtime_resume() and
  usb_port_runtime_suspend()

 I've applied a few of these, care to redo the series based on the
 feedback for the .h file issue?
Ok. I wll update soon.

 thanks,

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




--
Best regards
Tianyu Lan
--
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 v2 1/1] usb: chipidea: imx: Add system suspend/resume API

2013-01-20 Thread Peter Chen
During the system suspend/resume procedure, the USB also
needs to go suspend/resume procedure, this patch adds
related APIs. It is tested at i.mx6q sabrelite. Meanwhile,
it fixes the bug that the USB will out of work after
system suspend/resume.

Signed-off-by: Peter Chen peter.c...@freescale.com
Tested-by: Shawn Guo shawn@linaro.org
---
Changes for v2:
- Add tested-by from Shawn Guo
- Using dev_get_drvdata to get driver data

 drivers/usb/chipidea/bits.h|1 +
 drivers/usb/chipidea/ci13xxx_imx.c |   59 
 2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index ba9c6ef..d1467bb 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -47,6 +47,7 @@
 #define PORTSC_FPRBIT(6)
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
+#define PORTSC_PHCD   BIT(23) /* phy suspend mode */
 #define PORTSC_PTC(0x0FUL  16)
 
 /* DEVLC */
diff --git a/drivers/usb/chipidea/ci13xxx_imx.c 
b/drivers/usb/chipidea/ci13xxx_imx.c
index 342eab0..ff11cee 100644
--- a/drivers/usb/chipidea/ci13xxx_imx.c
+++ b/drivers/usb/chipidea/ci13xxx_imx.c
@@ -25,6 +25,7 @@
 #include linux/mfd/syscon.h
 
 #include ci.h
+#include bits.h
 #include ci13xxx_imx.h
 
 #define pdev_to_phy(pdev) \
@@ -321,6 +322,61 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int ci13xxx_imx_suspend(struct device *dev)
+{
+   struct ci13xxx_imx_data *data = dev_get_drvdata(dev);
+   struct platform_device *plat_ci;
+   struct ci13xxx  *ci;
+
+   plat_ci = data-ci_pdev;
+   ci = platform_get_drvdata(plat_ci);
+
+   hw_write(ci, OP_PORTSC, PORTSC_PHCD, PORTSC_PHCD);
+
+   if (data-phy)
+   usb_phy_set_suspend(data-phy, 1);
+
+   clk_disable_unprepare(data-clk);
+
+   return 0;
+}
+
+static int ci13xxx_imx_resume(struct device *dev)
+{
+   int ret;
+   struct ci13xxx_imx_data *data = dev_get_drvdata(dev);
+   struct platform_device *plat_ci;
+   struct ci13xxx  *ci;
+
+   plat_ci = data-ci_pdev;
+   ci = platform_get_drvdata(plat_ci);
+
+   ret = clk_prepare_enable(data-clk);
+   if (ret) {
+   dev_err(dev,
+   Failed to prepare or enable clock, err=%d\n, ret);
+   return ret;
+   }
+
+   if (hw_read(ci, OP_PORTSC, PORTSC_PHCD)) {
+   hw_write(ci, OP_PORTSC, PORTSC_PHCD, 0);
+   /* Some clks sync between Controller and USB PHY */
+   mdelay(1);
+   }
+
+   if (data-phy)
+   usb_phy_set_suspend(data-phy, 0);
+
+   return ret;
+}
+
+static const struct dev_pm_ops ci13xxx_imx_pm_ops = {
+   .suspend= ci13xxx_imx_suspend,
+   .resume = ci13xxx_imx_resume,
+};
+#endif
+
 static const struct of_device_id ci13xxx_imx_dt_ids[] = {
{ .compatible = fsl,imx27-usb, },
{ /* sentinel */ }
@@ -334,6 +390,9 @@ static struct platform_driver ci13xxx_imx_driver = {
.name = imx_usb,
.owner = THIS_MODULE,
.of_match_table = ci13xxx_imx_dt_ids,
+#ifdef CONFIG_PM
+   .pm = ci13xxx_imx_pm_ops,
+#endif
 },
 };
 
-- 
1.7.0.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: [RESEND PATCH v5 0/7] Add fully tested id switch and vbus connect detect support for Chipidea

2013-01-20 Thread Peter Chen
gre...@linuxfoundation.org, ba...@ti.com, st...@rowland.harvard.edu
Cc: linux-usb@vger.kernel.org, linux-arm-ker...@lists.infradead.org,
feste...@gmail.com, ma...@denx.de, m...@genesi-usa.com,
shawn@linaro.org, ker...@pengutronix.de, m...@pengutronix.de,
m.grzesc...@pengutronix.de, maxime.rip...@free-electrons.com
Bcc: 
Subject: Re: [RESEND PATCH v5 0/7] Add fully tested id switch and vbus
 connect detect support for Chipidea
Reply-To: 
In-Reply-To: 1358733418-17969-1-git-send-email-peter.c...@freescale.com

Hi Alex,

Would you help to review recently chipidea patchsets, including
mine and Michael Grzeschik/Marc Kleine-Budde's. Alan may delete
CONFIG_USB_SUSPEND at next release (v3.9?), in that case, the 
imx chipidea driver will be out of work. So, I have worked
on power management for chipidea recently, this work is based
on the patchsets I mentioned above.

Thanks

On Mon, Jan 21, 2013 at 09:56:51AM +0800, Peter Chen wrote:
 Only one typo suggestion from Marek Vasut (change d to D) is added.
 At this v5 version.
 Anyone who have tested this patchset, please give a tested-by, thanks.
 
 This patchset adds fully tested otg id switch function and
 vbus connect/disconnect detection for chipidea driver.
 The mainly design of id/vbus handling follows msm otg driver.
 I hope the msm usb maintainer can have a look of this patchset,
 and give some comments, and move the whole msm usb driver to
 chipidea framework if possible in the future.
 
 This patchset is fully tested at i.mx6Q saberlite board.
 
 There is github repo for my chipdiea work:
 https://github.com/hzpeterchen/linux-usb.git
 branch: master
 
 Peter Chen (7):
   Revert USB: chipidea: add vbus detect for udc
   usb: chipidea: add otg file
   usb: chipidea: add otg id switch and vbus connect/disconnect detect
   usb: chipidea: consolidate ci_role_driver's API for both roles
   usb: chipidea: udc: add pullup/pulldown dp at hw_device_state
   usb: chipidea: udc: retire the flag CI13_PULLUP_ON_VBUS
   usb: chipidea: imx: add internal vbus regulator control
 
  drivers/usb/chipidea/Makefile  |2 +-
  drivers/usb/chipidea/bits.h|   10 ++
  drivers/usb/chipidea/ci.h  |   30 ++-
  drivers/usb/chipidea/ci13xxx_imx.c |   81 +
  drivers/usb/chipidea/ci13xxx_msm.c |1 -
  drivers/usb/chipidea/core.c|  178 
 +++-
  drivers/usb/chipidea/host.c|2 +
  drivers/usb/chipidea/otg.c |   68 ++
  drivers/usb/chipidea/otg.h |9 ++
  drivers/usb/chipidea/udc.c |  101 ++---
  include/linux/usb/chipidea.h   |1 -
  11 files changed, 382 insertions(+), 101 deletions(-)
  create mode 100644 drivers/usb/chipidea/otg.c
  create mode 100644 drivers/usb/chipidea/otg.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
 

-- 

Best Regards,
Peter Chen

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


RE: USB: storage: optimize the matching rules and support new switch command for Huawei USB storage devices

2013-01-20 Thread Fangxiaozhi (Franko)
Dear Greg:

 -Original Message-
 From: Greg KH [mailto:gre...@linuxfoundation.org]
 Sent: Saturday, January 19, 2013 7:42 AM
 To: Fangxiaozhi (Franko)
 Cc: linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org; Xueguiying 
 (Zihan);
 Linlei (Lei Lin); Yili (Neil); Wangyuhua (Roger, Credit); Huqiao (C); 
 ba...@ti.com;
 mdharm-...@one-eyed-alien.net; sebast...@breakpoint.cc
 Subject: Re: USB: storage: optimize the matching rules and support new switch
 command for Huawei USB storage devices
 
 On Mon, Jan 14, 2013 at 10:55:48AM +0800, fangxiaozhi 00110321 wrote:
 
  From: fangxiaozhi huana...@huawei.com
 
  1. Optimize the matching rules with new macro for Huawei USB storage
 devices, to avoid to load USB storage driver for the modem interface
 with Huawei devices.
  2. Add to support new switch command for new Huawei USB dongles.
 
  Signed-off-by: fangxiaozhi huana...@huawei.com
 
 Next time, please always use the scripts/checkpatch.pl tool to find any
 problems you might have made in your patch (you had trailing whitespace in
 this one, which I have fixed.)
 
-Yes, I have checked my patch with scripts/checkpatch.pl tool before 
submitting.
-For this trailing whitespace error, I think that it is better readable to 
leave whitespace in our patch code. Isn't it?

 Also, you might want to use git, it makes creating the patches easier, that 
 way
 you don't end up with lines in the patch like this one:
 
  Binary files linux-3.8-rc3_orig/drivers/usb/storage/initializers.o and
  linux-3.8-rc3/drivers/usb/storage/initializers.o differ
 
 thanks,
 
 greg k-h

Best Regards,
Franko Fang


Not enough resource for old configuration after USB bus reset

2013-01-20 Thread Soar Hung
Hi everybody,

We ported the Linux and related drivers to our embedded 
system(a customized board), and using TUSB7340 as our 
host controller.

We also write a usb interface driver for the tested device, 
the enumeration and bulk in/out transfers work fine.

But we encounter problem when we keep doing the bus reset to 
the same device, the HC will fail to complete the recovering 
old configuration after 128th usb bus reset and shows the 
message not enough bandwidth.

When we repeat the same operation to another similar device, 
HC fails at 1020th usb bus reset.

In addition to the bus reset, if we plug and unplug the device 
repeatedly, the host also fails to complete the set configuration.

Below are logs: 
(ep1 and ep2 are bulk endpoint, 
the kernel version is 3.0.30+,
during the test, only one device is attached.)

1 Bus reset
usb 1-2: reset high speed USB device number 2 using xhci_hcd
xhci_hcd :01:00.0: WARN: short transfer on control ep
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb90e0
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb910c
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb9138
usb 1-2: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 micros
usb 1-2: ep 0x2 - rounding interval to 32768 microframes, ep desc says 0 microfs
[FT] skel_post_reset
[FT]usb_reset_device, result 0

... 

2~127 are the same with 1

...

[FT] skel_pre_reset
128 Bus reset
usb 1-2: reset high speed USB device number 2 using xhci_hcd
xhci_hcd :01:00.0: WARN: short transfer on control ep
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb90e0
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb910c
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb9138
usb 1-2: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 micros
usb 1-2: ep 0x2 - rounding interval to 32768 microframes, ep desc says 0 microfs
usb 1-2: Not enough bandwidth for new device state.
usb 1-2: Busted HC?  Not enough HCD resources for old configuration.
[FT] skel_post_reset
[FT]usb_reset_device, result -19
usb 1-2: USB disconnect, device number 2
[FT] skel_disconnect
skeleton 1-2:1.0: [FT] USB Skeleton #192 now disconnected
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb90e0
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb910c
xhci_hcd :01:00.0: xHCI xhci_drop_endpoint called with disabled ep 81fb9138
[USB_CORE] generic_disconnect
usb 1-2: new high speed USB device number 3 using xhci_hcd
xhci_hcd :01:00.0: WARN: short transfer on control ep
xhci_hcd :01:00.0: WARN: short transfer on control ep
xhci_hcd :01:00.0: WARN: short transfer on control ep
xhci_hcd :01:00.0: WARN: short transfer on control ep
[USB_CORE] generic_probe, force select config #1
usb 1-2: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 micros
usb 1-2: ep 0x2 - rounding interval to 32768 microframes, ep desc says 0 microfs
usb 1-2: Not enough bandwidth for new device state.
usb 1-2: can't set config #1, error -28

Below are part of sources (modify from linux kernel usb skeleton.c)

We register a char device to system, and wrtie a user-space application use
ioctl to call the _usbft_bus_reset().

static int skel_pre_reset(struct usb_interface *intf)
{
struct usb_skel *dev = usb_get_intfdata(intf);

printk(KERN_INFO [FT] skel_pre_reset\n);

mutex_lock(dev-io_mutex);

return 0;
}

static int skel_post_reset(struct usb_interface *intf)
{
struct usb_skel *dev = usb_get_intfdata(intf);

printk(KERN_INFO [FT] skel_post_reset\n);

mutex_unlock(dev-io_mutex);

return 0;
}

static long _usbft_bus_reset(struct file *filp)
{
struct usb_skel *dev;
long result = 0;

printk(KERN_DEBUG [FT] Bus Reset\n);
dev = filp-private_data;

result = usb_lock_device_for_reset(dev-udev, NULL);
printk(KERN_DEBUG [FT]usb_lock_device_for_reset, result %ld\n, 
result);
if(result != 0)
{
return result;
}

result = usb_reset_device(dev-udev);
printk(KERN_INFO [FT]usb_reset_device, result %ld\n, result);

// release device lock
printk(KERN_DEBUG [FT]device_unlock\n);
device_unlock((dev-udev-dev));

return result;
}

Does anybody has the same experience or some guide and 
would kindly share with us?

Thanks for your reading and helping.

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


Re: [PATCH 2/2] CDC_NCM: adding support FLAG_NOARP for Infineon modem platform

2013-01-20 Thread David Miller
From: Wei Shuai cpuw...@gmail.com
Date: Mon, 21 Jan 2013 10:20:22 +0800

 The main problem is that these devices don't support ethernet.

He's saying your comment is referring to the wrong thing,
rather than saying anything against what your change is
doing.

Read his feedback carefully:

 +/* Same as wwan_info, but with IFF_NOARP  */

 FLAG_NOARP, you mean?

He's saying your commnet is talking about FLAG_NOARP rather
than what the core code does with this flag, which is
translate into setting IFF_NOARP on the net device.

--
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] usbnet: pegasus: set wakeup enable in set_wol

2013-01-20 Thread David Miller
From: Ming Lei ming@canonical.com
Date: Sat, 19 Jan 2013 19:32:01 +0800

 This patch calls device_set_wakeup_enable() inside set_wol
 callback, so that turning on WOL from user mode utility
 can make the 'wakeup' of pegasus device to be enabled, then
 remote wakeup may be enabled before putting into sleep.
 
 Cc: Sarah Sharp sarah.a.sh...@linux.intel.com
 Cc: Petko Manolov pet...@users.sourceforge.net
 Signed-off-by: Ming Lei ming@canonical.com

Applied to net-next, thanks Ming.
--
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: Not enough resource for old configuration after USB bus reset

2013-01-20 Thread Peter Stuge
Soar Hung wrote:
 We ported the Linux and related drivers to our embedded 
 system(a customized board), and using TUSB7340 as our 
 host controller.
 
 We also write a usb interface driver for the tested device, 
 the enumeration and bulk in/out transfers work fine.
 
 But we encounter problem
..
 Does anybody has the same experience or some guide and 
 would kindly share with us?

It's basically impossible for anyone to help you in any way unless   
you either share the complete and full kernel source code that you 
are using, or reproduce the error with a combination of hardware and
software that others who will do the debugging also have access to.


//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: [PATCH v3 0/2] Adding USB 3.0 DRD-phy support for exynos5250

2013-01-20 Thread Vivek Gautam
Hi Felipe,


On Mon, Jan 14, 2013 at 6:29 PM, Vivek Gautam gautam.vi...@samsung.com wrote:
 Changes from v2:
  - Renaming 'samsung-usbphy.c' driver to 'samsung-usb2.c' indicating
usb 2.0 phy controller's driver for Samsung's SoCs.
  - Moving the register definitions and strcuture definitions to
common header file 'samsung-usbphy.h' to be used across
usb 2.0 and usb 3.0 phy.
  - Keeping common exported function definitions in samsung-usbphy.c
which can be used across usb 2.0 and usb 3.0 phy.
  - Writting separate driver file for Samsung's USB 3.0 phy controller.
and making it dependent on USB_DWC3.


Is the re-organization being done here fine as per requirements for
separate drivers for usb 2.0 type PHY and usb 3.0 type PHY ?

 Rebased on top of usb-next followed by following patches/patch-threads:
 -- [PATCH v9 1/2] usb: phy: samsung: Introducing usb phy driver for 
 hsotg
 -- [PATCH] usb: phy: samsung: Add support to set pmu isolation 
 (version 6)
 -- [PATCH v6 0/4] Adding usb2.0 host-phy support for exynos5250

 Changes form v1:
  - Moved architecture related patch out of this patch-set.
  - Replaced unnecessary multi-line macro definitions by
single line definitions.
  - Creating new data structure for USB 3.0 phy type and embedding
it in 'samsung_usbphy' structure.
  - Adding a flag in 'samsung_usbphy' structure to check if device
has usb 3.0 type phy or not.
  - Restructuring probe sequence for USB 3.0 phy, such that we are
initializing only when device has usb3.0 type phy.

 Vivek Gautam (2):
   usb: phy: samsung: Common out the generic stuff
   usb: phy: samsung: Add PHY support for USB 3.0 controller

  drivers/usb/phy/Kconfig  |8 +
  drivers/usb/phy/Makefile |3 +-
  drivers/usb/phy/samsung-usb2.c   |  511 +++
  drivers/usb/phy/samsung-usb3.c   |  349 +++
  drivers/usb/phy/samsung-usbphy.c |  713 
 +-
  drivers/usb/phy/samsung-usbphy.h |  328 +
  6 files changed, 1205 insertions(+), 707 deletions(-)
  create mode 100644 drivers/usb/phy/samsung-usb2.c
  create mode 100644 drivers/usb/phy/samsung-usb3.c
  create mode 100644 drivers/usb/phy/samsung-usbphy.h




-- 
Thanks  Regards
Vivek
--
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