[PATCH v2 0/5] usbnet: avoiding access auto-suspended device

2012-11-04 Thread Ming Lei
Thip patchset avoids accessing auto-suspended device in ioctl path,
which is generally triggered by some network utility(ethtool, ifconfig,
...)

Most of network devices have the problem, but as discussed in the
thread:

http://marc.info/?t=13505486063&r=1&w=2

the problem should be solved inside driver.

Considered that only smsc75xx and smsc95xx calls usbnet_read_cmd()
and usbnet_write_cmd() inside its resume and suspend callback, the
patcheset introduce the nopm version of the two functions which
should be called only in the resume and suspend callback. So we
can solve the problem by runtime resuming device before doing
control message things.

The patchset is against 3.7.0-rc3-next-20121102, and has been tested
OK on smsc95xx usbnet device.

Change logs:
V2:
- rebased on the latest net-next tree, only 2/5 changed
V1:
- rebased on 3.7.0-rc3-next-20121102, only patch 4/5 changed
- fix one memory leak during smsc95xx_suspend, patch 3/5 added

 drivers/net/usb/smsc75xx.c |  147 +++-
 drivers/net/usb/smsc95xx.c |  146 +++
 drivers/net/usb/usbnet.c   |   72 --
 include/linux/usb/usbnet.h |4 ++
 4 files changed, 255 insertions(+), 114 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 v2 1/5] usbnet: introduce usbnet_read[write]_cmd_nopm

2012-11-04 Thread Ming Lei
This patch introduces the below two helpers to prepare for solving
the usbnet runtime PM problem, which may cause some network utilities
(ifconfig, ethtool,...) touch a suspended device.

usbnet_read_cmd_nopm()
usbnet_write_cmd_nopm()

The above two helpers should be called by usbnet resume/suspend
callback to avoid deadlock.

Signed-off-by: Ming Lei 
---
 drivers/net/usb/usbnet.c   |   62 
 include/linux/usb/usbnet.h |4 +++
 2 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 09ea47a..a7fb074 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1614,8 +1614,8 @@ void usbnet_device_suggests_idle(struct usbnet *dev)
 EXPORT_SYMBOL(usbnet_device_suggests_idle);
 
 /*-*/
-int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
-   u16 value, u16 index, void *data, u16 size)
+static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
+u16 value, u16 index, void *data, u16 size)
 {
void *buf = NULL;
int err = -ENOMEM;
@@ -1639,10 +1639,10 @@ int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 
reqtype,
 out:
return err;
 }
-EXPORT_SYMBOL_GPL(usbnet_read_cmd);
 
-int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
-u16 value, u16 index, const void *data, u16 size)
+static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
+ u16 value, u16 index, const void *data,
+ u16 size)
 {
void *buf = NULL;
int err = -ENOMEM;
@@ -1665,8 +1665,56 @@ int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 
reqtype,
 out:
return err;
 }
+
+/*
+ * The function can't be called inside suspend/resume callback,
+ * otherwise deadlock will be caused.
+ */
+int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
+   u16 value, u16 index, void *data, u16 size)
+{
+   return __usbnet_read_cmd(dev, cmd, reqtype, value, index,
+data, size);
+}
+EXPORT_SYMBOL_GPL(usbnet_read_cmd);
+
+/*
+ * The function can't be called inside suspend/resume callback,
+ * otherwise deadlock will be caused.
+ */
+int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
+u16 value, u16 index, const void *data, u16 size)
+{
+   return __usbnet_write_cmd(dev, cmd, reqtype, value, index,
+ data, size);
+}
 EXPORT_SYMBOL_GPL(usbnet_write_cmd);
 
+/*
+ * The function can be called inside suspend/resume callback safely
+ * and should only be called by suspend/resume callback generally.
+ */
+int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
+ u16 value, u16 index, void *data, u16 size)
+{
+   return __usbnet_read_cmd(dev, cmd, reqtype, value, index,
+data, size);
+}
+EXPORT_SYMBOL_GPL(usbnet_read_cmd_nopm);
+
+/*
+ * The function can be called inside suspend/resume callback safely
+ * and should only be called by suspend/resume callback generally.
+ */
+int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
+ u16 value, u16 index, const void *data,
+ u16 size)
+{
+   return __usbnet_write_cmd(dev, cmd, reqtype, value, index,
+ data, size);
+}
+EXPORT_SYMBOL_GPL(usbnet_write_cmd_nopm);
+
 static void usbnet_async_cmd_cb(struct urb *urb)
 {
struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
@@ -1680,6 +1728,10 @@ static void usbnet_async_cmd_cb(struct urb *urb)
usb_free_urb(urb);
 }
 
+/*
+ * The caller must make sure that device can't be put into suspend
+ * state until the control URB completes.
+ */
 int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
   u16 value, u16 index, const void *data, u16 size)
 {
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 4410e416..9bbeabf 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -167,6 +167,10 @@ extern int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 
reqtype,
u16 value, u16 index, void *data, u16 size);
 extern int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
u16 value, u16 index, const void *data, u16 size);
+extern int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
+   u16 value, u16 index, void *data, u16 size);
+extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
+   u16 value, u16 index, const void *data, u16 size);
 extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
u16 value, u16 index, const void *data, u16 size);
 
-- 
1.7.9.5

-

[PATCH v2 2/5] usbnet: smsc75xx: apply the introduced usbnet_read[write]_cmd_nopm

2012-11-04 Thread Ming Lei
This patch applies the introduced usbnet_read_cmd_nopm() and
usbnet_write_cmd_nopm() in the callback of resume and suspend
to avoid deadlock if USB runtime PM is considered into
usbnet_read_cmd() and usbnet_write_cmd().

Cc: Steve Glendinning 
Signed-off-by: Ming Lei 
---
 drivers/net/usb/smsc75xx.c |  147 +++-
 1 file changed, 90 insertions(+), 57 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 85d70c2..c5353cf 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -85,18 +85,23 @@ static bool turbo_mode = true;
 module_param(turbo_mode, bool, 0644);
 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
 
-static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
- u32 *data)
+static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index,
+   u32 *data, int in_pm)
 {
u32 buf;
int ret;
+   int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);
 
BUG_ON(!dev);
 
-   ret = usbnet_read_cmd(dev, USB_VENDOR_REQUEST_READ_REGISTER,
- USB_DIR_IN | USB_TYPE_VENDOR |
- USB_RECIP_DEVICE,
- 0, index, &buf, 4);
+   if (!in_pm)
+   fn = usbnet_read_cmd;
+   else
+   fn = usbnet_read_cmd_nopm;
+
+   ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
+| USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+0, index, &buf, 4);
if (unlikely(ret < 0))
netdev_warn(dev->net,
"Failed to read reg index 0x%08x: %d", index, ret);
@@ -107,21 +112,26 @@ static int __must_check smsc75xx_read_reg(struct usbnet 
*dev, u32 index,
return ret;
 }
 
-static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
-  u32 data)
+static int __must_check __smsc75xx_write_reg(struct usbnet *dev, u32 index,
+u32 data, int in_pm)
 {
u32 buf;
int ret;
+   int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);
 
BUG_ON(!dev);
 
+   if (!in_pm)
+   fn = usbnet_write_cmd;
+   else
+   fn = usbnet_write_cmd_nopm;
+
buf = data;
cpu_to_le32s(&buf);
 
-   ret = usbnet_write_cmd(dev, USB_VENDOR_REQUEST_WRITE_REGISTER,
-  USB_DIR_OUT | USB_TYPE_VENDOR |
-  USB_RECIP_DEVICE,
-  0, index, &buf, 4);
+   ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT
+| USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+0, index, &buf, 4);
if (unlikely(ret < 0))
netdev_warn(dev->net,
"Failed to write reg index 0x%08x: %d", index, ret);
@@ -129,16 +139,38 @@ static int __must_check smsc75xx_write_reg(struct usbnet 
*dev, u32 index,
return ret;
 }
 
