Re: [PATCH] 6fire: fix URB transfer buffer for midi output

2013-08-08 Thread Takashi Iwai
At Wed, 7 Aug 2013 13:38:20 -0400 (EDT),
Alan Stern wrote:
 
 On Wed, 7 Aug 2013, Takashi Iwai wrote:
 
  [Cc'ed to linux-usb ML]
  
  At Wed, 7 Aug 2013 16:51:49 +0200,
  Torsten Schenk wrote:
   
   Patch fixes URB transfer buffer allocation for midi output to be DMA-able.
  
  Is this really needed?
  That is, can't a transfer buffer be at middle of kmalloc'ed space, but
  must be always the head of the kmalloc'ed space?
 
 A buffer _can_ be in the middle of a kmalloc'ed space, but the CPU must
 not access any of the fields around it that might occupy the same cache
 line while the buffer is being used for DMA.  In general, it's safest
 not to put any other data in the same kmalloc'ed region with a DMA
 buffer.

Hrm, but does the kmalloc buffer always guarantee such cache line
exclusiveness...?  I thought a simple one like SLOB doesn't care.


   @@ -32,7 +28,7 @@
 struct snd_rawmidi_substream *out;
 struct urb out_urb;
 u8 out_serial; /* serial number of out packet */
   - u8 out_buffer[MIDI_BUFSIZE];
   + u8 *out_buffer;
 int buffer_offset;
 
 In this case, the CPU would access out_urb while out_buffer was in use.

OK, then we need to fix sound/usb/6fire/pcm.c, too.
Torsten, care to respin the patch?


thanks,

Takashi
--
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: [alsa-devel] [PATCH] 6fire: fix URB transfer buffer for midi output

2013-08-08 Thread Takashi Iwai
At Thu, 08 Aug 2013 09:16:27 +0200,
Clemens Ladisch wrote:
 
 Takashi Iwai wrote:
  Alan Stern wrote:
  A buffer _can_ be in the middle of a kmalloc'ed space, but the CPU must
  not access any of the fields around it that might occupy the same cache
  line while the buffer is being used for DMA.
 
  Hrm, but does the kmalloc buffer always guarantee such cache line
  exclusiveness...?  I thought a simple one like SLOB doesn't care.
 
 Documentation/DMA-API-HOWTO.txt says:
 |  Architectures must ensure that kmalloc'ed buffer is
 |  DMA-safe. Drivers and subsystems depend on it. If an architecture
 |  isn't fully DMA-coherent (i.e. hardware doesn't ensure that data in
 |  the CPU cache is identical to data in main memory),
 |  ARCH_DMA_MINALIGN must be set so that the memory allocator
 |  makes sure that kmalloc'ed buffer doesn't share a cache line with
 |  the others.

Ah, good, thanks!


Takashi
--
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: [alsa-devel] [PATCH] 6fire: fix URB transfer buffer for midi output

2013-08-08 Thread Clemens Ladisch
Takashi Iwai wrote:
 Alan Stern wrote:
 A buffer _can_ be in the middle of a kmalloc'ed space, but the CPU must
 not access any of the fields around it that might occupy the same cache
 line while the buffer is being used for DMA.

 Hrm, but does the kmalloc buffer always guarantee such cache line
 exclusiveness...?  I thought a simple one like SLOB doesn't care.

Documentation/DMA-API-HOWTO.txt says:
|  Architectures must ensure that kmalloc'ed buffer is
|  DMA-safe. Drivers and subsystems depend on it. If an architecture
|  isn't fully DMA-coherent (i.e. hardware doesn't ensure that data in
|  the CPU cache is identical to data in main memory),
|  ARCH_DMA_MINALIGN must be set so that the memory allocator
|  makes sure that kmalloc'ed buffer doesn't share a cache line with
|  the others.


Regards,
Clemens
--
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][bugfix] usb/gadget: configfs: keep a function if it is not successfully added

2013-08-08 Thread Andrzej Pietrasiewicz
If usb_add_function() fails then the currently processed function
is already not in the list in struct config_usb_cfg, and neither is it
in the list in struct usb_configuration. At the err_purge_funcs label the
purge_config_funcs() is called, which iterates over all configurations,
and in each configuration it iterates over all _successfully_ added
functions, and moves them back from the list in struct usb_configuration
to the list in struct config_usb_cfg. BUT the function which has just
failed adding and caused the unwind process is not taken care of and
is effectively lost.

This patch modifies the configfs_composite_bind() function so that if
the usb_add_function() fails, then the currently processed function
is returned to the list in struct config_usb_cfg.

It would be tempting to delay the list_del() in question after
usb_add_function() invocation, but a struct list_head (f-list) cannot be
stored in more than one list at the same time, so the list_del() must
be called before usb_add_function(). Hence, the solution is to list_add()
after usb_add_function() in case of error.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/configfs.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index c5d8f81..8cb5006 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -866,8 +866,10 @@ static int configfs_composite_bind(struct usb_gadget 
*gadget,
list_for_each_entry_safe(f, tmp, cfg-func_list, list) {
list_del(f-list);
ret = usb_add_function(c, f);
-   if (ret)
+   if (ret) {
+   list_add(f-list, cfg-func_list);
goto err_purge_funcs;
+   }
}
usb_ep_autoconfig_reset(cdev-gadget);
}
-- 
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: [alsa-devel] [PATCH] Fix invalid volume resolution for Logitech HD Webcam C525

2013-08-08 Thread Takashi Iwai
At Wed, 07 Aug 2013 23:24:46 +0400,
Бойко Максим wrote:
 
 From: Maksim Boyko maksim.a.bo...@gmail.com
 
 Add the volume control quirk for avoiding the kernel warning for Logitech HD 
 Webcam C525.
 The similar patch was previously reported for Logitech HD Webcam C310 (see 
 36691e1be6ec551eef4a5225f126a281f8c051c2).

Your sign-off is missing.  And the patch can't be applied cleanly as
is, likely because your MUA broke the spaces/tabs.

Could you resubmit with the fixes?


thanks,

Takashi


 
 --- linux-3.10.5-orig/sound/usb/mixer.c   2013-08-04 12:51:49.0 
 +0400
 +++ linux-3.10.5/sound/usb/mixer.c2013-08-06 21:12:42.274197287 +0400
 @@ -888,6 +888,7 @@
  case USB_ID(0x046d, 0x081b): /* HD Webcam c310 */
  case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */
  case USB_ID(0x046d, 0x0825): /* HD Webcam c270 */
 + case USB_ID(0x046d, 0x0826): /* HD Webcam c525 */
  case USB_ID(0x046d, 0x0991):
  /* Most audio usb devices lie about volume resolution.
   * Most Logitech webcams have res = 384.
 ___
 Alsa-devel mailing list
 alsa-de...@alsa-project.org
 http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] usb: chipidea: imx: delete the dead code

2013-08-08 Thread Peter Chen
Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index b886998..30fdc2f 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -23,9 +23,6 @@
 #include ci.h
 #include ci_hdrc_imx.h
 
-#define pdev_to_phy(pdev) \
-   ((struct usb_phy *)platform_get_drvdata(pdev))
-
 struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
-- 
1.7.1


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


Re: [RFC 1/2] usb: phy: Add Qualcomm SS-USB and HS-USB drivers for DWC3 core

2013-08-08 Thread Mark Rutland
On Tue, Aug 06, 2013 at 03:36:33PM +0100, Ivan T. Ivanov wrote:
 Hi,
 
 On Tue, 2013-08-06 at 15:03 +0100, Mark Rutland wrote:
  On Tue, Aug 06, 2013 at 12:53:10PM +0100, Ivan T. Ivanov wrote:
   From: Ivan T. Ivanov iiva...@mm-sol.com
  
   Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
   ---
.../devicetree/bindings/usb/msm-ssusb.txt  |   49 +++
drivers/usb/phy/Kconfig|   11 +
drivers/usb/phy/Makefile   |2 +
drivers/usb/phy/phy-msm-dwc3-usb2.c|  342 
   +
drivers/usb/phy/phy-msm-dwc3-usb3.c|  389 
   
5 files changed, 793 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/msm-ssusb.txt
create mode 100644 drivers/usb/phy/phy-msm-dwc3-usb2.c
create mode 100644 drivers/usb/phy/phy-msm-dwc3-usb3.c
  
   diff --git a/Documentation/devicetree/bindings/usb/msm-ssusb.txt 
   b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
   new file mode 100644
   index 000..550b496
   --- /dev/null
   +++ b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
   @@ -0,0 +1,49 @@
   +MSM SuperSpeed USB3.0 SoC controllers
   +
   +Required properities :
   +- compatible sould be qcom,dwc3-usb2;
   +- reg : offset and length of the register set in the memory map
   +- clocks: cxo, usb2a_phy_sleep_cxc;
  
  Huh? That doesn't describe what these are. These would be better
  explained with a reference to clock-names and a basic description as to
  what the input's called, what it drives, etc, as you've done done for
  the *-supply properties.
 
 Ok, I will fix this.
 
  
   +- clock-names: xo, sleep_a_clk;
   +supply-name-supply: phandle to the regulator device tree node
   +Required supply-name examples are:
   +   v1p8 : 1.8v supply for HSPHY
   +   v3p3 : 3.3v supply for HSPHY
   +   vbus : vbus supply for host mode
   +   vddcx : vdd supply for HS-PHY digital circuit operation
   +
   +Required properities :
   +- compatible sould be qcom,dwc3-usb3;
   +- reg : offset and length of the register set in the memory map
   +- clocks: cxo, usb30_mock_utmi_cxc;
  
  Similarly, this doesn't describe what the clocks are.
 
 Understood.
 
  
   +- clock-names: xo, ref_clk;
   +supply-name-supply: phandle to the regulator device tree node
   +Required supply-name examples are:
   +   v1p8 : 1.8v supply for SS-PHY
   +   vddcx : vdd supply for SS-PHY digital circuit operation
   +
   +Example device nodes:
   +
   +   dwc3_usb2: phy@f92f8800 {
   +   compatible = qcom,dwc3-usb2;
   +   reg = 0xf92f8800 0x30;
   +
   +   clocks = cxo, usb2a_phy_sleep_cxc;
   +   clock-names = xo, sleep_a_clk;
   +
   +   vbus-supply = supply;
   +   vddcx-supply = supply;
   +   v1p8-supply = supply;
   +   v3p3-supply = supply;
   +   };
   +
   +   dwc3_usb3: phy@f92f8830 {
   +   compatible = qcom,dwc3-usb3;
   +   reg = 0xf92f8830 0x30;
   +
   +   clocks = cxo, usb30_mock_utmi_cxc;
   +   clock-names = xo, ref_clk;
   +
   +   vddcx-supply = supply;
   +   v1p8-supply = supply;
   +   };
  
  
  Those regster banks look suspiciously close. Are these the same IP
  block? Can they ever appear separately?
  
 
 They are part of the wrapper Qualcomm logic around Synopsys USB3 core.
 In this sense they are part of the one IP, I believe. Manage them from
 separate drivers simplify code.

Hmmm. I'm not entirely certain on this. On the one hand, they're
separate IP blocks, and have lgoically separate drivers, so describing
them as two devices makes sense. On the other hand, they've been fused
into one IP block with shared resources. Describing them as two devices
probably makes sense given you have the wrapper driver.

 
  Do the drivers not trample each other when messing with shared clocks
  and regulators?
  
 
 Regulators and clocks have reference counting, right?, so this should
 be safe. Even if they are part of the one driver, clocks and regulators
 could be switched off only if both PHY's do not use them.

Ok, I just wanted to be sure this had been considered :)

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


[PATCH v2 1/5] usb: chipidea: imx: rename the DT doc name

2013-08-08 Thread Peter Chen
To reflect source file name change

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 .../devicetree/bindings/usb/ci13xxx-imx.txt|   31 
 .../devicetree/bindings/usb/ci_hdrc_imx.txt|   31 
 Documentation/devicetree/bindings/usb/mxs-phy.txt  |   13 
 .../devicetree/bindings/usb/phy-mxs-usb.txt|   13 
 4 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt 
b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
deleted file mode 100644
index b4b5b79..000
--- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-* Freescale i.MX ci13xxx usb controllers
-
-Required properties:
-- compatible: Should be fsl,imx27-usb
-- reg: Should contain registers location and length
-- interrupts: Should contain controller interrupt
-
-Recommended properies:
-- phy_type: the type of the phy connected to the core. Should be one
-  of utmi, utmi_wide, ulpi, serial or hsic. Without this
-  property the PORTSC register won't be touched
-- dr_mode: One of host, peripheral or otg. Defaults to otg
-
-Optional properties:
-- fsl,usbphy: phandler of usb phy that connects to the only one port
-- fsl,usbmisc: phandler of non-core register device, with one argument
-  that indicate usb controller index
-- vbus-supply: regulator for vbus
-- disable-over-current: disable over current detect
-- external-vbus-divider: enables off-chip resistor divider for Vbus
-
-Examples:
-usb@02184000 { /* USB OTG */
-   compatible = fsl,imx6q-usb, fsl,imx27-usb;
-   reg = 0x02184000 0x200;
-   interrupts = 0 43 0x04;
-   fsl,usbphy = usbphy1;
-   fsl,usbmisc = usbmisc 0;
-   disable-over-current;
-   external-vbus-divider;
-};
diff --git a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt 
b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
new file mode 100644
index 000..b4b5b79
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
@@ -0,0 +1,31 @@
+* Freescale i.MX ci13xxx usb controllers
+
+Required properties:
+- compatible: Should be fsl,imx27-usb
+- reg: Should contain registers location and length
+- interrupts: Should contain controller interrupt
+
+Recommended properies:
+- phy_type: the type of the phy connected to the core. Should be one
+  of utmi, utmi_wide, ulpi, serial or hsic. Without this
+  property the PORTSC register won't be touched
+- dr_mode: One of host, peripheral or otg. Defaults to otg
+
+Optional properties:
+- fsl,usbphy: phandler of usb phy that connects to the only one port
+- fsl,usbmisc: phandler of non-core register device, with one argument
+  that indicate usb controller index
+- vbus-supply: regulator for vbus
+- disable-over-current: disable over current detect
+- external-vbus-divider: enables off-chip resistor divider for Vbus
+
+Examples:
+usb@02184000 { /* USB OTG */
+   compatible = fsl,imx6q-usb, fsl,imx27-usb;
+   reg = 0x02184000 0x200;
+   interrupts = 0 43 0x04;
+   fsl,usbphy = usbphy1;
+   fsl,usbmisc = usbmisc 0;
+   disable-over-current;
+   external-vbus-divider;
+};
diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt 
b/Documentation/devicetree/bindings/usb/mxs-phy.txt
deleted file mode 100644
index 5835b27..000
--- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-* Freescale MXS USB Phy Device
-
-Required properties:
-- compatible: Should be fsl,imx23-usbphy
-- reg: Should contain registers location and length
-- interrupts: Should contain phy interrupt
-
-Example:
-usbphy1: usbphy@020c9000 {
-   compatible = fsl,imx6q-usbphy, fsl,imx23-usbphy;
-   reg = 0x020c9000 0x1000;
-   interrupts = 0 44 0x04;
-};
diff --git a/Documentation/devicetree/bindings/usb/phy-mxs-usb.txt 
b/Documentation/devicetree/bindings/usb/phy-mxs-usb.txt
new file mode 100644
index 000..5835b27
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/phy-mxs-usb.txt
@@ -0,0 +1,13 @@
+* Freescale MXS USB Phy Device
+
+Required properties:
+- compatible: Should be fsl,imx23-usbphy
+- reg: Should contain registers location and length
+- interrupts: Should contain phy interrupt
+
+Example:
+usbphy1: usbphy@020c9000 {
+   compatible = fsl,imx6q-usbphy, fsl,imx23-usbphy;
+   reg = 0x020c9000 0x1000;
+   interrupts = 0 44 0x04;
+};
-- 
1.7.1


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


