Re: [PATCH v2] usb: introduce OTG 2.0 related kernel feature and API.

2015-03-26 Thread Peter Chen
On Thu, Mar 26, 2015 at 11:21:43AM +0800, Macpaul Lin wrote:
> Introduce kernel feature CONFIG_USB_OTG20 and related
> gadget_is_otg20() API for supporting OTG20 compliant
> drivers.
> This patch also updated usb_otg_descritpor.
> 
> Signed-off-by: Macpaul Lin 
> ---
>  drivers/usb/core/Kconfig |  9 +
>  include/linux/usb/gadget.h   | 24 
>  include/uapi/linux/usb/ch9.h |  4 
>  3 files changed, 37 insertions(+)
> 
> changes for v2:
>  - Add USB_OTG_ADP definition in ch9.h
> 
> diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> index cc0ced0..7fdda5f 100644
> --- a/drivers/usb/core/Kconfig
> +++ b/drivers/usb/core/Kconfig
> @@ -55,6 +55,15 @@ config USB_OTG
> Select this only if your board has Mini-AB/Micro-AB
> connector.
>  
> +config USB_OTG20
> + bool "OTG20 support (EXPERIMENTAL)"
> + depends on USB_OTG
> + default n
> + help
> +   This feature is still under developing.
> +
> +   Select this only if your board support OTG 20's hardware requirements.
> +
>  config USB_OTG_WHITELIST
>   bool "Rely on OTG and EH Targeted Peripherals List"
>   depends on USB
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index e2f00fd..e598677 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -512,6 +512,8 @@ struct usb_gadget_ops {
>   * @sg_supported: true if we can handle scatter-gather
>   * @is_otg: True if the USB device port uses a Mini-AB jack, so that the
>   *   gadget driver must provide a USB OTG descriptor.
> + * @is_otg20: True if the USB hardware supports OTG 2.0 specification.
> + *   The gadget driver must provide USB OTG 2.0 descriptor.
>   * @is_a_peripheral: False unless is_otg, the "A" end of a USB cable
>   *   is in the Mini-AB jack, and HNP has been used to switch roles
>   *   so that the "A" device currently acts as A-Peripheral, not A-Host.
> @@ -559,6 +561,7 @@ struct usb_gadget {
>  
>   unsignedsg_supported:1;
>   unsignedis_otg:1;
> + unsignedis_otg20:1;
>   unsignedis_a_peripheral:1;
>   unsignedb_hnp_enable:1;
>   unsigneda_hnp_support:1;
> @@ -634,6 +637,23 @@ static inline int gadget_is_otg(struct usb_gadget *g)
>  }
>  
>  /**
> + * gadget_is_otg20 - return true iff the hardware is OTG 2.0-ready
> + * @g: controller that might supports OTG 2.0 specification.
> + *
> + * This is a runtime test, since kernels with a USB-OTG stack sometimes
> + * run on boards which only supports OTG 1.3,

%s/1.3/2.0

> + */
> +static inline int gadget_is_otg20(struct usb_gadget *g)
> +{
> +#ifdef CONFIG_USB_OTG20
> + return g->is_otg20;
> +#else
> + return 0;
> +#endif
> +}
> +
> +
> +/**
>   * usb_gadget_frame_number - returns the current frame number
>   * @gadget: controller that reports the frame number
>   *
> @@ -832,6 +852,10 @@ static inline int usb_gadget_disconnect(struct 
> usb_gadget *gadget)
>   * having called usb_gadget_disconnect(), and the USB host stack has
>   * initialized.
>   *
> + * If gadget->is_otg20 is true, the gadget driver must provide an OTG 2.0
> + * descriptor during enumeration, and related behavior must compliant with
> + * OTG 2.0 specificaiton.
> + *
>   * Drivers use hardware-specific knowledge to configure the usb hardware.
>   * endpoint addressing is only one of several hardware characteristics that
>   * are in descriptors the ep0 implementation returns from setup() calls.
> diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
> index aa33fd1..aaabdca 100644
> --- a/include/uapi/linux/usb/ch9.h
> +++ b/include/uapi/linux/usb/ch9.h
> @@ -672,11 +672,15 @@ struct usb_otg_descriptor {
>   __u8  bDescriptorType;
>  
>   __u8  bmAttributes; /* support for HNP, SRP, etc */
> +#ifdef   CONFIG_USB_OTG20
> + __le16 bcdOTG;  /* Support OTG 2.0 */
> +#endif

Why you use tab instead of space for this define?
For above, you use space.

>  } __attribute__ ((packed));
>  
>  /* from usb_otg_descriptor.bmAttributes */
>  #define USB_OTG_SRP  (1 << 0)
>  #define USB_OTG_HNP  (1 << 1)/* swap host/device roles */
> +#define USB_OTG_ADP  (1 << 2)/* support ADP */
>  
>  /*-*/
>  
> -- 
> 1.8.3.2
> 

-- 

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


Re: [PATCH v2] usb: introduce OTG 2.0 related kernel feature and API.

2015-03-26 Thread Greg KH
On Thu, Mar 26, 2015 at 11:21:43AM +0800, Macpaul Lin wrote:
> Introduce kernel feature CONFIG_USB_OTG20 and related
> gadget_is_otg20() API for supporting OTG20 compliant
> drivers.
> This patch also updated usb_otg_descritpor.
> 
> Signed-off-by: Macpaul Lin 
> ---
>  drivers/usb/core/Kconfig |  9 +
>  include/linux/usb/gadget.h   | 24 
>  include/uapi/linux/usb/ch9.h |  4 
>  3 files changed, 37 insertions(+)
> 
> changes for v2:
>  - Add USB_OTG_ADP definition in ch9.h
> 
> diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> index cc0ced0..7fdda5f 100644
> --- a/drivers/usb/core/Kconfig
> +++ b/drivers/usb/core/Kconfig
> @@ -55,6 +55,15 @@ config USB_OTG
> Select this only if your board has Mini-AB/Micro-AB
> connector.
>  
> +config USB_OTG20
> + bool "OTG20 support (EXPERIMENTAL)"

The "EXPERIMENTAL" tag is no longer used, please remove.

> + depends on USB_OTG
> + default n

That's the normal default, please remove.

> + help
> +   This feature is still under developing.
> +
> +   Select this only if your board support OTG 20's hardware requirements.

Please provide more information here, and a '.'  Why would someone want
to turn this off?  What is "OTG"?  Be specific here.

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


[PATCH v2 1/1] usb: chipidea: otg: remove mutex unlock and lock while stop and start role

2015-03-26 Thread Li Jun
Wrongly release mutex lock during otg_statemachine may result in re-enter
otg_statemachine, which is not allowed, we should do next state transtition
after previous one completed.