+static int __must_check smsc75xx_read_reg_nopm(struct usbnet *dev, u32 index,
+  u32 *data)
+{
+   return __smsc75xx_read_reg(dev, index, data, 1);
+}
+
+static int __must_check smsc75xx_write_reg_nopm(struct usbnet *dev, u32 index,
+   u32 data)
+{
+   return __smsc75xx_write_reg(dev, index, data, 1);
+}
+
+static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
+ u32 *data)
+{
+   return __smsc75xx_read_reg(dev, index, data, 0);
+}
+
+static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
+  u32 data)
+{
+   return __smsc75xx_write_reg(dev, index, data, 0);
+}
+
 static int smsc75xx_set_feature(struct usbnet *dev, u32 feature)
 {
if (WARN_ON_ONCE(!dev))
return -EINVAL;
 
-   cpu_to_le32s(&feature);
-
-   return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
-   USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, feature, 0, NULL, 0,
-   USB_CTRL_SET_TIMEOUT);
+   return usbnet_write_cmd_nopm(dev, USB_REQ_SET_FEATURE,
+USB_DIR_OUT | USB_RECIP_DEVICE,
+feature, 0, NULL, 0);
 }
 
 static int smsc75xx_clear_feature(struct usbnet *dev, u32 feature)
@@ -146,11 +178,9 @@ static int smsc75xx_clear_feature(struct usbnet *dev, u32 
feature)
if (WARN_ON_ONCE(!dev))
return -EINVAL;
 
-   cpu_to_le32s(&feature);
-
-   return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
-   USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE, feature, 0, NULL, 0,
-   USB_CTRL_SET_TIMEOUT);
+   return usbnet_write_cmd_nopm(dev, USB_REQ_CLEAR_FEATURE

[PATCH v2 3/5] usbnet: smsc95xx: fix memory leak in smsc95xx_suspend

2012-11-04 Thread Ming Lei
This patch fixes memory leak in smsc95xx_suspend.

Also, it isn't necessary to bother mm to allocate 8bytes/16byte,
and we can use stack variable safely.

Cc: Steve Glendinning 
Signed-off-by: Ming Lei 
---
 drivers/net/usb/smsc95xx.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 46cd784..f1f473f 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1070,11 +1070,15 @@ static int smsc95xx_suspend(struct usb_interface *intf, 
pm_message_t message)
 
if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) 
{
u32 *filter_mask = kzalloc(32, GFP_KERNEL);
-   u32 *command = kzalloc(2, GFP_KERNEL);
-   u32 *offset = kzalloc(2, GFP_KERNEL);
-   u32 *crc = kzalloc(4, GFP_KERNEL);
+   u32 command[2];
+   u32 offset[2];
+   u32 crc[4];
int i, filter = 0;
 
+   memset(command, 0, sizeof(command));
+   memset(offset, 0, sizeof(offset));
+   memset(crc, 0, sizeof(crc));
+
if (pdata->wolopts & WAKE_BCAST) {
const u8 bcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
netdev_info(dev->net, "enabling broadcast detection");
@@ -1131,6 +1135,8 @@ static int smsc95xx_suspend(struct usb_interface *intf, 
pm_message_t message)
check_warn_return(ret, "Error writing WUFF");
}
 
+   kfree(filter_mask);
+
for (i = 0; i < (pdata->wuff_filter_count / 4); i++) {
ret = smsc95xx_write_reg(dev, WUFF, command[i]);
check_warn_return(ret, "Error writing WUFF");
-- 
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 v2 4/5] usbnet: smsc95xx: apply the introduced usbnet_read[write]_cmd_nopm

2012-11-04 Thread Ming Lei
This patch applies the introduced usbnet_read_cmd_nopm() and
usbnet_write_cmd_nopm() in the callback of resume and suspend
to avoid deadlock if USB runtime PM is considered into
usbnet_read_cmd() and usbnet_write_cmd().

Cc: Steve Glendinning 
Signed-off-by: Ming Lei 
---
 drivers/net/usb/smsc95xx.c |  134 
 1 file changed, 85 insertions(+), 49 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index f1f473f..0241db4 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -73,20 +73,26 @@ static bool turbo_mode = true;
 module_param(turbo_mode, bool, 0644);
 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
 
-static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
- u32 *data)
+static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
+   u32 *data, int in_pm)
 {
u32 buf;
int ret;
+   int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);
 
BUG_ON(!dev);
 
-   ret = usbnet_read_cmd(dev, USB_VENDOR_REQUEST_READ_REGISTER,
- USB_DIR_IN | USB_TYPE_VENDOR |
- USB_RECIP_DEVICE,
- 0, index, &buf, 4);
+   if (!in_pm)
+   fn = usbnet_read_cmd;
+   else
+   fn = usbnet_read_cmd_nopm;
+
+   ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN
+| USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+0, index, &buf, 4);
if (unlikely(ret < 0))
-   netdev_warn(dev->net, "Failed to read register index 0x%08x\n", 
index);
+   netdev_warn(dev->net,
+   "Failed to read reg index 0x%08x: %d", index, ret);
 
le32_to_cpus(&buf);
*data = buf;
@@ -94,35 +100,64 @@ static int __must_check smsc95xx_read_reg(struct usbnet 
*dev, u32 index,
return ret;
 }
 
-static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index,
-  u32 data)
+static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index,
+u32 data, int in_pm)
 {
u32 buf;
int ret;
+   int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);
 
BUG_ON(!dev);
 
+   if (!in_pm)
+   fn = usbnet_write_cmd;
+   else
+   fn = usbnet_write_cmd_nopm;
+
buf = data;
cpu_to_le32s(&buf);
 
-
-   ret = usbnet_write_cmd(dev, USB_VENDOR_REQUEST_WRITE_REGISTER,
-  USB_DIR_OUT | USB_TYPE_VENDOR |
-  USB_RECIP_DEVICE,
-  0, index, &buf, 4);
+   ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT
+| USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+0, index, &buf, 4);
if (unlikely(ret < 0))
-   netdev_warn(dev->net, "Failed to write register index 
0x%08x\n", index);
+   netdev_warn(dev->net,
+   "Failed to write reg index 0x%08x: %d", index, ret);
 
return ret;
 }
 
+static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index,
+  u32 *data)
+{
+   return __smsc95xx_read_reg(dev, index, data, 1);
+}
+
+static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index,
+   u32 data)
+{
+   return __smsc95xx_write_reg(dev, index, data, 1);
+}
+
+static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index,
+ u32 *data)
+{
+   return __smsc95xx_read_reg(dev, index, data, 0);
+}
+
+static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index,
+  u32 data)
+{
+   return __smsc95xx_write_reg(dev, index, data, 0);
+}
 static int smsc95xx_set_feature(struct usbnet *dev, u32 feature)
 {
if (WARN_ON_ONCE(!dev))
return -EINVAL;
 
-   return usbnet_write_cmd(dev, USB_REQ_SET_FEATURE,
-   USB_RECIP_DEVICE, feature, 0, NULL, 0);
+   return usbnet_write_cmd_nopm(dev, USB_REQ_SET_FEATURE,
+USB_RECIP_DEVICE, feature, 0,
+NULL, 0);
 }
 
 static int smsc95xx_clear_feature(struct usbnet *dev, u32 feature)
@@ -130,8 +165,9 @@ static int smsc95xx_clear_feature(struct usbnet *dev, u32 
feature)
if (WARN_ON_ONCE(!dev))
return -EINVAL;
 
-   return usbnet_write_cmd(dev, USB_REQ_CLEAR_FEATURE,
-   USB_RECIP_DEVICE, feature, 0, NULL, 0);
+   return usbnet_write_cmd_nopm(dev, USB_REQ_CLEAR_FEATURE,
+USB_RECIP_DEVICE, feature,

[PATCH v2 5/5] usbnet: make device out of suspend before calling usbnet_read[write]_cmd

2012-11-04 Thread Ming Lei
This patche gets the runtime PM reference count before calling
usbnet_read[write]_cmd, and puts it after completion of the
usbnet_read[write]_cmd, so that the usb control message can always
be sent to one active device in the non-PM context.

Signed-off-by: Ming Lei 
---
 drivers/net/usb/usbnet.c |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index a7fb074..74caa67 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1673,8 +1673,13 @@ out:
 int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
u16 value, u16 index, void *data, u16 size)
 {
-   return __usbnet_read_cmd(dev, cmd, reqtype, value, index,
-data, size);
+   int ret;
+   if (usb_autopm_get_interface(dev->intf) < 0)
+   return -ENODEV;
+   ret = __usbnet_read_cmd(dev, cmd, reqtype, value, index,
+   data, size);
+   usb_autopm_put_interface(dev->intf);
+   return ret;
 }
 EXPORT_SYMBOL_GPL(usbnet_read_cmd);
 
