Re: Errata for Freescale root-hub TT?

2015-03-24 Thread Peter Chen
On Mon, Mar 23, 2015 at 10:11:04AM -0400, Alan Stern wrote:
> On Mon, 23 Mar 2015, Peter Chen wrote:
> 
> > For going on debugging this problem, we need
> 
> I will have the hardware only for one more day, so I may not be able to
> get all the information you want.
> 
> > - Your bus analyzer file, I think there should be no enough IN/OUT
> > tokens within one frame, does the remaining time to frame boundaries
> > is enough? 
> 
> Here's an example: There are four OUT transfers near the start of the 
> frame, and they take about 300 us.  The remaining 700 us in the frame 
> are completely idle, even though they should contain four IN transfers.

How do you know the frame has filled already at that time? The software
makes sure it fills frame in time before next time frame?

-- 

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] usb: gadget: Check for NULL pointer in disconnect

2015-03-24 Thread Peter Chen
On Mon, Mar 23, 2015 at 04:00:37PM -0700, Badhri Jagan Sridharan wrote:
> > Do you really see some udc drivers call it after composite_unbind is
> > called? If it is, you may add dump_stack() to track that error.
> >
> > Besides this, function suspended_show is needed to add cdev NULL pointer
> > checking.
> 
> We see this happening occasionally in *not yet* upstreamed UDC
> code of some vendors (Yes, disconnect being called after unbind)

Does it a spurious interrupt?
I guess if you add struct usb_gadget_driver NULL pointer check check, it
will not occur:
if (you_udc->driver)
you_udc->driver->disconnect(&you_udc->gadget);
 
> After reviewing the entire composite.c file, I did notice that
> none of the functions check for NULL pointer when cdev is
> obtained from get_gadget_data.
> Is crashing/bringing down the whole kernel intentionally
> left to happen ?

Hmm, I don't think, the design may think it never occurs.

> Isn't printing a WARN/ERROR msg and
> returning not the preferable approach ?

I think BUG_ON is more suitable, let's see Felipe's comment.

> 
> On 03/22/2015 12:43 AM, Peter Chen wrote:
> >On Fri, Mar 20, 2015 at 04:40:52PM -0700, Badhri Jagan Sridharan wrote:
> >>Added a safety net to make sure that
> >>composite_disconnect does not end up disconneting
> >>a NULL device. Prevents NULL pointer crash.
> >>
> >>Signed-off-by: Badhri Jagan Sridharan 
> >>---
> >>  drivers/usb/gadget/composite.c | 5 +
> >>  1 file changed, 5 insertions(+)
> >>
> >>diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> >>index 13adfd1..90b37bd 100644
> >>--- a/drivers/usb/gadget/composite.c
> >>+++ b/drivers/usb/gadget/composite.c
> >>@@ -1823,6 +1823,11 @@ void composite_disconnect(struct usb_gadget *gadget)
> >>struct usb_composite_dev*cdev = get_gadget_data(gadget);
> >>unsigned long   flags;
> >>
> >>+   if (!cdev) {
> >>+   WARN(1, "Trying to disconnect a NULL composite device\n");
> >>+   return;
> >>+   }
> >>+
> >
> >Do you really see some udc drivers call it after composite_unbind is
> >called? If it is, you may add dump_stack() to track that error.
> >
> >Besides this, function suspended_show is needed to add cdev NULL pointer
> >checking.
> >
> >>/* REVISIT:  should we have config and device level
> >> * disconnect callbacks?
> >> */
> >>--
> >>2.2.0.rc0.207.ga3a616c
> >>
> >>--
> >>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


[PATCH v4 00/22] usb: third series of updates for dwc2 driver

2015-03-24 Thread Mian Yousaf Kaukab
Hi,
This patchset consists of some bug fixes and feature enhancements for
the dwc2 driver. All the patches are verified on dwc2 v3.0a with
dedicated fifos. Main focus of testing was with dma enabled. Although
basic testing without dma was also done.

This is based on testing/next branch in Felipe's git.

Thank you,

Best regards,
Yousaf

History:
v4:
 - Fixed comment from Julius Werner
v3:
 - Fixed comments from Julius Werner and Sergei Shtylyov
 - Dropped "usb: dwc2: allow dwc2_pci to be a module even when dwc2 is 
statically linked"
   due to http://marc.info/?l=linux-usb&m=142661773703793&w=2
 - "usb: dwc2: host: ensure qtb exists before dereferencing it" is added
   to fix a NULL pointer dereferencing bug
v2:
 - Fixed comments from John Youn and Julius Werner
 - Fixed regression, found by John, when switching to gadget mode
   after running host mode
 - Added patch to add core parameter for enabling/disabling hibernation
 - Added patch to build dwc2_pci.ko independent from dwc2.ko
v1:
 - Fixed comments from John Youn and Robert Baldyga
 - Dropped all changes to pci.c due to
   http://permalink.gmane.org/gmane.linux.usb.general/123411
 - Added patch to remove unnecessary EXPORT_SYMBOL_GPL calls

Gregory Herrero (15):
  usb: dwc2: add controller hibernation support
  usb: dwc2: implement hibernation during bus suspend/resume
  usb: dwc2: controller must update lx_state before releasing lock
  usb: dwc2: add external_id_pin_ctl core parameter
  usb: dwc2: gadget: use reset detect interrupt
  usb: dwc2: gadget: ignore pm suspend/resume in L2
  usb: dwc2: gadget: prevent new request submission during suspend
  usb: dwc2: gadget: powerup controller if needed
  usb: dwc2: gadget: enable otg flag in dual role configuration
  usb: dwc2: host: add bus_suspend/bus_resume callback
  usb: dwc2: host: resume root hub on port connect
  usb: dwc2: host: spinlock urb_enqueue
  usb: dwc2: host: don't use dma_alloc_coherent with irqs disabled
  usb: dwc2: add hibernation core parameter
  usb: dwc2: host: ensure qtb exists before dereferencing it

Jingwu Lin (1):
  usb: dwc2: host: implement test mode

Mian Yousaf Kaukab (6):
  usb: dwc2: move debugfs code to a separate file
  usb: dwc2: debugfs: add support for complete register dump
  usb: dwc2: set parameter values in probe function
  usb: dwc2: gadget: remove s3c_hsotg_ep_disable_force
  usb: dwc2: host: register handle to the phy
  usb: dwc2: remove dwc2_platform.ko

 drivers/usb/dwc2/Kconfig |   8 -
 drivers/usb/dwc2/Makefile|   9 +-
 drivers/usb/dwc2/core.c  | 439 +++-
 drivers/usb/dwc2/core.h  | 120 ++-
 drivers/usb/dwc2/core_intr.c |  45 ++-
 drivers/usb/dwc2/debug.h |  27 ++
 drivers/usb/dwc2/debugfs.c   | 771 +++
 drivers/usb/dwc2/gadget.c| 459 +++---
 drivers/usb/dwc2/hcd.c   | 100 +++---
 drivers/usb/dwc2/hcd.h   |   7 +-
 drivers/usb/dwc2/hcd_intr.c  |  66 +++-
 drivers/usb/dwc2/hcd_queue.c |  15 +-
 drivers/usb/dwc2/platform.c  |  25 +-
 13 files changed, 1570 insertions(+), 521 deletions(-)
 create mode 100644 drivers/usb/dwc2/debug.h
 create mode 100644 drivers/usb/dwc2/debugfs.c

-- 
2.3.3

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


[PATCH v4 02/22] usb: dwc2: debugfs: add support for complete register dump

2015-03-24 Thread Mian Yousaf Kaukab
Dump all registers to take a complete snapshot of dwc2 state.
Code is inspired by dwc3/debugfs.c

Signed-off-by: Mian Yousaf Kaukab 
---
 drivers/usb/dwc2/core.h|   1 +
 drivers/usb/dwc2/debugfs.c | 357 +
 2 files changed, 358 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 3695c6f..1fd8d2b 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -615,6 +615,7 @@ struct dwc2_hsotg {
enum dwc2_lx_state lx_state;
 
struct dentry *debug_root;
+   struct debugfs_regset32 *regset;
 
/* DWC OTG HW Release versions */
 #define DWC2_CORE_REV_2_71a0x4f54271a
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index e57e554..af89537 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -391,9 +391,344 @@ static inline void s3c_hsotg_create_debug(struct 
dwc2_hsotg *hsotg) {}
 
 /* s3c_hsotg_delete_debug is removed as cleanup in done in dwc2_debugfs_exit */
 
+#define dump_register(nm)  \
+{  \
+   .name   = #nm,  \
+   .offset = nm,   \
+}
+
+static const struct debugfs_reg32 dwc2_regs[] = {
+   /*
+* Accessing registers like this can trigger mode mismatch interrupt.
+* However, according to dwc2 databook, the register access, in this
+* case, is completed on the processor bus but is ignored by the core
+* and does not affect its operation.
+*/
+   dump_register(GOTGCTL),
+   dump_register(GOTGINT),
+   dump_register(GAHBCFG),
+   dump_register(GUSBCFG),
+   dump_register(GRSTCTL),
+   dump_register(GINTSTS),
+   dump_register(GINTMSK),
+   dump_register(GRXSTSR),
+   dump_register(GRXSTSP),
+   dump_register(GRXFSIZ),
+   dump_register(GNPTXFSIZ),
+   dump_register(GNPTXSTS),
+   dump_register(GI2CCTL),
+   dump_register(GPVNDCTL),
+   dump_register(GGPIO),
+   dump_register(GUID),
+   dump_register(GSNPSID),
+   dump_register(GHWCFG1),
+   dump_register(GHWCFG2),
+   dump_register(GHWCFG3),
+   dump_register(GHWCFG4),
+   dump_register(GLPMCFG),
+   dump_register(GPWRDN),
+   dump_register(GDFIFOCFG),
+   dump_register(ADPCTL),
+   dump_register(HPTXFSIZ),
+   dump_register(DPTXFSIZN(1)),
+   dump_register(DPTXFSIZN(2)),
+   dump_register(DPTXFSIZN(3)),
+   dump_register(DPTXFSIZN(4)),
+   dump_register(DPTXFSIZN(5)),
+   dump_register(DPTXFSIZN(6)),
+   dump_register(DPTXFSIZN(7)),
+   dump_register(DPTXFSIZN(8)),
+   dump_register(DPTXFSIZN(9)),
+   dump_register(DPTXFSIZN(10)),
+   dump_register(DPTXFSIZN(11)),
+   dump_register(DPTXFSIZN(12)),
+   dump_register(DPTXFSIZN(13)),
+   dump_register(DPTXFSIZN(14)),
+   dump_register(DPTXFSIZN(15)),
+   dump_register(DCFG),
+   dump_register(DCTL),
+   dump_register(DSTS),
+   dump_register(DIEPMSK),
+   dump_register(DOEPMSK),
+   dump_register(DAINT),
+   dump_register(DAINTMSK),
+   dump_register(DTKNQR1),
+   dump_register(DTKNQR2),
+   dump_register(DTKNQR3),
+   dump_register(DTKNQR4),
+   dump_register(DVBUSDIS),
+   dump_register(DVBUSPULSE),
+   dump_register(DIEPCTL(0)),
+   dump_register(DIEPCTL(1)),
+   dump_register(DIEPCTL(2)),
+   dump_register(DIEPCTL(3)),
+   dump_register(DIEPCTL(4)),
+   dump_register(DIEPCTL(5)),
+   dump_register(DIEPCTL(6)),
+   dump_register(DIEPCTL(7)),
+   dump_register(DIEPCTL(8)),
+   dump_register(DIEPCTL(9)),
+   dump_register(DIEPCTL(10)),
+   dump_register(DIEPCTL(11)),
+   dump_register(DIEPCTL(12)),
+   dump_register(DIEPCTL(13)),
+   dump_register(DIEPCTL(14)),
+   dump_register(DIEPCTL(15)),
+   dump_register(DOEPCTL(0)),
+   dump_register(DOEPCTL(1)),
+   dump_register(DOEPCTL(2)),
+   dump_register(DOEPCTL(3)),
+   dump_register(DOEPCTL(4)),
+   dump_register(DOEPCTL(5)),
+   dump_register(DOEPCTL(6)),
+   dump_register(DOEPCTL(7)),
+   dump_register(DOEPCTL(8)),
+   dump_register(DOEPCTL(9)),
+   dump_register(DOEPCTL(10)),
+   dump_register(DOEPCTL(11)),
+   dump_register(DOEPCTL(12)),
+   dump_register(DOEPCTL(13)),
+   dump_register(DOEPCTL(14)),
+   dump_register(DOEPCTL(15)),
+   dump_register(DIEPINT(0)),
+   dump_register(DIEPINT(1)),
+   dump_register(DIEPINT(2)),
+   dump_register(DIEPINT(3)),
+   dump_register(DIEPINT(4)),
+   dump_register(DIEPINT(5)),
+   dump_register(DIEPINT(6)),
+   dump_register(DIEPINT(7)),
+   dump_register(DIEPINT(8)),
+   dump_register(DIEPINT(9)),
+   dump_register(DIEPINT(10)),
+   dump_register(DIEPINT(11)),
+   dump_register(DIEPINT(12)),
+   dump_register(DIEPINT(13)),
+   dump_register(DIEPINT(14)),
+   dum

[PATCH v4 01/22] usb: dwc2: move debugfs code to a separate file

2015-03-24 Thread Mian Yousaf Kaukab
Prepare to add more debug code. Moreover, don't save dentry * for
each file in struct dwc2_hsotg as clean up is done with
debugfs_remove_recursive(). s3c_hsotg_delete_debug() is removed
altogether for the same reason.

Signed-off-by: Mian Yousaf Kaukab 
---
 drivers/usb/dwc2/Makefile   |   4 +
 drivers/usb/dwc2/core.h |   7 +-
 drivers/usb/dwc2/debug.h|  27 +++
 drivers/usb/dwc2/debugfs.c  | 416 
 drivers/usb/dwc2/gadget.c   | 405 +-
 drivers/usb/dwc2/platform.c |   4 +
 6 files changed, 456 insertions(+), 407 deletions(-)
 create mode 100644 drivers/usb/dwc2/debug.h
 create mode 100644 drivers/usb/dwc2/debugfs.c

diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index f07b425..324fbb4 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -13,6 +13,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC2_PERIPHERAL) 
$(CONFIG_USB_DWC2_DUAL_ROLE)),)
dwc2-y  += gadget.o
 endif
 
+ifneq ($(CONFIG_DEBUG_FS),)
+   dwc2-y  += debugfs.o
+endif
+
 # NOTE: The previous s3c-hsotg peripheral mode only driver has been moved to
 # this location and renamed gadget.c. When building for dynamically linked
 # modules, dwc2.ko will get built for host mode, peripheral mode, and dual-role
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 836c012..3695c6f 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -615,9 +615,6 @@ struct dwc2_hsotg {
enum dwc2_lx_state lx_state;
 
struct dentry *debug_root;
-   struct dentry *debug_file;
-   struct dentry *debug_testmode;
-   struct dentry *debug_fifo;
 
/* DWC OTG HW Release versions */
 #define DWC2_CORE_REV_2_71a0x4f54271a
@@ -1005,6 +1002,7 @@ extern void s3c_hsotg_core_init_disconnected(struct 
dwc2_hsotg *dwc2,
bool reset);
 extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
 #else
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
@@ -1018,6 +1016,9 @@ static inline void 
s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
bool reset) {}
 static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
 static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
+static inline int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
+   int testmode)
+{ return 0; }
 #endif
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/debug.h b/drivers/usb/dwc2/debug.h
new file mode 100644
index 000..12dbd1d
--- /dev/null
+++ b/drivers/usb/dwc2/debug.h
@@ -0,0 +1,27 @@
+/**
+ * debug.h - Designware USB2 DRD controller debug header
+ *
+ * Copyright (C) 2015 Intel Corporation
+ * Mian Yousaf Kaukab 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include "core.h"
+
+#ifdef CONFIG_DEBUG_FS
+extern int dwc2_debugfs_init(struct dwc2_hsotg *);
+extern void dwc2_debugfs_exit(struct dwc2_hsotg *);
+#else
+static inline int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
+{  return 0;  }
+static inline void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg)
+{  }
+#endif
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
new file mode 100644
index 000..e57e554
--- /dev/null
+++ b/drivers/usb/dwc2/debugfs.c
@@ -0,0 +1,416 @@
+/**
+ * debugfs.c - Designware USB2 DRD controller debugfs
+ *
+ * Copyright (C) 2015 Intel Corporation
+ * Mian Yousaf Kaukab 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "debug.h"
+
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+   IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * testmode_write - debugfs: change usb test mode
+ * @seq: The seq file to write to.
+ * @v: Unused parameter.
+ *
+ * This debugfs entry modify the current usb test mode.
+ */
+static ssize_t testm

[PATCH v4 04/22] usb: dwc2: implement hibernation during bus suspend/resume

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Allow controller to enter in hibernation during usb bus suspend and
inform both phy and gadget about the suspended state.
While in hibernation, the controller can't detect the resume condition.
An external mechanism must call usb_phy_set_suspend on resume.
Exit hibernation when controller gets the resume interrupt and inform
only gadget driver about it.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/core.h  |  2 ++
 drivers/usb/dwc2/core_intr.c | 32 
 2 files changed, 34 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index b0ee951..e6abc28 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1088,6 +1088,7 @@ extern void s3c_hsotg_core_init_disconnected(struct 
dwc2_hsotg *dwc2,
 extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
 extern int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
+#define dwc2_is_device_connected(hsotg) (hsotg->connected)
 #else
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
@@ -1104,6 +1105,7 @@ static inline void s3c_hsotg_disconnect(struct dwc2_hsotg 
*dwc2) {}
 static inline int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
int testmode)
 { return 0; }
