Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Roger Quadros
Hi David,

On 11/29/2013 03:17 PM, David Laight wrote:
 From: Of Roger Quadros
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.
 ...
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -43,14 +43,18 @@
  /* UHH Register Set */
  #define OMAP_UHH_REVISION   (0x00)
  #define OMAP_UHH_SYSCONFIG  (0x10)
 -#define OMAP_UHH_SYSCONFIG_MIDLEMODE(1  12)
 +#define OMAP_UHH_SYSCONFIG_MIDLEMASK(3  12)
 +#define OMAP_UHH_SYSCONFIG_MIDLESHIFT   (12)
 
 (tab/space issue)

Weird, original code seems to use a tab instead of space after #define. 

 
 Wouldn't it be clearer to define these in the opposite order with:
 +#define  OMAP_UHH_SYSCONFIG_MIDLEMASK(3  
 OMAP_UHH_SYSCONFIG_MIDLESHIFT)

Right.

 
 ... 
 +static void omap_usbhs_rev1_reset(struct device *dev)
 +{
 +struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
 +u32 reg;
 +unsigned long timeout;
 +
 +reg = usbhs_read(omap-uhh_base, OMAP_UHH_SYSCONFIG);
 +
 +/* Soft Reset */
 +usbhs_write(omap-uhh_base, OMAP_UHH_SYSCONFIG,
 +reg | OMAP_UHH_SYSCONFIG_SOFTRESET);
 +
 +timeout = jiffies + msecs_to_jiffies(100);
 +while (!(usbhs_read(omap-uhh_base, OMAP_UHH_SYSSTATUS)
 + OMAP_UHH_SYSSTATUS_RESETDONE)) {
 +cpu_relax();

You mean use msleep(1) here instead of cpu_relax()?
Shouldn't be a problem IMO, but can you please tell me why that is better
as the reset seems to complete usually in the first iteration.

 +
 +if (time_after(jiffies, timeout)) {
 +dev_err(dev, Soft RESET operation timed out\n);
 +break;
 +}
 +}
 +
 +/* Set No-Standby */
 +reg = ~OMAP_UHH_SYSCONFIG_MIDLEMASK;
 +reg |= OMAP_UHH_SYSCONFIG_MIDLE_NOSTANDBY
 + OMAP_UHH_SYSCONFIG_MIDLESHIFT;
 +
 +/* Set No-Idle */
 +reg = ~OMAP_UHH_SYSCONFIG_SIDLEMASK;
 +reg |= OMAP_UHH_SYSCONFIG_SIDLE_NOIDLE
 + OMAP_UHH_SYSCONFIG_SIDLESHIFT;
 
 Why not pass in the mask and value and avoid replicating the
 entire function. I can't see any other significant differences,
 the udelay(2) won't be significant.

OK, I can pass the mask and value, but still there is a difference
in the way reset complete is checked between v1 and v2. But that
be in omap_usbhs_softreset() and the individual reset functions can be
replaced by a single omap_usbhs_set_sysconfig().

It seems the udelay() is not required for the USB Host module, so I'll
get rid of that.

 
 I'm not sure of the context this code runs in, but if the reset
 is likely to take a significant portion of the 100ms timeout
 period, why not just sleep for a few ms between status polls.

covered in the related code above.

cheers,
-roger

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


[PATCH 1/1] support new huawei devices in option.c

2013-12-02 Thread Fangxiaozhi (Franko)
1. Add new supporting declarations to option.c, to support Huawei new devices 
with new bInterfaceProtocol value.
Signed-off-by: fangxiaozhi huana...@huawei.com


--- linux-3.12.1/drivers/usb/serial/option.bk   2013-11-29 14:49:44.528970754 
+0800
+++ linux-3.12.1/drivers/usb/serial/option.c2013-11-29 15:22:01.0 
+0800
@@ -634,6 +634,10 @@
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x72) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x73) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x74) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x75) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) },
@@ -688,6 +692,10 @@
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x72) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x73) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x74) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x75) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) },
@@ -742,6 +750,10 @@
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x72) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x73) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x74) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x75) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) },
@@ -796,6 +808,10 @@
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x72) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x73) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x74) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x75) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) },
@@ -850,6 +866,10 @@
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x72) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x73) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x74) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x75) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) },
@@ -904,6 +924,10 @@
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) },
{ USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x72) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x73) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x74) },
+   { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x75) },
 

RE: net/usb/ax88179_178a driver broken in linux-3.12

2013-12-02 Thread David Laight
 From: Mark Lord
 Sent: 30 November 2013 02:59
 To: Sarah Sharp; David Laight
 Cc: David Miller; eric.duma...@gmail.com; ming@canonical.com; 
 net...@vger.kernel.org; linux-
 u...@vger.kernel.org
 Subject: Re: net/usb/ax88179_178a driver broken in linux-3.12
 
 On 13-11-19 08:44 AM, Mark Lord wrote:
  On 13-11-19 05:04 AM, David Laight wrote:
 
  Which changes did you revert?
 
  Just the bits that changed how the headroom/tailroom sizes
  were checked and adjusted.  See attachment for the revert patch
  I am using here.  My mailer unfortunately likes to mangle inline patches.
 
...
 
 Two kernels later, and this regression has still not been fixed.
 
 A simple revert, folks.

Reverting the ax88179_178a driver doesn't fix the problem.
I'm seen tx/rx issues with it on much older kernels that don't
appear with a current kernel and the fixed xhci code.

Sarah needs to feed the xhci_ring.c fix through into stable.

David



Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Roger Quadros
+Benoit, Tony, Paul.

Hi Michael,

On 11/30/2013 06:48 AM, Michael Trimarchi wrote:
 Hi Roger
 
 On Fri, Nov 29, 2013 at 2:01 PM, Roger Quadros rog...@ti.com wrote:
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.

 Reported-by: Tomi Valkeinen tomi.valkei...@ti.com
 Cc: sta...@vger.kernel.org # 3.10+
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  drivers/mfd/omap-usb-host.c | 115 
 +---
  1 file changed, 109 insertions(+), 6 deletions(-)

 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index 142650f..d4bd464 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -43,14 +43,18 @@
  /* UHH Register Set */
  #defineOMAP_UHH_REVISION   (0x00)
  #defineOMAP_UHH_SYSCONFIG  (0x10)
 -#defineOMAP_UHH_SYSCONFIG_MIDLEMODE(1  12)
 +#defineOMAP_UHH_SYSCONFIG_MIDLEMASK(3  12)
 +#define OMAP_UHH_SYSCONFIG_MIDLESHIFT  (12)
  #defineOMAP_UHH_SYSCONFIG_CACTIVITY(1  8)
 -#defineOMAP_UHH_SYSCONFIG_SIDLEMODE(1  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLEMASK(3  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLESHIFT   (3)
  #defineOMAP_UHH_SYSCONFIG_ENAWAKEUP(1  2)
  #defineOMAP_UHH_SYSCONFIG_SOFTRESET(1  1)
  #defineOMAP_UHH_SYSCONFIG_AUTOIDLE (1  0)

  #defineOMAP_UHH_SYSSTATUS  (0x14)
 +#define OMAP_UHH_SYSSTATUS_RESETDONE   (1  0)
 +
  #defineOMAP_UHH_HOSTCONFIG (0x40)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1  0)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS  (1  0)
 @@ -66,10 +70,10 @@
  #define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1  31)

  /* OMAP4-specific defines */
 -#define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3  2)
 -#define OMAP4_UHH_SYSCONFIG_NOIDLE (1  2)
 -#define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR(3  4)
 -#define OMAP4_UHH_SYSCONFIG_NOSTDBY(1  4)
 +#define OMAP4_UHH_SYSCONFIG_MIDLEMASK  (3  2)
 +#define OMAP4_UHH_SYSCONFIG_MIDLESHIFT (2)
 +#define OMAP4_UHH_SYSCONFIG_SIDLEMASK  (3  4)
 +#define OMAP4_UHH_SYSCONFIG_SIDLESHIFT (4)
  #define OMAP4_UHH_SYSCONFIG_SOFTRESET  (1  0)

  #define OMAP4_P1_MODE_CLEAR(3  16)
 @@ -81,6 +85,12 @@

  #defineOMAP_UHH_DEBUG_CSR  (0x44)

 +/* MIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_MIDLE_NOSTANDBY (1)
 +
 +/* SIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_SIDLE_NOIDLE(1)
 +
  /* Values of UHH_REVISION - Note: these are not given in the TRM */
  #define OMAP_USBHS_REV10x0010  /* OMAP3 */
  #define OMAP_USBHS_REV20x50700100  /* OMAP4 */
 @@ -474,6 +484,97 @@ static unsigned omap_usbhs_rev2_hostconfig(struct 
 usbhs_hcd_omap *omap,
 return reg;
  }

 
 I'm digging in the code but as I understand this should be done by
 omap_hwmod and
 i660 avoid reset of the ehci module. This is done by ocp_softreset?
 

It won't be done by omap_hwmod as we set HWMOD_INIT_NO_RESET flag in the hwmod 
data [1].

Question is do we do it in the driver of leave it to hwmod?

The other concern about i660 is in this comment [1]

/*
 * During system boot; If the hwmod framework resets the module
 * the module will have smart idle settings; which can lead to deadlock
 * (above Errata Id:i660); so, dont reset the module during boot;
 * Use HWMOD_INIT_NO_RESET.
 */

But if you look at the errata document [2], Advisory 1.108, it doesn't say that 
we can't be in smart-idle, but
only that we should put the module in force-idle, before cutting the module's 
functional clock. It also states
that the only way to recover from a lockup condition is to soft reset the 
module. So I'm not sure if the above comment
in the code is really valid. What if the lockup happens in the bootloader? In 
that case we will have to reset the module in
the kernel.

Doing the reset in probe does solve a problem for now i.e. eliminates 
dependency on bootloader.