[PATCH v2 2/5] usb: chipidea: usbmisc_imx: Using regmap to access register

2013-08-08 Thread Peter Chen
Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/usbmisc_imx.c |   71 +---
 1 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index ac5a461..545efbf 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -15,6 +15,7 @@
 #include linux/err.h
 #include linux/io.h
 #include linux/delay.h
+#include linux/regmap.h
 
 #include ci_hdrc_imx.h
 
@@ -34,10 +35,10 @@
 
 struct imx_usbmisc {
void __iomem *base;
-   spinlock_t lock;
struct clk *clk;
struct usbmisc_usb_device usbdev[USB_DEV_MAX];
const struct usbmisc_ops *ops;
+   struct regmap *regmap;
 };
 
 static struct imx_usbmisc *usbmisc;
@@ -66,21 +67,16 @@ static struct usbmisc_usb_device *get_usbdev(struct device 
*dev)
 static int usbmisc_imx25_post(struct device *dev)
 {
struct usbmisc_usb_device *usbdev;
-   void __iomem *reg;
-   unsigned long flags;
-   u32 val;
 
usbdev = get_usbdev(dev);
if (IS_ERR(usbdev))
return PTR_ERR(usbdev);
 
-   reg = usbmisc-base + MX25_USB_PHY_CTRL_OFFSET;
-
if (usbdev-evdo) {
-   spin_lock_irqsave(usbmisc-lock, flags);
-   val = readl(reg);
-   writel(val | MX25_BM_EXTERNAL_VBUS_DIVIDER, reg);
-   spin_unlock_irqrestore(usbmisc-lock, flags);
+   regmap_update_bits(usbmisc-regmap,
+   MX25_USB_PHY_CTRL_OFFSET,
+   MX25_BM_EXTERNAL_VBUS_DIVIDER,
+   MX25_BM_EXTERNAL_VBUS_DIVIDER);
usleep_range(5000, 1); /* needed to stabilize voltage */
}
 
@@ -90,37 +86,33 @@ static int usbmisc_imx25_post(struct device *dev)
 static int usbmisc_imx53_init(struct device *dev)
 {
struct usbmisc_usb_device *usbdev;
-   void __iomem *reg = NULL;
-   unsigned long flags;
-   u32 val = 0;
+   unsigned int reg = 0, val = 0;
 
usbdev = get_usbdev(dev);
if (IS_ERR(usbdev))
return PTR_ERR(usbdev);
 
if (usbdev-disable_oc) {
-   spin_lock_irqsave(usbmisc-lock, flags);
switch (usbdev-index) {
case 0:
-   reg = usbmisc-base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
-   val = readl(reg) | MX53_BM_OVER_CUR_DIS_OTG;
+   reg = MX53_USB_OTG_PHY_CTRL_0_OFFSET;
+   val = MX53_BM_OVER_CUR_DIS_OTG;
break;
case 1:
-   reg = usbmisc-base + MX53_USB_OTG_PHY_CTRL_0_OFFSET;
-   val = readl(reg) | MX53_BM_OVER_CUR_DIS_H1;
+   reg = MX53_USB_OTG_PHY_CTRL_0_OFFSET;
+   val = MX53_BM_OVER_CUR_DIS_H1;
break;
case 2:
-   reg = usbmisc-base + MX53_USB_UH2_CTRL_OFFSET;
-   val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+   reg = MX53_USB_UH2_CTRL_OFFSET;
+   val = MX53_BM_OVER_CUR_DIS_UHx;
break;
case 3:
-   reg = usbmisc-base + MX53_USB_UH3_CTRL_OFFSET;
-   val = readl(reg) | MX53_BM_OVER_CUR_DIS_UHx;
+   reg = MX53_USB_UH3_CTRL_OFFSET;
+   val = MX53_BM_OVER_CUR_DIS_UHx;
break;
}
-   if (reg  val)
-   writel(val, reg);
-   spin_unlock_irqrestore(usbmisc-lock, flags);
+   if (usbdev-index = 0  usbdev-index = 3)
+   regmap_update_bits(usbmisc-regmap, reg, val, val);
}
 
return 0;
@@ -128,22 +120,15 @@ static int usbmisc_imx53_init(struct device *dev)
 
 static int usbmisc_imx6q_init(struct device *dev)
 {
-
struct usbmisc_usb_device *usbdev;
-   unsigned long flags;
-   u32 reg;
 
usbdev = get_usbdev(dev);
if (IS_ERR(usbdev))
return PTR_ERR(usbdev);
 
-   if (usbdev-disable_oc) {
-   spin_lock_irqsave(usbmisc-lock, flags);
-   reg = readl(usbmisc-base + usbdev-index * 4);
-   writel(reg | MX6_BM_OVER_CUR_DIS,
-   usbmisc-base + usbdev-index * 4);
-   spin_unlock_irqrestore(usbmisc-lock, flags);
-   }
+   if (usbdev-disable_oc)
+   regmap_update_bits(usbmisc-regmap, usbdev-index * 4,
+   MX6_BM_OVER_CUR_DIS, MX6_BM_OVER_CUR_DIS);
 
return 0;
 }
@@ -177,6 +162,12 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
 
+static struct regmap_config usbmisc_regmap_config = {
+   .reg_bits = 32,
+   .val_bits = 32,
+   .reg_stride = 4,
+};
+

[PATCH v2 0/5] usb: chipidea: delete usbmisc_imx

2013-08-08 Thread Peter Chen
At former design, both ci13xxx_imx and usbmisc_imx are individual
module, ci13xxx_imx is glue layer for imx usb driver. usbmisc_imx
handles non-core registers which have different register layout
for imx SoC serials, it usually supplies interface for wakeup
setting, PHY setting, etc.

usbmisc_imx uses symbols from ci_hdrc_imx, So, when we combile both
of drivers as loadable module, usbmisc is needed to be unload first.
However at ci_hdrc_imx, it needs to call usbmisc_imx's interface
at its removal function once we enable wakeup/runtime pm function, so
keeping two drivers together will not work at loadable module use case.

To fix loadable module use case, we need to build usbmisc_imx and
ci_hdrc_imx together as one module, the usbmisc_imx still handles
misc setting for controllers.

The first one of this serial has no relateship with this topic, but
it is related to rename file, and the other patches will use the new
file name, so I hope they can be queued together.

Peter Chen (5):
  usb: chipidea: imx: rename the DT doc name
  usb: chipidea: usbmisc_imx: Using regmap to access register
  usb: chipidea: imx: build ci_hdrc_imx.c and usbmisc_imx.c together
  arm: dts: imx: add aliases for usb
  arm: dts: imx: Delete usbmisc_imx

 .../devicetree/bindings/usb/ci13xxx-imx.txt|   31 ---
 .../devicetree/bindings/usb/ci_hdrc_imx.txt|   35 +++
 Documentation/devicetree/bindings/usb/mxs-phy.txt  |   13 --
 .../devicetree/bindings/usb/phy-mxs-usb.txt|   13 ++
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 --
 arch/arm/boot/dts/imx23.dtsi   |1 +
 arch/arm/boot/dts/imx25.dtsi   |   14 +-
 arch/arm/boot/dts/imx28.dtsi   |2 +
 arch/arm/boot/dts/imx51.dtsi   |   20 +-
 arch/arm/boot/dts/imx53.dtsi   |   20 +-
 arch/arm/boot/dts/imx6qdl.dtsi |   20 +-
 drivers/usb/chipidea/ci_hdrc_imx.c |  113 +--
 drivers/usb/chipidea/ci_hdrc_imx.h |   28 ++--
 drivers/usb/chipidea/usbmisc_imx.c |  217 +++-
 drivers/usb/chipidea/usbmisc_imx.h |   14 ++
 15 files changed, 201 insertions(+), 354 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
 delete mode 100644 Documentation/devicetree/bindings/usb/mxs-phy.txt
 create mode 100644 Documentation/devicetree/bindings/usb/phy-mxs-usb.txt
 delete mode 100644 Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 create mode 100644 drivers/usb/chipidea/usbmisc_imx.h


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


[PATCH v2 3/5] usb: chipidea: imx: build ci_hdrc_imx.c and usbmisc_imx.c together

2013-08-08 Thread Peter Chen
At former design, both ci13xxx_imx and usbmisc_imx are individual
module, ci13xxx_imx is glue layer for imx usb driver. usbmisc_imx
handles non-core registers which have different register layout
for imx SoC serials, it usually supplies interface for wakeup
setting, PHY setting, etc.

usbmisc_imx uses symbols from ci_hdrc_imx, So, when we combile both
of drivers as loadable module, usbmisc is needed to be unload first.
However at ci_hdrc_imx, it needs to call usbmisc_imx's interface
at its removal function once we enable wakeup/runtime pm function, so
keeping two drivers together will not work at loadable module use case.

To fix loadable module use case, we need to build usbmisc_imx and
ci_hdrc_imx together as one module, the usbmisc_imx still handles
misc setting for controllers.

There is a short discussion for it:
http://marc.info/?l=linux-usbm=136861599423172w=2

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c |  113 +++---
 drivers/usb/chipidea/ci_hdrc_imx.h |   28 +++---
 drivers/usb/chipidea/usbmisc_imx.c |  186 +++-
 drivers/usb/chipidea/usbmisc_imx.h |   14 +++
 4 files changed, 98 insertions(+), 243 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 30fdc2f..be7c86f 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -19,68 +19,68 @@
 #include linux/dma-mapping.h
 #include linux/usb/chipidea.h
 #include linux/clk.h
+#include linux/mfd/syscon.h
 
 #include ci.h
 #include ci_hdrc_imx.h
+#include usbmisc_imx.h
 
-struct ci_hdrc_imx_data {
-   struct usb_phy *phy;
-   struct platform_device *ci_pdev;
-   struct clk *clk;
+static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
+   {
+   .compatible = fsl,imx25-usb,
+   .data = imx25_usbmisc_data,
+   },
+   {
+   .compatible = fsl,imx53-usb,
+   .data = imx53_usbmisc_data,
+   },
+   {
+   .compatible = fsl,imx6q-usb,
+   .data = imx6q_usbmisc_data,
+   },
+   { /* sentinel */ }
 };
+MODULE_DEVICE_TABLE(of, ci_hdrc_imx_dt_ids);
 
-static const struct usbmisc_ops *usbmisc_ops;
-
-/* Common functions shared by usbmisc drivers */
-
-int usbmisc_set_ops(const struct usbmisc_ops *ops)
-{
-   if (usbmisc_ops)
-   return -EBUSY;
-
-   usbmisc_ops = ops;
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(usbmisc_set_ops);
-
-void usbmisc_unset_ops(const struct usbmisc_ops *ops)
-{
-   usbmisc_ops = NULL;
-}
-EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
-
-int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
*usbdev)
+static int usbmisc_init(struct device *dev)
 {
struct device_node *np = dev-of_node;
-   struct of_phandle_args args;
+   struct ci_hdrc_imx_data *data = dev_get_drvdata(dev);
int ret;
+   const struct of_device_id *of_id =
+   of_match_device(ci_hdrc_imx_dt_ids, dev);
 
-   usbdev-dev = dev;
+   if (of_id-data)
+   data-misc_data = (struct usbmisc_data *)of_id-data;
+   else
+   dev_dbg(dev, no usbmisc data\n);
 
-   ret = of_parse_phandle_with_args(np, fsl,usbmisc, #index-cells,
-   0, args);
-   if (ret) {
-   dev_err(dev, Failed to parse property fsl,usbmisc, errno %d\n,
-   ret);
-   memset(usbdev, 0, sizeof(*usbdev));
+   ret = of_alias_get_id(np, usb);
+   if (ret  0) {
+   dev_err(dev, failed to get alias id, errno %d\n, ret);
return ret;
}
-   usbdev-index = args.args[0];
-   of_node_put(args.np);
 
if (of_find_property(np, disable-over-current, NULL))
-   usbdev-disable_oc = 1;
+   data-disable_oc = 1;
 
if (of_find_property(np, external-vbus-divider, NULL))
-   usbdev-evdo = 1;
+   data-evdo = 1;
+
+   /* Currently, the usbmisc only handles non core register stuffs */
+   if (!data-misc_data)
+   return 0;
+
+   data-regmap = syscon_regmap_lookup_by_phandle
+   (np, ci,noncore);
+   if (IS_ERR(data-regmap)) {
+   dev_err(dev, can't find non-core regmap: %ld\n,
+   PTR_ERR(data-regmap));
+   return PTR_ERR(data-regmap);
+   }
 
return 0;
 }
-EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
-
-/* End of common functions shared by usbmisc drivers*/
-
 static int ci_hdrc_imx_probe(struct platform_device *pdev)
 {
struct ci_hdrc_imx_data *data;
@@ -93,10 +93,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
};
int ret;
 
-   if (of_find_property(pdev-dev.of_node, fsl,usbmisc, NULL)
-!usbmisc_ops)
-   return -EPROBE_DEFER;
-
data = devm_kzalloc(pdev-dev, 

[PATCH v2 4/5] arm: dts: imx: add aliases for usb

2013-08-08 Thread Peter Chen
At imx usb driver, it needs to know the controller id to access
register.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 arch/arm/boot/dts/imx23.dtsi   |1 +
 arch/arm/boot/dts/imx28.dtsi   |2 ++
 arch/arm/boot/dts/imx51.dtsi   |4 
 arch/arm/boot/dts/imx53.dtsi   |4 
 arch/arm/boot/dts/imx6qdl.dtsi |4 
 5 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 587ceef..a0d8471 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -20,6 +20,7 @@
gpio2 = gpio2;
serial0 = auart0;
serial1 = auart1;
+   usb0 = usb0;
};
 
cpus {
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 9524a05..931be9c 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -29,6 +29,8 @@
serial4 = auart4;
ethernet0 = mac0;
ethernet1 = mac1;
+   usb0 = usb0;
+   usb1 = usb1;
};
 
cpus {
diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
index 25764b5..67f114c 100644
--- a/arch/arm/boot/dts/imx51.dtsi
+++ b/arch/arm/boot/dts/imx51.dtsi
@@ -22,6 +22,10 @@
gpio1 = gpio2;
gpio2 = gpio3;
gpio3 = gpio4;
+   usb0 = usbotg;
+   usb1 = usbh1;
+   usb2 = usbh2;
+   usb3 = usbh3;
};
 
tzic: tz-interrupt-controller@e000 {
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 569aa9f..429a16f 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -30,6 +30,10 @@
i2c0 = i2c1;
i2c1 = i2c2;
i2c2 = i2c3;
+   usb0 = usbotg;
+   usb1 = usbh1;
+   usb2 = usbh2;
+   usb3 = usbh3;
};
 
tzic: tz-interrupt-controller@0fffc000 {
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index f21d259..be1811c 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -26,6 +26,10 @@
gpio4 = gpio5;
gpio5 = gpio6;
gpio6 = gpio7;
+   usb0 = usbotg;
+   usb1 = usbh1;
+   usb2 = usbh2;
+   usb3 = usbh3;
};
 
intc: interrupt-controller@00a01000 {
-- 
1.7.1


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


Re: [PATCH 1/3 v5] usb: phy-samsung-usb: Simplify PMU register handling

2013-08-08 Thread Mark Rutland
On Wed, Aug 07, 2013 at 06:06:05PM +0100, Julius Werner wrote:
  This breaks compatibility, both for an old kernel and a new dt and a new
  kernel with an old dt. Is anyone using these bindings?
 
 They only affect Samsung SoCs and have only been upstream for half a
 year, so I doubt it's heavily used.

I'm not sure everyone will be happy with that line.

 
  Why are we describing fewer registers now? Are they described elsewhere?
 
  The dt should describe the device, not only the portion of it Linux
  wants to use right now.
 
 This only ever described a small section of the huge set of PMU
 registers anyway. Before it described up to three registers
 controlling different PHYs (using hardcoded offsets in the code to
 later find the right one)... with my patch every PHY's DT entry only
 describes the one register concerning itself, which makes more sense
 in my opinion. It will also prevent the register descriptions in
 different DT entries from overlapping.
 

I'm not sure I understand. The old documentation referred to the
USBDEVICE_PHY_CONTROL and USBHOST_PHY_CONTROL registers for a phy, and
your new version only refers to (usb device) PHY_CONTROL. Regardless of
multiple phys, you're suggesting that we describe less of each phy.
That seems like taking away usable information. Unless I've
misunderstood?

Ideally, we'd describe the whole set of registers and linkages to phys,
even if Linux doesn't ahppen to use that information right now.

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


[PATCH v2 5/5] arm: dts: imx: Delete usbmisc_imx

2013-08-08 Thread Peter Chen
Since ci_hdrc_imx and usbmisc_imx has relationship between each other,
they can't be existed as two modules. We change the code, and make
the usbmisc_imx has no longer a driver.

Due to above reason, we introduce non core register phandle to know
the non core register, and delete the binding doc from usbmisc_imx as well.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 .../devicetree/bindings/usb/ci_hdrc_imx.txt|   12 
 .../devicetree/bindings/usb/usbmisc-imx.txt|   14 --
 arch/arm/boot/dts/imx25.dtsi   |   14 +-
 arch/arm/boot/dts/imx51.dtsi   |   16 +++-
 arch/arm/boot/dts/imx53.dtsi   |   16 +++-
 arch/arm/boot/dts/imx6qdl.dtsi |   16 +++-
 6 files changed, 34 insertions(+), 54 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt 
b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
index b4b5b79..56d94cb 100644
--- a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
@@ -1,4 +1,4 @@
-* Freescale i.MX ci13xxx usb controllers
+* Freescale i.MX chipidea usb controllers
 
 Required properties:
 - compatible: Should be fsl,imx27-usb
@@ -13,8 +13,7 @@ Recommended properies:
 
 Optional properties:
 - fsl,usbphy: phandler of usb phy that connects to the only one port
-- fsl,usbmisc: phandler of non-core register device, with one argument
-  that indicate usb controller index
+- ci,noncore: phandler of non-core register node
 - vbus-supply: regulator for vbus
 - disable-over-current: disable over current detect
 - external-vbus-divider: enables off-chip resistor divider for Vbus
@@ -25,7 +24,12 @@ usb@02184000 { /* USB OTG */
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
fsl,usbphy = usbphy1;
-   fsl,usbmisc = usbmisc 0;
+   ci,noncore = noncore;
disable-over-current;
external-vbus-divider;
 };
+
+noncore: usb-non-core@02184800 {
+compatible = fsl,imx-usb-non-core, syscon;
+reg = 0x02184800 0x200;
+};
diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
deleted file mode 100644
index 97ce94e..000
--- a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-* Freescale i.MX non-core registers
-
-Required properties:
-- #index-cells: Cells used to descibe usb controller index. Should be 1
-- compatible: Should be one of below:
-   fsl,imx6q-usbmisc for imx6q
-- reg: Should contain registers location and length
-
-Examples:
-usbmisc@02184800 {
-   #index-cells = 1;
-   compatible = fsl,imx6q-usbmisc;
-   reg = 0x02184800 0x200;
-};
diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
index 7011539..a09251b 100644
--- a/arch/arm/boot/dts/imx25.dtsi
+++ b/arch/arm/boot/dts/imx25.dtsi
@@ -460,7 +460,7 @@
interrupts = 37;
clocks = clks 9, clks 70, clks 8;
clock-names = ipg, ahb, per;
-   fsl,usbmisc = usbmisc 0;
+   ci,noncore = noncore;
status = disabled;
};
 
@@ -470,17 +470,13 @@
interrupts = 35;
clocks = clks 9, clks 70, clks 8;
clock-names = ipg, ahb, per;
-   fsl,usbmisc = usbmisc 1;
+   ci,noncore = noncore;
status = disabled;
};
 
-   usbmisc: usbmisc@53ff4600 {
-   #index-cells = 1;
-   compatible = fsl,imx25-usbmisc;
-   clocks = clks 9, clks 70, clks 8;
-   clock-names = ipg, ahb, per;
-   reg = 0x53ff4600 0x00f;
-   status = disabled;
+   noncore: usb-non-core@53ff4600 {
+compatible = fsl,imx-usb-non-core, syscon;
+reg = 0x53ff4600 0xf;
};
 
dryice@53ffc000 {
diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
index 67f114c..8e55499 100644
--- a/arch/arm/boot/dts/imx51.dtsi
+++ b/arch/arm/boot/dts/imx51.dtsi
@@ -191,7 +191,7 @@
reg = 0x73f8 0x0200;
interrupts = 18;
clocks = clks 108;
-   fsl,usbmisc = usbmisc 0;
+   ci,noncore = noncore;
fsl,usbphy = usbphy0;
status = disabled;

Re: [PATCH 1/3 v5] usb: phy-samsung-usb: Simplify PMU register handling

2013-08-08 Thread Vivek Gautam
On Thu, Aug 8, 2013 at 2:56 PM, Mark Rutland mark.rutl...@arm.com wrote:
 On Wed, Aug 07, 2013 at 06:06:05PM +0100, Julius Werner wrote:
  This breaks compatibility, both for an old kernel and a new dt and a new
  kernel with an old dt. Is anyone using these bindings?

 They only affect Samsung SoCs and have only been upstream for half a
 year, so I doubt it's heavily used.

 I'm not sure everyone will be happy with that line.


  Why are we describing fewer registers now? Are they described elsewhere?
 
  The dt should describe the device, not only the portion of it Linux
  wants to use right now.

 This only ever described a small section of the huge set of PMU
 registers anyway. Before it described up to three registers
 controlling different PHYs (using hardcoded offsets in the code to
 later find the right one)... with my patch every PHY's DT entry only
 describes the one register concerning itself, which makes more sense
 in my opinion. It will also prevent the register descriptions in
 different DT entries from overlapping.


 I'm not sure I understand. The old documentation referred to the
 USBDEVICE_PHY_CONTROL and USBHOST_PHY_CONTROL registers for a phy, and
 your new version only refers to (usb device) PHY_CONTROL. Regardless of
 multiple phys, you're suggesting that we describe less of each phy.
 That seems like taking away usable information. Unless I've
 misunderstood?

Just giving some pointers here:

As also mentioned in the documentation for samsung-usbphy, SoCs prior
to exynos4x had only one PMU
register handling power to the PHYs (USB 2.0 phy to be specific).
Exynos4x SoCs also had USB 2.0 PHY only
but device and host PHYs' power was being handled by two registers
namely - USBDEVICE_PHY_CONTROL and
USBHOST_PHY_CONTROL.

Exynos5x series of SoCs now have USB 2.0 type PHY (both device and
host PHY are power-handled by only one register)
and USB 3.0 type PHY (having a separate PMU register to handle power
to PHY); so in a total of two registers but both
handling entirely separate PHYs.

So, samsung-usb2 phy driver should be interacting with only one PMU
register (with an exception for exynos4x)
and furthermore samsung-usb3phy driver interact with its separate PMU register.

Sylwester,
Please correct me if i am wrong somewhere.


 Ideally, we'd describe the whole set of registers and linkages to phys,
 even if Linux doesn't ahppen to use that information right now.

 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



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


[PULL] Moxa UPort firmware

2013-08-08 Thread Andrew Lunn
Hi Ben, David

Here is a pull request for firmware for Moxa USB-Serial hub devices.

Thanks
Andrew

The following changes since commit 931e4469dc254df66a2c990ff1a8723685759eb4:

  radeon: add ucode for KABINI GPUs (2013-07-28 22:39:47 +0100)

are available in the git repository at:

  https://github.com/lunn/linux-firmware.git moxa

for you to fetch changes up to 6eed67a9f372a5ade30431af9af0aff8df6f678f:

  moxa: Add firmware for some of the Moxa USB-Serial hubs (2013-08-08 12:04:52 
+0200)


Andrew Lunn (1):
  moxa: Add firmware for some of the Moxa USB-Serial hubs

 WHENCE|   32 
 moxa/moxa-04e2.fw |  Bin 0 - 33681 bytes
 moxa/moxa-04e3.fw |  Bin 0 - 33685 bytes
 moxa/moxa-0582.fw |  Bin 0 - 33521 bytes
 moxa/moxa-05aa.fw |  Bin 0 - 33521 bytes
 moxa/moxa-05ab.fw |  Bin 0 - 33525 bytes
 moxa/moxa-064d.fw |  Bin 0 - 33529 bytes
 moxa/moxa-0652.fw |  Bin 0 - 33525 bytes
 moxa/moxa-0675.fw |  Bin 0 - 33529 bytes
 moxa/moxa-067a.fw |  Bin 0 - 33525 bytes
 10 files changed, 32 insertions(+)
 create mode 100644 moxa/moxa-04e2.fw
 create mode 100644 moxa/moxa-04e3.fw
 create mode 100644 moxa/moxa-0582.fw
 create mode 100644 moxa/moxa-05aa.fw
 create mode 100644 moxa/moxa-05ab.fw
 create mode 100644 moxa/moxa-064d.fw
 create mode 100644 moxa/moxa-0652.fw
 create mode 100644 moxa/moxa-0675.fw
 create mode 100644 moxa/moxa-067a.fw
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 5/5] arm: dts: imx: Delete usbmisc_imx

2013-08-08 Thread Sascha Hauer
On Thu, Aug 08, 2013 at 03:33:01PM +0800, Peter Chen wrote:
 Since ci_hdrc_imx and usbmisc_imx has relationship between each other,
 they can't be existed as two modules. We change the code, and make
 the usbmisc_imx has no longer a driver.
 
 Due to above reason, we introduce non core register phandle to know
 the non core register, and delete the binding doc from usbmisc_imx as well.
 
 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  .../devicetree/bindings/usb/ci_hdrc_imx.txt|   12 
  .../devicetree/bindings/usb/usbmisc-imx.txt|   14 --
  arch/arm/boot/dts/imx25.dtsi   |   14 +-
  arch/arm/boot/dts/imx51.dtsi   |   16 +++-
  arch/arm/boot/dts/imx53.dtsi   |   16 +++-
  arch/arm/boot/dts/imx6qdl.dtsi |   16 +++-
  6 files changed, 34 insertions(+), 54 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt 
 b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
 index b4b5b79..56d94cb 100644
 --- a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
 +++ b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
 @@ -1,4 +1,4 @@
 -* Freescale i.MX ci13xxx usb controllers
 +* Freescale i.MX chipidea usb controllers
  
  Required properties:
  - compatible: Should be fsl,imx27-usb
 @@ -13,8 +13,7 @@ Recommended properies:
  
  Optional properties:
  - fsl,usbphy: phandler of usb phy that connects to the only one port
 -- fsl,usbmisc: phandler of non-core register device, with one argument
 -  that indicate usb controller index
 +- ci,noncore: phandler of non-core register node
  - vbus-supply: regulator for vbus
  - disable-over-current: disable over current detect
  - external-vbus-divider: enables off-chip resistor divider for Vbus
 @@ -25,7 +24,12 @@ usb@02184000 { /* USB OTG */
   reg = 0x02184000 0x200;
   interrupts = 0 43 0x04;
   fsl,usbphy = usbphy1;
 - fsl,usbmisc = usbmisc 0;
 + ci,noncore = noncore;
   disable-over-current;
   external-vbus-divider;
  };
 +
 +noncore: usb-non-core@02184800 {
 +  compatible = fsl,imx-usb-non-core, syscon;
 +  reg = 0x02184800 0x200;
 +};
 diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
 b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 deleted file mode 100644
 index 97ce94e..000
 --- a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
 +++ /dev/null
 @@ -1,14 +0,0 @@
 -* Freescale i.MX non-core registers
 -
 -Required properties:
 -- #index-cells: Cells used to descibe usb controller index. Should be 1
 -- compatible: Should be one of below:
 - fsl,imx6q-usbmisc for imx6q
 -- reg: Should contain registers location and length
 -
 -Examples:
 -usbmisc@02184800 {
 - #index-cells = 1;
 - compatible = fsl,imx6q-usbmisc;
 - reg = 0x02184800 0x200;
 -};
 diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
 index 7011539..a09251b 100644
 --- a/arch/arm/boot/dts/imx25.dtsi
 +++ b/arch/arm/boot/dts/imx25.dtsi
 @@ -460,7 +460,7 @@
   interrupts = 37;
   clocks = clks 9, clks 70, clks 8;
   clock-names = ipg, ahb, per;
 - fsl,usbmisc = usbmisc 0;
 + ci,noncore = noncore;
   status = disabled;
   };
  
 @@ -470,17 +470,13 @@
   interrupts = 35;
   clocks = clks 9, clks 70, clks 8;
   clock-names = ipg, ahb, per;
 - fsl,usbmisc = usbmisc 1;
 + ci,noncore = noncore;
   status = disabled;
   };
  
 - usbmisc: usbmisc@53ff4600 {
 - #index-cells = 1;
 - compatible = fsl,imx25-usbmisc;
 - clocks = clks 9, clks 70, clks 8;
 - clock-names = ipg, ahb, per;
 - reg = 0x53ff4600 0x00f;
 - status = disabled;
 + noncore: usb-non-core@53ff4600 {
 +  compatible = fsl,imx-usb-non-core, syscon;
 +  reg = 0x53ff4600 0xf;
   };

This is bullshit for multiple reasons.

It's the usbmisc unit that changes between different SoCs, not the
chipidea core. So pretending the usbmisc unit is generic by removing the
SoC specific compatible and instead leaking in the SoC type from the
chipidea device nodes is just crazy.

What you are doing here is to model the DT after how the Linux driver is
programmed. This really is a bad idea. Remember that the bindings have
to be OS agnostic. They can't be changed just because you want to
resolve your module 

[PATCH] usb: phy: nop: Prepare clocks as well as enabling them

2013-08-08 Thread Mark Brown
From: Mark Brown broo...@linaro.org

Systems with the common clock API need clk_prepare() as well as the enable
step.

Signed-off-by: Mark Brown broo...@linaro.org
---
 drivers/usb/phy/phy-nop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-nop.c
index f52b7f8..6988c15 100644
--- a/drivers/usb/phy/phy-nop.c
+++ b/drivers/usb/phy/phy-nop.c
@@ -80,7 +80,7 @@ static int nop_init(struct usb_phy *phy)
}
 
if (!IS_ERR(nop-clk))
-   clk_enable(nop-clk);
+   clk_prepare_enable(nop-clk);
 
if (!IS_ERR(nop-reset)) {
/* De-assert RESET */
@@ -102,7 +102,7 @@ static void nop_shutdown(struct usb_phy *phy)
}
 
if (!IS_ERR(nop-clk))
-   clk_disable(nop-clk);
+   clk_disable_unprepare(nop-clk);
 
if (!IS_ERR(nop-vcc)) {
if (regulator_disable(nop-vcc))
-- 
1.8.4.rc1

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


Re: [PATCH v2 5/5] arm: dts: imx: Delete usbmisc_imx

2013-08-08 Thread Peter Chen
On Thu, Aug 08, 2013 at 12:38:59PM +0200, Sascha Hauer wrote:
 On Thu, Aug 08, 2013 at 03:33:01PM +0800, Peter Chen wrote:
  Since ci_hdrc_imx and usbmisc_imx has relationship between each other,
  they can't be existed as two modules. We change the code, and make
  the usbmisc_imx has no longer a driver.
  
  Due to above reason, we introduce non core register phandle to know
  the non core register, and delete the binding doc from usbmisc_imx as well.
  
  Signed-off-by: Peter Chen peter.c...@freescale.com
  ---
   .../devicetree/bindings/usb/ci_hdrc_imx.txt|   12 
   .../devicetree/bindings/usb/usbmisc-imx.txt|   14 --
   arch/arm/boot/dts/imx25.dtsi   |   14 +-
   arch/arm/boot/dts/imx51.dtsi   |   16 +++-
   arch/arm/boot/dts/imx53.dtsi   |   16 +++-
   arch/arm/boot/dts/imx6qdl.dtsi |   16 +++-
   6 files changed, 34 insertions(+), 54 deletions(-)
  
  diff --git a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt 
  b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
  index b4b5b79..56d94cb 100644
  --- a/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
  +++ b/Documentation/devicetree/bindings/usb/ci_hdrc_imx.txt
  @@ -1,4 +1,4 @@
  -* Freescale i.MX ci13xxx usb controllers
  +* Freescale i.MX chipidea usb controllers
   
   Required properties:
   - compatible: Should be fsl,imx27-usb
  @@ -13,8 +13,7 @@ Recommended properies:
   
   Optional properties:
   - fsl,usbphy: phandler of usb phy that connects to the only one port
  -- fsl,usbmisc: phandler of non-core register device, with one argument
  -  that indicate usb controller index
  +- ci,noncore: phandler of non-core register node
   - vbus-supply: regulator for vbus
   - disable-over-current: disable over current detect
   - external-vbus-divider: enables off-chip resistor divider for Vbus
  @@ -25,7 +24,12 @@ usb@02184000 { /* USB OTG */
  reg = 0x02184000 0x200;
  interrupts = 0 43 0x04;
  fsl,usbphy = usbphy1;
  -   fsl,usbmisc = usbmisc 0;
  +   ci,noncore = noncore;
  disable-over-current;
  external-vbus-divider;
   };
  +
  +noncore: usb-non-core@02184800 {
  +compatible = fsl,imx-usb-non-core, syscon;
  +reg = 0x02184800 0x200;
  +};
  diff --git a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt 
  b/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
  deleted file mode 100644
  index 97ce94e..000
  --- a/Documentation/devicetree/bindings/usb/usbmisc-imx.txt
  +++ /dev/null
  @@ -1,14 +0,0 @@
  -* Freescale i.MX non-core registers
  -
  -Required properties:
  -- #index-cells: Cells used to descibe usb controller index. Should be 1
  -- compatible: Should be one of below:
  -   fsl,imx6q-usbmisc for imx6q
  -- reg: Should contain registers location and length
  -
  -Examples:
  -usbmisc@02184800 {
  -   #index-cells = 1;
  -   compatible = fsl,imx6q-usbmisc;
  -   reg = 0x02184800 0x200;
  -};
  diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
  index 7011539..a09251b 100644
  --- a/arch/arm/boot/dts/imx25.dtsi
  +++ b/arch/arm/boot/dts/imx25.dtsi
  @@ -460,7 +460,7 @@
  interrupts = 37;
  clocks = clks 9, clks 70, clks 8;
  clock-names = ipg, ahb, per;
  -   fsl,usbmisc = usbmisc 0;
  +   ci,noncore = noncore;
  status = disabled;
  };
   
  @@ -470,17 +470,13 @@
  interrupts = 35;
  clocks = clks 9, clks 70, clks 8;
  clock-names = ipg, ahb, per;
  -   fsl,usbmisc = usbmisc 1;
  +   ci,noncore = noncore;
  status = disabled;
  };
   
  -   usbmisc: usbmisc@53ff4600 {
  -   #index-cells = 1;
  -   compatible = fsl,imx25-usbmisc;
  -   clocks = clks 9, clks 70, clks 8;
  -   clock-names = ipg, ahb, per;
  -   reg = 0x53ff4600 0x00f;
  -   status = disabled;
  +   noncore: usb-non-core@53ff4600 {
  +compatible = fsl,imx-usb-non-core, syscon;
  +reg = 0x53ff4600 0xf;
  };
 
 This is bullshit for multiple reasons.
 
 It's the usbmisc unit that changes between different SoCs, not the
 chipidea core. So pretending the usbmisc unit is generic by removing the
 SoC specific compatible and instead leaking in the SoC type from the
 chipidea device nodes is just crazy.
 

Please do not call usbmisc as unit, it should not be a driver, it is
a lib, it is usbmisc-lib to implement functions for 

Linux USB power delivery

2013-08-08 Thread Rajaram R
Hi All

Can someone share thoughts if there is a work in progress or plan on
USB power delivery support for Linux  ?

Rajaram
--
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 0/4] USB USBNET: loose SG check and support usbnet DMA SG