+#define dwc2_is_device_connected(hsotg) (0)
 #endif
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 02e3e2d..42f2fd5 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -334,6 +334,7 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg 
*hsotg)
  */
 static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
 {
+   int ret;
dev_dbg(hsotg->dev, "++Resume or Remote Wakeup Detected Interrupt++\n");
dev_dbg(hsotg->dev, "%s lxstate = %d\n", __func__, hsotg->lx_state);
 
@@ -345,6 +346,11 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
/* Clear Remote Wakeup Signaling */
dctl &= ~DCTL_RMTWKUPSIG;
writel(dctl, hsotg->regs + DCTL);
+   ret = dwc2_exit_hibernation(hsotg, true);
+   if (ret)
+   dev_err(hsotg->dev, "exit hibernation 
failed\n");
+
+   call_gadget(hsotg, resume);
}
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
@@ -394,6 +400,7 @@ static void dwc2_handle_disconnect_intr(struct dwc2_hsotg 
*hsotg)
 static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg)
 {
u32 dsts;
+   int ret;
 
dev_dbg(hsotg->dev, "USB SUSPEND\n");
 
@@ -408,6 +415,30 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
"DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n",
!!(dsts & DSTS_SUSPSTS),
hsotg->hw_params.power_optimized);
+   if ((dsts & DSTS_SUSPSTS) && hsotg->hw_params.power_optimized) {
+   /* Ignore suspend request before enumeration */
+   if (!dwc2_is_device_connected(hsotg)) {
+   dev_dbg(hsotg->dev,
+   "ignore suspend request before 
enumeration\n");
+   goto clear_int;
+   }
+
+   ret = dwc2_enter_hibernation(hsotg);
+   if (ret) {
+   dev_err(hsotg->dev,
+   "enter hibernation failed\n");
+   goto skip_power_saving;
+   }
+
+   udelay(100);
+
+   /* Ask phy to be suspended */
+   if (!IS_ERR_OR_NULL(hsotg->uphy))
+   usb_phy_set_suspend(hsotg->uphy, true);
+skip_power_saving:
+   /* Call gadget suspend callback */
+   call_gadget(hsotg, suspend);
+   }
} else {
if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg->dev, "a_peripheral->a_host\n");
@@ -423,6 +454,7 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
/* Change to L2 (suspend) state */
hsotg->lx_state = DWC2_L2;
 
+clear_int:
/* Clear interrupt */
writel(GINTSTS_USBSUSP, hsotg->regs + GINTSTS);
 }
-- 
2.3.3

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


[PATCH v4 03/22] usb: dwc2: add controller hibernation support

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

When suspending usb bus, phy driver may disable controller power.
In this case, registers need to be saved on suspend and restored
on resume.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/core.c | 377 
 drivers/usb/dwc2/core.h |  84 +++
 2 files changed, 461 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index d5197d4..889dc5f 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -56,6 +56,383 @@
 #include "core.h"
 #include "hcd.h"
 
+#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * dwc2_backup_host_registers() - Backup controller host registers.
+ * When suspending usb bus, registers needs to be backuped
+ * if controller power is disabled once suspended.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ */
+static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
+{
+   struct dwc2_hregs_backup *hr;
+   int i;
+
+   dev_dbg(hsotg->dev, "%s\n", __func__);
+
+   /* Backup Host regs */
+   hr = hsotg->hr_backup;
+   if (!hr) {
+   hr = devm_kzalloc(hsotg->dev, sizeof(*hr), GFP_KERNEL);
+   if (!hr) {
+   dev_err(hsotg->dev, "%s: can't allocate host regs\n",
+   __func__);
+   return -ENOMEM;
+   }
+
+   hsotg->hr_backup = hr;
+   }
+   hr->hcfg = readl(hsotg->regs + HCFG);
+   hr->haintmsk = readl(hsotg->regs + HAINTMSK);
+   for (i = 0; i < hsotg->core_params->host_channels; ++i)
+   hr->hcintmsk[i] = readl(hsotg->regs + HCINTMSK(i));
+
+   hr->hprt0 = readl(hsotg->regs + HPRT0);
+   hr->hfir = readl(hsotg->regs + HFIR);
+
+   return 0;
+}
+
+/**
+ * dwc2_restore_host_registers() - Restore controller host registers.
+ * When resuming usb bus, device registers needs to be restored
+ * if controller power were disabled.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ */
+static int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
+{
+   struct dwc2_hregs_backup *hr;
+   int i;
+
+   dev_dbg(hsotg->dev, "%s\n", __func__);
+
+   /* Restore host regs */
+   hr = hsotg->hr_backup;
+   if (!hr) {
+   dev_err(hsotg->dev, "%s: no host registers to restore\n",
+   __func__);
+   return -EINVAL;
+   }
+
+   writel(hr->hcfg, hsotg->regs + HCFG);
+   writel(hr->haintmsk, hsotg->regs + HAINTMSK);
+
+   for (i = 0; i < hsotg->core_params->host_channels; ++i)
+   writel(hr->hcintmsk[i], hsotg->regs + HCINTMSK(i));
+
+   writel(hr->hprt0, hsotg->regs + HPRT0);
+   writel(hr->hfir, hsotg->regs + HFIR);
+
+   return 0;
+}
+#else
+static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
+{ return 0; }
+
+static inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
+{ return 0; }
+#endif
+
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+   IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * dwc2_backup_device_registers() - Backup controller device registers.
+ * When suspending usb bus, registers needs to be backuped
+ * if controller power is disabled once suspended.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ */
+static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
+{
+   struct dwc2_dregs_backup *dr;
+   int i;
+
+   dev_dbg(hsotg->dev, "%s\n", __func__);
+
+   /* Backup dev regs */
+   dr = hsotg->dr_backup;
+   if (!dr) {
+   dr = devm_kzalloc(hsotg->dev, sizeof(*dr), GFP_KERNEL);
+   if (!dr) {
+   dev_err(hsotg->dev, "%s: can't allocate device regs\n",
+   __func__);
+   return -ENOMEM;
+   }
+
+   hsotg->dr_backup = dr;
+   }
+
+   dr->dcfg = readl(hsotg->regs + DCFG);
+   dr->dctl = readl(hsotg->regs + DCTL);
+   dr->daintmsk = readl(hsotg->regs + DAINTMSK);
+   dr->diepmsk = readl(hsotg->regs + DIEPMSK);
+   dr->doepmsk = readl(hsotg->regs + DOEPMSK);
+
+   for (i = 0; i < hsotg->num_of_eps; i++) {
+   /* Backup IN EPs */
+   dr->diepctl[i] = readl(hsotg->regs + DIEPCTL(i));
+
+   /* Ensure DATA PID is correctly configured */
+   if (dr->diepctl[i] & DXEPCTL_DPID)
+   dr->diepctl[i] |= DXEPCTL_SETD1PID;
+   else
+   dr->diepctl[i] |= DXEPCTL_SETD0PID;
+
+   dr->dieptsiz[i] = readl(hsotg->regs + DIEPTSIZ(i));
+   dr->diepdma[i] = readl(hsotg->regs + DIEPDMA(i));
+
+   /* Backup OUT EPs */
+   dr->doepctl[i] = readl(hsotg->regs + DOEPCTL(i));
+
+   /* Ensure DATA PID is correctly configured */
+   if (dr->doepctl[i] &

[PATCH v4 14/22] usb: dwc2: host: register handle to the phy

2015-03-24 Thread Mian Yousaf Kaukab
If phy driver is present register hcd handle to it.

Signed-off-by: Mian Yousaf Kaukab 
---
 drivers/usb/dwc2/hcd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 1cca5e0..919658e 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2913,6 +2913,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
/* Don't support SG list at this point */
hcd->self.sg_tablesize = 0;
 
+   if (!IS_ERR_OR_NULL(hsotg->uphy))
+   otg_set_host(hsotg->uphy->otg, &hcd->self);
+
/*
 * Finish generic HCD initialization and start the HCD. This function
 * allocates the DMA buffer pool, registers the USB bus, requests the
@@ -2966,6 +2969,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
return;
}
 
+   if (!IS_ERR_OR_NULL(hsotg->uphy))
+   otg_set_host(hsotg->uphy->otg, NULL);
+
usb_remove_hcd(hcd);
hsotg->priv = NULL;
dwc2_hcd_release(hsotg);
-- 
2.3.3

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


[PATCH v4 13/22] usb: dwc2: gadget: remove s3c_hsotg_ep_disable_force

2015-03-24 Thread Mian Yousaf Kaukab
Force argument is not used anymore. Clean up leftovers from
https://lkml.org/lkml/2014/12/9/283

Signed-off-by: Mian Yousaf Kaukab 
---
 drivers/usb/dwc2/gadget.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index eb906bd..2b73615 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2764,7 +2764,7 @@ error:
  * s3c_hsotg_ep_disable - disable given endpoint
  * @ep: The endpoint to disable.
  */
-static int s3c_hsotg_ep_disable_force(struct usb_ep *ep, bool force)
+static int s3c_hsotg_ep_disable(struct usb_ep *ep)
 {
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
struct dwc2_hsotg *hsotg = hs_ep->parent;
@@ -2807,10 +2807,6 @@ static int s3c_hsotg_ep_disable_force(struct usb_ep *ep, 
bool force)
return 0;
 }
 
-static int s3c_hsotg_ep_disable(struct usb_ep *ep)
-{
-   return s3c_hsotg_ep_disable_force(ep, false);
-}
 /**
  * on_list - check request is on the given endpoint
  * @ep: The endpoint to check.
-- 
2.3.3

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


[PATCH v4 11/22] usb: dwc2: gadget: powerup controller if needed

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

During vbus session, usb controller needs to exit hibernation if it was
previously in suspend state.
Since controller will be resetted and configured, there is no need
to restore registers.

Moreover, set lx_state to L0 on B session. vbus_session callback may
not be used by all platforms. Thus, controller software state needs
to be set to L0 if the controller detects a valid B session.
Otherwise, lx_state will remain L2 and prevent any request submission.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/gadget.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 732761f..56a08ac 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2515,6 +2515,7 @@ irq_retry:
kill_all_requests(hsotg, hsotg->eps_out[0],
  -ECONNRESET);
 
+   hsotg->lx_state = DWC2_L0;
s3c_hsotg_core_init_disconnected(hsotg, true);
}
}
@@ -3205,6 +3206,14 @@ static int s3c_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
spin_lock_irqsave(&hsotg->lock, flags);
 
if (is_active) {
+   /*
+* If controller is hibernated, it must exit from hibernation
+* before being initialized
+*/
+   if (hsotg->lx_state == DWC2_L2) {
+   dwc2_exit_hibernation(hsotg, false);
+   hsotg->lx_state = DWC2_L0;
+   }
/* Kill any ep0 requests as controller will be reinitialized */
kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
s3c_hsotg_core_init_disconnected(hsotg, false);
-- 
2.3.3

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


[PATCH v4 12/22] usb: dwc2: gadget: enable otg flag in dual role configuration

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 56a08ac..eb906bd 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3525,6 +3525,8 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
hsotg->gadget.max_speed = USB_SPEED_HIGH;
hsotg->gadget.ops = &s3c_hsotg_gadget_ops;
hsotg->gadget.name = dev_name(dev);
+   if (hsotg->dr_mode == USB_DR_MODE_OTG)
+   hsotg->gadget.is_otg = 1;
 
/* reset the system */
 
-- 
2.3.3

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


[PATCH v4 10/22] usb: dwc2: gadget: prevent new request submission during suspend

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

If usb controller is in partial power down, any write to registers may
cause unpredictable behavior.
Thus, prevent any new request submission once controller is in partial
power down.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/gadget.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index a360f49..732761f 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -790,6 +790,13 @@ static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct 
usb_request *req,
ep->name, req, req->length, req->buf, req->no_interrupt,
req->zero, req->short_not_ok);
 
+   /* Prevent new request submission when controller is suspended */
+   if (hs->lx_state == DWC2_L2) {
+   dev_dbg(hs->dev, "%s: don't submit request while suspended\n",
+   __func__);
+   return -EAGAIN;
+   }
+
/* initialise status of the request */
INIT_LIST_HEAD(&hs_req->queue);
req->actual = 0;
-- 
2.3.3

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


[PATCH v4 06/22] usb: dwc2: add external_id_pin_ctl core parameter

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

This is required due to an Intel specific hardware issue. Where id-
pin setup causes glitches on the interrupt line when CONIDSTSCHG
interrupt is enabled.

Specify external_id_pin_ctl when an external driver (for example phy)
can handle id change, so that CONIDSTSCHG interrupt can be disabled
from the controller.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/core.c | 22 +-
 drivers/usb/dwc2/core.h |  6 ++
 drivers/usb/dwc2/platform.c |  2 ++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 889dc5f..8c3bc84 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -454,8 +454,10 @@ static void dwc2_enable_common_interrupts(struct 
dwc2_hsotg *hsotg)
 
if (hsotg->core_params->dma_enable <= 0)
intmsk |= GINTSTS_RXFLVL;
+   if (hsotg->core_params->external_id_pin_ctl <= 0)
+   intmsk |= GINTSTS_CONIDSTSCHNG;
 
-   intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
+   intmsk |= GINTSTS_WKUPINT | GINTSTS_USBSUSP |
  GINTSTS_SESSREQINT;
 
writel(intmsk, hsotg->regs + GINTMSK);
@@ -2979,6 +2981,23 @@ static void dwc2_set_param_uframe_sched(struct 
dwc2_hsotg *hsotg, int val)
hsotg->core_params->uframe_sched = val;
 }
 
+static void dwc2_set_param_external_id_pin_ctl(struct dwc2_hsotg *hsotg,
+   int val)
+{
+   if (DWC2_OUT_OF_BOUNDS(val, 0, 1)) {
+   if (val >= 0) {
+   dev_err(hsotg->dev,
+   "'%d' invalid for parameter 
external_id_pin_ctl\n",
+   val);
+   dev_err(hsotg->dev, "external_id_pin_ctl must be 0 or 
1\n");
+   }
+   val = 0;
+   dev_dbg(hsotg->dev, "Setting external_id_pin_ctl to %d\n", val);
+   }
+
+   hsotg->core_params->external_id_pin_ctl = val;
+}
+
 /*
  * This function is called during module intialization to pass module 
parameters
  * for the DWC_otg core.
@@ -3023,6 +3042,7 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_ahbcfg(hsotg, params->ahbcfg);
dwc2_set_param_otg_ver(hsotg, params->otg_ver);
dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
+   dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
 }
 
 /**
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index e6abc28..e46304d 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -331,6 +331,11 @@ enum dwc2_ep0_state {
  *  by the driver and are ignored in this
  *  configuration value.
  * @uframe_sched:   True to enable the microframe scheduler
+ * @external_id_pin_ctl: Specifies whether ID pin is handled externally.
+ *  Disable CONIDSTSCHNG controller interrupt in such
+ *  case.
+ *  0 - No (default)
+ *  1 - Yes
  *
  * The following parameters may be specified when starting the module. These
  * parameters define how the DWC_otg controller should be configured. A
@@ -368,6 +373,7 @@ struct dwc2_core_params {
int reload_ctl;
int ahbcfg;
int uframe_sched;
+   int external_id_pin_ctl;
 };
 
 /**
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 4fb058b..ce39e8a0 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -77,6 +77,7 @@ static const struct dwc2_core_params params_bcm2835 = {
.reload_ctl = 0,
.ahbcfg = 0x10,
.uframe_sched   = 0,
+   .external_id_pin_ctl= -1,
 };
 
 static const struct dwc2_core_params params_rk3066 = {
@@ -105,6 +106,7 @@ static const struct dwc2_core_params params_rk3066 = {
.reload_ctl = -1,
.ahbcfg = 0x7, /* INCR16 */
.uframe_sched   = -1,
+   .external_id_pin_ctl= -1,
 };
 
 /**
-- 
2.3.3

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


[PATCH v4 09/22] usb: dwc2: gadget: ignore pm suspend/resume in L2

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Nothing to be done in pm suspend/resume when controller is in L2.
Don't disconnect or reset. State is already saved when putting
controller in hibernation and will be restored on USB bus resume.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/gadget.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f867e95..a360f49 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3672,6 +3672,9 @@ int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
unsigned long flags;
int ret = 0;
 
+   if (hsotg->lx_state != DWC2_L0)
+   return ret;
+
mutex_lock(&hsotg->init_mutex);
 
if (hsotg->driver) {
@@ -3712,6 +3715,9 @@ int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
unsigned long flags;
int ret = 0;
 
+   if (hsotg->lx_state == DWC2_L2)
+   return ret;
+
mutex_lock(&hsotg->init_mutex);
 
if (hsotg->driver) {
-- 
2.3.3

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


[PATCH v4 08/22] usb: dwc2: gadget: use reset detect interrupt

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

ResetDet interrupt is used to detect a reset of the bus
while the controller is suspended.
This may happens for example when using Command Verifier.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/gadget.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bed56dc..f867e95 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2308,8 +2308,9 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
writel(GINTSTS_ERLYSUSP | GINTSTS_SESSREQINT |
GINTSTS_GOUTNAKEFF | GINTSTS_GINNAKEFF |
GINTSTS_CONIDSTSCHNG | GINTSTS_USBRST |
-   GINTSTS_ENUMDONE | GINTSTS_OTGINT |
-   GINTSTS_USBSUSP | GINTSTS_WKUPINT,
+   GINTSTS_RESETDET | GINTSTS_ENUMDONE |
+   GINTSTS_OTGINT | GINTSTS_USBSUSP |
+   GINTSTS_WKUPINT,
hsotg->regs + GINTMSK);
 
if (using_dma(hsotg))
@@ -2475,7 +2476,19 @@ irq_retry:
}
}
 
-   if (gintsts & GINTSTS_USBRST) {
+   if (gintsts & GINTSTS_RESETDET) {
+   dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__);
+
+   writel(GINTSTS_RESETDET, hsotg->regs + GINTSTS);
+
+   /* This event must be used only if controller is suspended */
+   if (hsotg->lx_state == DWC2_L2) {
+   dwc2_exit_hibernation(hsotg, true);
+   hsotg->lx_state = DWC2_L0;
+   }
+   }
+
+   if (gintsts & (GINTSTS_USBRST | GINTSTS_RESETDET)) {
 
u32 usb_status = readl(hsotg->regs + GOTGCTL);
 
-- 
2.3.3

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


[PATCH v4 05/22] usb: dwc2: controller must update lx_state before releasing lock

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

During suspend, there could a race condition between ep_queue and
suspend interrupt if lx_state is updated after releasing spinlock in
call_gadget(hsotg, suspend).

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/core_intr.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 42f2fd5..f5ef26e 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -436,6 +436,12 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
if (!IS_ERR_OR_NULL(hsotg->uphy))
usb_phy_set_suspend(hsotg->uphy, true);
 skip_power_saving:
+   /*
+* Change to L2 (suspend) state before releasing
+* spinlock
+*/
+   hsotg->lx_state = DWC2_L2;
+
/* Call gadget suspend callback */
call_gadget(hsotg, suspend);
}
@@ -443,6 +449,8 @@ skip_power_saving:
if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg->dev, "a_peripheral->a_host\n");
 