Fixes: 826cfe751f3e ("usb: chipidea: add OTG fsm operation functions 
implementation")
Cc:  # v3.16+
Signed-off-by: Li Jun 

Changes for v2:
- Add Cc tag for sta...@vger.kernel.org

---
 drivers/usb/chipidea/otg_fsm.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 82b1e23..789dd76 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -531,7 +531,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
 {
struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
 
-   mutex_unlock(&fsm->lock);
if (on) {
ci_role_stop(ci);
ci_role_start(ci, CI_ROLE_HOST);
@@ -540,7 +539,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
hw_device_reset(ci);
ci_role_start(ci, CI_ROLE_GADGET);
}
-   mutex_lock(&fsm->lock);
return 0;
 }
 
@@ -548,12 +546,10 @@ static int ci_otg_start_gadget(struct otg_fsm *fsm, int 
on)
 {
struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
 
-   mutex_unlock(&fsm->lock);
if (on)
usb_gadget_vbus_connect(&ci->gadget);
else
usb_gadget_vbus_disconnect(&ci->gadget);
-   mutex_lock(&fsm->lock);
 
return 0;
 }
-- 
1.9.1

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


[PATCH 1/1] usb: chipidea: debug: add low power mode check before print registers

2015-03-26 Thread Li Jun
Since the required clock to access registers is gated off in low power mode,
add ci->in_lpm check before try to dump registers value.

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

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 268e423..905e4da 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -336,7 +336,7 @@ static int ci_registers_show(struct seq_file *s, void 
*unused)
struct ci_hdrc *ci = s->private;
u32 tmp_reg;
 
-   if (!ci)
+   if (!ci || ci->in_lpm)
return 0;
 
/* -- Registers - */
-- 
1.9.1

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


Re: [PATCH 00/12] USB: chipidea: patchset for performance improvement

2015-03-26 Thread victorascroft
Hello Peter,

On 15-03-24 20:21:47, Peter Chen wrote:
> On Tue, Mar 24, 2015 at 04:02:53PM +0530, victorascr...@gmail.com wrote:
> > Hello Peter, 
> > 
> > On 15-03-19 09:19:11, Peter Chen wrote:
> > > Hi all,
> > > 
> > > In this patch set, I add some interfaces for tuning the performance
> > > of chipidea usb driver. With this set, the USB performance can be improved
> > > at some user cases with suitable parameters. The main changes:
> > > 
> > > - Interface to tune interrupt threshold control, and set
> > > 'Immediate' for default value
> > > - The glue layer can disable stream mode according to USB role
> > > - Interface to tune AHB burst configuration at SBUSCFG
> > > - Interface to tune tx/rx burst size
> > > - i.mx changes for achieving better performance, it can reduce
> > >   the latecy between bus and USB FIFO, and reduce the overrun
> > >   and underrun occurrences, it is useful for the system bus is busy.
> > >   we see great improvement for ISO transfer, eg, high resolution
> > >   USB camera when the bus is busy.
> > > 
> > > Below are some test results at imx6sx sdb board
> > > (set ehci_hcd.park=3 at bootargs), the tests are done
> > > at v4.0 kernel, no other bus loading during the tests,
> > > so we have not seen performance change for some use cases.
> > > 
> > > USB Mass Storage (Host mode)
> > > With Patch SetWithout Patch Set
> > > R: 26.9 MB/s  27 MB/s
> > > W: 25.2 MB/s  24.5 MB/s
> > > 
> > > 1G USB Ethernet Card
> > > With Patch SetWithout Patch Set
> > > TX: 186 Mb/s  185 Mb/s
> > > RX: 219 Mb/s  216 Mb/s
> > > 
> > > g_ncm (Device Mode)
> > > With Patch SetWithout Patch Set
> > > TX: 166MB/s   163MB/s
> > > RX: 230MB/s   184MB/s
> > > 
> > 
> > I tested these patches on a Colibri Vybrid VF61. Have not applied the 
> > 7th and 11th patch, but, the changes these patches introduce, I added 
> > them to our device tree node. These would be  the addition of 
> > ahb-burst-config = <0x0> and tx-burst-size-dword = <0x10> and 
> > rx-burst-size-dword = <0x10> to the usb node in vfxxx.dtsi file for both 
> > the peripheral and host usb nodes.
> > 
> > I used hdparm and dd for the tests. Some of the readings are below.
> > 
> > With this patchset applied
> > 
> > Reads
> > hdparm -t --direct /dev/sda
> > 
> > /dev/sda:
> >  Timing O_DIRECT disk reads:  36 MB in  3.05 seconds =  11.80 MB/sec
> > 
> > Writes
> > root@colibri-vf:~# time dd if=/dev/zero bs=128k count=4096
> > of=/media/sda1/tmpfile
> > 4096+0 records in
> > 4096+0 records out
> > 
> > real1m11.671s
> > user0m0.010s
> > sys 0m10.130s
> > 
> > USB Client - RNDIS
> > 
> > root@colibri-vf:~# iperf -c 192.168.1.1
> > 
> > Client connecting to 192.168.1.1, TCP port 5001
> > TCP window size: 43.8 KByte (default)
> > 
> > [  3] local 192.168.1.2 port 41317 connected with 192.168.1.1 port 5001
> > [ ID] Interval   Transfer Bandwidth
> > [  3]  0.0-10.0 sec   105 MBytes  88.2 Mbits/sec
> > 
> > Without this patchset applied
> > 
> > Reads
> > hdparm -t --direct /dev/sda
> > 
> > /dev/sda:
> >  Timing O_DIRECT disk reads:  78 MB in  3.06 seconds =  25.50 MB/sec
> > 
> > Writes
> > root@colibri-vf:~# time dd if=/dev/zero bs=128k count=4096
> > of=/media/sda1/tmpfil
> > 4096+0 records in
> > 4096+0 records out
> > 
> > real0m43.807s
> > user0m0.050s
> > sys 0m9.960s
> > 
> > USB Client - RNDIS
> > 
> > root@colibri-vf:~# iperf -c 192.168.1.1
> > 
> > Client connecting to 192.168.1.1, TCP port 5001
> > TCP window size: 43.8 KByte (default)
> > 
> > [  3] local 192.168.1.2 port 49857 connected with 192.168.1.1 port 5001
> > [ ID] Interval   Transfer Bandwidth
> > [  3]  0.0-10.0 sec   138 MBytes   116 Mbits/sec
> > 
> > 
> > Perhaps I am missing something? I have the ehci_hcd.park=3 set.
> > 
> > root@colibri-vf:~# cat /proc/cmdline
> > ehci_hcd.park=3 ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs
> > ubi.fm_autoconvert=1 mtdparts=vf610_nfc:128k(vf-bcb)ro,1408k(
> > u-boot)ro,512k(u-boot-env),-(ubi) fec_mac= consoleblank=0 console=tty1
> > console=ttyLP0,115200n8 mem=256M
> > 
> > Is there any other parameter or variable I need to set?
> 
> Hi Sanchayan,
> 
> The dts setting is specific for i.mx6 (maybe i.mx5 is applicate),
> and it needs below patch to co-work with it, it is an i.mx
> controller specific improvement (not in core).
> > >   usb: chipidea: usbmisc_imx: add unburst setting for imx6
> 
> Other chipidea SoCs may have optimized parameters than default ones, it
> needs to check with IC guys.
> 
> Enable stream mode should improve tx performance, you can have a try.

I will give this a try in a while and check, if that helps.

Thanks.

- Sanchayan.


Re: [PATCH 1/1] usb: chipidea: debug: add low power mode check before print registers

2015-03-26 Thread Peter Chen
On Thu, Mar 26, 2015 at 04:19:52PM +0800, Li Jun wrote:
> Since the required clock to access registers is gated off in low power mode,
> add ci->in_lpm check before try to dump registers value.
> 
> Signed-off-by: Li Jun 
> ---
>  drivers/usb/chipidea/debug.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
> index 268e423..905e4da 100644
> --- a/drivers/usb/chipidea/debug.c
> +++ b/drivers/usb/chipidea/debug.c
> @@ -336,7 +336,7 @@ static int ci_registers_show(struct seq_file *s, void 
> *unused)
>   struct ci_hdrc *ci = s->private;
>   u32 tmp_reg;
>  
> - if (!ci)
> + if (!ci || ci->in_lpm)
>   return 0;
>  
>   /* -- Registers - */
> -- 
> 1.9.1
> 

Would you show an warning message if this operation is not allowed,
Eg, return -EPERM?

-- 

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


Re: [PATCH v2 1/1] usb: chipidea: otg: remove mutex unlock and lock while stop and start role

2015-03-26 Thread Peter Chen
On Thu, Mar 26, 2015 at 04:09:46PM +0800, Li Jun wrote:
> Wrongly release mutex lock during otg_statemachine may result in re-enter
> otg_statemachine, which is not allowed, we should do next state transtition
> after previous one completed.
> 
> Fixes: 826cfe751f3e ("usb: chipidea: add OTG fsm operation functions 
> implementation")
> Cc:  # v3.16+
> Signed-off-by: Li Jun 
> 
> Changes for v2:
> - Add Cc tag for sta...@vger.kernel.org

You may need to add change log after "---", otherwise, the
change log will be showed in commit log which is not expected.
I have changed and applied it, thanks.

> 
> ---
>  drivers/usb/chipidea/otg_fsm.c | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
> index 82b1e23..789dd76 100644
> --- a/drivers/usb/chipidea/otg_fsm.c
> +++ b/drivers/usb/chipidea/otg_fsm.c
> @@ -531,7 +531,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
>  {
>   struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
>  
> - mutex_unlock(&fsm->lock);
>   if (on) {
>   ci_role_stop(ci);
>   ci_role_start(ci, CI_ROLE_HOST);
> @@ -540,7 +539,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
>   hw_device_reset(ci);
>   ci_role_start(ci, CI_ROLE_GADGET);
>   }
> - mutex_lock(&fsm->lock);
>   return 0;
>  }
>  
> @@ -548,12 +546,10 @@ static int ci_otg_start_gadget(struct otg_fsm *fsm, int 
> on)
>  {
>   struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
>  
> - mutex_unlock(&fsm->lock);
>   if (on)
>   usb_gadget_vbus_connect(&ci->gadget);
>   else
>   usb_gadget_vbus_disconnect(&ci->gadget);
> - mutex_lock(&fsm->lock);
>  
>   return 0;
>  }
> -- 
> 1.9.1
> 

-- 

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


Re: [PATCH 1/1] usb: chipidea: udc: bypass pullup DP when gadget connect in OTG fsm mode

2015-03-26 Thread Peter Chen
On Mon, Mar 23, 2015 at 04:03:35PM +0800, Li Jun wrote:
> By pass pullup DP in OTG fsm mode when do gadget connect, to let it handled
> by OTG state machine.
> 
> Signed-off-by: Li Jun 
> 
> This patch can fix the problem you found with my HNP polling patchset after
> below 3 patches introduced:
> 467a78c usb: chipidea: udc: apply new usb_udc_vbus_handler interface
> 628ef0d usb: udc: add usb_udc_vbus_handler
> dfea9c9 usb: udc: store usb_udc pointer in struct usb_gadget
> 
> Problem:
> - Connect USB cable and MicroAB cable between two boards
> - Boot up two boards
> - load g_mass_storage at B-device side, the enumeration will success,
> and A will see a usb mass-storage device
> - load g_mass_storage at A-device side, the problem has occurred, the
> connection will be lost at the beginning, then connect again.
> 
> This patch is based on
> commit eff933c1d3a2e046492b3dfc86db813856553a29
> (chipidea: pci: make it depends on NOP_USB_XCEIV)
> on branch peter-usb-dev of
> git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
>  
> ---
>  drivers/usb/chipidea/udc.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 8ed497e..e1c1d99 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1575,6 +1575,10 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, 
> int is_on)
>  {
>   struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
>  
> + /* Data+ pullup controlled by OTG state machine in OTG fsm mode */
> + if (ci_otg_is_fsm_mode(ci))
> + return 0;
> +
>   pm_runtime_get_sync(&ci->gadget.dev);
>   if (is_on)
>   hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
> -- 
> 1.9.1
> 

Applied it, thanks.

-- 

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


Re: [PATCH v4 0/8] add HNP polling support for usb otg fsm

2015-03-26 Thread Peter Chen
On Wed, Mar 25, 2015 at 07:25:24PM +0800, Li Jun wrote:
> On Wed, Mar 25, 2015 at 02:43:43PM +0800, Chen Peter-B29397 wrote:
> >  
> > > On Wed, Mar 25, 2015 at 02:03:51PM +0800, Peter Chen wrote:
> > > >
> > > > Hi Jun,
> > > >
> > > > The above three patches are in Greg's next tree, after I apply your
> > > > chipidea fix [1] for pullup dp, it still some other problems for HNP,
> > > > am I missing something?
> > > >
> > > > The procedures to reproduce:
> > > >
> > > > - Connect USB cable and MicroAB cable between two boards
> > > > - Boot up two boards
> > > > - load g_mass_storage at B-device side, the enumeration will success,
> > > > and A will see a usb mass-storage device
> > > > - load g_mass_storage at A-device side
> > > > - Do HNP at B side, the HNP will succeed echo 1 >
> > > > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
> > > > - Do HNP at A side
> > > > echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
> > > >
> > > > The problem has occurred, the A can't be back to host again.
> > > >
> > > I use your peter-usb-dev branch and did not found the problem, so I need 
> > > use
> > > Greg's tree to try again?
> > > 
> > 
> > No, I first found this problem with my dev tree, then, I rebase the latest 
> > Greg next
> > tree, this problem still exists.  You can try to use FSL imx6dl sdb as A 
> > device and imx6sx sdb
> > as B device to reproduce it.
> > 
> 
> It can work with my i.MX6DL + i.MX6Q SD, but with i.MX6DL + i.MX6SX SDB, I can
> reproduce the problem you reported, which triggers a bug in our otg_fsm 
> driver,
> I will send out a patch to fix it.
> 
> Li Jun
> 

Jun,

With your two chipidea fixes [1][2], I can run otg test successfully.

[1]
https://git.kernel.org/cgit/linux/kernel/git/peter.chen/usb.git/commit/?h=ci-for-usb-stable&id=885510e8778bf0f2d38e2fd0807d8f84ca12a8d9
[2]
https://git.kernel.org/cgit/linux/kernel/git/peter.chen/usb.git/commit/?h=ci-for-usb-next&id=80c4b00dd0bee2ff5f430fae7e96d9599d36682f

Hi Felipe,

I am ok with this series, if you have no more comments, would you help
queue this series through your tree?

-- 

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


Re: [PATCH v4 3/8] usb: common: otg-fsm: add HNP polling support

2015-03-26 Thread Peter Chen
On Thu, Mar 19, 2015 at 11:11:20AM +0800, Li Jun wrote:
> Adds HNP polling timer when transits to host state, the OTG status request
> will be sent to peripheral after timeout, if host request flag is set, it will
> switch to peripheral state, otherwise it will repeat HNP polling every 1.5s 
> and
> maintain the current session.

Signed-off-by: Peter Chen 

> 
> Signed-off-by: Li Jun 
> ---
>  drivers/usb/common/usb-otg-fsm.c |   92 
> ++
>  include/linux/usb/otg-fsm.h  |   13 ++
>  2 files changed, 105 insertions(+)
> 
> diff --git a/drivers/usb/common/usb-otg-fsm.c 
> b/drivers/usb/common/usb-otg-fsm.c
> index 61d538a..6f0d40b 100644
> --- a/drivers/usb/common/usb-otg-fsm.c
> +++ b/drivers/usb/common/usb-otg-fsm.c
> @@ -78,6 +78,8 @@ static void otg_leave_state(struct otg_fsm *fsm, enum 
> usb_otg_state old_state)
>   fsm->b_srp_done = 0;
>   break;
>   case OTG_STATE_B_PERIPHERAL:
> + if (fsm->otg->gadget)
> + fsm->otg->gadget->host_request_flag = 0;
>   break;
>   case OTG_STATE_B_WAIT_ACON:
>   otg_del_timer(fsm, B_ASE0_BRST);
> @@ -107,6 +109,8 @@ static void otg_leave_state(struct otg_fsm *fsm, enum 
> usb_otg_state old_state)
>   case OTG_STATE_A_PERIPHERAL:
>   otg_del_timer(fsm, A_BIDL_ADIS);
>   fsm->a_bidl_adis_tmout = 0;
> + if (fsm->otg->gadget)
> + fsm->otg->gadget->host_request_flag = 0;
>   break;
>   case OTG_STATE_A_WAIT_VFALL:
>   otg_del_timer(fsm, A_WAIT_VFALL);
> @@ -120,6 +124,92 @@ static void otg_leave_state(struct otg_fsm *fsm, enum 
> usb_otg_state old_state)
>   }
>  }
>  
> +static void otg_hnp_polling_work(struct work_struct *work)
> +{
> + struct otg_fsm *fsm = container_of(to_delayed_work(work),
> + struct otg_fsm, hnp_polling_work);
> + struct usb_device *udev;
> + u8 host_req_flag;
> + enum usb_otg_state state = fsm->otg->state;
> + struct usb_otg_descriptor *desc = NULL;
> + int retval;
> +
> + if (state != OTG_STATE_A_HOST && state != OTG_STATE_B_HOST)
> + return;
> +
> + udev = usb_hub_find_child(fsm->otg->host->root_hub, 1);
> + if (!udev) {
> + dev_err(fsm->otg->host->controller,
> + "no usb dev connected, can't start HNP polling\n");
> + return;
> + }
> +
> + /* Check if it's a HNP capable OTG device */
> + retval = __usb_get_extra_descriptor(udev->rawdescriptors[0],
> + le16_to_cpu(udev->config[0].desc.wTotalLength),
> + USB_DT_OTG, (void **) &desc);
> + if (retval || !(desc->bmAttributes & USB_OTG_HNP))
> + return;
> +
> + /* Get host request flag from connected USB device */
> + retval = usb_control_msg(udev,
> + usb_rcvctrlpipe(udev, 0),
> + USB_REQ_GET_STATUS,
> + USB_DIR_IN | USB_RECIP_DEVICE,
> + 0,
> + OTG_STS_SELECTOR,
> + &host_req_flag,
> + 1,
> + USB_CTRL_GET_TIMEOUT);
> + if (retval != 1) {
> + dev_err(&udev->dev, "Get one byte OTG status failed\n");
> + return;
> + }
> +
> + if (host_req_flag == 0) {
> + /* Continue HNP polling */
> + schedule_delayed_work(&fsm->hnp_polling_work,
> + msecs_to_jiffies(T_HOST_REQ_POLL));
> + return;
> + } else if (host_req_flag != HOST_REQUEST_FLAG) {
> + dev_err(&udev->dev, "host request flag %d is invalid\n",
> + host_req_flag);
> + return;
> + }
> +
> + /* Host request flag is set */
> + if (state == OTG_STATE_A_HOST) {
> + /* Set b_hnp_enable */
> + if (!fsm->otg->host->b_hnp_enable) {
> + retval = usb_control_msg(udev,
> + usb_sndctrlpipe(udev, 0),
> + USB_REQ_SET_FEATURE, 0,
> + USB_DEVICE_B_HNP_ENABLE,
> + 0, NULL, 0,
> + USB_CTRL_SET_TIMEOUT);
> + if (retval < 0) {
> + dev_err(&udev->dev,
> + "can't enable HNP %d\n", retval);
> + return;
> + }
> + fsm->otg->host->b_hnp_enable = 1;
> + }
> +
> + fsm->a_bus_req = 0;
> + } else if (state == OTG_STATE_B_HOST) {
> + fsm->b_bus_req = 0;
> + }
> +
> + otg_statemachine(fsm);
> +}
> +
> +static void otg_s