2013-08-08 Thread Ming Lei
Hi,

This patchset allows drivers to pass sg buffers which size can't be divided
by max packet size of endpoint if the host controllers(such ax xHCI) support
this kind of sg buffers.

Previously we added check[1] on the situation and don't allow these sg buffers
passed to USB HCD, looks the check is too strict to make use of new feature of
new hardware(xHCI) for some applications(such as network stack) which can't
provide this kind of sg buffers to usbnet driver, so the patch looses the check
in case that the host controller supports it.

Patch 3/4 implements DMA SG on usbnet driver, and patch 4/4 uses it on 
ax88179_178a
USB3 NIC for supporting TSO, so both CPU utilization and tx throughput can be
improved with TSO and DMA SG in case of the USB NIC is attached to xHCI 
controller.

This patchset depends on both net-next and usb-next tree, so hope David and Greg
to figure out one elegent way to merge it.

[1], 
http://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-nextid=10e232c597ac757e7f8600649f7e872e86de190f

V4:
- don't set NETIF_F_SG | NETIF_F_TSO in reset() callback
as pointed out by Eric(only 4/4 changed)

V3:
- save 3 lines code for usb_device_no_sg_constraint() as suggested by 
Alan
- fix urb-sg leak in xmit failure path

V2:
- add missed kfree(urb-sg) in 3/4
- rename no_sg_limit as no_sg_constraint as suggested by Alan