@@ -1685,8 +1690,13 @@ EXPORT_SYMBOL_GPL(usbnet_read_cmd);
 int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 u16 value, u16 index, const void *data, u16 size)
 {
-   return __usbnet_write_cmd(dev, cmd, reqtype, value, index,
- data, size);
+   int ret;
+   if (usb_autopm_get_interface(dev->intf) < 0)
+   return -ENODEV;
+   ret = __usbnet_write_cmd(dev, cmd, reqtype, value, index,
+data, size);
+   usb_autopm_put_interface(dev->intf);
+   return ret;
 }
 EXPORT_SYMBOL_GPL(usbnet_write_cmd);
 
-- 
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 v1 2/5] usbnet: smsc75xx: apply the introduced usbnet_read[write]_cmd_nopm

2012-11-04 Thread Ming Lei
On Sun, Nov 4, 2012 at 1:58 PM, David Miller  wrote:
>
> This gets rejects, you didn't have your net-next tree uptodate
> enough.

Sorry, I just rebased that on 3.7.0-rc3-next-20121102.

The new patchset which is against the latest net-next has been sent out.

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: 3.4.4: disabling irq

2012-11-04 Thread Udo van den Heuvel
Well,

The issue appeared again.
irq 18 was disabled, one pwc webcam was on that irq.

This time on new hardware: Gigabyte F2A85X-UP4 with A10-5800K APU.
The box was busy with it's raid10 array, this time, by running bonnie++;
also a raid-check was in progress. (unknown at the time)

So what does this say? It appears not to be a hardware problem per se.

Anyone?

Kind regards,
Udo


--
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] usbnet: make device out of suspend before calling usbnet_read[write]_cmd

2012-11-04 Thread Sergei Shtylyov

Hello.

On 04-11-2012 15:16, Ming Lei wrote:

   s/make/wake/ in the subject?


This patche gets the runtime PM reference count before calling


   s/patche/patch/


usbnet_read[write]_cmd, and puts it after completion of the
usbnet_read[write]_cmd, so that the usb control message can always


   You probably meant usbnet_{read|write}_cmd() here and in the subject?


be sent to one active device in the non-PM context.



Signed-off-by: Ming Lei 
---
  drivers/net/usb/usbnet.c |   18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index a7fb074..74caa67 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1673,8 +1673,13 @@ out:
  int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
u16 value, u16 index, void *data, u16 size)
  {
-   return __usbnet_read_cmd(dev, cmd, reqtype, value, index,
-data, size);
+   int ret;


   Empty line wouldn't hurt here, after declaration block.


+   if (usb_autopm_get_interface(dev->intf) < 0)
+   return -ENODEV;
+   ret = __usbnet_read_cmd(dev, cmd, reqtype, value, index,
+   data, size);
+   usb_autopm_put_interface(dev->intf);
+   return ret;
  }
  EXPORT_SYMBOL_GPL(usbnet_read_cmd);

@@ -1685,8 +1690,13 @@ EXPORT_SYMBOL_GPL(usbnet_read_cmd);
  int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 u16 value, u16 index, const void *data, u16 size)
  {
-   return __usbnet_write_cmd(dev, cmd, reqtype, value, index,
- data, size);
+   int ret;


   And here too...


+   if (usb_autopm_get_interface(dev->intf) < 0)
+   return -ENODEV;
+   ret = __usbnet_write_cmd(dev, cmd, reqtype, value, index,
+data, size);
+   usb_autopm_put_interface(dev->intf);
+   return ret;
  }
  EXPORT_SYMBOL_GPL(usbnet_write_cmd);


WBR, Sergei

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


USB issue with kernel 3.6

2012-11-04 Thread Piergiorgio Sartor
Hi all,

I've a strange problem with the USB subsystem, under
kernel 3.6, this was not happening under 3.5.
The system is Fedora, so I'll use their kernel numbers,
and the related bug report is this:

https://bugzilla.redhat.com/show_bug.cgi?id=866166

I've some USB hubs cascaded in order to have 10 ports
available.
Two configurations: one is with 3 hubs, 4 ports each,
where 2 hubs are connected to the first one.
Second configuration is similar, it only uses 1 hubs
with 7 ports followed by a 5 ports one.

To the resulting 10 ports are connected to 10 USB hard
disks. This is a "feasibility study" on the possibility
to create a storage device in this condition.

The 10 HDDs are combined in RAID-6.

Now, until kernel 3.5.6, everything was working fine,
I can achieve around 43MB/sec transfer rate (read) from
such setup, with high reliability.
Of course, some times one HDD would flight away, but
nothing really serious as a problem. In fact this was
one of the point I wanted to check.

Since kernel 3.6.x, after short time accessing the
RAID (or in parallel the 10 HDDs, independently from
the md layer), I get error -110 from the USB subsystem
and everything dies.
It seems to me, but I'm not sure, reading a single
HDD does not lead to this problem.

Furthermore, the USB ehci subsystem does not work
any more, even after waiting for the usual timeouts,
connecting a USB stick to some other USB port in the
PC results in absolute nothing.

Removing ehci, via sysfs since it is compiled in,
result in a system working, but at USB 1.1 speed.

My suspect is that something in kernel 3.6 changed
the behaviour under load of the USB subsystem, showing
up only in such extreme cases, I guess.
Probably it is a borderline test case, nevertheless,
still a failure.

The USB HDD controller are JMicron, I do not know if
it does matter.

Any idea or suggestion on how to test further?

Thanks a lot in advance,

bye,

-- 

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


Re: [PATCH] usb: gadget: ncm: correct endianess conversion

2012-11-04 Thread Dmytro Milinevskyy
Hum, you are right. It's pain to send anything via thunderbird.
Resending.

br,
-- dmytro

On Fri, Nov 2, 2012 at 12:46 PM, Sergei Shtylyov  wrote:
> Hello.
>
>
> On 01-11-2012 19:16, Dmytro Milinevskyy wrote:
>
>> Convert USB descriptor's fields to CPU byte order before using locally in
>> USB
>> NCM gadget driver.
>> Tested on MIPS32 big-endian device.
>
>
>> Signed-off-by: Dmytro Milinevskyy 
>> ---
>>   drivers/usb/gadget/f_ncm.c | 12 
>>
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>
>
>> diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
>> index b651b52..a7cdd47 100644
>> --- a/drivers/usb/gadget/f_ncm.c
>> +++ b/drivers/usb/gadget/f_ncm.c
>
> [...]
>>
>> @@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether
>> *port,
>>
>>   struct sk_buff*skb2;
>>   intncb_len = 0;
>>   __le16*tmp;
>> -intdiv = ntb_parameters.wNdpInDivisor;
>> -intrem = ntb_parameters.wNdpInPayloadRemainder;
>> +intdiv;
>> +intrem;
>>
>>   intpad;
>> -intndp_align = ntb_parameters.wNdpInAlignment;
>> +intndp_align;
>>   intndp_pad;
>>
>>   unsignedmax_size = ncm->port.fixed_in_len;
>>   struct ndp_parser_opts *opts = ncm->parser_opts;
>>   unsignedcrc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
>>   +div = le16_to_cpu(ntb_parameters.wNdpInDivisor);
>
>
> Probably corrupt patch -- there shouldn't be spaces before '+'.
>
> WBR, Sergei
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: ncm: correct endianess conversion

2012-11-04 Thread Dmytro Milinevskyy

Convert USB descriptor's fields to CPU byte order before using locally in USB 
NCM gadget driver.
Tested on MIPS32 big-endian device.

Signed-off-by: Dmytro Milinevskyy 
---
 drivers/usb/gadget/f_ncm.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index b651b52..a7cdd47 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g)
 USB_CDC_NCM_NTB32_SUPPORTED)
 
 static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {

-   .wLength = sizeof ntb_parameters,
+   .wLength = cpu_to_le16(sizeof(ntb_parameters)),
.bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED),
.dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE),
.wNdpInDivisor = cpu_to_le16(4),
@@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port,
struct sk_buff  *skb2;
int ncb_len = 0;
__le16  *tmp;
-   int div = ntb_parameters.wNdpInDivisor;
-   int rem = ntb_parameters.wNdpInPayloadRemainder;
+   int div;
+   int rem;
int pad;
-   int ndp_align = ntb_parameters.wNdpInAlignment;
+   int ndp_align;
int ndp_pad;
unsignedmax_size = ncm->port.fixed_in_len;
struct ndp_parser_opts *opts = ncm->parser_opts;
unsignedcrc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
 
+	div = le16_to_cpu(ntb_parameters.wNdpInDivisor);

+   rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder);
+   ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment);
+
ncb_len += opts->nth_size;
ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len;
ncb_len += ndp_pad;
--
1.8.0


--
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 V3 1/4] USB: Set usb port's DeviceRemovable according acpi information in EHCI