Re: [PATCH] Documentation: usb: serial: fixed how to provide vendor and product id

2015-03-26 Thread Greg KH
On Wed, Mar 25, 2015 at 09:53:34PM +0100, Marek Belisko wrote:
> From: "H. Nikolaus Schaller" 
> 
> While trying to test the Pyra GSM/GPS/3G module I had reconfigured
> the USB interface by mistake and therefore needed to run a different
> USB driver than CSC-ACM. It turned out that I need the "usbserial" driver.
> 
> This file is an official description how to use it:
> Documentation/usb/usb-serial.txt
> 
> But it is outdated. The parameters vendor= and product= are no longer
> available since ca. 3.12 which means that documentation is lagging behind
> quite some time.
> 
> Here was the solution:
> 
> https://bbs.archlinux.org/viewtopic.php?id=175499
> 
>   insmod usbserial vendor=0x product=0x
> 
> becomes (first  is vendor, second is product)
> 
>   modprobe usbserial
>   echo   >/sys/bus/usb-serial/drivers/generic/new_id
> 
> This patch changes the documentation file as needed.
> 
> Signed-off-by: H. Nikolaus Schaller 

You are forwarding on a patch from someone else, why didn't you also
sign-off on it?  Do you not agree with 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 4/4] usb: legacy/multi add supports OTG 2.0