V1:
- introduce and apply usb_device_no_sg_limit() helper as suggested by 
Greg
- simplify patch 4/4 against Eric Dumazet's patch(ax88179_178a: avoid 
copy of tx tcp packets)
- don't pass usbnet header as sg buffer

 drivers/net/usb/ax88179_178a.c |8 +++
 drivers/net/usb/usbnet.c   |   45 +---
 drivers/usb/core/urb.c |3 ++-
 drivers/usb/host/xhci.c|4 
 include/linux/usb.h|8 ++-
 include/linux/usb/usbnet.h |1 +
 6 files changed, 64 insertions(+), 5 deletions(-)



Thanks,
--
Ming Lei

--
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 2/4] USB: XHCI: mark no_sg_constraint

2013-08-08 Thread Ming Lei
This patch marks all xHCI controllers as no_sg_constraint
since xHCI supports building packet from discontinuous buffers.

Cc: Alan Stern st...@rowland.harvard.edu
Acked-by: Sarah Sharp sarah.a.sh...@linux.intel.com
Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/usb/host/xhci.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2c49f00..6e2ac57 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4841,6 +4841,10 @@ int xhci_gen_setup(struct usb_hcd *hcd, 
xhci_get_quirks_t get_quirks)
 
/* Accept arbitrarily long scatter-gather lists */
hcd-self.sg_tablesize = ~0;
+
+   /* support to build packet from discontinuous buffers */
+   hcd-self.no_sg_constraint = 1;
+
/* XHCI controllers don't stop the ep queue on short packets :| */
hcd-self.no_stop_on_short = 1;
 
-- 
1.7.9.5

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


[PATCH v4 3/4] USBNET: support DMA SG

2013-08-08 Thread Ming Lei
This patch introduces support of DMA SG if the USB host controller
which usbnet device is attached to is capable of building packet from
discontinuous buffers.

The patch supports passing the skb fragment buffers to usb stack directly
via urb-sg.

Cc: Eric Dumazet eric.duma...@gmail.com
Cc: Ben Hutchings bhutchi...@solarflare.com
Cc: Grant Grundler grund...@google.com
Cc: Freddy Xin fre...@asix.com.tw
Cc: Alan Stern st...@rowland.harvard.edu
Acked-by: Oliver Neukum oneu...@suse.de
Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/usbnet.c   |   45 +---
 include/linux/usb/usbnet.h |1 +
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index e4811d7..534b60b 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1232,6 +1232,37 @@ EXPORT_SYMBOL_GPL(usbnet_tx_timeout);
 
 /*-*/
 
+static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
+{
+   unsigned num_sgs, total_len = 0;
+   int i, s = 0;
+
+   num_sgs = skb_shinfo(skb)-nr_frags + 1;
+   if (num_sgs == 1)
+   return 0;
+
+   urb-sg = kmalloc(num_sgs * sizeof(struct scatterlist), GFP_ATOMIC);
+   if (!urb-sg)
+   return -ENOMEM;
+
+   urb-num_sgs = num_sgs;
+   sg_init_table(urb-sg, urb-num_sgs);
+
+   sg_set_buf(urb-sg[s++], skb-data, skb_headlen(skb));
+   total_len += skb_headlen(skb);
+
+   for (i = 0; i  skb_shinfo(skb)-nr_frags; i++) {
+   struct skb_frag_struct *f = skb_shinfo(skb)-frags[i];
+
+   total_len += skb_frag_size(f);
+   sg_set_page(urb-sg[i + s], f-page.p, f-size,
+   f-page_offset);
+   }
+   urb-transfer_buffer_length = total_len;
+
+   return 1;
+}
+
 netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
 struct net_device *net)
 {
@@ -1258,7 +1289,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
goto drop;
}
}
-   length = skb-len;
 
if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
netif_dbg(dev, tx_err, dev-net, no urb\n);
@@ -1268,10 +1298,14 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
entry = (struct skb_data *) skb-cb;
entry-urb = urb;
entry-dev = dev;
-   entry-length = length;
 
usb_fill_bulk_urb (urb, dev-udev, dev-out,
skb-data, skb-len, tx_complete, skb);
+   if (dev-can_dma_sg) {
+   if (build_dma_sg(skb, urb)  0)
+   goto drop;
+   }
+   entry-length = length = urb-transfer_buffer_length;
 