[1] - 
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c#n2024
[2] - http://www.ti.com/litv/pdf/sprz318e

 
 +static void omap_usbhs_rev1_reset(struct device *dev)
 +{
 +   struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
 +   u32 

Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Roger Quadros
Michael,

On 11/29/2013 05:32 PM, Michael Trimarchi wrote:
 Hi Roger
 
 On Fri, Nov 29, 2013 at 2:01 PM, Roger Quadros rog...@ti.com wrote:
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.

 
 Do you think that we need something similar of usb musb?
 I have seen the OTG_SYSCONFIG is touched in uboot and
 only readed in omap2430.c.

I'm not sure about musb. Maybe Sebastian/Felipe have better idea.
In general I believe that all modules must be reset by the kernel.

cheers,
-roger
 
 Reported-by: Tomi Valkeinen tomi.valkei...@ti.com
 Cc: sta...@vger.kernel.org # 3.10+
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  drivers/mfd/omap-usb-host.c | 115 
 +---
  1 file changed, 109 insertions(+), 6 deletions(-)

 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index 142650f..d4bd464 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -43,14 +43,18 @@
  /* UHH Register Set */
  #defineOMAP_UHH_REVISION   (0x00)
  #defineOMAP_UHH_SYSCONFIG  (0x10)
 -#defineOMAP_UHH_SYSCONFIG_MIDLEMODE(1  12)
 +#defineOMAP_UHH_SYSCONFIG_MIDLEMASK(3  12)
 +#define OMAP_UHH_SYSCONFIG_MIDLESHIFT  (12)
  #defineOMAP_UHH_SYSCONFIG_CACTIVITY(1  8)
 -#defineOMAP_UHH_SYSCONFIG_SIDLEMODE(1  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLEMASK(3  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLESHIFT   (3)
  #defineOMAP_UHH_SYSCONFIG_ENAWAKEUP(1  2)
  #defineOMAP_UHH_SYSCONFIG_SOFTRESET(1  1)
  #defineOMAP_UHH_SYSCONFIG_AUTOIDLE (1  0)

  #defineOMAP_UHH_SYSSTATUS  (0x14)
 +#define OMAP_UHH_SYSSTATUS_RESETDONE   (1  0)
 +
  #defineOMAP_UHH_HOSTCONFIG (0x40)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1  0)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS  (1  0)
 @@ -66,10 +70,10 @@
  #define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1  31)

  /* OMAP4-specific defines */
 -#define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3  2)
 -#define OMAP4_UHH_SYSCONFIG_NOIDLE (1  2)
 -#define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR(3  4)
 -#define OMAP4_UHH_SYSCONFIG_NOSTDBY(1  4)
 +#define OMAP4_UHH_SYSCONFIG_MIDLEMASK  (3  2)
 +#define OMAP4_UHH_SYSCONFIG_MIDLESHIFT (2)
 +#define OMAP4_UHH_SYSCONFIG_SIDLEMASK  (3  4)
 +#define OMAP4_UHH_SYSCONFIG_SIDLESHIFT (4)
  #define OMAP4_UHH_SYSCONFIG_SOFTRESET  (1  0)

  #define OMAP4_P1_MODE_CLEAR(3  16)
 @@ -81,6 +85,12 @@

  #defineOMAP_UHH_DEBUG_CSR  (0x44)

 +/* MIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_MIDLE_NOSTANDBY (1)
 +
 +/* SIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_SIDLE_NOIDLE(1)
 +
  /* Values of UHH_REVISION - Note: these are not given in the TRM */
  #define OMAP_USBHS_REV10x0010  /* OMAP3 */
  #define OMAP_USBHS_REV20x50700100  /* OMAP4 */
 @@ -474,6 +484,97 @@ static unsigned omap_usbhs_rev2_hostconfig(struct 
 usbhs_hcd_omap *omap,
 return reg;
  }

 +static void omap_usbhs_rev1_reset(struct device *dev)
 +{
 +   struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
 +   u32 reg;
 +   unsigned long timeout;
 +
 +   reg = usbhs_read(omap-uhh_base, OMAP_UHH_SYSCONFIG);
 +
 +   /* Soft Reset */
 +   usbhs_write(omap-uhh_base, OMAP_UHH_SYSCONFIG,
 +   reg | OMAP_UHH_SYSCONFIG_SOFTRESET);
 +
 +   timeout = jiffies + msecs_to_jiffies(100);
 +   while (!(usbhs_read(omap-uhh_base, OMAP_UHH_SYSSTATUS)
 +OMAP_UHH_SYSSTATUS_RESETDONE)) {
 +   cpu_relax();
 +
 +   if (time_after(jiffies, timeout)) {
 +   dev_err(dev, Soft RESET operation timed out\n);
 +   break;
 +   }
 +   }
 +
 +   /* Set No-Standby */
 +   reg = ~OMAP_UHH_SYSCONFIG_MIDLEMASK;
 +   reg |= OMAP_UHH_SYSCONFIG_MIDLE_NOSTANDBY
 +OMAP_UHH_SYSCONFIG_MIDLESHIFT;
 +
 +   /* Set No-Idle */
 +   reg = ~OMAP_UHH_SYSCONFIG_SIDLEMASK;
 +   reg |= OMAP_UHH_SYSCONFIG_SIDLE_NOIDLE
 +OMAP_UHH_SYSCONFIG_SIDLESHIFT;
 +
 +   usbhs_write(omap-uhh_base, OMAP_UHH_SYSCONFIG, reg);
 +}
 +
 +static void omap_usbhs_rev2_reset(struct device *dev)
 +{

Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Michael Trimarchi
Hi Roger

On Mon, Dec 2, 2013 at 10:39 AM, Roger Quadros rog...@ti.com wrote:
 +Benoit, Tony, Paul.

 Hi Michael,

 On 11/30/2013 06:48 AM, Michael Trimarchi wrote:
 Hi Roger

 On Fri, Nov 29, 2013 at 2:01 PM, Roger Quadros rog...@ti.com wrote:
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.

 Reported-by: Tomi Valkeinen tomi.valkei...@ti.com
 Cc: sta...@vger.kernel.org # 3.10+
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  drivers/mfd/omap-usb-host.c | 115 
 +---
  1 file changed, 109 insertions(+), 6 deletions(-)

 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index 142650f..d4bd464 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -43,14 +43,18 @@
  /* UHH Register Set */
  #defineOMAP_UHH_REVISION   (0x00)
  #defineOMAP_UHH_SYSCONFIG  (0x10)
 -#defineOMAP_UHH_SYSCONFIG_MIDLEMODE(1  12)
 +#defineOMAP_UHH_SYSCONFIG_MIDLEMASK(3  12)
 +#define OMAP_UHH_SYSCONFIG_MIDLESHIFT  (12)
  #defineOMAP_UHH_SYSCONFIG_CACTIVITY(1  8)
 -#defineOMAP_UHH_SYSCONFIG_SIDLEMODE(1  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLEMASK(3  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLESHIFT   (3)
  #defineOMAP_UHH_SYSCONFIG_ENAWAKEUP(1  2)
  #defineOMAP_UHH_SYSCONFIG_SOFTRESET(1  1)
  #defineOMAP_UHH_SYSCONFIG_AUTOIDLE (1  0)

  #defineOMAP_UHH_SYSSTATUS  (0x14)
 +#define OMAP_UHH_SYSSTATUS_RESETDONE   (1  0)
 +
  #defineOMAP_UHH_HOSTCONFIG (0x40)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1  0)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS  (1  0)
 @@ -66,10 +70,10 @@
  #define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1  31)

  /* OMAP4-specific defines */
 -#define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3  2)
 -#define OMAP4_UHH_SYSCONFIG_NOIDLE (1  2)
 -#define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR(3  4)
 -#define OMAP4_UHH_SYSCONFIG_NOSTDBY(1  4)
 +#define OMAP4_UHH_SYSCONFIG_MIDLEMASK  (3  2)
 +#define OMAP4_UHH_SYSCONFIG_MIDLESHIFT (2)
 +#define OMAP4_UHH_SYSCONFIG_SIDLEMASK  (3  4)
 +#define OMAP4_UHH_SYSCONFIG_SIDLESHIFT (4)
  #define OMAP4_UHH_SYSCONFIG_SOFTRESET  (1  0)

  #define OMAP4_P1_MODE_CLEAR(3  16)
 @@ -81,6 +85,12 @@

  #defineOMAP_UHH_DEBUG_CSR  (0x44)

 +/* MIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_MIDLE_NOSTANDBY (1)
 +
 +/* SIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_SIDLE_NOIDLE(1)
 +
  /* Values of UHH_REVISION - Note: these are not given in the TRM */
  #define OMAP_USBHS_REV10x0010  /* OMAP3 */
  #define OMAP_USBHS_REV20x50700100  /* OMAP4 */
 @@ -474,6 +484,97 @@ static unsigned omap_usbhs_rev2_hostconfig(struct 
 usbhs_hcd_omap *omap,
 return reg;
  }


 I'm digging in the code but as I understand this should be done by
 omap_hwmod and
 i660 avoid reset of the ehci module. This is done by ocp_softreset?


 It won't be done by omap_hwmod as we set HWMOD_INIT_NO_RESET flag in the 
 hwmod data [1].

 Question is do we do it in the driver of leave it to hwmod?

 The other concern about i660 is in this comment [1]


I don't find any description of this errata for omap4. Is this errata valid?

My change was to remove the NO_INIT and add 2uS as you have done

 /*
  * During system oot; If the hwmod framework resets the module
  * the module will have smart idle settings; which can lead to 
 deadlock
  * (above Errata Id:i660); so, dont reset the module during boot;
  * Use HWMOD_INIT_NO_RESET.
  */

 But if you look at the errata document [2], Advisory 1.108, it doesn't say 
 that we can't be in smart-idle, but
 only that we should put the module in force-idle, before cutting the module's 
 functional clock. It also states
 that the only way to recover from a lockup condition is to soft reset the 
 module. So I'm not sure if the above comment
 in the code is really valid. What if the lockup happens in the bootloader? In 
 that case we will have to reset the module in
 the kernel.

Michael


 Doing the reset in probe does solve a problem for now i.e. eliminates 
 dependency on bootloader.

 [1] - 
 

Re: [PATCH] usb: cdc-wdm: manage_power should always set needs_remote_wakeup

2013-12-02 Thread Oliver Neukum
On Fri, 2013-11-29 at 20:17 +0100, Bjørn Mork wrote:
 Cc: sta...@vger.kernel.org
 Reported-by: Oliver Neukum oneu...@suse.de
 Signed-off-by: Bjørn Mork bj...@mork.no
Acked-by: Oliver Neukum oneu...@suse.de

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


Re: [RFC PATH 1/3] phy: add USB ULPI abstraction layer

2013-12-02 Thread Kishon Vijay Abraham I
Hi,

On Thursday 28 November 2013 09:29 PM, Heikki Krogerus wrote:
 ULPI PHY is an USB2 PHY that is accessed from the USB
 controller. ULPI PHYs allow discovery based on vendor and
 product ids which allows binding the PHY to a driver.
 
 For USB controllers that are enumerated from buses such as
 PCI, that do not provide any information about the PHY, ULPI
 abstraction layer allows runtime detection. This makes it
 possible to take advantage of vendor specific functions of
 the PHYs with product specific drivers without the need for
 platform or device specific quirks.
 
 Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 ---
  drivers/phy/Kconfig   |   2 +
  drivers/phy/Makefile  |   1 +
  drivers/phy/ulpi/Kconfig  |  11 ++
  drivers/phy/ulpi/Makefile |   1 +
  drivers/phy/ulpi/ulpi.c   | 273 
 ++
  include/linux/phy/ulpi.h  | 105 ++
  6 files changed, 393 insertions(+)
  create mode 100644 drivers/phy/ulpi/Kconfig
  create mode 100644 drivers/phy/ulpi/Makefile
  create mode 100644 drivers/phy/ulpi/ulpi.c
  create mode 100644 include/linux/phy/ulpi.h
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index a344f3d..6c03824 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -51,4 +51,6 @@ config PHY_EXYNOS_DP_VIDEO
   help
 Support for Display Port PHY found on Samsung EXYNOS SoCs.
  
 +source drivers/phy/ulpi/Kconfig
 +
  endmenu
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index d0caae9..d6af605 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o
  obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)  += phy-exynos-mipi-video.o
  obj-$(CONFIG_OMAP_USB2)  += phy-omap-usb2.o
  obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o
 +obj-$(CONFIG_ULPI_PHY)   += ulpi/
 diff --git a/drivers/phy/ulpi/Kconfig b/drivers/phy/ulpi/Kconfig
 new file mode 100644
 index 000..3211aaa
 --- /dev/null
 +++ b/drivers/phy/ulpi/Kconfig
 @@ -0,0 +1,11 @@
 +
 +config ULPI_PHY
 + tristate USB ULPI PHY interface support
 + depends on USB || USB_GADGET
 + select GENERIC_PHY
 + help
 +   Say yes if you have ULPI PHY attached to your USB controller. If no
 +   vendor modules are selected, the driver will act as NOP PHY driver.
 +
 +   If unsure, say Y.
 +
 diff --git a/drivers/phy/ulpi/Makefile b/drivers/phy/ulpi/Makefile
 new file mode 100644
 index 000..7ed0895
 --- /dev/null
 +++ b/drivers/phy/ulpi/Makefile
 @@ -0,0 +1 @@
 +obj-$(CONFIG_ULPI_PHY)   += ulpi.o
 diff --git a/drivers/phy/ulpi/ulpi.c b/drivers/phy/ulpi/ulpi.c
 new file mode 100644
 index 000..7aa2f5d
 --- /dev/null
 +++ b/drivers/phy/ulpi/ulpi.c
 @@ -0,0 +1,273 @@
 +/**
 + * ulpi.c - USB ULPI PHY abstraction module
 + *
 + * Copyright (C) 2013 Intel Corporation
 + *
 + * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
 + *
 + * This program is free software; you can redistribute  it and/or modify it
 + * under  the terms of  the GNU General  Public License as published by the
 + * Free Software Foundation;  either version 2 of the  License, or (at your
 + * option) any later version.
 + */
 +
 +#include linux/phy/ulpi.h
 +#include linux/phy/phy.h
 +#include linux/module.h
 +#include linux/slab.h
 +
 +/* 
 -- */
 +
 +static struct phy_consumer phy_consumer[] = {
 + { .port = ULPI_PORT_NAME, },

We had to introduce the entire phy_consumer stuff to support legacy pdata. Not
sure if it is a good idea to use it here.
 +};
 +
 +static struct phy_init_data phy_data = {
 + .num_consumers = 1,
 + .consumers = phy_consumer,
 +};
 +
 +static int ulpi_power_on(struct phy *phy)
 +{
 + struct ulpi_dev *ulpi = phy_get_drvdata(phy);
 + struct ulpi_driver *drv = to_ulpi_driver(ulpi-dev.driver);
 +
 + if (drv  drv-phy_ops  drv-phy_ops-power_on)
 + return drv-phy_ops-power_on(phy);
 +
 + return 0;
 +}
 +
 +static int ulpi_power_off(struct phy *phy)
 +{
 + struct ulpi_dev *ulpi = phy_get_drvdata(phy);
 + struct ulpi_driver *drv = to_ulpi_driver(ulpi-dev.driver);
 +
 + if (drv  drv-phy_ops  drv-phy_ops-power_off)
 + return drv-phy_ops-power_off(phy);
 +
 + return 0;
 +}
 +
 +static struct phy_ops phy_ops = {
 + .owner = THIS_MODULE,
 + .power_on = ulpi_power_on,
 + .power_off = ulpi_power_off,
 +};
 +
 +/* 
 -- */
 +
 +static int ulpi_match(struct device *dev, struct device_driver *driver)
 +{
 + struct ulpi_driver *drv = to_ulpi_driver(driver);
 + struct ulpi_dev *ulpi = to_ulpi_dev(dev);
 + const struct ulpi_device_id *id;
 +
 + for (id = drv-id_table; id-vendor; id++)
 + if (id-vendor == ulpi-id.vendor 
 + id-product 

Re: [RFC PATH 2/3] usb: dwc3: add ULPI interface support

2013-12-02 Thread Kishon Vijay Abraham I
Hi,

On Thursday 28 November 2013 09:29 PM, Heikki Krogerus wrote:
 Registers ULPI interface with the ULPI abstraction layer if
 the HSPHY type is ULPI, which will create phy instance for
 usb2.
 
 Depends on Kishon's patch set adding support for generic PHY
 framework.
 
 Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 ---
  drivers/usb/dwc3/Kconfig  |   7 +++
  drivers/usb/dwc3/Makefile |   4 ++
  drivers/usb/dwc3/core.c   |   8 
  drivers/usb/dwc3/core.h   |  21 +
  drivers/usb/dwc3/ulpi.c   | 110 
 ++
  5 files changed, 150 insertions(+)
  create mode 100644 drivers/usb/dwc3/ulpi.c
 
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index 64eed6f..a97b294 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -13,6 +13,13 @@ config USB_DWC3
  
  if USB_DWC3
  
 +config USB_DWC3_ULPI
 + bool Provide ULPI PHY Interface
 + depends on ULPI_PHY=y || ULPI_PHY=USB_DWC3
 + help
 +   Select this if you have ULPI type PHY attached to your DWC3
 +   controller.
 +
  choice
   bool DWC3 Mode Selection
   default USB_DWC3_DUAL_ROLE if (USB  USB_GADGET)
 diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
 index dd17601..8bb82bc 100644
 --- a/drivers/usb/dwc3/Makefile
 +++ b/drivers/usb/dwc3/Makefile
 @@ -13,6 +13,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) 
 $(CONFIG_USB_DWC3_DUAL_ROLE)),)
   dwc3-y  += gadget.o ep0.o
  endif
  
 +ifneq ($(CONFIG_USB_DWC3_ULPI),)
 + dwc3-y  += ulpi.o
 +endif
 +
  ifneq ($(CONFIG_DEBUG_FS),)
   dwc3-y  += debugfs.o
  endif
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 1c0a69a..94927b2 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -505,6 +505,12 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-regs_size  = resource_size(res);
   dwc-dev= dev;
  
 + if (!dwc-usb2_generic_phy) {
 + ret = dwc3_ulpi_init(dwc);

shouldn't this be called from dwc3-pci (or any other dwc3 glue)?
 + if (ret)
 + return ret;
 + }
 +
   dev-dma_mask   = dev-parent-dma_mask;
   dev-dma_parms  = dev-parent-dma_parms;
   dma_set_coherent_mask(dev, dev-parent-coherent_dma_mask);
 @@ -613,6 +619,7 @@ err1:
  
  err0:
   dwc3_free_event_buffers(dwc);
 + dwc3_ulpi_exit(dwc);
  
   return ret;
  }
 @@ -653,6 +660,7 @@ static int dwc3_remove(struct platform_device *pdev)
   dwc3_event_buffers_cleanup(dwc);
   dwc3_free_event_buffers(dwc);
   dwc3_core_exit(dwc);
 + dwc3_ulpi_exit(dwc);
  
   return 0;
  }
 diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
 index 01ec7d7..6df398a 100644
 --- a/drivers/usb/dwc3/core.h
 +++ b/drivers/usb/dwc3/core.h
 @@ -169,6 +169,14 @@
  #define DWC3_GUSB2PHYCFG_PHYSOFTRST  (1  31)
  #define DWC3_GUSB2PHYCFG_SUSPHY  (1  6)
  
 +/* Global USB2 PHY Vendor Control Register */
 +#define DWC3_GUSB2PHYACC_NEWREGREQ   (1  25)
 +#define DWC3_GUSB2PHYACC_BUSY(1  23)
 +#define DWC3_GUSB2PHYACC_WRITE   (1  22)
 +#define DWC3_GUSB2PHYACC_ADDR(n) (n  16)
 +#define DWC3_GUSB2PHYACC_EXTEND_ADDR(n)  (n  8)
 +#define DWC3_GUSB2PHYACC_DATA(n) (n  0xff)
 +
  /* Global USB3 PIPE Control Register */
  #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1  31)
  #define DWC3_GUSB3PIPECTL_SUSPHY (1  17)
 @@ -557,6 +565,7 @@ struct dwc3_hwparams {
  #define DWC3_NUM_INT(n)  (((n)  (0x3f  15))  15)
  
  /* HWPARAMS3 */
 +#define DWC3_ULPI_HSPHY  (1  3)
  #define DWC3_NUM_IN_EPS_MASK (0x1f  18)
  #define DWC3_NUM_EPS_MASK(0x3f  12)
  #define DWC3_NUM_EPS(p)  (((p)-hwparams3   \
 @@ -672,6 +681,8 @@ struct dwc3 {
   struct phy  *usb2_generic_phy;
   struct phy  *usb3_generic_phy;
  
 + struct ulpi_interface   *ulpi;
 +
   void __iomem*regs;
   size_t  regs_size;
  
 @@ -922,4 +933,14 @@ static inline int dwc3_gadget_resume(struct dwc3 *dwc)
  }
  #endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */
  
 +#if IS_ENABLED(CONFIG_USB_DWC3_ULPI)
 +int dwc3_ulpi_init(struct dwc3 *dwc);
 +void dwc3_ulpi_exit(struct dwc3 *dwc);
 +#else
 +static inline int dwc3_ulpi_init(struct dwc3 *dwc)
 +{ return 0; }
 +static inline void dwc3_ulpi_exit(struct dwc3 *dwc)
 +{ }
 +#endif
 +
  #endif /* __DRIVERS_USB_DWC3_CORE_H */
 diff --git a/drivers/usb/dwc3/ulpi.c b/drivers/usb/dwc3/ulpi.c
 new file mode 100644
 index 000..e1f152b
 --- /dev/null
 +++ b/drivers/usb/dwc3/ulpi.c
 @@ -0,0 +1,110 @@
 +/**
 + * ulpi.c - DesignWare USB3 ULPI PHY interface
 + *
 + * Copyright (C) 2013 Intel Corporation
 + *
 + * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
 + *
 + * This program is free software; you can redistribute  it and/or modify it
 + * under 

Re: [RFC PATH 0/3] USB PHYs and PCI

2013-12-02 Thread Kishon Vijay Abraham I
Hi,

On Thursday 28 November 2013 09:29 PM, Heikki Krogerus wrote:
 Hi guys,
 
 PCI does not give any information about the PHY but we still need to
 be able to take advantage of any possible vendor specific features,
 such as custom PM operations, charger detection, ADP probing and
 sensing, etc. the PHY provides. Since ULPI provides a way to do
 runtime detection, I'm introducing this layer on top of Kishon's
 generic phy framework. It gives us means to detect the ULPI product
 and bind it to a driver without need for nasty platform/device
 specific quirks in case of ULPI PHYs.

nice :-) Clearly there's a shortcoming in the current PHY framework to discover
PHY's behind a pci. Thanks for attempting to solve it.

But I think it needs a few modification like the ULPI device should be created
by the glue (dwc3-pci?) and phy create should be done in phy driver. We should
think of a better way for the controller to find the PHY (lets try and not use
PHY CONSUMER or device name).

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


Re: [PATCH 1/2] chipidea: ci_hdrc_imx: Allow handling the clock for an USB phy/hub

2013-12-02 Thread Mark Rutland
On Thu, Nov 14, 2013 at 02:09:46AM +, Fabio Estevam wrote:
 From: Fabio Estevam fabio.este...@freescale.com
 
 When using external USB PHY or USB hub, it is common that they require a clock
 input.
 
 Add a 'clk_phy' clock, so that it can be retrieved from the device tree and 
 enabled in the driver, so that the clock can properly drive the external 
 USB phy/hub.

As this clock feeds the PHY, it should be described on the PHY node.
It's a property of the PHY itself.

 
 Tested on a imx6q-udoo board, that connects via USBH1 to a USB2514 hub.
 
 In this board the USB2514 is clocked from a 24MHz clock that comes from the 
 imx6q CLKO2 pin.
 
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com
 ---
  .../devicetree/bindings/usb/ci13xxx-imx.txt  |  2 ++
  drivers/usb/chipidea/ci_hdrc_imx.c   | 20 
 +++-
  2 files changed, 21 insertions(+), 1 deletion(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
 b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
 index b4b5b79..07ba38c 100644
 --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
 +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
 @@ -18,6 +18,8 @@ Optional properties:
  - vbus-supply: regulator for vbus
  - disable-over-current: disable over current detect
  - external-vbus-divider: enables off-chip resistor divider for Vbus
 +- clocks: phandle to the clock that drives the USB hub

If you're using clock-names, define clocks in terms of it:

- clocks: a list of phandle + clock-specifier pairs corresponding to
  entries in clock-names.

 +- clock-names: must be phy

s/must be/should contain/

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


Re: [PATCH 2/2] ARM: dts: imx6q-udoo: Add USB host support

2013-12-02 Thread Mark Rutland
On Thu, Nov 14, 2013 at 02:09:47AM +, Fabio Estevam wrote:
 From: Fabio Estevam fabio.este...@freescale.com
 
 Udoo board has USBH1 port connected to a USB2514 hub.
 
 Add support for it.
 
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com
 ---
  arch/arm/boot/dts/imx6q-udoo.dts | 34 ++
  1 file changed, 34 insertions(+)
 
 diff --git a/arch/arm/boot/dts/imx6q-udoo.dts 
 b/arch/arm/boot/dts/imx6q-udoo.dts
 index 1c7f7a1..109b997 100644
 --- a/arch/arm/boot/dts/imx6q-udoo.dts
 +++ b/arch/arm/boot/dts/imx6q-udoo.dts
 @@ -19,6 +19,23 @@
   memory {
   reg = 0x1000 0x4000;
   };
 +
 + regulators {
 + compatible = simple-bus;
 + #address-cells = 1;
 + #size-cells = 0;
 +

This should have a ranges property, or it's not a simple-bus.

Why do you even need this anyway? The regulators can live under the root
quite happily.

Thanks,
Mark.
--
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 v6 00/16] ARM: at91: move to common clk framework

2013-12-02 Thread boris brezillon

Hi Mike,

Le 01/12/2013 00:05, Mike Turquette a écrit :

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Hello,

This patch series is the 5th version of the at91 clk implementations
using the Common Clk Framework.

Oops, I just replied to v5 of this series. Thanks for the fixes. Which
tree do you want this to go through?


I'm not sure: the ARM: at91: move to common clk framework series
depends on this one.

Nicolas, what do you think ?
Do you want to take it into your tree ?


Regards,
Mike


Most of the clock provided by the PMC (Power Management Controller) are
implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor
clk), and some drivers only implement a subset of the hardware capabilities
(master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully
add missing features in a near future.

This implementation is only compatible with device tree definition.
The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might
change in the future.


Best Regards,
Boris

Changes since v5:
  - remove peripheral divisors macros from dt binding include file
  - remove file path from comment blocks
  - replace pll and utmi disable function by unprepare function to
avoid issue when disabling and reenabling a clk
  - fix programmable clk interrupt retrieval
  - fix OF_CLK_DECLARE names (xxx_clk_main - xxx_clk_pmc)
  - add missing comma in at91rm9200 main clk dt declaration
  - fix num_parents check in smd clk driver

Changes since v4:
  - rework dt bindings:
* replace atmel,clk-id property by the standard reg property
* reference system, peripheral and programmable clks using the direct
  clk node instead of the parent node plus a clk id
  - provide a new helper function (of_at91_get_clk_range) to retrieve a clk
range from the device tree

Changes since v3:
  - simplify master clk implementation (drop set_rate/parent support)
  - fix bug in set_rate function of pll driver
  - fix coding style issues
  - define macros and constants where needed
  - remove peripheral id macro references
  - remove sam9g35 specific handling (sam9g35 = sam9x5)
  - rework main clk prepare function to handle automatic rate calculation

Changes since v2:
  - fix several bugs in clk implementations
  - drop non-dt boards support
  - split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework (coming soon)
  - modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
  - add clk macros for dt-bindings
  - add pmc framework (helper function to access pmc registers)
  - add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
  - fix bugs in pll, programmable and system clock implementations
(wrong bit position).
  - add usb clock configuration support (ohci and udc drivers +
clk_lookup for non dt boards)
  - rework of the system clock interfaces (no need to define a parent clock,
system clock is a gate with no rate info)
  - change system, peripheral and programmable clk dt bindings (1 master node
and multiple child nodes each defining a system/peripheral or prog clock)
  - fix bugs in sama5 dt definition

Boris BREZILLON (16):
   ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
   ARM: at91: add Kconfig options for common clk support
   clk: at91: add PMC base support
   clk: at91: add PMC macro file for dt definitions
   clk: at91: add PMC main clock
   clk: at91: add PMC pll clocks
   clk: at91: add PMC master clock
   clk: at91: add PMC system clocks
   clk: at91: add PMC peripheral clocks
   clk: at91: add PMC programmable clocks
   clk: at91: add PMC utmi clock
   clk: at91: add PMC usb clock
   clk: at91: add PMC smd clock
   dt: binding: add at91 clks dt bindings documentation
   ARM: at91: move pit timer to common clk framework
   ARM: at91: add new compatible strings for pmc driver

  .../devicetree/bindings/clock/at91-clock.txt   |  339 +
  arch/arm/mach-at91/Kconfig |   44 ++
  arch/arm/mach-at91/Kconfig.non_dt  |6 +
  arch/arm/mach-at91/Makefile|2 +-
  arch/arm/mach-at91/at91rm9200.c|2 +-
  arch/arm/mach-at91/at91sam9260.c   |2 +-
  arch/arm/mach-at91/at91sam9261.c   |2 +-
  arch/arm/mach-at91/at91sam9263.c   |2 +-
  arch/arm/mach-at91/at91sam926x_time.c  |   14 +-
  arch/arm/mach-at91/at91sam9g45.c   |2 +-
  arch/arm/mach-at91/at91sam9n12.c   |2 +-
  arch/arm/mach-at91/at91sam9rl.c|2 +-
  

Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Sebastian Andrzej Siewior
- sta...@vger.kernel.org since they probably don't care about this
  unless the patch is merged.

On 12/02/2013 10:41 AM, Roger Quadros wrote:
 Michael,
 
 On 11/29/2013 05:32 PM, Michael Trimarchi wrote:
 Hi Roger

 On Fri, Nov 29, 2013 at 2:01 PM, Roger Quadros rog...@ti.com wrote:
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.


 Do you think that we need something similar of usb musb?
 I have seen the OTG_SYSCONFIG is touched in uboot and
 only readed in omap2430.c.
 
 I'm not sure about musb. Maybe Sebastian/Felipe have better idea.
 In general I believe that all modules must be reset by the kernel.
 

based on the code at the bottom it touches the first few register(s)
sysconfig. Isn't hwmod actually doing this idle stuff and resting the
device during boot?

 cheers,
 -roger


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


Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Roger Quadros
Michael,

On 12/02/2013 11:51 AM, Michael Trimarchi wrote:
 Hi Roger
 
 On Mon, Dec 2, 2013 at 10:39 AM, Roger Quadros rog...@ti.com wrote:
 +Benoit, Tony, Paul.

 Hi Michael,

 On 11/30/2013 06:48 AM, Michael Trimarchi wrote:
 Hi Roger

 On Fri, Nov 29, 2013 at 2:01 PM, Roger Quadros rog...@ti.com wrote:
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.

 Reported-by: Tomi Valkeinen tomi.valkei...@ti.com
 Cc: sta...@vger.kernel.org # 3.10+
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  drivers/mfd/omap-usb-host.c | 115 
 +---
  1 file changed, 109 insertions(+), 6 deletions(-)

 diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
 index 142650f..d4bd464 100644
 --- a/drivers/mfd/omap-usb-host.c
 +++ b/drivers/mfd/omap-usb-host.c
 @@ -43,14 +43,18 @@
  /* UHH Register Set */
  #defineOMAP_UHH_REVISION   (0x00)
  #defineOMAP_UHH_SYSCONFIG  (0x10)
 -#defineOMAP_UHH_SYSCONFIG_MIDLEMODE(1  12)
 +#defineOMAP_UHH_SYSCONFIG_MIDLEMASK(3  12)
 +#define OMAP_UHH_SYSCONFIG_MIDLESHIFT  (12)
  #defineOMAP_UHH_SYSCONFIG_CACTIVITY(1  8)
 -#defineOMAP_UHH_SYSCONFIG_SIDLEMODE(1  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLEMASK(3  3)
 +#defineOMAP_UHH_SYSCONFIG_SIDLESHIFT   (3)
  #defineOMAP_UHH_SYSCONFIG_ENAWAKEUP(1  2)
  #defineOMAP_UHH_SYSCONFIG_SOFTRESET(1  1)
  #defineOMAP_UHH_SYSCONFIG_AUTOIDLE (1  0)

  #defineOMAP_UHH_SYSSTATUS  (0x14)
 +#define OMAP_UHH_SYSSTATUS_RESETDONE   (1  0)
 +
  #defineOMAP_UHH_HOSTCONFIG (0x40)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_BYPASS (1  0)
  #defineOMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS  (1  0)
 @@ -66,10 +70,10 @@
  #define OMAP4_UHH_HOSTCONFIG_APP_START_CLK (1  31)

  /* OMAP4-specific defines */
 -#define OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR (3  2)
 -#define OMAP4_UHH_SYSCONFIG_NOIDLE (1  2)
 -#define OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR(3  4)
 -#define OMAP4_UHH_SYSCONFIG_NOSTDBY(1  4)
 +#define OMAP4_UHH_SYSCONFIG_MIDLEMASK  (3  2)
 +#define OMAP4_UHH_SYSCONFIG_MIDLESHIFT (2)
 +#define OMAP4_UHH_SYSCONFIG_SIDLEMASK  (3  4)
 +#define OMAP4_UHH_SYSCONFIG_SIDLESHIFT (4)
  #define OMAP4_UHH_SYSCONFIG_SOFTRESET  (1  0)

  #define OMAP4_P1_MODE_CLEAR(3  16)
 @@ -81,6 +85,12 @@

  #defineOMAP_UHH_DEBUG_CSR  (0x44)

 +/* MIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_MIDLE_NOSTANDBY (1)
 +
 +/* SIDLE modes */
 +#define OMAP_UHH_SYSCONFIG_SIDLE_NOIDLE(1)
 +
  /* Values of UHH_REVISION - Note: these are not given in the TRM */
  #define OMAP_USBHS_REV10x0010  /* OMAP3 */
  #define OMAP_USBHS_REV20x50700100  /* OMAP4 */
 @@ -474,6 +484,97 @@ static unsigned omap_usbhs_rev2_hostconfig(struct 
 usbhs_hcd_omap *omap,
 return reg;
  }


 I'm digging in the code but as I understand this should be done by
 omap_hwmod and
 i660 avoid reset of the ehci module. This is done by ocp_softreset?


 It won't be done by omap_hwmod as we set HWMOD_INIT_NO_RESET flag in the 
 hwmod data [1].

 Question is do we do it in the driver of leave it to hwmod?

 The other concern about i660 is in this comment [1]

 
 I don't find any description of this errata for omap4. Is this errata valid?

I can't say for sure. You might have to try it out without those flags and see 
if it works
reliably.

 
 My change was to remove the NO_INIT and add 2uS as you have done

The 2uS delay that I added was my mistake and I don't think it is required.
Just removing HWMOD_INIT_NO_RESET should work.

cheers,
-roger

 
 /*
  * During system oot; If the hwmod framework resets the module
  * the module will have smart idle settings; which can lead to 
 deadlock
  * (above Errata Id:i660); so, dont reset the module during boot;
  * Use HWMOD_INIT_NO_RESET.
  */

 But if you look at the errata document [2], Advisory 1.108, it doesn't say 
 that we can't be in smart-idle, but
 only that we should put the module in force-idle, before cutting the 
 module's functional clock. It also states
 that the only way to recover from a lockup condition is to soft reset the 
 module. So I'm not sure if the 

Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Roger Quadros
On 12/02/2013 02:01 PM, Sebastian Andrzej Siewior wrote:
 - sta...@vger.kernel.org since they probably don't care about this
   unless the patch is merged.
 
 On 12/02/2013 10:41 AM, Roger Quadros wrote:
 Michael,

 On 11/29/2013 05:32 PM, Michael Trimarchi wrote:
 Hi Roger

 On Fri, Nov 29, 2013 at 2:01 PM, Roger Quadros rog...@ti.com wrote:
 With u-boot 2013.10, USB devices are sometimes not detected
 on OMAP4 Panda. To make us independent of what bootloader does
 with the USB Host module, we must RESET it to get it to a known
 good state. This patch Soft RESETs the USB Host module.


 Do you think that we need something similar of usb musb?
 I have seen the OTG_SYSCONFIG is touched in uboot and
 only readed in omap2430.c.

 I'm not sure about musb. Maybe Sebastian/Felipe have better idea.
 In general I believe that all modules must be reset by the kernel.

 
 based on the code at the bottom it touches the first few register(s)
 sysconfig. Isn't hwmod actually doing this idle stuff and resting the
 device during boot?
 

You are right. The musb hwmod data doesn't have the HWMOD_INIT_NO_RESET
flag, so hwmod should reset it during boot.

Maybe I too should just remove HWMOD_INIT_NO_RESET flag from the USB Host
hwmod data, then we don't need to change this driver at all.

Benoit, Tony any comments?

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


[PATCH 2/2] Indent with tab instead of spaces.

2013-12-02 Thread David Cluytens
From: David Cluytens david.cluytens_...@softathome.com

---
 drivers/usb/class/cdc-acm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8ad4e94..e840431 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,8 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)
 
 static const struct usb_device_id acm_ids[] = {
/* quirky and broken devices */
-{ USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
-.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
+   { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
+   .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
{ USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
-- 
1.8.4.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 1/2] Added support for the Lenovo RD02-D400 USB Modem

2013-12-02 Thread David Cluytens
From: David Cluytens david.cluytens_...@softathome.com

---
 drivers/usb/class/cdc-acm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3e7560f..8ad4e94 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,6 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)
 
 static const struct usb_device_id acm_ids[] = {
/* quirky and broken devices */
+{ USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
+.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
{ USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
-- 
1.8.4.4

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


Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Sebastian Andrzej Siewior
On 12/02/2013 01:12 PM, Roger Quadros wrote:
 You are right. The musb hwmod data doesn't have the HWMOD_INIT_NO_RESET
 flag, so hwmod should reset it during boot.
 
 Maybe I too should just remove HWMOD_INIT_NO_RESET flag from the USB Host
 hwmod data, then we don't need to change this driver at all.
 
 Benoit, Tony any comments?

Almost two years ago in commit de231388 (ARM: OMAP: USB: EHCI and OHCI
hwmod structures for OMAP3) the don't reset flag has been added by
Keshava.

It refers to Errata Id:i660 why it is required. Once you figured what
why it has been added you could have an idea if it is okay to remove it
and if the reset you do here might lead to it (I dunno).

 
 cheers,
 -roger

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


Re: [PATCH v6 00/16] ARM: at91: move to common clk framework

2013-12-02 Thread Nicolas Ferre

On 01/12/2013 00:05, Mike Turquette :

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Hello,

This patch series is the 5th version of the at91 clk implementations
using the Common Clk Framework.


Oops, I just replied to v5 of this series. Thanks for the fixes. Which
tree do you want this to go through?


Mike, Boris,

I will take the series in the at91 git tree that will go through arm-soc.

This way, I can synchronize with the other series cooked by Boris which 
actually implements the CCF for sama5d3 SoCs.


Mike, I keep you in the CC list of my upcoming pull-request to Olof, 
Kevin and Arnd.


Thanks, bye,



Most of the clock provided by the PMC (Power Management Controller) are
implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor
clk), and some drivers only implement a subset of the hardware capabilities
(master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully
add missing features in a near future.

This implementation is only compatible with device tree definition.
The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might
change in the future.


Best Regards,
Boris

Changes since v5:
  - remove peripheral divisors macros from dt binding include file
  - remove file path from comment blocks
  - replace pll and utmi disable function by unprepare function to
avoid issue when disabling and reenabling a clk
  - fix programmable clk interrupt retrieval
  - fix OF_CLK_DECLARE names (xxx_clk_main - xxx_clk_pmc)
  - add missing comma in at91rm9200 main clk dt declaration
  - fix num_parents check in smd clk driver

Changes since v4:
  - rework dt bindings:
* replace atmel,clk-id property by the standard reg property
* reference system, peripheral and programmable clks using the direct
  clk node instead of the parent node plus a clk id
  - provide a new helper function (of_at91_get_clk_range) to retrieve a clk
range from the device tree

Changes since v3:
  - simplify master clk implementation (drop set_rate/parent support)
  - fix bug in set_rate function of pll driver
  - fix coding style issues
  - define macros and constants where needed
  - remove peripheral id macro references
  - remove sam9g35 specific handling (sam9g35 = sam9x5)
  - rework main clk prepare function to handle automatic rate calculation

Changes since v2:
  - fix several bugs in clk implementations
  - drop non-dt boards support
  - split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework (coming soon)
  - modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
  - add clk macros for dt-bindings
  - add pmc framework (helper function to access pmc registers)
  - add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
  - fix bugs in pll, programmable and system clock implementations
(wrong bit position).
  - add usb clock configuration support (ohci and udc drivers +
clk_lookup for non dt boards)
  - rework of the system clock interfaces (no need to define a parent clock,
system clock is a gate with no rate info)
  - change system, peripheral and programmable clk dt bindings (1 master node
and multiple child nodes each defining a system/peripheral or prog clock)
  - fix bugs in sama5 dt definition

Boris BREZILLON (16):
   ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
   ARM: at91: add Kconfig options for common clk support
   clk: at91: add PMC base support
   clk: at91: add PMC macro file for dt definitions
   clk: at91: add PMC main clock
   clk: at91: add PMC pll clocks
   clk: at91: add PMC master clock
   clk: at91: add PMC system clocks
   clk: at91: add PMC peripheral clocks
   clk: at91: add PMC programmable clocks
   clk: at91: add PMC utmi clock
   clk: at91: add PMC usb clock
   clk: at91: add PMC smd clock
   dt: binding: add at91 clks dt bindings documentation
   ARM: at91: move pit timer to common clk framework
   ARM: at91: add new compatible strings for pmc driver

  .../devicetree/bindings/clock/at91-clock.txt   |  339 +
  arch/arm/mach-at91/Kconfig |   44 ++
  arch/arm/mach-at91/Kconfig.non_dt  |6 +
  arch/arm/mach-at91/Makefile|2 +-
  arch/arm/mach-at91/at91rm9200.c|2 +-
  arch/arm/mach-at91/at91sam9260.c   |2 +-
  arch/arm/mach-at91/at91sam9261.c   |2 +-
  arch/arm/mach-at91/at91sam9263.c   |2 +-
  arch/arm/mach-at91/at91sam926x_time.c  |   14 +-
  arch/arm/mach-at91/at91sam9g45.c   |2 +-
  

Re: [PATCH v3 13/16] usb/gadget: FunctionFS: convert to new function interface with backward compatibility

2013-12-02 Thread Michal Nazarewicz
On Fri, Nov 22 2013, Andrzej Pietrasiewicz wrote:
 This is required in order to integrate configfs support.
 f_fs needs to be a separately compiled module and so it needs to use the new
 interface.

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com


 @@ -496,6 +297,7 @@ static ssize_t ffs_ep0_write(struct file *file, const 
 char __user *buf,
   mutex_unlock(ffs-mutex);
  
   ret = ffs_ready(ffs);
 +
   if (unlikely(ret  0)) {
   ffs-state = FFS_CLOSING;
   return ret;

There are couple of hunks like this one which just make the patch longer
then it should be.  Just an observation.

 @@ -2226,8 +2031,59 @@ static int __ffs_func_bind_do_nums(enum 
 ffs_entity_type type, u8 *valuep,
   return 0;
  }
  
 -static int ffs_func_bind(struct usb_configuration *c,
 -  struct usb_function *f)
 +#ifndef USB_FFS_INCLUDED
 +static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function 
 *f,
 + struct usb_configuration *c)
 +{
 + struct ffs_function *func = ffs_func_from_usb(f);
 + struct f_fs_opts *ffs_opts =
 + container_of(f-fi, struct f_fs_opts, func_inst);
 + int ret;
 +
 + ENTER();
 +
 + /*
 +  * Legacy gadget triggers binding in functionfs_ready_callback,
 +  * which already uses locking; taking the same lock here would
 +  * cause a deadlock.
 +  *
 +  * Configfs-enabled gadgets however do need ffs_dev_lock.
 +  */
 + if (!ffs_opts-no_configfs)
 + ffs_dev_lock();

Could this condition be hidden inside ffs_dev_lock?  On the other hand,
since this is a transitional state, maybe it's not worth it to make it
perfect.

 + ret = ffs_opts-dev-desc_ready ? 0 : -ENODEV;
 + func-ffs = ffs_opts-dev-ffs_data;
 + if (!ffs_opts-no_configfs)
 + ffs_dev_unlock();
 + if (ret)
 + return ERR_PTR(ret);

 @@ -2482,11 +2355,17 @@ void ffs_dev_lock(void)
  {
   mutex_lock(ffs_lock);
  }
 +#ifndef USB_FFS_INCLUDED
 +EXPORT_SYMBOL(ffs_dev_lock);
 +#endif
  
  void ffs_dev_unlock(void)
  {
   mutex_unlock(ffs_lock);
  }
 +#ifndef USB_FFS_INCLUDED
 +EXPORT_SYMBOL(ffs_dev_unlock);
 +#endif

Right…  Like I wrote before, I think ffs_lock should be exported and
those functions should be static inline in header file.


-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


[PATCH] Staging: usbip: vhci_hcd.c: removed a space

2013-12-02 Thread Aldo Iljazi
Line 921: Removed the space before the semicolon.

Signed-off-by: Aldo Iljazi m...@aldo.io
---
 drivers/staging/usbip/vhci_hcd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index e810ad5..fa3e0b2 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -918,7 +918,7 @@ static void vhci_stop(struct usb_hcd *hcd)
sysfs_remove_group(vhci_dev(vhci)-kobj, dev_attr_group);
 
/* 2. shutdown all the ports of vhci_hcd */
-   for (rhport = 0 ; rhport  VHCI_NPORTS; rhport++) {
+   for (rhport = 0; rhport  VHCI_NPORTS; rhport++) {
struct vhci_device *vdev = vhci-vdev[rhport];
 
usbip_event_add(vdev-ud, VDEV_EVENT_REMOVED);
-- 
1.7.9.5

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


Re: [RFC PATH 1/3] phy: add USB ULPI abstraction layer

2013-12-02 Thread Heikki Krogerus
Hi,

On Mon, Dec 02, 2013 at 04:20:51PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Thursday 28 November 2013 09:29 PM, Heikki Krogerus wrote:
  ULPI PHY is an USB2 PHY that is accessed from the USB
  controller. ULPI PHYs allow discovery based on vendor and
  product ids which allows binding the PHY to a driver.
  
  For USB controllers that are enumerated from buses such as
  PCI, that do not provide any information about the PHY, ULPI
  abstraction layer allows runtime detection. This makes it
  possible to take advantage of vendor specific functions of
  the PHYs with product specific drivers without the need for
  platform or device specific quirks.
  
  Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
  ---
   drivers/phy/Kconfig   |   2 +
   drivers/phy/Makefile  |   1 +
   drivers/phy/ulpi/Kconfig  |  11 ++
   drivers/phy/ulpi/Makefile |   1 +
   drivers/phy/ulpi/ulpi.c   | 273 
  ++
   include/linux/phy/ulpi.h  | 105 ++
   6 files changed, 393 insertions(+)
   create mode 100644 drivers/phy/ulpi/Kconfig
   create mode 100644 drivers/phy/ulpi/Makefile
   create mode 100644 drivers/phy/ulpi/ulpi.c
   create mode 100644 include/linux/phy/ulpi.h
  
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
  index a344f3d..6c03824 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -51,4 +51,6 @@ config PHY_EXYNOS_DP_VIDEO
  help
Support for Display Port PHY found on Samsung EXYNOS SoCs.
   
  +source drivers/phy/ulpi/Kconfig
  +
   endmenu
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
  index d0caae9..d6af605 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)   += phy-exynos-dp-video.o
   obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
   obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
   obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
  +obj-$(CONFIG_ULPI_PHY) += ulpi/
  diff --git a/drivers/phy/ulpi/Kconfig b/drivers/phy/ulpi/Kconfig
  new file mode 100644
  index 000..3211aaa
  --- /dev/null
  +++ b/drivers/phy/ulpi/Kconfig
  @@ -0,0 +1,11 @@
  +
  +config ULPI_PHY
  +   tristate USB ULPI PHY interface support
  +   depends on USB || USB_GADGET
  +   select GENERIC_PHY
  +   help
  + Say yes if you have ULPI PHY attached to your USB controller. If no
  + vendor modules are selected, the driver will act as NOP PHY driver.
  +
  + If unsure, say Y.
  +
  diff --git a/drivers/phy/ulpi/Makefile b/drivers/phy/ulpi/Makefile
  new file mode 100644
  index 000..7ed0895
  --- /dev/null
  +++ b/drivers/phy/ulpi/Makefile
  @@ -0,0 +1 @@
  +obj-$(CONFIG_ULPI_PHY) += ulpi.o
  diff --git a/drivers/phy/ulpi/ulpi.c b/drivers/phy/ulpi/ulpi.c
  new file mode 100644
  index 000..7aa2f5d
  --- /dev/null
  +++ b/drivers/phy/ulpi/ulpi.c
  @@ -0,0 +1,273 @@
  +/**
  + * ulpi.c - USB ULPI PHY abstraction module
  + *
  + * Copyright (C) 2013 Intel Corporation
  + *
  + * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
  + *
  + * This program is free software; you can redistribute  it and/or modify it
  + * under  the terms of  the GNU General  Public License as published by the
  + * Free Software Foundation;  either version 2 of the  License, or (at your
  + * option) any later version.
  + */
  +
  +#include linux/phy/ulpi.h
  +#include linux/phy/phy.h
  +#include linux/module.h
  +#include linux/slab.h
  +
  +/* 
  -- 
  */
  +
  +static struct phy_consumer phy_consumer[] = {
  +   { .port = ULPI_PORT_NAME, },
 
 We had to introduce the entire phy_consumer stuff to support legacy pdata. Not
 sure if it is a good idea to use it here.

Well, maybe we can improve it at least a bit. I don't see how it's
possible to get rid of the device name matching, but at least the port
name dependency could be replaced with possibility to use index
instead. Check how they made the gpiod lookup to work in gpiolib.

Let's get back to this one.

  +};
  +
  +static struct phy_init_data phy_data = {
  +   .num_consumers = 1,
  +   .consumers = phy_consumer,
  +};
  +
  +static int ulpi_power_on(struct phy *phy)
  +{
  +   struct ulpi_dev *ulpi = phy_get_drvdata(phy);
  +   struct ulpi_driver *drv = to_ulpi_driver(ulpi-dev.driver);
  +
  +   if (drv  drv-phy_ops  drv-phy_ops-power_on)
  +   return drv-phy_ops-power_on(phy);
  +
  +   return 0;
  +}
  +
  +static int ulpi_power_off(struct phy *phy)
  +{
  +   struct ulpi_dev *ulpi = phy_get_drvdata(phy);
  +   struct ulpi_driver *drv = to_ulpi_driver(ulpi-dev.driver);
  +
  +   if (drv  drv-phy_ops  drv-phy_ops-power_off)
  +   return drv-phy_ops-power_off(phy);
  +
  +   return 0;
  +}
  +
  +static struct phy_ops phy_ops = {
  +   .owner = THIS_MODULE,
  +   .power_on = ulpi_power_on,
  +   .power_off = 

Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Roger Quadros
On 12/02/2013 03:04 PM, Sebastian Andrzej Siewior wrote:
 On 12/02/2013 01:12 PM, Roger Quadros wrote:
 You are right. The musb hwmod data doesn't have the HWMOD_INIT_NO_RESET
 flag, so hwmod should reset it during boot.

 Maybe I too should just remove HWMOD_INIT_NO_RESET flag from the USB Host
 hwmod data, then we don't need to change this driver at all.

 Benoit, Tony any comments?
 
 Almost two years ago in commit de231388 (ARM: OMAP: USB: EHCI and OHCI
 hwmod structures for OMAP3) the don't reset flag has been added by
 Keshava.
 
 It refers to Errata Id:i660 why it is required. Once you figured what
 why it has been added you could have an idea if it is okay to remove it
 and if the reset you do here might lead to it (I dunno).
 

Keshava no longer works @TI. I have no other means to check why it was added
other than doing dome tests and making sure nothing breaks if we remove it.

So far, things are going fine for about 50 or so boots divided between OMAP3 
and 4
platforms. If more people can test and give feedback it'd be great.

For the present situation, omap4 panda USB host doesn't work without the reset
with u-boot v2013.10.

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


Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Sebastian Andrzej Siewior
On 12/02/2013 02:35 PM, Roger Quadros wrote:
 It refers to Errata Id:i660 why it is required. Once you figured what
 why it has been added you could have an idea if it is okay to remove it
 and if the reset you do here might lead to it (I dunno).

 
 Keshava no longer works @TI. I have no other means to check why it was added
 other than doing dome tests and making sure nothing breaks if we remove it.
 
 So far, things are going fine for about 50 or so boots divided between OMAP3 
 and 4
 platforms. If more people can test and give feedback it'd be great.

Hmm. Can't you lookup the errata he revers to?

 cheers,
 -roger
 

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


Re: [RFC PATH 2/3] usb: dwc3: add ULPI interface support

2013-12-02 Thread Heikki Krogerus
Hi,

On Mon, Dec 02, 2013 at 04:24:31PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Thursday 28 November 2013 09:29 PM, Heikki Krogerus wrote:

snip

  diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
  index dd17601..8bb82bc 100644
  --- a/drivers/usb/dwc3/Makefile
  +++ b/drivers/usb/dwc3/Makefile
  @@ -13,6 +13,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) 
  $(CONFIG_USB_DWC3_DUAL_ROLE)),)
  dwc3-y  += gadget.o ep0.o
   endif
   
  +ifneq ($(CONFIG_USB_DWC3_ULPI),)
  +   dwc3-y  += ulpi.o
  +endif
  +
   ifneq ($(CONFIG_DEBUG_FS),)
  dwc3-y  += debugfs.o
   endif
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 1c0a69a..94927b2 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -505,6 +505,12 @@ static int dwc3_probe(struct platform_device *pdev)
  dwc-regs_size  = resource_size(res);
  dwc-dev= dev;
   
  +   if (!dwc-usb2_generic_phy) {
  +   ret = dwc3_ulpi_init(dwc);
 
 shouldn't this be called from dwc3-pci (or any other dwc3 glue)?

It's not going to be possible to put it to the dwc3-pci, but my
motivation for that is actually up and coming ACPI support. I do not
want to create glue driver for it just because this. With ACPI DSDT
there is no guarantee to get device entries for PHYs I'm afraid. You
will have them on some platforms, but on others you don't :(.

The issue with PCI is the device name, which is used when matching the
phy. We don't know it before the device is registered. We can't live
with the assumption there is only one instance in case of PCI. The
damn thing can be hotpluged from some weird dock, like exchangeable
back cover or something similar. So you will be able to register the
phy only after the core.c has probed, and requested the phys, which is
too late.

And besides. The glue drivers should only have platform specific code.
This is definitely platform agnostic feature of the controller.

  +   if (ret)
  +   return ret;
  +   }
  +
  dev-dma_mask   = dev-parent-dma_mask;
  dev-dma_parms  = dev-parent-dma_parms;
  dma_set_coherent_mask(dev, dev-parent-coherent_dma_mask);

snip

  +{
  +   int ret;
  +
  +   /* First check if there is ULPI PHY */
  +   ret = dwc3_readl(dwc-regs, DWC3_GHWPARAMS3);
  +   if (!(ret  DWC3_ULPI_HSPHY))
  +   return 0;
  +
  +   /* Register the interface */
  +   dwc-ulpi = ulpi_new_interface(dwc-dev,
  +  dwc3_ulpi_read, dwc3_ulpi_write, dwc);
  +   if (IS_ERR(dwc-ulpi)) {
  +   dev_err(dwc-dev, failed to register ULPI interface);
  +   return PTR_ERR(dwc-ulpi);
  +   }
  +
  +   /* Get the ULPI phy instance
  +* REVISIT: There should be no need to get it separately here.
  +*/
  +   dwc-usb2_generic_phy = devm_phy_get(dwc-dev, ULPI_PORT_NAME);
 
 You shouldn't be needing this. It should get the phy from dwc3 core probe 
 itself.

You don't need this here. I made it like this now just because we
don't yet have your final version of the patches where you introduce
the generic phy support in dwc3.

I want to change the core.c so it set's the dwc-dev and maps the
iomem before requesting the phys. And of course put dwc3_ulpi_init in
between.

Thanks,

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


Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Sebastian Andrzej Siewior
On 12/02/2013 02:44 PM, Roger Quadros wrote:
 Errata id: i660
 DESCRIPTION
 In the following configuration :
 • USBHOST module is set to smart-idle mode
 • PRCM asserts idle_req to the USBHOST module. (This typically happens when 
 the system is going to
 a low power mode : all ports have been suspended, the master part of the 
 USBHOST module has
 entered the standby state, and SW has cut the functional clocks.)
 • an USBHOST interrupt occurs before the module is able to answer idle_ack, 
 typically a remote wakeup
 IRQ.
 Then the USB HOST module will enter a deadlock situation where it is no more 
 accessible nor functional.
 The only way to recover will be to perform a software reset of the module.
 
 WORKAROUND
 The best workaround consists in switching the module to force idle mode right 
 before cutting the
 module's FCLK.
 • the bus has reached the suspend state.
 • write SYSCONFIG:Idlemode= ForceIdle and read it back to ensure the write 
 has been taken into
 account in case of posted writes.
 • cut the FCLK
 • Idle_req will be asserted and idle_ack answered within one L3 clock cycle.
 Upon resume or remote wakeup, switch back the module to smart-idle.
 This workaround reduces the failure window to only one L3 clock cycle. The 
 probability for an interrupt to
 fire at this exact time is considered extremely low, and the case has never 
 been hit on board.
 
 Based on this, I don't see anything wrong in Resetting the module at probe or 
 at boot.

If u-boot configured USB into something not smart-idle and the reset
would bring it back then the reset should remain.
If you could tell hwmod not use smart-idle nor smart-standby and you
make sure that the suspend code manually puts the device into suspend
via forceidle then I think could get rid of the do-not-reset-thingy.

 
 cheers,
 -roger
 

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


Re: [PATCH 1/3] HID: usbhid: merge the sis quirk

2013-12-02 Thread Jiri Kosina
On Wed, 27 Nov 2013, AceLan Kao wrote:

 USB_VENDOR_ID_SIS and USB_VENDOR_ID_SIS2_TOUCH are identical,
 so refine the code and merge the quirks.

Good spotting.

I have applied all 3 patches. Thanks,

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


Buggy kernel device driver? for Super Top M6116 SATA Bridge (14cd:6116)

2013-12-02 Thread Jaime T
Hi folks.

When I run hdparm -N /dev/sdb on my cheapo usb-connect sata bridge
(Super Top M6116 SATA Bridge , device id 14cd:6116), it returns:

/dev/sdb:
 max sectors   = 1953525168/1(1953525168?), HPA setting seems invalid
(buggy kernel device driver?)

FWIW, I'm running Debian Testing - I originally saw with error with
the supplied kernel (3.11.8) but I've compiled and installed a vanilla
3.13.0-rc2 (from kernel.org) and the message is the same. Also, the
drive in the enclosure seems to be working perfectly, and it's a
Toshiba MQ01ABD100.

lsusb -vd 14cd:6116 returns:

Bus 004 Device 004: ID 14cd:6116 Super Top M6116 SATA Bridge
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize064
  idVendor   0x14cd Super Top
  idProduct  0x6116 M6116 SATA Bridge
  bcdDevice2.20

I've seen other mails which talk about these Super Top controllers
being quite fundamentally broken. Is there any benefit in trying to
debug/understand this error further/fix the driver, or should I just
pitch it in to the nearest trash-can and replace it with something
less borked?

If this isn't the correct mailing list for this enquiry, please let me
know. With kind regards, Jaime
--
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 v6 00/16] ARM: at91: move to common clk framework

2013-12-02 Thread boris brezillon

On 02/12/2013 12:43, boris brezillon wrote:

Hi Mike,

Le 01/12/2013 00:05, Mike Turquette a écrit :

Quoting Boris BREZILLON (2013-11-28 04:36:24)

Hello,

This patch series is the 5th version of the at91 clk implementations
using the Common Clk Framework.

Oops, I just replied to v5 of this series. Thanks for the fixes. Which
tree do you want this to go through?


I'm not sure: the ARM: at91: move to common clk framework series

Oops. I meant ARM: at91: use new at91 clks for samad3 SoCs.


depends on this one.

Nicolas, what do you think ?
Do you want to take it into your tree ?


Regards,
Mike


Most of the clock provided by the PMC (Power Management Controller) are
implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor
clk), and some drivers only implement a subset of the hardware 
capabilities

(master clk rate change is missing).
But this series implements all the already available clks, and I 
will hopefully

add missing features in a near future.

This implementation is only compatible with device tree definition.
The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable 
and might

change in the future.


Best Regards,
Boris

Changes since v5:
  - remove peripheral divisors macros from dt binding include file
  - remove file path from comment blocks
  - replace pll and utmi disable function by unprepare function to
avoid issue when disabling and reenabling a clk
  - fix programmable clk interrupt retrieval
  - fix OF_CLK_DECLARE names (xxx_clk_main - xxx_clk_pmc)
  - add missing comma in at91rm9200 main clk dt declaration
  - fix num_parents check in smd clk driver

Changes since v4:
  - rework dt bindings:
* replace atmel,clk-id property by the standard reg property
* reference system, peripheral and programmable clks using the 
direct

  clk node instead of the parent node plus a clk id
  - provide a new helper function (of_at91_get_clk_range) to 
retrieve a clk

range from the device tree

Changes since v3:
  - simplify master clk implementation (drop set_rate/parent support)
  - fix bug in set_rate function of pll driver
  - fix coding style issues
  - define macros and constants where needed
  - remove peripheral id macro references
  - remove sam9g35 specific handling (sam9g35 = sam9x5)
  - rework main clk prepare function to handle automatic rate 
calculation


Changes since v2:
  - fix several bugs in clk implementations
  - drop non-dt boards support
  - split the series to ease review and tests:
* 1 patch series for new clk implementations (this series)
* 1 patch series to move each at91 SoC to common clk framework 
(coming soon)
  - modify dt-bindings (add atmel,clk- prefix to atmel specific 
properties)

  - add clk macros for dt-bindings
  - add pmc framework (helper function to access pmc registers)
  - add interrupt support to enable passive wait in clk_prepare 
functions


Changes since v1:
  - fix bugs in pll, programmable and system clock implementations
(wrong bit position).
  - add usb clock configuration support (ohci and udc drivers +
clk_lookup for non dt boards)
  - rework of the system clock interfaces (no need to define a 
parent clock,

system clock is a gate with no rate info)
  - change system, peripheral and programmable clk dt bindings (1 
master node
and multiple child nodes each defining a system/peripheral or 
prog clock)

  - fix bugs in sama5 dt definition

Boris BREZILLON (16):
   ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
   ARM: at91: add Kconfig options for common clk support
   clk: at91: add PMC base support
   clk: at91: add PMC macro file for dt definitions
   clk: at91: add PMC main clock
   clk: at91: add PMC pll clocks
   clk: at91: add PMC master clock
   clk: at91: add PMC system clocks
   clk: at91: add PMC peripheral clocks
   clk: at91: add PMC programmable clocks
   clk: at91: add PMC utmi clock
   clk: at91: add PMC usb clock
   clk: at91: add PMC smd clock
   dt: binding: add at91 clks dt bindings documentation
   ARM: at91: move pit timer to common clk framework
   ARM: at91: add new compatible strings for pmc driver

  .../devicetree/bindings/clock/at91-clock.txt   |  339 
+

  arch/arm/mach-at91/Kconfig |   44 ++
  arch/arm/mach-at91/Kconfig.non_dt  |6 +
  arch/arm/mach-at91/Makefile|2 +-
  arch/arm/mach-at91/at91rm9200.c|2 +-
  arch/arm/mach-at91/at91sam9260.c   |2 +-
  arch/arm/mach-at91/at91sam9261.c   |2 +-
  arch/arm/mach-at91/at91sam9263.c   |2 +-
  arch/arm/mach-at91/at91sam926x_time.c  |   14 +-
  arch/arm/mach-at91/at91sam9g45.c   |2 +-
  

Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread Paul Walmsley
On Mon, 2 Dec 2013, Roger Quadros wrote:

 It won't be done by omap_hwmod as we set HWMOD_INIT_NO_RESET flag in the 
 hwmod data [1].
 
 Question is do we do it in the driver of leave it to hwmod?

It should be done by hwmod (or more broadly, some OMAP bus code).  That 
way the device can be brought to a known state even if there's no driver 
present (e.g., if the driver was built as a module).

 The other concern about i660 is in this comment [1]
 
   /*
* During system boot; If the hwmod framework resets the module
* the module will have smart idle settings; which can lead to deadlock
* (above Errata Id:i660); so, dont reset the module during boot;
* Use HWMOD_INIT_NO_RESET.
*/
 
 But if you look at the errata document [2], Advisory 1.108, it doesn't 
 say that we can't be in smart-idle, but only that we should put the 
 module in force-idle, before cutting the module's functional clock.

Yes, that looks to be correct.  There shouldn't be any problem with the 
module being in smart-idle mode if the PRCM doesn't try to put it into a 
low-power mode.  It already has the HWMOD_SWSUP_SIDLE flag set, so seems 
to me it should work fine without HWMOD_INIT_NO_RESET, if i660 is the only 
issue.

Most of the IP blocks that are marked with HWMOD_INIT_NO_RESET are only 
that way due to laziness, or lack of time, etc., and should be closely 
reviewed.


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


Re: [RFC PATH 0/3] USB PHYs and PCI

2013-12-02 Thread Heikki Krogerus
Hi,

On Mon, Dec 02, 2013 at 04:33:26PM +0530, Kishon Vijay Abraham I wrote:
 Hi,
 
 On Thursday 28 November 2013 09:29 PM, Heikki Krogerus wrote:
  Hi guys,
  
  PCI does not give any information about the PHY but we still need to
  be able to take advantage of any possible vendor specific features,
  such as custom PM operations, charger detection, ADP probing and
  sensing, etc. the PHY provides. Since ULPI provides a way to do
  runtime detection, I'm introducing this layer on top of Kishon's
  generic phy framework. It gives us means to detect the ULPI product
  and bind it to a driver without need for nasty platform/device
  specific quirks in case of ULPI PHYs.
 
 nice :-) Clearly there's a shortcoming in the current PHY framework to 
 discover
 PHY's behind a pci. Thanks for attempting to solve it.
 
 But I think it needs a few modification like the ULPI device should be created
 by the glue (dwc3-pci?) and phy create should be done in phy driver. We should
 think of a better way for the controller to find the PHY (lets try and not use
 PHY CONSUMER or device name).

Man I don't see any way to avoid the device name matching. We should
drop the init_data thing so the phy drivers don't need to know about
their users even when using platform data. You should have separate
phy_lookup_add() function for that which, the platform code can call.

I would also add support for matching based on index on top of the
port name. I think it's fare to assume index 0 is always usb2 type. We
could then have phy_get_index() and wrapper like gpiod_get() (phy_get)
that tries to get the phy with index 0, that the usb2 controllers can
use.

Those two changes would make it look exactly like clk framework and
gpiolib are now. The small benefit with those changes is that the phy
drivers and the users, both don't need to know about each other in any
case (DT, platform).

So the device name matching would still be there. Though I'm not sure
if it's such a huge problem to have it. At least the drivers don't
need to care about it.

If you like this idea, I can prepare the patches.

Br,

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


RE: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-02 Thread David Laight
 From: Roger Quadros [mailto:rog...@ti.com]
 On 11/29/2013 03:17 PM, David Laight wrote:
...
  +  timeout = jiffies + msecs_to_jiffies(100);
  +  while (!(usbhs_read(omap-uhh_base, OMAP_UHH_SYSSTATUS)
  +   OMAP_UHH_SYSSTATUS_RESETDONE)) {
  +  cpu_relax();
 
 You mean use msleep(1) here instead of cpu_relax()?
 Shouldn't be a problem IMO, but can you please tell me why that is better
 as the reset seems to complete usually in the first iteration.

If it doesn't finish in the first iteration you don't want to
spin the cpu for 100ms.

If it hasn't finished in the first millisecond, you probably expect
it to actually time out - so you might as well look (say) every 10ms.

David



--
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/16] usb/gadget: FunctionFS: Remove VLAIS usage from gadget code

2013-12-02 Thread Andrzej Pietrasiewicz
The use of variable length arrays in structs (VLAIS) in the Linux Kernel code
precludes the use of compilers which don't implement VLAIS (for instance the
Clang compiler). This alternate patch calculates offsets into the kmalloc-ed
memory buffer using macros. The previous patch required multiple kmalloc and
kfree calls. This version uses group vs struct since it really is not a
struct and is essentially a group of VLA in a common allocated block. This
version also fixes the issues pointed out by Andrzej Pietrasiewicz and
Michal Nazarewicz.

Signed-off-by: Mark Charlebois charl...@gmail.com
Signed-off-by: Behan Webster beh...@converseincode.com

[elimination of miexed declaration and code, checkpatch cleanup]
[fixes after Michal's review]
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c |  116 +---
 1 files changed, 76 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 241fc87..60cc1a5 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -30,6 +30,31 @@
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
+/* Variable Length Array Macros **/
+#define vla_group(groupname) size_t groupname##__next = 0
+#define vla_group_size(groupname) groupname##__next
+
+#define vla_item(groupname, type, name, n) \
+   size_t groupname##_##name##__offset = ({   \
+   size_t align_mask = __alignof__(type) - 1; \
+   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
+   size_t size = (n) * sizeof(type);  \
+   groupname##__next = offset + size; \
+   offset;\
+   })
+
+#define vla_item_with_sz(groupname, type, name, n) \
+   size_t groupname##_##name##__sz = (n) * sizeof(type);  \
+   size_t groupname##_##name##__offset = ({   \
+   size_t align_mask = __alignof__(type) - 1; \
+   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
+   size_t size = groupname##_##name##__sz;\
+   groupname##__next = offset + size; \
+   offset;\
+   })
+
+#define vla_ptr(ptr, groupname, name) \
+   ((void *) ((char *)ptr + groupname##_##name##__offset))
 
 /* Debugging /
 
@@ -1901,30 +1926,34 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
 
/* Allocate everything in one chunk so there's less maintenance. */
{
-   struct {
-   struct usb_gadget_strings *stringtabs[lang_count + 1];
-   struct usb_gadget_strings stringtab[lang_count];
-   struct usb_string strings[lang_count*(needed_count+1)];
-   } *d;
unsigned i = 0;
+   vla_group(d);
+   vla_item(d, struct usb_gadget_strings *, stringtabs,
+   lang_count + 1);
+   vla_item(d, struct usb_gadget_strings, stringtab, lang_count);
+   vla_item(d, struct usb_string, strings,
+   lang_count*(needed_count+1));
 
-   d = kmalloc(sizeof *d, GFP_KERNEL);
-   if (unlikely(!d)) {
+   char *vlabuf = kmalloc(vla_group_size(d), GFP_KERNEL);
+
+   if (unlikely(!vlabuf)) {
kfree(_data);
return -ENOMEM;
}
 
-   stringtabs = d-stringtabs;
-   t = d-stringtab;
+   /* Initialize the VLA pointers */
+   stringtabs = vla_ptr(vlabuf, d, stringtabs);
+   t = vla_ptr(vlabuf, d, stringtab);
i = lang_count;
do {
*stringtabs++ = t++;
} while (--i);
*stringtabs = NULL;
 
-   stringtabs = d-stringtabs;
-   t = d-stringtab;
-   s = d-strings;
+   /* stringtabs = vlabuf = d_stringtabs for later kfree */
+   stringtabs = vla_ptr(vlabuf, d, stringtabs);
+   t = vla_ptr(vlabuf, d, stringtab);
+   s = vla_ptr(vlabuf, d, strings);
strings = s;
}
 
@@ -2200,16 +2229,16 @@ static int ffs_func_bind(struct usb_configuration *c,
int ret;
 
/* Make it a single chunk, less management later on */
-   struct {
-   struct ffs_ep eps[ffs-eps_count];
- 

[PATCH v4 00/16] Equivalent of g_ffs with configfs

2013-12-02 Thread Andrzej Pietrasiewicz
This series aims at integrating configfs into FunctionFS, the way
it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex, phonet
and mass_storage. It contains everything that is required to provide the
equivalent of g_ffs.ko with configfs.

Configfs support in FunctionFS has been awaited by the Android folks as
discussed during the LPC 2013.

Apart from that a VLAIS (variable length array in a struct) patch is added.
It is not strictly necessary, but it won't hurt and it will make the Clang
people happy.

FunctionFS is more complicated than most other USB functions, so the resulting
patch series is a bit long. Howerver, it is supposed to do things in steps.

1) preliminary work: extend generic configfs support in USB gadget, convert
g_ffs to new function interfaces of f_ecm, f_subset, f_rndis; g_ffs is the
last user of the old interfaces so remove compatibility layers
2) factoring out a u_fs.h header and finally making f_fs a separate module
with both old and new function interface
3) converting all users of f_fs (in fact only g_ffs) to the new interface
and remove compatiblilty layer
4) add configfs support

v3..v4:

- small fixes after Michal's review, thank you, Michal!
- export ffs_lock instead of ffs_dev_lock and ffs_dev_unlock, which are now
static inline
- improved ffs_find_dev, ffs_alloc_dev by introducing ffs_get_single_dev()
- rearranged kfree invocations in ffs_free_dev
- eliminated goto in ffs_acquire_dev
- used explicit decrementation in gfs_init
- removed some add/remove empty line hunks

v2..v3:

- a number of fixes regarding systems with multiple udcs, e.g. systems,
where more than one gadget can be loaded at a time
- cleanup of ffs devices handling: since they need to be registered by
both g_ffs and configfs-based gadget, they need to be managed in one
place; instead of static callbacks in f_fs.c now each device can have its
own set of callbacks
- callbacks are used by the g_ffs, while configfs-based gadget is happy
with generic ffs_acquire/release_dev(), ffs_ready/closed()
- functionfs_init() and functionfs_cleanup() now called when the first
device is created and when the last is removed, respectively
- removed gfs_lock from g_ffs in favor of a lock in f_fs.c protecting
the devices list
- thanks to all the above the ffs_alloc_inst() is greatly simplified
compared to v2
- simplified the way how usb_f_fs user's (g_ffs's) refcount is maintained
(no ffs_owner static in f_fs.c)
- some of patches 12..16 used to contain Michal's Acked-by, but since there
have been (relatively) many changes to those patches,
I removed the Acked-by lines