2015-03-26 Thread Peter Chen
On Thu, Mar 26, 2015 at 03:38:38AM +0800, Macpaul Lin wrote:
> add supports OTG 2.0 for multi.c
> 
> Signed-off-by: Macpaul Lin 
> ---
>  drivers/usb/gadget/legacy/multi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/gadget/legacy/multi.c 
> b/drivers/usb/gadget/legacy/multi.c
> index 39d27bb..0f4005e 100644
> --- a/drivers/usb/gadget/legacy/multi.c
> +++ b/drivers/usb/gadget/legacy/multi.c
> @@ -89,6 +89,9 @@ static const struct usb_descriptor_header *otg_desc[] = {
>* it would not be called "OTG" ...
>*/
>   .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
> +#ifdef   CONFIG_USB_OTG20
> + .bcdOTG =   cpu_to_le16(0x0200),
> +#endif
>   },
>   NULL,
>  };
> -- 
> 1.8.3.2
> 

Would you consider abstract most your changes for composite.c as API, like
usb_gadget_customize_otg_desc, and call it at here and other gadget
driver which needs to change.

At composite.c, you only need to copy configuration descriptor[0]
to request buffer.

It can align otg descriptor at two places as well as customize otg
descriptor according to platforms.

One more thing, the code in condition gadget_is_otg(usb_gadget) may
need for otg v2.0 device too, you may consider using gadget_is_otg
for all otg devices, and using gadget_is_otg13 and gadget_is_otg20
only for differences.