/* don't assume the hardware handles USB_ZERO_PACKET
 * NOTE:  strictly conforming cdc-ether devices should expect
@@ -1340,7 +1374,10 @@ drop:
 not_drop:
if (skb)
dev_kfree_skb_any (skb);
-   usb_free_urb (urb);
+   if (urb) {
+   kfree(urb-sg);
+   usb_free_urb(urb);
+   }
} else
netif_dbg(dev, tx_queued, dev-net,
   tx, len %d, type 0x%x\n, length, skb-protocol);
@@ -1391,6 +1428,7 @@ static void usbnet_bh (unsigned long param)
rx_process (dev, skb);
continue;
case tx_done:
+   kfree(entry-urb-sg);
case rx_cleanup:
usb_free_urb (entry-urb);
dev_kfree_skb (skb);
@@ -1727,6 +1765,7 @@ int usbnet_resume (struct usb_interface *intf)
retval = usb_submit_urb(res, GFP_ATOMIC);
if (retval  0) {
dev_kfree_skb_any(skb);
+   kfree(res-sg);
usb_free_urb(res);
usb_autopm_put_interface_async(dev-intf);
} else {
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 8fbc008..9cb2fe8 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -35,6 +35,7 @@ struct usbnet {
unsigned char   suspend_count;
unsigned char   pkt_cnt, pkt_err;
unsigned short  rx_qlen, tx_qlen;
+   unsignedcan_dma_sg:1;
 
/* i/o info: pipes etc */
unsignedin, out;
-- 
1.7.9.5

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


[PATCH v4 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma

2013-08-08 Thread Ming Lei
This patch enables 'can_dma_sg' flag for ax88179_178a device
if the attached host controller supports building packet from
discontinuous buffers(DMA SG is possible), so TSO can be enabled
and skb fragment buffers can be passed to usb stack via urb-sg
directly.

With the patch, system CPU utilization decreased ~50% and throughput
increased by ~10% when doing iperf client test on one ARM A15 dual
core board.

Cc: Eric Dumazet eric.duma...@gmail.com
Cc: Ben Hutchings bhutchi...@solarflare.com
Cc: Grant Grundler grund...@google.com
Cc: Oliver Neukum oneu...@suse.de
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Freddy Xin fre...@asix.com.tw
Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/ax88179_178a.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index fb0caa2..3569293 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1031,12 +1031,20 @@ static int ax88179_bind(struct usbnet *dev, struct 
usb_interface *intf)
dev-mii.phy_id = 0x03;
dev-mii.supports_gmii = 1;
 
+   if (usb_device_no_sg_constraint(dev-udev))
+   dev-can_dma_sg = 1;
+
dev-net-features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
  NETIF_F_RXCSUM;
 
dev-net-hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
 NETIF_F_RXCSUM;
 
+   if (dev-can_dma_sg) {
+   dev-net-features |= NETIF_F_SG | NETIF_F_TSO;
+   dev-net-hw_features |= NETIF_F_SG | NETIF_F_TSO;
+   }
+
/* Enable checksum offload */
*tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
   AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6;
-- 
1.7.9.5

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


[PATCH v4 1/4] USB: introduce usb_device_no_sg_constraint() helper

2013-08-08 Thread Ming Lei
Some host controllers(such as xHCI) can support building
packet from discontinuous buffers, so introduce one flag
and helper for this kind of host controllers, then the
feature can help some applications(such as usbnet) by
supporting arbitrary length of sg buffers.

Acked-by: Alan Stern st...@rowland.harvard.edu
Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/usb/core/urb.c |3 ++-
 include/linux/usb.h|8 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index e75115a..c77ec78 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -414,7 +414,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
urb-iso_frame_desc[n].status = -EXDEV;
urb-iso_frame_desc[n].actual_length = 0;
}
-   } else if (dev-speed != USB_SPEED_WIRELESS  urb-num_sgs) {
+   } else if (urb-num_sgs  !urb-dev-bus-no_sg_constraint 
+   dev-speed != USB_SPEED_WIRELESS) {
struct scatterlist *sg;
int i;
 
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 84f14e2..bbd2c8d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -337,6 +337,7 @@ struct usb_bus {
 * the ep queue on a short transfer
 * with the URB_SHORT_NOT_OK flag set.
 */
+   unsigned no_sg_constraint:1;/* no sg constraint */
unsigned sg_tablesize;  /* 0 or largest number of sg list 
entries */
 
int devnum_next;/* Next open device number in
@@ -684,6 +685,11 @@ static inline bool usb_device_supports_ltm(struct 
usb_device *udev)
return udev-bos-ss_cap-bmAttributes  USB_LTM_SUPPORT;
 }
 
+static inline bool usb_device_no_sg_constraint(struct usb_device *udev)
+{
+   return udev  udev-bus  udev-bus-no_sg_constraint;
+}
+
 
 /*-*/
 
@@ -1249,7 +1255,7 @@ typedef void (*usb_complete_t)(struct urb *);
  * transfer_buffer.
  * @sg: scatter gather buffer list, the buffer size of each element in
  * the list (except the last) must be divisible by the endpoint's
- * max packet size
+ * max packet size if no_sg_constraint isn't set in 'struct usb_bus'
  * @num_mapped_sgs: (internal) number of mapped sg entries
  * @num_sgs: number of entries in the sg list
  * @transfer_buffer_length: How big is transfer_buffer.  The transfer may
-- 
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: Linux USB power delivery

2013-08-08 Thread Sarah Sharp
I've heard there's little to do at the software level, but I haven't
been following the spec closely.  Are you volunteering to add support?

Sarah Sharp

On Thu, Aug 08, 2013 at 06:16:54PM +0530, Rajaram R wrote:
 Hi All
 
 Can someone share thoughts if there is a work in progress or plan on
 USB power delivery support for Linux  ?
 
 Rajaram
--
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] UWB: fix sysfs warning on HWA device unplug.

2013-08-08 Thread Thomas Pugliese
In the disconnect routine for the hwa_hc interface, it calls 
uwb_pal_unregister to unregister itself from the UWB subsystem.  This 
function attempts to clean up the link to the host controller directory in 
the device's UWB radio control interface directory.  If the disconnect 
routine for the radio control interface has already run, the uwb directory 
will be gone so the call to sysfs_remove_link generates a warning.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com

diff --git a/drivers/uwb/pal.c b/drivers/uwb/pal.c
index 690577d..c1304b8 100644
--- a/drivers/uwb/pal.c
+++ b/drivers/uwb/pal.c
@@ -68,8 +68,40 @@ int uwb_pal_register(struct uwb_pal *pal)
 }
 EXPORT_SYMBOL_GPL(uwb_pal_register);
 
+static int find_rc(struct device *dev, const void *data)
+{
+   const struct uwb_rc *target_rc = data;
+   struct uwb_rc *rc = dev_get_drvdata(dev);
+
+   if (rc == NULL) {
+   WARN_ON(1);
+   return 0;
+   }
+   if (rc == target_rc) {
+   if (rc-ready == 0)
+   return 0;
+   else
+   return 1;
+   }
+   return 0;
+}
+
+/**
+ * Given a radio controller descriptor see if it is registered.
+ *
+ * @returns false if the rc does not exist or is quiescing; true otherwise.
+ */
+static bool uwb_rc_class_device_exists(struct uwb_rc *target_rc)
+{
+   struct device *dev;
+
+   dev = class_find_device(uwb_rc_class, NULL, target_rc, find_rc);
+
+   return (dev != NULL);
+}
+
 /**
- * uwb_pal_register - unregister a UWB PAL
+ * uwb_pal_unregister - unregister a UWB PAL
  * @pal: the PAL
  */
 void uwb_pal_unregister(struct uwb_pal *pal)
@@ -85,7 +117,11 @@ void uwb_pal_unregister(struct uwb_pal *pal)
debugfs_remove(pal-debugfs_dir);
 
if (pal-device) {
-   sysfs_remove_link(rc-uwb_dev.dev.kobj, pal-name);
+   /* remove link to the PAL in the UWB device's directory. */
+   if (uwb_rc_class_device_exists(rc))
+   sysfs_remove_link(rc-uwb_dev.dev.kobj, pal-name);
+
+   /* remove link to uwb_rc in the PAL device's directory. */
sysfs_remove_link(pal-device-kobj, uwb_rc);
}
 }
--
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: FUSB200 xhci issue

2013-08-08 Thread Oleksij Rempel

Am 31.07.2013 08:52, schrieb Oleksij Rempel:

Am 28.07.2013 22:41, schrieb Christian Lamparter:

On Sunday, July 28, 2013 04:28:25 PM Oleksij Rempel wrote:

Am 28.07.2013 14:12, schrieb Oleksij Rempel:

Am 28.07.2013 13:38, schrieb Christian Lamparter:


before  rmmod.

Oh, I it was on the latest wireless-testing. (And the ath9k_htc
module
had the patch ath9k_htc: reboot firmwware if it was loaded).

Furthermore, I did the same test with one of the ehci-only ports
and it worked. Both, devices (one had a AR7015, the other a AR9271)
came back after autosuspend there.


Grrr... so it brings us back to xhci issue. Even EP4 workaround wont
work here :( Suddenly i have no more ideas.

Sarah, it's your turn now.


Christian,
can you please provide some more info about your xhci controller. I'll
try to get me same.


Well, it's a laptop (HP DV6-6003EG). I recon that getting 100% the
same setup will be difficult. However, since the uPD720200 was/is
very popular, it should be very easy to find one. [It's probably
on all of these 10 euro usb-3.0 pcie-adapters. So as long as you
got a free 1x-pcie port you should be good.]

Here's the lspci summary:

19:00.0 USB controller [0c03]: NEC Corporation uPD720200 USB 3.0 Host
Controller [1033:0194] (rev 04) (prog-if 30 [XHCI])
 Subsystem: Hewlett-Packard Company Device [103c:1657]
 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx+
 Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast
TAbort- TAbort- MAbort- SERR- PERR- INTx-
 Latency: 0, Cache Line Size: 64 bytes
 Interrupt: pin A routed to IRQ 19
 Region 0: Memory at d340 (64-bit, non-prefetchable)
[size=8K]
 Capabilities: access denied
 Kernel driver in use: xhci_hcd



Thx... i purchased on random on ebay, will see what i get.

I know now why carl9170 don't triggering this bug. Carl uses EP4 as
Interrupt with packet size 64. ath9k-htc initially have EP4=Intr,
Interval=1, but will reconfigure it to Bulk, Interval=0.
It mean, before usb suspend EP4=Bulk, Interval=0 and after resume
EP4=Intr, Inter=?. May be xhci can't handle some thing like this? Or may
be interval stay 0, and xhci will overfill usb buffer on adapter - at
least it looks so.


Christian,
can you please test one more patch. It is working for me, but who knows. 
More testing is never bad idea ;)


--
Regards,
Oleksij
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 5205a36..6f4f39c 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -1053,7 +1053,7 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev)
 == USB_ENDPOINT_XFER_INT) {
 			endp-bmAttributes = ~USB_ENDPOINT_XFERTYPE_MASK;
 			endp-bmAttributes |= USB_ENDPOINT_XFER_BULK;
-			endp-bInterval = 0;
+	//		endp-bInterval = 0;
 		}
 	}
 


Re: [PATCH] net/usb: rtl8150: allocate URB transfer_buffer and setup_packet separately

2013-08-08 Thread Petko Manolov
On Wed, 7 Aug 2013, Jussi Kivilinna wrote:

 rtl8150 allocates URB transfer_buffer and setup_packet as part of same 
 structure 'struct async_req'. This can cause same cacheline to be 
 DMA-mapped twice with same URB. This can lead to memory corruption on 
 some systems.

I can see performance impact due to the double mapping.  However, memory 
corruption seems a bit too much for sane cache and DMA controllers.  Out 
of interest - which is the architecture that will potentially corrupt the 
memory.


cheers,
Petko
--
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


'Siano Mobile Silicon' firmware doesn't load in 3.10.x

2013-08-08 Thread mario tillmann
With the latest kernel 3.10.x I get an error message when loading the firmware
sms1xxx-hcw-55xxx-dvbt-02.fw:

smscore_load_firmware_family2: line: 986: sending
MSG_SMS_DATA_VALIDITY_REQ expecting 0xcfed1755
smscore_onresponse: line: 1565: MSG_SMS_DATA_VALIDITY_RES, checksum = 0xcfed1755

This error is reported for 32/64 bit systems.

If I can assist in debugging, please let me know.
--
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][bugfix] usb/gadget: configfs: keep a function if it is not successfully added

2013-08-08 Thread Sebastian Andrzej Siewior
On 08/08/2013 09:43 AM, Andrzej Pietrasiewicz wrote:
 diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
 index c5d8f81..8cb5006 100644
 --- a/drivers/usb/gadget/configfs.c
 +++ b/drivers/usb/gadget/configfs.c
 @@ -866,8 +866,10 @@ static int configfs_composite_bind(struct usb_gadget 
 *gadget,
   list_for_each_entry_safe(f, tmp, cfg-func_list, list) {
   list_del(f-list);
   ret = usb_add_function(c, f);
 - if (ret)
 + if (ret) {
 + list_add(f-list, cfg-func_list);
   goto err_purge_funcs;
 + }

Since when is this broken? I remember it used to work and
usb_add_function() cleaned up after itself in error case.

   }
   usb_ep_autoconfig_reset(cdev-gadget);
   }
 

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 v4 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma

2013-08-08 Thread Eric Dumazet
On Thu, 2013-08-08 at 21:48 +0800, Ming Lei wrote:
 This patch enables 'can_dma_sg' flag for ax88179_178a device
 if the attached host controller supports building packet from
 discontinuous buffers(DMA SG is possible), so TSO can be enabled
 and skb fragment buffers can be passed to usb stack via urb-sg
 directly.
 
 With the patch, system CPU utilization decreased ~50% and throughput
 increased by ~10% when doing iperf client test on one ARM A15 dual
 core board.
 
 Cc: Eric Dumazet eric.duma...@gmail.com
 Cc: Ben Hutchings bhutchi...@solarflare.com
 Cc: Grant Grundler grund...@google.com
 Cc: Oliver Neukum oneu...@suse.de
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Freddy Xin fre...@asix.com.tw
 Signed-off-by: Ming Lei ming@canonical.com
 ---
  drivers/net/usb/ax88179_178a.c |8 
  1 file changed, 8 insertions(+)

Acked-by: Eric Dumazet eduma...@gmail.com

Thanks for doing this !


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


Re: [PATCH v4 3/4] USBNET: support DMA SG