+   /* Change to L2 (suspend) state */
+   hsotg->lx_state = DWC2_L2;
/* Clear the a_peripheral flag, back to a_host */
spin_unlock(&hsotg->lock);
dwc2_hcd_start(hsotg);
@@ -451,9 +459,6 @@ skip_power_saving:
}
}
 
-   /* Change to L2 (suspend) state */
-   hsotg->lx_state = DWC2_L2;
-
 clear_int:
/* Clear interrupt */
writel(GINTSTS_USBSUSP, hsotg->regs + GINTSTS);
-- 
2.3.3

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


[PATCH v4 07/22] usb: dwc2: set parameter values in probe function

2015-03-24 Thread Mian Yousaf Kaukab
So the parameters can be used in both host and gadget modes.
Also consolidate param functions in the core.h

Signed-off-by: Mian Yousaf Kaukab 
---
 drivers/usb/dwc2/core.c | 19 +++
 drivers/usb/dwc2/core.h | 13 ++---
 drivers/usb/dwc2/hcd.c  | 36 +---
 drivers/usb/dwc2/hcd.h  |  7 +--
 drivers/usb/dwc2/platform.c | 17 -
 5 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 8c3bc84..6acbe90 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -3044,6 +3044,7 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
 }
+EXPORT_SYMBOL_GPL(dwc2_set_parameters);
 
 /**
  * During device initialization, read various hardware configuration
@@ -3210,6 +3211,24 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(dwc2_get_hwparams);
+
+/*
+ * Sets all parameters to the given value.
+ *
+ * Assumes that the dwc2_core_params struct contains only integers.
+ */
+void dwc2_set_all_params(struct dwc2_core_params *params, int value)
+{
+   int *p = (int *)params;
+   size_t size = sizeof(*params) / sizeof(*p);
+   int i;
+
+   for (i = 0; i < size; i++)
+   p[i] = value;
+}
+EXPORT_SYMBOL_GPL(dwc2_set_all_params);
+
 
 u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg)
 {
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index e46304d..d7fb1f7 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1071,6 +1071,15 @@ extern void dwc2_set_param_ahbcfg(struct dwc2_hsotg 
*hsotg, int val);
 
 extern void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val);
 
+extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
+   const struct dwc2_core_params *params);
+
+extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
+
+extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
+
+
+
 /*
  * Dump core registers and SPRAM
  */
@@ -1119,14 +1128,12 @@ extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg 
*hsotg);
 extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
 extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
 #else
-static inline void dwc2_set_all_params(struct dwc2_core_params *params, int 
value) {}
 static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
 { return 0; }
 static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
 static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
 static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
-static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
-   const struct dwc2_core_params *params)
+static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
 #endif
 
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 559b55e..1cca5e0 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2748,8 +2748,6 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg)
destroy_workqueue(hsotg->wq_otg);
}
 
-   kfree(hsotg->core_params);
-   hsotg->core_params = NULL;
del_timer(&hsotg->wkp_timer);
 }
 
@@ -2762,29 +2760,12 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg)
 }
 
 /*
- * Sets all parameters to the given value.
- *
- * Assumes that the dwc2_core_params struct contains only integers.
- */
-void dwc2_set_all_params(struct dwc2_core_params *params, int value)
-{
-   int *p = (int *)params;
-   size_t size = sizeof(*params) / sizeof(*p);
-   int i;
-
-   for (i = 0; i < size; i++)
-   p[i] = value;
-}
-EXPORT_SYMBOL_GPL(dwc2_set_all_params);
-
-/*
  * Initializes the HCD. This function allocates memory for and initializes the
  * static parts of the usb_hcd and dwc2_hsotg structures. It also registers the
  * USB bus with the core and calls the hc_driver->start() function. It returns
  * a negative error on failure.
  */
-int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
- const struct dwc2_core_params *params)
+int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 {
struct usb_hcd *hcd;
struct dwc2_host_chan *channel;
@@ -2797,12 +2778,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 
dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
 
-   /* Detect config values from hardware */
-   retval = dwc2_get_hwparams(hsotg);
-
-   if (retval)
-   return retval;
-
retval = -ENOMEM;
 
hcfg = readl(hsotg->regs + HCFG);
@@ -2821,15 +2796,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
hsotg->last_frame_num = HFNUM_MAX_FRNUM;
 #endif
 
-   hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
-  

[PATCH v4 22/22] usb: dwc2: host: ensure qtb exists before dereferencing it

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

dwc2_hc_nak_intr could be called with a NULL qtd.
Ensure qtd exists before dereferencing it to avoid kernel panic.
This happens when using usb to ethernet adapter.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/hcd_intr.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index 6ea8eb6..4cc95df 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -1208,6 +1208,16 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
 struct dwc2_host_chan *chan, int chnum,
 struct dwc2_qtd *qtd)
 {
+   if (!qtd) {
+   dev_dbg(hsotg->dev, "%s: qtd is NULL\n", __func__);
+   return;
+   }
+
+   if (!qtd->urb) {
+   dev_dbg(hsotg->dev, "%s: qtd->urb is NULL\n", __func__);
+   return;
+   }
+
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "--Host Channel %d Interrupt: NAK 
Received--\n",
 chnum);
-- 
2.3.3

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


[PATCH v4 17/22] usb: dwc2: host: spinlock urb_enqueue

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

During urb_enqueue, if the urb can't be queued to the endpoint,
the urb is freed without any spinlock protection.
This leads to memory corruption when concurrent urb_dequeue try to free
same urb->hcpriv.
Thus, ensure the whole urb_enqueue in spinlocked.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/hcd.c   | 15 ++-
 drivers/usb/dwc2/hcd_queue.c |  8 +---
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index bc04b3f8..763b63b 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -357,12 +357,12 @@ void dwc2_hcd_stop(struct dwc2_hsotg *hsotg)
writel(0, hsotg->regs + HPRT0);
 }
 
+/* Caller must hold driver lock */
 static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
struct dwc2_hcd_urb *urb, void **ep_handle,
gfp_t mem_flags)
 {
struct dwc2_qtd *qtd;
-   unsigned long flags;
u32 intr_mask;
int retval;
int dev_speed;
@@ -413,11 +413,9 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
 */
return 0;
 
-   spin_lock_irqsave(&hsotg->lock, flags);
tr_type = dwc2_hcd_select_transactions(hsotg);
if (tr_type != DWC2_TRANSACTION_NONE)
dwc2_hcd_queue_transactions(hsotg, tr_type);
-   spin_unlock_irqrestore(&hsotg->lock, flags);
}
 
return 0;
@@ -2484,7 +2482,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
"%s: unaligned transfer with no 
transfer_buffer",
__func__);
retval = -EINVAL;
-   goto fail1;
+   goto fail0;
}
}
 
@@ -2512,7 +2510,6 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
 
spin_lock_irqsave(&hsotg->lock, flags);
retval = usb_hcd_link_urb_to_ep(hcd, urb);
-   spin_unlock_irqrestore(&hsotg->lock, flags);
if (retval)
goto fail1;
 
@@ -2521,22 +2518,22 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
goto fail2;
 
if (alloc_bandwidth) {
-   spin_lock_irqsave(&hsotg->lock, flags);
dwc2_allocate_bus_bandwidth(hcd,
dwc2_hcd_get_ep_bandwidth(hsotg, ep),
urb);
-   spin_unlock_irqrestore(&hsotg->lock, flags);
}
 
+   spin_unlock_irqrestore(&hsotg->lock, flags);
+
return 0;
 
 fail2:
-   spin_lock_irqsave(&hsotg->lock, flags);
dwc2_urb->priv = NULL;
usb_hcd_unlink_urb_from_ep(hcd, urb);
-   spin_unlock_irqrestore(&hsotg->lock, flags);
 fail1:
+   spin_unlock_irqrestore(&hsotg->lock, flags);
urb->hcpriv = NULL;
+fail0:
kfree(dwc2_urb);
 
return retval;
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index bb97838..63207dc 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -761,6 +761,7 @@ void dwc2_hcd_qtd_init(struct dwc2_qtd *qtd, struct 
dwc2_hcd_urb *urb)
 
 /**
  * dwc2_hcd_qtd_add() - Adds a QTD to the QTD-list of a QH
+ * Caller must hold driver lock.
  *
  * @hsotg:The DWC HCD structure
  * @qtd:  The QTD to add
@@ -777,7 +778,6 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
 struct dwc2_qh **qh, gfp_t mem_flags)
 {
struct dwc2_hcd_urb *urb = qtd->urb;
-   unsigned long flags;
int allocated = 0;
int retval;
 
@@ -792,15 +792,12 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
allocated = 1;
}
 
-   spin_lock_irqsave(&hsotg->lock, flags);
-
retval = dwc2_hcd_qh_add(hsotg, *qh);
if (retval)
goto fail;
 
qtd->qh = *qh;
list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list);
-   spin_unlock_irqrestore(&hsotg->lock, flags);
 
return 0;
 
@@ -817,10 +814,7 @@ fail:
 qtd_list_entry)
dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh_tmp);
 
-   spin_unlock_irqrestore(&hsotg->lock, flags);
dwc2_hcd_qh_free(hsotg, qh_tmp);
-   } else {
-   spin_unlock_irqrestore(&hsotg->lock, flags);
}
 
return retval;
-- 
2.3.3

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


[PATCH v4 16/22] usb: dwc2: host: resume root hub on port connect

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Once hub is runtime suspended, dwc2 must resume it
on port connect event.
Else, roothub will stay in suspended state and will
not resume transfers.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/hcd_intr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index 551ba87..6927bba 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -350,6 +350,9 @@ static void dwc2_port_intr(struct dwc2_hsotg *hsotg)
dev_vdbg(hsotg->dev,
 "--Port Interrupt HPRT0=0x%08x Port Connect 
Detected--\n",
 hprt0);
+   if (hsotg->lx_state != DWC2_L0)
+   usb_hcd_resume_root_hub(hsotg->priv);
+
hsotg->flags.b.port_connect_status_change = 1;
hsotg->flags.b.port_connect_status = 1;
hprt0_modify |= HPRT0_CONNDET;
-- 
2.3.3

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


[PATCH v4 20/22] usb: dwc2: remove dwc2_platform.ko

2015-03-24 Thread Mian Yousaf Kaukab
As dwc2 pci module is now exporting dwc2 platform device, include
platform.o in dwc2-y and remove USB_DWC2_PLATFORM configuration
option. Driver will be built as two modules, dwc2.ko and dwc2_pci.ko.
dwc2.ko is the new platform driver.

Remove all EXPORT_SYMBOL_GPL as they are not needed any more.

Signed-off-by: Mian Yousaf Kaukab 
---
 drivers/usb/dwc2/Kconfig | 8 
 drivers/usb/dwc2/Makefile| 5 +
 drivers/usb/dwc2/core.c  | 3 ---
 drivers/usb/dwc2/core_intr.c | 1 -
 drivers/usb/dwc2/debugfs.c   | 2 --
 drivers/usb/dwc2/gadget.c| 5 -
 drivers/usb/dwc2/hcd.c   | 2 --
 7 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index 1bcb36a..fd95ba6 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -50,18 +50,10 @@ config USB_DWC2_DUAL_ROLE
  option requires USB_GADGET to be enabled.
 endchoice
 
-config USB_DWC2_PLATFORM
-   tristate "DWC2 Platform"
-   default USB_DWC2_HOST || USB_DWC2_PERIPHERAL
-help
-  The Designware USB2.0 platform interface module for
-  controllers directly connected to the CPU.
-
 config USB_DWC2_PCI
tristate "DWC2 PCI"
depends on PCI
default n
-   select USB_DWC2_PLATFORM
select NOP_USB_XCEIV
help
  The Designware USB2.0 PCI interface module for controllers
diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index 324fbb4..50fdaac 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_DWC2_DEBUG)+= -DDEBUG
 ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG
 
 obj-$(CONFIG_USB_DWC2) += dwc2.o
-dwc2-y := core.o core_intr.o
+dwc2-y := core.o core_intr.o platform.o
 
 ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
dwc2-y  += hcd.o hcd_intr.o
@@ -25,6 +25,3 @@ endif
 
 obj-$(CONFIG_USB_DWC2_PCI) += dwc2_pci.o
 dwc2_pci-y := pci.o
-
-obj-$(CONFIG_USB_DWC2_PLATFORM)+= dwc2_platform.o
-dwc2_platform-y:= platform.o
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 6acbe90..7f461e3 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -3044,7 +3044,6 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
 }
-EXPORT_SYMBOL_GPL(dwc2_set_parameters);
 
 /**
  * During device initialization, read various hardware configuration
@@ -3211,7 +3210,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
 
return 0;
 }
-EXPORT_SYMBOL_GPL(dwc2_get_hwparams);
 
 /*
  * Sets all parameters to the given value.
@@ -3227,7 +3225,6 @@ void dwc2_set_all_params(struct dwc2_core_params *params, 
int value)
for (i = 0; i < size; i++)
p[i] = value;
 }
-EXPORT_SYMBOL_GPL(dwc2_set_all_params);
 
 
 u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index f5ef26e..e66eb38 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -556,4 +556,3 @@ out:
spin_unlock(&hsotg->lock);
return retval;
 }
-EXPORT_SYMBOL_GPL(dwc2_handle_common_intr);
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index af89537..ef2ee3d 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -763,11 +763,9 @@ err1:
 err0:
return ret;
 }
-EXPORT_SYMBOL_GPL(dwc2_debugfs_init);
 
 void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg)
 {
debugfs_remove_recursive(hsotg->debug_root);
hsotg->debug_root = NULL;
 }
-EXPORT_SYMBOL_GPL(dwc2_debugfs_exit);
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 2b73615..4d47b7c 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2190,7 +2190,6 @@ void s3c_hsotg_disconnect(struct dwc2_hsotg *hsotg)
 
call_gadget(hsotg, disconnect);
 }
-EXPORT_SYMBOL_GPL(s3c_hsotg_disconnect);
 
 /**
  * s3c_hsotg_irq_fifoempty - TX FIFO empty interrupt handler
@@ -3666,7 +3665,6 @@ err_clk:
 
return ret;
 }
-EXPORT_SYMBOL_GPL(dwc2_gadget_init);
 
 /**
  * s3c_hsotg_remove - remove function for hsotg driver
@@ -3679,7 +3677,6 @@ int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
 
return 0;
 }
-EXPORT_SYMBOL_GPL(s3c_hsotg_remove);
 
 int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
 {
@@ -3722,7 +3719,6 @@ int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
 
return ret;
 }
-EXPORT_SYMBOL_GPL(s3c_hsotg_suspend);
 
 int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
 {
@@ -3754,4 +3750,3 @@ int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
 
return ret;
 }
-EXPORT_SYMBOL_GPL(s3c_hso

[PATCH v4 18/22] usb: dwc2: host: don't use dma_alloc_coherent with irqs disabled

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Align buffer must be allocated using kmalloc since irqs are disabled.
Coherency is handled through dma_map_single which can be used with irqs
disabled.

Reviewed-by: Julius Werner 
Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/hcd.c   | 13 ---
 drivers/usb/dwc2/hcd_intr.c  | 53 +++-
 drivers/usb/dwc2/hcd_queue.c |  7 +++---
 3 files changed, 52 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 763b63b..7f8c154 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -719,9 +719,7 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
/* 3072 = 3 max-size Isoc packets */
buf_size = 3072;
 
-   qh->dw_align_buf = dma_alloc_coherent(hsotg->dev, buf_size,
- &qh->dw_align_buf_dma,
- GFP_ATOMIC);
+   qh->dw_align_buf = kmalloc(buf_size, GFP_ATOMIC | GFP_DMA);
if (!qh->dw_align_buf)
return -ENOMEM;
qh->dw_align_buf_size = buf_size;
@@ -746,6 +744,15 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
}
}
 
+   qh->dw_align_buf_dma = dma_map_single(hsotg->dev,
+   qh->dw_align_buf, qh->dw_align_buf_size,
+   chan->ep_is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
+   if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) {
+   dev_err(hsotg->dev, "can't map align_buf\n");
+   chan->align_buf = (dma_addr_t)NULL;
+   return -EINVAL;
+   }
+
chan->align_buf = qh->dw_align_buf_dma;
return 0;
 }
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index 6927bba..6ea8eb6 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -466,10 +466,15 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg,
}
 
/* Non DWORD-aligned buffer case handling */
-   if (chan->align_buf && xfer_length && chan->ep_is_in) {
+   if (chan->align_buf && xfer_length) {
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__);
-   memcpy(urb->buf + urb->actual_length, chan->qh->dw_align_buf,
-  xfer_length);
+   dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
+   chan->qh->dw_align_buf_size,
+   chan->ep_is_in ?
+   DMA_FROM_DEVICE : DMA_TO_DEVICE);
+   if (chan->ep_is_in)
+   memcpy(urb->buf + urb->actual_length,
+   chan->qh->dw_align_buf, xfer_length);
}
 
dev_vdbg(hsotg->dev, "urb->actual_length=%d xfer_length=%d\n",
@@ -555,13 +560,18 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
chan, chnum, qtd, halt_status, NULL);
 