2012-11-04 Thread Lan Tianyu
ACPI provide "_PLD" and "_UPC" aml methods to describe usb port
visibility and connectability. This patch is to use those information
to change ehci root hub descriptors and set usb hub port's DeviceRemovable
in the hub_configure(). When hub descriptor request is issued at first time,
usb port device isn't created and usb port is not bound with acpi. So first
hub descriptor request is not changed based on ACPI information. After usb
port device being created, set hub port's DeviceRemovable according ACPI
information and this also works for non-root hub.

Signed-off-by: Lan Tianyu 
---
 drivers/usb/core/hub.c  |   23 +++
 drivers/usb/core/usb.h  |4 
 drivers/usb/host/ehci-hub.c |9 +
 include/linux/usb.h |4 
 4 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 90accde..706db5c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1546,6 +1546,25 @@ static int hub_configure(struct usb_hub *hub,
dev_err(hub->intfdev,
"couldn't create port%d device.\n", i + 1);
 
+   if (!hub_is_superspeed(hdev)) {
+   for (i = 1; i <= hdev->maxchild; i++)
+   if (hub->ports[i - 1]->connect_type
+   == USB_PORT_CONNECT_TYPE_HARD_WIRED)
+   hub->descriptor->u.hs.DeviceRemovable[i/8]
+   |= 1 << (i%8);
+   } else  {
+   u16 port_removable =
+   le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable);
+
+   for (i = 1; i <= hdev->maxchild; i++)
+   if (hub->ports[i - 1]->connect_type
+   == USB_PORT_CONNECT_TYPE_HARD_WIRED)
+   port_removable |= 1 << i;
+
+   hub->descriptor->u.ss.DeviceRemovable =
+   cpu_to_le16(port_removable);
+   }
+
hub_activate(hub, HUB_INIT);
return 0;
 
@@ -5191,8 +5210,12 @@ usb_get_hub_port_connect_type(struct usb_device *hdev, 
int port1)
 {
struct usb_hub *hub = hdev_to_hub(hdev);
 
+   if (!hub)
+   return USB_PORT_CONNECT_TYPE_UNKNOWN;
+
return hub->ports[port1 - 1]->connect_type;
 }
+EXPORT_SYMBOL_GPL(usb_get_hub_port_connect_type);
 
 #ifdef CONFIG_ACPI
 /**
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 1c528c1..1633f6e 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -169,10 +169,6 @@ extern void usb_notify_add_device(struct usb_device *udev);
 extern void usb_notify_remove_device(struct usb_device *udev);
 extern void usb_notify_add_bus(struct usb_bus *ubus);
 extern void usb_notify_remove_bus(struct usb_bus *ubus);
-extern enum usb_port_connect_type
-   usb_get_hub_port_connect_type(struct usb_device *hdev, int port1);
-extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1,
-   enum usb_port_connect_type type);
 
 #ifdef CONFIG_ACPI
 extern int usb_acpi_register(void);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 4ccb97c..dd084b3 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -662,6 +662,7 @@ ehci_hub_descriptor (
struct usb_hub_descriptor   *desc
 ) {
int ports = HCS_N_PORTS (ehci->hcs_params);
+   int i;
u16 temp;
 
desc->bDescriptorType = 0x29;
@@ -676,6 +677,14 @@ ehci_hub_descriptor (
memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
 
+   for (i = 1; i <= ports; i++) {
+   if (usb_get_hub_port_connect_type(
+   ehci_to_hcd(ehci)->self.root_hub, i)
+   == USB_PORT_CONNECT_TYPE_HARD_WIRED)
+   desc->u.hs.DeviceRemovable[i/8] |= 1 << (i%8);
+   }
+
+
temp = 0x0008;  /* per-port overcurrent reporting */
if (HCS_PPC (ehci->hcs_params))
temp |= 0x0001; /* per-port power control */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 689b14b..e996bb6 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -577,6 +577,10 @@ static inline struct usb_device 
*interface_to_usbdev(struct usb_interface *intf)
return to_usb_device(intf->dev.parent);
 }
 
+extern enum usb_port_connect_type
+   usb_get_hub_port_connect_type(struct usb_device *hdev, int port1);
+extern void usb_set_hub_port_connect_type(struct usb_device *hdev, int port1,
+   enum usb_port_connect_type type);
 extern struct usb_device *usb_get_dev(struct usb_device *dev);
 extern void usb_put_dev(struct usb_device *dev);
 extern struct usb_device *usb_hub_find_child(struct usb_device *hdev,
-- 
1.7.9.5

--
To unsubscribe from this list: sen

[PATCH V3 3/4] usb: Create link files between child device and usb port device.

2012-11-04 Thread Lan Tianyu
To show the relationship between usb port and child device,
add link file "port" under usb device's sysfs directoy and
"device" under usb port device's sysfs directory. They are linked
to each other.

Signed-off-by: Lan Tianyu 
---
 drivers/usb/core/hub.c |   22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 706db5c..a08a018 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2015,6 +2015,8 @@ void usb_disconnect(struct usb_device **pdev)
 {
struct usb_device   *udev = *pdev;
struct usb_hub  *hub = hdev_to_hub(udev);
+   struct usb_port *port_dev =
+   hdev_to_hub(udev->parent)->ports[udev->portnum - 1];
int i;
 
/* mark the device as inactive, so any further urb submissions for
@@ -2041,6 +2043,8 @@ void usb_disconnect(struct usb_device **pdev)
usb_disable_device(udev, 0);
usb_hcd_synchronize_unlinks(udev);
 
+   sysfs_remove_link(&udev->dev.kobj, "port");
+   sysfs_remove_link(&port_dev->dev.kobj, "device");
usb_remove_ep_devs(&udev->ep0);
usb_unlock_device(udev);
 
@@ -2333,6 +2337,24 @@ int usb_new_device(struct usb_device *udev)
goto fail;
}
 
+   /* Create link files between child device and usb port device. */
+   if (udev->parent) {
+   struct usb_port *port_dev =
+   hdev_to_hub(udev->parent)->ports[udev->portnum - 1];
+
+   err = sysfs_create_link(&udev->dev.kobj,
+   &port_dev->dev.kobj, "port");
+   if (err)
+   goto fail;
+
+   err = sysfs_create_link(&port_dev->dev.kobj,
+   &udev->dev.kobj, "device");
+   if (err) {
+   sysfs_remove_link(&udev->dev.kobj, "port");
+   goto fail;
+   }
+   }
+
(void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev);
usb_mark_last_busy(udev);
pm_runtime_put_sync_autosuspend(&udev->dev);
-- 
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 V3 0/4] usb: expose DeviceRemovable to user space via sysfs attribute

2012-11-04 Thread Lan Tianyu
Change since v1:
[PATCH 3] Rename link file's name "child" to "device", add check of 
return value of
sysfs_create_link() and handle error return value properly.

Change since v2:
   [PATCH 1] fix a logic backward problem. Add changelog about change ehci 
root hub descriptors based on ACPI information.  
   [PATCH 2] Add changelog about using ACPI inforatmion to set hub 
DeviceRemovable rather than xhci PORTSC.

This patchset is to set DeviceRemovable according ACPI information
and create a new attribute "connect_type" under port device to expose
port connect type to user space. Patch3 create two link files under
port device and its child device to show their relationship under sysfs.

Following patchset is based on the commit d124a60dbb "USB: isp1760-if:
Change to use irq_of_parse_and_map" of usb-next tree

USB: Set usb port's DeviceRemovable according acpi information in EHCI
usb/xhci: set root hub's DeviceRemovable according to usb port connect type
usb: Create link files between child device and usb port device.
usb: Add "portX/connect_type" attribute to expose usb port's connect type

 Documentation/ABI/testing/sysfs-bus-usb |9 +
 drivers/usb/core/hub.c  |   83 
+++
 drivers/usb/core/usb.h  |4 
 drivers/usb/host/ehci-hub.c |9 +
 drivers/usb/host/xhci-hub.c |   19 +--
 include/linux/usb.h |4 
 6 files changed, 122 insertions(+), 6 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 2/4] usb/xhci: set root hub's DeviceRemovable according to usb port connect type

2012-11-04 Thread Lan Tianyu
This patch is to set xhci root hub's DeviceRemovable according to usb port's
connect type which currently comes from ACPI information rather than xhci PORTSC
register due to Windows prefers to ACPI information. If ACPI information was
different with PORTSC, there would be a warning.