2013-08-08 Thread Eric Dumazet
On Thu, 2013-08-08 at 21:48 +0800, Ming Lei wrote:
 This patch introduces support of DMA SG if the USB host controller
 which usbnet device is attached to is capable of building packet from
 discontinuous buffers.


 diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
 index 8fbc008..9cb2fe8 100644
 --- a/include/linux/usb/usbnet.h
 +++ b/include/linux/usb/usbnet.h
 @@ -35,6 +35,7 @@ struct usbnet {
   unsigned char   suspend_count;
   unsigned char   pkt_cnt, pkt_err;
   unsigned short  rx_qlen, tx_qlen;
 + unsignedcan_dma_sg:1;

We try to use unsigned int instead of plain unsigned, but its a
minor point and should not block your patches.

Apart from this :

Reviewed-by: Eric Dumazet eduma...@google.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


[PATCH] wusbcore: fix root hub hub_status_data to only return 0 if status has actually changed

2013-08-08 Thread Thomas Pugliese
The hub_status_data function on the wireless USB root hub controller 
(wusbhc_rh_status_data) always returns a positive value even if no ports 
have changed.  This patch updates wusbhc_rh_status_data to only return a 
positive value if the root hub status needs to be queried.  The current 
implementation can also leave the upper bits of the port bitmap 
uninitialized if wusbhc-ports_max is not one less than an even multiple 
of 8.  This patch fixes that as well by initializing the buffer to 0.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com

diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c
index bdb0cc3..fe8bc77 100644
--- a/drivers/usb/wusbcore/rh.c
+++ b/drivers/usb/wusbcore/rh.c
@@ -141,18 +141,26 @@ static int wusbhc_rh_port_reset(struct wusbhc *wusbhc, u8 
port_idx)
 int wusbhc_rh_status_data(struct usb_hcd *usb_hcd, char *_buf)
 {
struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
-   size_t cnt, size;
-   unsigned long *buf = (unsigned long *) _buf;
+   size_t cnt, size, bits_set = 0;
 
/* WE DON'T LOCK, see comment */
-   size = wusbhc-ports_max + 1 /* hub bit */;
-   size = (size + 8 - 1) / 8;  /* round to bytes */
-   for (cnt = 0; cnt  wusbhc-ports_max; cnt++)
-   if (wusb_port_by_idx(wusbhc, cnt)-change)
-   set_bit(cnt + 1, buf);
-   else
-   clear_bit(cnt + 1, buf);
-   return size;
+   /* round up to bytes.  Hub bit is bit 0 so add 1. */
+   size = DIV_ROUND_UP(wusbhc-ports_max + 1, 8);
+
+   /* clear the output buffer. */
+   memset(_buf, 0, size);
+   /* set the bit for each changed port. */
+   for (cnt = 0; cnt  wusbhc-ports_max; cnt++) {
+
+   if (wusb_port_by_idx(wusbhc, cnt)-change) {
+   const int bitpos = cnt+1;
+
+   _buf[bitpos/8] |= (1  (bitpos % 8));
+   bits_set++;
+   }
+   }
+
+   return bits_set ? size : 0;
 }
 EXPORT_SYMBOL_GPL(wusbhc_rh_status_data);
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFT] xhci-plat: Don't enable legacy PCI interrupts.

2013-08-08 Thread Sarah Sharp
Hi Yu,

Please test this patch, and make sure that interrupts aren't registered
twice.  I think this approach is better, since it creates a new quirk
specifically for xhci platform devices, so we can tell them apart from
PCI devices.

Sarah Sharp

8---8

The xHCI platform driver calls into usb_add_hcd to register the irq for
its platform device.  It does not want the xHCI generic driver to
register an interrupt for it at all.  The original code did that by
setting the XHCI_BROKEN_MSI quirk, which tells the xHCI driver to not
enable MSI or MSI-X for a PCI host.

Unfortunately, if CONFIG_PCI is enabled, and CONFIG_USB_DW3 is enabled,
the xHCI generic driver will attempt to register a legacy PCI interrupt
for the xHCI platform device in xhci_try_enable_msi().  This will result
in a bogus irq being registered, since the underlying device is a
platform_device, not a pci_device, and thus the pci_device-irq pointer
will be bogus.

Add a new quirk, XHCI_PLAT, so that the xHCI generic driver can
distinguish between a PCI device that can't handle MSI or MSI-X, and a
platform device that should not have its interrupts touched at all.
This quirk may be useful in the future, in case other corner cases like
this arise.

This patch should be backported to kernels as old as 3.9, that
contain the commit 00eed9c814cb8f281be6f0f5d8f45025dc0a97eb USB: xhci:
correctly enable interrupts.

Signed-off-by: Sarah Sharp sarah.a.sh...@linux.intel.com
Reported-by: Yu Y Wang yu.y.w...@intel.com
Cc: sta...@vger.kernel.org
---
 drivers/usb/host/xhci-plat.c | 2 +-
 drivers/usb/host/xhci.c  | 7 ++-
 drivers/usb/host/xhci.h  | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 51e22bf..6eca5a5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -24,7 +24,7 @@ static void xhci_plat_quirks(struct device *dev, struct 
xhci_hcd *xhci)
 * here that the generic code does not try to make a pci_dev from our
 * dev struct in order to setup MSI
 */
-   xhci-quirks |= XHCI_BROKEN_MSI;
+   xhci-quirks |= XHCI_PLAT;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 9478caa..ead3555 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -343,9 +343,14 @@ static void __maybe_unused xhci_msix_sync_irqs(struct 
xhci_hcd *xhci)
 static int xhci_try_enable_msi(struct usb_hcd *hcd)
 {
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-   struct pci_dev  *pdev = to_pci_dev(xhci_to_hcd(xhci)-self.controller);
+   struct pci_dev  *pdev;
int ret;
 
+   /* The xhci platform device has set up IRQs through usb_add_hcd. */
+   if (xhci-quirks  XHCI_PLAT)
+   return 0;
+
+   pdev = to_pci_dev(xhci_to_hcd(xhci)-self.controller);
/*
 * Some Fresco Logic host controllers advertise MSI, but fail to
 * generate interrupts.  Don't even try to enable MSI.
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index c338741..6ab1e60 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1542,6 +1542,7 @@ struct xhci_hcd {
 #define XHCI_SPURIOUS_REBOOT   (1  13)
 #define XHCI_COMP_MODE_QUIRK   (1  14)
 #define XHCI_AVOID_BEI (1  15)
+#define XHCI_PLAT  (1  16)
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
/* There are two roothubs to keep track of bus suspend info for */
-- 
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 1/3 v5] usb: phy-samsung-usb: Simplify PMU register handling

2013-08-08 Thread Julius Werner
 I'm not sure I understand. The old documentation referred to the
 USBDEVICE_PHY_CONTROL and USBHOST_PHY_CONTROL registers for a phy, and
 your new version only refers to (usb device) PHY_CONTROL. Regardless of
 multiple phys, you're suggesting that we describe less of each phy.
 That seems like taking away usable information. Unless I've
 misunderstood?

Well that's just the thing that's confusing right now, and which I am
trying to fix: every PHY is either DEVICE or HOST and thus has only
one PMU register. The current code describes the PMU register space
for all PHYs on the system in the DT entry of every PHY and then
calculates which register to use with hardcoded offsets. I think it
makes much more sense if every PHY only describes its own register and
doesn't need to do address arithmetic later on.

As Vivek said there is one exception in an old Exynos4, but that is
currently not implemented in the upstream kernel anyway, and if it
ever will be it's still much easier to special case one weird chip
than to have a super complicated and confusing mechanism for all of
them.
--
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: FUSB200 xhci issue

2013-08-08 Thread Christian Lamparter
On Thursday 08 August 2013 17:35:34 Oleksij Rempel wrote:
 Am 31.07.2013 08:52, schrieb Oleksij Rempel:
  Am 28.07.2013 22:41, schrieb Christian Lamparter:
  On Sunday, July 28, 2013 04:28:25 PM Oleksij Rempel wrote:
  Am 28.07.2013 14:12, schrieb Oleksij Rempel:
  Am 28.07.2013 13:38, schrieb Christian Lamparter:
 
  before  rmmod.
  Oh, I it was on the latest wireless-testing. (And the ath9k_htc
  module
  had the patch ath9k_htc: reboot firmwware if it was loaded).
 
  Furthermore, I did the same test with one of the ehci-only ports
  and it worked. Both, devices (one had a AR7015, the other a AR9271)
  came back after autosuspend there.
 
  Grrr... so it brings us back to xhci issue. Even EP4 workaround wont
  work here :( Suddenly i have no more ideas.
 
  Sarah, it's your turn now.
 
  Christian,
  can you please provide some more info about your xhci controller. I'll
  try to get me same.
 
  Well, it's a laptop (HP DV6-6003EG). I recon that getting 100% the
  same setup will be difficult. However, since the uPD720200 was/is
  very popular, it should be very easy to find one. [It's probably
  on all of these 10 euro usb-3.0 pcie-adapters. So as long as you
  got a free 1x-pcie port you should be good.]
 
  Here's the lspci summary:
 
  19:00.0 USB controller [0c03]: NEC Corporation uPD720200 USB 3.0 Host
  Controller [1033:0194] (rev 04) (prog-if 30 [XHCI])
   Subsystem: Hewlett-Packard Company Device [103c:1657]
   Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
  ParErr- Stepping- SERR- FastB2B- DisINTx+
   Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast
  TAbort- TAbort- MAbort- SERR- PERR- INTx-
   Latency: 0, Cache Line Size: 64 bytes
   Interrupt: pin A routed to IRQ 19
   Region 0: Memory at d340 (64-bit, non-prefetchable)
  [size=8K]
   Capabilities: access denied
   Kernel driver in use: xhci_hcd
 
 
  Thx... i purchased on random on ebay, will see what i get.
 
  I know now why carl9170 don't triggering this bug. Carl uses EP4 as
  Interrupt with packet size 64. ath9k-htc initially have EP4=Intr,
  Interval=1, but will reconfigure it to Bulk, Interval=0.
  It mean, before usb suspend EP4=Bulk, Interval=0 and after resume
  EP4=Intr, Inter=?. May be xhci can't handle some thing like this? Or may
  be interval stay 0, and xhci will overfill usb buffer on adapter - at
  least it looks so.
 
 Christian,
 can you please test one more patch. It is working for me, but who knows. 
 More testing is never bad idea ;)

It sort of works, but not without a hiccup: 

I get the following messages when I try to load the driver
again after an autosuspend cycle (ar9271, NEC xhci):

ath: phy6: Reading Magic # failed
ath9k_htc: Failed to Initialize the device
usb 2-1: ath9k_htc: USB layer deinitialized


However, the device is resetted automatically and it
comes back on the second probe attempt.



Anyway, I do have a question about something else too.

in ath9k_htc's hif_usb:

 struct usb_host_interface *alt = hif_dev-interface-altsetting[0];
 struct usb_endpoint_descriptor *endp;
 ...
 /* On downloading the firmware to the target, the USB descriptor of EP4
  * is 'patched' to change the type of the endpoint to Bulk. This will
  * bring down CPU usage during the scan period. */

 for (idx = 0; idx  alt-desc.bNumEndpoints; idx++) {
   endp = alt-endpoint[idx].desc;
   if ((endp-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK) == 
 USB_ENDPOINT_XFER_INT) {
 endp-bmAttributes = ~USB_ENDPOINT_XFERTYPE_MASK;
 endp-bmAttributes |= USB_ENDPOINT_XFER_BULK;
// endp-bInterval = 0;
   }
 }

Alan, can you please tell us, if it is really safe to
override the bmAttributes this way? After all (according to
the comment) the device has morphed (EP4 has changed).

Or, is it necessary for the driver call usb_reset_device
or (usb_reset_configuration) in this case? 

Regards,
   Chr
--
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] HWA: avoid constant suspend and resume on the root hub

2013-08-08 Thread Thomas Pugliese
Prevent the USB core from suspending the HWA root hub since bus_suspend 
and bus_resume are not yet supported.  Otherwise the PM system will chew 
up CPU time constantly attempting to suspend and resume the root hub but 
never succeeding.

Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com

diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index 483990c..02650f7 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -161,6 +161,11 @@ static int hwahc_op_start(struct usb_hcd *usb_hcd)
usb_hcd-uses_new_polling = 1;
set_bit(HCD_FLAG_POLL_RH, usb_hcd-flags);
usb_hcd-state = HC_STATE_RUNNING;
+
+   /* prevent USB core from suspending the root hub since
+* bus_suspend and bus_resume are not yet supported. */
+   pm_runtime_get_noresume(usb_hcd-self.root_hub-dev);
+
result = 0;
 out:
mutex_unlock(wusbhc-mutex);
--
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] net/usb: rtl8150: allocate URB transfer_buffer and setup_packet separately

2013-08-08 Thread Jussi Kivilinna
On 08.08.2013 18:14, Petko Manolov wrote:
 On Wed, 7 Aug 2013, Jussi Kivilinna wrote:
 
 rtl8150 allocates URB transfer_buffer and setup_packet as part of same 
 structure 'struct async_req'. This can cause same cacheline to be 
 DMA-mapped twice with same URB. This can lead to memory corruption on 
 some systems.
 
 I can see performance impact due to the double mapping.  However, memory 
 corruption seems a bit too much for sane cache and DMA controllers.  Out 
 of interest - which is the architecture that will potentially corrupt the 
 memory.

rtlwifi driver had similar structure to allocate both setup_packet and 
transfer_buffer in single go (overlapping dma-mapping cachelines) and this 
caused problems on ARM/sunxi. Problems means: memory corruptions at random 
locations, device freezes and lock-ups.

-Jussi

 
 
 cheers,
 Petko
 

--
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: FUSB200 xhci issue

2013-08-08 Thread Alan Stern
On Thu, 8 Aug 2013, Christian Lamparter wrote:

 Anyway, I do have a question about something else too.
 
 in ath9k_htc's hif_usb:
 
  struct usb_host_interface *alt = hif_dev-interface-altsetting[0];
  struct usb_endpoint_descriptor *endp;
  ...
  /* On downloading the firmware to the target, the USB descriptor of EP4
   * is 'patched' to change the type of the endpoint to Bulk. This will
   * bring down CPU usage during the scan period. */
 
  for (idx = 0; idx  alt-desc.bNumEndpoints; idx++) {
endp = alt-endpoint[idx].desc;
if ((endp-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK) == 
  USB_ENDPOINT_XFER_INT) {
  endp-bmAttributes = ~USB_ENDPOINT_XFERTYPE_MASK;
  endp-bmAttributes |= USB_ENDPOINT_XFER_BULK;
 // endp-bInterval = 0;
}
  }
 
 Alan, can you please tell us, if it is really safe to
 override the bmAttributes this way? After all (according to
 the comment) the device has morphed (EP4 has changed).

This does not look like a good idea.  Why does the driver do it?

 Or, is it necessary for the driver call usb_reset_device
 or (usb_reset_configuration) in this case? 

After loading firmware, a reset generally is necessary.  Some devices 
will do it themselves; others require you to call usb_reset_device().

Alan Stern

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