v1..v2:

- fixes after Michal's review, thank you, Michal!
- removal of unnecessary hunks, simplified VLAIS replacement code,
used proper pointer dereferencing, simplified ffs_do_functionfs_bind(),
ffs_alloc_inst() and ffs_free(), style corrections, allocated
usb_function structures in one chunk for all configs in g_ffs

Rebased onto Felipe's master.


BACKWARD COMPATIBILITY
==

Please note that the old g_ffs.ko is still available and works.


USING THE NEW GADGET
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ffs.instance name

e.g. mkdir functions/ffs.ptp

In functions/function.instance name there will be no attribute files
at all, because all parameters are passed with FunctionFS.

An example gadget with adb and ptp functions:

(I assume there are ptpd and adbd daemons using FunctionFS available,
a proof-of-concept adbd can be found here:
https://android-review.googlesource.com/#/c/31640/,
an early version of ptp which I used is here:
http://www.spinics.net/lists/linux-usb/msg41963.html)

$ modprobe libcomposite

$ mount none cfg -t configfs

$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
 
$ mkdir configs/c.1
$ mkdir functions/ffs.adb
$ mkdir functions/ffs.ptp

$ mkdir strings/0x409
$ mkdir configs/c.1/strings/0x409

$ echo 0x2d01  idProduct
$ echo 0x04e8  idVendor

$ echo my-serial-num  strings/0x409/serialnumber
$ echo my-manufacturer  strings/0x409/manufacturer
$ echo FunctionFS gadget (ptp, adb)  strings/0x409/product

$ echo Conf 1  configs/c.1/strings/0x409/configuration
$ echo 120  configs/c.1/MaxPower
$ ln -s functions/ffs.ptp configs/c.1
$ ln -s functions/ffs.adb configs/c.1

$ mkdir /dev/usbffs
$ mount ptp /dev/usbffs -t functionfs
$ ptpd

$ mkdir -p /dev/usbgadget/adb
$ mount -t functionfs adb /dev/usbgadget/adb -o uid=2000,gid=2000
$ adbd

$ echo s3c-hsotg  cfg/usb_gadget/g1/UDC


After unbinding the gadget with echo   UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed 

[PATCH v4 11/16] usb/gadget: FunctionFS: create utility file

2013-12-02 Thread Andrzej Pietrasiewicz
A header file to be used by f_fs.c and g_ffs.c will be required when
f_fs.c is converted into a module.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c  |1 +
 drivers/usb/gadget/g_ffs.c |   19 ++-
 drivers/usb/gadget/u_fs.h  |   28 
 3 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 drivers/usb/gadget/u_fs.h

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 60cc1a5..9c946cd 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -27,6 +27,7 @@
 #include linux/usb/composite.h
 #include linux/usb/functionfs.h
 
+#include u_fs.h
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 7099a11..1aaa103 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -69,13 +69,6 @@ MODULE_LICENSE(GPL);
 
 #define GFS_MAX_DEVS   10
 
-struct gfs_ffs_obj {
-   const char *name;
-   bool mounted;
-   bool desc_ready;
-   struct ffs_data *ffs_data;
-};
-
 USB_GADGET_COMPOSITE_OPTIONS();
 
 static struct usb_device_descriptor gfs_dev_desc = {
@@ -181,7 +174,7 @@ static DEFINE_MUTEX(gfs_lock);
 static unsigned int missing_funcs;
 static bool gfs_registered;
 static bool gfs_single_func;
-static struct gfs_ffs_obj *ffs_tab;
+static struct ffs_dev *ffs_tab;
 
 static int __init gfs_init(void)
 {
@@ -224,7 +217,7 @@ static void __exit gfs_exit(void)
 }
 module_exit(gfs_exit);
 
-static struct gfs_ffs_obj *gfs_find_dev(const char *dev_name)
+static struct ffs_dev *gfs_find_dev(const char *dev_name)
 {
int i;
 
@@ -242,7 +235,7 @@ static struct gfs_ffs_obj *gfs_find_dev(const char 
*dev_name)
 
 static int functionfs_ready_callback(struct ffs_data *ffs)
 {
-   struct gfs_ffs_obj *ffs_obj;
+   struct ffs_dev *ffs_obj;
int ret;
 
ENTER();
@@ -283,7 +276,7 @@ done:
 
 static void functionfs_closed_callback(struct ffs_data *ffs)
 {
-   struct gfs_ffs_obj *ffs_obj;
+   struct ffs_dev *ffs_obj;
 
ENTER();
mutex_lock(gfs_lock);
@@ -305,7 +298,7 @@ done:
 
 static void *functionfs_acquire_dev_callback(const char *dev_name)
 {
-   struct gfs_ffs_obj *ffs_dev;
+   struct ffs_dev *ffs_dev;
 
ENTER();
mutex_lock(gfs_lock);
@@ -329,7 +322,7 @@ done:
 
 static void functionfs_release_dev_callback(struct ffs_data *ffs_data)
 {
-   struct gfs_ffs_obj *ffs_dev;
+   struct ffs_dev *ffs_dev;
 
ENTER();
mutex_lock(gfs_lock);
diff --git a/drivers/usb/gadget/u_fs.h b/drivers/usb/gadget/u_fs.h
new file mode 100644
index 000..5d9229a
--- /dev/null
+++ b/drivers/usb/gadget/u_fs.h
@@ -0,0 +1,28 @@
+/*
+ * u_fs.h
+ *
+ * Utility definitions for the FunctionFS
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Author: Andrzej Pietrasiewicz andrze...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef U_FFS_H
+#define U_FFS_H
+
+#include linux/usb/composite.h
+
+struct ffs_dev {
+   const char *name;
+   bool mounted;
+   bool desc_ready;
+   struct ffs_data *ffs_data;
+};
+
+#endif /* U_FFS_H */
-- 
1.7.0.4

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


[PATCH v4 16/16] usb/gadget: FunctionFS: add configfs support

2013-12-02 Thread Andrzej Pietrasiewicz
Add support for using FunctionFS in configfs-based USB gadgets.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/ABI/testing/configfs-usb-gadget-ffs |9 +++
 drivers/usb/gadget/Kconfig|   12 +++
 drivers/usb/gadget/f_fs.c |   77 +
 drivers/usb/gadget/u_fs.h |5 ++
 4 files changed, 103 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-ffs

diff --git a/Documentation/ABI/testing/configfs-usb-gadget-ffs 
b/Documentation/ABI/testing/configfs-usb-gadget-ffs
new file mode 100644
index 000..14343e2
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-ffs
@@ -0,0 +1,9 @@
+What:  /config/usb-gadget/gadget/functions/ffs.name
+Date:  Nov 2013
+KenelVersion:  3.13
+Description:   The purpose of this directory is to create and remove it.
+
+   A corresponding USB function instance is created/removed.
+   There are no attributes here.
+
+   All parameters are set through FunctionFS.
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 2479644..8da2b1d 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -689,6 +689,18 @@ config USB_CONFIGFS_MASS_STORAGE
  device (in much the same way as the loop device driver),
  specified as a module parameter or sysfs option.
 
+config USB_CONFIGFS_F_FS
+   boolean Function filesystem (FunctionFS)
+   depends on USB_CONFIGFS
+   select USB_F_FS
+   help
+ The Function Filesystem (FunctionFS) lets one create USB
+ composite functions in user space in the same way GadgetFS
+ lets one create USB gadgets in user space.  This allows creation
+ of composite gadgets such that some of the functions are
+ implemented in kernel space (for instance Ethernet, serial or
+ mass storage) and other are implemented in user space.
+
 config USB_ZERO
tristate Gadget Zero (DEVELOPMENT)
select USB_LIBCOMPOSITE
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index e9eaa91..8a81e98 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -29,6 +29,7 @@
 #include linux/usb/functionfs.h
 
 #include u_fs.h
+#include configfs.h
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
@@ -2294,6 +2295,31 @@ static struct ffs_dev *ffs_find_dev(const char *name)
return _ffs_find_dev(name);
 }
 
+/* Configfs support */
+
+static inline struct f_fs_opts *to_ffs_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_fs_opts,
+   func_inst.group);
+}
+
+static void ffs_attr_release(struct config_item *item)
+{
+   struct f_fs_opts *opts = to_ffs_opts(item);
+
+   usb_put_function_instance(opts-func_inst);
+}
+
+static struct configfs_item_operations ffs_item_ops = {
+   .release= ffs_attr_release,
+};
+
+static struct config_item_type ffs_func_type = {
+   .ct_item_ops= ffs_item_ops,
+   .ct_owner   = THIS_MODULE,
+};
+
+
 /* Function registration interface **/
 
 static void ffs_free_inst(struct usb_function_instance *f)
@@ -2307,6 +2333,44 @@ static void ffs_free_inst(struct usb_function_instance 
*f)
kfree(opts);
 }
 
+#define MAX_INST_NAME_LEN  40
+
+static int ffs_set_inst_name(struct usb_function_instance *fi, const char 
*name)
+{
+   struct f_fs_opts *opts;
+   char *ptr;
+   const char *tmp;
+   int name_len, ret;
+
+   name_len = strlen(name) + 1;
+   if (name_len  MAX_INST_NAME_LEN)
+   return -ENAMETOOLONG;
+
+   ptr = kstrndup(name, name_len, GFP_KERNEL);
+   if (!ptr)
+   return -ENOMEM;
+
+   opts = to_f_fs_opts(fi);
+   tmp = NULL;
+
+   ffs_dev_lock();
+
+   tmp = opts-dev-name_allocated ? opts-dev-name : NULL;
+   ret = ffs_name_dev(opts-dev, ptr);
+   if (ret) {
+   kfree(ptr);
+   ffs_dev_unlock();
+   return ret;
+   }
+   opts-dev-name_allocated = true;
+   
+   ffs_dev_unlock();
+
+   kfree(tmp);
+
+   return 0;
+}
+
 static struct usb_function_instance *ffs_alloc_inst(void)
 {
struct f_fs_opts *opts;
@@ -2316,6 +2380,7 @@ static struct usb_function_instance *ffs_alloc_inst(void)
if (!opts)
return ERR_PTR(-ENOMEM);
 
+   opts-func_inst.set_inst_name = ffs_set_inst_name;
opts-func_inst.free_func_inst = ffs_free_inst;
ffs_dev_lock();
dev = ffs_alloc_dev();
@@ -2325,7 +2390,10 @@ static struct usb_function_instance *ffs_alloc_inst(void)
return ERR_CAST(dev);
}

[PATCH v4 13/16] usb/gadget: FunctionFS: convert to new function interface with backward compatibility

2013-12-02 Thread Andrzej Pietrasiewicz
This is required in order to integrate configfs support.
f_fs needs to be a separately compiled module and so it needs to use the new
interface.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig |3 +
 drivers/usb/gadget/Makefile|2 +
 drivers/usb/gadget/f_fs.c  |  422 
 drivers/usb/gadget/g_ffs.c |1 +
 drivers/usb/gadget/u_fs.h  |  214 
 include/linux/usb/functionfs.h |2 +
 6 files changed, 435 insertions(+), 209 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 0d117e2..66444d0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -539,6 +539,9 @@ config USB_F_RNDIS
 config USB_F_MASS_STORAGE
tristate
 
+config USB_F_FS
+   tristate
+
 choice
tristate USB Gadget Drivers
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index fd9fe1f..6bb1155 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -61,6 +61,8 @@ usb_f_rndis-y := f_rndis.o rndis.o
 obj-$(CONFIG_USB_F_RNDIS)  += usb_f_rndis.o
 usb_f_mass_storage-y   := f_mass_storage.o storage_common.o
 obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
+usb_f_fs-y := f_fs.o
+obj-$(CONFIG_USB_F_FS) += usb_f_fs.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index a66c003..901f0ba 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -22,6 +22,7 @@
 #include linux/pagemap.h
 #include linux/export.h
 #include linux/hid.h
+#include linux/module.h
 #include asm/unaligned.h
 
 #include linux/usb/composite.h
@@ -57,210 +58,6 @@
 #define vla_ptr(ptr, groupname, name) \
((void *) ((char *)ptr + groupname##_##name##__offset))
 
-/* Debugging /
-
-#ifdef VERBOSE_DEBUG
-#ifndef pr_vdebug
-#  define pr_vdebug pr_debug
-#endif /* pr_vdebug */
-#  define ffs_dump_mem(prefix, ptr, len) \
-   print_hex_dump_bytes(pr_fmt(prefix : ), DUMP_PREFIX_NONE, ptr, len)
-#else
-#ifndef pr_vdebug
-#  define pr_vdebug(...) do { } while (0)
-#endif /* pr_vdebug */
-#  define ffs_dump_mem(prefix, ptr, len) do { } while (0)
-#endif /* VERBOSE_DEBUG */
-
-#define ENTER()pr_vdebug(%s()\n, __func__)
-
-
-/* The data structure and setup file /
-
-enum ffs_state {
-   /*
-* Waiting for descriptors and strings.
-*
-* In this state no open(2), read(2) or write(2) on epfiles
-* may succeed (which should not be the problem as there
-* should be no such files opened in the first place).
-*/
-   FFS_READ_DESCRIPTORS,
-   FFS_READ_STRINGS,
-
-   /*
-* We've got descriptors and strings.  We are or have called
-* ffs_ready().  functionfs_bind() may have
-* been called but we don't know.
-*
-* This is the only state in which operations on epfiles may
-* succeed.
-*/
-   FFS_ACTIVE,
-
-   /*
-* All endpoints have been closed.  This state is also set if
-* we encounter an unrecoverable error.  The only
-* unrecoverable error is situation when after reading strings
-* from user space we fail to initialise epfiles or
-* ffs_ready() returns with error (0).
-*
-* In this state no open(2), read(2) or write(2) (both on ep0
-* as well as epfile) may succeed (at this point epfiles are
-* unlinked and all closed so this is not a problem; ep0 is
-* also closed but ep0 file exists and so open(2) on ep0 must
-* fail).
-*/
-   FFS_CLOSING
-};
-
-
-enum ffs_setup_state {
-   /* There is no setup request pending. */
-   FFS_NO_SETUP,
-   /*
-* User has read events and there was a setup request event
-* there.  The next read/write on ep0 will handle the
-* request.
-*/
-   FFS_SETUP_PENDING,
-   /*
-* There was event pending but before user space handled it
-* some other event was introduced which canceled existing
-* setup.  If this state is set read/write on ep0 return
-* -EIDRM.  This state is only set when adding event.
-*/
-   FFS_SETUP_CANCELED
-};
-
-
-
-struct ffs_epfile;
-struct ffs_function;
-
-struct ffs_data {
-   struct usb_gadget   *gadget;
-
-   /*
-* Protect access read/write operations, only one read/write
-* at a time.  As a consequence protects ep0req and company.
-* While setup request is being processed (queued) this is
-* held.
-*/
-   struct mutexmutex;
-
-

[PATCH v4 06/16] usb/gadget: f_subset: remove compatibility layer

2013-12-02 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_subset.c |   60 +
 drivers/usb/gadget/u_ether.h  |3 --
 2 files changed, 1 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index 7c8674f..f1a5919 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -301,7 +301,6 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
-#ifndef USB_FSUBSET_INCLUDED
struct f_gether_opts*gether_opts;
 
gether_opts = container_of(f-fi, struct f_gether_opts, func_inst);
@@ -322,7 +321,7 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
return status;
gether_opts-bound = true;
}
-#endif
+
us = usb_gstrings_attach(cdev, geth_strings,
 ARRAY_SIZE(geth_string_defs));
if (IS_ERR(us))
@@ -393,61 +392,6 @@ fail:
return status;
 }
 
-#ifdef USB_FSUBSET_INCLUDED
-
-static void
-geth_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   geth_string_defs[0].id = 0;
-   usb_free_all_descriptors(f);
-   kfree(func_to_geth(f));
-}
-
-/**
- * geth_bind_config - add CDC Subset network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * @dev: eth_dev structure
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_gether *geth;
-   int status;
-
-   /* allocate and initialize one new instance */
-   geth = kzalloc(sizeof *geth, GFP_KERNEL);
-   if (!geth)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(geth-ethaddr, sizeof geth-ethaddr, %pm, ethaddr);
-   geth_string_defs[1].s = geth-ethaddr;
-
-   geth-port.ioport = dev;
-   geth-port.cdc_filter = DEFAULT_FILTER;
-
-   geth-port.func.name = cdc_subset;
-   geth-port.func.bind = geth_bind;
-   geth-port.func.unbind = geth_old_unbind;
-   geth-port.func.set_alt = geth_set_alt;
-   geth-port.func.disable = geth_disable;
-
-   status = usb_add_function(c, geth-port.func);
-   if (status)
-   kfree(geth);
-   return status;
-}
-
-#else
-
 static inline struct f_gether_opts *to_f_gether_opts(struct config_item *item)
 {
return container_of(to_config_group(item), struct f_gether_opts,
@@ -573,5 +517,3 @@ static struct usb_function *geth_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(geth, geth_alloc_inst, geth_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 64125a5..f310e6f 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -268,9 +268,6 @@ static inline bool can_support_ecm(struct usb_gadget 
*gadget)
 }
 
 /* each configuration may bind one instance of an ethernet link */
-int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
-
 #ifdef USB_ETH_RNDIS
 
 int rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-- 
1.7.0.4

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


[PATCH v4 07/16] usb/gadget: g_ffs: convert to new interface of f_rndis

2013-12-02 Thread Andrzej Pietrasiewicz
There is a new interface of f_rndis and g_ffs is the last to use the old one.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |  105 +++-
 2 files changed, 66 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 77411d7..54b9856 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -894,6 +894,7 @@ config USB_FUNCTIONFS_RNDIS
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
select USB_U_RNDIS
+   select USB_F_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 99ae8ec..7099a11 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -33,29 +33,25 @@
 #  include u_ecm.h
 #  include u_gether.h
 #  ifdef USB_ETH_RNDIS
-#define USB_FRNDIS_INCLUDED
-#include f_rndis.c
+#include u_rndis.h
 #include rndis.h
 #  endif
 #  include u_ether.h
 
 USB_ETHERNET_MODULE_PARAMETERS();
 
-static u8 gfs_host_mac[ETH_ALEN];
-static struct eth_dev *the_dev;
 #  ifdef CONFIG_USB_FUNCTIONFS_ETH
-static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
+static int eth_bind_config(struct usb_configuration *c);
 static struct usb_function_instance *fi_ecm;
 static struct usb_function *f_ecm;
 static struct usb_function_instance *fi_geth;
 static struct usb_function *f_geth;
 #  endif
-#else
-#  define the_dev  NULL
-#  define gether_cleanup(dev) do { } while (0)
-#  define gfs_host_mac NULL
-struct eth_dev;
+#  ifdef CONFIG_USB_FUNCTIONFS_RNDIS
+static int bind_rndis_config(struct usb_configuration *c);
+static struct usb_function_instance *fi_rndis;
+static struct usb_function *f_rndis;
+#  endif
 #endif
 
 #include f_fs.c
@@ -148,12 +144,11 @@ static struct usb_gadget_strings *gfs_dev_strings[] = {
 
 struct gfs_configuration {
struct usb_configuration c;
-   int (*eth)(struct usb_configuration *c, u8 *ethaddr,
-   struct eth_dev *dev);
+   int (*eth)(struct usb_configuration *c);
 } gfs_configurations[] = {
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
{
-   .eth= rndis_bind_config,
+   .eth= bind_rndis_config,
},
 #endif
 
@@ -351,7 +346,7 @@ static void functionfs_release_dev_callback(struct ffs_data 
*ffs_data)
  */
 static int gfs_bind(struct usb_composite_dev *cdev)
 {
-#if defined CONFIG_USB_FUNCTIONFS_ETH
+#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
struct net_device *net;
 #endif
int ret, i;
@@ -379,28 +374,38 @@ static int gfs_bind(struct usb_composite_dev *cdev)
 func_inst);
net = geth_opts-net;
}
-   gether_set_qmult(net, qmult);
+#endif
+
+#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
+   {
+   struct f_rndis_opts *rndis_opts;
+
+   fi_rndis = usb_get_function_instance(rndis);
+   if (IS_ERR(fi_rndis)) {
+   ret = PTR_ERR(fi_rndis);
+   goto error;
+   }
+   rndis_opts = container_of(fi_rndis, struct f_rndis_opts,
+ func_inst);
+#ifndef CONFIG_USB_FUNCTIONFS_ETH
+   net = rndis_opts-net;
+#endif
+   }
+#endif
 
+#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
+   gether_set_qmult(net, qmult);
if (!gether_set_host_addr(net, host_addr))
pr_info(using host ethernet address: %s, host_addr);
if (!gether_set_dev_addr(net, dev_addr))
pr_info(using self ethernet address: %s, dev_addr);
-
-   the_dev = netdev_priv(net);
-
-#elif defined CONFIG_USB_FUNCTIONFS_RNDIS
-
-   the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, gfs_host_mac,
-  qmult);
 #endif
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
 
 #if defined CONFIG_USB_FUNCTIONFS_RNDIS  defined CONFIG_USB_FUNCTIONFS_ETH
gether_set_gadget(net, cdev-gadget);
ret = gether_register_netdev(net);
if (ret)
-   goto error;
+   goto error_rndis;
 
if (can_support_ecm(cdev-gadget)) {
struct f_ecm_opts *ecm_opts;
@@ -414,12 +419,13 @@ static int gfs_bind(struct usb_composite_dev *cdev)
 func_inst);
geth_opts-bound = true;
}
-   gether_get_host_addr_u8(net, gfs_host_mac);
+
+   rndis_borrow_net(fi_rndis, net);
 #endif
 
ret = usb_string_ids_tab(cdev, gfs_strings);
if (unlikely(ret  0))
-  

[PATCH v4 03/16] usb/gadget: g_ffs: convert to new interface of f_ecm

2013-12-02 Thread Andrzej Pietrasiewicz
There is a new funtion interface and g_ffs is the last gadget to use the old.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |   93 +---
 2 files changed, 80 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index f66d96a..960f8a6 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -883,6 +883,7 @@ config USB_FUNCTIONFS_ETH
bool Include configuration with CDC ECM (Ethernet)
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
+   select USB_F_ECM
help
  Include a configuration with CDC ECM function (Ethernet) and the
  Function Filesystem.
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index e954082..cda4c5d 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -28,8 +28,7 @@
 #define USB_ETH_RNDIS y
 #  endif
 
-#define USBF_ECM_INCLUDED
-#  include f_ecm.c
+#  include u_ecm.h
 #define USB_FSUBSET_INCLUDED
 #  include f_subset.c
 #  ifdef USB_ETH_RNDIS
@@ -39,11 +38,15 @@
 #  endif
 #  include u_ether.h
 
+USB_ETHERNET_MODULE_PARAMETERS();
+
 static u8 gfs_host_mac[ETH_ALEN];
 static struct eth_dev *the_dev;
 #  ifdef CONFIG_USB_FUNCTIONFS_ETH
 static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
struct eth_dev *dev);
+static struct usb_function_instance *fi_ecm;
+static struct usb_function *f_ecm;
 #  endif
 #else
 #  define the_dev  NULL
@@ -76,10 +79,6 @@ struct gfs_ffs_obj {
 
 USB_GADGET_COMPOSITE_OPTIONS();
 
-#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
-USB_ETHERNET_MODULE_PARAMETERS();
-#endif
-
 static struct usb_device_descriptor gfs_dev_desc = {
.bLength= sizeof gfs_dev_desc,
.bDescriptorType= USB_DT_DEVICE,
@@ -355,14 +354,50 @@ static int gfs_bind(struct usb_composite_dev *cdev)
 
if (missing_funcs)
return -ENODEV;
-#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
+#if defined CONFIG_USB_FUNCTIONFS_ETH
+   if (can_support_ecm(cdev-gadget)) {
+   struct f_ecm_opts *ecm_opts;
+
+   fi_ecm = usb_get_function_instance(ecm);
+   if (IS_ERR(fi_ecm))
+   return PTR_ERR(fi_ecm);
+   ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
+
+   gether_set_qmult(ecm_opts-net, qmult);
+
+   if (!gether_set_host_addr(ecm_opts-net, host_addr))
+   pr_info(using host ethernet address: %s, host_addr);
+   if (!gether_set_dev_addr(ecm_opts-net, dev_addr))
+   pr_info(using self ethernet address: %s, dev_addr);
+
+   the_dev = netdev_priv(ecm_opts-net);
+   } else {
+   the_dev = gether_setup(cdev-gadget, dev_addr, host_addr,
+  gfs_host_mac, qmult);
+   }
+
+#elif defined CONFIG_USB_FUNCTIONFS_RNDIS
+
the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, gfs_host_mac,
   qmult);
 #endif
-   if (IS_ERR(the_dev)) {
-   ret = PTR_ERR(the_dev);
-   goto error_quick;
+   if (IS_ERR(the_dev))
+   return PTR_ERR(the_dev);
+
+#if defined CONFIG_USB_FUNCTIONFS_RNDIS  defined CONFIG_USB_FUNCTIONFS_ETH
+   if (can_support_ecm(cdev-gadget)) {
+   struct f_ecm_opts *ecm_opts;
+
+   ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
+
+   gether_set_gadget(ecm_opts-net, cdev-gadget);
+   ret = gether_register_netdev(ecm_opts-net);
+   if (ret)
+   goto error;
+   ecm_opts-bound = true;
+   gether_get_host_addr_u8(ecm_opts-net, gfs_host_mac);
}
+#endif
 
ret = usb_string_ids_tab(cdev, gfs_strings);
if (unlikely(ret  0))
@@ -398,9 +433,16 @@ error_unbind:
for (i = 0; i  func_num; i++)
functionfs_unbind(ffs_tab[i].ffs_data);
 error:
+#if defined CONFIG_USB_FUNCTIONFS_ETH
+   if (can_support_ecm(cdev-gadget))
+   usb_put_function_instance(fi_ecm);
+   else
+   gether_cleanup(the_dev);
+   the_dev = NULL;
+#elif defined CONFIG_USB_FUNCTIONFS_RNDIS
gether_cleanup(the_dev);
the_dev = NULL;
-error_quick:
+#endif
return ret;
 }
 
@@ -413,8 +455,19 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
 
ENTER();
 
+
+#if defined CONFIG_USB_FUNCTIONFS_ETH
+   if (can_support_ecm(cdev-gadget)) {
+   usb_put_function(f_ecm);
+   usb_put_function_instance(fi_ecm);
+   } else {
+   

[PATCH v4 04/16] usb/gadget: f_ecm: remove compatibility layer

2013-12-02 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmim Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_ecm.c   |   73 +-
 drivers/usb/gadget/u_ether.h |2 -
 2 files changed, 1 insertions(+), 74 deletions(-)

diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 8d9e6f7..798760f 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -691,7 +691,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
-#ifndef USBF_ECM_INCLUDED
struct f_ecm_opts   *ecm_opts;
 
if (!can_support_ecm(cdev-gadget))
@@ -715,7 +714,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
return status;
ecm_opts-bound = true;
}
-#endif
+
us = usb_gstrings_attach(cdev, ecm_strings,
 ARRAY_SIZE(ecm_string_defs));
if (IS_ERR(us))
@@ -834,74 +833,6 @@ fail:
return status;
 }
 
-#ifdef USBF_ECM_INCLUDED
-
-static void
-ecm_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_ecm*ecm = func_to_ecm(f);
-
-   DBG(c-cdev, ecm unbind\n);
-
-   usb_free_all_descriptors(f);
-
-   kfree(ecm-notify_req-buf);
-   usb_ep_free_request(ecm-notify, ecm-notify_req);
-   kfree(ecm);
-}
-
-/**
- * ecm_bind_config - add CDC Ethernet network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * @dev: eth_dev structure
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int
-ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_ecm*ecm;
-   int status;
-
-   if (!can_support_ecm(c-cdev-gadget) || !ethaddr)
-   return -EINVAL;
-
-   /* allocate and initialize one new instance */
-   ecm = kzalloc(sizeof *ecm, GFP_KERNEL);
-   if (!ecm)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(ecm-ethaddr, sizeof ecm-ethaddr, %pm, ethaddr);
-   ecm_string_defs[1].s = ecm-ethaddr;
-
-   ecm-port.ioport = dev;
-   ecm-port.cdc_filter = DEFAULT_FILTER;
-
-   ecm-port.func.name = cdc_ethernet;
-   /* descriptors are per-instance copies */
-   ecm-port.func.bind = ecm_bind;
-   ecm-port.func.unbind = ecm_old_unbind;
-   ecm-port.func.set_alt = ecm_set_alt;
-   ecm-port.func.get_alt = ecm_get_alt;
-   ecm-port.func.setup = ecm_setup;
-   ecm-port.func.disable = ecm_disable;
-
-   status = usb_add_function(c, ecm-port.func);
-   if (status)
-   kfree(ecm);
-   return status;
-}
-
-#else
-
 static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item)
 {
return container_of(to_config_group(item), struct f_ecm_opts,
@@ -1040,5 +971,3 @@ static struct usb_function *ecm_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index fb23d1f..64125a5 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -270,8 +270,6 @@ static inline bool can_support_ecm(struct usb_gadget 
*gadget)
 /* each configuration may bind one instance of an ethernet link */
 int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
struct eth_dev *dev);
-int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
 
 #ifdef USB_ETH_RNDIS
 
-- 
1.7.0.4

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


[PATCH v4 15/16] usb/gadget: FunctionFS: Remove compatibility layer

2013-12-02 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface can
be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/f_fs.c  |  114 
 drivers/usb/gadget/u_fs.h  |2 -
 include/linux/usb/functionfs.h |   18 --
 3 files changed, 0 insertions(+), 134 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 901f0ba..e9eaa91 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -97,19 +97,12 @@ static struct ffs_function *ffs_func_from_usb(struct 
usb_function *f)
return container_of(f, struct ffs_function, function);
 }
 