Signed-off-by: Lan Tianyu 
---
 drivers/usb/host/xhci-hub.c |   19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a686cf4..50a3c39 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -97,11 +97,18 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, 
struct xhci_hcd *xhci,
/* If a device is removable, PORTSC reports a 0, same as in the
 * hub descriptor DeviceRemovable bits.
 */
-   if (portsc & PORT_DEV_REMOVE)
+   if (usb_get_hub_port_connect_type(
+   hcd->self.root_hub, i + 1)
+   == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
+   if (!(portsc & PORT_DEV_REMOVE))
+   xhci_warn(xhci, "usb2.0 port%d's connect type 
from ACPI is different with PORTSC register. ACPI returns hard-wired.\n",
+   i + 1);
+
/* This math is hairy because bit 0 of DeviceRemovable
 * is reserved, and bit 1 is for port 1, etc.
 */
port_removable[(i + 1) / 8] |= 1 << ((i + 1) % 8);
+   }
}
 
/* ch11.h defines a hub descriptor that has room for USB_MAXCHILDREN
@@ -148,8 +155,16 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, 
struct xhci_hcd *xhci,
/* bit 0 is reserved, bit 1 is for port 1, etc. */
for (i = 0; i < ports; i++) {
portsc = xhci_readl(xhci, xhci->usb3_ports[i]);
-   if (portsc & PORT_DEV_REMOVE)
+
+   if (usb_get_hub_port_connect_type(
+   hcd->self.root_hub, i + 1)
+   == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
+   if (!(portsc & PORT_DEV_REMOVE))
+   xhci_warn(xhci, "usb3.0 port%d's connect type 
from ACPI is different with PORTSC register. ACPI returns hard-wired.\n",
+   i + 1);
+
port_removable |= 1 << (i + 1);
+   }
}
 
desc->u.ss.DeviceRemovable = cpu_to_le16(port_removable);
-- 
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 V3 4/4] usb: Add "portX/connect_type" attribute to expose usb port's connect type

2012-11-04 Thread Lan Tianyu
Some platforms provide usb port connect types through ACPI. This
patch is to add this new attribute to expose these information
to user space.

Signed-off-by: Lan Tianyu 
---
 Documentation/ABI/testing/sysfs-bus-usb |9 +++
 drivers/usb/core/hub.c  |   43 +++
 2 files changed, 52 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index b6fbe51..dad3533 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -227,3 +227,12 @@ Contact:   Lan Tianyu 
 Description:
The /sys/bus/usb/devices/.../(hub interface)/portX
is usb port device's sysfs directory.
+
+What:  /sys/bus/usb/devices/.../(hub interface)/portX/connect_type
+Date:  November 2012
+Contact:   Lan Tianyu 
+Description:
+   Some platforms provide usb port connect types through ACPI.
+   This attribute is to expose these information to user space.
+   The file will read "hotplug", "wired" and "not used" if the
+   information is available, and "unknown" otherwise.
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a08a018..d1aedea 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -98,6 +98,8 @@ struct usb_hub {
struct usb_port **ports;
 };
 
+static const struct attribute_group *port_dev_group[];
+
 static inline int hub_is_superspeed(struct usb_device *hdev)
 {
return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS);
@@ -1267,6 +1269,7 @@ static int usb_hub_create_port_device(struct usb_hub *hub,
 
hub->ports[port1 - 1] = port_dev;
port_dev->dev.parent = hub->intfdev;
+   port_dev->dev.groups = port_dev_group;
port_dev->dev.type = &usb_port_device_type;
dev_set_name(&port_dev->dev, "port%d", port1);
 
@@ -4754,6 +4757,46 @@ static int hub_thread(void *__unused)
return 0;
 }
 
+static ssize_t show_port_connect_type(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct usb_port *port_dev = to_usb_port(dev);
+   char *result;
+
+   switch (port_dev->connect_type) {
+   case USB_PORT_CONNECT_TYPE_HOT_PLUG:
+   result = "hotplug";
+   break;
+   case USB_PORT_CONNECT_TYPE_HARD_WIRED:
+   result = "hardwired";
+   break;
+   case USB_PORT_NOT_USED:
+   result = "not used";
+   break;
+   default:
+   result = "unknown";
+   break;
+   }
+
+   return sprintf(buf, "%s\n", result);
+}
+static DEVICE_ATTR(connect_type, S_IRUGO, show_port_connect_type,
+   NULL);
+
+static struct attribute *port_dev_attrs[] = {
+   &dev_attr_connect_type.attr,
+   NULL,
+};
+
+static struct attribute_group port_dev_attr_grp = {
+   .attrs = port_dev_attrs,
+};
+
+static const struct attribute_group *port_dev_group[] = {
+   &port_dev_attr_grp,
+   NULL,
+};
+
 static const struct usb_device_id hub_id_table[] = {
 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
   | USB_DEVICE_ID_MATCH_INT_CLASS,
-- 
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: EHCI controller CS5536 hard disk disconnects

2012-11-04 Thread Sergey Vlasov
On Sat, Nov 03, 2012 at 09:14:08PM +0100, Miguel Dardenne wrote:
> On 2012-11-03 17:50, Alan Stern wrote:
> >> I get a USB disconnect of my external USB HDD about once per day.
> >> Enabling USB debug in the kernel shows the first error as 'ehci_hcd
> >> detected XactErr'. It happens only when the drive is idle. For 
> >> example,
> >> I had a process writing on the HDD every 3 seconds and the problem 
> >> did
> >> not occur for several weeks.
> >
> > Correction: These errors do not occur when the drive is idle.  You 
> > can
> > see in the log you attached:
> 
> OK thanks for this. I then reformulate my statement: using the drive on 
> a frequent basis (3s period) prevents the problem from occuring.

Then the problem might be related to the power management in the drive
itself, not in the host OS.  2.5" drives tend to have a short spindown
timeout, and the first operation performed after such timeout causes
the drive to spin up.  The spinup process consumes a lot of power
(more than during sustained operation), and current fluctuations
during this process might cause problems if any components in the
power supply chain are marginal (even a lousy cable with too thin
conductors can be problematic).

You might be able to change APM settings of the hard drive using
utilities like hdparm; however, this might not work with your
particular WD external drive for several reasons:

 - Not all USB-SATA bridges can pass low-level ATA commands needed to
   change APM settings.  If you purchase an USB-SATA enclosure and HDD
   separately, you could work around this problem by attaching the
   drive to a SATA port directly to perform this configuration (APM
   settings are usually persistent), but doing this with an external
   USB drive sold as a single item will probably void the warranty.
   Even worse, some external drives made by WD have the USB port
   actually soldered to the drive PCB itself, and the SATA interface
   is not accessible directly.

 - WD drives often need undocumented vendor-specific commands to
   control spindown (google for "wdidle" used for 3.5" WD Green
   drives; not sure about their 2.5" drives).  Even if the appropriate
   tools exist, they might not work with USB-attached drives.

Did you try to use another drive with this system?  Using a drive with
a separate power supply might at least rule out the power-related
problems.  You can also try to attach the drive to a powered USB 2.0
hub instead of directly attaching to the onboard port.


signature.asc
Description: Digital signature


AR9331 chipset has XactErr when working with USB 1.1 devices

2012-11-04 Thread Ashok Rao
New small and portable routers from TP-LINK  (TL-MR3020 and TL-MR3040)
incorporate this Atheros chipset.
On Linux  3.3.8  (and earlier kernels like 3.2.5)   we are finding
data transfer issues with USB 1.1 devices.

The device (a Samsung BlackJack phone working as a 3G modem) can pass
data to the Internet initially but as
pages are opened these Xact errors show up and the USB port does not
pass any data after that.
Since the stock TP-LINK firmware (Linux 2.6.31) on these devices is
being used with 3G modems world wide -presumably this problem does not
appear with 2.0 devices - though I haven't verified it myself.
Also if a USB 2.0 passive hub is used in the middle - the problem goes
away   - I guess because the chipset will be doing USB 2.0  and the
hub will be doing the translation to USB 1.1. - leading me to believe
that it is an issue with USB 1.1 data transfers with this chipset.

Similar issues have been reported on the openwrt forum - see
https://forum.openwrt.org/viewtopic.php?id=39956

Reading through the linux-usb forum it appears that such errors are
very difficult to fix since they are tied to the hardware
implementation. But posing this question anyway...

Ashok



Relevant snippet  of dmesg below (with USB DEBUG enabled in the kernel
build)  is:

Linux version 3.3.8 (rao@asus) (gcc version 4.6.4 20121001
(prerelease) (Linaro GCC 4.6-2012.10) ) #1 Sun Nov 4 12:33:27 EST 2012
[0.00] MyLoader: sysp=fa89c804, boardp=69cd3b24, parts=31a09c82
[0.00] bootconsole [early0] enabled
[0.00] CPU revision is: 00019374 (MIPS 24Kc)
[0.00] SoC: Atheros AR9330 rev 1
[0.00] Clocks: CPU:400.000MHz, DDR:400.000MHz, AHB:200.000MHz,
Ref:25.000MHz

   30.45] usb 1-1: matched this device!
[   31.06] ehci-platform ehci-platform: detected XactErr len 0/128 retry 1
[   36.44] usb 1-1: unlink qh32-0e01/81b7d100 start 1 [1/2 us]
[   36.45] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.45] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.48] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.48] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.49] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.50] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.50] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.52] usb usb1: clear tt buffer port 1, a2 ep2 t80808d80
[   36.61] ehci-platform ehci-platform: reused qh 81b7d100 schedule
[   36.61] usb 1-1: link qh32-0e01/81b7d100 start 1 [1/2 us]
[   38.22] usb 1-1: unlink qh32-0e01/81b7d100 start 1 [1/2 us]
[   38.23] usb usb1: clear tt buffer port 1, a2 ep2 t00808d80
[   38.23] usb usb1: clear tt buffer port 1, a2 ep2 t00808d80
[   38.24] usb usb1: clear tt buffer port 1, a2 ep2 t00808d80
[   38.25] usb usb1: clear tt buffer port 1, a2 ep2 t00808d80
[   38.38] ehci-platform ehci-platform: reused qh 81b7d100 schedule
[   38.38] usb 1-1: link qh32-0e01/81b7d100 start 1 [1/2 us]
[  164.94] ehci-platform ehci-platform: detected XactErr len 0/128 retry 1
[  180.84] ehci-platform ehci-platform: detected XactErr len 0/181 retry 1
[  204.98] ehci-platform ehci-platform: detected XactErr len 0/128 retry 1