[RFC V2] usb: rh_call_control tbuf overflow fix

2013-08-08 Thread Sean O. Stalley
rh_call_control() contains a buffer, tbuf, which it uses to hold
USB descriptors. These discriptors are eventually copied into the
transfer_buffer in the URB. The buffer in the URB is dynamically
defined and is always large enough to hold the amount of data it
requests.

tbuf is currently statically allocated on the stack with a size
of 15 bytes, regardless of the size specified in the URB.
This patch dynamically allocates tbuf, and ensures that tbuf is
at least as big as the buffer in the URB.

If an hcd attempts to write a descriptor containing more than
15 bytes ( such as the Standard BOS Descriptor for hubs, defined
in the USB3.0 Spec, section 10.13.1 ) the write would overflow
the buffer and corrupt the stack. This patch addresses this
behavior.

Signed-off-by: Sean O. Stalley sean.stal...@intel.com
---
 drivers/usb/core/hcd.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 014dc99..cee8fb7 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -464,17 +464,13 @@ static int rh_call_control (struct usb_hcd *hcd, struct 
urb *urb)
struct usb_ctrlrequest *cmd;
u16 typeReq, wValue, wIndex, wLength;
u8  *ubuf = urb-transfer_buffer;
-   /*
-* tbuf should be as big as the BOS descriptor and
-* the USB hub descriptor.
-*/
-   u8  tbuf[USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE]
-   __attribute__((aligned(4)));
-   const u8*bufp = tbuf;
unsignedlen = 0;
int status;
u8  patch_wakeup = 0;
u8  patch_protocol = 0;
+   u16 tbuf_size;
+   u8  *tbuf;
+   const u8*bufp;
 
might_sleep();
 
@@ -494,6 +490,18 @@ static int rh_call_control (struct usb_hcd *hcd, struct 
urb *urb)
if (wLength  urb-transfer_buffer_length)
goto error;
 
+   /*
+* tbuf should be at least as big as the
+* USB hub descriptor.
+*/
+   tbuf_size =  max_t(u16, sizeof(struct usb_hub_descriptor), wLength);
+   tbuf = kzalloc(tbuf_size, GFP_KERNEL);
+   if (!tbuf)
+   return -ENOMEM;
+
+   bufp = tbuf;
+
+
urb-actual_length = 0;
switch (typeReq) {
 
@@ -675,6 +683,7 @@ error:
urb-actual_length = len;
// always USB_DIR_IN, toward host
memcpy (ubuf, bufp, len);
+   kfree(tbuf);
 
/* report whether RH hardware supports remote wakeup */
if (patch_wakeup 
-- 
1.8.1.2

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


Re: [RFC V2] usb: rh_call_control tbuf overflow fix

2013-08-08 Thread Alan Stern
On Thu, 8 Aug 2013, Sean O. Stalley wrote:

 rh_call_control() contains a buffer, tbuf, which it uses to hold
 USB descriptors. These discriptors are eventually copied into the
 transfer_buffer in the URB. The buffer in the URB is dynamically
 defined and is always large enough to hold the amount of data it
 requests.
 
 tbuf is currently statically allocated on the stack with a size
 of 15 bytes, regardless of the size specified in the URB.
 This patch dynamically allocates tbuf, and ensures that tbuf is
 at least as big as the buffer in the URB.
 
 If an hcd attempts to write a descriptor containing more than
 15 bytes ( such as the Standard BOS Descriptor for hubs, defined
 in the USB3.0 Spec, section 10.13.1 ) the write would overflow
 the buffer and corrupt the stack. This patch addresses this
 behavior.
 
 Signed-off-by: Sean O. Stalley sean.stal...@intel.com

 @@ -494,6 +490,18 @@ static int rh_call_control (struct usb_hcd *hcd, struct 
 urb *urb)
   if (wLength  urb-transfer_buffer_length)
   goto error;
  
 + /*
 +  * tbuf should be at least as big as the
 +  * USB hub descriptor.
 +  */
 + tbuf_size =  max_t(u16, sizeof(struct usb_hub_descriptor), wLength);
 + tbuf = kzalloc(tbuf_size, GFP_KERNEL);
 + if (!tbuf)
 + return -ENOMEM;
 +
 + bufp = tbuf;
 +
 +
   urb-actual_length = 0;
   switch (typeReq) {
  
 @@ -675,6 +683,7 @@ error:
   urb-actual_length = len;
   // always USB_DIR_IN, toward host
   memcpy (ubuf, bufp, len);
 + kfree(tbuf);
  
   /* report whether RH hardware supports remote wakeup */
   if (patch_wakeup 

This deallocates tbuf when len  0, but it leaks the memory when len is 
0.

Alan Stern

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


Re: [PULL] Moxa UPort firmware

2013-08-08 Thread Ben Hutchings
On Thu, 2013-08-08 at 12:20 +0200, Andrew Lunn wrote:
 Hi Ben, David
 
 Here is a pull request for firmware for Moxa USB-Serial hub devices.
 
 Thanks
   Andrew
 
 The following changes since commit 931e4469dc254df66a2c990ff1a8723685759eb4:
 
   radeon: add ucode for KABINI GPUs (2013-07-28 22:39:47 +0100)
 
 are available in the git repository at:
 
   https://github.com/lunn/linux-firmware.git moxa
 
 for you to fetch changes up to 6eed67a9f372a5ade30431af9af0aff8df6f678f:
 
   moxa: Add firmware for some of the Moxa USB-Serial hubs (2013-08-08 
 12:04:52 +0200)
[...]

Pulled and pushed out, thanks.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.


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


[PATCH] xhci-hub: Roothub USB2.0 descriptor for BESL DBESL

2013-08-08 Thread Alexandra Yates
Modified xHCI roothub descriptor to return USB2.0 extension descriptor
with BESL and DBESL values set when these values are set on the xHCI
host.

Curretnly the root hub device descriptor values are set to zero by the
BIOS. Therefore to test this functionality with lsusb, I hard coded
the usb2_rh_dev_descriptor (not include on patch) to set the bcdUSB
bit to 0x01.

Here is the test output.
$ sudo lsusb -s 01:01 -v
...
Binary Object Store Descriptor:
bLength 5
bDescriptorType15
wTotalLength   12
bNumDeviceCaps  1
USB 2.0 Extension Device Capability:
  bLength 7
  bDescriptorType16
  bDevCapabilityType  2
  bmAttributes   0xff1e
BESL Link Power Management (LPM) Supported
  BESL value 3840 us
  Deep BESL value61440 us
  Device Status: 0x0001
Self Powered

Signed-off-by: Alexandra Yates alexandra.ya...@intel.com
---
 drivers/usb/host/xhci-hub.c |   53 +++
 drivers/usb/host/xhci.h |3 +++
 2 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 1d35459..60601df 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -30,7 +30,7 @@
 PORT_RC | PORT_PLC | PORT_PE)
 
 /* USB 3.0 BOS descriptor and a capability descriptor, combined */
-static u8 usb_bos_descriptor [] = {
+static u8 usb3_bos_descriptor[] = {
USB_DT_BOS_SIZE,/*  __u8 bLength, 5 bytes */
USB_DT_BOS, /*  __u8 bDescriptorType */
0x0F, 0x00, /*  __le16 wTotalLength, 15 bytes */
@@ -47,6 +47,28 @@ static u8 usb_bos_descriptor [] = {
0x00, 0x00  /* __le16 bU2DevExitLat, set later. */
 };
 
+/* USB 3.0 BOS descriptor and a capability descriptor, combined */
+static u8 usb2_bos_descriptor[] = {
+   USB_DT_BOS_SIZE,/*  __u8 bLength, 5 bytes */
+   USB_DT_BOS, /*  __u8 bDescriptorType */
+   0x0c, 0x00, /*  __le16 wTotalLength, 15 bytes */
+   0x1,/*  __u8 bNumDeviceCaps */
+   /* First device capability */
+   USB_DT_USB_EXT_CAP_SIZE,/*  7 bits USB2 ext */
+   USB_DT_DEVICE_CAPABILITY,   /* Device Capability */
+   USB_CAP_TYPE_EXT,   /* DevCapability Type, USB2.0 ext */
+   0x1e,   /* bmAttributes first byte: bit1:LPM
+  Supported, bit2: BESL supported,
+  bit3:valid  baseline BESL, bit4:
+  valid Deep BESL, bits5-7 */
+   0xff,   /* bmAttributes - second byte:
+  8-11bit:BESL and 12-16bit:DBESL*/
+   0x00,   /* bmAttribute - third byte: reserved,
+  must be zero */
+   0x00,   /* bmAttribute - fourth byte: reserved,
+  must be zero */
+};
+
 
 static void xhci_common_hub_descriptor(struct xhci_hcd *xhci,
struct usb_hub_descriptor *desc, int ports)
@@ -577,12 +599,33 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, 
u16 wValue,
if ((wValue  0xff00) != (USB_DT_BOS  8))
goto error;
 
-   if (hcd-speed != HCD_USB3)
+   if (hcd-speed == HCD_USB3) {
+   /* Set the U1 and U2 exit latencies. */
+   memcpy(buf, usb3_bos_descriptor,
+   USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE);
+   } else if (hcd -speed == HCD_USB2) {
+   memcpy(buf, usb2_bos_descriptor,
+   USB_DT_BOS_SIZE + USB_DT_USB_EXT_CAP_SIZE);
+
+/* Set first byte of bmAttributes in the
+ * usb2_bos_descriptor */
+   if (xhci-hw_lpm_support)
+   buf[8] |= USB_LPM_SUPPORT;
+   /* Set the BESL support bit in bmAttributes first
+* byte */
+   if (XHCI_BLC)
+   buf[8] |= USB_BESL_SUPPORT;
+   if (xhci-dbesl) {
+   buf[8] = USB_BESL_DEEP_VALID;
+   buf[9] = xhci-dbesl;
+   }
+   if (xhci-dbesld) {
+   buf[8] = USB_BESL_DEEP_VALID;
+   buf[9] = xhci-dbesl  4;
+   }
+   } else
goto error;
 
-   /* Set the U1 and U2 exit latencies. */
-   memcpy(buf, 

Re: 'Siano Mobile Silicon' firmware doesn't load in 3.10.x

2013-08-08 Thread Greg KH
On Thu, Aug 08, 2013 at 05:52:53PM +0200, mario tillmann wrote:
 With the latest kernel 3.10.x I get an error message when loading the firmware
 sms1xxx-hcw-55xxx-dvbt-02.fw:
 
 smscore_load_firmware_family2: line: 986: sending
 MSG_SMS_DATA_VALIDITY_REQ expecting 0xcfed1755
 smscore_onresponse: line: 1565: MSG_SMS_DATA_VALIDITY_RES, checksum = 
 0xcfed1755
 
 This error is reported for 32/64 bit systems.
 
 If I can assist in debugging, please let me know.

This is a media driver, I would suggest the linux-media mailing list
would know much more than the usb mailing list does (cc:ed).


--
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 v5] usb: phy-samsung-usb: Simplify PMU register handling

2013-08-08 Thread Tomasz Figa
Hi Julius,

On Thursday 08 of August 2013 11:06:54 Julius Werner wrote:
  I'm not sure I understand. The old documentation referred to the
  USBDEVICE_PHY_CONTROL and USBHOST_PHY_CONTROL registers for a phy, and
  your new version only refers to (usb device) PHY_CONTROL. Regardless
  of
  multiple phys, you're suggesting that we describe less of each phy.
  That seems like taking away usable information. Unless I've
  misunderstood?
 
 Well that's just the thing that's confusing right now, and which I am
 trying to fix: every PHY is either DEVICE or HOST and thus has only
 one PMU register. The current code describes the PMU register space
 for all PHYs on the system in the DT entry of every PHY and then
 calculates which register to use with hardcoded offsets. I think it
 makes much more sense if every PHY only describes its own register and
 doesn't need to do address arithmetic later on.
 
 As Vivek said there is one exception in an old Exynos4,

Not that old yet. :)

 but that is
 currently not implemented in the upstream kernel anyway

Sorry, I don't understand what is not implemented. Without your patch, the 
PHY driver handles both PMU registers of Exynos4.

Best regards,
Tomasz

 , and if it
 ever will be it's still much easier to special case one weird chip
 than to have a super complicated and confusing mechanism for all of
 them.
 --
 To unsubscribe from this list: send the line unsubscribe devicetree 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: FUSB200 xhci issue

2013-08-08 Thread Christian Lamparter
On Thursday 08 August 2013 22:19:32 Alan Stern wrote:
 On Thu, 8 Aug 2013, Christian Lamparter wrote:
 
  Anyway, I do have a question about something else too.
  
  in ath9k_htc's hif_usb:
  
   struct usb_host_interface *alt = hif_dev-interface-altsetting[0];
   struct usb_endpoint_descriptor *endp;
   ...
   /* On downloading the firmware to the target, the USB descriptor of EP4
* is 'patched' to change the type of the endpoint to Bulk. This will
* bring down CPU usage during the scan period. */
  
   for (idx = 0; idx  alt-desc.bNumEndpoints; idx++) {
 endp = alt-endpoint[idx].desc;
 if ((endp-bmAttributes  USB_ENDPOINT_XFERTYPE_MASK) == 
   USB_ENDPOINT_XFER_INT) {
   endp-bmAttributes = ~USB_ENDPOINT_XFERTYPE_MASK;
   endp-bmAttributes |= USB_ENDPOINT_XFER_BULK;
  // endp-bInterval = 0;
 }
   }
  
  Alan, can you please tell us, if it is really safe to
  override the bmAttributes this way? After all (according to
  the comment) the device has morphed (EP4 has changed).
 
 This does not look like a good idea.  Why does the driver do it?

Probably because people use ath9k_htc devices with everything that
has some sort of usb port (devkits and embedded systems: Dockstar,
Rasberry Pi, ...) to get wifi connectivity. ...


Yeah. I think we better ask Rajkumar Manoharan 
(before I write more text out of thin air :-D )

commit 4a0e8ecca4eeed38d4b3b7a317a3aaab4dd3cacd
Author: Rajkumar Manoharan rmanoha...@atheros.com
Date:   Tue Sep 14 14:35:55 2010 +0530

ath9k_htc: Fix CPU usage issue during scan period

Does anyone know his Qualcomm Atheros address?
 
  Or, is it necessary for the driver call usb_reset_device
  or (usb_reset_configuration) in this case? 
 
 After loading firmware, a reset generally is necessary.  Some devices 
 will do it themselves; others require you to call usb_reset_device().

This makes things complicated. Because, as far as I remember,
usb_reset_device() will cause the current driver to be unbound
unless its called during .probe, right?

You see, ath9k_htc loads its firmware asynchronously in .probe
(ath9k_htc's .probe routine finishes before the firmware is
retrieved via the firmware loader helper... so part of the
firmware download is done in a firmware_complete callback
on a workqueue). 

So, if we call usb_reset_device there and the driver is unbound
and later rebound. the next ath9k_htc .probe will start again and
again and again not knowing that it is already initialized 
(and we have a loop).


This could be solved, if the devices changes the usb-id again 
when a proper wifi ath9k_htc firmware was downloaded. So, the
driver would know that it doesn't have to download and reset
the device... But we need a free USB-ID for that.

Alan, Oleksij: What do you think?

Regards,
Chr
--
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] xhci-hub: Roothub USB2.0 descriptor for BESL DBESL

2013-08-08 Thread Yates, Alexandra
Ahh! Good point.  Will resend the patch.  :)


Thank you, 

Alexandra. 

-Original Message-
From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-ow...@vger.kernel.org] 
On Behalf Of Greg KH
Sent: Thursday, August 08, 2013 2:12 PM
To: Yates, Alexandra
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] xhci-hub: Roothub USB2.0 descriptor for BESL DBESL