/* Non DWORD-aligned buffer case handling */
-   if (chan->align_buf && frame_desc->actual_length &&
-   chan->ep_is_in) {
+   if (chan->align_buf && frame_desc->actual_length) {
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n",
 __func__);
-   memcpy(urb->buf + frame_desc->offset +
-  qtd->isoc_split_offset, chan->qh->dw_align_buf,
-  frame_desc->actual_length);
+   dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
+   chan->qh->dw_align_buf_size,
+   chan->ep_is_in ?
+   DMA_FROM_DEVICE : DMA_TO_DEVICE);
+   if (chan->ep_is_in)
+   memcpy(urb->buf + frame_desc->offset +
+   qtd->isoc_split_offset,
+   chan->qh->dw_align_buf,
+   frame_desc->actual_length);
}
break;
case DWC2_HC_XFER_FRAME_OVERRUN:
@@ -584,13 +594,18 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
chan, chnum, qtd, halt_status, NULL);
 
/* Non DWORD-aligned buffer case handling */
-   if (chan->align_buf && frame_desc->actual_length &&
-   chan->ep_is_in) {
+   if (chan->align_buf && frame_desc->actual_length) {
dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n",
 __func__);
-   memcpy(urb->buf + frame_desc->offset +
-  qtd->isoc_

[PATCH v4 19/22] usb: dwc2: host: implement test mode

2015-03-24 Thread Mian Yousaf Kaukab
From: Jingwu Lin 

Add support for SetPortFeature(PORT_TEST) for root port.

Signed-off-by: Jingwu Lin 
---
 drivers/usb/dwc2/hcd.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 7f8c154..08f30e9 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1779,6 +1779,15 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg 
*hsotg, u16 typereq,
/* Not supported */
break;
 
+   case USB_PORT_FEAT_TEST:
+   hprt0 = dwc2_read_hprt0(hsotg);
+   dev_dbg(hsotg->dev,
+   "SetPortFeature - USB_PORT_FEAT_TEST\n");
+   hprt0 &= ~HPRT0_TSTCTL_MASK;
+   hprt0 |= (windex >> 8) << HPRT0_TSTCTL_SHIFT;
+   writel(hprt0, hsotg->regs + HPRT0);
+   break;
+
default:
retval = -EINVAL;
dev_err(hsotg->dev,
-- 
2.3.3

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


[PATCH v4 15/22] usb: dwc2: host: add bus_suspend/bus_resume callback

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/hcd.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 919658e..bc04b3f8 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2313,6 +2313,22 @@ static void _dwc2_hcd_stop(struct usb_hcd *hcd)
usleep_range(1000, 3000);
 }
 
+static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
+{
+   struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
+
+   hsotg->lx_state = DWC2_L2;
+   return 0;
+}
+
+static int _dwc2_hcd_resume(struct usb_hcd *hcd)
+{
+   struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
+
+   hsotg->lx_state = DWC2_L0;
+   return 0;
+}
+
 /* Returns the current frame number */
 static int _dwc2_hcd_get_frame_number(struct usb_hcd *hcd)
 {
@@ -2683,6 +2699,9 @@ static struct hc_driver dwc2_hc_driver = {
.hub_status_data = _dwc2_hcd_hub_status_data,
.hub_control = _dwc2_hcd_hub_control,
.clear_tt_buffer_complete = _dwc2_hcd_clear_tt_buffer_complete,
+
+   .bus_suspend = _dwc2_hcd_suspend,
+   .bus_resume = _dwc2_hcd_resume,
 };
 
 /*
-- 
2.3.3

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


[PATCH v4 21/22] usb: dwc2: add hibernation core parameter

2015-03-24 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

dwc2 may not be able to exit from hibernation if the hardware
does not provide a way to detect resume signalling in this state.
Thus, add the possibility to disable hibernation feature.

Signed-off-by: Gregory Herrero 
---
 drivers/usb/dwc2/core.c  | 24 
 drivers/usb/dwc2/core.h  |  7 +++
 drivers/usb/dwc2/core_intr.c |  7 ---
 drivers/usb/dwc2/platform.c  |  2 ++
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 7f461e3..e5b546f 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -342,6 +342,9 @@ int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool 
restore)
u32 pcgcctl;
int ret = 0;
 
+   if (!hsotg->core_params->hibernation)
+   return -ENOTSUPP;
+
pcgcctl = readl(hsotg->regs + PCGCTL);
pcgcctl &= ~PCGCTL_STOPPCLK;
writel(pcgcctl, hsotg->regs + PCGCTL);
@@ -392,6 +395,9 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg)
u32 pcgcctl;
int ret = 0;
 
+   if (!hsotg->core_params->hibernation)
+   return -ENOTSUPP;
+
/* Backup all registers */
ret = dwc2_backup_global_registers(hsotg);
if (ret) {
@@ -2998,6 +3004,23 @@ static void dwc2_set_param_external_id_pin_ctl(struct 
dwc2_hsotg *hsotg,
hsotg->core_params->external_id_pin_ctl = val;
 }
 
+static void dwc2_set_param_hibernation(struct dwc2_hsotg *hsotg,
+   int val)
+{
+   if (DWC2_OUT_OF_BOUNDS(val, 0, 1)) {
+   if (val >= 0) {
+   dev_err(hsotg->dev,
+   "'%d' invalid for parameter hibernation\n",
+   val);
+   dev_err(hsotg->dev, "hibernation must be 0 or 1\n");
+   }
+   val = 0;
+   dev_dbg(hsotg->dev, "Setting hibernation to %d\n", val);
+   }
+
+   hsotg->core_params->hibernation = val;
+}
+
 /*
  * This function is called during module intialization to pass module 
parameters
  * for the DWC_otg core.
@@ -3043,6 +3066,7 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_otg_ver(hsotg, params->otg_ver);
dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
+   dwc2_set_param_hibernation(hsotg, params->hibernation);
 }
 
 /**
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index d7fb1f7..53b8de0 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -336,6 +336,12 @@ enum dwc2_ep0_state {
  *  case.
  *  0 - No (default)
  *  1 - Yes
+ * @hibernation:   Specifies whether the controller support hibernation.
+ * If hibernation is enabled, the controller will enter
+ * hibernation in both peripheral and host mode when
+ * needed.
+ * 0 - No (default)
+ * 1 - Yes
  *
  * The following parameters may be specified when starting the module. These
  * parameters define how the DWC_otg controller should be configured. A
@@ -374,6 +380,7 @@ struct dwc2_core_params {
int ahbcfg;
int uframe_sched;
int external_id_pin_ctl;
+   int hibernation;
 };
 
 /**
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index e66eb38..940582f 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -347,7 +347,7 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
dctl &= ~DCTL_RMTWKUPSIG;
writel(dctl, hsotg->regs + DCTL);
ret = dwc2_exit_hibernation(hsotg, true);
-   if (ret)
+   if (ret && (ret != -ENOTSUPP))
dev_err(hsotg->dev, "exit hibernation 
failed\n");
 
call_gadget(hsotg, resume);
@@ -425,8 +425,9 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
 
ret = dwc2_enter_hibernation(hsotg);
if (ret) {
-   dev_err(hsotg->dev,
-   "enter hibernation failed\n");
+   if (ret != -ENOTSUPP)
+   dev_err(hsotg->dev,
+   "enter hibernation 
failed\n");
goto skip_power_saving;
}
 
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 2562c90..9093530 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -78,6 +78,7 @@ static const struct dwc2_core_params params_bcm2835 = {
.ahbcfg = 0x10,

Re: [PATCH v2] USB: serial: add nt124 usb to serial driver

2015-03-24 Thread Johan Hovold
On Tue, Mar 03, 2015 at 11:57:04AM -0600, George McCollister wrote:
> This driver is for the NovaTech 124 4x serial expansion board for the
> NovaTech OrionLXm.
> 
> Firmware source code can be found here:
> https://github.com/novatechweb/nt124
> 
> Signed-off-by: George McCollister 

Thanks for the v2, George. And sorry for not getting back to you sooner.
I'll try to find time to review it this week.

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


[PATCH] usb: gadget: f_printer: fix dependencies

2015-03-24 Thread Andrzej Pietrasiewicz
If f_printer is selected without legacy g_printer, it should
depend on USB_CONFIGFS which pulls in libcomposite.

Signed-off-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 3bb0e67..bcf83c0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -440,6 +440,7 @@ config USB_CONFIGFS_F_UVC
 config USB_CONFIGFS_F_PRINTER
bool "Printer function"
select USB_F_PRINTER
+   depends on USB_CONFIGFS
help
  The Printer function channels data between the USB host and a
  userspace program driving the print engine. The user space
-- 
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: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Oliver Neukum
On Mon, 2015-03-23 at 21:11 +0200, Sami Farin wrote:
> I tried reverting f46ad73ac696 in 4.0.0-rc5, did not help.  Have to
> reboot first into 3.18.9.
> 
> This happens:
> [ 2765.268081] usb 2-1.4.4: USB disconnect, device number 16
> [ 2777.209388] usb 2-1.4.4: new high-speed USB device number 17 using
> ehci-pci
> [ 2777.303172] usb 2-1.4.4: New USB device found, idVendor=12d1,
> idProduct=157d
> [ 2777.303174] usb 2-1.4.4: New USB device strings: Mfr=1, Product=2,
> SerialNumber=3
> [ 2777.303176] usb 2-1.4.4: Product: HUAWEI_MOBILE
> [ 2777.303177] usb 2-1.4.4: Manufacturer: HUAWEI_MOBILE
> [ 2777.303178] usb 2-1.4.4: SerialNumber: 0123456789ABCDEF
> [ 2777.325198] usb-storage 2-1.4.4:1.0: USB Mass Storage device
> detected
> [ 2777.325282] scsi host37: usb-storage 2-1.4.4:1.0
> [ 2777.903039] usb 2-1.4.4: usbfs: interface 0 claimed by usb-storage
> while 'usb_modeswitch' sets config #2

This fails. It comes from proc_setconfig(). It suggests that a change
in storage causes this. To verify, could you blacklist usb-storage
in a test with 4.0?

Regards
Oliver


--
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-24 Thread victorascroft
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?

- Sanchayan

> Peter Chen (12):
>   Doc: usb: ci-hdrc-imx: add gadget-itc-setting for binding doc
>   usb: chipidea: set ITC to 0 for device mode
>   usb: chipidea: define stream mode disable for both roles
>   usb: chipidea: imx: add stream mode enable for device mode at
> imx6sl/imx6sx
>   usb: chipidea: introduce ci_platform_config
>   Doc: usb: ci-hdrc-imx: add ahb-burst-config for binding doc
>   ARM: imx6: set ahb-burst-config as 0 for USB
>   usb: chipidea: add ahb burst configuration
>   usb: chipidea: usbmisc_imx: add unburst setting for imx6
>   Doc: usb: ci-hdrc-imx: add tx(rx)-burst-config-dword for binding doc
>   ARM: imx6: change default burst size for USB
>   usb: chipidea: add burst size configuration interface
> 
>  .../devicetree/bindings/usb/ci-hdrc-imx.txt|  12 +++
>  arch/arm/boot/dts/imx6qdl.dtsi |  12 +++
>  arch/arm/boot/dts/imx6sl.dtsi  |   9 ++
>  arch/arm/boot/dts/imx6sx.dtsi  |   9 ++
>  drivers/usb/chipidea/bits.h|   7 ++
>  drivers/usb/chipidea/ci.h  |   3 +
>  drivers/usb/chipid

Re: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Lars Melin

On 2015-03-24 17:20, Oliver Neukum wrote:

On Mon, 2015-03-23 at 21:11 +0200, Sami Farin wrote:

I tried reverting f46ad73ac696 in 4.0.0-rc5, did not help.  Have to
reboot first into 3.18.9.

This happens:
[ 2765.268081] usb 2-1.4.4: USB disconnect, device number 16
[ 2777.209388] usb 2-1.4.4: new high-speed USB device number 17 using
ehci-pci
[ 2777.303172] usb 2-1.4.4: New USB device found, idVendor=12d1,
idProduct=157d
[ 2777.303174] usb 2-1.4.4: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[ 2777.303176] usb 2-1.4.4: Product: HUAWEI_MOBILE
[ 2777.303177] usb 2-1.4.4: Manufacturer: HUAWEI_MOBILE
[ 2777.303178] usb 2-1.4.4: SerialNumber: 0123456789ABCDEF
[ 2777.325198] usb-storage 2-1.4.4:1.0: USB Mass Storage device
detected
[ 2777.325282] scsi host37: usb-storage 2-1.4.4:1.0
[ 2777.903039] usb 2-1.4.4: usbfs: interface 0 claimed by usb-storage
while 'usb_modeswitch' sets config #2

This fails. It comes from proc_setconfig(). It suggests that a change
in storage causes this. To verify, could you blacklist usb-storage
in a test with 4.0?

Regards
Oliver
12d1:157d has 2 configurations, config #1 being the virtual cd-rom 
containing windows drivers and config #2 containing cdc_mbim interfaces.
cdc_mbim is the primary protocol for this Win8 approved dongle but it 
can be switched via a bulkmsg into an "old Win" compatibility mode which

usually is cdc_ether.
usb_modeswitch will check if the cdc_mbim driver is present in the 
system when it finds a dongle which has cdc_mbim attributes on its 
interfaces.
If the driver is found then the port will be set to config #2 which is 
the required config number for cdc_mbim.
If no driver is found then the bulk msg will be sent for switching the 
dongle into compatibility mode where it also will have a different usb id.





--
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: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Oliver Neukum
On Tue, 2015-03-24 at 18:02 +0700, Lars Melin wrote:
> On 2015-03-24 17:20, Oliver Neukum wrote:
> > On Mon, 2015-03-23 at 21:11 +0200, Sami Farin wrote:
> >> I tried reverting f46ad73ac696 in 4.0.0-rc5, did not help.  Have to
> >> reboot first into 3.18.9.
> >>
> >> This happens:
> >> [ 2765.268081] usb 2-1.4.4: USB disconnect, device number 16
> >> [ 2777.209388] usb 2-1.4.4: new high-speed USB device number 17 using
> >> ehci-pci
> >> [ 2777.303172] usb 2-1.4.4: New USB device found, idVendor=12d1,
> >> idProduct=157d
> >> [ 2777.303174] usb 2-1.4.4: New USB device strings: Mfr=1, Product=2,
> >> SerialNumber=3
> >> [ 2777.303176] usb 2-1.4.4: Product: HUAWEI_MOBILE
> >> [ 2777.303177] usb 2-1.4.4: Manufacturer: HUAWEI_MOBILE
> >> [ 2777.303178] usb 2-1.4.4: SerialNumber: 0123456789ABCDEF
> >> [ 2777.325198] usb-storage 2-1.4.4:1.0: USB Mass Storage device
> >> detected
> >> [ 2777.325282] scsi host37: usb-storage 2-1.4.4:1.0
> >> [ 2777.903039] usb 2-1.4.4: usbfs: interface 0 claimed by usb-storage
> >> while 'usb_modeswitch' sets config #2
> > This fails. It comes from proc_setconfig(). It suggests that a change
> > in storage causes this. To verify, could you blacklist usb-storage
> > in a test with 4.0?
> >
> > Regards
> > Oliver
> 12d1:157d has 2 configurations, config #1 being the virtual cd-rom 
> containing windows drivers and config #2 containing cdc_mbim interfaces.
> cdc_mbim is the primary protocol for this Win8 approved dongle but it 
> can be switched via a bulkmsg into an "old Win" compatibility mode which
> usually is cdc_ether.

Yes. But the dmesg makes clear that usb_modeswitch had decided to go
to config#2. It just fails. So we must look for the reason of the
failure. And that is likely in the storage driver binding to the
virtual CD.

At this point that is just theory so I would like to see this confirmed
by blacklisting usb-storage.

Regards
Oliver


--
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: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Sami Farin
On Tue, Mar 24, 2015 at 18:02:51 +0700, Lars Melin wrote:
> On 2015-03-24 17:20, Oliver Neukum wrote:
...
> >>[ 2777.325282] scsi host37: usb-storage 2-1.4.4:1.0
> >>[ 2777.903039] usb 2-1.4.4: usbfs: interface 0 claimed by usb-storage
> >>while 'usb_modeswitch' sets config #2
> >This fails. It comes from proc_setconfig(). It suggests that a change
> >in storage causes this. To verify, could you blacklist usb-storage
> >in a test with 4.0?
> >
> > Regards
> > Oliver
> 12d1:157d has 2 configurations, config #1 being the virtual cd-rom
> containing windows drivers and config #2 containing cdc_mbim interfaces.
> cdc_mbim is the primary protocol for this Win8 approved dongle but it can be
> switched via a bulkmsg into an "old Win" compatibility mode which
> usually is cdc_ether.

4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist usb_storage,
have to reboot to 3.18.9.

Why?

[57023.245141] usb 5-1: USB disconnect, device number 3
[57036.756071] usb 5-1: new high-speed USB device number 4 using xhci_hcd
[57036.926823] usb 5-1: New USB device found, idVendor=12d1, idProduct=157d
[57036.926827] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[57036.926828] usb 5-1: Product: HUAWEI_MOBILE
[57036.926829] usb 5-1: Manufacturer: HUAWEI_MOBILE
[57036.926831] usb 5-1: SerialNumber: 0123456789ABCDEF

> usb_modeswitch will check if the cdc_mbim driver is present in the system
> when it finds a dongle which has cdc_mbim attributes on its interfaces.
> If the driver is found then the port will be set to config #2 which is the
> required config number for cdc_mbim.
> If no driver is found then the bulk msg will be sent for switching the
> dongle into compatibility mode where it also will have a different usb id.

-- 
Do what you love because life is too short for anything else.

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


Re: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Oliver Neukum
On Tue, 2015-03-24 at 13:26 +0200, Sami Farin wrote:
> On Tue, Mar 24, 2015 at 18:02:51 +0700, Lars Melin wrote:
> > On 2015-03-24 17:20, Oliver Neukum wrote:
> ...
> > >>[ 2777.325282] scsi host37: usb-storage 2-1.4.4:1.0
> > >>[ 2777.903039] usb 2-1.4.4: usbfs: interface 0 claimed by usb-storage
> > >>while 'usb_modeswitch' sets config #2
> > >This fails. It comes from proc_setconfig(). It suggests that a change
> > >in storage causes this. To verify, could you blacklist usb-storage
> > >in a test with 4.0?
> > >
> > >   Regards
> > >   Oliver
> > 12d1:157d has 2 configurations, config #1 being the virtual cd-rom
> > containing windows drivers and config #2 containing cdc_mbim interfaces.
> > cdc_mbim is the primary protocol for this Win8 approved dongle but it can be
> > switched via a bulkmsg into an "old Win" compatibility mode which
> > usually is cdc_ether.
> 
> 4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist usb_storage,
> have to reboot to 3.18.9.
> 
> Why?

Good question. Please post the full dmesg.
But do you want it to? Ideally cdc_mbim would work, wouldn't it?

Regards
Oliver


--
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: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Lars Melin

On 2015-03-24 18:26, Sami Farin wrote:

On Tue, Mar 24, 2015 at 18:02:51 +0700, Lars Melin wrote:

On 2015-03-24 17:20, Oliver Neukum wrote:

...

[ 2777.325282] scsi host37: usb-storage 2-1.4.4:1.0
[ 2777.903039] usb 2-1.4.4: usbfs: interface 0 claimed by usb-storage
while 'usb_modeswitch' sets config #2

This fails. It comes from proc_setconfig(). It suggests that a change
in storage causes this. To verify, could you blacklist usb-storage
in a test with 4.0?

Regards
Oliver

12d1:157d has 2 configurations, config #1 being the virtual cd-rom
containing windows drivers and config #2 containing cdc_mbim interfaces.
cdc_mbim is the primary protocol for this Win8 approved dongle but it can be
switched via a bulkmsg into an "old Win" compatibility mode which
usually is cdc_ether.

4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist usb_storage,
have to reboot to 3.18.9.

Why?

[57023.245141] usb 5-1: USB disconnect, device number 3
[57036.756071] usb 5-1: new high-speed USB device number 4 using xhci_hcd
[57036.926823] usb 5-1: New USB device found, idVendor=12d1, idProduct=157d
[57036.926827] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[57036.926828] usb 5-1: Product: HUAWEI_MOBILE
[57036.926829] usb 5-1: Manufacturer: HUAWEI_MOBILE
[57036.926831] usb 5-1: SerialNumber: 0123456789ABCDEF


usb_modeswitch will check if the cdc_mbim driver is present in the system
when it finds a dongle which has cdc_mbim attributes on its interfaces.
If the driver is found then the port will be set to config #2 which is the
required config number for cdc_mbim.
If no driver is found then the bulk msg will be sent for switching the
dongle into compatibility mode where it also will have a different usb id.

Blacklisting usb_storage will not change the behavior of usb_modeswitch.
Your dongle has cdc_mbim interfaces and you have the cdc_mbim driver in 
4.0.0-rc5 so usb_modeswitch  will select config #2.
If you remove the cdc_mbim driver from your system then you will get a 
traditional mode switch into cdc_ether compatibility mode.

--
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: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Sami Farin
On Tue, Mar 24, 2015 at 12:29:19 +0100, Oliver Neukum wrote:
> On Tue, 2015-03-24 at 13:26 +0200, Sami Farin wrote:
...
> > 4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist 
> > usb_storage,
> > have to reboot to 3.18.9.
> > 
> > Why?
> 
> Good question. Please post the full dmesg.
> But do you want it to? Ideally cdc_mbim would work, wouldn't it?

http://pastebin.com/dBUS3uy7

Please read the thread from the beginning, cdc_mbim does not work.
Only errors, and no packets moving.

-- 
Do what you love because life is too short for anything else.

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


Re: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Oliver Neukum
On Tue, 2015-03-24 at 13:57 +0200, Sami Farin wrote:
> On Tue, Mar 24, 2015 at 12:29:19 +0100, Oliver Neukum wrote:
> > On Tue, 2015-03-24 at 13:26 +0200, Sami Farin wrote:
> ...
> > > 4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist 
> > > usb_storage,
> > > have to reboot to 3.18.9.
> > > 
> > > Why?
> > 
> > Good question. Please post the full dmesg.
> > But do you want it to? Ideally cdc_mbim would work, wouldn't it?
> 
> http://pastebin.com/dBUS3uy7
> 
> Please read the thread from the beginning, cdc_mbim does not work.
> Only errors, and no packets moving.

How have you determined that if you cannot switch?
If that really is the case, you will have to remove cdc-mbim
or hack usb_modeswitch.

Regards
Oliver


--
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: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Lars Melin

On 2015-03-24 18:57, Sami Farin wrote:

On Tue, Mar 24, 2015 at 12:29:19 +0100, Oliver Neukum wrote:

On Tue, 2015-03-24 at 13:26 +0200, Sami Farin wrote:

...

4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist usb_storage,
have to reboot to 3.18.9.

Why?

Good question. Please post the full dmesg.
But do you want it to? Ideally cdc_mbim would work, wouldn't it?

http://pastebin.com/dBUS3uy7

Please read the thread from the beginning, cdc_mbim does not work.
Only errors, and no packets moving.

Then run it in compatible mode while waiting for a solution to the 
cdc_mbim driver.

Either remove the cdc_mbim driver or add
NoMBIMCheck=1
in the device config file for 12d1:157d.
--
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-24 Thread Peter Chen
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 Set  Without Patch Set
> > R: 26.9 MB/s27 MB/s
> > W: 25.2 MB/s24.5 MB/s
> > 
> > 1G USB Ethernet Card
> > With Patch Set  Without Patch Set
> > TX: 186 Mb/s185 Mb/s
> > RX: 219 Mb/s216 Mb/s
> > 
> > g_ncm (Device Mode)
> > With Patch Set  Without 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.

> 
> - Sanchayan
> 
> > Peter Chen (12):
> >   Doc: usb: ci-hdrc-imx: add gadget-itc-setting for binding doc
> >   usb: chipidea: set ITC to 0 for device mode
> >   usb: chipidea: define stream mode disable for both roles
> >   usb: chipidea: imx: add stream mode enable for device mode at
> > imx6sl/imx6sx
> >   usb: chipidea: introduce ci_platform_config
> >   Doc: usb: ci-hdrc-imx: add ahb

Re: cdc_mbim with Huawei E3372, nothing works

2015-03-24 Thread Sami Farin
On Tue, Mar 24, 2015 at 19:08:21 +0700, Lars Melin wrote:
> On 2015-03-24 18:57, Sami Farin wrote:
> >On Tue, Mar 24, 2015 at 12:29:19 +0100, Oliver Neukum wrote:
> >>On Tue, 2015-03-24 at 13:26 +0200, Sami Farin wrote:
> >...
> >>>4.0.0-rc5+ does not switch to "old Win" mode even if I blacklist 
> >>>usb_storage,
> >>>have to reboot to 3.18.9.
> >>>
> >>>Why?
> >>Good question. Please post the full dmesg.
> >>But do you want it to? Ideally cdc_mbim would work, wouldn't it?
> >http://pastebin.com/dBUS3uy7
> >
> >Please read the thread from the beginning, cdc_mbim does not work.
> >Only errors, and no packets moving.
> >
> Then run it in compatible mode while waiting for a solution to the cdc_mbim
> driver.
> Either remove the cdc_mbim driver or add
> NoMBIMCheck=1
> in the device config file for 12d1:157d.

NoMBIMCheck=1 helped!  cdc_ether works .. thanks!
One thing causing confusion was that usb_modeswitch read the vim backup file
first ( /etc/usb_modeswitch.d/12d1:157d~ ) ..  8-)

But why 3.18.9 and 4.0.0-rc5 behave differently, in 3.18.9 (Fedora 21)
it's enough to blacklist cdc_mbim, and cdc_ether is used instead..

-- 
Do what you love because life is too short for anything else.

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


Re: Errata for Freescale root-hub TT?

2015-03-24 Thread Alan Stern
On Tue, 24 Mar 2015, Peter Chen wrote:

> On Mon, Mar 23, 2015 at 10:11:04AM -0400, Alan Stern wrote:
> > On Mon, 23 Mar 2015, Peter Chen wrote:
> > 
> > > For going on debugging this problem, we need
> > 
> > I will have the hardware only for one more day, so I may not be able to
> > get all the information you want.
> > 
> > > - Your bus analyzer file, I think there should be no enough IN/OUT
> > > tokens within one frame, does the remaining time to frame boundaries
> > > is enough? 
> > 
> > Here's an example: There are four OUT transfers near the start of the 
> > frame, and they take about 300 us.  The remaining 700 us in the frame 
> > are completely idle, even though they should contain four IN transfers.
> 
> How do you know the frame has filled already at that time? The software
> makes sure it fills frame in time before next time frame?

I'm not sure I understand the question.

The USB analyzer log showed something like this (this is a rough 
approximation because I didn't keep the original analyzer output file):

Timestamp   Transaction
s.mmm uuu
---
0.000 000   SOF
0.000 030   Isoc OUT
0.000 091   Isoc OUT
0.000 162   Isoc OUT
0.000 224   Isoc OUT
0.001 000   SOF

In this example, there are 4 OUT transfers taking about 290 us and then
nothing else for the rest of the frame.

I also know, from looking at the "periodic" file in the EHCI debugfs 
directory, that each frame was linked to 8 siTDs:

siTD OUT, Smask = 0x01, Cmask = 0x00, transfer length = 64
siTD OUT, Smask = 0x01, Cmask = 0x00, transfer length = 64
siTD OUT, Smask = 0x02, Cmask = 0x00, transfer length = 64
siTD OUT, Smask = 0x02, Cmask = 0x00, transfer length = 64
siTD IN,  Smask = 0x04, Cmask = 0x70, transfer length = 64
siTD IN,  Smask = 0x04, Cmask = 0x70, transfer length = 64
siTD IN,  Smask = 0x08, Cmask = 0xe0, transfer length = 64
siTD IN,  Smask = 0x08, Cmask = 0xe0, transfer length = 64

Alan Stern

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


Re: [PATCH] usb: gadget: Check for NULL pointer in disconnect

2015-03-24 Thread Felipe Balbi
On Mon, Mar 23, 2015 at 04:00:37PM -0700, Badhri Jagan Sridharan wrote:
> > Do you really see some udc drivers call it after composite_unbind is
> > called? If it is, you may add dump_stack() to track that error.
> >
> > Besides this, function suspended_show is needed to add cdev NULL pointer
> > checking.
> 
> We see this happening occasionally in *not yet* upstreamed UDC
> code of some vendors (Yes, disconnect being called after unbind)

fix your UDC. We leave these sort of thing open so people realise they
have to fix their drivers.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Felipe Balbi
On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> The MUSB test mode register can only be set once, otherwise the result
> is undefined.
> 
> This prevents the debugfs testmode entry to set the register more than
> once which causes test failure.
> 
> Signed-off-by: Bin Liu 
> ---
>  drivers/usb/musb/musb_debugfs.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
> index 78a283e..cd0c381 100644
> --- a/drivers/usb/musb/musb_debugfs.c
> +++ b/drivers/usb/musb/musb_debugfs.c
> @@ -194,6 +194,12 @@ static ssize_t musb_test_mode_write(struct file *file,
>   u8  test = 0;
>   charbuf[18];
>  
> + test = musb_readb(musb->mregs, MUSB_TESTMODE);
> + if (test) {
> + dev_err(musb->controller, "Error: test mode is running\n");

with this message, user doesn't really know exactly what to do. Perhaps
mention that a USB Bus Reset is needed to get the thing out of test
mode?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: musb: do not backup/restore registers in runtime PM callbacks

2015-03-24 Thread Felipe Balbi
On Mon, Mar 23, 2015 at 08:40:58PM -0500, Liu, Bin wrote:
> Felipe,
> 
> > -Original Message-
> > From: Balbi, Felipe
> > Sent: Monday, March 23, 2015 7:37 PM
> > To: Liu, Bin
> > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > Subject: Re: [PATCH] usb: musb: do not backup/restore registers in runtime 
> > PM
> > callbacks
> > 
> > On Mon, Mar 23, 2015 at 04:52:54PM -0500, Bin Liu wrote:
> > > The MUSB controller does not lost power during runtime suspend/resume,
> > > so unnecessary to backup/restore its registers.
> > >
> > > Signed-off-by: Bin Liu 
> > 
> > are you sure this is true for *all* users of musb ?
> 
> Well, I am not 100% sure, so posted this patch for comments ;)
> 
> I checked MUSB only lost power during system suspend, in which case
>  musb_suspend/resume() are already called to backup/resume MUSB registers.

bus this is only true for AM335x devices. OMAP3/4 have been doing
off-while-idle for years :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: isp1760: fix spin unlock in the error path of isp1760_udc_start

2015-03-24 Thread Felipe Balbi
On Fri, Mar 20, 2015 at 02:27:40PM +, Sudeep Holla wrote:
> Hi Laurent,
> 
> On 20/03/15 14:20, Laurent Pinchart wrote:
> >Hi Sudeep,
> >
> >Thank you for the patch.
> >
> >On Friday 20 March 2015 11:42:17 Sudeep Holla wrote:
> >>Commit a124820de5fd ("usb: isp1760: fix possible deadlock in
> >>isp1760_udc_irq") replaced spin_{un,}lock with
> >>spin_{un,}lock_irq{save,restore}. However it missed an error path resulting
> >>in the smatch warning as below:
> >>
> >>drivers/usb/isp1760/isp1760-udc.c:1230 isp1760_udc_start() warn:
> >>inconsistent returns 'irqsave:flags'. Locked on:   line 1207
> >>Unlocked on: line 1199
> >>
> >>This patch fixes the spin unlock in the error path in isp1760_udc_start
> >>thereby removing the smatch warning mentioned above.
> >>
> >>Reported-by: Dan Carpenter 
> >>Cc: Laurent Pinchart 
> >>Cc: Felipe Balbi 
> >>Signed-off-by: Sudeep Holla 
> >
> >Acked-by: Laurent Pinchart 
> >
> 
> Thanks
> 
> >>---
> >>  drivers/usb/isp1760/isp1760-udc.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >>Hi Laurent, Felipe,
> >>
> >>I am extremely sorry for missing this in my original patch.
> >
> >I hope you will be ashamed for the 7 generations to come for this totally
> >unacceptable low quality standard.
> >
> 
> Yes ;)

shameful indeed, doesn't build ;-)

drivers/usb/isp1760/isp1760-udc.c:1205:52: error: undefined identifier 'flags'
drivers/usb/isp1760/isp1760-udc.c: In function ‘isp1760_udc_start’:
drivers/usb/isp1760/isp1760-udc.c:1205:38: error: ‘flags’ undeclared (first use 
in this function)
   spin_unlock_irqrestore(&udc->lock, flags);
  ^
drivers/usb/isp1760/isp1760-udc.c:1205:38: note: each undeclared identifier is 
reported only once for each function it appears in
make[2]: *** [drivers/usb/isp1760/isp1760-udc.o] Error 1
make[1]: *** [drivers/usb/isp1760] Error 2
make[1]: *** Waiting for unfinished jobs
make: *** [drivers/usb/] Error 2

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: isp1760: fix spin unlock in the error path of isp1760_udc_start

2015-03-24 Thread Felipe Balbi
On Tue, Mar 24, 2015 at 11:37:43AM -0500, Felipe Balbi wrote:
> On Fri, Mar 20, 2015 at 02:27:40PM +, Sudeep Holla wrote:
> > Hi Laurent,
> > 
> > On 20/03/15 14:20, Laurent Pinchart wrote:
> > >Hi Sudeep,
> > >
> > >Thank you for the patch.
> > >
> > >On Friday 20 March 2015 11:42:17 Sudeep Holla wrote:
> > >>Commit a124820de5fd ("usb: isp1760: fix possible deadlock in
> > >>isp1760_udc_irq") replaced spin_{un,}lock with
> > >>spin_{un,}lock_irq{save,restore}. However it missed an error path 
> > >>resulting
> > >>in the smatch warning as below:
> > >>
> > >>drivers/usb/isp1760/isp1760-udc.c:1230 isp1760_udc_start() warn:
> > >>inconsistent returns 'irqsave:flags'. Locked on:   line 1207
> > >>Unlocked on: line 1199
> > >>
> > >>This patch fixes the spin unlock in the error path in isp1760_udc_start
> > >>thereby removing the smatch warning mentioned above.
> > >>
> > >>Reported-by: Dan Carpenter 
> > >>Cc: Laurent Pinchart 
> > >>Cc: Felipe Balbi 
> > >>Signed-off-by: Sudeep Holla 
> > >
> > >Acked-by: Laurent Pinchart 
> > >
> > 
> > Thanks
> > 
> > >>---
> > >>  drivers/usb/isp1760/isp1760-udc.c | 2 +-
> > >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >>Hi Laurent, Felipe,
> > >>
> > >>I am extremely sorry for missing this in my original patch.
> > >
> > >I hope you will be ashamed for the 7 generations to come for this totally
> > >unacceptable low quality standard.
> > >
> > 
> > Yes ;)
> 
> shameful indeed, doesn't build ;-)
> 
> drivers/usb/isp1760/isp1760-udc.c:1205:52: error: undefined identifier 'flags'
> drivers/usb/isp1760/isp1760-udc.c: In function ‘isp1760_udc_start’:
> drivers/usb/isp1760/isp1760-udc.c:1205:38: error: ‘flags’ undeclared (first 
> use in this function)
>spin_unlock_irqrestore(&udc->lock, flags);
>   ^
> drivers/usb/isp1760/isp1760-udc.c:1205:38: note: each undeclared identifier 
> is reported only once for each function it appears in
> make[2]: *** [drivers/usb/isp1760/isp1760-udc.o] Error 1
> make[1]: *** [drivers/usb/isp1760] Error 2
> make[1]: *** Waiting for unfinished jobs
> make: *** [drivers/usb/] Error 2

oh, nevermind, it depends on a previous fix :-)

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH] usb: musb: do not backup/restore registers in runtime PM callbacks

2015-03-24 Thread Liu, Bin
Felipe,

> -Original Message-
> From: Balbi, Felipe
> Sent: Tuesday, March 24, 2015 11:33 AM
> To: Liu, Bin
> Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> Subject: Re: [PATCH] usb: musb: do not backup/restore registers in runtime PM
> callbacks
> 
> On Mon, Mar 23, 2015 at 08:40:58PM -0500, Liu, Bin wrote:
> > Felipe,
> >
> > > -Original Message-
> > > From: Balbi, Felipe
> > > Sent: Monday, March 23, 2015 7:37 PM
> > > To: Liu, Bin
> > > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > > Subject: Re: [PATCH] usb: musb: do not backup/restore registers in
> > > runtime PM callbacks
> > >
> > > On Mon, Mar 23, 2015 at 04:52:54PM -0500, Bin Liu wrote:
> > > > The MUSB controller does not lost power during runtime
> > > > suspend/resume, so unnecessary to backup/restore its registers.
> > > >
> > > > Signed-off-by: Bin Liu 
> > >
> > > are you sure this is true for *all* users of musb ?
> >
> > Well, I am not 100% sure, so posted this patch for comments ;)
> >
> > I checked MUSB only lost power during system suspend, in which case
> >  musb_suspend/resume() are already called to backup/resume MUSB registers.
> 
> bus this is only true for AM335x devices. OMAP3/4 have been doing off-while-
> idle for years :-)

Yeah, I just read Hema HK's patch which originally added this context 
save/restore, and feel uncomfortable with my change either.

Let's drop this patch, I am trying to find a different way to solve my problem, 
and having a good progress right now.

Thanks,
-Bin.

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


RE: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Liu, Bin
Felipe,

> -Original Message-
> From: Balbi, Felipe
> Sent: Tuesday, March 24, 2015 11:31 AM
> To: Liu, Bin
> Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> Subject: Re: [PATCH] usb: musb: only set test mode once
> 
> On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > The MUSB test mode register can only be set once, otherwise the result
> > is undefined.
> >
> > This prevents the debugfs testmode entry to set the register more than
> > once which causes test failure.
> >
> > Signed-off-by: Bin Liu 
> > ---
> >  drivers/usb/musb/musb_debugfs.c | 6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/usb/musb/musb_debugfs.c
> > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381 100644
> > --- a/drivers/usb/musb/musb_debugfs.c
> > +++ b/drivers/usb/musb/musb_debugfs.c
> > @@ -194,6 +194,12 @@ static ssize_t musb_test_mode_write(struct file *file,
> > u8  test = 0;
> > charbuf[18];
> >
> > +   test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > +   if (test) {
> > +   dev_err(musb->controller, "Error: test mode is running\n");
> 
> with this message, user doesn't really know exactly what to do. Perhaps 
> mention
> that a USB Bus Reset is needed to get the thing out of test mode?

Ok, will change it. How about only print the error message when the new test 
mode is different from the running one, and silently do nothing if the new test 
mode is the same. Something like

if (test) {
if (new test is different) {
dev_err(...);
return -EINVAL;
} else {
return 0;
}
}

Regards,
-Bin.

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


Re: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Felipe Balbi
On Tue, Mar 24, 2015 at 11:52:04AM -0500, Liu, Bin wrote:
> Felipe,
> 
> > -Original Message-
> > From: Balbi, Felipe
> > Sent: Tuesday, March 24, 2015 11:31 AM
> > To: Liu, Bin
> > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > Subject: Re: [PATCH] usb: musb: only set test mode once
> > 
> > On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > > The MUSB test mode register can only be set once, otherwise the result
> > > is undefined.
> > >
> > > This prevents the debugfs testmode entry to set the register more than
> > > once which causes test failure.
> > >
> > > Signed-off-by: Bin Liu 
> > > ---
> > >  drivers/usb/musb/musb_debugfs.c | 6 ++
> > >  1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/usb/musb/musb_debugfs.c
> > > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381 100644
> > > --- a/drivers/usb/musb/musb_debugfs.c
> > > +++ b/drivers/usb/musb/musb_debugfs.c
> > > @@ -194,6 +194,12 @@ static ssize_t musb_test_mode_write(struct file 
> > > *file,
> > >   u8  test = 0;
> > >   charbuf[18];
> > >
> > > + test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > > + if (test) {
> > > + dev_err(musb->controller, "Error: test mode is running\n");
> > 
> > with this message, user doesn't really know exactly what to do. Perhaps 
> > mention
> > that a USB Bus Reset is needed to get the thing out of test mode?
> 
> Ok, will change it. How about only print the error message when the
> new test mode is different from the running one, and silently do
> nothing if the new test mode is the same. Something like
> 
> if (test) {
> if (new test is different) {
> dev_err(...);
> return -EINVAL;
> } else {
> return 0;
> }
> }

USB2 spec says you *must* go through a bus reset in order to get out of
testmode. So if you want to change test_j to test_k, you must first bus
reset.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Felipe Balbi
On Tue, Mar 24, 2015 at 12:05:20PM -0500, Liu, Bin wrote:
> Felipe,
> 
> > -Original Message-
> > From: Balbi, Felipe
> > Sent: Tuesday, March 24, 2015 11:54 AM
> > To: Liu, Bin
> > Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> > Subject: Re: [PATCH] usb: musb: only set test mode once
> > 
> > On Tue, Mar 24, 2015 at 11:52:04AM -0500, Liu, Bin wrote:
> > > Felipe,
> > >
> > > > -Original Message-
> > > > From: Balbi, Felipe
> > > > Sent: Tuesday, March 24, 2015 11:31 AM
> > > > To: Liu, Bin
> > > > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > > >
> > > > On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > > > > The MUSB test mode register can only be set once, otherwise the
> > > > > result is undefined.
> > > > >
> > > > > This prevents the debugfs testmode entry to set the register more
> > > > > than once which causes test failure.
> > > > >
> > > > > Signed-off-by: Bin Liu 
> > > > > ---
> > > > >  drivers/usb/musb/musb_debugfs.c | 6 ++
> > > > >  1 file changed, 6 insertions(+)
> > > > >
> > > > > diff --git a/drivers/usb/musb/musb_debugfs.c
> > > > > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381 100644
> > > > > --- a/drivers/usb/musb/musb_debugfs.c
> > > > > +++ b/drivers/usb/musb/musb_debugfs.c
> > > > > @@ -194,6 +194,12 @@ static ssize_t musb_test_mode_write(struct file
> > *file,
> > > > >   u8  test = 0;
> > > > >   charbuf[18];
> > > > >
> > > > > + test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > > > > + if (test) {
> > > > > + dev_err(musb->controller, "Error: test mode is 
> > > > > running\n");
> > > >
> > > > with this message, user doesn't really know exactly what to do.
> > > > Perhaps mention that a USB Bus Reset is needed to get the thing out of 
> > > > test
> > mode?
> > >
> > > Ok, will change it. How about only print the error message when the
> > > new test mode is different from the running one, and silently do
> > > nothing if the new test mode is the same. Something like
> > >
> > > if (test) {
> > > if (new test is different) {
> > > dev_err(...);
> > > return -EINVAL;
> > > } else {
> > > return 0;
> > > }
> > > }
> > 
> > USB2 spec says you *must* go through a bus reset in order to get out of
> > testmode. So if you want to change test_j to test_k, you must first bus 
> > reset.
> 
> Yes, this will be handled in if branch - dev_err():
> 
>   dev_err(musb->controller, "Error: test mode is already running. "
>   "Please do USB Bus Reset to start a new test\n");

that's alright, but that if (new test is different) check is pointless
;-)

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Liu, Bin
Felipe,

> -Original Message-
> From: Balbi, Felipe
> Sent: Tuesday, March 24, 2015 12:11 PM
> To: Liu, Bin
> Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> Subject: Re: [PATCH] usb: musb: only set test mode once
> 
> On Tue, Mar 24, 2015 at 12:05:20PM -0500, Liu, Bin wrote:
> > Felipe,
> >
> > > -Original Message-
> > > From: Balbi, Felipe
> > > Sent: Tuesday, March 24, 2015 11:54 AM
> > > To: Liu, Bin
> > > Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > >
> > > On Tue, Mar 24, 2015 at 11:52:04AM -0500, Liu, Bin wrote:
> > > > Felipe,
> > > >
> > > > > -Original Message-
> > > > > From: Balbi, Felipe
> > > > > Sent: Tuesday, March 24, 2015 11:31 AM
> > > > > To: Liu, Bin
> > > > > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > > > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > > > >
> > > > > On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > > > > > The MUSB test mode register can only be set once, otherwise
> > > > > > the result is undefined.
> > > > > >
> > > > > > This prevents the debugfs testmode entry to set the register
> > > > > > more than once which causes test failure.
> > > > > >
> > > > > > Signed-off-by: Bin Liu 
> > > > > > ---
> > > > > >  drivers/usb/musb/musb_debugfs.c | 6 ++
> > > > > >  1 file changed, 6 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/usb/musb/musb_debugfs.c
> > > > > > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381
> > > > > > 100644
> > > > > > --- a/drivers/usb/musb/musb_debugfs.c
> > > > > > +++ b/drivers/usb/musb/musb_debugfs.c
> > > > > > @@ -194,6 +194,12 @@ static ssize_t
> > > > > > musb_test_mode_write(struct file
> > > *file,
> > > > > > u8  test = 0;
> > > > > > charbuf[18];
> > > > > >
> > > > > > +   test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > > > > > +   if (test) {
> > > > > > +   dev_err(musb->controller, "Error: test mode is
> running\n");
> > > > >
> > > > > with this message, user doesn't really know exactly what to do.
> > > > > Perhaps mention that a USB Bus Reset is needed to get the thing
> > > > > out of test
> > > mode?
> > > >
> > > > Ok, will change it. How about only print the error message when
> > > > the new test mode is different from the running one, and silently
> > > > do nothing if the new test mode is the same. Something like
> > > >
> > > > if (test) {
> > > > if (new test is different) {
> > > > dev_err(...);
> > > > return -EINVAL;
> > > > } else {
> > > > return 0;
> > > > }
> > > > }
> > >
> > > USB2 spec says you *must* go through a bus reset in order to get out
> > > of testmode. So if you want to change test_j to test_k, you must first bus
> reset.
> >
> > Yes, this will be handled in if branch - dev_err():
> >
> > dev_err(musb->controller, "Error: test mode is already running. "
> > "Please do USB Bus Reset to start a new test\n");
> 
> that's alright, but that if (new test is different) check is pointless
> ;-)

Ok, I see your point now. What I wanted to enhance is to not print the annoying 
message when user runs the *same* test mode command multiple times.

I don't have a strong opinion on either one. You make the call ;)

Regards,
-Bin.

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


[GIT PULL] USB patches for v4.1 merge window

2015-03-24 Thread Felipe Balbi
Hi Greg,

Because of ELC, I have to cut short on patch queueing this time. In any case,
we have some pretty good content for v4.1.

Patches have been tested with platforms I have around (heh, took me a while
to do that remotely) and most have been in next for several days.

Let me know if you want anything to be changed.

cheers

ps: I was hoping you'd be at ELC, but aparently I was wrong :-)

The following changes since commit 9eccca0843205f87c00404b663188b88eb248051:

  Linux 4.0-rc3 (2015-03-08 16:09:09 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/usb-for-v4.1

for you to fetch changes up to 3e457371f436e89ce9239674828f9729a36b2595:

  usb: musb: Fix fifo reads for dm816x with musb_dsps (2015-03-24 11:36:38 
-0500)


usb: patches for v4.1 merge window

As usual, a big pile of commits. This time a total
of 111 non-merge commits.

Other than the usual set of cleanups and non-critical
fixes, we have some interesting work for AM335x's MUSB
babble recovery. Now that takes a lot less time and we
don't have to Reset MUSB all the time.

The printer gadget has been converted to configfs interface
and the atmel udc has learned suspend/resume with wakeup.

Signed-off-by: Felipe Balbi 


Andrzej Pietrasiewicz (31):
  usb: gadget: composite: don't try standard handling for non-standard 
requests
  usb: gadget: printer: enqueue printer's response for setup request
  usb: gadget: printer: remove unused and empty printer_unbind
  usb: gadget: printer: eliminate random pointer dereference
  usb: gadget: printer: revert usb_add_function() effect in error recovery
  usb: gadget: printer: add missing error handling
  usb: gadget: printer: eliminate pdev member of struct printer_dev
  usb: gadget: printer: follow the naming convention for usb_add_config 
callback
  usb: gadget: printer: standardize printer_do_config
  usb: gadget: printer: move function-related bind code to function's bind
  usb: gadget: printer: call usb_add_function() last
  usb: gadget: printer: move function-related unbind code to function's 
unbind
  usb: gadget: printer: define pnp string buffer length
  usb: gadget: printer: don't access file global pnp_string in function's 
code
  usb: gadget: printer: add setup and cleanup functions
  usb: gadget: printer: call gprinter_setup() from gadget's bind
  usb: gadget: printer: eliminate file global printer_mutex
  usb: gadget: printer: don't access file global usb_printer_gadget in 
function's code
  usb: gadget: printer: add container_of helper for printer_dev
  usb: gadget: composite: add req_match method to usb_function
  usb: gadget: printer: name class specific requests
  usb: gadget: printer: add req_match for printer function
  usb: gadget: printer: allocate printer_dev instances dynamically
  usb: gadget: printer: factor out f_printer
  usb: gadget: f_printer: convert to new function interface with backward 
compatibility
  usb: gadget: printer: convert to new interface of f_printer
  usb: gadget: f_printer: remove compatibility layer
  usb: gadget: printer: use module_usb_composite_driver helper macro
  usb: gadget: printer: add configfs support
  usb: gadget: f_printer: use non-zero flag for bitwise and
  usb: gadget: f_printer: fix dependencies

Axel Lin (1):
  usb: phy: Find the right match in devm_usb_phy_match

Ben Dooks (1):
  usb: gadget: atmel_usba: use endian agnostic IO on ARM

Dan Carpenter (2):
  usb: gadget: printer: delete some dead code
  usb: gadget: printer: use after free in gprinter_alloc_inst()

Fabian Frederick (1):
  usb: gadget: constify of_device_id array

Fabio Estevam (1):
  usb: phy: phy-generic: No need to call gpiod_direction_output() twice

Felipe Balbi (36):
  usb: musb: gadget: get rid of stop_activity()
  usb: musb: core: fix TX/RX endpoint order
  usb: musb: core: improve musb_interrupt() a bit
  usb: dwc3: core: only reset res->start in case of error
  usb: dwc3: omap: call of_platform_depopulate() instead
  usb: dwc3: gadget: drop unnecessary loop when cleaning up TRBs
  usb: musb: core: remove unnecessary logical comparison
  usb: musb: core: add missing curly braces
  usb: musb: core: fix highspeed check
  usb: musb: dsps: return error code if reset fails
  usb: musb: core: move babble recovery inside babble check
  usb: musb: core: break long line
  usb: musb: core: remove unnecessary reg access from resume IRQ
  usb: musb: core: there is no connect interrupt in peripheral mode
  usb: musb: dsps: remove babble check from dsps irq handler
  usb: musb: dsps: check for the single bit
  usb: musb: core: controller drops session automatically
  usb: mu

RE: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Liu, Bin
Felipe,

> -Original Message-
> From: Balbi, Felipe
> Sent: Tuesday, March 24, 2015 11:54 AM
> To: Liu, Bin
> Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> Subject: Re: [PATCH] usb: musb: only set test mode once
> 
> On Tue, Mar 24, 2015 at 11:52:04AM -0500, Liu, Bin wrote:
> > Felipe,
> >
> > > -Original Message-
> > > From: Balbi, Felipe
> > > Sent: Tuesday, March 24, 2015 11:31 AM
> > > To: Liu, Bin
> > > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > >
> > > On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > > > The MUSB test mode register can only be set once, otherwise the
> > > > result is undefined.
> > > >
> > > > This prevents the debugfs testmode entry to set the register more
> > > > than once which causes test failure.
> > > >
> > > > Signed-off-by: Bin Liu 
> > > > ---
> > > >  drivers/usb/musb/musb_debugfs.c | 6 ++
> > > >  1 file changed, 6 insertions(+)
> > > >
> > > > diff --git a/drivers/usb/musb/musb_debugfs.c
> > > > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381 100644
> > > > --- a/drivers/usb/musb/musb_debugfs.c
> > > > +++ b/drivers/usb/musb/musb_debugfs.c
> > > > @@ -194,6 +194,12 @@ static ssize_t musb_test_mode_write(struct file
> *file,
> > > > u8  test = 0;
> > > > charbuf[18];
> > > >
> > > > +   test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > > > +   if (test) {
> > > > +   dev_err(musb->controller, "Error: test mode is 
> > > > running\n");
> > >
> > > with this message, user doesn't really know exactly what to do.
> > > Perhaps mention that a USB Bus Reset is needed to get the thing out of 
> > > test
> mode?
> >
> > Ok, will change it. How about only print the error message when the
> > new test mode is different from the running one, and silently do
> > nothing if the new test mode is the same. Something like
> >
> > if (test) {
> > if (new test is different) {
> > dev_err(...);
> > return -EINVAL;
> > } else {
> > return 0;
> > }
> > }
> 
> USB2 spec says you *must* go through a bus reset in order to get out of
> testmode. So if you want to change test_j to test_k, you must first bus reset.

Yes, this will be handled in if branch - dev_err():

dev_err(musb->controller, "Error: test mode is already running. "
"Please do USB Bus Reset to start a new test\n");

Regards,
-Bin.

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


[GIT PULL] USB fix for v4.0-rc6

2015-03-24 Thread Felipe Balbi
Hi Greg,

Here's a single fix for isp1760. Please consider merging it
to usb/linus.

cheers

The following changes since commit bc465aa9d045feb0e13b4a8f32cc33c1943f62d6:

  Linux 4.0-rc5 (2015-03-22 16:50:21 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
tags/fixes-for-v4.0-rc6

for you to fetch changes up to 65582a7f4ce5bd7a1fb61516d9c2476f4f166f4e:

  usb: isp1760: fix spin unlock in the error path of isp1760_udc_start 
(2015-03-24 11:38:58 -0500)


usb: fix for v4.0-rc6

Here's a single fix to isp1760 calling spin_unlock_irqsave()
as we should have.

Signed-off-by: Felipe Balbi 


Sudeep Holla (1):
  usb: isp1760: fix spin unlock in the error path of isp1760_udc_start

 drivers/usb/isp1760/isp1760-udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--
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] cx82310_eth: fix semicolon.cocci warnings

2015-03-24 Thread David Miller
From: kbuild test robot 
Date: Tue, 24 Mar 2015 09:51:32 +0800

> drivers/net/usb/cx82310_eth.c:175:2-3: Unneeded semicolon
> 
>  Removes unneeded semicolon.
> 
> Generated by: scripts/coccinelle/misc/semicolon.cocci
> 
> CC: Ondrej Zary 
> Signed-off-by: Fengguang Wu 

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


[PATCH] usb: dwc3: dwc3-omap: correct the register macros

2015-03-24 Thread Bin Liu
The macros related to register UTMI_OTG_CTRL and UTMI_OTG_STATUS are
swapped. Correct them for readability.

Signed-off-by: Bin Liu 
---
 drivers/usb/dwc3/dwc3-omap.c | 94 ++--
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index edba534..6b486a3 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -65,8 +65,8 @@
 #define USBOTGSS_IRQENABLE_SET_MISC0x003c
 #define USBOTGSS_IRQENABLE_CLR_MISC0x0040
 #define USBOTGSS_IRQMISC_OFFSET0x03fc
-#define USBOTGSS_UTMI_OTG_CTRL 0x0080
-#define USBOTGSS_UTMI_OTG_STATUS   0x0084
+#define USBOTGSS_UTMI_OTG_STATUS   0x0080
+#define USBOTGSS_UTMI_OTG_CTRL 0x0084
 #define USBOTGSS_UTMI_OTG_OFFSET   0x0480
 #define USBOTGSS_TXFIFO_DEPTH  0x0508
 #define USBOTGSS_RXFIFO_DEPTH  0x050c
@@ -98,20 +98,20 @@
 #define USBOTGSS_IRQMISC_DISCHRGVBUS_FALL  (1 << 3)
 #define USBOTGSS_IRQMISC_IDPULLUP_FALL (1 << 0)
 
-/* UTMI_OTG_CTRL REGISTER */
-#define USBOTGSS_UTMI_OTG_CTRL_DRVVBUS (1 << 5)
-#define USBOTGSS_UTMI_OTG_CTRL_CHRGVBUS(1 << 4)
-#define USBOTGSS_UTMI_OTG_CTRL_DISCHRGVBUS (1 << 3)
-#define USBOTGSS_UTMI_OTG_CTRL_IDPULLUP(1 << 0)
-
 /* UTMI_OTG_STATUS REGISTER */
-#define USBOTGSS_UTMI_OTG_STATUS_SW_MODE   (1 << 31)
-#define USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT  (1 << 9)
-#define USBOTGSS_UTMI_OTG_STATUS_TXBITSTUFFENABLE (1 << 8)
-#define USBOTGSS_UTMI_OTG_STATUS_IDDIG (1 << 4)
-#define USBOTGSS_UTMI_OTG_STATUS_SESSEND   (1 << 3)
-#define USBOTGSS_UTMI_OTG_STATUS_SESSVALID (1 << 2)
-#define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID (1 << 1)
+#define USBOTGSS_UTMI_OTG_STATUS_DRVVBUS   (1 << 5)
+#define USBOTGSS_UTMI_OTG_STATUS_CHRGVBUS  (1 << 4)
+#define USBOTGSS_UTMI_OTG_STATUS_DISCHRGVBUS   (1 << 3)
+#define USBOTGSS_UTMI_OTG_STATUS_IDPULLUP  (1 << 0)
+
+/* UTMI_OTG_CTRL REGISTER */
+#define USBOTGSS_UTMI_OTG_CTRL_SW_MODE (1 << 31)
+#define USBOTGSS_UTMI_OTG_CTRL_POWERPRESENT(1 << 9)
+#define USBOTGSS_UTMI_OTG_CTRL_TXBITSTUFFENABLE (1 << 8)
+#define USBOTGSS_UTMI_OTG_CTRL_IDDIG   (1 << 4)
+#define USBOTGSS_UTMI_OTG_CTRL_SESSEND (1 << 3)
+#define USBOTGSS_UTMI_OTG_CTRL_SESSVALID   (1 << 2)
+#define USBOTGSS_UTMI_OTG_CTRL_VBUSVALID   (1 << 1)
 
 struct dwc3_omap {
struct device   *dev;
@@ -119,7 +119,7 @@ struct dwc3_omap {
int irq;
void __iomem*base;
 
-   u32 utmi_otg_status;
+   u32 utmi_otg_ctrl;
u32 utmi_otg_offset;
u32 irqmisc_offset;
u32 irq_eoi_offset;
@@ -153,15 +153,15 @@ static inline void dwc3_omap_writel(void __iomem *base, 
u32 offset, u32 value)
writel(value, base + offset);
 }
 
-static u32 dwc3_omap_read_utmi_status(struct dwc3_omap *omap)
+static u32 dwc3_omap_read_utmi_ctrl(struct dwc3_omap *omap)
 {
-   return dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS +
+   return dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_CTRL +
omap->utmi_otg_offset);
 }
 
-static void dwc3_omap_write_utmi_status(struct dwc3_omap *omap, u32 value)
+static void dwc3_omap_write_utmi_ctrl(struct dwc3_omap *omap, u32 value)
 {
-   dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS +
+   dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_CTRL +
omap->utmi_otg_offset, value);
 
 }
@@ -235,25 +235,25 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
}
}
 
-   val = dwc3_omap_read_utmi_status(omap);
-   val &= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG
-   | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
-   | USBOTGSS_UTMI_OTG_STATUS_SESSEND);
-   val |= USBOTGSS_UTMI_OTG_STATUS_SESSVALID
-   | USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT;
-   dwc3_omap_write_utmi_status(omap, val);
+   val = dwc3_omap_read_utmi_ctrl(omap);
+   val &= ~(USBOTGSS_UTMI_OTG_CTRL_IDDIG
+   | USBOTGSS_UTMI_OTG_CTRL_VBUSVALID
+   | USBOTGSS_UTMI_OTG_CTRL_SESSEND);
+   val |= USBOTGSS_UTMI_OTG_CTRL_SESSVALID
+   | USBOTGSS_UTMI_OTG_CTRL_POWERPRESENT;
+   dwc3_omap_write_utmi_ctrl(omap, val);
break;
 