-- 

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


Re: [PATCH] Documentation: usb: serial: fixed how to provide vendor and product id

2015-03-26 Thread Belisko Marek
On Thu, Mar 26, 2015 at 10:53 AM, Greg KH  wrote:
> On Wed, Mar 25, 2015 at 09:53:34PM +0100, Marek Belisko wrote:
>> From: "H. Nikolaus Schaller" 
>>
>> While trying to test the Pyra GSM/GPS/3G module I had reconfigured
>> the USB interface by mistake and therefore needed to run a different
>> USB driver than CSC-ACM. It turned out that I need the "usbserial" driver.
>>
>> This file is an official description how to use it:
>> Documentation/usb/usb-serial.txt
>>
>> But it is outdated. The parameters vendor= and product= are no longer
>> available since ca. 3.12 which means that documentation is lagging behind
>> quite some time.
>>
>> Here was the solution:
>>
>> https://bbs.archlinux.org/viewtopic.php?id=175499
>>
>>   insmod usbserial vendor=0x product=0x
>>
>> becomes (first  is vendor, second is product)
>>
>>   modprobe usbserial
>>   echo   >/sys/bus/usb-serial/drivers/generic/new_id
>>
>> This patch changes the documentation file as needed.
>>
>> Signed-off-by: H. Nikolaus Schaller 
>
> You are forwarding on a patch from someone else, why didn't you also
> sign-off on it?  Do you not agree with it?
I wasn't involved in patch development I just review it and forward.
>
> thanks,
>
> greg k-h

BR,

marek

-- 
as simple and primitive as possible
-
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
--
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] Documentation: usb: serial: fixed how to provide vendor and product id

2015-03-26 Thread Dr. H. Nikolaus Schaller

Am 26.03.2015 um 11:41 schrieb Belisko Marek :

> On Thu, Mar 26, 2015 at 10:53 AM, Greg KH  wrote:
>> On Wed, Mar 25, 2015 at 09:53:34PM +0100, Marek Belisko wrote:
>>> From: "H. Nikolaus Schaller" 
>>> 
>>> While trying to test the Pyra GSM/GPS/3G module I had reconfigured
>>> the USB interface by mistake and therefore needed to run a different
>>> USB driver than CSC-ACM. It turned out that I need the "usbserial" driver.
>>> 
>>> This file is an official description how to use it:
>>> Documentation/usb/usb-serial.txt
>>> 
>>> But it is outdated. The parameters vendor= and product= are no longer
>>> available since ca. 3.12 which means that documentation is lagging behind
>>> quite some time.
>>> 
>>> Here was the solution:
>>> 
>>> https://bbs.archlinux.org/viewtopic.php?id=175499
>>> 
>>>  insmod usbserial vendor=0x product=0x
>>> 
>>> becomes (first  is vendor, second is product)
>>> 
>>>  modprobe usbserial
>>>  echo   >/sys/bus/usb-serial/drivers/generic/new_id
>>> 
>>> This patch changes the documentation file as needed.
>>> 
>>> Signed-off-by: H. Nikolaus Schaller 
>> 
>> You are forwarding on a patch from someone else, why didn't you also
>> sign-off on it?  Do you not agree with it?
> I wasn’t involved in patch development I just review it and forward.

Yes,
I asked Marek to submit this patch (from our local repo).

BR,
Nikolaus

>> 
>> thanks,
>> 
>> greg k-h
> 
> BR,
> 
> marek
> 
> -- 
> as simple and primitive as possible
> -
> Marek Belisko - OPEN-NANDRA
> Freelance Developer
> 
> Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
> Tel: +421 915 052 184
> skype: marekwhite
> twitter: #opennandra
> web: http://open-nandra.com

--
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] Documentation: usb: serial: fixed how to provide vendor and product id

2015-03-26 Thread Greg KH
On Thu, Mar 26, 2015 at 11:41:24AM +0100, Belisko Marek wrote:
> On Thu, Mar 26, 2015 at 10:53 AM, Greg KH  wrote:
> > On Wed, Mar 25, 2015 at 09:53:34PM +0100, Marek Belisko wrote:
> >> From: "H. Nikolaus Schaller" 
> >>
> >> While trying to test the Pyra GSM/GPS/3G module I had reconfigured
> >> the USB interface by mistake and therefore needed to run a different
> >> USB driver than CSC-ACM. It turned out that I need the "usbserial" driver.
> >>
> >> This file is an official description how to use it:
> >> Documentation/usb/usb-serial.txt
> >>
> >> But it is outdated. The parameters vendor= and product= are no longer
> >> available since ca. 3.12 which means that documentation is lagging behind
> >> quite some time.
> >>
> >> Here was the solution:
> >>
> >> https://bbs.archlinux.org/viewtopic.php?id=175499
> >>
> >>   insmod usbserial vendor=0x product=0x
> >>
> >> becomes (first  is vendor, second is product)
> >>
> >>   modprobe usbserial
> >>   echo   >/sys/bus/usb-serial/drivers/generic/new_id
> >>
> >> This patch changes the documentation file as needed.
> >>
> >> Signed-off-by: H. Nikolaus Schaller 
> >
> > You are forwarding on a patch from someone else, why didn't you also
> > sign-off on it?  Do you not agree with it?
> I wasn't involved in patch development I just review it and forward.

If you reviewed and forwarded it, why did you not add a signed-off-by:
to it?  Do you not think it is acceptable for merging?  If not, then we
shouldn't either :)

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


[RFC 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-03-26 Thread Ben Dooks
Use  to provide IO accessors which work on both
AVR32 and ARM for on-chip peripherals.

Signed-off-by: Ben Dooks 
--
CC: Nicolas Ferre 
CC: Felipe Balbi 
CC: Greg Kroah-Hartman 
CC: linux-usb@vger.kernel.org
---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  1 +
 drivers/usb/gadget/udc/atmel_usba_udc.h | 12 +++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index be2f503..6735585 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 92bd486..3d40aa3 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -191,15 +191,9 @@
 | USBA_BF(name, value))
 
 /* Register access macros */