On Thu, Aug 08, 2013 at 02:05:53PM -0700, Alexandra Yates wrote:
 Modified xHCI roothub descriptor to return USB2.0 extension descriptor
 with BESL and DBESL values set when these values are set on the xHCI
 host.

Why would we want this?  What benefit or bug does this fix?

You need to explain why we want to accept this patch, not just what the
patch does.

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


[RFC V3] usb: rh_call_control tbuf overflow fix

2013-08-08 Thread Sean O. Stalley
rh_call_control() contains a buffer, tbuf, which it uses to hold
USB descriptors. These discriptors are eventually copied into the
transfer_buffer in the URB. The buffer in the URB is dynamically
defined and is always large enough to hold the amount of data it
requests.

tbuf is currently statically allocated on the stack with a size
of 15 bytes, regardless of the size specified in the URB.
This patch dynamically allocates tbuf, and ensures that tbuf is
at least as big as the buffer in the URB.

If an hcd attempts to write a descriptor containing more than
15 bytes ( such as the Standard BOS Descriptor for hubs, defined
in the USB3.0 Spec, section 10.13.1 ) the write would overflow
the buffer and corrupt the stack. This patch addresses this
behavior.

Signed-off-by: Sean O. Stalley sean.stal...@intel.com
---
 drivers/usb/core/hcd.c | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 014dc99..88d6e6e 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -464,17 +464,13 @@ static int rh_call_control (struct usb_hcd *hcd, struct 
urb *urb)
struct usb_ctrlrequest *cmd;
u16 typeReq, wValue, wIndex, wLength;
u8  *ubuf = urb-transfer_buffer;
-   /*
-* tbuf should be as big as the BOS descriptor and
-* the USB hub descriptor.
-*/
-   u8  tbuf[USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE]
-   __attribute__((aligned(4)));
-   const u8*bufp = tbuf;
unsignedlen = 0;
int status;
u8  patch_wakeup = 0;
u8  patch_protocol = 0;
+   u16 tbuf_size;
+   u8  *tbuf;
+   const u8*bufp;
 
might_sleep();
 
@@ -494,6 +490,18 @@ static int rh_call_control (struct usb_hcd *hcd, struct 
urb *urb)
if (wLength  urb-transfer_buffer_length)
goto error;
 
+   /*
+* tbuf should be at least as big as the
+* USB hub descriptor.
+*/
+   tbuf_size =  max_t(u16, sizeof(struct usb_hub_descriptor), wLength);
+   tbuf = kzalloc(tbuf_size, GFP_KERNEL);
+   if (!tbuf)
+   return -ENOMEM;
+
+   bufp = tbuf;
+
+
urb-actual_length = 0;
switch (typeReq) {
 
@@ -691,6 +699,8 @@ error:
bDeviceProtocol = USB_HUB_PR_HS_SINGLE_TT;
}
 
+   kfree(tbuf);
+
/* any errors get returned through the urb completion */
spin_lock_irq(hcd_root_hub_lock);
usb_hcd_unlink_urb_from_ep(hcd, urb);
-- 
1.8.1.2

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


Re: [RFC V3] usb: rh_call_control tbuf overflow fix

2013-08-08 Thread Greg KH
Note, I don't apply RFC patches, and rarely review them.  Why are you
claiming that is what this is, when it is in the 3rd version already?

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: [RFC V3] usb: rh_call_control tbuf overflow fix

2013-08-08 Thread Stalley, Sean
My apologies. This is my first attempt at submitting a patch, so I am 
unfamiliar with some of the procedures. I will resend this revision of the 
patch with the proper [PATCH] tag.

-Sean

 -Original Message-
 From: Greg KH [mailto:gre...@linuxfoundation.org]
 Sent: Thursday, August 08, 2013 4:12 PM
 To: Stalley, Sean
 Cc: linux-usb@vger.kernel.org; Sarah Sharp; Ismail, Abdul R
 Subject: Re: [RFC V3] usb: rh_call_control tbuf overflow fix
 
 Note, I don't apply RFC patches, and rarely review them.  Why are you
 claiming that is what this is, when it is in the 3rd version already?
 
 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 v3 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma

2013-08-08 Thread Grant Grundler
Ming,
We are splitting hairs now. :) I want to be clear I think your changes
are good and the rest of this conversation is just to learn something
new.

On Thu, Aug 8, 2013 at 4:48 PM, Ming Lei ming@canonical.com wrote:
 On Fri, Aug 9, 2013 at 1:25 AM, Grant Grundler grund...@google.com wrote:
...
 I am afraid that PCI network devices' setting still won't survive unbound
 re-probed, will they?

 Correct - but PCI isn't as prone to dropping off the bus like USB

 As far as I know, USB device still won't be disconnected easily, and
 reset is possible, but we can make setting survive reset by implementing
 .pre_reset() and .post_reset() callback. Or do you have other situation
 of USB 'dropping off the bus'?

So far only older USB core bugs like this one:
https://codereview.chromium.org/4687002/show

I agree USB won't be disconnected easily.

 is. Master aborts on some PCI systems is a Fatal Exception and AFAIK
 that's never been true for any USB device.

 I mean rmmod  modprobe still can reset setting of one PCI network
 device after powering on the device, can't it?

Definitely. But this isn't something that will randomly happen and
will leave tracks all over the place of it happening. So I'm not
worried about trying to debug this scenario.

thanks,
grant



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


[RFC v2] xhci-hub: Roothub USB2.0 descriptor for BESL DBESL

2013-08-08 Thread Alexandra Yates
Modified the xHCI roothub descriptor to return USB2.0 extension
descriptor Best Effort Service Latency (BESL) and Deep Best Effort
Service Latency (DBESL) values when set on the xHCI host.

On link power management the BESL and DBESL values are used to
estimate L1 exit latency for USB2.0 host and devices. Tools such as
PowerTop and lsusb will use BESL and DBESL values to
monitor LPM L1 exit latency.  Additionally, by presenting the host
controller BESL and DBESL values one could check if the BIOS or
firmware is setting these values correctly.
 
Currently the root hub device descriptor bcdUSB value is set to zero by
the BIOS. Therefore to test this functionality with lsusb, I hard
coded the usb2_rh_dev_descriptor (not include on patch) to:
bcdUSB 0x01.


Alexandra Yates (1):
  xhci-hub: Roothub USB2.0 descriptor for BESL DBESL

 drivers/usb/host/xhci-hub.c |   53 +++
 drivers/usb/host/xhci.h |3 +++
 2 files changed, 51 insertions(+), 5 deletions(-)

-- 
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 v2] xhci-hub: Roothub USB2.0 descriptor for BESL DBESL

2013-08-08 Thread Greg KH
On Thu, Aug 08, 2013 at 05:24:46PM -0700, Alexandra Yates wrote:
 Modified the xHCI roothub descriptor to return USB2.0 extension
 descriptor Best Effort Service Latency (BESL) and Deep Best Effort
 Service Latency (DBESL) values when set on the xHCI host.
 
 On link power management the BESL and DBESL values are used to
 estimate L1 exit latency for USB2.0 host and devices. Tools such as
 PowerTop and lsusb will use BESL and DBESL values to
 monitor LPM L1 exit latency.  Additionally, by presenting the host
 controller BESL and DBESL values one could check if the BIOS or
 firmware is setting these values correctly.
 
 Currently the root hub device descriptor bcdUSB value is set to zero by
 the BIOS. Therefore to test this functionality with lsusb, I hard
 coded the usb2_rh_dev_descriptor (not include on patch) to:
   bcdUSB 0x01.
 
 Here is the test output.
 $ sudo lsusb -s 01:01 -v
 ...
 Binary Object Store Descriptor:
 bLength 5
 bDescriptorType15
 wTotalLength   12
 bNumDeviceCaps  1
 USB 2.0 Extension Device Capability:
   bLength 7
   bDescriptorType16
   bDevCapabilityType  2
   bmAttributes   0xff1e
 BESL Link Power Management (LPM) Supported
   BESL value 3840 us
   Deep BESL value61440 us
   Device Status: 0x0001
 Self Powered
 
 Signed-off-by: Alexandra Yates alexandra.ya...@linux.intel.com
 ---
  drivers/usb/host/xhci-hub.c |   53 
 +++
  drivers/usb/host/xhci.h |3 +++
  2 files changed, 51 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
 index 1d35459..60601df 100644
 --- a/drivers/usb/host/xhci-hub.c
 +++ b/drivers/usb/host/xhci-hub.c
 @@ -30,7 +30,7 @@
PORT_RC | PORT_PLC | PORT_PE)
  
  /* USB 3.0 BOS descriptor and a capability descriptor, combined */
 -static u8 usb_bos_descriptor [] = {
 +static u8 usb3_bos_descriptor[] = {
   USB_DT_BOS_SIZE,/*  __u8 bLength, 5 bytes */
   USB_DT_BOS, /*  __u8 bDescriptorType */
   0x0F, 0x00, /*  __le16 wTotalLength, 15 bytes */
 @@ -47,6 +47,28 @@ static u8 usb_bos_descriptor [] = {
   0x00, 0x00  /* __le16 bU2DevExitLat, set later. */
  };
  
 +/* USB 3.0 BOS descriptor and a capability descriptor, combined */
 +static u8 usb2_bos_descriptor[] = {

I don't think that comment is correct, right?

--
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: isp1760: avoid to flush_dcache_page on slab page

2013-08-08 Thread Ming Lei
In isp1760-hcd driver, flush_dcache_page() is introduced in commit
db8516f61b4(USB: isp1760: Flush the D-cache for the pipe-in transfer buffers)
to fix cache incoherency problem when PIO reading from USB mass storage
device to mapped page, so the flush should not need for slab pages which
won't be mapped to userspace.

This patch fixes one kernel panic when CONFIG_DEBUG_VM is set.

Cc: Catalin Marinas catalin.mari...@arm.com
Tested-by: Christoffer Dall christoffer.d...@linaro.org
Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/usb/host/isp1760-hcd.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 2facee5..c370e7d 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -703,7 +703,9 @@ __acquires(priv-lock)
urb-status = 0;
}
 
-   if (usb_pipein(urb-pipe)  usb_pipetype(urb-pipe) != PIPE_CONTROL) {
+   if (usb_pipein(urb-pipe) 
+   usb_pipetype(urb-pipe) != PIPE_CONTROL 
+   !PageSlab(virt_to_page(urb-transfer_buffer))) {
void *ptr;
for (ptr = urb-transfer_buffer;
 ptr  urb-transfer_buffer + urb-transfer_buffer_length;
-- 
1.7.9.5

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


Re: [PATCH v3 4/4] USBNET: ax88179_178a: enable tso if usb host supports sg dma

2013-08-08 Thread Ming Lei
On Fri, Aug 9, 2013 at 8:18 AM, Grant Grundler grund...@google.com wrote:
 Ming,
 We are splitting hairs now. :) I want to be clear I think your changes
 are good and the rest of this conversation is just to learn something
 new.

 On Thu, Aug 8, 2013 at 4:48 PM, Ming Lei ming@canonical.com wrote:
 On Fri, Aug 9, 2013 at 1:25 AM, Grant Grundler grund...@google.com wrote:
 ...
 I am afraid that PCI network devices' setting still won't survive unbound
 re-probed, will they?

 Correct - but PCI isn't as prone to dropping off the bus like USB

 As far as I know, USB device still won't be disconnected easily, and
 reset is possible, but we can make setting survive reset by implementing
 .pre_reset() and .post_reset() callback. Or do you have other situation
 of USB 'dropping off the bus'?

 So far only older USB core bugs like this one:
 https://codereview.chromium.org/4687002/show

This happens in configuration change situation, which is seldom
triggered, and also not randomly happen per your standpoint,
just like rmmod/modprobe , :-)


 I agree USB won't be disconnected easily.

 is. Master aborts on some PCI systems is a Fatal Exception and AFAIK
 that's never been true for any USB device.

 I mean rmmod  modprobe still can reset setting of one PCI network
 device after powering on the device, can't it?

 Definitely. But this isn't something that will randomly happen and
 will leave tracks all over the place of it happening. So I'm not
 worried about trying to debug this scenario.

Thanks,
--
Ming Lei
--
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 v5] usb: phy-samsung-usb: Simplify PMU register handling

2013-08-08 Thread Julius Werner
 Sorry, I don't understand what is not implemented. Without your patch, the
 PHY driver handles both PMU registers of Exynos4.

I don't have an Exynos4 to actually test this, so please let me know
if I'm missing something here... but in order to hit the right HOST
PHY register in the current upstream code, the Exynos4 code would need
to have a hostphy_reg_offset of 4 somewhere in its
samsung_usbphy_drvdata. In my latest checkout of Linus' tree (6c2580c)
it does not (only Exynos5 sets that attribute), so it would default to
0 (thereby actually hitting the DEVICE register).

If you want I can gladly provide another change on top of my patchset
to fix that in the future... but it looks to me like it had been
broken anyway for 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: FUSB200 xhci issue

2013-08-08 Thread Sujith Manoharan
Christian Lamparter wrote:
 So, if we call usb_reset_device there and the driver is unbound
 and later rebound. the next ath9k_htc .probe will start again and
 again and again not knowing that it is already initialized 
 (and we have a loop).

The HW/FW is buggy and this workaround is required:
http://marc.info/?l=linux-usbm=127960864905646w=2

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