case OMAP_DWC3_VBUS_VALID:
dev_dbg(omap->dev, "VBUS Connect\n");
 
-   val = dwc3_omap_read_utmi_status(omap);
-   val &= ~USBOTGSS_UTMI_O

[PATCH v2] usb: musb: only set test mode once

2015-03-24 Thread Bin Liu
The MUSB test mode register can only be set once, otherwise the result
is undefined.

This prevents the debugfs testmode entry to set the register more than
once which causes test failure.

Signed-off-by: Bin Liu 
---
v2: revise the dev_err message.

 drivers/usb/musb/musb_debugfs.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 78a283e..04382ec 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -191,9 +191,16 @@ static ssize_t musb_test_mode_write(struct file *file,
 {
struct seq_file *s = file->private_data;
struct musb *musb = s->private;
-   u8  test = 0;
+   u8  test;
charbuf[18];
 
+   test = musb_readb(musb->mregs, MUSB_TESTMODE);
+   if (test) {
+   dev_err(musb->controller, "Error: test mode is already set. "
+   "Please do USB Bus Reset to start a new test.\n");
+   return count;
+   }
+
memset(buf, 0x00, sizeof(buf));
 
if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
-- 
1.8.4

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


[PATCH] usb: musb: add softconnect for host mode

2015-03-24 Thread Bin Liu
Add a debugfs interface - softconnect - for host mode to
connect/disconnect the devices without physically remove the
them.

This adds the capability to re-enumerate the devices which are
permanently mounted on the board with the MUSB controller
together.

Signed-off-by: Bin Liu 
---
 drivers/usb/musb/musb_debugfs.c | 92 +
 1 file changed, 92 insertions(+)

diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 04382ec..82b3be2 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -245,6 +245,91 @@ static const struct file_operations musb_test_mode_fops = {
.release= single_release,
 };
 
+static int musb_softconnect_show(struct seq_file *s, void *unused)
+{
+   struct musb *musb = s->private;
+   u8  reg;
+   int connect;
+
+   switch (musb->xceiv->otg->state) {
+   case OTG_STATE_A_HOST:
+   case OTG_STATE_A_WAIT_BCON:
+   reg = musb_readb(musb->mregs, MUSB_DEVCTL);
+   connect = reg & MUSB_DEVCTL_SESSION ? 1 : 0;
+   break;
+   default:
+   connect = -1;
+   }
+
+   seq_printf(s, "%d\n", connect);
+
+   return 0;
+}
+
+static int musb_softconnect_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, musb_softconnect_show, inode->i_private);
+}
+
+static ssize_t musb_softconnect_write(struct file *file,
+   const char __user *ubuf, size_t count, loff_t *ppos)
+{
+   struct seq_file *s = file->private_data;
+   struct musb *musb = s->private;
+   charbuf[2];
+   u8  reg;
+
+   memset(buf, 0x00, sizeof(buf));
+
+   if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+   return -EFAULT;
+
+   if (!strncmp(buf, "0", 1)) {
+   switch (musb->xceiv->otg->state) {
+   case OTG_STATE_A_HOST:
+   musb_root_disconnect(musb);
+   reg = musb_readb(musb->mregs, MUSB_DEVCTL);
+   reg &= ~MUSB_DEVCTL_SESSION;
+   musb_writeb(musb->mregs, MUSB_DEVCTL, reg);
+   break;
+   default:
+   break;
+   }
+   
+   } else if (!strncmp(buf, "1", 1)) {
+   switch (musb->xceiv->otg->state) {
+   case OTG_STATE_A_WAIT_BCON:
+   /*
+* musb_save_context() called in musb_runtime_suspend()
+* might cache devctl with SESSION bit cleared during
+* soft-disconnect, so specifically set SESSION bit
+* here to preserve it for musb_runtime_resume().
+*/
+   musb->context.devctl |= MUSB_DEVCTL_SESSION;
+   reg = musb_readb(musb->mregs, MUSB_DEVCTL);
+   reg |= MUSB_DEVCTL_SESSION;
+   musb_writeb(musb->mregs, MUSB_DEVCTL, reg);
+   break;
+   default:
+   break;
+   }
+   }
+
+   return count;
+}
+
+/*
+ * In host mode, connect/disconnect the bus without physically
+ * remove the devices.
+ */
+static const struct file_operations musb_softconnect_fops = {
+   .open   = musb_softconnect_open,
+   .write  = musb_softconnect_write,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release,
+};
+
 int musb_init_debugfs(struct musb *musb)
 {
struct dentry   *root;
@@ -271,6 +356,13 @@ int musb_init_debugfs(struct musb *musb)
goto err1;
}
 