-#ifdef CONFIG_AVR32
-#define usba_io_readl  __raw_readl
-#define usba_io_writel __raw_writel
-#define usba_io_writew __raw_writew
-#else
-#define usba_io_readl  readl_relaxed
-#define usba_io_writel writel_relaxed
-#define usba_io_writew writew_relaxed
-#endif
+#define usba_io_readl  atmel_oc_readl
+#define usba_io_writel atmel_oc_writel
+#define usba_io_writew atmel_oc_writew
 
 #define usba_readl(udc, reg)   \
usba_io_readl((udc)->regs + USBA_##reg)
-- 
2.1.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: [RFC 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-03-26 Thread Hans-Christian Egtvedt
Around Thu 26 Mar 2015 11:45:53 + or thereabout, Ben Dooks wrote:
> Use  to provide IO accessors which work on both
> AVR32 and ARM for on-chip peripherals.
> 
> Signed-off-by: Ben Dooks 

Acked-by: Hans-Christian Egtvedt 

> --
> CC: Nicolas Ferre 
> CC: Felipe Balbi 
> CC: Greg Kroah-Hartman 
> CC: linux-usb@vger.kernel.org
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c |  1 +
>  drivers/usb/gadget/udc/atmel_usba_udc.h | 12 +++-
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index be2f503..6735585 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
> b/drivers/usb/gadget/udc/atmel_usba_udc.h
> index 92bd486..3d40aa3 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
> @@ -191,15 +191,9 @@
>| USBA_BF(name, value))
>  
>  /* Register access macros */
> -#ifdef CONFIG_AVR32
> -#define usba_io_readl__raw_readl
> -#define usba_io_writel   __raw_writel
> -#define usba_io_writew   __raw_writew
> -#else
> -#define usba_io_readlreadl_relaxed
> -#define usba_io_writel   writel_relaxed
> -#define usba_io_writew   writew_relaxed
> -#endif
> +#define usba_io_readlatmel_oc_readl
> +#define usba_io_writel   atmel_oc_writel
> +#define usba_io_writew   atmel_oc_writew

Same comment as earlier patch, it would be nice to remove the define
usba_io_{read,write}{l,w} defines in a follow-up patch.



-- 
mvh
Hans-Christian Egtvedt
--
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_hcd error Transfer event TRB DMA ptr not part of current TD ep_index 8 comp_code 1

2015-03-26 Thread Alistair Grant
On Mon, Mar 23, 2015 at 10:14 PM, Devin Heitmueller
 wrote:
>
> My guess would be that there's some bug in the cx231xx that
> exacerbates an edge case in the XHCI core - like prematurely setting
> the USB alternate back to zero when stopping streaming and not
> canceling all the URBs first.
>
> ...
>
> As a test, you may wish to try disabling the cx231xx-audio module.
> That will help narrow down an interaction with ALSA, pulseaudio, and
> one of the two sources of URB queueing.


I think you're on the right track here - blacklisting the audio module
(cx231xxx_alsa) allowed successful video recording with the device inserted
during boot.

I added some logging to drivers/usb/core/message.c to check that the URB
list is empty before changing the alternate interface.  While it wasn't
ever called with a non-empty list, it did perhaps help narrow down the area
of code causing trouble.

The normal sequence of log messages when stopping recoring is:

Mar 26 08:50:41 alistair-XPS13 kernel: [  771.866435] cx231xx 1-2:1.1:
urb_init=0 dev->video_mode.max_pkt_size=2892
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.900280] cx231xx 1-2:1.1:
urb_init=0 dev->video_mode.max_pkt_size=2892
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.943487] cx231xx 1-2:1.1:
urb_init=0 dev->video_mode.max_pkt_size=2892
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988004] cx231xx 1-2:1.1:
stopping capture
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988009] cx231xx 1-2:1.1:
Stopping isoc
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988022] cx231xx 1-2:1.1:
Stop capture, if needed
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988056] cx231xx 1-2:1.1:
Stop capture, if needed
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988058] cx231xx 1-2:1.1:
closing device
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988062] cx231xx 1-2:1.1:
cx231xx_stop_stream: ep_mask = 4
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.988167] usb 1-2: akg URB
list: next=0x880073299d90, prev=0x880073299d90, eq=1, empty=1
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.993115] cx231xx 1-2:1.1:
cx231xx_stop_stream: ep_mask = 8
Mar 26 08:50:41 alistair-XPS13 kernel: [  771.993192] usb 1-2: akg URB
list: next=0x8800732992b0, prev=0x8800732992b0, eq=1, empty=1

The "akg URB" record is the log I added to usb_set_interface().

The failures appear to have several different paths, however one of them is:

Mar 26 08:57:17 alistair-XPS13 kernel: [   87.915849] cx231xx 1-2:1.1:
urb_init=0 dev->video_mode.max_pkt_size=2892
Mar 26 08:57:17 alistair-XPS13 kernel: [   87.960923] cx231xx 1-2:1.1:
urb_init=0 dev->video_mode.max_pkt_size=2892
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.004771] cx231xx 1-2:1.1:
urb_init=0 dev->video_mode.max_pkt_size=2892
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032245] cx231xx 1-2:1.1:
stopping capture
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032253] cx231xx 1-2:1.1:
Stopping isoc
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032273] cx231xx 1-2:1.1:
Stop capture, if needed
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032326] cx231xx 1-2:1.1:
Stop capture, if needed
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032331] cx231xx 1-2:1.1:
closing device
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032337] cx231xx 1-2:1.1:
cx231xx_stop_stream: ep_mask = 4
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032526] xhci_hcd
:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD
ep_index 8 comp_code 1
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032542] xhci_hcd
:00:14.0: Looking for event-dma 0001f8671400 trb-start
0001facb2090 trb-end 0001facb2090 seg-start 0001facb2000
seg-end 0001facb23f0
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032565] usb 1-2: akg URB
list: next=0x880215504eb0, prev=0x880215504eb0, eq=1, empty=1
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032579] xhci_hcd
:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD
ep_index 8 comp_code 1
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032596] xhci_hcd
:00:14.0: Looking for event-dma 0001f8671410 trb-start
0001facb2090 trb-end 0001facb2090 seg-start 0001facb2000
seg-end 0001facb23f0
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032703] xhci_hcd
:00:14.0: ERROR Transfer event TRB DMA ptr not part of current TD
ep_index 8 comp_code 1
Mar 26 08:57:17 alistair-XPS13 kernel: [   88.032712] xhci_hcd
:00:14.0: Looking for event-dma 0001f8671420 trb-start
0001facb2090 trb-end 0001facb2090 seg-start 0001facb2000
seg-end 0001facb23f0

Hopefully this will give some clues about where to look next.

Thanks again for all your assistance.

Cheers,
Alistair
--
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


[PATCHv4 01/12] usb: add bus type for USB ULPI

2015-03-26 Thread Heikki Krogerus
UTMI+ Low Pin Interface (ULPI) is a commonly used PHY
interface for USB 2.0. The ULPI specification describes a
standard set of registers which the vendors can extend for
their specific needs. ULPI PHYs provide often functions
such as charger detection and ADP sensing and probing.