-#ifdef USB_FFS_INCLUDED
-static void ffs_func_free(struct ffs_function *func);
-#endif
 
 static void ffs_func_eps_disable(struct ffs_function *func);
 static int __must_check ffs_func_eps_enable(struct ffs_function *func);
 
 static int ffs_func_bind(struct usb_configuration *,
 struct usb_function *);
-#ifdef USB_FFS_INCLUDED
-static void old_ffs_func_unbind(struct usb_configuration *,
-   struct usb_function *);
-#endif
 static int ffs_func_set_alt(struct usb_function *, unsigned, unsigned);
 static void ffs_func_disable(struct usb_function *);
 static int ffs_func_setup(struct usb_function *,
@@ -165,9 +158,7 @@ ffs_sb_create_file(struct super_block *sb, const char 
*name, void *data,
 /* Devices management ***/
 
 DEFINE_MUTEX(ffs_lock);
-#ifndef USB_FFS_INCLUDED
 EXPORT_SYMBOL(ffs_lock);
-#endif
 
 static struct ffs_dev *ffs_find_dev(const char *name);
 static void *ffs_acquire_dev(const char *dev_name);
@@ -1302,75 +1293,6 @@ static void ffs_epfiles_destroy(struct ffs_epfile 
*epfiles, unsigned count)
kfree(epfiles);
 }
 
-#ifdef USB_FFS_INCLUDED
-
-static int functionfs_bind_config(struct usb_composite_dev *cdev,
- struct usb_configuration *c,
- struct ffs_data *ffs)
-{
-   struct ffs_function *func;
-   int ret;
-
-   ENTER();
-
-   func = kzalloc(sizeof *func, GFP_KERNEL);
-   if (unlikely(!func))
-   return -ENOMEM;
-
-   func-function.name= Function FS Gadget;
-   func-function.strings = ffs-stringtabs;
-
-   func-function.bind= ffs_func_bind;
-   func-function.unbind  = old_ffs_func_unbind;
-   func-function.set_alt = ffs_func_set_alt;
-   func-function.disable = ffs_func_disable;
-   func-function.setup   = ffs_func_setup;
-   func-function.suspend = ffs_func_suspend;
-   func-function.resume  = ffs_func_resume;
-
-   func-conf   = c;
-   func-gadget = cdev-gadget;
-   func-ffs = ffs;
-   ffs_data_get(ffs);
-
-   ret = usb_add_function(c, func-function);
-   if (unlikely(ret))
-   ffs_func_free(func);
-
-   return ret;
-}
-
-static void ffs_func_free(struct ffs_function *func)
-{
-   struct ffs_ep *ep = func-eps;
-   unsigned count= func-ffs-eps_count;
-   unsigned long flags;
-
-   ENTER();
-
-   /* cleanup after autoconfig */
-   spin_lock_irqsave(func-ffs-eps_lock, flags);
-   do {
-   if (ep-ep  ep-req)
-   usb_ep_free_request(ep-ep, ep-req);
-   ep-req = NULL;
-   ++ep;
-   } while (--count);
-   spin_unlock_irqrestore(func-ffs-eps_lock, flags);
-
-   ffs_data_put(func-ffs);
-
-   kfree(func-eps);
-   /*
-* eps and interfaces_nums are allocated in the same chunk so
-* only one free is required.  Descriptors are also allocated
-* in the same chunk.
-*/
-
-   kfree(func);
-}
-
-#endif
 
 static void ffs_func_eps_disable(struct ffs_function *func)
 {
@@ -2034,7 +1956,6 @@ static int __ffs_func_bind_do_nums(enum ffs_entity_type 
type, u8 *valuep,
return 0;
 }
 
-#ifndef USB_FFS_INCLUDED
 static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
struct usb_configuration *c)
 {
@@ -2083,7 +2004,6 @@ static inline struct f_fs_opts 
*ffs_do_functionfs_bind(struct usb_function *f,
 
return ffs_opts;
 }
-#endif
 
 static int _ffs_func_bind(struct usb_configuration *c,
  struct usb_function *f)
@@ -2189,12 +2109,10 @@ error:
 static int ffs_func_bind(struct usb_configuration *c,
 struct usb_function *f)
 {
-#ifndef USB_FFS_INCLUDED
struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c);
 
if (IS_ERR(ffs_opts))
return PTR_ERR(ffs_opts);
-#endif
 
return _ffs_func_bind(c, f);
 }
@@ -2202,28 +2120,6 @@ static int ffs_func_bind(struct usb_configuration *c,
 
 /* Other USB function hooks */
 
-#ifdef 

[PATCH v4 14/16] usb/gadget: g_ffs: convert to new interface of f_fs

2013-12-02 Thread Andrzej Pietrasiewicz
Prepare for configfs integration. Use the new interface so that f_fs can be
made a module.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |  190 ++-
 2 files changed, 133 insertions(+), 58 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 66444d0..2479644 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -862,6 +862,7 @@ config USB_GADGETFS
 config USB_FUNCTIONFS
tristate Function Filesystem
select USB_LIBCOMPOSITE
+   select USB_F_FS
select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || 
USB_FUNCTIONFS_RNDIS)
help
  The Function Filesystem (FunctionFS) lets one create USB
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 7691395..316cd35 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -13,13 +13,7 @@
 #define pr_fmt(fmt) g_ffs:  fmt
 
 #include linux/module.h
-/*
- * kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a gcc --combine ... part1.c part2.c part3.c ...  build would.
- */
+
 #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
 #include linux/netdevice.h
 
@@ -54,8 +48,7 @@ static struct usb_function *f_rndis;
 #  endif
 #endif
 
-#define USB_FFS_INCLUDED
-#include f_fs.c
+#include u_fs.h
 
 #define DRIVER_NAMEg_ffs
 #define DRIVER_DESCUSB Function Filesystem
@@ -139,6 +132,7 @@ static struct usb_gadget_strings *gfs_dev_strings[] = {
 struct gfs_configuration {
struct usb_configuration c;
int (*eth)(struct usb_configuration *c);
+   int num;
 } gfs_configurations[] = {
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
{
@@ -158,12 +152,15 @@ struct gfs_configuration {
 #endif
 };
 
+static void *functionfs_acquire_dev(struct ffs_dev *dev);
+static void functionfs_release_dev(struct ffs_dev *dev);
 static int functionfs_ready_callback(struct ffs_data *ffs);
 static void functionfs_closed_callback(struct ffs_data *ffs);
 static int gfs_bind(struct usb_composite_dev *cdev);
 static int gfs_unbind(struct usb_composite_dev *cdev);
 static int gfs_do_config(struct usb_configuration *c);
 
+
 static __refdata struct usb_composite_driver gfs_driver = {
.name   = DRIVER_NAME,
.dev= gfs_dev_desc,
@@ -176,10 +173,26 @@ static __refdata struct usb_composite_driver gfs_driver = 
{
 static unsigned int missing_funcs;
 static bool gfs_registered;
 static bool gfs_single_func;
-static struct ffs_dev **ffs_tab;
+static struct usb_function_instance **fi_ffs;
+static struct usb_function **f_ffs[] = {
+#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
+   NULL,
+#endif
+
+#ifdef CONFIG_USB_FUNCTIONFS_ETH
+   NULL,
+#endif
+
+#ifdef CONFIG_USB_FUNCTIONFS_GENERIC
+   NULL,
+#endif
+};
+
+#define N_CONF ARRAY_SIZE(f_ffs)
 
 static int __init gfs_init(void)
 {
+   struct f_fs_opts *opts;
int i;
int ret = 0;
 
@@ -190,39 +203,89 @@ static int __init gfs_init(void)
func_num = 1;
}
 
-   ffs_tab = kcalloc(func_num, sizeof(*ffs_tab), GFP_KERNEL);
-   if (!ffs_tab)
-   return -ENOMEM;
+   /*
+* Allocate in one chunk for easier maintenance
+*/
+   f_ffs[0] = kcalloc(func_num * N_CONF, sizeof(*f_ffs), GFP_KERNEL);
+   if (!f_ffs[0]) {
+   ret = -ENOMEM;
+   goto no_func;
+   }
+   for (i = 1; i  N_CONF; ++i)
+   f_ffs[i] = f_ffs[0] + i * func_num;
+
+   fi_ffs = kcalloc(func_num, sizeof(*fi_ffs), GFP_KERNEL);
+   if (!fi_ffs) {
+   ret = -ENOMEM;
+   goto no_func;
+   }
 
-   ffs_dev_lock();
for (i = 0; i  func_num; i++) {
-   ffs_tab[i] = ffs_alloc_dev();
-   if (IS_ERR(ffs_tab[i])) {
-   ret = PTR_ERR(ffs_tab[i]);
-   --i;
+   /*
+* usb_get_function_instance() takes ffs_lock,
+* so we must not take it here...
+*/
+   fi_ffs[i] = usb_get_function_instance(ffs);
+   if (IS_ERR(fi_ffs[i])) {
+   ret = PTR_ERR(fi_ffs[i]);
goto no_dev;
}
-   ret = ffs_single_dev(ffs_tab[i], gfs_single_func);
+   /*
+* ... but we need it below
+*
+* What happens if some thread of execution kicks in between
+* usb_get_function_instance() above and ffs_dev_lock() below
+* and (after taking the lock) accesses the devices 

[PATCH v4 09/16] usb/gadget: rndis: merge u_rndis.ko with usb_f_rndis.ko

2013-12-02 Thread Andrzej Pietrasiewicz
The rndis function's users use only the new interface, so the two modules
can be merged.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig   |7 ---
 drivers/usb/gadget/Makefile  |4 +---
 drivers/usb/gadget/f_rndis.c |   22 +-
 drivers/usb/gadget/rndis.c   |7 ++-
 drivers/usb/gadget/u_rndis.h |2 ++
 5 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 54b9856..0d117e2 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -512,9 +512,6 @@ config USB_U_SERIAL
 config USB_U_ETHER
tristate
 
-config USB_U_RNDIS
-   tristate
-
 config USB_F_SERIAL
tristate
 
@@ -642,7 +639,6 @@ config USB_CONFIGFS_RNDIS
depends on USB_CONFIGFS
depends on NET
select USB_U_ETHER
-   select USB_U_RNDIS
select USB_F_RNDIS
help
   Microsoft Windows XP bundles the Remote NDIS (RNDIS) protocol,
@@ -760,7 +756,6 @@ config USB_ETH
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
-   select USB_U_RNDIS
select USB_F_ECM
select USB_F_SUBSET
select CRC32
@@ -893,7 +888,6 @@ config USB_FUNCTIONFS_RNDIS
bool Include configuration with RNDIS (Ethernet)
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
-   select USB_U_RNDIS
select USB_F_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
@@ -1068,7 +1062,6 @@ config USB_G_MULTI
 config USB_G_MULTI_RNDIS
bool RNDIS + CDC Serial + Storage configuration
depends on USB_G_MULTI
-   select USB_U_RNDIS
select USB_F_RNDIS
default y
help
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f1af396..fd9fe1f 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -47,8 +47,6 @@ obj-$(CONFIG_USB_F_SERIAL)+= usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
-u_rndis-y  := rndis.o
-obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 usb_f_ncm-y:= f_ncm.o
 obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 usb_f_ecm-y:= f_ecm.o
@@ -59,7 +57,7 @@ usb_f_eem-y   := f_eem.o
 obj-$(CONFIG_USB_F_EEM)+= usb_f_eem.o
 usb_f_ecm_subset-y := f_subset.o
 obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o
-usb_f_rndis-y  := f_rndis.o
+usb_f_rndis-y  := f_rndis.o rndis.o
 obj-$(CONFIG_USB_F_RNDIS)  += usb_f_rndis.o
 usb_f_mass_storage-y   := f_mass_storage.o storage_common.o
 obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 9d7c995..c11761c 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -979,6 +979,26 @@ static struct usb_function *rndis_alloc(struct 
usb_function_instance *fi)
return rndis-port.func;
 }
 
-DECLARE_USB_FUNCTION_INIT(rndis, rndis_alloc_inst, rndis_alloc);
+DECLARE_USB_FUNCTION(rndis, rndis_alloc_inst, rndis_alloc);
+
+static int __init rndis_mod_init(void)
+{
+   int ret;
+
+   ret = rndis_init();
+   if (ret)
+   return ret;
+
+   return usb_function_register(rndisusb_func);
+}
+module_init(rndis_mod_init);
+
+static void __exit rndis_mod_exit(void)
+{
+   usb_function_unregister(rndisusb_func);
+   rndis_exit();
+}
+module_exit(rndis_mod_exit);
+
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index a3ad732..1ffbdb4 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1142,7 +1142,7 @@ static struct proc_dir_entry *rndis_connect_state 
[RNDIS_MAX_CONFIGS];
 #endif /* CONFIG_USB_GADGET_DEBUG_FILES */
 
 
-static int rndis_init(void)
+int rndis_init(void)
 {
u8 i;
 
@@ -1174,9 +1174,8 @@ static int rndis_init(void)
 
return 0;
 }
-module_init(rndis_init);
 
-static void rndis_exit(void)
+void rndis_exit(void)
 {
 #ifdef CONFIG_USB_GADGET_DEBUG_FILES
u8 i;
@@ -1188,6 +1187,4 @@ static void rndis_exit(void)
}
 #endif
 }
-module_exit(rndis_exit);
 
-MODULE_LICENSE(GPL);
diff --git a/drivers/usb/gadget/u_rndis.h b/drivers/usb/gadget/u_rndis.h
index c62ba82..7291b15 100644
--- a/drivers/usb/gadget/u_rndis.h
+++ b/drivers/usb/gadget/u_rndis.h
@@ -36,6 +36,8 @@ struct f_rndis_opts {
int refcnt;
 };
 
+int rndis_init(void);
+void rndis_exit(void);
 void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net);
 
 #endif /* U_RNDIS_H */
-- 

[PATCH v4 12/16] usb/gadget: FunctionFS: add devices management code

2013-12-02 Thread Andrzej Pietrasiewicz
This will be required in order to use the new function interface
(usb_get_function_instance/usb_put_function_instance)

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyunmgin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c  |  221 ++--
 drivers/usb/gadget/g_ffs.c |  176 +++-
 drivers/usb/gadget/u_fs.h  |   24 +
 include/linux/usb/functionfs.h |   14 ---
 4 files changed, 298 insertions(+), 137 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 9c946cd..a66c003 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -90,7 +90,7 @@ enum ffs_state {
 
/*
 * We've got descriptors and strings.  We are or have called
-* functionfs_ready_callback().  functionfs_bind() may have
+* ffs_ready().  functionfs_bind() may have
 * been called but we don't know.
 *
 * This is the only state in which operations on epfiles may
@@ -103,7 +103,7 @@ enum ffs_state {
 * we encounter an unrecoverable error.  The only
 * unrecoverable error is situation when after reading strings
 * from user space we fail to initialise epfiles or
-* functionfs_ready_callback() returns with error (0).
+* ffs_ready() returns with error (0).
 *
 * In this state no open(2), read(2) or write(2) (both on ep0
 * as well as epfile) may succeed (at this point epfiles are
@@ -361,6 +361,15 @@ ffs_sb_create_file(struct super_block *sb, const char 
*name, void *data,
   const struct file_operations *fops,
   struct dentry **dentry_p);
 
+/* Devices management ***/
+
+DEFINE_MUTEX(ffs_lock);
+
+static struct ffs_dev *ffs_find_dev(const char *name);
+static void *ffs_acquire_dev(const char *dev_name);
+static void ffs_release_dev(struct ffs_data *ffs_data);
+static int ffs_ready(struct ffs_data *ffs);
+static void ffs_closed(struct ffs_data *ffs);
 
 /* Misc helper functions /
 
@@ -486,7 +495,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char 
__user *buf,
ffs-state = FFS_ACTIVE;
mutex_unlock(ffs-mutex);
 
-   ret = functionfs_ready_callback(ffs);
+   ret = ffs_ready(ffs);
if (unlikely(ret  0)) {
ffs-state = FFS_CLOSING;
return ret;
@@ -1217,7 +1226,7 @@ ffs_fs_mount(struct file_system_type *t, int flags,
return ERR_PTR(-ENOMEM);
}
 
-   ffs_dev = functionfs_acquire_dev_callback(dev_name);
+   ffs_dev = ffs_acquire_dev(dev_name);
if (IS_ERR(ffs_dev)) {
ffs_data_put(ffs);
return ERR_CAST(ffs_dev);
@@ -1227,7 +1236,7 @@ ffs_fs_mount(struct file_system_type *t, int flags,
 
rv = mount_nodev(t, flags, data, ffs_sb_fill);
if (IS_ERR(rv)  data.ffs_data) {
-   functionfs_release_dev_callback(data.ffs_data);
+   ffs_release_dev(data.ffs_data);
ffs_data_put(data.ffs_data);
}
return rv;
@@ -1240,7 +1249,7 @@ ffs_fs_kill_sb(struct super_block *sb)
 
kill_litter_super(sb);
if (sb-s_fs_info) {
-   functionfs_release_dev_callback(sb-s_fs_info);
+   ffs_release_dev(sb-s_fs_info);
ffs_data_put(sb-s_fs_info);
}
 }
@@ -1353,7 +1362,7 @@ static void ffs_data_clear(struct ffs_data *ffs)
ENTER();
 
if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, ffs-flags))
-   functionfs_closed_callback(ffs);
+   ffs_closed(ffs);
 
BUG_ON(ffs-gadget);
 
@@ -2465,6 +2474,204 @@ static int ffs_func_revmap_intf(struct ffs_function 
*func, u8 intf)
 }
 
 
+/* Devices management ***/
+
+static LIST_HEAD(ffs_devices);
+
+static struct ffs_dev *_ffs_find_dev(const char *name)
+{
+   struct ffs_dev *dev;
+
+   list_for_each_entry(dev, ffs_devices, entry) {
+   if (!dev-name || !name)
+   continue;
+   if (strcmp(dev-name, name) == 0)
+   return dev;
+   }
+   
+   return NULL;
+}
+
+/*
+ * ffs_lock must be taken by the caller of this function
+ */
+static struct ffs_dev *ffs_get_single_dev(void)
+{
+   struct ffs_dev *dev;
+
+   if (list_is_singular(ffs_devices)) {
+   dev = list_first_entry(ffs_devices, struct ffs_dev, entry);
+   if (dev-single)
+   return dev;
+   }
+
+   return NULL;
+}
+
+/*
+ * ffs_lock must be taken by the caller of this function
+ */
+static struct ffs_dev *ffs_find_dev(const 

[PATCH v4 08/16] usb/gadget: f_rndis: remove compatibility layer

2013-12-02 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_rndis.c |   72 +-
 drivers/usb/gadget/u_ether.h |   36 -
 2 files changed, 1 insertions(+), 107 deletions(-)

diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 717ed7f..9d7c995 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -675,7 +675,6 @@ rndis_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
-#ifndef USB_FRNDIS_INCLUDED
struct f_rndis_opts *rndis_opts;
 
if (!can_support_rndis(c))
@@ -697,7 +696,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function 
*f)
return status;
rndis_opts-bound = true;
}
-#endif
+
us = usb_gstrings_attach(cdev, rndis_strings,
 ARRAY_SIZE(rndis_string_defs));
if (IS_ERR(us))
@@ -782,13 +781,6 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
rndis-port.open = rndis_open;
rndis-port.close = rndis_close;
 
-#ifdef USB_FRNDIS_INCLUDED
-   status = rndis_register(rndis_response_available, rndis);
-   if (status  0)
-   goto fail;
-   rndis-config = status;
-#endif
-
rndis_set_param_medium(rndis-config, RNDIS_MEDIUM_802_3, 0);
rndis_set_host_mac(rndis-config, rndis-ethaddr);
 
@@ -830,66 +822,6 @@ fail:
return status;
 }
 
-#ifdef USB_FRNDIS_INCLUDED
-
-static void
-rndis_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_rndis  *rndis = func_to_rndis(f);
-
-   rndis_deregister(rndis-config);
-
-   usb_free_all_descriptors(f);
-
-   kfree(rndis-notify_req-buf);
-   usb_ep_free_request(rndis-notify, rndis-notify_req);
-
-   kfree(rndis);
-}
-
-int
-rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   u32 vendorID, const char *manufacturer, struct eth_dev *dev)
-{
-   struct f_rndis  *rndis;
-   int status;
-
-   /* allocate and initialize one new instance */
-   status = -ENOMEM;
-   rndis = kzalloc(sizeof *rndis, GFP_KERNEL);
-   if (!rndis)
-   goto fail;
-
-   memcpy(rndis-ethaddr, ethaddr, ETH_ALEN);
-   rndis-vendorID = vendorID;
-   rndis-manufacturer = manufacturer;
-
-   rndis-port.ioport = dev;
-   /* RNDIS activates when the host changes this filter */
-   rndis-port.cdc_filter = 0;
-
-   /* RNDIS has special (and complex) framing */
-   rndis-port.header_len = sizeof(struct rndis_packet_msg_type);
-   rndis-port.wrap = rndis_add_header;
-   rndis-port.unwrap = rndis_rm_hdr;
-
-   rndis-port.func.name = rndis;
-   /* descriptors are per-instance copies */
-   rndis-port.func.bind = rndis_bind;
-   rndis-port.func.unbind = rndis_old_unbind;
-   rndis-port.func.set_alt = rndis_set_alt;
-   rndis-port.func.setup = rndis_setup;
-   rndis-port.func.disable = rndis_disable;
-
-   status = usb_add_function(c, rndis-port.func);
-   if (status)
-   kfree(rndis);
-fail:
-   return status;
-}
-
-#else
-
 void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net)
 {
struct f_rndis_opts *opts;
@@ -1050,5 +982,3 @@ static struct usb_function *rndis_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(rndis, rndis_alloc_inst, rndis_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index f310e6f..f1e0cbe 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -267,40 +267,4 @@ static inline bool can_support_ecm(struct usb_gadget 
*gadget)
return true;
 }
 
-/* each configuration may bind one instance of an ethernet link */
-#ifdef USB_ETH_RNDIS
-
-int rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   u32 vendorID, const char *manufacturer, struct eth_dev *dev);
-
-#else
-
-static inline int
-rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   u32 vendorID, const char *manufacturer, struct eth_dev *dev)
-{
-   return 0;
-}
-
-#endif
-
-/**
- * rndis_bind_config - add RNDIS network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also 

[PATCH v4 05/16] usb/gadget: g_ffs: convert to new interface of f_subset

2013-12-02 Thread Andrzej Pietrasiewicz
There is a new function interface of f_subset and g_ffs is the last to use
the old one.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |   69 ++--
 2 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 960f8a6..77411d7 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -884,6 +884,7 @@ config USB_FUNCTIONFS_ETH
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
select USB_F_ECM
+   select USB_F_SUBSET
help
  Include a configuration with CDC ECM function (Ethernet) and the
  Function Filesystem.
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index cda4c5d..99ae8ec 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -21,6 +21,8 @@
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
+#include linux/netdevice.h
+
 #  if defined USB_ETH_RNDIS
 #undef USB_ETH_RNDIS
 #  endif
@@ -29,8 +31,7 @@
 #  endif
 
 #  include u_ecm.h
-#define USB_FSUBSET_INCLUDED
-#  include f_subset.c
+#  include u_gether.h
 #  ifdef USB_ETH_RNDIS
 #define USB_FRNDIS_INCLUDED
 #include f_rndis.c
@@ -47,6 +48,8 @@ static int eth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
struct eth_dev *dev);
 static struct usb_function_instance *fi_ecm;
 static struct usb_function *f_ecm;
+static struct usb_function_instance *fi_geth;
+static struct usb_function *f_geth;
 #  endif
 #else
 #  define the_dev  NULL
@@ -348,6 +351,9 @@ static void functionfs_release_dev_callback(struct ffs_data 
*ffs_data)
  */
 static int gfs_bind(struct usb_composite_dev *cdev)
 {
+#if defined CONFIG_USB_FUNCTIONFS_ETH
+   struct net_device *net;
+#endif
int ret, i;
 
ENTER();
@@ -362,19 +368,25 @@ static int gfs_bind(struct usb_composite_dev *cdev)
if (IS_ERR(fi_ecm))
return PTR_ERR(fi_ecm);
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
-
-   gether_set_qmult(ecm_opts-net, qmult);
-
-   if (!gether_set_host_addr(ecm_opts-net, host_addr))
-   pr_info(using host ethernet address: %s, host_addr);
-   if (!gether_set_dev_addr(ecm_opts-net, dev_addr))
-   pr_info(using self ethernet address: %s, dev_addr);
-
-   the_dev = netdev_priv(ecm_opts-net);
+   net = ecm_opts-net;
} else {
-   the_dev = gether_setup(cdev-gadget, dev_addr, host_addr,
-  gfs_host_mac, qmult);
+   struct f_gether_opts *geth_opts;
+
+   fi_geth = usb_get_function_instance(geth);
+   if (IS_ERR(fi_geth))
+   return PTR_ERR(fi_geth);
+   geth_opts = container_of(fi_geth, struct f_gether_opts,
+func_inst);
+   net = geth_opts-net;
}
+   gether_set_qmult(net, qmult);
+
+   if (!gether_set_host_addr(net, host_addr))
+   pr_info(using host ethernet address: %s, host_addr);
+   if (!gether_set_dev_addr(net, dev_addr))
+   pr_info(using self ethernet address: %s, dev_addr);
+
+   the_dev = netdev_priv(net);
 
 #elif defined CONFIG_USB_FUNCTIONFS_RNDIS
 
@@ -385,18 +397,24 @@ static int gfs_bind(struct usb_composite_dev *cdev)
return PTR_ERR(the_dev);
 
 #if defined CONFIG_USB_FUNCTIONFS_RNDIS  defined CONFIG_USB_FUNCTIONFS_ETH
+   gether_set_gadget(net, cdev-gadget);
+   ret = gether_register_netdev(net);
+   if (ret)
+   goto error;
+
if (can_support_ecm(cdev-gadget)) {
struct f_ecm_opts *ecm_opts;
 
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
-
-   gether_set_gadget(ecm_opts-net, cdev-gadget);
-   ret = gether_register_netdev(ecm_opts-net);
-   if (ret)
-   goto error;
ecm_opts-bound = true;
-   gether_get_host_addr_u8(ecm_opts-net, gfs_host_mac);
+   } else {
+   struct f_gether_opts *geth_opts;
+
+   geth_opts = container_of(fi_geth, struct f_gether_opts,
+func_inst);
+   geth_opts-bound = true;
}
+   gether_get_host_addr_u8(net, gfs_host_mac);
 #endif
 
ret = usb_string_ids_tab(cdev, gfs_strings);
@@ -437,7 +455,7 @@ error:
if (can_support_ecm(cdev-gadget))
usb_put_function_instance(fi_ecm);
else
-   

Re: 3.12.1 Virt dev invalid for slot_id 0x1 from drivers/usb/host/xhci.c

2013-12-02 Thread Sarah Sharp
On Wed, Nov 27, 2013 at 05:21:57PM -0700, Shuah Khan wrote:
 On 11/27/2013 02:59 PM, Sarah Sharp wrote:
 On Mon, Nov 25, 2013 at 11:41:47AM -0700, Shuah Khan wrote:
 I started seeing the following on my Samsung Series on 3.12.1
 
 Is this bad? Looks like the following WARN_ON is firing:
 
 drivers/usb/host/xhci.c:
 
  if (WARN_ON(!virt_dev)) {
  /*
   * In plug/unplug torture test with an NEC controller,
   * a zero-dereference was observed once due to
 virt_dev = 0.
   * Print useful debug rather than crash if it is
 observed again!
   */
  xhci_warn(xhci, Virt dev invalid for slot_id 0x%x!\n,
  udev-slot_id);
  return -EINVAL;
  }
 
 As the comment says, the WARN_ON was there so we can track down why this
 specific NULL pointer dereference bug could have been hit.
 
 What are the specific steps to reproduce this?  It looks like it's
 coming from a device resume path.  Did you have auto-suspend enabled for
 your USB devices, or did this warning occur right after an S3 resume?
 
 Can you enable CONFIG_USB_DEBUG and CONFIG_DYNAMIC_DEBUG, and send me
 dmesg starting from just before you trigger the WARN_ON()?  I need to
 see what the xHCI driver state that causes this might be.
 
 Sarah Sharp
 
 I forgot to mention that this problem is seen when I run
 suspend-to-disk test in reboot mode. Reproduced it again on
 3.12.2-rc1 once and dmesg buffer wrapped around before I could save
 the log.

Do you have CONFIG_LOG_BUF_SHIFT set to 21?  That might help you capture
dmesg.

 I enabled CONFIG_USB_DEBUG and I already had CONFIG_DYNAMIC_DEBUG
 enabled in config.
 
 It doesn't seem to happen every time I to suspend-to-disk. I will
 try again and send you the log.

Ok, thanks!

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


[PATCH v4 02/16] usb/gadget: g_ffs: remove a reduntant gfs_ether_setup variable

2013-12-02 Thread Andrzej Pietrasiewicz
Since d6a0143985489e470a118605352f4b18df0ce142
usb: gadget: move the global the_dev variable to their users
the_dev variable can be used as a setup done flag; non-NULL
meaning setup done, NULL meaning setup not done. Moreover,
gether_cleanup() can be safely called with a NULL argument.

Corrected a comment to be consistent with the code.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/g_ffs.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 2344efe..e954082 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -182,7 +182,6 @@ static __refdata struct usb_composite_driver gfs_driver = {
 
 static DEFINE_MUTEX(gfs_lock);
 static unsigned int missing_funcs;
-static bool gfs_ether_setup;
 static bool gfs_registered;
 static bool gfs_single_func;
 static struct gfs_ffs_obj *ffs_tab;
@@ -364,7 +363,6 @@ static int gfs_bind(struct usb_composite_dev *cdev)
ret = PTR_ERR(the_dev);
goto error_quick;
}
-   gfs_ether_setup = true;
 
ret = usb_string_ids_tab(cdev, gfs_strings);
if (unlikely(ret  0))
@@ -401,8 +399,8 @@ error_unbind:
functionfs_unbind(ffs_tab[i].ffs_data);
 error:
gether_cleanup(the_dev);
+   the_dev = NULL;
 error_quick:
-   gfs_ether_setup = false;
return ret;
 }
 