FULL dmesg:

root@OpenWrt:~# dmesg
[0.00] Linux version 3.3.8 (rao@asus) (gcc version 4.6.4
20121001 (prerelease) (Linaro GCC 4.6-2012.10) ) #1 Sun Nov 4 12:33:27
EST 2012
[0.00] MyLoader: sysp=fa89c804, boardp=69cd3b24, parts=31a09c82
[0.00] bootconsole [early0] enabled
[0.00] CPU revision is: 00019374 (MIPS 24Kc)
[0.00] SoC: Atheros AR9330 rev 1
[0.00] Clocks: CPU:400.000MHz, DDR:400.000MHz, AHB:200.000MHz,
Ref:25.000MHz
[0.00] Determined physical RAM map:
[0.00]  memory: 0200 @  (usable)
[0.00] Initrd not found or empty - disabling initrd
[0.00] Zone PFN ranges:
[0.00]   Normal   0x -> 0x2000
[0.00] Movable zone start PFN for each node
[0.00] Early memory PFN ranges
[0.00] 0: 0x -> 0x2000
[0.00] On node 0 totalpages: 8192
[0.00] free_area_init_node: node 0, pgdat 802ce100,
node_mem_map 8100
[0.00]   Normal zone: 64 pages used for memmap
[0.00]   Normal zone: 0 pages reserved
[0.00]   Normal zone: 8128 pages, LIFO batch:0
[0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[0.00] pcpu-alloc: [0] 0
[0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[0.00] Kernel command line:  board=TL-MR3040
console=ttyATH0,115200 rootfstype=squashfs,jffs2 noinitrd
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[0.

Re: USB issue with kernel 3.6

2012-11-04 Thread Alan Stern
On Sun, 4 Nov 2012, Piergiorgio Sartor wrote:

> Hi all,
> 
> I've a strange problem with the USB subsystem, under
> kernel 3.6, this was not happening under 3.5.
> The system is Fedora, so I'll use their kernel numbers,
> and the related bug report is this:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=866166
> 
> I've some USB hubs cascaded in order to have 10 ports
> available.
> Two configurations: one is with 3 hubs, 4 ports each,
> where 2 hubs are connected to the first one.
> Second configuration is similar, it only uses 1 hubs
> with 7 ports followed by a 5 ports one.
> 
> To the resulting 10 ports are connected to 10 USB hard
> disks. This is a "feasibility study" on the possibility
> to create a storage device in this condition.
> 
> The 10 HDDs are combined in RAID-6.
> 
> Now, until kernel 3.5.6, everything was working fine,
> I can achieve around 43MB/sec transfer rate (read) from
> such setup, with high reliability.
> Of course, some times one HDD would flight away, but
> nothing really serious as a problem. In fact this was
> one of the point I wanted to check.
> 
> Since kernel 3.6.x, after short time accessing the
> RAID (or in parallel the 10 HDDs, independently from
> the md layer), I get error -110 from the USB subsystem
> and everything dies.
> It seems to me, but I'm not sure, reading a single
> HDD does not lead to this problem.

> Any idea or suggestion on how to test further?

The first thing you should do is test a 3.6 kernel with 
CONFIG_USB_DEBUG enabled and post the dmesg log showing the problem.  
That will help indicate what is going wrong.

If that doesn't suggest a solution, the next thing you should do is use 
git bisect to find which change to the kernel is responsible for the 
errors.  For this to work, you have to be able to tell reliably whether 
the problem is present or not with a particular kernel, but it sounds 
like that should be easy enough.

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: USB issue with kernel 3.6

2012-11-04 Thread Piergiorgio Sartor
On Sun, Nov 04, 2012 at 03:07:35PM -0500, Alan Stern wrote:
[...]
> The first thing you should do is test a 3.6 kernel with 
> CONFIG_USB_DEBUG enabled and post the dmesg log showing the problem.  
> That will help indicate what is going wrong.

I guess this is a compile time option.
Is it any run-time possibility to achieve a similar result?

> If that doesn't suggest a solution, the next thing you should do is use 
> git bisect to find which change to the kernel is responsible for the 
> errors.  For this to work, you have to be able to tell reliably whether 
> the problem is present or not with a particular kernel, but it sounds 
> like that should be easy enough.

This seems a bit out of reach, for several reasons.
I'll have to use a Fedora kernel, which might have its
own patches and I suspect things will become complicated
beyond my capability to manage them.
I might try on a different PC, with a vanilla kernel,
not sure...

I was hoping someone had in mind what could be the hotspot
and the possibility to check it quickly.

bye,

-- 

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


Re: USB issue with kernel 3.6

2012-11-04 Thread Piergiorgio Sartor
On Sun, Nov 04, 2012 at 03:07:35PM -0500, Alan Stern wrote:
[...]
> The first thing you should do is test a 3.6 kernel with 
> CONFIG_USB_DEBUG enabled and post the dmesg log showing the problem.  
> That will help indicate what is going wrong.
> 
> If that doesn't suggest a solution, the next thing you should do is use 
> git bisect to find which change to the kernel is responsible for the 
> errors.  For this to work, you have to be able to tell reliably whether 
> the problem is present or not with a particular kernel, but it sounds 
> like that should be easy enough.
> 
> Alan Stern

Forgot to thank you for the reply...

bye,

-- 

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


merging printk and WARN

2012-11-04 Thread Julia Lawall
It looks like these patches were not a good idea, because in each case the 
printk provides an error level, and WARN then provides another one.


Sorry for the noise.

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


058f:9360 8GB MicroSD card not recognized in Alcor Micro Corp. 8-in-1 Media Card Reader

2012-11-04 Thread Dan 'Da Man'
Bug Short Description: 058f:9360 8GB MicroSD card not recognized in
Alcor Micro Corp. 8-in-1 Media Card Reader

When I insert a 8GB MicroSD into my integrated Alcor Micro Corp.
8-in-1 Media Card Reader using Oneiric it is not recognized. However,
the same MicroSD card works in a different laptop's card reader.

As well, in 10.04.4 through 11.10, when I insert a 2GB SD card it is
recognized, automatically mounted, and a window opens to display what
files are on the card.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1069289

Linux version 3.7.0-030700rc4-generic (apw@gomeisa) (gcc version 4.6.3
(Ubuntu/Linaro 4.6.3-1ubuntu5) ) #201211041435 SMP Sun Nov 4 19:43:27
UTC 2012

Description:Ubuntu 11.10
Release:11.10


Linux casino 3.7.0-030700rc4-generic #201211041435 SMP Sun Nov 4
19:43:27 UTC 2012 i686 i686 i386 GNU/Linux

Gnu C  4.6.1
Gnu make   3.81
binutils   2.21.53.20110810
util-linux 2.19.1
mount  support
module-init-tools  3.16
e2fsprogs  1.41.14
pcmciautils015
Linux C Library2.13
Dynamic linker (ldd)   2.13
Procps 3.2.8
Net-tools  1.60
Kbd1.15.2
Sh-utils   8.5
wireless-tools 30
Modules Loaded nls_iso8859_1 binfmt_misc snd_intel8x0 snd_ac97_codec
joydev hid_generic radeon ac97_bus snd_pcm snd_seq_midi ppdev snd_rawmidi
ttm snd_seq_midi_event drm_kms_helper snd_seq drm snd_timer i2c_algo_bit
snd_seq_device snd psmouse soundcore microcode lpc_ich snd_page_alloc shpchp
serio_raw mac_hid parport_pc lp parport usbhid hid usb_storage uas 8139too
firewire_ohci 8139cp firewire_core crc_itu_t


processor: 0
vendor_id: GenuineIntel
cpu family: 15
model: 2
model name: Intel(R) Pentium(R) 4 CPU 3.20GHz
stepping: 9
microcode: 0x21
cpu MHz: 3200.317
cache size: 512 KB
physical id: 0
siblings: 1
core id: 0
cpu cores: 1
apicid: 0
initial apicid: 0
fdiv_bug: no
hlt_bug: no
f00f_bug: no
coma_bug: no
fpu: yes
fpu_exception: yes
cpuid level: 2
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr
bogomips: 6400.63
clflush size: 64
cache_alignment: 128
address sizes: 36 bits physical, 32 bits virtual
power management:

processor: 1
vendor_id: GenuineIntel
cpu family: 15
model: 2
model name: Intel(R) Pentium(R) 4 CPU 3.20GHz
stepping: 9
microcode: 0x21
cpu MHz: 3200.317
cache size: 512 KB
physical id: 0
siblings: 1
core id: 0
cpu cores: 0
apicid: 1
initial apicid: 1
fdiv_bug: no
hlt_bug: no
f00f_bug: no
coma_bug: no
fpu: yes
fpu_exception: yes
cpuid level: 2
wp: yes
flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr
bogomips: 6400.58
clflush size: 64
cache_alignment: 128
address sizes: 36 bits physical, 32 bits virtual
power management:

nls_iso8859_1 12617 1 - Live 0x (F)
binfmt_misc 17292 1 - Live 0x (F)
snd_intel8x0 33490 1 - Live 0x (F)
snd_ac97_codec 110219 1 snd_intel8x0, Live 0x (F)
joydev 17329 0 - Live 0x (F)
hid_generic 12445 0 - Live 0x (F)
radeon 845326 2 - Live 0x (F)
ac97_bus 12670 1 snd_ac97_codec, Live 0x (F)
snd_pcm 81801 2 snd_intel8x0,snd_ac97_codec, Live 0x (F)
snd_seq_midi 13132 0 - Live 0x (F)
ppdev 12849 0 - Live 0x (F)
snd_rawmidi 25425 1 snd_seq_midi, Live 0x (F)
ttm 76325 1 radeon, Live 0x (F)
snd_seq_midi_event 14475 1 snd_seq_midi, Live 0x (F)
drm_kms_helper 45429 1 radeon, Live 0x (F)
snd_seq 51568 2 snd_seq_midi,snd_seq_midi_event, Live 0x (F)
drm 228757 4 radeon,ttm,drm_kms_helper, Live 0x (F)
snd_timer 28931 2 snd_pcm,snd_seq, Live 0x (F)
i2c_algo_bit 13316 1 radeon, Live 0x (F)
snd_seq_device 14137 3 snd_seq_midi,snd_rawmidi,snd_seq, Live 0x (F)
snd 62674 9
snd_intel8x0,snd_ac97_codec,snd_pcm,snd_rawmidi,snd_seq,snd_timer,snd_seq_device,
Live 0x (F)
psmouse 77485 0 - Live 0x (F)
soundcore 14635 1 snd, Live 0x (F)
microcode 18433 0 - Live 0x (F)
lpc_ich 17048 0 - Live 0x (F)
snd_page_alloc 18398 2 snd_intel8x0,snd_pcm, Live 0x (F)
shpchp 32325 0 - Live 0x (F)
serio_raw 13031 0 - Live 0x (F)
mac_hid 13077 0 - Live 0x (F)
parport_pc 32114 1 - Live 0x (F)
lp 17455 0 - Live 0x (F)
parport 40930 3 ppdev,parport_pc,lp, Live 0x (F)
usbhid 46094 0 - Live 0x (F)
hid 82340 2 hid_generic,usbhid, Live 0x (F)
usb_storage 48053 1 - Live 0x (F)
uas 17936 0 - Live 0x

Re: USB issue with kernel 3.6

2012-11-04 Thread Ming Lei
On Mon, Nov 5, 2012 at 4:17 AM, Piergiorgio Sartor
 wrote:
>
> This seems a bit out of reach, for several reasons.
> I'll have to use a Fedora kernel, which might have its
> own patches and I suspect things will become complicated
> beyond my capability to manage them.
> I might try on a different PC, with a vanilla kernel,
> not sure...

Upstream kernel should run on Fedora distribution directly
after you compile and install it.


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] USB: rcar-phy: fixup implicit declaration of function 'iowrite32'

2012-11-04 Thread Kuninori Morimoto
Current rcar-phy driver used iowerite32/ioread32,
but it cause compile error on some architectures.
This patch used writel/readl and HAS_IOMEM to solve this issue.

drivers/usb/phy/rcar-phy.c: In function 'rcar_usb_phy_init':
drivers/usb/phy/rcar-phy.c:75:3: error: implicit declaration of function\
'iowrite32' [-Werror=implicit-function-declaration]
drivers/usb/phy/rcar-phy.c:83:4: error: implicit declaration of function\
'ioread32' [-Werror=implicit-function-declaration]

Signed-off-by: Kuninori Morimoto 
---
>> Felipe

Sorry for late response.
Does this patch solve the issue ?

 drivers/usb/phy/Kconfig|1 +
 drivers/usb/phy/rcar-phy.c |   26 +-
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7eb73c5..39f920b 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -36,6 +36,7 @@ config MV_U3D_PHY
 config USB_RCAR_PHY
tristate "Renesas R-Car USB phy support"
depends on USB || USB_GADGET
+   depends on HAS_IOMEM
select USB_OTG_UTILS
help
  Say Y here to add support for the Renesas R-Car USB phy driver.
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
index 792f505..0096660c 100644
--- a/drivers/usb/phy/rcar-phy.c
+++ b/drivers/usb/phy/rcar-phy.c
@@ -72,15 +72,15 @@ static int rcar_usb_phy_init(struct usb_phy *phy)
 */
 
/* (1) USB-PHY standby release */
-   iowrite32(PHY_ENB, (reg0 + USBPCTRL1));
+   writel(PHY_ENB, (reg0 + USBPCTRL1));
 
/* (2) start USB-PHY internal PLL */
-   iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
+   writel(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
 
/* (3) USB module status check */
for (i = 0; i < 1024; i++) {
udelay(10);
-   val = ioread32(reg0 + USBST);
+   val = readl(reg0 + USBST);
if (val == (ST_ACT | ST_PLL))
break;
}
@@ -91,10 +91,10 @@ static int rcar_usb_phy_init(struct usb_phy *phy)
}
 
/* (4) USB-PHY reset clear */
-   iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
+   writel(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
 
/* set platform specific port settings */
-   iowrite32(0x, (reg0 + USBPCTRL0));
+   writel(0x, (reg0 + USBPCTRL0));
 
/*
 * EHCI IP internal buffer setting
@@ -103,21 +103,21 @@ static int rcar_usb_phy_init(struct usb_phy *phy)
 * These are recommended value of a datasheet
 * see [USB :: EHCI internal buffer setting]
 */
-   iowrite32(0x00ff0040, (reg0 + EIIBC1));
-   iowrite32(0x00ff0040, (reg1 + EIIBC1));
+   writel(0x00ff0040, (reg0 + EIIBC1));
+   writel(0x00ff0040, (reg1 + EIIBC1));
 
-   iowrite32(0x0001, (reg0 + EIIBC2));
-   iowrite32(0x0001, (reg1 + EIIBC2));
+   writel(0x0001, (reg0 + EIIBC2));
+   writel(0x0001, (reg1 + EIIBC2));
 
/*
 * Bus alignment settings
 */
 
/* (1) EHCI bus alignment (little endian) */
-   iowrite32(0x, (reg0 + USBEH0));
+   writel(0x, (reg0 + USBEH0));
 
/* (1) OHCI bus alignment (little endian) */
-   iowrite32(0x, (reg0 + USBOH0));
+   writel(0x, (reg0 + USBOH0));
}
 
 phy_init_end:
@@ -135,8 +135,8 @@ static void rcar_usb_phy_shutdown(struct usb_phy *phy)
spin_lock_irqsave(&priv->lock, flags);
 
if (priv->counter-- == 1) { /* last user */
-   iowrite32(0x, (reg0 + USBPCTRL0));
-   iowrite32(0x, (reg0 + USBPCTRL1));
+   writel(0x, (reg0 + USBPCTRL0));
+   writel(0x, (reg0 + USBPCTRL1));
}
 
spin_unlock_irqrestore(&priv->lock, flags);
-- 
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: USB issue with kernel 3.6

2012-11-04 Thread Alan Stern
On Sun, 4 Nov 2012, Piergiorgio Sartor wrote:

> On Sun, Nov 04, 2012 at 03:07:35PM -0500, Alan Stern wrote:
> [...]
> > The first thing you should do is test a 3.6 kernel with 
> > CONFIG_USB_DEBUG enabled and post the dmesg log showing the problem.  
> > That will help indicate what is going wrong.
> 
> I guess this is a compile time option.

Yes.

> Is it any run-time possibility to achieve a similar result?

No.

> > If that doesn't suggest a solution, the next thing you should do is use 
> > git bisect to find which change to the kernel is responsible for the 
> > errors.  For this to work, you have to be able to tell reliably whether 
> > the problem is present or not with a particular kernel, but it sounds 
> > like that should be easy enough.
> 
> This seems a bit out of reach, for several reasons.
> I'll have to use a Fedora kernel, which might have its
> own patches and I suspect things will become complicated
> beyond my capability to manage them.
> I might try on a different PC, with a vanilla kernel,
> not sure...
> 
> I was hoping someone had in mind what could be the hotspot
> and the possibility to check it quickly.

Not me, I'm afraid.

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: 058f:9360 8GB MicroSD card not recognized in Alcor Micro Corp. 8-in-1 Media Card Reader

2012-11-04 Thread Alan Stern
On Sun, 4 Nov 2012, Dan 'Da Man' wrote:

> Bug Short Description: 058f:9360 8GB MicroSD card not recognized in
> Alcor Micro Corp. 8-in-1 Media Card Reader
> 
> When I insert a 8GB MicroSD into my integrated Alcor Micro Corp.
> 8-in-1 Media Card Reader using Oneiric it is not recognized. However,
> the same MicroSD card works in a different laptop's card reader.
> 
> As well, in 10.04.4 through 11.10, when I insert a 2GB SD card it is
> recognized, automatically mounted, and a window opens to display what
> files are on the card.

It's possible that the old 8-in-1 media card reader can't handle
high-capacity SD cards.  It works okay with the low capacity 2-GB card
but not the 8-GB SDHC card.

However it wouldn't hurt to get more information.  You should post a 
usbmon trace showing what happens when the 8-GB card is inserted.

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


[PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.

2012-11-04 Thread Harvey Yang
From: harvey.yang 


Signed-off-by: harvey.yang 
---
 drivers/staging/usbip/usbip_event.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/usbip_event.c 
b/drivers/staging/usbip/usbip_event.c
index d332a34..668f8e0 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -116,10 +116,8 @@ int usbip_event_happened(struct usbip_device *ud)
 {
int happened = 0;
 
-   spin_lock(&ud->lock);
if (ud->event != 0)
happened = 1;
-   spin_unlock(&ud->lock);
 
return happened;
 }
-- 
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/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.

2012-11-04 Thread Greg Kroah-Hartman
On Mon, Nov 05, 2012 at 12:50:26PM +0800, Harvey Yang wrote:
> From: harvey.yang 
> 
> 
> Signed-off-by: harvey.yang 
> ---
>  drivers/staging/usbip/usbip_event.c |2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/usbip/usbip_event.c 
> b/drivers/staging/usbip/usbip_event.c
> index d332a34..668f8e0 100644
> --- a/drivers/staging/usbip/usbip_event.c
> +++ b/drivers/staging/usbip/usbip_event.c
> @@ -116,10 +116,8 @@ int usbip_event_happened(struct usbip_device *ud)
>  {
>   int happened = 0;
>  
> - spin_lock(&ud->lock);
>   if (ud->event != 0)
>   happened = 1;
> - spin_unlock(&ud->lock);
>  
>   return happened;

Are you sure that the real fix for this isn't just making 'happened' a
static variable?  That would make more sense here.  Well maybe, the code
seems pretty dumb, it's hard to tell what this is supposed to be doing,
any ideas?

thanks,

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


Re: [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.

2012-11-04 Thread Prashant Shah
Hi,

> int happened = 0;
>
> -   spin_lock(&ud->lock);
> if (ud->event != 0)
> happened = 1;
> -   spin_unlock(&ud->lock);
>
> return happened;

I am guessing locking was intended to protect ud->event along with
happened so that (checking the value of ud->event and setting value of
happened) was atomic.

return ud->event != 0 ? 1 : 0;

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


Re: [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.

2012-11-04 Thread harvey yang
I think no need to make 'happened' static as we just check 'ud->event'
feild. Maybe making this function inline would make more sense.

inline int usbip_event_happened(struct usbip_device *ud)
{
return ud->event ? 1 : 0;
}

Thanks
Harvey


On Mon, Nov 5, 2012 at 1:34 PM, Prashant Shah  wrote:
> Hi,
>
>> int happened = 0;
>>
>> -   spin_lock(&ud->lock);
>> if (ud->event != 0)
>> happened = 1;
>> -   spin_unlock(&ud->lock);
>>
>> return happened;
>
> I am guessing locking was intended to protect ud->event along with
> happened so that (checking the value of ud->event and setting value of
> happened) was atomic.
>
> return ud->event != 0 ? 1 : 0;
>
> Regards.
--
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: AR9331 chipset has XactErr when working with USB 1.1 devices

2012-11-04 Thread Greg KH
On Sun, Nov 04, 2012 at 02:42:32PM -0500, Ashok Rao wrote:
> New small and portable routers from TP-LINK  (TL-MR3020 and TL-MR3040)
> incorporate this Atheros chipset.
> On Linux  3.3.8  (and earlier kernels like 3.2.5)   we are finding
> data transfer issues with USB 1.1 devices.
> 
> The device (a Samsung BlackJack phone working as a 3G modem) can pass
> data to the Internet initially but as
> pages are opened these Xact errors show up and the USB port does not
> pass any data after that.
> Since the stock TP-LINK firmware (Linux 2.6.31) on these devices is
> being used with 3G modems world wide -presumably this problem does not
> appear with 2.0 devices - though I haven't verified it myself.
> Also if a USB 2.0 passive hub is used in the middle - the problem goes
> away   - I guess because the chipset will be doing USB 2.0  and the
> hub will be doing the translation to USB 1.1. - leading me to believe
> that it is an issue with USB 1.1 data transfers with this chipset.


What driver is controlling the ohci controller in this chipset?  Does
this hardware work properly with a "stock" kernel.org release of 2.6.31?
Or does that release require some patches (like the controller driver?)
Figuring out where we broke something would be a good thing to do.

thanks,

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


Re: [PATCH 1/1] usb: at91_udc: fix typo on vubs pullup valid check

2012-11-04 Thread Greg Kroah-Hartman
On Mon, Nov 05, 2012 at 08:39:43AM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> if the gpio is not valid complain
> 
> since 3285e0ec088febc5a88f57ddd78385a7da71476c
> ARM: at91/udc: use gpio_is_valid to check the gpio
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> Cc: linux-usb@vger.kernel.org
> Cc: Greg Kroah-Hartman 
> Cc: Nicolas Ferre 
> ---
> Hi Greg,
> 
>   this is broken since 3.2 can we have on the stable too

Sure, but you should be sending gadget patches to Felipe, not me, as
he's in charge of that tree.  So I suggest you resend this, cc: Felipe
and add the proper stable tree marking to the Cc: area of the
signed-off-by: part of the patch, like the file
Documentation/stable_kernel_rules.txt describes to do.  That way it will
be picked up automatically for the stable releases when it gets in to
Linus's tree.

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