There are two major issues that the bus type is meant to
tackle:

Firstly, ULPI registers are accessed from the controller.
The bus provides convenient method for the controller
drivers to share that access with the actual PHY drivers.

Secondly, there are already platforms that assume ULPI PHYs
are runtime detected, such as many Intel Baytrail based
platforms. They do not provide any kind of hardware
description for the ULPI PHYs like separate ACPI device
object that could be used to enumerate a device from.

Signed-off-by: Heikki Krogerus 
---

Since v3:
- Fix type in comment

 MAINTAINERS   |   7 ++
 drivers/usb/common/Makefile   |   1 +
 drivers/usb/common/ulpi.c | 246 ++
 drivers/usb/core/Kconfig  |   8 ++
 include/linux/mod_devicetable.h   |   6 +
 include/linux/ulpi/driver.h   |  62 ++
 include/linux/ulpi/interface.h|  23 
 include/linux/ulpi/regs.h | 130 
 include/linux/usb/ulpi.h  | 134 +
 scripts/mod/devicetable-offsets.c |   4 +
 scripts/mod/file2alias.c  |  13 ++
 11 files changed, 502 insertions(+), 132 deletions(-)
 create mode 100644 drivers/usb/common/ulpi.c
 create mode 100644 include/linux/ulpi/driver.h
 create mode 100644 include/linux/ulpi/interface.h
 create mode 100644 include/linux/ulpi/regs.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 93985a2..ef70a03 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10440,6 +10440,13 @@ S: Maintained
 F: Documentation/video4linux/zr364xx.txt
 F: drivers/media/usb/zr364xx/
 
+ULPI BUS
+M: Heikki Krogerus 
+L: linux-usb@vger.kernel.org
+S: Maintained
+F: drivers/usb/common/ulpi.c
+F: include/linux/ulpi/
+
 USER-MODE LINUX (UML)
 M: Jeff Dike 
 M: Richard Weinberger 
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index ca2f8bd..6bbb3ec 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -7,3 +7,4 @@ usb-common-y  += common.o
 usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
+obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
new file mode 100644
index 000..84dcd2e
--- /dev/null
+++ b/drivers/usb/common/ulpi.c
@@ -0,0 +1,246 @@
+/**
+ * ulpi.c - USB ULPI PHY bus
+ *
+ * Copyright (C) 2015 Intel Corporation
+ *
+ * Author: Heikki Krogerus 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* -- 
*/
+
+int ulpi_read(struct ulpi *ulpi, u8 addr)
+{
+   return ulpi->ops->read(ulpi->ops, addr);
+}
+EXPORT_SYMBOL_GPL(ulpi_read);
+
+int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val)
+{
+   return ulpi->ops->write(ulpi->ops, addr, val);
+}
+EXPORT_SYMBOL_GPL(ulpi_write);
+
+/* -- 
*/
+
+static int ulpi_match(struct device *dev, struct device_driver *driver)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(driver);
+   struct ulpi *ulpi = to_ulpi_dev(dev);
+   const struct ulpi_device_id *id;
+
+   for (id = drv->id_table; id->vendor; id++)
+   if (id->vendor == ulpi->id.vendor &&
+   id->product == ulpi->id.product)
+   return 1;
+
+   return 0;
+}
+
+static int ulpi_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+   struct ulpi *ulpi = to_ulpi_dev(dev);
+
+   if (add_uevent_var(env, "MODALIAS=ulpi:v%04xp%04x",
+  ulpi->id.vendor, ulpi->id.product))
+   return -ENOMEM;
+   return 0;
+}
+
+static int ulpi_probe(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev->driver);
+
+   return drv->probe(to_ulpi_dev(dev));
+}
+
+static int ulpi_remove(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev->driver);
+
+   if (drv->remove)
+   drv->remove(to_ulpi_dev(dev));
+
+   return 0;
+}
+
+struct bus_type ulpi_bus = {
+   .name = "ulpi",
+   .match = ulpi_match,
+   .uevent = ulpi_uevent,
+   .probe = ulpi_probe,
+   .remove = ulpi_remove,
+};
+EXPORT_SYMBOL_GPL(ulpi_bus);
+
+/* -- 
*/
+
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+  

[PATCH] usb: gadget: hid: Fix static variable usage

2015-03-26 Thread Krzysztof Opasiak
If we have multiple instances of hid function, each of
them may have different report descriptor, also their
length may be different.

Currently we are using static hidg_desc varable which
is being filled in hidg_bind(). Then we send its content
to host in hidg_setup() function. This content may
have been already overwriten if another instance
has executed hidg_bind().

Signed-off-by: Krzysztof Opasiak 
---
 drivers/usb/gadget/function/f_hid.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index a2612fb..e3fb9ec 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -437,12 +437,19 @@ static int hidg_setup(struct usb_function *f,
  | USB_REQ_GET_DESCRIPTOR):
switch (value >> 8) {
case HID_DT_HID:
+   {
+   struct hid_descriptor hidg_desc_copy = hidg_desc;
+   hidg_desc_copy.desc[0].bDescriptorType = HID_DT_REPORT;
+   hidg_desc_copy.desc[0].wDescriptorLength =
+   cpu_to_le16(hidg->report_desc_length);
+
VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: HID\n");
length = min_t(unsigned short, length,
-  hidg_desc.bLength);
-   memcpy(req->buf, &hidg_desc, length);
+  hidg_desc_copy.bLength);
+   memcpy(req->buf, &hidg_desc_copy, length);
goto respond;
break;
+   }
case HID_DT_REPORT:
VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: REPORT\n");
length = min_t(unsigned short, length,
@@ -632,6 +639,8 @@ static int hidg_bind(struct usb_configuration *c, struct 
usb_function *f)
hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
+   /* We can use hidg_desc struct here but we should not relay
+  that its content won't change after returning */
hidg_desc.desc[0].bDescriptorType = HID_DT_REPORT;
hidg_desc.desc[0].wDescriptorLength =
cpu_to_le16(hidg->report_desc_length);
-- 
1.9.1

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


Re: [PATCH] usb: gadget: hid: Fix static variable usage

2015-03-26 Thread Sergei Shtylyov

Hello.

On 03/26/2015 06:03 PM, Krzysztof Opasiak wrote:


If we have multiple instances of hid function, each of
them may have different report descriptor, also their
length may be different.



Currently we are using static hidg_desc varable which
is being filled in hidg_bind(). Then we send its content
to host in hidg_setup() function. This content may
have been already overwriten if another instance
has executed hidg_bind().



Signed-off-by: Krzysztof Opasiak 
---
  drivers/usb/gadget/function/f_hid.c | 13 +++--
  1 file changed, 11 insertions(+), 2 deletions(-)



diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index a2612fb..e3fb9ec 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c

[...]

@@ -632,6 +639,8 @@ static int hidg_bind(struct usb_configuration *c, struct 
usb_function *f)
hidg_fs_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
hidg_hs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
hidg_fs_out_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
+   /* We can use hidg_desc struct here but we should not relay
+  that its content won't change after returning */


   The preferred multi-line comment style is:

/*
 * bla
 * bla
 */

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


Need a phy function to enable / disable usb squelch detection

2015-03-26 Thread Hans de Goede

Hi Kishon,

I've been debugging why some devices do not work with
the musb otg controller found on Allwinner SoC-s, and the
conclusion is not good, the Android kernel does a
poke to the phy before releasing the usb reset.

Now you did not want me to introduce any sunxi specific /
private phy functions in my initial patch-series for adding
sunxi support, but in this case I do not really see an
alternative, as this is a very platform specific hack
to work around an issue with the phy-s squelch detection
which causes it to see a squelch when reset is released
switching it to high speed mode when a lo speed device
is connected, after which things fall apart.

I'm open to some generic solution for this, but I do
not see one myself.

Thanks & Regards,

Hans

p.s.

A review of my existing sun4i-usb-phy otg support work
would be appreciated, this squelch thing is best left
as a fix on top.
--
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/3] phy: core: Add devm_of_phy_get_by_index to phy-core