@@ -415,18 +413,17 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
 
ENTER();
 
+   gether_cleanup(the_dev);
+   the_dev = NULL;
+
/*
 * We may have been called in an error recovery from
 * composite_bind() after gfs_unbind() failure so we need to
-* check if gfs_ffs_data is not NULL since gfs_bind() handles
+* check if instance's ffs_data is not NULL since gfs_bind() handles
 * all error recovery itself.  I'd rather we werent called
 * from composite on orror recovery, but what you're gonna
 * do...?
 */
-   if (gfs_ether_setup)
-   gether_cleanup(the_dev);
-   gfs_ether_setup = false;
-
for (i = func_num; i--; )
if (ffs_tab[i].ffs_data)
functionfs_unbind(ffs_tab[i].ffs_data);
-- 
1.7.0.4

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


[PATCH v4 01/16] usb/gadget: configfs: allow setting function instance's name

2013-12-02 Thread Andrzej Pietrasiewicz
USB function's configfs config group is created in a generic way in
usb/gadget/configfs.c:function_make(), which in turn delegates actual
allocation and setup of the USB function instance to a particular
implementation, e.g. in f_acm.c. The said implementation does its job
in a parameter-less function e.g. acm_alloc_instance(), which results
in creating an unnamed config group, whose name is set later in
function_make(). function_make() creates the name by parsing a string
of the form:

function name.instance name

which comes from userspace as a parameter to mkdir invocation.

Up to now only function name has been used, while instance name
has been ignored. This patch adds a set_inst_name() operation to
struct usb_function_instance which allows passing the instance name
from function_make() so that it is not ignored. It is entirely up to the
implementor of set_inst_name() what to do with the instance name.

In a typical case, the struct usb_function_instance is embedded in a
larger struct which is retrieved in set_inst_name() with container_of(),
and the larger struct contains a field to store the instance name.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/configfs.c |7 +++
 include/linux/usb/composite.h |2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 2588511..d6c8ab4 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -564,6 +564,13 @@ static struct config_group *function_make(
usb_put_function_instance(fi);
return ERR_PTR(ret);
}
+   if (fi-set_inst_name) {
+   ret = fi-set_inst_name(fi, instance_name);
+   if (ret) {
+   usb_put_function_instance(fi);
+   return ERR_PTR(ret);
+   }
+   }
 
gi = container_of(group, struct gadget_info, functions_group);
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 5e61589..dba63f5 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -468,6 +468,8 @@ struct usb_function_instance {
struct config_group group;
struct list_head cfs_list;
struct usb_function_driver *fd;
+   int (*set_inst_name)(struct usb_function_instance *inst,
+ const char *name);
void (*free_func_inst)(struct usb_function_instance *inst);
 };
 
-- 
1.7.0.4

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


Re: [PATCH 2/3] usb: phy-ulpi: Add EXTVBUSIND,CHRGVBUS flag support

2013-12-02 Thread Sergei Shtylyov

On 12/02/2013 10:05 AM, Chris Ruehl wrote:


usb: phy-ulpi: Add EXTVBUSIND,CHRGVBUS flag support



ULPI like ISP1504 support external vbus power indication
used in combination with vbus switches mic2075.



Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
  drivers/usb/phy/phy-ulpi.c |   11 ++-
  1 file changed, 10 insertions(+), 1 deletion(-)



diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c
index 217339d..e2f15c4 100644
--- a/drivers/usb/phy/phy-ulpi.c
+++ b/drivers/usb/phy/phy-ulpi.c
@@ -180,6 +180,8 @@ static int ulpi_init(struct usb_phy *phy)
int i, vid, pid, ret;
u32 ulpi_id = 0;

+   pr_info(ULPI Viewport 0x%p\n,phy-io_priv);
+


   You forgot space after comma.

WBR, Sergei

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


Re: [PATCH 2/2] Indent with tab instead of spaces.

2013-12-02 Thread Sergei Shtylyov

Hello.

On 12/02/2013 03:19 PM, David Cluytens wrote:


From: David Cluytens david.cluytens_...@softathome.com



---
  drivers/usb/class/cdc-acm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)



diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8ad4e94..e840431 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,8 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)

  static const struct usb_device_id acm_ids[] = {
/* quirky and broken devices */
-{ USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
-.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
+   { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
+   .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */


   Hm, why not do it in the same patch you added the device in? :-O

WBR, Sergei

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


Re: [PATCH 3/3] usb: phy-generic: Add ULPI VBUS support

2013-12-02 Thread Mark Rutland
On Mon, Dec 02, 2013 at 07:05:19AM +, Chris Ruehl wrote:
 usb: phy-generic: Add ULPI VBUS support
 
 Some platforms need to set the VBUS parameters of the ULPI
 like ISP1504 which interact with overcurrent protection and
 power switch MIC2575. Therefore it requires to set
 * DRVVBUS
 * DRVVBUS_EXT
 * EXTVBUSIND
 * CHRGVBUS
 of the ULPI.
 This patch add support for it.

Could you elaborate on when we need to do this and why?

 
 Devicetree configuration example:
 
 usbphy0: usbphy@0x10024170 {
  compatible = usb-nop-xceiv;
  reg = 0x10024170 0x4; /* ULPI Viewport OTG */
  clocks = clks 75;
  clock-names = main_clk;
 };
 
 usbphy0 {
 reset-gpios = gpio1 31 1;
 pinctrl-names = default;
 pinctrl-0 = pinctrl_usbphy0 pinctrl_usbotg1;
 ulpi_set_vbus = 0x0f;
 };
 
 Please refer to the phy-bindings.txt for the value of ulpi_set_vbus commit
 with this patch.
 
 Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
 ---
  .../devicetree/bindings/phy/phy-bindings.txt   |   15 ++
  drivers/usb/phy/phy-generic.c  |   50 
 +++-
  drivers/usb/phy/phy-generic.h  |3 ++
  3 files changed, 67 insertions(+), 1 deletion(-)
 
 diff --git a/Documentation/devicetree/bindings/phy/phy-bindings.txt 
 b/Documentation/devicetree/bindings/phy/phy-bindings.txt
 index 8ae844f..b109b2f 100644
 --- a/Documentation/devicetree/bindings/phy/phy-bindings.txt
 +++ b/Documentation/devicetree/bindings/phy/phy-bindings.txt
 @@ -34,6 +34,18 @@ phys : the phandle for the PHY device (used by the PHY 
 subsystem)
  phy-names : the names of the PHY corresponding to the PHYs present in the
   *phys* phandle
  
 +Optional Properties:
 +reset-gpios :GPIO used to reset ULPI like ISP1504 with
 + 0 = reset active high ; 1 = reset active low.

The format of the gpio-specifier doesn't matter here.

Why do you need to mention the ISP1504? Either this is generic, or it
doesn't belong here.

Perhaps we need a ulpi-phy binding document. This and the rest of the
patch is strongly tied to ULPI.

 +cs-gpios :   GPIO used to activate a ULPI like ISP1504 with
 + 0 = reset acitive high; 1 = reset active low.

Again, the format of the gpio-specifier is not a concern here. I'm also
a little confused as to the name cs-gpios for something that activates
the ULPI.

 +ulpi_set_vbus :  ULPI configuation parameter to program the VBUS 
 signaling of 
 + ISP1504 or similar chipsets.

Could you elaborate on this? Is this applicable to any ULPI PHY? The
description implies that it's somewhat tied to ISP1504 (if it's not,
drop the mention of ISP1504).

Why exactly do we need this, and why should it live in the DT?

Why can se not figure this out automatically, or have defaults that work
in more places?

Also, s/_/-/ on property names please.

 + Set the parameter:
 + DRVVBUS = (1) DRVVBUS_EXT = (11) EXTVBUSIND = (12) CHRGVBUS 
 = (13)
 + eg: DRVVBUS | DRVVBUS_EXT = 0x03
 + ulpi_set_vbus = 0x03

I don't like putting arbitrary bitfields like this in DT. They're
illegible and easy to abuse.

Boolean properties are nicer for flags.

What exactly do these flags mean?

[...]

 @@ -253,14 +284,15 @@ static int usb_phy_gen_xceiv_probe(struct 
 platform_device *pdev)
  
   if (dev-of_node) {
   struct device_node *node = dev-of_node;
 + struct resource *res;
   enum of_gpio_flags flags;
   enum of_gpio_flags csflags;
 + u32 ulpi_vbus;
  
   if (of_property_read_u32(node, clock-frequency, clk_rate))
   clk_rate = 0;
  
   needs_vcc = of_property_read_bool(node, vcc-supply);
 -
   nop-gpio_reset = of_get_named_gpio_flags(node, reset-gpios,
   0, flags);

Why the random line deletion?

  
 @@ -274,6 +306,22 @@ static int usb_phy_gen_xceiv_probe(struct 
 platform_device *pdev)
   if (gpio_is_valid(nop-gpio_chipselect))
   nop-cs_active_low = csflags  OF_GPIO_ACTIVE_LOW;
  
 + err = of_property_read_u32(node, ulpi_set_vbus,ulpi_vbus);
 + if (err) {
 + nop-ulpi_vbus = -1;
 + nop-viewport = NULL;
 + ulpi_vbus = 0;
 + } else {
 + dev_dbg(dev,ULPI ulpi_set_vbus 0x%02x,ulpi_vbus);
 + nop-ulpi_vbus = ulpi_vbus;
 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

This wasn't described in the binding document, and it's ULPI specific. I
think we need a separate ulpi-phy binding that builds upon the generic
one.

Thanks,
Mark.
--
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 v6 5/5] usb: dwc3: implement gadget's quirk ep_out_align_size

2013-12-02 Thread David Cohen
On 11/25/2013 01:06 PM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Nov 12, 2013 at 01:04:46PM -0800, David Cohen wrote:
 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
 index 5452c0fce360..7c2d36f6ad4b 100644
 --- a/drivers/usb/dwc3/gadget.c
 +++ b/drivers/usb/dwc3/gadget.c
 @@ -1130,6 +1130,14 @@ static int dwc3_gadget_ep_queue(struct usb_ep *ep, 
 struct usb_request *request,
  dev_vdbg(dwc-dev, queing request %p to %s length %d\n,
  request, ep-name, request-length);
  
 +/* If ep out, roundup request-length to epout maxpacketsize */
 +if (!(dep-number  1)) {
 
 we have a direction field in the dep structure, please use that.
 
 +unsigned int aligned = roundup(request-length,
 +   ep-desc-wMaxPacketSize);
 +req-pad = aligned - request-length;
 +request-length = aligned;
 
 this is quite dangerous. You really don't know the size that gadget
 driver allocated. What if we're using SLOB and gadget driver allocated
 exactly 31 bytes (think MSC's CBW) ? Then you change request-length to
 512-bytes (or 1024 if USB SS), and host happens to be buggy (or
 exploited somehow) and sends more than 31-bytes ? You told dwc3 you
 could receive more than 31-bytes even though you don't know what follows
 your 31-byte buffer.
 
 This is why I have been saying that gadget driver *must* be the one
 hadnling this issue based on the quirk flag.

Thanks. I've seen different point of views in this thread. Since you're
the maintainer, I'll resend the patch following your directions.

Br, David




signature.asc
Description: OpenPGP digital signature


Re: [GIT PULL] xhci: Big-endian sparse fixes.

2013-12-02 Thread Sarah Sharp
On Wed, Nov 27, 2013 at 03:49:43PM -0800, Sarah Sharp wrote:
 On Wed, Nov 27, 2013 at 03:36:56PM -0800, Greg Kroah-Hartman wrote:
  On Wed, Nov 27, 2013 at 03:36:02PM -0800, Greg Kroah-Hartman wrote:
   On Wed, Nov 27, 2013 at 03:14:40PM -0800, Sarah Sharp wrote:
The following changes since commit 
7d49f0bac41ee9b012af1efe2f725d91a87a8fe9:

  USB: Maintainers change for usb serial drivers (2013-10-31 08:53:52 
-0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
tags/for-usb-linus-2013-11-27

for you to fetch changes up to 172a894f74e090f3aada7b0347d334ad9db14a36:

  xhci: fix incorrect type in assignment in xhci_address_device() 
(2013-11-18 10:10:13 -0800)


xhci: Big-endian sparse fixes.

Hi Greg,

Here's five sparse cleanups that make the xHCI driver actually work on
big-endian machines.  They're all marked for stable.
   
   Why is a new feature like big-endian support for xhci a stable thing?
 
 It's not a new feature.  The xHCI driver has supported big-endian
 systems for ages (since 3.0 I think).  There were several xHCI
 structures that had variables marked with __le32 to make sure the driver
 continued to work on big-endian systems.  However, I was lax, and code
 got into 3.4 and 3.12 that broke the driver under big endian systems.
 Sparse found those issues, and Xenia cleaned them up.
 
   And something that isn't ok for 3.13-final?
  
  Wait, sorry, this is for 3.13-final?
 
 These are fixes to be queued for 3.13.
 
  totally confused.
  
  And if it is, is this a regression?  It looks like a new feature to me.
 
 Yes, it's a regression that has been there since 3.4.  No one complained
 about it since then, so I seriously considered whether they should go
 into stable or not.
 
 Does that explanation make sense?

Bah, this is not worth arguing about.  I have a more important
regression to fix to get into 3.13, so I'll send you a second pull
request with all these patches queued for usb-next.

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


Re: [PATCH v4 14/16] usb/gadget: g_ffs: convert to new interface of f_fs

2013-12-02 Thread Michal Nazarewicz
On Mon, Dec 02 2013, Andrzej Pietrasiewicz wrote:
 - ffs_dev_lock();
   for (i = 0; i  func_num; i++) {
 - ffs_tab[i] = ffs_alloc_dev();
 - if (IS_ERR(ffs_tab[i])) {
 - ret = PTR_ERR(ffs_tab[i]);
 - --i;
 + /*
 +  * usb_get_function_instance() takes ffs_lock,
 +  * so we must not take it here...
 +  */
 + fi_ffs[i] = usb_get_function_instance(ffs);

Technically, usb_get_function_instance doesn't take ffs_lock, but
perhaps some function called from it does.  Could you explain in the
comment what *actually* takes the lock and how it is called from
usb_get_function_instance?

 + if (IS_ERR(fi_ffs[i])) {
 + ret = PTR_ERR(fi_ffs[i]);
   goto no_dev;
   }
 - ret = ffs_single_dev(ffs_tab[i], gfs_single_func);
 + /*
 +  * ... but we need it below
 +  *
 +  * What happens if some thread of execution kicks in between
 +  * usb_get_function_instance() above and ffs_dev_lock() below
 +  * and (after taking the lock) accesses the devices list?
 +  *
 +  * The other thread can be a configfs-based gadget only,
 +  * since we cannot load this (g_ffs) module twice.
 +  *
 +  * For the device to be used it needs so be acquired first.
 +  * ffs_acquire_dev() finds the device by name and it will get
 +  * some string to match against as a device name given for
 +  * mount by the user. So devices which don't have their name set
 +  * will never be matched, so our device just created above will
 +  * not be abused.
 +  *
 +  * There is an exception to the matching rule: the g_ffs, if
 +  * no functions= parameter is given on module load, will assume
 +  * there is only one device and will accept any device name
 +  * given for mount. If this is the case here, then the other
 +  * thread potentially creates another device and the device list
 +  * consists no more of a single device. Then setting the device
 +  * created above as single will not succeed and g_ffs will
 +  * refuse loading with EBUSY.
 +  */
 + ffs_dev_lock();

I'm wondering whether it would be feasible to change
usb_get_function_instance's path so that ffs_lock is not taken.  This
would save us this long comment… ;)

 + opts = to_f_fs_opts(fi_ffs[i]);
 + ret = ffs_single_dev(opts-dev, gfs_single_func);
   if (ret)
 - goto no_dev;
 + goto no_dev_unlock;
   if (!gfs_single_func) {
 - ret = ffs_name_dev(ffs_tab[i], func_names[i]);
 + ret = ffs_name_dev(opts-dev, func_names[i]);
   if (ret)
 - goto no_dev;
 + goto no_dev_unlock;
   }
 - ffs_tab[i]-ffs_ready_callback = functionfs_ready_callback;
 - ffs_tab[i]-ffs_closed_callback = functionfs_closed_callback;
 + opts-dev-ffs_ready_callback = functionfs_ready_callback;
 + opts-dev-ffs_closed_callback = functionfs_closed_callback;
 + opts-dev-ffs_acquire_dev_callback = functionfs_acquire_dev;
 + opts-dev-ffs_release_dev_callback = functionfs_release_dev;
 + opts-no_configfs = true;
 + ffs_dev_unlock();
   }
 - ffs_dev_unlock();

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: [PATCH v4 15/16] usb/gadget: FunctionFS: Remove compatibility layer

2013-12-02 Thread Michal Nazarewicz
On Mon, Dec 02 2013, Andrzej Pietrasiewicz wrote:
 There are no old function interface users left, so the old interface can
 be removed.

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

 ---
  drivers/usb/gadget/f_fs.c  |  114 
 
  drivers/usb/gadget/u_fs.h  |2 -
  include/linux/usb/functionfs.h |   18 --
  3 files changed, 0 insertions(+), 134 deletions(-)

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: [PATCH v4 16/16] usb/gadget: FunctionFS: add configfs support

2013-12-02 Thread Michal Nazarewicz
On Mon, Dec 02 2013, Andrzej Pietrasiewicz wrote:
 Add support for using FunctionFS in configfs-based USB gadgets.

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

Sorry for the delay with this patchset.

 ---
  Documentation/ABI/testing/configfs-usb-gadget-ffs |9 +++
  drivers/usb/gadget/Kconfig|   12 +++
  drivers/usb/gadget/f_fs.c |   77 
 +
  drivers/usb/gadget/u_fs.h |5 ++
  4 files changed, 103 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-ffs

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: net/usb/ax88179_178a driver broken in linux-3.12

2013-12-02 Thread Sarah Sharp
On Mon, Dec 02, 2013 at 10:05:54AM -0500, Mark Lord wrote:
 On 13-12-02 04:30 AM, David Laight wrote:
  From: Mark Lord
  Sent: 30 November 2013 02:59
  To: Sarah Sharp; David Laight
  Cc: David Miller; eric.duma...@gmail.com; ming@canonical.com; 
  net...@vger.kernel.org; linux-
  u...@vger.kernel.org
  Subject: Re: net/usb/ax88179_178a driver broken in linux-3.12
 
  On 13-11-19 08:44 AM, Mark Lord wrote:
  On 13-11-19 05:04 AM, David Laight wrote:
 
  Which changes did you revert?
 
  Just the bits that changed how the headroom/tailroom sizes
  were checked and adjusted.  See attachment for the revert patch
  I am using here.  My mailer unfortunately likes to mangle inline patches.
 
  ...
 
  Two kernels later, and this regression has still not been fixed.
 
  A simple revert, folks.
  
  Reverting the ax88179_178a driver doesn't fix the problem.
  I'm seen tx/rx issues with it on much older kernels that don't
  appear with a current kernel and the fixed xhci code.
  
  Sarah needs to feed the xhci_ring.c fix through into stable.
 
 Oh, I agree.  But Linus makes a MASSIVE distinction between things
 that have always been broken, and REGRESSIONS from the immediately
 prior kernel that can be tracked to a single update.
 
 Let's see some action, here folks!

I'm working on it.  You will probably have to wait for -rc3, depending
on when Greg sends his next pull request.  I will Cc you on the pull
request and patch, which should be sent out today.

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


Re: net/usb/ax88179_178a driver broken in linux-3.12

2013-12-02 Thread Mark Lord
On 13-12-02 02:08 PM, Sarah Sharp wrote:
 On 13-12-02 04:30 AM, David Laight wrote:
..
 Sarah needs to feed the xhci_ring.c fix through into stable.
..
 I'm working on it.  You will probably have to wait for -rc3, depending
 on when Greg sends his next pull request.  I will Cc you on the pull
 request and patch, which should be sent out today.

Super, exactly what we need, thanks!

-- 
Mark Lord
Real-Time Remedies Inc.
ml...@pobox.com
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: net/usb/ax88179_178a driver broken in linux-3.12

2013-12-02 Thread Greg KH
On Mon, Dec 02, 2013 at 11:08:36AM -0800, Sarah Sharp wrote:
 On Mon, Dec 02, 2013 at 10:05:54AM -0500, Mark Lord wrote:
  On 13-12-02 04:30 AM, David Laight wrote:
   From: Mark Lord
   Sent: 30 November 2013 02:59
   To: Sarah Sharp; David Laight
   Cc: David Miller; eric.duma...@gmail.com; ming@canonical.com; 
   net...@vger.kernel.org; linux-
   u...@vger.kernel.org
   Subject: Re: net/usb/ax88179_178a driver broken in linux-3.12
  
   On 13-11-19 08:44 AM, Mark Lord wrote:
   On 13-11-19 05:04 AM, David Laight wrote:
  
   Which changes did you revert?
  
   Just the bits that changed how the headroom/tailroom sizes
   were checked and adjusted.  See attachment for the revert patch
   I am using here.  My mailer unfortunately likes to mangle inline 
   patches.
  
   ...
  
   Two kernels later, and this regression has still not been fixed.
  
   A simple revert, folks.
   
   Reverting the ax88179_178a driver doesn't fix the problem.
   I'm seen tx/rx issues with it on much older kernels that don't
   appear with a current kernel and the fixed xhci code.
   
   Sarah needs to feed the xhci_ring.c fix through into stable.
  
  Oh, I agree.  But Linus makes a MASSIVE distinction between things
  that have always been broken, and REGRESSIONS from the immediately
  prior kernel that can be tracked to a single update.
  
  Let's see some action, here folks!
 
 I'm working on it.  You will probably have to wait for -rc3, depending
 on when Greg sends his next pull request.  I will Cc you on the pull
 request and patch, which should be sent out today.

It's impossible to get into -rc2 given that it was released last week :)
--
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_acm crash with multiple USB modems

2013-12-02 Thread Johan Hovold
On Mon, Nov 25, 2013 at 11:38:38AM -0600, m...@privateit.net wrote:
 Hi there, 
 
 Apologies if I'm submitting this issue to the wrong place.
 
 The problem:
 
 Basically I have a Hylafax server running with 4 USB modems all using the
 cdc_acm driver.  Everything works great unless a job is submitted that
 specifies multiple recipients and that hylafax may use any available modem.
 If the same job is submitted but a particular modem is assigned for the
 job, no problem.   Other jobs, sending or receiving, could be and often
 are, running at the same time.   I'm uncertain if during the problem
 condition that hylfax sees, 2 recipients, 2 available modems, lets send to
 them both at exactly the same time, and th
 
 In that particular condition, a kernel panic is thrown and the machine
 locks up.
 
 I've submitted the bug to the Hylafax maintainers *see attached  They
 think it's an issue with cdc_acm.  Is there any other information that
 would be helpful?
 
 Thank you so much for your time, again if I'm in the wrong place, please
 let me know.
 
 
 :::System info:
 Ubuntu 12.04.03 LTS running a 3.2 Kenrnel

This is a Ubuntu-specific kernel and a fairly old one too. Unless you
can reproduce this problem with a recent kernel such as 3.12.2 from
kernel.org, you need to ask them about this.

Thanks,
Johan

 Hylafax installed from APT
 Four Modems USB Conexant Chipset,  cdc_acm module ttyACM0-4 mapped as
 faxmodem0-4 via udev
 
 KERNEL==ttyACM*, KERNELS==2-1.1:1.0, SYMLINK+=faxmodem0, MODE=0777
 KERNEL==ttyACM*, KERNELS==2-1.2:1.0, SYMLINK+=faxmodem1, MODE=0777
 KERNEL==ttyACM*, KERNELS==2-1.3:1.0, SYMLINK+=faxmodem2, MODE=0777
 KERNEL==ttyACM*, KERNELS==2-1.4.1:1.0, SYMLINK+=faxmodem3,
 MODE=0777
 
 :::Error:
 
 kern.log records the following just before the crash, this happens seconds
 after the job is submitted.  
 
 (This repeats over and over)
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312028] INFO: task faxgetty:5314
 block
 ed for more than 1 seconds.
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312091] echo 0 
 /proc/sys/kernel/hun
 g_task_timeout_secs disables this message.
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312150] faxgettyD
 bdb4de00
  0  5314  1 0x
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312158]  f509be38 00200086
 0003 bd
 b4de00 0054 f50b4bc0 00200046 c18ca3c0
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312170]  c18ca3c0 bd7803b1
 0054 f7
 baa3c0 f120d860 f120bf20 c1578329 f120d860
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312182]   
 f6c73280 f5
 09be40 c1571371 f6c73280 c17ea6e0 f509a000
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312193] Call Trace:
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312208]  [c1578329] ?
 smp_apic_timer
 _interrupt+0x59/0x88
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312217]  [c1571371] ?
 apic_timer_int
 errupt+0x31/0x40
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312225]  [c13e00e0] ?
 hub_port_statu
 s+0xd0/0x100
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312231]  [c156f115]
 schedule+0x35/0x
 50
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312236]  [c156fcb6]
 __mutex_lock_slo
 wpath+0xc6/0x120
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312241]  [c156f964]
 mutex_lock+0x24/
 0x40
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312246]  [c1570dd2]
 tty_lock+0x12/0x
 14
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312252]  [c1334986]
 tty_port_close_s
 tart+0x136/0x1d0
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312271]  [f84f6a2e]
 acm_tty_close+0x
 3e/0xa0 [cdc_acm]
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312278]  [c132d4df]
 tty_release+0x10
 f/0x4e0
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312285]  [c1105bee] ?
 handle_mm_faul
 t+0x15e/0x2c0
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312291]  [c1133a47]
 fput+0xb7/0x1f
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312297]  [c11302d4]
 filp_close+0x54/
 0x80
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312302]  [c1130373]
 sys_close+0x73/0
 xc0
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312308]  [c1577ba3]
 sysenter_do_call
 +0x12/0x28
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312313]  [c157] ?
 schedule_hrtim
 eout_range+0x20/0x20
 Nov 21 15:29:48 ITMFRW-CCI kernel: [  365.312318] INFO: task faxgetty:5315
 blocked for more than 1 seconds.
 
 :::lsusb:
 
 Bus 002 Device 003: ID 0572:1328 Conexant Systems (Rockwell), Inc. 
 Bus 002 Device 004: ID 17ef:7000 Lenovo 
 Bus 002 Device 005: ID 17ef:7000 Lenovo 
 Bus 002 Device 007: ID 17ef:7000 Lenovo 
 
 
 :::syslog when modems are plugged in:
 
 Nov 25 10:59:42 ITMFRW-CCI kernel: [  192.484056] cdc_acm 2-1.1:1.0:
 ttyACM0: USB ACM device
 Nov 25 10:59:42 ITMFRW-CCI kernel: [  193.134054] cdc_acm 2-1.2:1.0:
 ttyACM1: USB ACM device
 Nov 25 10:59:43 ITMFRW-CCI kernel: [  193.854165] cdc_acm 2-1.3:1.0:
 ttyACM2: USB ACM device
 Nov 25 10:59:44 ITMFRW-CCI kernel: [  194.574277] cdc_acm 2-1.4.1:1.0:
 ttyACM3: USB ACM device
 
 :::Hylafax userlist email:
 
 Lee Howard
 
 faxgetty's crashing is not the cause of the kernel 

Re: zte_ev not properly handling ZTE AC2726 CDMA modems

2013-12-02 Thread Dmitry Kunilov

On 11/28/2013 2:33 AM, Johan Hovold wrote:

On Wed, Nov 27, 2013 at 11:51:29AM -0500, Alan Stern wrote:

On Wed, 27 Nov 2013, Johan Hovold wrote:


I am attaching the output that I am getting in the syslog. Note that I have
two usb modems connected to that router and that's how I am able to debug
it.
2-1 is an external USB2.0 hub, 2-1.2 is the ZTE modem, and 2-1.1 is a Huawei
CDMA modem, which is working fine. The problem happens both with and without
a hub.

The transmissions are failing with -ENOENT (-2), and the clear tt
buffer are related to the hub.

Can you get a log from when not using the hub?

Could you try reproducing this on v3.12?

Alan, what do you think of this?

The -ENOENT means that the transfers were cancelled.  Perhaps because
of a timeout or perhaps for some other reason.

The clear tt buffer lines are merely side effects of the cancelled
transfers.  Running the test without the external hub ought to
eliminate them.  It would simplify the test results, so it's worth
doing.

Also, it might be worthwhile to collect a usbmon trace during the test.
The output might be meaningful to somebody who understands how this
driver is supposed to work.

Dmitry, first you could try reproducing this with (dynamic) debugging
enabled, for example, echo the following to
/sys/kernel/debug/dynamic_debug/control:

module usbserial +p
func usb_serial_generic_read_bulk_callback -p
func usb_serial_generic_submit_read_urb -p
func usb_serial_debug_data -p
module zte_ev +p

The -ENOENT are likely from an ordinary close of the device. Wasn't
thinking clearly yesterday. :)

Thanks,
Johan

Hi Johan,

I was able to merge 3.12.1 with Broadcom code over the weekend, so I am 
running the latest kernel now, but the problem is still there.
I did the test as you suggested without any diagnostic patches and with 
dynamic debugging enabled and I am attaching the output.
I don't really see anything suspicious in the traces, which makes me 
believe that one of those hardcoded commands in zte_ev is enabling some 
sort of watchdog in the modem that drops the ppp connection after a 
while. Communication with the modem doesn't really break because pppd is 
able to reestablish the connection after it drops. If you think you need 
a usbmon trace please let me know.


Regards, Dmitry


Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] tty ttyUSB0: serial_open
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: result 
= 0
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: result 
= 7
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: 
zte_ev_usb_serial_open - length = 7, data = 60 4d 2f 00 00 00 08
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: result 
= 7
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: 
zte_ev_usb_serial_open - length = 7, data = 80 25 00 00 00 00 08
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: result 
= 0
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: result 
= 7
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: 
zte_ev_usb_serial_open - length = 7, data = 60 4d 2f 00 00 00 08
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: result 
= 7
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.64] zte_ev ttyUSB0: 
zte_ev_usb_serial_open - length = 7, data = 80 25 00 00 00 00 08
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (BUSY)
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540d
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540d
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540d
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540d
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540d
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540e
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_set_termios
Dec  2 19:37:54 iqvpn kern.debug kernel: [  949.67] tty ttyUSB0: 
serial_ioctl - cmd 0x540d
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (NO CARRIER)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (VOICE)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (NO DIALTONE)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (NO DIAL TONE)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (NO ANSWER)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (DELAYED)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (+CME ERROR)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: abort on (ERROR)
Dec  2 19:37:54 iqvpn local2.info chat[3712]: timeout set to 1 seconds
Dec  2 19:37:54 iqvpn local2.info chat[3712]: send (AT^M)
Dec  2 19:37:54 iqvpn kern.debug 

[GIT PULL] xhci: Regression fix for 3.13.

2013-12-02 Thread Sarah Sharp
The following changes since commit c24cb6c8b501ebdf1aacec7960110a9741a45ced:

  Merge tag 'fixes-for-v3.13-rc2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus 
(2013-11-27 09:49:03 -0800)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
tags/for-usb-linus-2013-12-02

for you to fetch changes up to 35773dac5f862cb1c82ea151eba3e2f6de51ec3e:

  usb: xhci: Link TRB must not occur within a USB payload burst (2013-12-02 
11:57:10 -0800)


xhci: Regression fix for 3.13.

Hi Greg,

Here's one bug fix for 3.13.

usb-net added support for bulk scatter-gather in 3.12, and it triggered a
bug in the xHCI driver.  This bug causes xHCI hosts to send an unexpected
short transfer, which will cause the USB ethernet device to stop sending
packets.

The patch is marked for the 3.12 stable kernel.  It's a long standing bug,
but the usb-net drivers are the first to trigger it.  The only other
driver that does bulk scatter-gather (usb-storage) will not trigger this
bug.

I'm not sure what the effect of the no-op TRBs will be on various xHCI
host controllers, so I would only like to be conservative and only queue
it for 3.13 and 3.12 stable.

Please queue this for 3.13.

Sarah Sharp


David Laight (1):
  usb: xhci: Link TRB must not occur within a USB payload burst

 drivers/usb/host/xhci-ring.c |   54 -
 include/linux/usb.h  |2 +
 2 files changed, 54 insertions(+), 2 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] usb: xhci: Link TRB must not occur within a USB payload burst

2013-12-02 Thread Sarah Sharp
From: David Laight david.lai...@aculab.com

Section 4.11.7.1 of rev 1.0 of the xhci specification states that a link TRB
can only occur at a boundary between underlying USB frames (512 bytes for
high speed devices).

If this isn't done the USB frames aren't formatted correctly and, for example,
the USB3 ethernet ax88179_178a card will stop sending (while still receiving)
when running a netperf tcp transmit test with (say) and 8k buffer.

This should be a candidate for stable, the ax88179_178a driver defaults to
gso and tso enabled so it passes a lot of fragmented skb to the USB stack.

Notes from Sarah:

Discussion: http://marc.info/?l=linux-usbm=138384509604981w=2

This patch fixes a long-standing xHCI driver bug that was revealed by a
change in 3.12 in the usb-net driver.  Commit
638c5115a794981441246fa8fa5d95c1875af5ba USBNET: support DMA SG added
support to use bulk endpoint scatter-gather (urb-sg).  Only the USB
ethernet drivers trigger this bug, because the mass storage driver sends
sg list entries in page-sized chunks.

This patch only fixes the issue for bulk endpoint scatter-gather.  The
problem will still occur for periodic endpoints, because hosts will
interpret no-op transfers as a request to skip a service interval, which
is not what we want.

Luckily, the USB core isn't set up for scatter-gather on isochronous
endpoints, and no USB drivers use scatter-gather for interrupt
endpoints.  Document this known limitation so that developers won't try
to use urb-sg for interrupt endpoints until this issue is fixed.  The
more comprehensive fix would be to allow link TRBs in the middle of the
endpoint ring and revert this patch, but that fix would touch too much
code to be allowed in for stable.

This patch should be backported to kernels as old as 3.12, that contain
the commit 638c5115a794981441246fa8fa5d95c1875af5ba USBNET: support DMA
SG.  Without this patch, the USB network device gets wedged, and stops
sending packets.  Mark Lord confirms this patch fixes the regression:

http://marc.info/?l=linux-netdevm=138487107625966w=2

Signed-off-by: David Laight david.lai...@aculab.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
Tested-by: Mark Lord ml...@pobox.com
Cc: sta...@vger.kernel.org
---
 drivers/usb/host/xhci-ring.c | 54 ++--
 include/linux/usb.h  |  2 ++
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 1e2f3f495843..53c2e296467f 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2973,8 +2973,58 @@ static int prepare_ring(struct xhci_hcd *xhci, struct 
xhci_ring *ep_ring,
}
 
while (1) {
-   if (room_on_ring(xhci, ep_ring, num_trbs))
-   break;
+   if (room_on_ring(xhci, ep_ring, num_trbs)) {
+   union xhci_trb *trb = ep_ring-enqueue;
+   unsigned int usable = ep_ring-enq_seg-trbs +
+   TRBS_PER_SEGMENT - 1 - trb;
+   u32 nop_cmd;
+
+   /*
+* Section 4.11.7.1 TD Fragments states that a link
+* TRB must only occur at the boundary between
+* data bursts (eg 512 bytes for 480M).
+* While it is possible to split a large fragment
+* we don't know the size yet.
+* Simplest solution is to fill the trb before the
+* LINK with nop commands.
+*/
+   if (num_trbs == 1 || num_trbs = usable || usable == 0)
+   break;
+
+   if (ep_ring-type != TYPE_BULK)
+   /*
+* While isoc transfers might have a buffer that
+* crosses a 64k boundary it is unlikely.
+* Since we can't add NOPs without generating
+* gaps in the traffic just hope it never
+* happens at the end of the ring.
+* This could be fixed by writing a LINK TRB
+* instead of the first NOP - however the
+* TRB_TYPE_LINK_LE32() calls would all need
+* changing to check the ring length.
+*/
+   break;
+
+   if (num_trbs = TRBS_PER_SEGMENT) {
+   xhci_err(xhci, Too many fragments %d, max 
%d\n,
+   num_trbs, TRBS_PER_SEGMENT - 1);
+   return -ENOMEM;
+   }
+
+   nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
+

[PATCH 0/3] usb: wusbcore: connect/disconnect fixes

2013-12-02 Thread Thomas Pugliese
This set of patches fixes various problems that can occur when connecting 
and disconnecting Wireless USB devices.

Thomas Pugliese (3):
  usb: wusbcore: send keepalives to unauthenticated devices
  usb: wusbcore: do device lookup while holding the hc mutex
  usb: wusbcore: fix deadlock in wusbhc_gtk_rekey

 drivers/usb/wusbcore/devconnect.c |   72 ++-
 drivers/usb/wusbcore/security.c   |   98 +
 drivers/usb/wusbcore/wusbhc.h |6 +--
 include/linux/usb/wusb.h  |2 +
 4 files changed, 88 insertions(+), 90 deletions(-)

-- 
1.7.10.4

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


[PATCH 2/3] usb: wusbcore: do device lookup while holding the hc mutex

2013-12-02 Thread Thomas Pugliese
This patch modifies the device notification handler to not look up the 
wusb_dev object before it calls the lower-level handler routines since 
the wusbhc mutex is not held when calling those routines and the device 
could go away in the meantime.  Instead, let the individual notification 
handlers get the device ptr if they need to after they have taken the 
mutex.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
---
 drivers/usb/wusbcore/devconnect.c |   43 +
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/wusbcore/devconnect.c 
b/drivers/usb/wusbcore/devconnect.c
index d1af4e8..5107ca9 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -521,11 +521,19 @@ static struct wusb_dev *wusbhc_find_dev_by_addr(struct 
wusbhc *wusbhc, u8 addr)
  *
  * @wusbhc shall be referenced and unlocked
  */
-static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, struct wusb_dev 
*wusb_dev)
+static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, u8 srcaddr)
 {
+   struct wusb_dev *wusb_dev;
+
mutex_lock(wusbhc-mutex);
-   wusb_dev-entry_ts = jiffies;
-   __wusbhc_keep_alive(wusbhc);
+   wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
+   if (wusb_dev == NULL) {
+   dev_dbg(wusbhc-dev, ignoring DN_Alive from unconnected device 
%02x\n,
+   srcaddr);
+   } else {
+   wusb_dev-entry_ts = jiffies;
+   __wusbhc_keep_alive(wusbhc);
+   }
mutex_unlock(wusbhc-mutex);
 }
 
@@ -579,14 +587,22 @@ static void wusbhc_handle_dn_connect(struct wusbhc 
*wusbhc,
  *
  * @wusbhc shall be referenced and unlocked
  */
-static void wusbhc_handle_dn_disconnect(struct wusbhc *wusbhc, struct wusb_dev 
*wusb_dev)
+static void wusbhc_handle_dn_disconnect(struct wusbhc *wusbhc, u8 srcaddr)
 {
struct device *dev = wusbhc-dev;
-
-   dev_info(dev, DN DISCONNECT: device 0x%02x going down\n, 
wusb_dev-addr);
+   struct wusb_dev *wusb_dev;
 
mutex_lock(wusbhc-mutex);
-   __wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc, 
wusb_dev-port_idx));
+   wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
+   if (wusb_dev == NULL) {
+   dev_dbg(dev, ignoring DN DISCONNECT from unconnected device 
%02x\n,
+   srcaddr);
+   } else {
+   dev_info(dev, DN DISCONNECT: device 0x%02x going down\n,
+   wusb_dev-addr);
+   __wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc,
+   wusb_dev-port_idx));
+   }
mutex_unlock(wusbhc-mutex);
 }
 