+   file = debugfs_create_file("softconnect", S_IRUGO | S_IWUSR,
+   root, musb, &musb_softconnect_fops);
+   if (!file) {
+   ret = -ENOMEM;
+   goto err1;
+   }
+
musb->debugfs_root = root;
 
return 0;
-- 
1.8.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: Delivery Status Notification (Failure)

2015-03-24 Thread Cristian
Hello Developers of linux USB:

My report:
https://bugzilla.kernel.org/show_bug.cgi?id=95441

Thanks,
-- 
Cristian
--
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: musb: only set test mode once

2015-03-24 Thread Felipe Balbi
On Tue, Mar 24, 2015 at 12:16:25PM -0500, Liu, Bin wrote:
> Felipe,
> 
> > -Original Message-
> > From: Balbi, Felipe
> > Sent: Tuesday, March 24, 2015 12:11 PM
> > To: Liu, Bin
> > Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> > Subject: Re: [PATCH] usb: musb: only set test mode once
> > 
> > On Tue, Mar 24, 2015 at 12:05:20PM -0500, Liu, Bin wrote:
> > > Felipe,
> > >
> > > > -Original Message-
> > > > From: Balbi, Felipe
> > > > Sent: Tuesday, March 24, 2015 11:54 AM
> > > > To: Liu, Bin
> > > > Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> > > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > > >
> > > > On Tue, Mar 24, 2015 at 11:52:04AM -0500, Liu, Bin wrote:
> > > > > Felipe,
> > > > >
> > > > > > -Original Message-
> > > > > > From: Balbi, Felipe
> > > > > > Sent: Tuesday, March 24, 2015 11:31 AM
> > > > > > To: Liu, Bin
> > > > > > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > > > > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > > > > >
> > > > > > On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > > > > > > The MUSB test mode register can only be set once, otherwise
> > > > > > > the result is undefined.
> > > > > > >
> > > > > > > This prevents the debugfs testmode entry to set the register
> > > > > > > more than once which causes test failure.
> > > > > > >
> > > > > > > Signed-off-by: Bin Liu 
> > > > > > > ---
> > > > > > >  drivers/usb/musb/musb_debugfs.c | 6 ++
> > > > > > >  1 file changed, 6 insertions(+)
> > > > > > >
> > > > > > > diff --git a/drivers/usb/musb/musb_debugfs.c
> > > > > > > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381
> > > > > > > 100644
> > > > > > > --- a/drivers/usb/musb/musb_debugfs.c
> > > > > > > +++ b/drivers/usb/musb/musb_debugfs.c
> > > > > > > @@ -194,6 +194,12 @@ static ssize_t
> > > > > > > musb_test_mode_write(struct file
> > > > *file,
> > > > > > >   u8  test = 0;
> > > > > > >   charbuf[18];
> > > > > > >
> > > > > > > + test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > > > > > > + if (test) {
> > > > > > > + dev_err(musb->controller, "Error: test mode is
> > running\n");
> > > > > >
> > > > > > with this message, user doesn't really know exactly what to do.
> > > > > > Perhaps mention that a USB Bus Reset is needed to get the thing
> > > > > > out of test
> > > > mode?
> > > > >
> > > > > Ok, will change it. How about only print the error message when
> > > > > the new test mode is different from the running one, and silently
> > > > > do nothing if the new test mode is the same. Something like
> > > > >
> > > > > if (test) {
> > > > > if (new test is different) {
> > > > > dev_err(...);
> > > > > return -EINVAL;
> > > > > } else {
> > > > > return 0;
> > > > > }
> > > > > }
> > > >
> > > > USB2 spec says you *must* go through a bus reset in order to get out
> > > > of testmode. So if you want to change test_j to test_k, you must first 
> > > > bus
> > reset.
> > >
> > > Yes, this will be handled in if branch - dev_err():
> > >
> > >   dev_err(musb->controller, "Error: test mode is already running. "
> > >   "Please do USB Bus Reset to start a new test\n");
> > 
> > that's alright, but that if (new test is different) check is pointless
> > ;-)
> 
> Ok, I see your point now. What I wanted to enhance is to not print the
> annoying message when user runs the *same* test mode command multiple
> times.
> 
> I don't have a strong opinion on either one. You make the call ;)

let the user get annoyed so he quits the nonsense :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: musb: add softconnect for host mode

2015-03-24 Thread Tal Shorer
Mostly out of curiosity, why a debugfs interface and not an attribute in sysfs?
--
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: [GIT PULL] USB patches for v4.1 merge window

2015-03-24 Thread Greg KH
On Tue, Mar 24, 2015 at 12:08:32PM -0500, Felipe Balbi wrote:
> Hi Greg,
> 
> Because of ELC, I have to cut short on patch queueing this time. In any case,
> we have some pretty good content for v4.1.
> 
> Patches have been tested with platforms I have around (heh, took me a while
> to do that remotely) and most have been in next for several days.
> 
> Let me know if you want anything to be changed.
> 
> cheers
> 
> ps: I was hoping you'd be at ELC, but aparently I was wrong :-)


I'm in France for 2 months, couldn't make it, it's the first I've missed
in years :(

> The following changes since commit 9eccca0843205f87c00404b663188b88eb248051:
> 
>   Linux 4.0-rc3 (2015-03-08 16:09:09 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/usb-for-v4.1

Pulled and pushed out, 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: [GIT PULL] USB fix for v4.0-rc6

2015-03-24 Thread Greg KH
On Tue, Mar 24, 2015 at 12:02:15PM -0500, Felipe Balbi wrote:
> Hi Greg,
> 
> Here's a single fix for isp1760. Please consider merging it
> to usb/linus.
> 
> cheers
> 
> The following changes since commit bc465aa9d045feb0e13b4a8f32cc33c1943f62d6:
> 
>   Linux 4.0-rc5 (2015-03-22 16:50:21 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v4.0-rc6

Pulled and pushed out, 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: [GIT PULL] USB patches for v4.1 merge window

2015-03-24 Thread Felipe Balbi
On Tue, Mar 24, 2015 at 10:58:46PM +0100, Greg KH wrote:
> On Tue, Mar 24, 2015 at 12:08:32PM -0500, Felipe Balbi wrote:
> > Hi Greg,
> > 
> > Because of ELC, I have to cut short on patch queueing this time. In any 
> > case,
> > we have some pretty good content for v4.1.
> > 
> > Patches have been tested with platforms I have around (heh, took me a while
> > to do that remotely) and most have been in next for several days.
> > 
> > Let me know if you want anything to be changed.
> > 
> > cheers
> > 
> > ps: I was hoping you'd be at ELC, but aparently I was wrong :-)
> 
> 
> I'm in France for 2 months, couldn't make it, it's the first I've missed
> in years :(

Have fun, there will be other conferences :-)

> > The following changes since commit 9eccca0843205f87c00404b663188b88eb248051:
> > 
> >   Linux 4.0-rc3 (2015-03-08 16:09:09 -0700)
> > 
> > are available in the git repository at:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> > tags/usb-for-v4.1
> 
> Pulled and pushed out, thanks.

tks

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: musb: add softconnect for host mode

2015-03-24 Thread Felipe Balbi
On Tue, Mar 24, 2015 at 11:49:53PM +0200, Tal Shorer wrote:
> Mostly out of curiosity, why a debugfs interface and not an attribute in 
> sysfs?

mostly out of curiosity, why deleting the entire context ?

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH] usb: musb: only set test mode once

2015-03-24 Thread Liu, Bin

> -Original Message-
> From: Balbi, Felipe
> Sent: Tuesday, March 24, 2015 4:28 PM
> To: Liu, Bin
> Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> Subject: Re: [PATCH] usb: musb: only set test mode once
> 
> On Tue, Mar 24, 2015 at 12:16:25PM -0500, Liu, Bin wrote:
> > Felipe,
> >
> > > -Original Message-
> > > From: Balbi, Felipe
> > > Sent: Tuesday, March 24, 2015 12:11 PM
> > > To: Liu, Bin
> > > Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > >
> > > On Tue, Mar 24, 2015 at 12:05:20PM -0500, Liu, Bin wrote:
> > > > Felipe,
> > > >
> > > > > -Original Message-
> > > > > From: Balbi, Felipe
> > > > > Sent: Tuesday, March 24, 2015 11:54 AM
> > > > > To: Liu, Bin
> > > > > Cc: Balbi, Felipe; linux-usb@vger.kernel.org
> > > > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > > > >
> > > > > On Tue, Mar 24, 2015 at 11:52:04AM -0500, Liu, Bin wrote:
> > > > > > Felipe,
> > > > > >
> > > > > > > -Original Message-
> > > > > > > From: Balbi, Felipe
> > > > > > > Sent: Tuesday, March 24, 2015 11:31 AM
> > > > > > > To: Liu, Bin
> > > > > > > Cc: linux-usb@vger.kernel.org; Balbi, Felipe
> > > > > > > Subject: Re: [PATCH] usb: musb: only set test mode once
> > > > > > >
> > > > > > > On Fri, Mar 20, 2015 at 04:49:58PM -0500, Bin Liu wrote:
> > > > > > > > The MUSB test mode register can only be set once,
> > > > > > > > otherwise the result is undefined.
> > > > > > > >
> > > > > > > > This prevents the debugfs testmode entry to set the
> > > > > > > > register more than once which causes test failure.
> > > > > > > >
> > > > > > > > Signed-off-by: Bin Liu 
> > > > > > > > ---
> > > > > > > >  drivers/usb/musb/musb_debugfs.c | 6 ++
> > > > > > > >  1 file changed, 6 insertions(+)
> > > > > > > >
> > > > > > > > diff --git a/drivers/usb/musb/musb_debugfs.c
> > > > > > > > b/drivers/usb/musb/musb_debugfs.c index 78a283e..cd0c381
> > > > > > > > 100644
> > > > > > > > --- a/drivers/usb/musb/musb_debugfs.c
> > > > > > > > +++ b/drivers/usb/musb/musb_debugfs.c
> > > > > > > > @@ -194,6 +194,12 @@ static ssize_t
> > > > > > > > musb_test_mode_write(struct file
> > > > > *file,
> > > > > > > > u8  test = 0;
> > > > > > > > charbuf[18];
> > > > > > > >
> > > > > > > > +   test = musb_readb(musb->mregs, MUSB_TESTMODE);
> > > > > > > > +   if (test) {
> > > > > > > > +   dev_err(musb->controller, "Error: test mode is
> > > running\n");
> > > > > > >
> > > > > > > with this message, user doesn't really know exactly what to do.
> > > > > > > Perhaps mention that a USB Bus Reset is needed to get the
> > > > > > > thing out of test
> > > > > mode?
> > > > > >
> > > > > > Ok, will change it. How about only print the error message
> > > > > > when the new test mode is different from the running one, and
> > > > > > silently do nothing if the new test mode is the same.
> > > > > > Something like
> > > > > >
> > > > > > if (test) {
> > > > > > if (new test is different) {
> > > > > > dev_err(...);
> > > > > > return -EINVAL;
> > > > > > } else {
> > > > > > return 0;
> > > > > > }
> > > > > > }
> > > > >
> > > > > USB2 spec says you *must* go through a bus reset in order to get
> > > > > out of testmode. So if you want to change test_j to test_k, you
> > > > > must first bus
> > > reset.
> > > >
> > > > Yes, this will be handled in if branch - dev_err():
> > > >
> > > > dev_err(musb->controller, "Error: test mode is already running. 
> > > > "
> > > > "Please do USB Bus Reset to start a new test\n");
> > >
> > > that's alright, but that if (new test is different) check is
> > > pointless
> > > ;-)
> >
> > Ok, I see your point now. What I wanted to enhance is to not print the
> > annoying message when user runs the *same* test mode command multiple
> > times.
> >
> > I don't have a strong opinion on either one. You make the call ;)
> 
> let the user get annoyed so he quits the nonsense :-)

Yup, that was what I picked in v2 ;) Please review it.

Thanks,
-Bin.

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


Re: Errata for Freescale root-hub TT?

2015-03-24 Thread Peter Chen
On Tue, Mar 24, 2015 at 10:15:38AM -0400, Alan Stern wrote:
> On Tue, 24 Mar 2015, Peter Chen wrote:
> 
> > On Mon, Mar 23, 2015 at 10:11:04AM -0400, Alan Stern wrote:
> > > On Mon, 23 Mar 2015, Peter Chen wrote:
> > > 
> > > > For going on debugging this problem, we need
> > > 
> > > I will have the hardware only for one more day, so I may not be able to
> > > get all the information you want.
> > > 
> > > > - Your bus analyzer file, I think there should be no enough IN/OUT
> > > > tokens within one frame, does the remaining time to frame boundaries
> > > > is enough? 
> > > 
> > > Here's an example: There are four OUT transfers near the start of the 
> > > frame, and they take about 300 us.  The remaining 700 us in the frame 
> > > are completely idle, even though they should contain four IN transfers.
> > 
> > How do you know the frame has filled already at that time? The software
> > makes sure it fills frame in time before next time frame?
> 
> I'm not sure I understand the question.
> 
> The USB analyzer log showed something like this (this is a rough 
> approximation because I didn't keep the original analyzer output file):
> 
>   Timestamp   Transaction
>   s.mmm uuu
>   ---
>   0.000 000   SOF
>   0.000 030   Isoc OUT
>   0.000 091   Isoc OUT
>   0.000 162   Isoc OUT
>   0.000 224   Isoc OUT
>   0.001 000   SOF
> 
> In this example, there are 4 OUT transfers taking about 290 us and then
> nothing else for the rest of the frame.
> 
> I also know, from looking at the "periodic" file in the EHCI debugfs 
> directory, that each frame was linked to 8 siTDs:
> 
>   siTD OUT, Smask = 0x01, Cmask = 0x00, transfer length = 64
>   siTD OUT, Smask = 0x01, Cmask = 0x00, transfer length = 64
>   siTD OUT, Smask = 0x02, Cmask = 0x00, transfer length = 64
>   siTD OUT, Smask = 0x02, Cmask = 0x00, transfer length = 64
>   siTD IN,  Smask = 0x04, Cmask = 0x70, transfer length = 64
>   siTD IN,  Smask = 0x04, Cmask = 0x70, transfer length = 64
>   siTD IN,  Smask = 0x08, Cmask = 0xe0, transfer length = 64
>   siTD IN,  Smask = 0x08, Cmask = 0xe0, transfer length = 64
> 

I did not debug too many for Host ISOC, I just want to make sure the
siTD is ready before the controller read it? 

Does it fail at the beginning or running several cycles?

-- 

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-24 Thread Peter Chen
On Mon, Mar 23, 2015 at 03:19:07PM +0800, Li Jun wrote:
> On Fri, Mar 20, 2015 at 11:07:17AM +0800, Peter Chen wrote:
> > On Thu, Mar 19, 2015 at 11:11:17AM +0800, Li Jun wrote:
> > > HNP polling is a mechanism which allows the OTG device currently acting 
> > > as host
> > > to determine when the other attached OTG device wishes to take the host 
> > > role.
> > > When an OTG host, which supports HNP, is connected to an OTG peripheral 
> > > which
> > > also supports HNP it shall poll the peripheral regularly to determine 
> > > whether
> > > it requires a role-swap and grant this at the earliest opportunity.
> > > 
> > > changes for v4:
> > > - Add OTG HNP capable check for connected device before sending HNP 
> > > polling
> > >   in patch 3/8.
> > > - Add comment to explain HNP test update in chipidea.txt in patch 8/8.
> > > - Fix some typo.
> > > - Add Peter's Ack in patch 1,2,4,5,6,7/8 of the series.
> > > 
> > 
> > Have a test with your patch set, one problem has been found, for how to
> > re-produce:
> > - 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. See below
> > log:
> > 
> > root@imx6sxsabresd:~# modprobe g_mass_storage file=/dev/mmcblk0p1
> > [   19.311974] Number of LUNs=8
> > [   19.314903] Mass Storage Function, version: 2009/09/11
> > [   19.320192] LUN: removable file: (no medium)
> > [   19.324520] Number of LUNs=1
> > [   19.327888] LUN: file: /dev/mmcblk0p1
> > [   19.331568] Number of LUNs=1
> > [   19.336831] g_mass_storage gadget: Mass Storage Gadget,
> > version: 2009/09/11
> > [   19.343817] g_mass_storage gadget: userspace failed to
> > provide iSerialNumber
> > [   19.350912] g_mass_storage gadget: g_mass_storage ready
> > root@imx6sxsabresd:~# [   19.396639] usb 1-1: USB disconnect,
> > device number 2
> > [   19.423829] sd 0:0:0:0: [sda] Synchronizing SCSI cache
> > [   19.430245] sd 0:0:0:0: [sda] Synchronize Cache(10) failed:
> > Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
> > [   19.446612] usb 1-1: Get one byte OTG status failed
> > [   19.735877] usb 1-1: new high-speed USB device number 3 using
> > ci_hdrc
> > [   19.887394] usb 1-1: Dual-Role OTG device on HNP port
> > [   19.905834] usb-storage 1-1:1.0: USB Mass Storage device
> > detected
> > [   19.912812] usb-storage 1-1:1.0: Quirks match for vid 0525
> > pid a4a5: 1
> > [   19.922080] scsi host1: usb-storage 1-1:1.0
> > [   20.927712] scsi 1:0:0:0: Direct-Access Linux
> > File-Stor Gadget 0400 PQ: 0 ANSI: 2
> > [   20.956936] sd 1:0:0:0: [sda] 1024000 512-byte logical
> > blocks: (524 MB/500 MiB)
> > [   21.069069] sd 1:0:0:0: [sda] Write Protect is off
> > [   21.179176] sd 1:0:0:0: [sda] Write cache: enabled, read
> > cache: enabled, doesn't support DPO or FUA
> > [   21.420525]  sda:
> > 
> > [   21.649297] sd 1:0:0:0: [sda] Attached SCSI disk
> > 
> This is because latest pullup DP change(fully controlled by udc-core)
> introduced but it's not in my code base, I will create a patch to adapt
> it to OTG fsm driver.
> 
> 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
> 

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.

The log at A side:
root@imx6sxsabresd:~# modprobe g_mass_storage file=/dev/mmcblk0p1
[  428.998052] Number of LUNs=8
[  429.000979] Mass Storage Function, version: 2009/09/11
[  429.006135] LUN: removable file: (no medium)
[  429.013328] Number of LUNs=1
[  429.016669] LUN: file: /dev/mmcblk0p1
[  429.020415] Number of LUNs=1
[  429.026513] g_mass_storage gadget: Mass Storage Gadget,
version: 2009/09/11
[  429.033539] g_mass_storage gadget: userspace failed to
provide iSerialNumber
[  429.040646] g_mass_storage gadget: g_mass_storage ready
root@imx6sxsabresd:~# 
root@imx6sxsabresd:~# [  436.232338] ci_hdrc ci_hdrc.0: remove,
state 1
[  436.237892] usb usb1: USB disconnect, device number 1
[  436.243003] usb 1-1: USB disconnect, device number 2
[  436.295634] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  436.302602] sd 0:0:0:0: [sda] Synchronize Cache(

Re: [PATCH] usb: chipidea: usbmisc_imx: fix returnvar.cocci warnings

2015-03-24 Thread Julia Lawall
Please take a look.

thanks,
julia

On Wed, 25 Mar 2015, kbuild test robot wrote:

> TO: Peter Chen 
> CC: "Greg Kroah-Hartman" 
> CC: linux-usb@vger.kernel.org
> CC: linux-ker...@vger.kernel.org
> 
> drivers/usb/chipidea/usbmisc_imx.c:277:5-8: Unneeded variable: "ret". Return 
> "0" on line 297
> 
> 
>  Removes unneeded variable used to store return value.
> 
> Generated by: scripts/coccinelle/misc/returnvar.cocci
> 
> CC: Peter Chen 
> Signed-off-by: Fengguang Wu 
> ---
> 
> Please take the patch only if it's a positive warning. Thanks!
> 
>  usbmisc_imx.c |3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> --- a/drivers/usb/chipidea/usbmisc_imx.c
> +++ b/drivers/usb/chipidea/usbmisc_imx.c
> @@ -274,7 +274,6 @@ static int usbmisc_imx6sx_init(struct im
>   unsigned long flags;
>   struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
>   u32 val;
> - int ret = 0;
>  
>   usbmisc_imx6q_init(data);
>  
> @@ -294,7 +293,7 @@ static int usbmisc_imx6sx_init(struct im
>   spin_unlock_irqrestore(&usbmisc->lock, flags);
>   }
>  
> - return ret;
> + return 0;
>  }
>  
>  static int usbmisc_vf610_init(struct imx_usbmisc_data *data)
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: chipidea: usbmisc_imx: fix returnvar.cocci warnings

2015-03-24 Thread Peter Chen
On Wed, Mar 25, 2015 at 07:23:52AM +0100, Julia Lawall wrote:
> Please take a look.
> 

It is strange why I did not receive it.
The patch is ok.

Signed-off-by: Peter Chen 

> thanks,
> julia
> 
> On Wed, 25 Mar 2015, kbuild test robot wrote:
> 
> > TO: Peter Chen 
> > CC: "Greg Kroah-Hartman" 
> > CC: linux-usb@vger.kernel.org
> > CC: linux-ker...@vger.kernel.org
> > 
> > drivers/usb/chipidea/usbmisc_imx.c:277:5-8: Unneeded variable: "ret". 
> > Return "0" on line 297
> > 
> > 
> >  Removes unneeded variable used to store return value.
> > 
> > Generated by: scripts/coccinelle/misc/returnvar.cocci
> > 
> > CC: Peter Chen 
> > Signed-off-by: Fengguang Wu 
> > ---
> > 
> > Please take the patch only if it's a positive warning. Thanks!
> > 
> >  usbmisc_imx.c |3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > --- a/drivers/usb/chipidea/usbmisc_imx.c
> > +++ b/drivers/usb/chipidea/usbmisc_imx.c
> > @@ -274,7 +274,6 @@ static int usbmisc_imx6sx_init(struct im
> > unsigned long flags;
> > struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
> > u32 val;
> > -   int ret = 0;
> >  
> > usbmisc_imx6q_init(data);
> >  
> > @@ -294,7 +293,7 @@ static int usbmisc_imx6sx_init(struct im
> > spin_unlock_irqrestore(&usbmisc->lock, flags);
> > }
> >  
> > -   return ret;
> > +   return 0;
> >  }
> >  
> >  static int usbmisc_vf610_init(struct imx_usbmisc_data *data)
> > 
> --
> 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: [PATCH v4 0/8] add HNP polling support for usb otg fsm

2015-03-24 Thread Li Jun
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?

Li Jun
> 
> [1] http://www.spinics.net/lists/linux-usb/msg123204.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: [PATCH v4 0/8] add HNP polling support for usb otg fsm

2015-03-24 Thread Peter Chen
 
> 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.

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


[PATCH] usb: Enable LPM for USB 2.01+ full-speed devices

2015-03-24 Thread rtatiya
From: Rupesh Tatiya 

USB 2.01+ full-speed devices can have extended descriptor as well
and can support LPM.

Change-Id: Ic055d51c02651810d3eb7141bab20a090fe8453b
Signed-off-by: Rupesh Tatiya 
---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 9ef2d2c..1ed7b5d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -140,7 +140,7 @@ static int usb_device_supports_lpm(struct usb_device *udev)
/* USB 2.1 (and greater) devices indicate LPM support through
 * their USB 2.0 Extended Capabilities BOS descriptor.
 */
-   if (udev->speed == USB_SPEED_HIGH) {
+   if (udev->speed == USB_SPEED_HIGH || udev->speed == USB_SPEED_FULL) {
if (udev->bos->ext_cap &&
(USB_LPM_SUPPORT &
 le32_to_cpu(udev->bos->ext_cap->bmAttributes)))
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, 
a Linux Foundation Collaborative Project

--
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: Enable LPM for USB 2.01+ full-speed devices

2015-03-24 Thread Greg KH
On Wed, Mar 25, 2015 at 12:23:19PM +0530, rtat...@codeaurora.org wrote:
> From: Rupesh Tatiya 
> 
> USB 2.01+ full-speed devices can have extended descriptor as well
> and can support LPM.
> 
> Change-Id: Ic055d51c02651810d3eb7141bab20a090fe8453b

We can't take patches with this in it, as it makes no sense in a kernel
changelog :(

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