2015-03-26 Thread Dmitry Torokhov
On Wed, Mar 25, 2015 at 05:04:32PM -0700, Arun Ramamurthy wrote:
> 
> 
> On 15-03-25 03:03 PM, Kishon Vijay Abraham I wrote:
> >Hi,
> >
> >On Saturday 21 March 2015 02:59 AM, Arun Ramamurthy wrote:
> >>
> >>
> >>On 15-03-20 02:26 PM, Dmitry Torokhov wrote:
> >>>Hi Arun,
> >>>
> >>>On Fri, Mar 20, 2015 at 02:07:08PM -0700, Arun Ramamurthy wrote:
> Adding devm_of_phy_get_by_index to get phys by supplying an index
> and not a phy name when multiple phys are declared
> >
> >I think a bit more explanation on why get_by_index is needed here.
> Thanks Kison. Can you be more specific? I am unsure of what more I
> can explain here.

We just need to mention that some generic drivers, such as ehci, may use
multiple phys, and for such drivers referencing phy(s) by name(s) does
not make sense. Instead of inventing elaborate naming schemes and
producing custom code to iterate over names, such drivers are better of
using nameless phy bindings and using this newly introduced API to
iterate through them.

Thanks.

-- 
Dmitry
--
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: Fix warnings in chaoskey driver

2015-03-26 Thread keithp
From: Keith Packard 

>drivers/usb/misc/chaoskey.c: In function 'chaoskey_read':
> >> drivers/usb/misc/chaoskey.c:412:3: error: implicit declaration of function 
> >> 'copy_to_user'
> >> [-Werror=implicit-function-declaration]
>   remain = copy_to_user(buffer, dev->buf + dev->used, this_time);

I was unable to reproduce this locally, but added an explicit

#include 

which should ensure the definition on all architectures.

> sparse warnings: (new ones prefixed by >>)
>
> >> drivers/usb/misc/chaoskey.c:117:30: sparse: incorrect type in assignment 
> >> (different base types)
>drivers/usb/misc/chaoskey.c:117:30:expected int [signed] size
>drivers/usb/misc/chaoskey.c:117:30:got restricted __le16 [usertype] 
> wMaxPacketSize

Switched the code to using the USB descriptor accessor functions.

Signed-off-by: Keith Packard 
---
 drivers/usb/misc/chaoskey.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index ef80ce9..3ad5d19 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -27,6 +27,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static struct usb_driver chaoskey_driver;
 static struct usb_class_driver chaoskey_class;
@@ -113,8 +115,8 @@ static int chaoskey_probe(struct usb_interface *interface,
/* Find the first bulk IN endpoint and its packet size */
for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
if (usb_endpoint_is_bulk_in(&altsetting->endpoint[i].desc)) {
-   in_ep = altsetting->endpoint[i].desc.bEndpointAddress;
-   size = altsetting->endpoint[i].desc.wMaxPacketSize;
+   in_ep = usb_endpoint_num(&altsetting->endpoint[i].desc);
+   size = usb_endpoint_maxp(&altsetting->endpoint[i].desc);
break;
}
}
-- 
2.1.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: Need a phy function to enable / disable usb squelch detection

2015-03-26 Thread Peter Chen
 
> Hi Kishon,
> 
> I've been debugging why some devices do not work with the musb otg
> controller found on Allwinner SoC-s, and the conclusion is not good, the
> Android kernel does a poke to the phy before releasing the usb reset.
> 
> Now you did not want me to introduce any sunxi specific / private phy
> functions in my initial patch-series for adding sunxi support, but in this 
> case I do
> not really see an alternative, as this is a very platform specific hack to 
> work
> around an issue with the phy-s squelch detection which causes it to see a
> squelch when reset is released switching it to high speed mode when a lo
> speed device is connected, after which things fall apart.
> 

The nofity_connect API at struct usb_phy may satisfy your requirement,
it will be called after bus rest has finished.

Peter



[PATCH] usb: gadget: s3c2410_udc: Remove static char buffer, use vsprintf extension %pV

2015-03-26 Thread Joe Perches
Using unnecessary static char buffers isn't good.
Use the %pV extension instead.

Miscellanea:

o the dprintk return value is unused, make it void
o add __printf format and argument verification

Signed-off-by: Joe Perches 
---
This doesn't matter much as it is pretty unusual to enable
printk support and CONFIG_USB_S3C2410_DEBUG for this board.

This is just for completeness.

Compiled with and without printk support, but otherwise untested.

 drivers/usb/gadget/udc/s3c2410_udc.c | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c 
b/drivers/usb/gadget/udc/s3c2410_udc.c
index b808951..2979575 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -92,40 +92,38 @@ static struct s3c2410_udc_mach_info *udc_info;
 
 static uint32_t s3c2410_ticks = 0;
 
-static int dprintk(int level, const char *fmt, ...)
+__printf(2, 3)
+static void dprintk(int level, const char *fmt, ...)
 {
-   static char printk_buf[1024];
static long prevticks;
static int invocation;
+   struct va_format vaf;
va_list args;
-   int len;
 
if (level > USB_S3C2410_DEBUG_LEVEL)
-   return 0;
+   return;
+
+   va_start(args, fmt);
+
+   vaf.fmt = fmt;
+   vaf.va = &args;
 
if (s3c2410_ticks != prevticks) {
prevticks = s3c2410_ticks;
invocation = 0;
}
 
-   len = scnprintf(printk_buf,
-   sizeof(printk_buf), "%1lu.%02d USB: ",
-   prevticks, invocation++);
+   pr_debug("%1lu.%02d USB: %pV", prevticks, invocation++, &vaf);
 
-   va_start(args, fmt);
-   len = vscnprintf(printk_buf+len,
-   sizeof(printk_buf)-len, fmt, args);
va_end(args);
-
-   pr_debug("%s", printk_buf);
-   return len;
 }
 #else
-static int dprintk(int level, const char *fmt, ...)
+__printf(2, 3)
+static void dprintk(int level, const char *fmt, ...)
 {
-   return 0;
 }
 #endif
+
 static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p)
 {
u32 addr_reg, pwr_reg, ep_int_reg, usb_int_reg;


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