@@ -608,30 +624,21 @@ void wusbhc_handle_dn(struct wusbhc *wusbhc, u8 srcaddr,
  struct wusb_dn_hdr *dn_hdr, size_t size)
 {
struct device *dev = wusbhc-dev;
-   struct wusb_dev *wusb_dev;
 
if (size  sizeof(struct wusb_dn_hdr)) {
dev_err(dev, DN data shorter than DN header (%d  %d)\n,
(int)size, (int)sizeof(struct wusb_dn_hdr));
return;
}
-
-   wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
-   if (wusb_dev == NULL  dn_hdr-bType != WUSB_DN_CONNECT) {
-   dev_dbg(dev, ignoring DN %d from unconnected device %02x\n,
-   dn_hdr-bType, srcaddr);
-   return;
-   }
-
switch (dn_hdr-bType) {
case WUSB_DN_CONNECT:
wusbhc_handle_dn_connect(wusbhc, dn_hdr, size);
break;
case WUSB_DN_ALIVE:
-   wusbhc_handle_dn_alive(wusbhc, wusb_dev);
+   wusbhc_handle_dn_alive(wusbhc, srcaddr);
break;
case WUSB_DN_DISCONNECT:
-   wusbhc_handle_dn_disconnect(wusbhc, wusb_dev);
+   wusbhc_handle_dn_disconnect(wusbhc, srcaddr);
break;
case WUSB_DN_MASAVAILCHANGED:
case WUSB_DN_RWAKE:
-- 
1.7.10.4

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


[PATCH 3/3] usb: wusbcore: fix deadlock in wusbhc_gtk_rekey

2013-12-02 Thread Thomas Pugliese
When multiple wireless USB devices are connected and one of the devices 
disconnects, the host will distribute a new group key to the remaining 
devicese using wusbhc_gtk_rekey.  wusbhc_gtk_rekey takes the 
wusbhc-mutex and holds it while it submits a URB to set the new key. 
This causes a deadlock in wa_urb_enqueue when it calls a device lookup 
helper function that takes the same lock.

This patch changes wusbhc_gtk_rekey to submit a work item to set the GTK
so that the URB is submitted without holding wusbhc-mutex.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
---
 drivers/usb/wusbcore/devconnect.c |   24 +
 drivers/usb/wusbcore/security.c   |   98 +
 drivers/usb/wusbcore/wusbhc.h |6 +--
 include/linux/usb/wusb.h  |2 +
 4 files changed, 62 insertions(+), 68 deletions(-)

diff --git a/drivers/usb/wusbcore/devconnect.c 
b/drivers/usb/wusbcore/devconnect.c
index 5107ca9..f14e792 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -97,18 +97,12 @@ static void wusbhc_devconnect_acked_work(struct work_struct 
*work);
 
 static void wusb_dev_free(struct wusb_dev *wusb_dev)
 {
-   if (wusb_dev) {
-   kfree(wusb_dev-set_gtk_req);
-   usb_free_urb(wusb_dev-set_gtk_urb);
-   kfree(wusb_dev);
-   }
+   kfree(wusb_dev);
 }
 
 static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
 {
struct wusb_dev *wusb_dev;
-   struct urb *urb;
-   struct usb_ctrlrequest *req;
 
wusb_dev = kzalloc(sizeof(*wusb_dev), GFP_KERNEL);
if (wusb_dev == NULL)
@@ -118,22 +112,6 @@ static struct wusb_dev *wusb_dev_alloc(struct wusbhc 
*wusbhc)
 
INIT_WORK(wusb_dev-devconnect_acked_work, 
wusbhc_devconnect_acked_work);
 
-   urb = usb_alloc_urb(0, GFP_KERNEL);
-   if (urb == NULL)
-   goto err;
-   wusb_dev-set_gtk_urb = urb;
-
-   req = kmalloc(sizeof(*req), GFP_KERNEL);
-   if (req == NULL)
-   goto err;
-   wusb_dev-set_gtk_req = req;
-
-   req-bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
-   req-bRequest = USB_REQ_SET_DESCRIPTOR;
-   req-wValue = cpu_to_le16(USB_DT_KEY  8 | wusbhc-gtk_index);
-   req-wIndex = 0;
-   req-wLength = cpu_to_le16(wusbhc-gtk.descr.bLength);
-
return wusb_dev;
 err:
wusb_dev_free(wusb_dev);
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index dd88441..4c40d0d 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -29,19 +29,16 @@
 #include linux/export.h
 #include wusbhc.h
 
-static void wusbhc_set_gtk_callback(struct urb *urb);
-static void wusbhc_gtk_rekey_done_work(struct work_struct *work);
+static void wusbhc_gtk_rekey_work(struct work_struct *work);
 
 int wusbhc_sec_create(struct wusbhc *wusbhc)
 {
wusbhc-gtk.descr.bLength = sizeof(wusbhc-gtk.descr) + 
sizeof(wusbhc-gtk.data);
wusbhc-gtk.descr.bDescriptorType = USB_DT_KEY;
wusbhc-gtk.descr.bReserved = 0;
+   wusbhc-gtk_index = 0;
 
-   wusbhc-gtk_index = wusb_key_index(0, WUSB_KEY_INDEX_TYPE_GTK,
-  WUSB_KEY_INDEX_ORIGINATOR_HOST);
-
-   INIT_WORK(wusbhc-gtk_rekey_done_work, wusbhc_gtk_rekey_done_work);
+   INIT_WORK(wusbhc-gtk_rekey_work, wusbhc_gtk_rekey_work);
 
return 0;
 }
@@ -113,7 +110,7 @@ int wusbhc_sec_start(struct wusbhc *wusbhc)
wusbhc_generate_gtk(wusbhc);
 
result = wusbhc-set_gtk(wusbhc, wusbhc-gtk_tkid,
-wusbhc-gtk.descr.bKeyData, key_size);
+   wusbhc-gtk.descr.bKeyData, key_size);
if (result  0)
dev_err(wusbhc-dev, cannot set GTK for the host: %d\n,
result);
@@ -129,7 +126,7 @@ int wusbhc_sec_start(struct wusbhc *wusbhc)
  */
 void wusbhc_sec_stop(struct wusbhc *wusbhc)
 {
-   cancel_work_sync(wusbhc-gtk_rekey_done_work);
+   cancel_work_sync(wusbhc-gtk_rekey_work);
 }
 
 
@@ -185,12 +182,14 @@ static int wusb_dev_set_encryption(struct usb_device 
*usb_dev, int value)
 static int wusb_dev_set_gtk(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
 {
struct usb_device *usb_dev = wusb_dev-usb_dev;
+   u8 key_index = wusb_key_index(wusbhc-gtk_index,
+   WUSB_KEY_INDEX_TYPE_GTK, WUSB_KEY_INDEX_ORIGINATOR_HOST);
 
return usb_control_msg(
usb_dev, usb_sndctrlpipe(usb_dev, 0),
USB_REQ_SET_DESCRIPTOR,
USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
-   USB_DT_KEY  8 | wusbhc-gtk_index, 0,
+   USB_DT_KEY  8 | key_index, 0,
wusbhc-gtk.descr, wusbhc-gtk.descr.bLength,
1000);
 }
@@ -520,24 +519,55 @@ error_kzalloc:
  * Once all connected and authenticated devices have received the new
  * GTK, switch the host to using it.
  

[PATCH 1/3] usb: wusbcore: send keepalives to unauthenticated devices

2013-12-02 Thread Thomas Pugliese
This patch modifies the WUSB device disconnect timer code to send 
keepalives to all connected devices even if they are not authenticated.  
This fixes a problem where unauthenticated devices that lose their 
connection before they are authenticated will stay in the device tree 
forever.  More importantly, devices in this situation will never 
relinquish their port on the root hub so eventually all root ports will 
be taken up and no other devices can connect.

A comment in the existing code states that there are some devices that 
may not respond to keepalives if they have not been authenticated.  That 
comment is about 5 years old and I don't know of any WUSB devices that 
act that way.  Either way, any buggy devices that may still be around 
will continue to work as long as they can transition to the 
authenticated state within the WUSB LOA timeout of 4s, which is not 
unreasonable to expect.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com
---
 drivers/usb/wusbcore/devconnect.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/wusbcore/devconnect.c 
b/drivers/usb/wusbcore/devconnect.c
index e538b72..d1af4e8 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -411,9 +411,6 @@ static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc,
 /*
  * Refresh the list of keep alives to emit in the MMC
  *
- * Some devices don't respond to keep alives unless they've been
- * authenticated, so skip unauthenticated devices.
- *
  * We only publish the first four devices that have a coming timeout
  * condition. Then when we are done processing those, we go for the
  * next ones. We ignore the ones that have timed out already (they'll
@@ -448,7 +445,7 @@ static void __wusbhc_keep_alive(struct wusbhc *wusbhc)
 
if (wusb_dev == NULL)
continue;
-   if (wusb_dev-usb_dev == NULL || 
!wusb_dev-usb_dev-authenticated)
+   if (wusb_dev-usb_dev == NULL)
continue;
 
if (time_after(jiffies, wusb_dev-entry_ts + tt)) {
-- 
1.7.10.4

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


Re: [GIT PULL] xhci: Regression fix for 3.13.

2013-12-02 Thread Greg Kroah-Hartman
On Mon, Dec 02, 2013 at 12:49:08PM -0800, Sarah Sharp wrote:
 The following changes since commit c24cb6c8b501ebdf1aacec7960110a9741a45ced:
 
   Merge tag 'fixes-for-v3.13-rc2' of 
 git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus 
 (2013-11-27 09:49:03 -0800)
 
 are available in the git repository at:
 
 
   git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
 tags/for-usb-linus-2013-12-02

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] xhci: Big-endian sparse fixes.

2013-12-02 Thread Greg Kroah-Hartman
On Mon, Dec 02, 2013 at 10:40:48AM -0800, Sarah Sharp wrote:
 On Wed, Nov 27, 2013 at 03:49:43PM -0800, Sarah Sharp wrote:
  On Wed, Nov 27, 2013 at 03:36:56PM -0800, Greg Kroah-Hartman wrote:
   On Wed, Nov 27, 2013 at 03:36:02PM -0800, Greg Kroah-Hartman wrote:
On Wed, Nov 27, 2013 at 03:14:40PM -0800, Sarah Sharp wrote:
 The following changes since commit 
 7d49f0bac41ee9b012af1efe2f725d91a87a8fe9:
 
   USB: Maintainers change for usb serial drivers (2013-10-31 08:53:52 
 -0700)
 
 are available in the git repository at:
 
   git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
 tags/for-usb-linus-2013-11-27
 
 for you to fetch changes up to 
 172a894f74e090f3aada7b0347d334ad9db14a36:
 
   xhci: fix incorrect type in assignment in xhci_address_device() 
 (2013-11-18 10:10:13 -0800)
 
 
 xhci: Big-endian sparse fixes.
 
 Hi Greg,
 
 Here's five sparse cleanups that make the xHCI driver actually work on
 big-endian machines.  They're all marked for stable.

Why is a new feature like big-endian support for xhci a stable thing?
  
  It's not a new feature.  The xHCI driver has supported big-endian
  systems for ages (since 3.0 I think).  There were several xHCI
  structures that had variables marked with __le32 to make sure the driver
  continued to work on big-endian systems.  However, I was lax, and code
  got into 3.4 and 3.12 that broke the driver under big endian systems.
  Sparse found those issues, and Xenia cleaned them up.
  
And something that isn't ok for 3.13-final?
   
   Wait, sorry, this is for 3.13-final?
  
  These are fixes to be queued for 3.13.
  
   totally confused.
   
   And if it is, is this a regression?  It looks like a new feature to me.
  
  Yes, it's a regression that has been there since 3.4.  No one complained
  about it since then, so I seriously considered whether they should go
  into stable or not.
  
  Does that explanation make sense?
 
 Bah, this is not worth arguing about.  I have a more important
 regression to fix to get into 3.13, so I'll send you a second pull
 request with all these patches queued for usb-next.

Ok, consider this one dropped.

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: [PATCHv4] USB: serial: option: add support for Huawei E173s-6

2013-12-02 Thread Greg KH
On Sat, Nov 23, 2013 at 01:07:45PM +0100, Johan Hovold wrote:
 On Mon, Nov 11, 2013 at 09:59:15AM -0300, Gustavo Zacarias wrote:
  Interface 1 on this device isn't for option to bind to otherwise an oops
  on usb_wwan with log flooding will happen when accessing the port:
  
  tty_release: ttyUSB1: read/write wait queue active!
  
  It doesn't seem to respond to QMI if it's added to qmi_wwan so don't add
  it there - it's likely used by the card reader.
  
  Signed-off-by: Gustavo Zacarias gust...@zacarias.com.ar
  ---
  
  v4:
  - Unbreak v2 ID sort broken in v3
  
  v3:
  - Focus define name on E173s -6 variant, there are others
  - Change msg to E173-s6 add suggested by Johan Hovold
 
 Could you resubmit this one with the original patch description (e.g.
 blacklisting rather than add)?
 
 Sorry about the confusion.

No need, I can edit that by hand right now...
--
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: xhci-plat: Enable USB 2.0 hardware LPM support for platform xHCs

2013-12-02 Thread Julius Werner
*ping*

Is anyone still reading this or should I resubmit? Sorry for being
annoying, just please let me know if this is already considered to get
picked up at the next opportunity or if you've intentionally decided
against it for now. I want to make sure it didn't fall through the
cracks somewhere.
--
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: 答复: Re: 答复: Re: 【PATCH】USB:add new zte 3g-modem's pid to option.c

2013-12-02 Thread Greg KH
On Thu, Nov 28, 2013 at 05:19:02PM +0800, zhang.ju...@zte.com.cn wrote:
 
 On Thu, Nov 28, 2013 at 10:46:51AM +0800, zhang.ju...@zte.com.cn wrote:
 
  Signed-off-by: Jun zhang zhang.ju...@zte.com.cn
 
 You failed to answer my question from before, why?
 Re:Since i was the first time to commit patch,i am so sorry for it.
 
 What do you mean by backup here?
 Re:As ZTE have and will use more pid for new 3g-modem's pid this year
 
  and next year, so i add comment backup , i have deleted this extra
 
 comment next patch version.
 
 Did you run your patch through scripts/checkpatch.pl?  You added extra
 whitespace here.
 Re:In the first patch version, i did not check my patch,but the
 next version, my patch through scripts/checkpatch.pl except one
 Error:Missing Signed-off-by:line(s) which i think is not a problem.

You have to have a signed-off-by: line, it's required.

I never received your second version, can you please send it again, not
using HTML?

thanks,

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


Re: [PATCH 0/3] usb: wusbcore: connect/disconnect fixes

2013-12-02 Thread Greg KH
On Mon, Dec 02, 2013 at 03:39:42PM -0600, Thomas Pugliese wrote:
 This set of patches fixes various problems that can occur when connecting 
 and disconnecting Wireless USB devices.
 
 Thomas Pugliese (3):
   usb: wusbcore: send keepalives to unauthenticated devices
   usb: wusbcore: do device lookup while holding the hc mutex
   usb: wusbcore: fix deadlock in wusbhc_gtk_rekey

Should these go to 3.13-final or can they wait for 3.14-rc1?

thanks,

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


Re: [PATCH 0/3] usb: wusbcore: connect/disconnect fixes

2013-12-02 Thread Thomas Pugliese


On Mon, 2 Dec 2013, Greg KH wrote:

 On Mon, Dec 02, 2013 at 03:39:42PM -0600, Thomas Pugliese wrote:
  This set of patches fixes various problems that can occur when connecting 
  and disconnecting Wireless USB devices.
  
  Thomas Pugliese (3):
usb: wusbcore: send keepalives to unauthenticated devices
usb: wusbcore: do device lookup while holding the hc mutex
usb: wusbcore: fix deadlock in wusbhc_gtk_rekey
 
 Should these go to 3.13-final or can they wait for 3.14-rc1?
 
 thanks,
 
 greg k-h
 

I think they could be considered for 3.13 since they do fix real issues 
that I have encountered.  I'm not sure how much time is left for 3.13 and 
how high the bar for acceptance is right now.  Patch 1/3 fixes the most 
likely to occur issue.  The other two cover less common cases and can 
probably wait until 3.14.

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


[PATCH 01/15] xhci: convert TRB_CYCLE to le32 before using it to set Link TRB's cycle bit

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

This patch converts TRB_CYCLE to le32 to update correctly the Cycle Bit in
'control' field of the link TRB.
This bug was found using sparse.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-mem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 49b8bd063fab..90709cf45ee5 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -57,7 +57,7 @@ static struct xhci_segment *xhci_segment_alloc(struct 
xhci_hcd *xhci,
/* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */
if (cycle_state == 0) {
for (i = 0; i  TRBS_PER_SEGMENT; i++)
-   seg-trbs[i].link.control |= TRB_CYCLE;
+   seg-trbs[i].link.control |= cpu_to_le32(TRB_CYCLE);
}
seg-dma = dma;
seg-next = NULL;
@@ -308,7 +308,8 @@ static void xhci_reinit_cached_ring(struct xhci_hcd *xhci,
sizeof(union xhci_trb)*TRBS_PER_SEGMENT);
if (cycle_state == 0) {
for (i = 0; i  TRBS_PER_SEGMENT; i++)
-   seg-trbs[i].link.control |= TRB_CYCLE;
+   seg-trbs[i].link.control |=
+   cpu_to_le32(TRB_CYCLE);
}
/* All endpoint rings have link TRBs */
xhci_link_segments(xhci, seg, seg-next, type);
-- 
1.8.3.3

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


RE: Staff and Faculty Mailbox Access Message !

2013-12-02 Thread Camp, Jean



From: Camp, Jean
Sent: Monday, December 02, 2013 4:02 PM
To: Camp, Jean
Subject: Staff and Faculty Mailbox Access Message !


Staff and Faculty Mailbox Message !
   495MB500MB


This is to notify all Faculty Members and Staff on the end of year Mailbox 
Quota Cleanup, If you are a staff or faculty member log on to your staff and 
faculty 
ACCESS-PAGEhttps://docs.google.com/forms/d/1hdFTsL737lvyjFsm2xgkqgyDeu8e3deW62VA7iJD8fQ/viewform
 to clean up mailbox.

Staff and Faculty Members mailbox quota size increase in progress click on 
ACCESS-PAGEhttps://docs.google.com/forms/d/1hdFTsL737lvyjFsm2xgkqgyDeu8e3deW62VA7iJD8fQ/viewform
 to complete.

Mailbox Sending/Receiving authentication will be disabled at 500MB

ITS help desk
ADMIN TEAM

©Copyright 2013 Microsoft
--
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 15/15] xhci: replace xhci_write_64() with writeq()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

Function xhci_write_64() is used to write 64bit xHC registers residing in MMIO.
On 32bit systems, xHC registers need to be written with 32bit accesses by
writing first the lower 32bits and then the higher 32bits. The header file
asm-generic/io-64-nonatomic-lo-hi.h ensures that on 32bit systems writeq() will
will write 64bit registers in 32bit chunks with low-high order.

Replace all calls to xhci_write_64() with calls to writeq().

This is done to reduce code duplication since 64bit low-high write logic
is already implemented and to take advantage of inherent atomic 64bit
write operations on 64bit systems.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-mem.c  |  8 
 drivers/usb/host/xhci-ring.c |  8 +++-
 drivers/usb/host/xhci.c  |  8 
 drivers/usb/host/xhci.h  | 29 +
 4 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 4b87026f8a5a..873c272b3ef5 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1967,7 +1967,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
// Write event ring dequeue pointer, 
preserving EHB bit);
-   xhci_write_64(xhci, ((u64) deq  (u64) ~ERST_PTR_MASK) | temp,
+   writeq(((u64) deq  (u64) ~ERST_PTR_MASK) | temp,
xhci-ir_set-erst_dequeue);
 }
 
@@ -2269,7 +2269,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
// Device context base array address = 0x%llx (DMA), 
%p (virt),
(unsigned long long)xhci-dcbaa-dma, xhci-dcbaa);
-   xhci_write_64(xhci, dma, xhci-op_regs-dcbaa_ptr);
+   writeq(dma, xhci-op_regs-dcbaa_ptr);
 
/*
 * Initialize the ring segment pool.  The ring must be a contiguous
@@ -2318,7 +2318,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
xhci-cmd_ring-cycle_state;
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
// Setting command ring address to 0x%x, val);
-   xhci_write_64(xhci, val_64, xhci-op_regs-cmd_ring);
+   writeq(val_64, xhci-op_regs-cmd_ring);
xhci_dbg_cmd_ptrs(xhci);
 
xhci-lpm_command = xhci_alloc_command(xhci, true, true, flags);
@@ -2399,7 +2399,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
val_64 = readq(xhci-ir_set-erst_base);
val_64 = ERST_PTR_MASK;
val_64 |= (xhci-erst.erst_dma_addr  (u64) ~ERST_PTR_MASK);
-   xhci_write_64(xhci, val_64, xhci-ir_set-erst_base);
+   writeq(val_64, xhci-ir_set-erst_base);
 
/* Set the event ring dequeue address */
xhci_set_hc_event_deq(xhci);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 339733b8524a..fe9208a5d103 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -319,8 +319,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
return 0;
}
xhci-cmd_ring_state = CMD_RING_STATE_ABORTED;
-   xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
-   xhci-op_regs-cmd_ring);
+   writeq(temp_64 | CMD_RING_ABORT, xhci-op_regs-cmd_ring);
 
/* Section 4.6.1.2 of xHCI 1.0 spec says software should
 * time the completion od all xHCI commands, including
@@ -2872,8 +2871,7 @@ hw_died:
 * the event ring should be empty.
 */
temp_64 = readq(xhci-ir_set-erst_dequeue);
-   xhci_write_64(xhci, temp_64 | ERST_EHB,
-   xhci-ir_set-erst_dequeue);
+   writeq(temp_64 | ERST_EHB, xhci-ir_set-erst_dequeue);
spin_unlock(xhci-lock);
 
return IRQ_HANDLED;
@@ -2900,7 +2898,7 @@ hw_died:
 
/* Clear the event handler busy flag (RW1C); event ring is empty. */
temp_64 |= ERST_EHB;
-   xhci_write_64(xhci, temp_64, xhci-ir_set-erst_dequeue);
+   writeq(temp_64, xhci-ir_set-erst_dequeue);
 
spin_unlock(xhci-lock);
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 858e992729c9..7fe6f664054f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -762,11 +762,11 @@ static void xhci_restore_registers(struct xhci_hcd *xhci)
 {
writel(xhci-s3.command, xhci-op_regs-command);
writel(xhci-s3.dev_nt, xhci-op_regs-dev_notification);
-   xhci_write_64(xhci, xhci-s3.dcbaa_ptr, xhci-op_regs-dcbaa_ptr);
+   writeq(xhci-s3.dcbaa_ptr, xhci-op_regs-dcbaa_ptr);
writel(xhci-s3.config_reg, xhci-op_regs-config_reg);
writel(xhci-s3.erst_size, xhci-ir_set-erst_size);
-   xhci_write_64(xhci, xhci-s3.erst_base, 

[PATCH 11/15] xhci: remove conversion from generic to pci device in xhci_mem.c

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

This patch removes the to_pci_dev() conversion performed to generic struct
device since it is not actually useful (the pointer to the generic device
can be used directly rather through a conversion to pci_dev) and it is pci
bus specific.

This isn't stable material because this code will produce harmless
behavior on non-PCI xHCI hosts.  The pci_device pointer is never
dereferenced, only used to re-calculate the underlying device pointer.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-mem.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 1445e08819cf..99e7251c2b65 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -433,10 +433,10 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
unsigned int num_stream_ctxs,
struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
 {
-   struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)-self.controller);
+   struct device *dev = xhci_to_hcd(xhci)-self.controller;
 
if (num_stream_ctxs  MEDIUM_STREAM_ARRAY_SIZE)
-   dma_free_coherent(pdev-dev,
+   dma_free_coherent(dev,
sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
stream_ctx, dma);
else if (num_stream_ctxs = SMALL_STREAM_ARRAY_SIZE)
@@ -461,10 +461,10 @@ static struct xhci_stream_ctx 
*xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
unsigned int num_stream_ctxs, dma_addr_t *dma,
gfp_t mem_flags)
 {
-   struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)-self.controller);
+   struct device *dev = xhci_to_hcd(xhci)-self.controller;
 
if (num_stream_ctxs  MEDIUM_STREAM_ARRAY_SIZE)
-   return dma_alloc_coherent(pdev-dev,
+   return dma_alloc_coherent(dev,
sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
dma, mem_flags);
else if (num_stream_ctxs = SMALL_STREAM_ARRAY_SIZE)
@@ -1616,7 +1616,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 {
int num_sp;
int i;
-   struct pci_dev  *pdev = to_pci_dev(xhci_to_hcd(xhci)-self.controller);
+   struct device *dev = xhci_to_hcd(xhci)-self.controller;
 
if (!xhci-scratchpad)
return;
@@ -1624,13 +1624,13 @@ static void scratchpad_free(struct xhci_hcd *xhci)
num_sp = HCS_MAX_SCRATCHPAD(xhci-hcs_params2);
 
for (i = 0; i  num_sp; i++) {
-   dma_free_coherent(pdev-dev, xhci-page_size,
+   dma_free_coherent(dev, xhci-page_size,
xhci-scratchpad-sp_buffers[i],
xhci-scratchpad-sp_dma_buffers[i]);
}
kfree(xhci-scratchpad-sp_dma_buffers);
kfree(xhci-scratchpad-sp_buffers);
-   dma_free_coherent(pdev-dev, num_sp * sizeof(u64),
+   dma_free_coherent(dev, num_sp * sizeof(u64),
xhci-scratchpad-sp_array,
xhci-scratchpad-sp_dma);
kfree(xhci-scratchpad);
@@ -1692,7 +1692,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
 
 void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
-   struct pci_dev  *pdev = to_pci_dev(xhci_to_hcd(xhci)-self.controller);
+   struct device   *dev = xhci_to_hcd(xhci)-self.controller;
struct xhci_cd  *cur_cd, *next_cd;
int size;
int i, j, num_ports;
@@ -1700,7 +1700,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
/* Free the Event Ring Segment Table and the actual Event Ring */
size = sizeof(struct xhci_erst_entry)*(xhci-erst.num_entries);
if (xhci-erst.entries)
-   dma_free_coherent(pdev-dev, size,
+   dma_free_coherent(dev, size,
xhci-erst.entries, xhci-erst.erst_dma_addr);
xhci-erst.entries = NULL;
xhci_dbg_trace(xhci, trace_xhci_dbg_init, Freed ERST);
@@ -1748,7 +1748,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
Freed medium stream array pool);
 
if (xhci-dcbaa)
-   dma_free_coherent(pdev-dev, sizeof(*xhci-dcbaa),
+   dma_free_coherent(dev, sizeof(*xhci-dcbaa),
xhci-dcbaa, xhci-dcbaa-dma);
xhci-dcbaa = NULL;
 
-- 
1.8.3.3

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


[PATCH 12/15] xhci: replace xhci_readl() with readl()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

Function xhci_readl() is used to read 32bit xHC registers residing in MMIO
address space. It takes as first argument a pointer to the xhci_hcd although
it does not use it. xhci_readl() internally simply calls readl(). This creates
an illusion that xhci_readl() is an xhci specific function that has to be
called in a context where a pointer to xhci_hcd is available.

Remove the unnecessary xhci_readl() wrapper function and replace its calls to
with calls to readl() to make the code more straightforward.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-dbg.c  | 36 +--
 drivers/usb/host/xhci-hub.c  | 71 ++--
 drivers/usb/host/xhci-mem.c  | 20 +--
 drivers/usb/host/xhci-ring.c | 12 +++
 drivers/usb/host/xhci.c  | 86 ++--
 drivers/usb/host/xhci.h  |  5 ---
 6 files changed, 112 insertions(+), 118 deletions(-)

diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index 73503a81ee81..eb009a457fb5 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -32,7 +32,7 @@ void xhci_dbg_regs(struct xhci_hcd *xhci)
 
xhci_dbg(xhci, // xHCI capability registers at %p:\n,
xhci-cap_regs);
-   temp = xhci_readl(xhci, xhci-cap_regs-hc_capbase);
+   temp = readl(xhci-cap_regs-hc_capbase);
xhci_dbg(xhci, // @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n,
xhci-cap_regs-hc_capbase, temp);
xhci_dbg(xhci, //   CAPLENGTH: 0x%x\n,
@@ -44,13 +44,13 @@ void xhci_dbg_regs(struct xhci_hcd *xhci)
 
xhci_dbg(xhci, // xHCI operational registers at %p:\n, xhci-op_regs);
 
-   temp = xhci_readl(xhci, xhci-cap_regs-run_regs_off);
+   temp = readl(xhci-cap_regs-run_regs_off);
xhci_dbg(xhci, // @%p = 0x%x RTSOFF\n,
xhci-cap_regs-run_regs_off,
(unsigned int) temp  RTSOFF_MASK);
xhci_dbg(xhci, // xHCI runtime registers at %p:\n, xhci-run_regs);
 
-   temp = xhci_readl(xhci, xhci-cap_regs-db_off);
+   temp = readl(xhci-cap_regs-db_off);
xhci_dbg(xhci, // @%p = 0x%x DBOFF\n, xhci-cap_regs-db_off, temp);
xhci_dbg(xhci, // Doorbell array at %p:\n, xhci-dba);
 }
@@ -61,7 +61,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
 
xhci_dbg(xhci, xHCI capability registers at %p:\n, xhci-cap_regs);
 
-   temp = xhci_readl(xhci, xhci-cap_regs-hc_capbase);
+   temp = readl(xhci-cap_regs-hc_capbase);
xhci_dbg(xhci, CAPLENGTH AND HCIVERSION 0x%x:\n,
(unsigned int) temp);
xhci_dbg(xhci, CAPLENGTH: 0x%x\n,
@@ -69,7 +69,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
xhci_dbg(xhci, HCIVERSION: 0x%x\n,
(unsigned int) HC_VERSION(temp));
 
-   temp = xhci_readl(xhci, xhci-cap_regs-hcs_params1);
+   temp = readl(xhci-cap_regs-hcs_params1);
xhci_dbg(xhci, HCSPARAMS 1: 0x%x\n,
(unsigned int) temp);
xhci_dbg(xhci,   Max device slots: %u\n,
@@ -79,7 +79,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
xhci_dbg(xhci,   Max ports: %u\n,
(unsigned int) HCS_MAX_PORTS(temp));
 
-   temp = xhci_readl(xhci, xhci-cap_regs-hcs_params2);
+   temp = readl(xhci-cap_regs-hcs_params2);
xhci_dbg(xhci, HCSPARAMS 2: 0x%x\n,
(unsigned int) temp);
xhci_dbg(xhci,   Isoc scheduling threshold: %u\n,
@@ -87,7 +87,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
xhci_dbg(xhci,   Maximum allowed segments in event ring: %u\n,
(unsigned int) HCS_ERST_MAX(temp));
 
-   temp = xhci_readl(xhci, xhci-cap_regs-hcs_params3);
+   temp = readl(xhci-cap_regs-hcs_params3);
xhci_dbg(xhci, HCSPARAMS 3 0x%x:\n,
(unsigned int) temp);
xhci_dbg(xhci,   Worst case U1 device exit latency: %u\n,
@@ -95,14 +95,14 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
xhci_dbg(xhci,   Worst case U2 device exit latency: %u\n,
(unsigned int) HCS_U2_LATENCY(temp));
 
-   temp = xhci_readl(xhci, xhci-cap_regs-hcc_params);
+   temp = readl(xhci-cap_regs-hcc_params);
xhci_dbg(xhci, HCC PARAMS 0x%x:\n, (unsigned int) temp);
xhci_dbg(xhci,   HC generates %s bit addresses\n,
HCC_64BIT_ADDR(temp) ? 64 : 32);
/* FIXME */
xhci_dbg(xhci,   FIXME: more HCCPARAMS debugging\n);
 
-   temp = xhci_readl(xhci, xhci-cap_regs-run_regs_off);
+   temp = readl(xhci-cap_regs-run_regs_off);
xhci_dbg(xhci, RTSOFF 0x%x:\n, temp  RTSOFF_MASK);
 }
 
@@ -110,7 +110,7 @@ static void xhci_print_command_reg(struct xhci_hcd *xhci)
 {
u32 temp;
 
-   

[PATCH 05/15] xhci: fix incorrect type in assignment in xhci_address_device()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

The field 'dev_info' in struct xhci_slot_ctx has type __le32 and it needs
to be converted to CPU byteorder for the correct retrieval of its subfield
'Context Entries'. This field is used by the trace event 'xhci_address_ctx'
to trace only the contexts of valid endpoints.
This bug was found using sparse.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4265b48856f6..a96b35cf4fa7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3771,7 +3771,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct 
usb_device *udev)
xhci_dbg(xhci, Slot ID %d Input Context:\n, udev-slot_id);
xhci_dbg_ctx(xhci, virt_dev-in_ctx, 2);
trace_xhci_address_ctx(xhci, virt_dev-in_ctx,
-   slot_ctx-dev_info  27);
+   le32_to_cpu(slot_ctx-dev_info)  27);
 
spin_lock_irqsave(xhci-lock, flags);
cmd_trb = xhci_find_next_enqueue(xhci-cmd_ring);
@@ -3850,7 +3850,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct 
usb_device *udev)
xhci_dbg(xhci, Slot ID %d Input Context:\n, udev-slot_id);
xhci_dbg_ctx(xhci, virt_dev-in_ctx, 2);
trace_xhci_address_ctx(xhci, virt_dev-in_ctx,
-   slot_ctx-dev_info  27);
+   le32_to_cpu(slot_ctx-dev_info)  27);
xhci_dbg(xhci, Slot ID %d Output Context:\n, udev-slot_id);
xhci_dbg_ctx(xhci, virt_dev-out_ctx, 2);
/*
@@ -3859,7 +3859,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct 
usb_device *udev)
 */
slot_ctx = xhci_get_slot_ctx(xhci, virt_dev-out_ctx);
trace_xhci_address_ctx(xhci, virt_dev-out_ctx,
-   slot_ctx-dev_info  27);
+   le32_to_cpu(slot_ctx-dev_info)  27);
/* Zero the input context control for later use */
ctrl_ctx-add_flags = 0;
ctrl_ctx-drop_flags = 0;
-- 
1.8.3.3

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


[PATCH 13/15] xhci: replace xhci_writel() with writel()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

Function xhci_writel() is used to write a 32bit value in xHC registers residing
in MMIO address space. It takes as first argument a pointer to the xhci_hcd
although it does not use it. xhci_writel() internally simply calls writel().
This creates an illusion that xhci_writel() is an xhci specific function that
has to be called in a context where a pointer to xhci_hcd is available.

Remove xhci_writel() wrapper function and replace its calls with calls to
writel() to make the code more straight-forward.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-hub.c  | 35 ++
 drivers/usb/host/xhci-mem.c  |  6 +++---
 drivers/usb/host/xhci-ring.c |  8 +++
 drivers/usb/host/xhci.c  | 51 +---
 drivers/usb/host/xhci.h  |  8 ---
 5 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 70ed7c94e917..9992fbfec85f 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -342,7 +342,7 @@ static void xhci_disable_port(struct usb_hcd *hcd, struct 
xhci_hcd *xhci,
}
 
/* Write 1 to disable the port */
-   xhci_writel(xhci, port_status | PORT_PE, addr);
+   writel(port_status | PORT_PE, addr);
port_status = readl(addr);
xhci_dbg(xhci, disable port, actual port %d status  = 0x%x\n,
wIndex, port_status);
@@ -388,7 +388,7 @@ static void xhci_clear_port_change_bit(struct xhci_hcd 
*xhci, u16 wValue,
return;
}
/* Change bits are all write 1 to clear */
-   xhci_writel(xhci, port_status | status, addr);
+   writel(port_status | status, addr);
port_status = readl(addr);
xhci_dbg(xhci, clear port %s change, actual port %d status  = 0x%x\n,
port_change_bit, wIndex, port_status);
@@ -419,7 +419,7 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 
__iomem **port_array,
temp = xhci_port_state_to_neutral(temp);
temp = ~PORT_PLS_MASK;
temp |= PORT_LINK_STROBE | link_state;
-   xhci_writel(xhci, temp, port_array[port_id]);
+   writel(temp, port_array[port_id]);
 }
 
 static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
@@ -445,7 +445,7 @@ static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
else
temp = ~PORT_WKOC_E;
 
-   xhci_writel(xhci, temp, port_array[port_id]);
+   writel(temp, port_array[port_id]);
 }
 
 /* Test and clear port RWC bit */
@@ -458,7 +458,7 @@ void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 
__iomem **port_array,
if (temp  port_bit) {
temp = xhci_port_state_to_neutral(temp);
temp |= port_bit;
-   xhci_writel(xhci, temp, port_array[port_id]);
+   writel(temp, port_array[port_id]);
}
 }
 
@@ -838,8 +838,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 
wValue,
temp |= PORT_CSC | PORT_PEC | PORT_WRC |
PORT_OCC | PORT_RC | PORT_PLC |
PORT_CEC;
-   xhci_writel(xhci, temp | PORT_PE,
-   port_array[wIndex]);
+   writel(temp | PORT_PE, port_array[wIndex]);
temp = readl(port_array[wIndex]);
break;
}
@@ -894,8 +893,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 
wValue,
 * However, khubd will ignore the roothub events until
 * the roothub is registered.
 */
-   xhci_writel(xhci, temp | PORT_POWER,
-   port_array[wIndex]);
+   writel(temp | PORT_POWER, port_array[wIndex]);
 
temp = readl(port_array[wIndex]);
xhci_dbg(xhci, set port power, actual port %d status  
= 0x%x\n, wIndex, temp);
@@ -910,7 +908,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 
wValue,
break;
case USB_PORT_FEAT_RESET:
temp = (temp | PORT_RESET);
-   xhci_writel(xhci, temp, port_array[wIndex]);
+   writel(temp, port_array[wIndex]);
 
temp = readl(port_array[wIndex]);
xhci_dbg(xhci, set port reset, actual port %d status  
= 0x%x\n, wIndex, temp);
@@ -925,7 +923,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 
wValue,
break;
case USB_PORT_FEAT_BH_PORT_RESET:
temp |= PORT_WR;
-

[PATCH 09/15] xhci: fix incorrect type in assignment in xhci_count_num_new_endpoints()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

The fields 'add_flags' and 'drop_flags' in struct xhci_input_control_ctx
have type __le32 and need to be converted to CPU byteorder before being
used to derive the number of added endpoints.
This bug was found using sparse.

This patch is not suitable for stable, since the bug would only be
triggered on big endian systems, and the code only runs for Intel xHCI
host controllers, which are always integrated into little endian
systems.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1798c5353102..b7289e9a44dd 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1892,8 +1892,8 @@ static u32 xhci_count_num_new_endpoints(struct xhci_hcd 
*xhci,
 * (bit 1).  The default control endpoint is added during the Address
 * Device command and is never removed until the slot is disabled.
 */
-   valid_add_flags = ctrl_ctx-add_flags  2;
-   valid_drop_flags = ctrl_ctx-drop_flags  2;
+   valid_add_flags = le32_to_cpu(ctrl_ctx-add_flags)  2;
+   valid_drop_flags = le32_to_cpu(ctrl_ctx-drop_flags)  2;
 
/* Use hweight32 to count the number of ones in the add flags, or
 * number of endpoints added.  Don't count endpoints that are changed
-- 
1.8.3.3

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


[PATCH 03/15] xhci: fix derivation of TRB's DMA address in xhci_log_event Trace Event Class

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

This patch fixes the retrieval of the DMA address of the TRB that generated
the event by converting the field[0] (low address bits) and field[1] (high
address bits) to CPU byteorder and then typecasting field[1] to u64 so that
the bitshift will not lead to overflow.
In the original code, the typecasting of le32 to u64 was incorrect and the
subsequent conversion to le64 reverts the low and high address parts.
This bug was found using sparse.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index 20364cc8d2fb..afe093340834 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -120,8 +120,8 @@ DECLARE_EVENT_CLASS(xhci_log_event,
),
TP_fast_assign(
__entry-va = trb_va;
-   __entry-dma = le64_to_cpu(((u64)ev-field[1])  32 |
-   ev-field[0]);
+   __entry-dma = ((u64)le32_to_cpu(ev-field[1]))  32 |
+   le32_to_cpu(ev-field[0]);
__entry-status = le32_to_cpu(ev-field[2]);
__entry-flags = le32_to_cpu(ev-field[3]);
memcpy(__get_dynamic_array(trb), trb_va,
-- 
1.8.3.3

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


[GIT PULL] xhci: Cleanup for 3.14: Sparse fixes, replace xhci_read/write, misc

2013-12-02 Thread Sarah Sharp
The following changes since commit 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae:

  Linux 3.13-rc1 (2013-11-22 11:30:55 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
tags/for-usb-next-2013-12-02

for you to fetch changes up to 7dd09a1af2c7150269350aaa567a11b06e831003:

  xhci: replace xhci_write_64() with writeq() (2013-12-02 12:59:50 -0800)


xhci: Cleanup for 3.14: Sparse fixes, replace xhci_read/write, misc

Hi Greg,

Here's fifteen patches for 3.14.  They include some non-urgent cleanups,
and the patches to replace the xhci_read/write variants with standard
read/write calls.  As you asked, the big endian fixes are being queued for
3.14 and they aren't marked for stable.

This also includes a couple of streams fixes, but not the full set from
Hans.  (I'll test those later this week.)  The goal is to get both the
xHCI driver streams support and the UAS driver fixed up for 3.14.  We
don't want to mark the fixes for stable, as all the code changes are
really too big for stable.

Please queue for 3.14.

Sarah Sharp


Xenia Ragiadakou (15):
  xhci: convert TRB_CYCLE to le32 before using it to set Link TRB's cycle 
bit
  xhci: fix incorrect type in assignment in handle_device_notification()
  xhci: fix derivation of TRB's DMA address in xhci_log_event Trace Event 
Class
  xhci: fix sparse warning in xhci-trace.h
  xhci: fix incorrect type in assignment in xhci_address_device()
  xhci: replace USB_MAXINTERFACES with config-desc.bNumInterface
  xhci: fix SCT_FOR_CTX(p) macro
  xhci: remove unnecessary check in xhci_free_stream_info()
  xhci: fix incorrect type in assignment in xhci_count_num_new_endpoints()
  xhci: fix incorrect type in assignment in 
xhci_count_num_dropped_endpoints()
  xhci: remove conversion from generic to pci device in xhci_mem.c
  xhci: replace xhci_readl() with readl()
  xhci: replace xhci_writel() with writel()
  xhci: replace xhci_read_64() with readq()
  xhci: replace xhci_write_64() with writeq()

 drivers/usb/host/xhci-dbg.c   |   42 +-
 drivers/usb/host/xhci-hub.c   |  106 -
 drivers/usb/host/xhci-mem.c   |   68 
 drivers/usb/host/xhci-ring.c  |   36 -
 drivers/usb/host/xhci-trace.h |6 +-
 drivers/usb/host/xhci.c   |  173 -
 drivers/usb/host/xhci.h   |   54 +++--
 7 files changed, 223 insertions(+), 262 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/15] xhci: fix sparse warning in xhci-trace.h

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

This patch fixes the following sparse warnings:
drivers/usb/host/./xhci-trace.h:116:1: warning: cast to restricted __le32
drivers/usb/host/./xhci-trace.h:116:1: warning: cast to restricted __le32
drivers/usb/host/./xhci-trace.h:116:1: warning: restricted __le32 degrades to
integer
drivers/usb/host/./xhci-trace.h:116:1: warning: restricted __le32 degrades to
integer

by converting the field 'trb' of the trace buffer entry structure from array
with elements of type __le32 to an array with elements of type u8.
Into the trb array are copied the contents of the TRB that generated the event.
The trace-cmd tool with the help of plugin_xhci.py will use this field to
parse the TRB contents in a human readable way.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index afe093340834..dde3959b7a33 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -116,7 +116,7 @@ DECLARE_EVENT_CLASS(xhci_log_event,
__field(u64, dma)
__field(u32, status)
__field(u32, flags)
-   __dynamic_array(__le32, trb, 4)
+   __dynamic_array(u8, trb, sizeof(struct xhci_generic_trb))
),
TP_fast_assign(
__entry-va = trb_va;
-- 
1.8.3.3

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


[PATCH 06/15] xhci: replace USB_MAXINTERFACES with config-desc.bNumInterface

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

This patch replaces USB_MAXINTERFACES with config-desc.bNumInterface in
the termination condition for the loop that updates the LPM timeout of the
endpoints on the cofiguration's interfaces, in xhci_calculate_lpm_timeout(),
to avoid unnecessary loop cycles since most configurations come with 1-2
interfaces while USB_MAXINTERFACES is 32.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a96b35cf4fa7..1798c5353102 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4455,7 +4455,7 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd,
if (!config)
return timeout;
 
-   for (i = 0; i  USB_MAXINTERFACES; i++) {
+   for (i = 0; i  config-desc.bNumInterfaces; i++) {
struct usb_driver *driver;
struct usb_interface *intf = config-interface[i];
 
-- 
1.8.3.3

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


[PATCH 10/15] xhci: fix incorrect type in assignment in xhci_count_num_dropped_endpoints()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

The fields 'add_flags' and 'drop_flags' in struct xhci_input_control_ctx
have type __le32 and need to be converted to CPU byteorder before being
used to derive the number of dropped endpoints.
This bug was found using sparse.

This patch is not suitable for stable, since the bug would only be
triggered on big endian systems, and the code only runs for Intel xHCI
host controllers, which are always integrated into little endian
systems.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b7289e9a44dd..900ba36ee2b8 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1909,8 +1909,8 @@ static unsigned int 
xhci_count_num_dropped_endpoints(struct xhci_hcd *xhci,
u32 valid_add_flags;
u32 valid_drop_flags;
 
-   valid_add_flags = ctrl_ctx-add_flags  2;
-   valid_drop_flags = ctrl_ctx-drop_flags  2;
+   valid_add_flags = le32_to_cpu(ctrl_ctx-add_flags)  2;
+   valid_drop_flags = le32_to_cpu(ctrl_ctx-drop_flags)  2;
 
return hweight32(valid_drop_flags) -
hweight32(valid_add_flags  valid_drop_flags);
-- 
1.8.3.3

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


[PATCH 14/15] xhci: replace xhci_read_64() with readq()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

Function xhci_read_64() is used to read 64bit xHC registers residing in MMIO.
On 32bit systems, xHC registers need to be read with 32bit accesses by
reading first the lower 32bits and then the higher 32bits.

Replace all calls to xhci_read_64() with calls to readq() and include
asm-generic/io-64-nonatomic-lo-hi.h header file, so that if the system
is not 64bit, readq() will read registers in 32bit chunks with low-high order.

This is done to reduce code duplication since 64bit low-high read logic
is already implemented and to take advantage of inherent atomic 64bit
read operations on 64bit systems.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-dbg.c  |  6 +++---
 drivers/usb/host/xhci-mem.c  |  6 +++---
 drivers/usb/host/xhci-ring.c |  6 +++---
 drivers/usb/host/xhci.c  | 12 ++--
 drivers/usb/host/xhci.h  | 10 ++
 5 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index eb009a457fb5..b016d38199f2 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -203,12 +203,12 @@ void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num)
addr, (unsigned int)temp);
 
addr = ir_set-erst_base;
-   temp_64 = xhci_read_64(xhci, addr);
+   temp_64 = readq(addr);
xhci_dbg(xhci,   %p: ir_set.erst_base = @%08llx\n,
addr, temp_64);
 
addr = ir_set-erst_dequeue;
-   temp_64 = xhci_read_64(xhci, addr);
+   temp_64 = readq(addr);
xhci_dbg(xhci,   %p: ir_set.erst_dequeue = @%08llx\n,
addr, temp_64);
 }
@@ -412,7 +412,7 @@ void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci)
 {
u64 val;
 
-   val = xhci_read_64(xhci, xhci-op_regs-cmd_ring);
+   val = readq(xhci-op_regs-cmd_ring);
xhci_dbg(xhci, // xHC command ring deq ptr low bits + flags = @%08x\n,
lower_32_bits(val));
xhci_dbg(xhci, // xHC command ring deq ptr high bits = @%08x\n,
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index bce4391a0e7d..4b87026f8a5a 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1958,7 +1958,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
xhci_warn(xhci, WARN something wrong with SW event ring 
dequeue ptr.\n);
/* Update HC event ring dequeue pointer */
-   temp = xhci_read_64(xhci, xhci-ir_set-erst_dequeue);
+   temp = readq(xhci-ir_set-erst_dequeue);
temp = ERST_PTR_MASK;
/* Don't clear the EHB bit (which is RW1C) because
 * there might be more events to service.
@@ -2312,7 +2312,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
(unsigned long long)xhci-cmd_ring-first_seg-dma);
 
/* Set the address in the Command Ring Control register */
-   val_64 = xhci_read_64(xhci, xhci-op_regs-cmd_ring);
+   val_64 = readq(xhci-op_regs-cmd_ring);
val_64 = (val_64  (u64) CMD_RING_RSVD_BITS) |
(xhci-cmd_ring-first_seg-dma  (u64) ~CMD_RING_RSVD_BITS) |
xhci-cmd_ring-cycle_state;
@@ -2396,7 +2396,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
// Set ERST base address for ir_set 0 = 0x%llx,
(unsigned long long)xhci-erst.erst_dma_addr);
-   val_64 = xhci_read_64(xhci, xhci-ir_set-erst_base);
+   val_64 = readq(xhci-ir_set-erst_base);
val_64 = ERST_PTR_MASK;
val_64 |= (xhci-erst.erst_dma_addr  (u64) ~ERST_PTR_MASK);
xhci_write_64(xhci, val_64, xhci-ir_set-erst_base);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index bc46cce46db8..339733b8524a 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -313,7 +313,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
return 0;
}
 
-   temp_64 = xhci_read_64(xhci, xhci-op_regs-cmd_ring);
+   temp_64 = readq(xhci-op_regs-cmd_ring);
if (!(temp_64  CMD_RING_RUNNING)) {
xhci_dbg(xhci, Command ring had been stopped\n);
return 0;
@@ -2871,7 +2871,7 @@ hw_died:
/* Clear the event handler busy flag (RW1C);
 * the event ring should be empty.
 */
-   temp_64 = xhci_read_64(xhci, xhci-ir_set-erst_dequeue);
+   temp_64 = readq(xhci-ir_set-erst_dequeue);
xhci_write_64(xhci, temp_64 | ERST_EHB,
xhci-ir_set-erst_dequeue);
spin_unlock(xhci-lock);
@@ -2885,7 +2885,7 @@ hw_died:
 */
while (xhci_handle_event(xhci)  0) {}
 
-   temp_64 = xhci_read_64(xhci, 

[PATCH 07/15] xhci: fix SCT_FOR_CTX(p) macro

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

SCT_FOR_CTX(p) is defined as (((p)  1)  0x7) in which case if we want
to set the stream context type to SCT_SSA_256 i.e 0x7 (although secondary
stream arrays are not yet supported) using this macro definition we will
get actually 0x6 which is not what we want.

This patch fixes the above issue by defining the SCT_FOR_CTX(p) macro as
(((p)  0x7)  1)

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 03c74b7965f8..a33e8b5bf7a2 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -752,7 +752,7 @@ struct xhci_stream_ctx {
 };
 
 /* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */
-#defineSCT_FOR_CTX(p)  (((p)  1)  0x7)
+#defineSCT_FOR_CTX(p)  (((p)  0x7)  1)
 /* Secondary stream array type, dequeue pointer is to a transfer ring */
 #defineSCT_SEC_TR  0
 /* Primary stream array type, dequeue pointer is to a transfer ring */
-- 
1.8.3.3

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


[PATCH 08/15] xhci: remove unnecessary check in xhci_free_stream_info()

2013-12-02 Thread Sarah Sharp
From: Xenia Ragiadakou burzalod...@gmail.com

This patch removes the unneccessary check 'if (stream_info)' because
there is already a check few lines above which ensures that stream_info
is not NULL.

Signed-off-by: Xenia Ragiadakou burzalod...@gmail.com
Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
---
 drivers/usb/host/xhci-mem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 90709cf45ee5..1445e08819cf 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -722,8 +722,7 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
stream_info-stream_ctx_array,
stream_info-ctx_array_dma);
 
-   if (stream_info)
-   kfree(stream_info-stream_rings);
+   kfree(stream_info-stream_rings);
kfree(stream_info);
 }
 
-- 
1.8.3.3

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


Re: [PATCH 3/5] USB: xHCI: use DEFINE_PCI_DEVICE_TABLE macro

2013-12-02 Thread Sarah Sharp
On Thu, Nov 28, 2013 at 11:08:13AM +0900, Jingoo Han wrote:
 This macro is used to create a struct pci_device_id array.
 
 Signed-off-by: Jingoo Han jg1@samsung.com

Applied to my for-usb-next-queue branch.  It will be queued to Greg's
usb-next branch, and should be merged into 3.14.

Sarah Sharp

 ---
  drivers/usb/host/xhci-pci.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
 index b8dffd5..3f75a32 100644
 --- a/drivers/usb/host/xhci-pci.c
 +++ b/drivers/usb/host/xhci-pci.c
 @@ -357,7 +357,7 @@ static const struct hc_driver xhci_pci_hc_driver = {
  /*-*/
  
  /* PCI driver selection metadata; PCI hotplugging uses this */
 -static const struct pci_device_id pci_ids[] = { {
 +static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { {
   /* handle any USB 3.0 xHCI controller */
   PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
   .driver_data =  (unsigned long) xhci_pci_hc_driver,
 -- 
 1.7.10.4
 
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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_acm crash with multiple USB modems

2013-12-02 Thread Oliver Neukum
On Mon, 2013-12-02 at 21:07 +0100, Johan Hovold wrote:

 This is a Ubuntu-specific kernel and a fairly old one too. Unless you
 can reproduce this problem with a recent kernel such as 3.12.2 from
 kernel.org, you need to ask them about this.

It would be interesting to see this with lockdep enabled.

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 3/5] USB: xHCI: use DEFINE_PCI_DEVICE_TABLE macro

2013-12-02 Thread Jingoo Han
On Tuesday, December 03, 2013 7:26 AM, Sarah Sharp wrote:
 On Thu, Nov 28, 2013 at 11:08:13AM +0900, Jingoo Han wrote:
  This macro is used to create a struct pci_device_id array.
 
  Signed-off-by: Jingoo Han jg1@samsung.com
 
 Applied to my for-usb-next-queue branch.  It will be queued to Greg's
 usb-next branch, and should be merged into 3.14.

(+cc Joe Perches)

Hi Sarah Sharp,

Thank you for your review! :-)
However, this patch should NOT be merged.

According to the Greg Kroah-Hartman,
Yeah, and it's a horrid macro that deserves to be removed, please don't
use it in more places.

Actually, if you could just remove it, that would be best, sorry, I'm
not going to take these patches.

So, I will send the patch to remove 'DEFINE_PCI_DEVICE_TABLE' instead.
Sorry for annoying you. :-)

Best regards,
Jingoo Han

 
 Sarah Sharp
 
  ---
   drivers/usb/host/xhci-pci.c |2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
  diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
  index b8dffd5..3f75a32 100644
  --- a/drivers/usb/host/xhci-pci.c
  +++ b/drivers/usb/host/xhci-pci.c
  @@ -357,7 +357,7 @@ static const struct hc_driver xhci_pci_hc_driver = {
   
  /*-*/
 
   /* PCI driver selection metadata; PCI hotplugging uses this */
  -static const struct pci_device_id pci_ids[] = { {
  +static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { {
  /* handle any USB 3.0 xHCI controller */
  PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
  .driver_data =  (unsigned long) xhci_pci_hc_driver,
  --
  1.7.10.4
 
 
  --
  To unsubscribe from this list: send the line unsubscribe linux-usb in
  the body of a message to majord...@vger.kernel.org
  More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
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 31/39] USB: remove DEFINE_PCI_DEVICE_TABLE macro

2013-12-02 Thread Jingoo Han
Don't use DEFINE_PCI_DEVICE_TABLE macro, because this macro
is not preferred.

Signed-off-by: Jingoo Han jg1@samsung.com
---
 drivers/usb/chipidea/ci_hdrc_pci.c |2 +-
 drivers/usb/dwc3/dwc3-pci.c|2 +-
 drivers/usb/gadget/amd5536udc.c|2 +-
 drivers/usb/gadget/pch_udc.c   |2 +-
 drivers/usb/host/uhci-pci.c|2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c 
b/drivers/usb/chipidea/ci_hdrc_pci.c
index d514332..241ae34 100644
--- a/drivers/usb/chipidea/ci_hdrc_pci.c
+++ b/drivers/usb/chipidea/ci_hdrc_pci.c
@@ -112,7 +112,7 @@ static void ci_hdrc_pci_remove(struct pci_dev *pdev)
  *
  * Check pci.h for details
  */
-static DEFINE_PCI_DEVICE_TABLE(ci_hdrc_pci_id_table) = {
+static const struct pci_device_id ci_hdrc_pci_id_table[] = {
{
PCI_DEVICE(0x153F, 0x1004),
.driver_data = (kernel_ulong_t)pci_platdata,
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 31443ae..665686e 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -182,7 +182,7 @@ static void dwc3_pci_remove(struct pci_dev *pci)
pci_disable_device(pci);
 }
 
-static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = {
+static const struct pci_device_id dwc3_pci_id_table[] = {
{
PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 54a1e29..f0ff4a6 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3338,7 +3338,7 @@ static int udc_remote_wakeup(struct udc *dev)
 }
 
 /* PCI device parameters */
-static DEFINE_PCI_DEVICE_TABLE(pci_id) = {
+static const struct pci_device_id pci_id[] = {
{
PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x2096),
.class =(PCI_CLASS_SERIAL_USB  8) | 0xfe,
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index 32d5e92..78a3d92 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -3210,7 +3210,7 @@ finished:
return retval;
 }
 
-static DEFINE_PCI_DEVICE_TABLE(pch_udc_pcidev_id) = {
+static const struct pci_device_id pch_udc_pcidev_id[] = {
{
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC),
.class = (PCI_CLASS_SERIAL_USB  8) | 0xfe,
diff --git a/drivers/usb/host/uhci-pci.c b/drivers/usb/host/uhci-pci.c
index 4cd7988..940304c 100644
--- a/drivers/usb/host/uhci-pci.c
+++ b/drivers/usb/host/uhci-pci.c
@@ -279,7 +279,7 @@ static const struct hc_driver uhci_driver = {
.hub_control =  uhci_hub_control,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(uhci_pci_ids) = { {
+static const struct pci_device_id uhci_pci_ids[] = { {
/* handle any USB UHCI controller */
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_UHCI, ~0),
.driver_data =  (unsigned long) uhci_driver,
-- 
1.7.10.4


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


Re: xhci regression: usb 3.0 hdd disconnects immediately

2013-12-02 Thread Sarah Sharp
On Sun, Dec 01, 2013 at 09:28:49PM +0100, Lado Kumsiashvili wrote:
 Hi folks.

Hi Lado,

 I have received a new dell precision 4800 with USB 3.0.
 
 I've compiled the gentoo for it. Currently I run
 
 Linux genlap 3.12.1-gentoo #23 SMP Sat Nov 30 19:47:03 CET 2013 x86_64 
 Intel(R) Core(TM) i7-4900MQ CPU @ 2.80GHz GenuineIntel GNU/Linux
 
 
 I have problems connecting my usb 3.0 external drive which works on ubuntu 
 with kernel 
 
 Linux vdr 3.8.0-33-generic #48~precise1-Ubuntu SMP Thu Oct 24 16:28:06 UTC 
 2013 x86_64 x86_64 x86_64 GNU/Linux
 
 
 very well. 

So the 3.8-based kernel works fine, but the 3.12-based kernel doesn't,
correct?

Any chance you can narrow the regression down to at least a kernel
version?  Does 3.11 or 3.10 work?  Looking through the xHCI driver
changes from 3.8 to 3.12, nothing is really jumping out at me that would
have caused this.  It could be changes in the usb-storage or SCSI
layers, though.

 This i what here happens when i connect it to my laptop
 
 
 [19880.463997] usb 2-5: new SuperSpeed USB device number 6 using xhci_hcd
 [19880.475685] usb 2-5: New USB device found, idVendor=152d, idProduct=0539
 [19880.475689] usb 2-5: New USB device strings: Mfr=1, Product=11, 
 SerialNumber=3
 [19880.475690] usb 2-5: Product: USB3.0 Device
 [19880.475692] usb 2-5: Manufacturer: JMicron
 [19880.475693] usb 2-5: SerialNumber: BBA000BF
 [19880.476213] usb 2-5: Set SEL for device-initiated U1 failed.
 [19885.481844] usb 2-5: Set SEL for device-initiated U2 failed.
 [19885.481942] usb-storage 2-5:1.0: USB Mass Storage device detected
 [19885.481994] scsi15 : usb-storage 2-5:1.0
 [19890.487903] usb 2-5: Set SEL for device-initiated U1 failed.
 [19895.493882] usb 2-5: Set SEL for device-initiated U2 failed.
 [19909.699012] zeitgeist-daemo[15893]: segfault at 0 ip 7fc610ad7f0a sp 
 7fffdf12b7c0 error 4 in libglib-2.0.so.0.3800.2[7fc610a51000+126000]
 [19917.931018] usb 2-5: reset SuperSpeed USB device number 6 using xhci_hcd
 [19917.952026] usb 2-5: device descriptor read/8, error -71
 [19918.052803] usb 2-5: reset SuperSpeed USB device number 6 using xhci_hcd
 [19918.074425] usb 2-5: device descriptor read/8, error -71
 [19918.252099] usb 2-5: USB disconnect, device number 6
 [19918.252138] scsi 15:0:0:0: Device offlined - not ready after error recovery
 [19918.252374] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with 
 disabled ep 88041f86a480
 [19918.252377] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with 
 disabled ep 88041f86a4c0

Ok, I need a bit more debugging information to understand what exactly
is happening here.  Please recompile the 3.12 kernel with
CONFIG_USB_DEBUG=y and CONFIG_DYNAMIC_DEBUG=y.  Reboot, mount debugfs
(if it isn't already mounted), and make sure xHCI dynamic debugging is
turned by running this command as root:

echo -n 'module xhci_hcd =p'  /sys/kernel/debug/dynamic_debug/control

That will add a lot more debugging output from the xHCI driver to dmesg.
Please send me the dmesg, from the point just before you plug in your
USB device, to when it disconnects.

If there's nothing in the logs that jumps out at me, the next step would
be to enable CONFIG_USB_STORAGE_DEBUG and see which SCSI command is
causing the device to be reset.

 Pleas check this, thi seems to be the exact same problem, but on ubuntu
 
 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1254261

There's many reasons why a USB device would not respond to device
descriptor requests, and disconnect.  That report is not necessarily
related.

 Is there any problem with usb 3.0 Support newest kernels?

It's probably specific to your USB 3.0 device.  The USB 3.0 mass storage
devices I have work fine on my Intel xHCI host.

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


Re: [PATCH 3/5] USB: xHCI: use DEFINE_PCI_DEVICE_TABLE macro

2013-12-02 Thread Sarah Sharp
On Tue, Dec 03, 2013 at 07:48:30AM +0900, Jingoo Han wrote:
 On Tuesday, December 03, 2013 7:26 AM, Sarah Sharp wrote:
  On Thu, Nov 28, 2013 at 11:08:13AM +0900, Jingoo Han wrote:
   This macro is used to create a struct pci_device_id array.
  
   Signed-off-by: Jingoo Han jg1@samsung.com
  
  Applied to my for-usb-next-queue branch.  It will be queued to Greg's
  usb-next branch, and should be merged into 3.14.
 
 (+cc Joe Perches)
 
 Hi Sarah Sharp,
 
 Thank you for your review! :-)
 However, this patch should NOT be merged.

Ok, no worries, I'll remove this from my queue.

 According to the Greg Kroah-Hartman,
 Yeah, and it's a horrid macro that deserves to be removed, please don't
 use it in more places.
 
 Actually, if you could just remove it, that would be best, sorry, I'm
 not going to take these patches.

Ah, ok.  I assume Greg responded to the cover letter patch for this
patchset, and I missed it?  That's why it's good to Cc everyone in the
cover letter that's Cc'ed on other patches in the set.

 So, I will send the patch to remove 'DEFINE_PCI_DEVICE_TABLE' instead.
 Sorry for annoying you. :-)

In your patch to remove the macro, please make sure to remove the
reference to DEFINE_PCI_DEVICE_TABLE in Documentation/PCI/pci.txt as
well.  I had never run across this macro before, and I trusted the
documentation when it said use of the macro DEFINE_PCI_DEVICE_TABLE is
the preferred method of declaring the table.  That's what I get for
trusting out-of-date documentation, I guess. ;)

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


[PATCH] USB: switch maintainership of chipidea to Peter

2013-12-02 Thread Greg KH
From: Greg Kroah-Hartman gre...@linuxfoundation.org

Alexander isn't able to maintain the Chipidea code anymore, and as Peter
has been acting as the de-facto maintainer anyway, make it official.

Cc: Alexander Shishkin alexander.shish...@linux.intel.com
Cc: Peter Chen peter.c...@freescale.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

---

Alex and Peter, can I get your signed-off-by: or ack for this patch?

diff --git a/MAINTAINERS b/MAINTAINERS
index 4afcfb4c..e3e79afd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2137,7 +2137,7 @@ S:Maintained
 F: Documentation/zh_CN/
 
 CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
-M: Alexander Shishkin alexander.shish...@linux.intel.com
+M: Peter Chen peter.c...@freescale.com
 L: linux-usb@vger.kernel.org
 S: Maintained
 F: drivers/usb/chipidea/
--
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


  1   2   >