Support for new USB Modem 4G drive

2014-03-19 Thread Julio Araujo

Hello,

My name is Julio and I'm trying to use a USB Modem 4G model OLICARD500 
from the manufacture Olivetti and I got the follow message from syslog:
Mar 19 05:23:29 mynote kernel: [  265.072844] usbserial_generic 
1-1.3:1.0: Tell linux-usb@vger.kernel.org to add your device to a proper 
driver.
Mar 19 05:23:29 mynote kernel: [  265.072852] usbserial_generic 
1-1.3:1.0: generic converter detected
Mar 19 05:23:29 mynote kernel: [  265.073168] usb 1-1.3: generic 
converter now attached to ttyUSB0
Mar 19 05:23:29 mynote kernel: [  265.073385] usbserial_generic 
1-1.3:1.1: The "generic" usb-serial driver is only for testing and 
one-off prototypes.

So this is the reason why I'm sending this email.

Follow the printout from lsusb:
julio@mynote:~$ lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 04f2:b351 Chicony Electronics Co., Ltd
Bus 002 Device 006: ID 058f:9254 Alcor Micro Corp. Hub
Bus 002 Device 011: ID 0b3c:f017 Olivetti Techcenter
Bus 002 Device 007: ID 04fc:0538 Sunplus Technology Co., Ltd Wireless 
Optical Mouse 2.4G [Bright]


I'm not a programmer, but I'm using Linux Ubuntu since 2007 in my home 
so could you please help me with this issue?
If you need me to do any kind of test or get any log or file from my 
system in order to help please let me know.


Thank you in advance.

My kind regards,
--
Julio Araujo
+551298283-5264 (TIM)
julio.ara...@wllctel.com.br 
geren...@wllctel.com.br 
--
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: questions about give back urb in tasklet

2014-03-19 Thread vichy
hi  Ming.lei:
2014-03-17 22:01 GMT+08:00 Alan Stern :
> On Sun, 16 Mar 2014, vichy wrote:
>
>> hi all:
>> recently we bump to system performance issue when usb irq take quite long.
>> I found below link for discussing how to short
>>

in http://permalink.gmane.org/gmane.linux.usb.general/89363

I have some questions about this patch.
1. is there patch or kernel config I can use to measure man/avage usb
irq time consuming like the above link show

2. I see this patch is roll back in commit
"c04ee4b1136e462722567cf6e76bb35a181574a7" and intend to be ready in
3.13-rc1
Is there special reason why we need to roll back?

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


[PATCH v4 00/11] Add USB OTG HNP and SRP support on Chipidea usb driver

2014-03-19 Thread Li Jun
From: Li Jun 

This patchset adds USB OTG HNP and SRP support on chipidea usb driver,
existing OTG port role swtich function by ID pin status kept unchanged,
based on that, if select CONFIG_USB_OTG_FSM, OTG HNP and SRP will be
supported.

Reference to:
"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification 
July 27, 2012
Revision 2.0 version 1.1a"

Changes since v3:
- Move out 2 patches from this patchset, as which are not directly related to
  otg fsm.
- Add a new file chipidea.txt under Documentation/usb/ to show how to test
  OTG HNP and SRP.
- Directly embed struct otg_fsm into ci_hdrc instead of pointer of otg_fsm.
- Remove flag check in ci_otg_del_timer().
- Remove ADP related code and comments since ADP is not supported by chip.
- Start OTG fsm before request_irq.
- For B-device, do not do OTG fsm transitions when gadget driver
  is not registered, and start OTG fsm in register gadget driver.
- Directly call ci_otg_fsm_work() in ci_hdrc_otg_fsm_start().
- Enable data pulse when a_wait_vfall timer time out.
- Update a_wait_vrise time out function.
- UPdate comments of OTG time macro definitions in otg_fsm.h according to
  OTG and EH 2.0.
- Some typo correction and comments format changes.

Changes since v2:
- Add ABI document for sysfs input files description:
  Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
- Add a debug file for show some USB registers value.
- Split host driver change to be 2 patches, one for otg_port number init;
  the other one for vbus control change.
- Export interrupt enable and status read functions from udc driver.
- Only enable AVV irq in otg fsm init.
- Remove duplicated USBSTS bits definitions.
- Add HowTo demo role switch with 2 Freescale i.MX6Q sabre SD boards
  in cover letter.
- typo correction.

Changes since v1:
- Move out HNP polling patch from this series, which will be a seperated 
patchset
  followed this one
- Change fsm timers global variables to be a structure embeded in ci_hdrc,
  to make multiple OTG instances can exist in one system
- Change some otg fsm functions to be static
- Re-split timer init patch to avoid a later patch changing a previous one
  in the same series
- Change timer structure memory allocation to be devm_kzalloc
- Update some format alignment and spelling errors

Li Jun (11):
  usb: chipidea: usb OTG fsm initialization.
  usb: chipidea: host: vbus control change for OTG HNP.
  usb: chipidea: host: init otg port number.
  usb: chipidea: udc: driver update for OTG HNP.
  usb: chipidea: add OTG fsm operation functions implemenation.
  usb: chipidea: OTG fsm timers initialization.
  usb: chipidea: OTG HNP and SRP fsm implementation.
  usb: chipidea: add sys inputs for OTG fsm input.
  usb: chipidea: debug: add debug file for OTG variables
  Documentation: ABI: usb: chipidea USB OTG HNP sysfs
  Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and
SRP

 .../ABI/testing/sysfs-platform-chipidea-usb-otg|   56 ++
 Documentation/usb/chipidea.txt |   69 ++
 drivers/usb/chipidea/Makefile  |1 +
 drivers/usb/chipidea/bits.h|   11 +-
 drivers/usb/chipidea/ci.h  |3 +
 drivers/usb/chipidea/core.c|   10 +-
 drivers/usb/chipidea/debug.c   |   84 ++
 drivers/usb/chipidea/host.c|   13 +-
 drivers/usb/chipidea/host.h|9 +
 drivers/usb/chipidea/otg.c |   17 +-
 drivers/usb/chipidea/otg_fsm.c |  852 
 drivers/usb/chipidea/otg_fsm.h |  122 +++
 drivers/usb/chipidea/udc.c |   17 +-
 13 files changed, 1255 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
 create mode 100644 Documentation/usb/chipidea.txt
 create mode 100644 drivers/usb/chipidea/otg_fsm.c
 create mode 100644 drivers/usb/chipidea/otg_fsm.h

-- 
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 02/11] usb: chipidea: host: vbus control change for OTG HNP.

2014-03-19 Thread Li Jun
Leave vbus on/off hanlded by OTG fsm if in OTG mode.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/host.c |6 +++---
 drivers/usb/chipidea/host.h |9 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index a8ac6c1..4b609bc 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -67,7 +67,7 @@ static int host_start(struct ci_hdrc *ci)
ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
ehci->imx28_write_fix = ci->imx28_write_fix;
 
-   if (ci->platdata->reg_vbus) {
+   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci)) {
ret = regulator_enable(ci->platdata->reg_vbus);
if (ret) {
dev_err(ci->dev,
@@ -89,7 +89,7 @@ static int host_start(struct ci_hdrc *ci)
return ret;
 
 disable_reg:
-   if (ci->platdata->reg_vbus)
+   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci))
regulator_disable(ci->platdata->reg_vbus);
 
 put_hcd:
@@ -105,7 +105,7 @@ static void host_stop(struct ci_hdrc *ci)
if (hcd) {
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
-   if (ci->platdata->reg_vbus)
+   if (ci->platdata->reg_vbus && !ci_host_is_otg(ci))
regulator_disable(ci->platdata->reg_vbus);
}
 }
diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h
index 5707bf3..f98d084 100644
--- a/drivers/usb/chipidea/host.h
+++ b/drivers/usb/chipidea/host.h
@@ -6,6 +6,15 @@
 int ci_hdrc_host_init(struct ci_hdrc *ci);
 void ci_hdrc_host_destroy(struct ci_hdrc *ci);
 
+static inline bool ci_host_is_otg(struct ci_hdrc *ci)
+{
+#ifdef CONFIG_USB_OTG_FSM
+   return (ci->is_otg) && (ci->platdata->dr_mode == USB_DR_MODE_OTG);
+#else
+   return false;
+#endif
+}
+
 #else
 
 static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
-- 
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 05/11] usb: chipidea: add OTG fsm operation functions implemenation.

2014-03-19 Thread Li Jun
Add OTG HNP and SRP operation functions implementation:
- charge vbus
- drive vbus
- connection signaling
- drive sof
- start data pulse
- add fsm timer
- delete fsm timer
- start host
- start gadget

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/bits.h|   10 +-
 drivers/usb/chipidea/ci.h  |1 +
 drivers/usb/chipidea/otg_fsm.c |  203 
 drivers/usb/chipidea/otg_fsm.h |   23 +
 4 files changed, 236 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 83d06c1..9e95378 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -44,9 +44,14 @@
 #define DEVICEADDR_USBADR (0x7FUL << 25)
 
 /* PORTSC */
+#define PORTSC_CCSBIT(0)
+#define PORTSC_CSCBIT(1)
+#define PORTSC_PECBIT(3)
+#define PORTSC_OCCBIT(5)
 #define PORTSC_FPRBIT(6)
 #define PORTSC_SUSP   BIT(7)
 #define PORTSC_HSPBIT(9)
+#define PORTSC_PP BIT(12)
 #define PORTSC_PTC(0x0FUL << 16)
 #define PORTSC_PHCD(d)   ((d) ? BIT(22) : BIT(23))
 /* PTS and PTW for non lpm version only */
@@ -56,6 +61,9 @@
 #define PORTSC_PTWBIT(28)
 #define PORTSC_STSBIT(29)
 
+#define PORTSC_W1C_BITS\
+   (PORTSC_CSC | PORTSC_PEC | PORTSC_OCC)
+
 /* DEVLC */
 #define DEVLC_PFSCBIT(23)
 #define DEVLC_PSPD(0x03UL << 25)
@@ -69,9 +77,9 @@
 #define PTS_ULPI  2
 #define PTS_SERIAL3
 #define PTS_HSIC  4
-
 /* OTGSC */
 #define OTGSC_IDPU   BIT(5)
+#define OTGSC_HADP   BIT(6)
 #define OTGSC_ID BIT(8)
 #define OTGSC_AVVBIT(9)
 #define OTGSC_ASVBIT(10)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 4491c43..cece7e2 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -176,6 +176,7 @@ struct ci_hdrc {
enum ci_rolerole;
boolis_otg;
struct otg_fsm  fsm;
+   struct ci_otg_fsm_timer_list*fsm_timer;
struct work_struct  work;
struct workqueue_struct *wq;
 
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index fbe63f0..f0e50fd 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -18,12 +18,214 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ci.h"
 #include "bits.h"
 #include "otg.h"
 #include "otg_fsm.h"
 
+/*
+ * Add timer to active timer list
+ */
+static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
+{
+   struct ci_otg_fsm_timer *tmp_timer;
+   struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
+   struct list_head *active_timers = &ci->fsm_timer->active_timers;
+
+   if (t >= NUM_CI_OTG_FSM_TIMERS)
+   return;
+
+   /*
+* Check if the timer is already in the active list,
+* if so update timer count
+*/
+   list_for_each_entry(tmp_timer, active_timers, list)
+   if (tmp_timer == timer) {
+   timer->count = timer->expires;
+   return;
+   }
+
+   timer->count = timer->expires;
+   list_add_tail(&timer->list, active_timers);
+
+   /* Enable 1ms irq */
+   if (!(hw_read_otgsc(ci, OTGSC_1MSIE)))
+   hw_write_otgsc(ci, OTGSC_1MSIE, OTGSC_1MSIE);
+}
+
+/*
+ * Remove timer from active timer list
+ */
+static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
+{
+   struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
+   struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
+   struct list_head *active_timers = &ci->fsm_timer->active_timers;
+
+   if (t >= NUM_CI_OTG_FSM_TIMERS)
+   return;
+
+   list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list)
+   if (tmp_timer == timer)
+   list_del(&timer->list);
+
+   /* Disable 1ms irq if there is no any active timer */
+   if (list_empty(active_timers))
+   hw_write_otgsc(ci, OTGSC_1MSIE, 0);
+}
+
+/* -*/
+/* Operations that will be called from OTG Finite State Machine */
+/* -*/
+static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
+{
+   struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
+
+   if (t < NUM_OTG_FSM_TIMERS)
+   ci_otg_add_timer(ci, t);
+   return;
+}
+
+static void ci_otg_fsm_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
+{
+   struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
+
+   if (t < NUM_OTG_FSM_TIMERS)
+   ci_otg_del_timer(ci, t);
+   retu

[PATCH v4 10/11] Documentation: ABI: usb: sysfs Description for chipidea USB OTG HNP and SRP

2014-03-19 Thread Li Jun
From: Li Jun 

This patch adds sysfs interface description for chipidea USB OTG HNP and SRP.

Signed-off-by: Li Jun 
---
 .../ABI/testing/sysfs-platform-chipidea-usb-otg|   56 
 1 file changed, 56 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg 
b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
new file mode 100644
index 000..6498810
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-platform-chipidea-usb-otg
@@ -0,0 +1,56 @@
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Can be set and read.
+   Set a_bus_req(A-device bus request) input to be 1 if
+   the Application running on the A-device wants to use the bus,
+   and to be 0 when the Application no longer wants to use
+   the bus(or wants to work as peripheral). a_bus_req can also
+   be set to 1 by kernel in response to remote wakeup signaling
+   from the B-device, the A-device should decide to resume the bus.
+
+   Valid values are "1" and "0".
+
+   Reading: returns 1 if the application running on the A-device
+   is using the bus as host role, otherwise 0.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Can be set and read
+   The a_bus_drop(A-device bus drop) input is 1 when the
+   Application running on the A-device wants to power down
+   the bus, and is 0 otherwise, When a_bus_drop is 1, then
+   the a_bus_req shall be 0.
+
+   Valid values are "1" and "0".
+
+   Reading: returns 1 if the bus is off(vbus is turned off) by
+A-device, otherwise 0.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Can be set and read.
+   The b_bus_req(B-device bus request) input is 1 during the time
+   that the Application running on the B-device wants to use the
+   bus as host, and is 0 when the Application no longer wants to
+   work as host and decides to switch back to be peripheral.
+
+   Valid values are "1" and "0".
+
+   Reading: returns if the application running on the B device
+   is using the bus as host role, otherwise 0.
+
+What:  /sys/bus/platform/devices/ci_hdrc.0/inputs/a_clr_err
+Date:  Feb 2014
+Contact:   Li Jun 
+Description:
+   Only can be set.
+   The a_clr_err(A-device Vbus error clear) input is used to clear
+   vbus error, then A-device will power down the bus.
+
+   Valid value is "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 08/11] usb: chipidea: add sys inputs for OTG fsm input.

2014-03-19 Thread Li Jun
From: Li Jun 

This patch adds sys input to control and show OTG fsm inputs by application,
user can do host and preipheral role switch by change these inputs.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/otg.c |1 +
 drivers/usb/chipidea/otg_fsm.c |  174 
 drivers/usb/chipidea/otg_fsm.h |6 ++
 3 files changed, 181 insertions(+)

diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 5098982..6de2f76 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -144,4 +144,5 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
/* Disable all OTG irq and clear status */
hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
OTGSC_INT_STATUS_BITS);
+   ci_hdrc_otg_fsm_remove(ci);
 }
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 569f208..fc0c6ce 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -41,6 +41,167 @@ static struct ci_otg_fsm_timer *otg_timer_initializer
return timer;
 }
 
+/* Add for otg: interact with user space app */
+static ssize_t
+get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_req);
+   size -= t;
+   next += t;
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_req(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1;
+
+   mutex_lock(&ci->fsm.lock);
+   if (buf[0] == '0') {
+   ci->fsm.a_bus_req = 0;
+   } else if (buf[0] == '1') {
+   /* If a_bus_drop is TRUE, a_bus_req can't be set */
+   if (ci->fsm.a_bus_drop) {
+   mutex_unlock(&ci->fsm.lock);
+   return count;
+   }
+   ci->fsm.a_bus_req = 1;
+   }
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   mutex_unlock(&ci->fsm.lock);
+
+   return count;
+}
+static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
+
+static ssize_t
+get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_drop);
+   size -= t;
+   next += t;
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_drop(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1;
+
+   mutex_lock(&ci->fsm.lock);
+   if (buf[0] == '0') {
+   ci->fsm.a_bus_drop = 0;
+   } else if (buf[0] == '1') {
+   ci->fsm.a_bus_drop = 1;
+   ci->fsm.a_bus_req = 0;
+   }
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   mutex_unlock(&ci->fsm.lock);
+
+   return count;
+}
+static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop,
+   set_a_bus_drop);
+
+static ssize_t
+get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   char*next;
+   unsignedsize, t;
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   next = buf;
+   size = PAGE_SIZE;
+   t = scnprintf(next, size, "%d\n", ci->fsm.b_bus_req);
+   size -= t;
+   next += t;
+
+   return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_b_bus_req(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1;
+
+   mutex_lock(&ci->fsm.lock);
+   if (buf[0] == '0')
+   ci->fsm.b_bus_req = 0;
+   else if (buf[0] == '1')
+   ci->fsm.b_bus_req = 1;
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   mutex_unlock(&ci->fsm.lock);
+
+   return count;
+}
+static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
+
+static ssize_t
+set_a_clr_err(struct device *dev, struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct ci_hdrc  *ci = dev_get_drvdata(dev);
+
+   if (count > 2)
+   return -1;
+
+   mutex_lock(&ci->fsm.lock);

[PATCH v4 03/11] usb: chipidea: host: init otg port number.

2014-03-19 Thread Li Jun
Init otg_port number of otg capable host to be 1 at host start.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/host.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 4b609bc..5ec8ccd 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -80,8 +80,13 @@ static int host_start(struct ci_hdrc *ci)
ret = usb_add_hcd(hcd, 0, 0);
if (ret)
goto disable_reg;
-   else
+   else {
ci->hcd = hcd;
+   if (ci_host_is_otg(ci)) {
+   ci->transceiver->otg->host = &hcd->self;
+   ci->transceiver->otg->host->otg_port = 1;
+   }
+   }
 
if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
-- 
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 06/11] usb: chipidea: OTG fsm timers initialization.

2014-03-19 Thread Li Jun
From: Li Jun 

This patch adds OTG fsm timers initialization, which use controller's 1ms
interrupt as timeout counter, also adds some local timers which are not
in otg_fsm_timer list.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/bits.h|1 +
 drivers/usb/chipidea/otg_fsm.c |  188 
 drivers/usb/chipidea/otg_fsm.h |   46 ++
 3 files changed, 235 insertions(+)

diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 9e95378..c6f1767 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -80,6 +80,7 @@
 /* OTGSC */
 #define OTGSC_IDPU   BIT(5)
 #define OTGSC_HADP   BIT(6)
+#define OTGSC_HABA   BIT(7)
 #define OTGSC_ID BIT(8)
 #define OTGSC_AVVBIT(9)
 #define OTGSC_ASVBIT(10)
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index f0e50fd..1fcb2b0 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -25,6 +25,22 @@
 #include "otg.h"
 #include "otg_fsm.h"
 
+static struct ci_otg_fsm_timer *otg_timer_initializer
+(struct ci_hdrc *ci, void (*function)(void *, unsigned long),
+   unsigned long expires, unsigned long data)
+{
+   struct ci_otg_fsm_timer *timer;
+
+   timer = devm_kzalloc(ci->dev, sizeof(struct ci_otg_fsm_timer),
+   GFP_KERNEL);
+   if (!timer)
+   return NULL;
+   timer->function = function;
+   timer->expires = expires;
+   timer->data = data;
+   return timer;
+}
+
 /*
  * Add timer to active timer list
  */
@@ -76,6 +92,161 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum 
ci_otg_fsm_timer_index t)
hw_write_otgsc(ci, OTGSC_1MSIE, 0);
 }
 
+/* The timeout callback function to set time out bit */
+static void set_tmout(void *ptr, unsigned long indicator)
+{
+   *(int *)indicator = 1;
+}
+
+static void set_tmout_and_fsm(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+}
+
+static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+   /* Clear exsiting DP irq */
+   hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
+   /* Enable data pulse irq */
+   hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+}
+
+static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+   if (!hw_read_otgsc(ci, OTGSC_BSVIS))
+   ci->fsm.b_sess_vld = 0;
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+}
+
+static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   set_tmout(ci, indicator);
+
+   /* only vbus fall below B_sess_vld in b_idle state */
+   if (ci->transceiver->state == OTG_STATE_B_IDLE) {
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+}
+
+static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   /* Check if A detached */
+   if (!(hw_read_otgsc(ci, OTGSC_BSV))) {
+   ci->fsm.b_sess_vld = 0;
+   ci_otg_add_timer(ci, B_SSEND_SRP);
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+   }
+}
+
+static void b_data_pulse_end(void *ptr, unsigned long indicator)
+{
+   struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
+
+   ci->fsm.b_srp_done = 1;
+   ci->fsm.b_bus_req = 0;
+   if (ci->fsm.power_up)
+   ci->fsm.power_up = 0;
+
+   hw_write_otgsc(ci, OTGSC_HABA, 0);
+
+   disable_irq_nosync(ci->irq);
+   queue_work(ci->wq, &ci->work);
+}
+
+/* Initialize timers */
+static int ci_otg_init_timers(struct ci_hdrc *ci)
+{
+   struct otg_fsm *fsm = &ci->fsm;
+
+   /* FSM used timers */
+   ci->fsm_timer->timer_list[A_WAIT_VRISE] =
+   otg_timer_initializer(ci, &set_tmout_and_fsm, TA_WAIT_VRISE,
+   (unsigned long)&fsm->a_wait_vrise_tmout);
+   if (ci->fsm_timer->timer_list[A_WAIT_VRISE] == NULL)
+   return -ENOMEM;
+
+   ci->fsm_timer->timer_list[A_WAIT_VFALL] =
+   otg_timer_initializer(ci, &a_wait_vfall_tmout_func,
+   TA_WAIT_VFALL, (unsigned long)&fsm->a_wait_vfall_tmout);
+   if (ci->fsm_timer->timer_list[A_WAIT_VFALL] == NULL)
+   return -ENOMEM;
+
+   ci->fsm_timer->timer_list[A_WAIT_BCON] =
+   otg_timer_initializer(ci, &set_tmout_and_

[PATCH v4 01/11] usb: chipidea: usb OTG fsm initialization.

2014-03-19 Thread Li Jun
This patch adds OTG fsm related initialization when do otg init,
add a seperate file for OTG fsm related utilities.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/Makefile  |1 +
 drivers/usb/chipidea/ci.h  |2 ++
 drivers/usb/chipidea/otg.c |7 +
 drivers/usb/chipidea/otg_fsm.c |   60 
 drivers/usb/chipidea/otg_fsm.h |   29 +++
 5 files changed, 99 insertions(+)

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 480bd4d..2f099c7 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -6,6 +6,7 @@ ci_hdrc-y   := core.o otg.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)   += debug.o
+ci_hdrc-$(CONFIG_USB_OTG_FSM)  += otg_fsm.o
 
 # Glue/Bridge layers go here
 
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 7ae8cb6..4491c43 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * DEFINE
@@ -174,6 +175,7 @@ struct ci_hdrc {
struct ci_role_driver   *roles[CI_ROLE_END];
enum ci_rolerole;
boolis_otg;
+   struct otg_fsm  fsm;
struct work_struct  work;
struct workqueue_struct *wq;
 
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index c694340..3082b52 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -22,6 +22,7 @@
 #include "ci.h"
 #include "bits.h"
 #include "otg.h"
+#include "otg_fsm.h"
 
 /**
  * hw_read_otgsc returns otgsc register bits value.
@@ -109,6 +110,12 @@ static void ci_otg_work(struct work_struct *work)
  */
 int ci_hdrc_otg_init(struct ci_hdrc *ci)
 {
+   int retval = 0;
+
+   retval = ci_hdrc_otg_fsm_init(ci);
+   if (retval)
+   return retval;
+
INIT_WORK(&ci->work, ci_otg_work);
ci->wq = create_singlethread_workqueue("ci_otg");
if (!ci->wq) {
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
new file mode 100644
index 000..fbe63f0
--- /dev/null
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -0,0 +1,60 @@
+/*
+ * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ *
+ * Author: Jun Li
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This file mainly handles OTG fsm, it includes OTG fsm operations
+ * for HNP and SRP.
+ */
+
+#include 
+#include 
+#include 
+
+#include "ci.h"
+#include "bits.h"
+#include "otg.h"
+#include "otg_fsm.h"
+
+int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
+{
+   if (ci->platdata->dr_mode != USB_DR_MODE_OTG)
+   return 0;
+
+   ci->transceiver->otg = devm_kzalloc(ci->dev,
+   sizeof(struct usb_otg), GFP_KERNEL);
+   if (!ci->transceiver->otg) {
+   dev_err(ci->dev,
+   "Failed to allocate usb_otg structure for ci hdrc otg!\n");
+   return -ENOMEM;
+   }
+
+   ci->fsm.power_up = 1;
+   ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID);
+   ci->fsm.otg = ci->transceiver->otg;
+   ci->fsm.otg->phy = ci->transceiver;
+   ci->fsm.otg->gadget = &ci->gadget;
+   ci->transceiver->state = OTG_STATE_UNDEFINED;
+
+   mutex_init(&ci->fsm.lock);
+
+   /* Enable A vbus valid irq */
+   hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE);
+
+   if (ci->fsm.id) {
+   ci->fsm.b_ssend_srp =
+   hw_read_otgsc(ci, OTGSC_BSV) ? 0 : 1;
+   ci->fsm.b_sess_vld =
+   hw_read_otgsc(ci, OTGSC_BSV) ? 1 : 0;
+   }
+
+   return 0;
+}
diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h
new file mode 100644
index 000..cf27253
--- /dev/null
+++ b/drivers/usb/chipidea/otg_fsm.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ *
+ * Author: Jun Li
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
+#define __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
+
+#include 
+
+#ifdef CONFIG_USB_OTG_FSM
+
+int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);
+
+#else
+
+static int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
+{
+   return 0;
+}
+
+#endif
+
+#endif /* __DRIVERS_USB_CHIPIDEA_OTG_FSM_H */
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message

[PATCH v4 11/11] Documentation: usb: add chipidea.txt for how to demo usb OTG HNP and SRP

2014-03-19 Thread Li Jun
From: Li Jun 

This patch adds a file chipidea.txt for how to demo chipidea usb OTG HNP and SRP
functions via sysfs input files, any other possible information should be
documented for chipidea usb driver in future can be added into this file.

Signed-off-by: Li Jun 
---
 Documentation/usb/chipidea.txt |   70 
 1 file changed, 70 insertions(+)

diff --git a/Documentation/usb/chipidea.txt b/Documentation/usb/chipidea.txt
new file mode 100644
index 000..54fb437
--- /dev/null
+++ b/Documentation/usb/chipidea.txt
@@ -0,0 +1,70 @@
+1. How to test OTG FSM(HNP and SRP)
+---
+To show how to demo OTG HNP and SRP functions via sys input files
+with 2 Freescale i.MX6Q sabre SD boards.
+
+1.1 How to enable OTG FSM in menuconfig
+---
+Select CONFIG_USB_OTG_FSM.
+If you want to check some internal variables for otg fsm,
+select CONFIG_USB_CHIPIDEA_DEBUG, there are 2 files which
+can show otg fsm variables and some controller registers value:
+cat /sys/kernel/debug/ci_hdrc.0/otg
+cat /sys/kernel/debug/ci_hdrc.0/register
+
+1.2 Test operations
+---
+1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
+   (e.g. g_mass_storage).
+
+2) Connect 2 boards with usb cable with one end is micro A plug, the other end
+   is micro B plug.
+
+   The A-device(with micro A plug inserted) should enumrate B-device.
+
+3) Role switch
+   On B-device:
+   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+   if HNP polling is not supported, also need:
+   On A-device:
+   echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+
+   B-device should take host role and enumrate A-device.
+
+4) A-device switch back to host.
+   On B-device:
+   echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+   A-device should switch back to host and enumrate B-device.
+
+5) Remove B-device(unplug micro B plug) and insert again in 10 seconds,
+   A-device should enumrate B-device again.
+
+6) Remove B-device(unplug micro B plug) and insert again after 10 seconds,
+   A-device should NOT enumrate B-device.
+
+   if A-device wants to use bus:
+   On A-device:
+   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
+
+   if B-device wants to use bus:
+   On B-device:
+   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+7) A-device power down the bus.
+   On A-device:
+   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
+
+   A-device should disconnect with B-device and power down the bus.
+
+8) B-device does data pulse for SRP.
+   On B-device:
+   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
+
+   A-device should resume usb bus and enumrate B-device.
+
+1.3 Reference document
+--
+"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
+July 27, 2012 Revision 2.0 version 1.1a"
-- 
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 07/11] usb: chipidea: OTG HNP and SRP fsm implementation.

2014-03-19 Thread Li Jun
From: Li Jun 

USB OTG interrupt handling and fsm transitions according to USB OTG
and EH 2.0.

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/core.c|   10 +-
 drivers/usb/chipidea/otg.c |9 +-
 drivers/usb/chipidea/otg_fsm.c |  235 +++-
 drivers/usb/chipidea/otg_fsm.h |   18 +++
 drivers/usb/chipidea/udc.c |6 +
 5 files changed, 270 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ff38cf3..c0eacf4 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -74,6 +74,7 @@
 #include "host.h"
 #include "debug.h"
 #include "otg.h"
+#include "otg_fsm.h"
 
 /* Controller register map */
 static const u8 ci_regs_nolpm[] = {
@@ -412,8 +413,12 @@ static irqreturn_t ci_irq(int irq, void *data)
irqreturn_t ret = IRQ_NONE;
u32 otgsc = 0;
 
-   if (ci->is_otg)
+   if (ci->is_otg) {
otgsc = hw_read_otgsc(ci, ~0);
+   ret = ci_otg_fsm_irq(ci);
+   if (ret == IRQ_HANDLED)
+   return ret;
+   }
 
/*
 * Handle id change interrupt, it indicates device/host function
@@ -697,6 +702,9 @@ static int ci_hdrc_probe(struct platform_device *pdev)
goto stop;
}
 
+   if (ci->is_otg)
+   ci_hdrc_otg_fsm_start(ci);
+
platform_set_drvdata(pdev, ci);
ret = request_irq(ci->irq, ci_irq, IRQF_SHARED, ci->platdata->name,
  ci);
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 3082b52..5098982 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -11,8 +11,8 @@
  */
 
 /*
- * This file mainly handles otgsc register, it may include OTG operation
- * in the future.
+ * This file mainly handles otgsc register, OTG fsm operations for HNP and SRP
+ * are also included.
  */
 
 #include 
@@ -91,6 +91,11 @@ static void ci_otg_work(struct work_struct *work)
 {
struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
 
+   if (!ci_otg_fsm_work(ci)) {
+   enable_irq(ci->irq);
+   return;
+   }
+
if (ci->id_event) {
ci->id_event = false;
ci_handle_id_switch(ci);
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 1fcb2b0..569f208 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -92,6 +92,33 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum 
ci_otg_fsm_timer_index t)
hw_write_otgsc(ci, OTGSC_1MSIE, 0);
 }
 
+/*
+ * Reduce timer count by 1, and find timeout conditions.
+ * Called by otg 1ms timer interrupt
+ */
+static inline int ci_otg_tick_timer(struct ci_hdrc *ci)
+{
+   struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
+   struct list_head *active_timers = &ci->fsm_timer->active_timers;
+   int expired = 0;
+
+   list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) {
+   tmp_timer->count--;
+   /* check if timer expires */
+   if (!tmp_timer->count) {
+   list_del(&tmp_timer->list);
+   tmp_timer->function(ci, tmp_timer->data);
+   expired = 1;
+   }
+   }
+
+   /* disable 1ms irq if there is no any timer active */
+   if ((expired == 1) && list_empty(active_timers))
+   hw_write_otgsc(ci, OTGSC_1MSIE, 0);
+
+   return expired;
+}
+
 /* The timeout callback function to set time out bit */
 static void set_tmout(void *ptr, unsigned long indicator)
 {
@@ -297,11 +324,6 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
regulator_disable(ci->platdata->reg_vbus);
/* Disable port power */
hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP, 0);
-
-   /* Clear exsiting DP irq */
-   hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
-   /* Enable data pulse irq */
-   hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
}
 }
 
@@ -397,6 +419,209 @@ static struct otg_fsm_ops ci_otg_ops = {
.start_gadget = ci_otg_start_gadget,
 };
 
+int ci_otg_fsm_work(struct ci_hdrc *ci)
+{
+   if (!ci->transceiver->otg)
+   return -ENODEV;
+
+   /*
+* Don't do fsm transition for B device
+* when there is no gadget class driver
+*/
+   if (ci->fsm.id && !(ci->driver) &&
+   ci->transceiver->state < OTG_STATE_A_IDLE)
+   return 0;
+
+   if (otg_statemachine(&ci->fsm)) {
+   if (ci->transceiver->state == OTG_STATE_A_IDLE) {
+   if (ci->fsm.id)
+   /* A idle to B idle */
+   otg_statemachine(&ci->fsm);
+   else if ((ci->id_event) || (ci->fsm.power_up)) {
+   ci->id_even

[PATCH v4 04/11] usb: chipidea: udc: driver update for OTG HNP.

2014-03-19 Thread Li Jun
Add b_hnp_enable request handling and enable gadget->is_otg

Signed-off-by: Li Jun 
---
 drivers/usb/chipidea/udc.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index f58857d..022dd18 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ci.h"
@@ -1052,6 +1053,14 @@ __acquires(ci->lock)
default:
break;
}
+   break;
+   case USB_DEVICE_B_HNP_ENABLE:
+   if (gadget_is_otg(&ci->gadget)) {
+   ci->gadget.b_hnp_enable = 1;
+   err = isr_setup_status_phase(
+   ci);
+   }
+   break;
default:
goto delegate;
}
@@ -1759,7 +1768,7 @@ static int udc_start(struct ci_hdrc *ci)
ci->gadget.ops  = &usb_gadget_ops;
ci->gadget.speed= USB_SPEED_UNKNOWN;
ci->gadget.max_speed= USB_SPEED_HIGH;
-   ci->gadget.is_otg   = 0;
+   ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
ci->gadget.name = ci->platdata->name;
 
INIT_LIST_HEAD(&ci->gadget.ep_list);
-- 
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 09/11] usb: chipidea: debug: add debug file for OTG variables

2014-03-19 Thread Li Jun
From: Li Jun 

This patch adds a debug file for OTG vairables show.

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

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 5b890c1..33fcaf9 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -7,6 +7,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include "ci.h"
 #include "udc.h"
@@ -205,6 +208,80 @@ static const struct file_operations ci_requests_fops = {
.release= single_release,
 };
 
+int ci_otg_show(struct seq_file *s, void *unused)
+{
+   struct ci_hdrc *ci = s->private;
+   struct otg_fsm *fsm;
+
+   if (!ci || !ci->is_otg)
+   return 0;
+
+   fsm = &ci->fsm;
+
+   /* -- State - */
+   seq_printf(s, "OTG state: %s\n\n",
+   usb_otg_state_string(ci->transceiver->state));
+
+   /* -- State Machine Variables - */
+   seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
+
+   seq_printf(s, "a_bus_req: %d\n", fsm->a_bus_req);
+
+   seq_printf(s, "a_srp_det: %d\n", fsm->a_srp_det);
+
+   seq_printf(s, "a_vbus_vld: %d\n", fsm->a_vbus_vld);
+
+   seq_printf(s, "b_conn: %d\n", fsm->b_conn);
+
+   seq_printf(s, "adp_change: %d\n", fsm->adp_change);
+
+   seq_printf(s, "power_up: %d\n", fsm->power_up);
+
+   seq_printf(s, "a_bus_resume: %d\n", fsm->a_bus_resume);
+
+   seq_printf(s, "a_bus_suspend: %d\n", fsm->a_bus_suspend);
+
+   seq_printf(s, "a_conn: %d\n", fsm->a_conn);
+
+   seq_printf(s, "b_bus_req: %d\n", fsm->b_bus_req);
+
+   seq_printf(s, "b_bus_suspend: %d\n", fsm->b_bus_suspend);
+
+   seq_printf(s, "b_se0_srp: %d\n", fsm->b_se0_srp);
+
+   seq_printf(s, "b_ssend_srp: %d\n", fsm->b_ssend_srp);
+
+   seq_printf(s, "b_sess_vld: %d\n", fsm->b_sess_vld);
+
+   seq_printf(s, "b_srp_done: %d\n", fsm->b_srp_done);
+
+   seq_printf(s, "drv_vbus: %d\n", fsm->drv_vbus);
+
+   seq_printf(s, "loc_conn: %d\n", fsm->loc_conn);
+
+   seq_printf(s, "loc_sof: %d\n", fsm->loc_sof);
+
+   seq_printf(s, "adp_prb: %d\n", fsm->adp_prb);
+
+   seq_printf(s, "id: %d\n", fsm->id);
+
+   seq_printf(s, "protocol: %d\n", fsm->protocol);
+
+   return 0;
+}
+
+static int ci_otg_open(struct inode *inode, struct file *file)
+{
+   return single_open(file, ci_otg_show, inode->i_private);
+}
+
+static const struct file_operations ci_otg_fops = {
+   .open   = ci_otg_open,
+   .read   = seq_read,
+   .llseek = seq_lseek,
+   .release= single_release,
+};
+
 static int ci_role_show(struct seq_file *s, void *data)
 {
struct ci_hdrc *ci = s->private;
@@ -332,6 +409,13 @@ int dbg_create_files(struct ci_hdrc *ci)
if (!dent)
goto err;
 
+   if (ci->is_otg) {
+   dent = debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci,
+   &ci_otg_fops);
+   if (!dent)
+   goto err;
+   }
+
dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
   &ci_role_fops);
if (!dent)
-- 
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 0/6] Fix line over 80 characters warning in bcm.

2014-03-19 Thread Heena Sirwani
This patchset consists of patches that fix line over 80 characters
warning in bcm module in Adapter.h.Please review the patches that
follow.

Heena Sirwani (6):
  staging: bcm: Fix line over 80 characters.
  staging: bcm: Fix line over 80 characters.
  staging: bcm: Fix line over 80 characters.
  staging: bcm: Fix line over 80 characters.
  staging: bcm: Fix line over 80 characters.
  staging: bcm: Fix line over 80 characters.

 drivers/staging/bcm/Adapter.h |   61 +++--
 1 file changed, 40 insertions(+), 21 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: [xhci_hcd] reset SuperSpeed, xhci_drop_endpoint called with disabled ep, Error in queuecommand_lck: task blocked

2014-03-19 Thread Andreas Reis

I've uploaded a dmesg with the new debugging patch to bugzilla:
https://bugzilla.kernel.org/attachment.cgi?id=130041

Andreas Reis

On 18.03.2014 15:57, Alan Stern wrote:>
> The debugging information didn't go far enough.  Try the patch below
> instead, which has some additional messages.
>
> There are two apparently separate problems here.  First, why was the
> reset necessary?  As far as I can tell, the only explanation seems to
> be a failure of Link Power Management.
>
> Second, why the errors in queuecommand_lck?  I suspect the answer to
> that lies somewhere in the SCSI subystem, not USB.  The new debugging
> patch should tell us for sure.
>
> 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/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Heena Sirwani
Fix checkpatch.pl issues with line over 80 characters in Adapter.h

Signed-off-by: Heena Sirwani 
---
 drivers/staging/bcm/Adapter.h |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index f0d6f0c..1b2d9f3 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -37,8 +37,10 @@ struct bcm_link_request {
 
 union u_ip_address {
struct {
-   ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; /* Source Ip Address 
Range */
-   ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; /* Source Ip Mask 
Address Range */
+   /* Source Ip Address Range */
+   ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];
+/* Source Ip Mask Address Range */
+   ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];
};
struct {
ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address 
Range */
-- 
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 2/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Heena Sirwani
Fix checkpatch.pl issues with line over 80 characters in Adapter.h

Signed-off-by: Heena Sirwani 
---
 drivers/staging/bcm/Adapter.h |   23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index 1b2d9f3..a387234 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -39,12 +39,14 @@ union u_ip_address {
struct {
/* Source Ip Address Range */
ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];
-/* Source Ip Mask Address Range */
+   /* Source Ip Mask Address Range */
ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];
};
struct {
-   ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address 
Range */
-   ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Mask 
Address Range */
+   /* Source Ip Address Range */
+   ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];
+   /* Source Ip Mask Address Range */
+   ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];
};
struct {
UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
@@ -57,9 +59,11 @@ union u_ip_address {
 };
 
 struct bcm_hdr_suppression_contextinfo {
-   UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer 
to accumulate pkt Header for PHS */
-   UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* 
Intermediate buffer containing pkt Header after PHS */
-};
+   /* Intermediate buffer to accumulate pkt Header for PHS */
+   UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS];
+   /* Intermediate buffer containing pkt Header after PHS */
+   UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN];
+   };
 
 struct bcm_classifier_rule {
ULONG   ulSFID;
@@ -67,11 +71,12 @@ struct bcm_classifier_rule {
B_UINT16uiClassifierRuleIndex;
boolbUsed;
USHORT  usVCID_Value;
-   B_UINT8 u8ClassifierRulePriority; /* This field detemines the 
Classifier Priority */
+   /* This field detemines the Classifier Priority */
+   B_UINT8 u8ClassifierRulePriority;
union u_ip_address  stSrcIpAddress;
-   UCHAR   ucIPSourceAddressLength; /* Ip Source Address Length */
-
union u_ip_address  stDestIpAddress;
+   /* Ip Source Address Length */
+   UCHAR   ucIPSourceAddressLength;
UCHAR   ucIPDestinationAddressLength; /* Ip Destination Address 
Length */
UCHAR   ucIPTypeOfServiceLength; /* Type of service Length */
UCHAR   ucTosLow; /* Tos Low */
-- 
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 3/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Heena Sirwani
Fix checkpatch.pl issues with line over 80 characters in Adapter.h

Signed-off-by: Heena Sirwani 
---
 drivers/staging/bcm/Adapter.h |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index a387234..d241164 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -53,8 +53,10 @@ union u_ip_address {
UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
};
struct {
-   UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * 
IPV6_ADDRESS_SIZEINBYTES];
-   UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * 
IPV6_ADDRESS_SIZEINBYTES];
+   UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH
+   * IPV6_ADDRESS_SIZEINBYTES];
+   UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH
+   * IPV6_ADDRESS_SIZEINBYTES];
};
 };
 
@@ -77,7 +79,8 @@ struct bcm_classifier_rule {
union u_ip_address  stDestIpAddress;
/* Ip Source Address Length */
UCHAR   ucIPSourceAddressLength;
-   UCHAR   ucIPDestinationAddressLength; /* Ip Destination Address 
Length */
+   /* Ip Destination Address Length */
+   UCHAR   ucIPDestinationAddressLength;
UCHAR   ucIPTypeOfServiceLength; /* Type of service Length */
UCHAR   ucTosLow; /* Tos Low */
UCHAR   ucTosHigh; /* Tos High */
-- 
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 4/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Heena Sirwani
Fix checkpatch.pl issues with line over 80 characters in Adapter.h

Signed-off-by: Heena Sirwani 
---
 drivers/staging/bcm/Adapter.h |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index d241164..d0c8cec 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -144,7 +144,8 @@ struct bcm_packet_info {
 
B_UINT8 u8QueueType; /* BE or rtPS */
 
-   UINTuiMaxBucketSize; /* maximum size of the bucket for the 
queue */
+   /* maximum size of the bucket for the queue */
+   UINTuiMaxBucketSize;
UINTuiCurrentQueueDepthOnTarget;
UINTuiCurrentBytesOnHost;
UINTuiCurrentPacketsOnHost;
@@ -284,7 +285,8 @@ struct bcm_mini_adapter {
UINTindex_datpkt;
struct semaphorerdmwrmsync;
 
-   struct bcm_targetdsx_buffer 
astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
+   struct bcm_targetdsx_buffer
+   astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
ULONG   ulFreeTargetBufferCnt;
ULONG   ulCurrentTargetBuffer;
ULONG   ulTotalTargetBuffersAvailable;
-- 
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 5/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Heena Sirwani
Fix checkpatch.pl issues with line over 80 characters in Adapter.h

Signed-off-by: Heena Sirwani 
---
 drivers/staging/bcm/Adapter.h |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index d0c8cec..be959b9 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -5,6 +5,7 @@
 #define__ADAPTER_H__
 
 #define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
+#define BCM_IPV6_ADDR_RANGELEN (MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES)
 #include "Debug.h"
 
 struct bcm_leader {
@@ -53,10 +54,8 @@ union u_ip_address {
UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
};
struct {
-   UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH
-   * IPV6_ADDRESS_SIZEINBYTES];
-   UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH
-   * IPV6_ADDRESS_SIZEINBYTES];
+   UCHAR ucIpv6Address[BCM_IPV6_ADDR_RANGELEN];
+   UCHAR ucIpv6Mask[BCM_IPV6_ADDR_RANGELEN];
};
 };
 
-- 
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 6/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Heena Sirwani
Fix checkpatch.pl issues with line over 80 characters in Adapter.h

Signed-off-by: Heena Sirwani 
---
 drivers/staging/bcm/Adapter.h |   20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index be959b9..a336d39 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -381,25 +381,33 @@ struct bcm_mini_adapter {
struct bcm_flash_cs_info *psFlashCSInfo;
struct bcm_flash2x_vendor_info *psFlash2xVendorInfo;
UINTuiFlashBaseAdd; /* Flash start address */
-   UINTuiActiveISOOffset; /* Active ISO offset chosen 
before f/w download */
+   /* Active ISO offset chosen before f/w download */
+   UINTuiActiveISOOffset;
enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */
-   enum bcm_flash2x_section_val eActiveDSD; /* Active DSD val chosen 
before f/w download */
-   UINTuiActiveDSDOffsetAtFwDld;  /* For accessing 
Active DSD chosen before f/w download */
+   /* Active DSD val chosen before f/w download */
+   enum bcm_flash2x_section_val eActiveDSD;
+   /* For accessing Active DSD chosen before f/w download */
+   UINTuiActiveDSDOffsetAtFwDld;
UINTuiFlashLayoutMajorVersion;
UINTuiFlashLayoutMinorVersion;
boolbAllDSDWriteAllow;
boolbSigCorrupted;
-   /* this should be set who so ever want to change the Headers. after 
Write it should be reset immediately. */
+   /* this should be set who so ever want to change the Headers.
+* after Write it should be reset immediately.
+*/
boolbHeaderChangeAllowed;
int SelectedChip;
boolbEndPointHalted;
-   /* while bFlashRawRead will be true, Driver  ignore map lay out and 
consider flash as of without any map. */
+   /* while bFlashRawRead will be true,
+* Driver  ignore map lay out and consider flash as of without any map.
+*/
boolbFlashRawRead;
boolbPreparingForLowPowerMode;
boolbDoSuspend;
UINTsyscfgBefFwDld;
boolStopAllXaction;
-   UINT32  liTimeSinceLastNetEntry; /* Used to Support 
extended CAPI requirements from */
+   /* Used to Support extended CAPI requirements from */
+   UINT32  liTimeSinceLastNetEntry;
struct semaphoreLowPowerModeSync;
ULONG   liDrainCalculated;
UINTgpioBitMap;
-- 
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 1/2] extcon: of: Remove unnecessary function call by using the name of device_node

2014-03-19 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 18 March 2014 05:34 PM, Chanwoo Choi wrote:
> This patch remove unnecessary function call in of_extcon_get_extcon_dev()
> by using the name of device_node structure.
> 
> Signed-off-by: Chanwoo Choi 
> ---
>  drivers/extcon/of_extcon.c | 12 ++--
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
> index 72173ec..0a29f82 100644
> --- a/drivers/extcon/of_extcon.c
> +++ b/drivers/extcon/of_extcon.c
> @@ -32,7 +32,6 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct device 
> *dev, int index)
>  {
>   struct device_node *node;
>   struct extcon_dev *edev;
> - struct platform_device *extcon_parent_dev;
>  
>   if (!dev->of_node) {
>   dev_dbg(dev, "device does not have a device node entry\n");
> @@ -46,16 +45,9 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct device 
> *dev, int index)
>   return ERR_PTR(-ENODEV);
>   }
>  
> - extcon_parent_dev = of_find_device_by_node(node);
> - if (!extcon_parent_dev) {
> - dev_dbg(dev, "unable to find device by node\n");
> - return ERR_PTR(-EPROBE_DEFER);
> - }
> -
> - edev = extcon_get_extcon_dev(dev_name(&extcon_parent_dev->dev));
> + edev = extcon_get_extcon_dev(node->name);

Since you no longer want to use device names I think you should add this too to
warn users if they rely on using the device name.
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index bc4c789..025eb39 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -601,7 +601,6 @@ int extcon_dev_register(struct extcon_dev *edev)
edev->dev.class = extcon_class;
edev->dev.release = extcon_dev_release;

-   edev->name = edev->name ? edev->name : dev_name(edev->dev.parent);
//The user should always pass the 'name' as we no longer use device name while
getting extcon device. And this name should also be the 'node' name?
if (IS_ERR_OR_NULL(edev->name)) {
dev_err(&edev->dev,
"extcon device name is null\n");

Btw changing to node name from device name breaks dwc3 in OMAP5 and you would
need this too..

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 2aea4bc..cea8cd3 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -188,6 +188,7 @@ static int palmas_usb_probe(struct platform_device *pdev)

palmas_usb->edev.supported_cable = palmas_extcon_cable;
palmas_usb->edev.dev.parent = palmas_usb->dev;
+   palmas_usb->edev.name = "palmas_usb";
palmas_usb->edev.mutually_exclusive = mutually_exclusive;

status = extcon_dev_register(&palmas_usb->edev);

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


Re: [PATCH] usb:hub set hub->change_bits when over-current happens

2014-03-19 Thread Yuvaraj Cd
With this patch,I can see usb 3.0 device detection is failing on
exynos5250-smdk5250 boards.
CONFIG_USB_SUSPEND=n

/ $ [   11.486922] hub 2-0:1.0: connect-debounce failed, port 1 disabled
[   13.891919] hub 2-0:1.0: connect-debounce failed, port 1 disabled
[   16.296919] hub 2-0:1.0: connect-debounce failed, port 1 disabled
[   18.701919] hub 2-0:1.0: connect-debounce failed, port 1 disabled
[   21.106919] hub 2-0:1.0: connect-debounce failed, port 1 disabled
[   23.511918] hub 2-0:1.0: connect-debounce failed, port 1 disabled
[   25.916918] hub 2-0:1.0: connect-debounce failed, port 1 disabled

When I revert this patch, device detection works fine.Anyone have come
across the same on other platforms?

On Wed, Jan 8, 2014 at 11:49 PM, Sarah Sharp
 wrote:
> On Wed, Jan 08, 2014 at 12:49:57PM -0500, Alan Stern wrote:
>> On Wed, 8 Jan 2014, Greg KH wrote:
>>
>> > On Wed, Jan 08, 2014 at 02:45:42PM +0800, Shen Guang wrote:
>> > > When we are doing compliance test with xHCI, we found that if we
>> > > enable CONFIG_USB_SUSPEND and plug in a bad device which causes
>> > > over-current condition to the root port, software will not be noticed.
>> > > The reason is that current code don't set hub->change_bits in
>> > > hub_activate() when over-current happens, and then hub_events() will
>> > > not check the port status because it thinks nothing changed.
>> > > If CONFIG_USB_SUSPEND is disabled, the interrupt pipe of the hub will
>> > > report the change and set hub->event_bits, and then hub_events() will
>> > > check what events happened.In this case over-current can be detected.
>> > >
>> > > Signed-off-by: Shen Guang 
>> > > ---
>> > >  drivers/usb/core/hub.c |3 ++-
>> > >  1 file changed, 2 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>> > > index bd9dc35..98b5679 100644
>> > > --- a/drivers/usb/core/hub.c
>> > > +++ b/drivers/usb/core/hub.c
>> > > @@ -1154,7 +1154,8 @@ static void hub_activate(struct usb_hub *hub,
>> > > enum hub_activation_type type)
>> > > /* Tell khubd to disconnect the device or
>> > >  * check for a new connection
>> > >  */
>> > > -   if (udev || (portstatus & 
>> > > USB_PORT_STAT_CONNECTION))
>> > > +   if (udev || (portstatus & 
>> > > USB_PORT_STAT_CONNECTION) ||
>> > > +   (portstatus & USB_PORT_STAT_OVERCURRENT))
>> > > set_bit(port1, hub->change_bits);
>> > >
>> > > } else if (portstatus & USB_PORT_STAT_ENABLE) {
>> > > --
>> > > 1.7.9.5
>> >
>> > Alan and Sarah, any objection to this patch?
>>
>> It seems okay to me.
>>
>> Acked-by: Alan Stern 
>
> Looks fine to me as well.
>
> Acked-by: Sarah Sharp 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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: questions about give back urb in tasklet

2014-03-19 Thread vichy
hi all:

2014-03-19 17:57 GMT+08:00 vichy :
> hi  Ming.lei:
> 2014-03-17 22:01 GMT+08:00 Alan Stern :
>> On Sun, 16 Mar 2014, vichy wrote:
>>
>>> hi all:
>>> recently we bump to system performance issue when usb irq take quite long.
>>> I found below link for discussing how to short
>>>
>
> in http://permalink.gmane.org/gmane.linux.usb.general/89363
>
> I have some questions about this patch.
> 1. is there patch or kernel config I can use to measure man/avage usb
> irq time consuming like the above link show
>
> 2. I see this patch is roll back in commit
> "c04ee4b1136e462722567cf6e76bb35a181574a7" and intend to be ready in
> 3.13-rc1
> Is there special reason why we need to roll back?
why this patch didn't implement xhci?
in xhci-pci.c
there is no HCD_HB at
xhci_pci_hc_driver
.flags =HCD_MEMORY | HCD_USB3 | HCD_SHARED,

does that mean xhci don't need to pug complete in the BH?

thanks for your help,
--
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: Support for new USB Modem 4G drive

2014-03-19 Thread Dan Williams
On Wed, 2014-03-19 at 06:25 -0300, Julio Araujo wrote:
> Hello,
> 
> My name is Julio and I'm trying to use a USB Modem 4G model OLICARD500 
> from the manufacture Olivetti and I got the follow message from syslog:
> Mar 19 05:23:29 mynote kernel: [  265.072844] usbserial_generic 
> 1-1.3:1.0: Tell linux-usb@vger.kernel.org to add your device to a proper 
> driver.
> Mar 19 05:23:29 mynote kernel: [  265.072852] usbserial_generic 
> 1-1.3:1.0: generic converter detected
> Mar 19 05:23:29 mynote kernel: [  265.073168] usb 1-1.3: generic 
> converter now attached to ttyUSB0
> Mar 19 05:23:29 mynote kernel: [  265.073385] usbserial_generic 
> 1-1.3:1.1: The "generic" usb-serial driver is only for testing and 
> one-off prototypes.
> So this is the reason why I'm sending this email.
> 
> Follow the printout from lsusb:
> julio@mynote:~$ lsusb
> Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
> Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 001 Device 003: ID 04f2:b351 Chicony Electronics Co., Ltd
> Bus 002 Device 006: ID 058f:9254 Alcor Micro Corp. Hub
> Bus 002 Device 011: ID 0b3c:f017 Olivetti Techcenter
> Bus 002 Device 007: ID 04fc:0538 Sunplus Technology Co., Ltd Wireless 
> Optical Mouse 2.4G [Bright]
> 
> I'm not a programmer, but I'm using Linux Ubuntu since 2007 in my home 
> so could you please help me with this issue?
> If you need me to do any kind of test or get any log or file from my 
> system in order to help please let me know.

Can you reply with the output of:

lsusb -v -n 0b3c:f017

Thanks,
Dan

--
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: questions about give back urb in tasklet

2014-03-19 Thread Ming Lei
On Wed, Mar 19, 2014 at 5:57 PM, vichy  wrote:
> hi  Ming.lei:
> 2014-03-17 22:01 GMT+08:00 Alan Stern :
>> On Sun, 16 Mar 2014, vichy wrote:
>>
>>> hi all:
>>> recently we bump to system performance issue when usb irq take quite long.
>>> I found below link for discussing how to short
>>>
>
> in http://permalink.gmane.org/gmane.linux.usb.general/89363
>
> I have some questions about this patch.
> 1. is there patch or kernel config I can use to measure man/avage usb
> irq time consuming like the above link show

One approach I like to use is trace event.

>
> 2. I see this patch is roll back in commit
> "c04ee4b1136e462722567cf6e76bb35a181574a7" and intend to be ready in
> 3.13-rc1
> Is there special reason why we need to roll back?

Yes, the revert revert can enable to run completion handler in BH,
isn't that what you need?

But actually the local interrupt is still disabled during completion
because we need to convert spin_lock in all current usb drivers
to spin_lock_irqsave() first.

I posted lot of patches to do the conversion, but unfortunately
most of them aren't merged.


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: questions about give back urb in tasklet

2014-03-19 Thread vichy
hi Ming
>>
>> in http://permalink.gmane.org/gmane.linux.usb.general/89363
>>
>> I have some questions about this patch.
>> 1. is there patch or kernel config I can use to measure man/avage usb
>> irq time consuming like the above link show
>
> One approach I like to use is trace event.
Would you please let us how to to use trace event for calculate
max/average usb irq time?

>
>>
>> 2. I see this patch is roll back in commit
>> "c04ee4b1136e462722567cf6e76bb35a181574a7" and intend to be ready in
>> 3.13-rc1
>> Is there special reason why we need to roll back?
>
> Yes, the revert revert can enable to run completion handler in BH,
> isn't that what you need?
YES, what I need is try to see whether my problem will be solved if
running completion handlers in BH.

At beginning, the "revert" let me think there are something wrong
after we put completion in BH.
And we need to revert it back to "put completion in irq"

so the revert mean "put completion in BH", right?

>
> But actually the local interrupt is still disabled during completion
> because we need to convert spin_lock in all current usb drivers
> to spin_lock_irqsave() first.
Would you please let me know the function or source you mentioned?

BTW, why I cannot see xhci add HCD_BH?
is there some reason xhci cannot put completion in BH?

thanks for your kind help,
--
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: questions about give back urb in tasklet

2014-03-19 Thread Ming Lei
On Wed, Mar 19, 2014 at 9:34 PM, vichy  wrote:
> hi Ming
>>>
>>> in http://permalink.gmane.org/gmane.linux.usb.general/89363
>>>
>>> I have some questions about this patch.
>>> 1. is there patch or kernel config I can use to measure man/avage usb
>>> irq time consuming like the above link show
>>
>> One approach I like to use is trace event.
> Would you please let us how to to use trace event for calculate
> max/average usb irq time?

You can enable irq_handler_entry and irq_handler_exit event, then
write a script easily to figure out the time consumed in ehci irq handler,
see Documentation/trace/events.txt of linux kernel for detailed steps.

>
>>
>>>
>>> 2. I see this patch is roll back in commit
>>> "c04ee4b1136e462722567cf6e76bb35a181574a7" and intend to be ready in
>>> 3.13-rc1
>>> Is there special reason why we need to roll back?
>>
>> Yes, the revert revert can enable to run completion handler in BH,
>> isn't that what you need?
> YES, what I need is try to see whether my problem will be solved if
> running completion handlers in BH.
>
> At beginning, the "revert" let me think there are something wrong
> after we put completion in BH.
> And we need to revert it back to "put completion in irq"
>
> so the revert mean "put completion in BH", right?

Yes, it is a revert revert.

>
>>
>> But actually the local interrupt is still disabled during completion
>> because we need to convert spin_lock in all current usb drivers
>> to spin_lock_irqsave() first.
> Would you please let me know the function or source you mentioned?

The local interrupt is disabled during completion handler in
__usb_hcd_giveback_urb().

>
> BTW, why I cannot see xhci add HCD_BH?

There might be some reasons:

- in previous following up discussion, Alan thought it should
be easier to just split the hcd interrupt handler into two parts

- as I said, spin_lock() isn't converted to spin_lock_irqsave()
in drivers' completion handler yet

- maybe no one really care the time in which local interrupt is
disabled by USB completion handler.(That might be true
because USB devices are commonly used in personal
computer, not in big server product)

> is there some reason xhci cannot put completion in BH?

IMO, the completion handler should be put into tasklet, and
can be done. If you like, you can take time to do that.


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: questions about give back urb in tasklet

2014-03-19 Thread Alan Stern
On Wed, 19 Mar 2014, Ming Lei wrote:

> But actually the local interrupt is still disabled during completion
> because we need to convert spin_lock in all current usb drivers
> to spin_lock_irqsave() first.
> 
> I posted lot of patches to do the conversion, but unfortunately
> most of them aren't merged.

You should resubmit those patches after the end of the upcoming merge
window.  They probably will be accepted.

Alan Stern

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


RE: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in platform device id

2014-03-19 Thread suresh.gu...@freescale.com
Hi

> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Saturday, March 15, 2014 7:10 AM
> To: Gupta Suresh-B42813
> Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-usb@vger.kernel.org;
> linux-ker...@vger.kernel.org
> Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> platform device id
> 
> On Fri, Mar 14, 2014 at 08:52:19PM +, suresh.gu...@freescale.com
> wrote:
> > Hi,
> > Thanks for reviewing my patches.
> > Please find my comments inline
> >
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Thursday, March 13, 2014 8:56 PM
> > To: Gupta Suresh-B42813
> > Cc: ba...@ti.com; gre...@linuxfoundation.org;
> > linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org; Gupta
> > Suresh-B42813
> > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > platform device id
> >
> > On Thu, Mar 13, 2014 at 07:35:31PM +0530, Suresh Gupta wrote:
> > > From: Suresh Gupta 
> > >
> > >   Add FSL USB Gadget entry in platform device id table
> >
> > why this tab ?
> > [SuresH] I will remove it in next version.
> >
> > > Signed-off-by: Suresh Gupta 
> > > ---
> > >  drivers/usb/gadget/fsl_udc_core.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/usb/gadget/fsl_udc_core.c
> > > b/drivers/usb/gadget/fsl_udc_core.c
> > > index b7dea4e..35b20e6 100644
> > > --- a/drivers/usb/gadget/fsl_udc_core.c
> > > +++ b/drivers/usb/gadget/fsl_udc_core.c
> > > @@ -2654,6 +2654,8 @@ static const struct platform_device_id
> fsl_udc_devtype[] = {
> > >   }, {
> > >   .name = "imx-udc-mx51",
> > >   }, {
> > > + .name = "fsl-usb2-udc",
> >
> > why aren't you just using chipidea ?
> > [SuresH] This is our legacy driver for all previous and existing ppc
> > socs. Many of our customers are already using this, and we need to
> > support them on this driver. We do have plans to shift to chipidea,
> > but after some time.
> 
> cool, you already have plans, so we will see a new glue layer for v3.16
> right ? Which means I don't need to take this patch either.
> 
we do have plans, but in remote future. Right now, we need to support
customers on the present legacy driver. We'll phase out this driver 
slowly when we integrate chipidea. At this time I would request you 
to please accept this patch

---
Thanks
SuresH
--
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: fsl driver pullup fix

2014-03-19 Thread suresh.gu...@freescale.com


> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Saturday, March 15, 2014 7:05 AM
> To: Gupta Suresh-B42813
> Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-usb@vger.kernel.org;
> linux-ker...@vger.kernel.org; Stefani Seibold
> Subject: Re: [PATCH] USB: Gadget: fsl driver pullup fix
> 
> Hi,
> 
> (first of all, please fix your email client, we need the quotation marks.
> See Documentation/email-clients.txt)
> 
> On Fri, Mar 14, 2014 at 08:53:24PM +, suresh.gu...@freescale.com
> wrote:
> > > On Thu, Mar 13, 2014 at 06:40:55PM +0530, Suresh Gupta wrote:
> > > > Attached is a small fix for the fsl usb gadget driver. This fix
> > > > the driver in a way that the usb device will be only "pulled up"
> > > > on requests like other usb gadget drivers do.
> > > > This is necessary, because the device information is not always
> > > > available until an application is up and running which provides
> > > > this datas.
> > > >
> > > > Signed-off-by: Stefani Seibold 
> > > > Signed-off-by: Suresh Gupta 
> > > > ---
> > > >  drivers/usb/gadget/fsl_udc_core.c | 38
> > > > +-
> > > >  1 file changed, 21 insertions(+), 17 deletions(-)
> > > >
> > > > diff --git a/drivers/usb/gadget/fsl_udc_core.c
> > > > b/drivers/usb/gadget/fsl_udc_core.c
> > > > index 35cb972..9a93727 100644
> > > > --- a/drivers/usb/gadget/fsl_udc_core.c
> > > > +++ b/drivers/usb/gadget/fsl_udc_core.c
> > > > @@ -153,6 +153,21 @@ static inline void fsl_set_accessors(struct
> > > > fsl_usb2_platform_data *pdata) {}
> > > >
> /
> > > >   * Internal Used Function
> > > >
> > > > **
> > > > **/
> > > > +static int can_pullup(struct fsl_udc *udc) {
> > > > +   return udc->driver && udc->softconnect && udc->vbus_active; }
> > > > +
> > > > +static void set_pullup(struct fsl_udc *udc) {
> > > > +   if (can_pullup(udc))
> > > > +   fsl_writel((fsl_readl(&dr_regs->usbcmd) |
> USB_CMD_RUN_STOP),
> > > > +   &dr_regs->usbcmd);
> > > > +   else
> > > > +   fsl_writel((fsl_readl(&dr_regs->usbcmd) &
> ~USB_CMD_RUN_STOP),
> > > > +   &dr_regs->usbcmd);
> > > > +}
> > >
> > > why is this a "fix", you just re-factored some code into
> set_pullup().
> > >
> > [SuresH] I set udc->vbus_active and udc->softconnect to default value
> > of 1 in struct_udc_setup. This was actual fix in this patch.  The
> 
> right, you see now why is it a problem to mix cleanups with fixes ? You
> *never*, ever combine unrelated changes in a single patch. It makes it a
> lot more difficult to see what you're actually changing. So, to start
> with, this patch should (if it was correct) be split into two smaller
> patches: one re-factoring the duplicated code into set_pullup() and
> another which fixes vbus_active and softconnect flags.

Agreed, I will resend the patches.  

> 
> But hang on, before you do that...
> 
> > can_pullup function return false when these values was not set and
> > intern the code return without enabling the pullup and gadget
> > controller stops.
> 
> So here's you mistake: the idea of can_pullup() (and thus, vbus_active
> and softconnect flags) is to tell the driver "we're connet to a host,
> it's safe to connect your pullups".
> 
> When you set both those flags to true, you're telling the driver that
> you, indeed, are connected to a host. This might not be true if you first
> boot up your platform, load all drivers and only after connect the cable.
> In essence, you're lying to your driver and, as my mommy used to say,
> "nobody likes a liar, my boy".
> 
> Curret situation isn't very good either since the driver is assuming that
> cable is only plugged after driver is loaded, so it won't cope very well
> with situation where cable is first plugged, then you apply power to your
> board.
> 
> What you *really* need to do here is ask the HW for initial states of
> those flags. During your probe() routine - as the name says - you probe
> your HW to check its state (or to initialize its state), then you ask
> "Hey IP, is VBUS above session valid threshold ?" Then you use the HW's
> reply to initialize both flags, the way you want.

After your explanation and some code browsing, I think the exact place to
set vbus_active is fsl_vbus_session which called on detecting vbus.
Also fsl_pullup should return without doing anything if vbus_active is not set.
Please suggest.

I do not get the usage of softconnect. Do I set softconnect also in 
fsl_vbus_session.
Please suggest.

Thanks
SuresH
--
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: questions about give back urb in tasklet

2014-03-19 Thread vichy
hi Ming:
>>> One approach I like to use is trace event.
>> Would you please let us how to to use trace event for calculate
>> max/average usb irq time?
>
> You can enable irq_handler_entry and irq_handler_exit event, then
> write a script easily to figure out the time consumed in ehci irq handler,
> see Documentation/trace/events.txt of linux kernel for detailed steps.
I find it ^^

>>> But actually the local interrupt is still disabled during completion
>>> because we need to convert spin_lock in all current usb drivers
>>> to spin_lock_irqsave() first.
>> Would you please let me know the function or source you mentioned?
>
> The local interrupt is disabled during completion handler in
> __usb_hcd_giveback_urb().
>
>>
>> BTW, why I cannot see xhci add HCD_BH?
>
> There might be some reasons:
>
> - in previous following up discussion, Alan thought it should
> be easier to just split the hcd interrupt handler into two parts
>
> - as I said, spin_lock() isn't converted to spin_lock_irqsave()
> in drivers' completion handler yet
Do you mean ,
take uvc/uac for example,
if we put completion what they register previously in BH,
the spin_lock() in their completions should be changed to spin_lock_irqsave()?

Is it due to original completion is called in irq context?

>
> - maybe no one really care the time in which local interrupt is
> disabled by USB completion handler.(That might be true
> because USB devices are commonly used in personal
> computer, not in big server product)
>
>> is there some reason xhci cannot put completion in BH?
>
> IMO, the completion handler should be put into tasklet, and
> can be done. If you like, you can take time to do that.
Below is so far kernel implementation.
Isn't it put completion handler into tasklet?
   ...
   ..
spin_lock(&bh->lock);
list_add_tail(&urb->urb_list, &bh->head);
running = bh->running;
spin_unlock(&bh->lock);

if (running)
;
else if (high_prio_bh)
tasklet_hi_schedule(&bh->bh);
else
tasklet_schedule(&bh->bh);


Thanks for your help,
--
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: problem with resume after s2ram

2014-03-19 Thread Alan Stern
On Wed, 19 Mar 2014, Peter Münster wrote:

> On Tue, Mar 18 2014, Alan Stern wrote:
> 
> >> Commit 0aa2832dd0d9d8609fd8f15139bc7572541a1215 introduces a problem for
> >> my system:
> >
> > You should include the name of the commit along with the hash ID;  
> > otherwise nobody will know what it is unless they go to the trouble of
> > looking it up for themselves.
> >
> > You also should address your email to the author of the commit.  
> > Otherwise your message is very likely to get overlooked.
> 
> Hi,
> 
> Sorry, next time I'll do it better.
> (I thought that the link to the initial report would have been enough...)

No, it isn't, because nobody will know what the initial report says
unless they click on the link.  You have to provide enough information
in the email itself for readers to judge whether they should pay
attention to it, without requiring them to do any extra work to find
out.  Otherwise they will simply ignore the message.

> > What do you get if you boot with no_console_suspend on the kernel
> > command line and do "echo 8 >/proc/sys/kernel/printk" before starting
> > the suspend?
> 
> Please see attached photo. It's the 3.12.14 kernel.

Okay.  It shows what happened, but not the reason for the crash.

In the photo, what were the two devices plugged into the rear ports?  
It looks like one of them was a keyboard or mouse, but the other seems
to be a serial port.

Can you use netconsole to capture the log messages, instead of taking a
picture of the screen?  See the instructions in
Documentation/networking/netconsole.txt.  (You'll need another computer 
to capture the messages.)

Do you have CONFIG_DETECT_HUNG_TASK enabled?  If not, please turn it 
on.  Then after you get a hang, wait a couple of minutes to see if 
any extra messages show up.

I'd like to see a comparable log showing what happens when you suspend
with only the mouse plugged in to a rear port, and one with only the
keyboard plugged in to the rear.  No serial ports or other stuff.

> > Also, can you turn on CONFIG_USB_DEBUG?
> 
> Yes, done.
> 
> 
> > What happens if you run a kernel that doesn't have that commit, such as
> > 3.9 or earlier, and you turn off CONFIG_USB_SUSPEND?
> 
> When pressing a key on the mouse or the keyboard, the system does not
> wake-up.

That's right; without CONFIG_USB_SUSPEND there is no support for USB 
wakeup.

>  But it wakes up after pressing the power-button. The system is
> ok after resume. Please find attached the log. The kernel is 3.9.11 with
> CONFIG_USB_DEBUG turned on and with CONFIG_USB_SUSPEND turned off.

Please post a log for the same kernel version and settings but with 
CONFIG_USB_SUSPEND turned back on.

Alan Stern

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


Re: [PATCH net,stable] net: cdc_ncm: fix control message ordering

2014-03-19 Thread Thomas Schäfer

> 
> I will test  also a further device(k5150), which was not working since 3.13,
> later this week.

The test was ok. The K5150 from HUAWEI/Vodafone (mbim) works again.
At least with IPv4. No statement about IPv6.


Regards,
Thomas

--
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 01/16] staging: wlags49_h2: Use tabs for indentation

2014-03-19 Thread Greg KH
On Tue, Mar 18, 2014 at 10:13:45PM +0100, Jelena Bjelja wrote:
> Fix the following checkpatch.pl issues in wl_netdev.c:
> WARNING: please, no spaces at the start of a line
> ERROR: code indent should use tabs where possible
> 
> Signed-off-by: Jelena Bjelja 
> ---
>  drivers/staging/wlags49_h2/wl_netdev.c | 1635 
> 
>  1 file changed, 817 insertions(+), 818 deletions(-)

This whole series doesn't apply to my tree anymore, I think due to some
patches that I took that were just sent before yours (sorry).

Can you refresh them and resend?

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] USB: Gadget: fsl driver pullup fix

2014-03-19 Thread Felipe Balbi
On Wed, Mar 19, 2014 at 02:23:59PM +, suresh.gu...@freescale.com wrote:
> 
> 
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Saturday, March 15, 2014 7:05 AM
> > To: Gupta Suresh-B42813
> > Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-usb@vger.kernel.org;
> > linux-ker...@vger.kernel.org; Stefani Seibold
> > Subject: Re: [PATCH] USB: Gadget: fsl driver pullup fix
> > 
> > Hi,
> > 
> > (first of all, please fix your email client, we need the quotation marks.
> > See Documentation/email-clients.txt)
> > 
> > On Fri, Mar 14, 2014 at 08:53:24PM +, suresh.gu...@freescale.com
> > wrote:
> > > > On Thu, Mar 13, 2014 at 06:40:55PM +0530, Suresh Gupta wrote:
> > > > > Attached is a small fix for the fsl usb gadget driver. This fix
> > > > > the driver in a way that the usb device will be only "pulled up"
> > > > > on requests like other usb gadget drivers do.
> > > > > This is necessary, because the device information is not always
> > > > > available until an application is up and running which provides
> > > > > this datas.
> > > > >
> > > > > Signed-off-by: Stefani Seibold 
> > > > > Signed-off-by: Suresh Gupta 
> > > > > ---
> > > > >  drivers/usb/gadget/fsl_udc_core.c | 38
> > > > > +-
> > > > >  1 file changed, 21 insertions(+), 17 deletions(-)
> > > > >
> > > > > diff --git a/drivers/usb/gadget/fsl_udc_core.c
> > > > > b/drivers/usb/gadget/fsl_udc_core.c
> > > > > index 35cb972..9a93727 100644
> > > > > --- a/drivers/usb/gadget/fsl_udc_core.c
> > > > > +++ b/drivers/usb/gadget/fsl_udc_core.c
> > > > > @@ -153,6 +153,21 @@ static inline void fsl_set_accessors(struct
> > > > > fsl_usb2_platform_data *pdata) {}
> > > > >
> > /
> > > > >   *   Internal Used Function
> > > > >
> > > > > **
> > > > > **/
> > > > > +static int can_pullup(struct fsl_udc *udc) {
> > > > > + return udc->driver && udc->softconnect && udc->vbus_active; }
> > > > > +
> > > > > +static void set_pullup(struct fsl_udc *udc) {
> > > > > + if (can_pullup(udc))
> > > > > + fsl_writel((fsl_readl(&dr_regs->usbcmd) |
> > USB_CMD_RUN_STOP),
> > > > > + &dr_regs->usbcmd);
> > > > > + else
> > > > > + fsl_writel((fsl_readl(&dr_regs->usbcmd) &
> > ~USB_CMD_RUN_STOP),
> > > > > + &dr_regs->usbcmd);
> > > > > +}
> > > >
> > > > why is this a "fix", you just re-factored some code into
> > set_pullup().
> > > >
> > > [SuresH] I set udc->vbus_active and udc->softconnect to default value
> > > of 1 in struct_udc_setup. This was actual fix in this patch.  The
> > 
> > right, you see now why is it a problem to mix cleanups with fixes ? You
> > *never*, ever combine unrelated changes in a single patch. It makes it a
> > lot more difficult to see what you're actually changing. So, to start
> > with, this patch should (if it was correct) be split into two smaller
> > patches: one re-factoring the duplicated code into set_pullup() and
> > another which fixes vbus_active and softconnect flags.
> 
> Agreed, I will resend the patches.  
> 
> > 
> > But hang on, before you do that...
> > 
> > > can_pullup function return false when these values was not set and
> > > intern the code return without enabling the pullup and gadget
> > > controller stops.
> > 
> > So here's you mistake: the idea of can_pullup() (and thus, vbus_active
> > and softconnect flags) is to tell the driver "we're connet to a host,
> > it's safe to connect your pullups".
> > 
> > When you set both those flags to true, you're telling the driver that
> > you, indeed, are connected to a host. This might not be true if you first
> > boot up your platform, load all drivers and only after connect the cable.
> > In essence, you're lying to your driver and, as my mommy used to say,
> > "nobody likes a liar, my boy".
> > 
> > Curret situation isn't very good either since the driver is assuming that
> > cable is only plugged after driver is loaded, so it won't cope very well
> > with situation where cable is first plugged, then you apply power to your
> > board.
> > 
> > What you *really* need to do here is ask the HW for initial states of
> > those flags. During your probe() routine - as the name says - you probe
> > your HW to check its state (or to initialize its state), then you ask
> > "Hey IP, is VBUS above session valid threshold ?" Then you use the HW's
> > reply to initialize both flags, the way you want.
> 
> After your explanation and some code browsing, I think the exact place to
> set vbus_active is fsl_vbus_session which called on detecting vbus.
> Also fsl_pullup should return without doing anything if vbus_active is not 
> set.
> Please suggest.
> 
> I do not get the usage of softconnect. Do I set softconnect also in
> fsl_vbus_session.  Please suggest.

looks like softconnect shoul

Re: [OPW kernel] [PATCH 2/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Greg KH
On Wed, Mar 19, 2014 at 05:08:58PM +0530, Heena Sirwani wrote:
> Fix checkpatch.pl issues with line over 80 characters in Adapter.h
> 
> Signed-off-by: Heena Sirwani 
> ---
>  drivers/staging/bcm/Adapter.h |   23 ++-
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
> index 1b2d9f3..a387234 100644
> --- a/drivers/staging/bcm/Adapter.h
> +++ b/drivers/staging/bcm/Adapter.h
> @@ -39,12 +39,14 @@ union u_ip_address {
>   struct {
>   /* Source Ip Address Range */
>   ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];
> -  /* Source Ip Mask Address Range */
> + /* Source Ip Mask Address Range */
>   ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];
>   };
>   struct {
> - ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address 
> Range */
> - ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Mask 
> Address Range */
> + /* Source Ip Address Range */
> + ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];
> + /* Source Ip Mask Address Range */
> + ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];
>   };
>   struct {
>   UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
> @@ -57,9 +59,11 @@ union u_ip_address {
>  };
>  
>  struct bcm_hdr_suppression_contextinfo {
> - UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer 
> to accumulate pkt Header for PHS */
> - UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* 
> Intermediate buffer containing pkt Header after PHS */
> -};
> + /* Intermediate buffer to accumulate pkt Header for PHS */
> + UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS];
> + /* Intermediate buffer containing pkt Header after PHS */
> + UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN];
> + };
>  
>  struct bcm_classifier_rule {
>   ULONG   ulSFID;
> @@ -67,11 +71,12 @@ struct bcm_classifier_rule {
>   B_UINT16uiClassifierRuleIndex;
>   boolbUsed;
>   USHORT  usVCID_Value;
> - B_UINT8 u8ClassifierRulePriority; /* This field detemines the 
> Classifier Priority */
> + /* This field detemines the Classifier Priority */
> + B_UINT8 u8ClassifierRulePriority;
>   union u_ip_address  stSrcIpAddress;
> - UCHAR   ucIPSourceAddressLength; /* Ip Source Address Length */
> -
>   union u_ip_address  stDestIpAddress;
> + /* Ip Source Address Length */
> + UCHAR   ucIPSourceAddressLength;

You moved the fields areound in the structure, which mighe be just fine,
but if this is trying to match up with some hardware registers, could
break things badly.

So please don't do that, unless you "know" it's ok.

thanks,

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


Re: [PATCH 4/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Greg KH
On Wed, Mar 19, 2014 at 05:12:13PM +0530, Heena Sirwani wrote:
> Fix checkpatch.pl issues with line over 80 characters in Adapter.h
> 
> Signed-off-by: Heena Sirwani 

You have 5 patches here with the same Subject:, which I can't take.

Please uniquely name the subject and resend.

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 3/6] staging: bcm: Fix line over 80 characters.

2014-03-19 Thread Greg KH
On Wed, Mar 19, 2014 at 05:10:34PM +0530, Heena Sirwani wrote:
> Fix checkpatch.pl issues with line over 80 characters in Adapter.h
> 
> Signed-off-by: Heena Sirwani 
> ---
>  drivers/staging/bcm/Adapter.h |9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
> index a387234..d241164 100644
> --- a/drivers/staging/bcm/Adapter.h
> +++ b/drivers/staging/bcm/Adapter.h
> @@ -53,8 +53,10 @@ union u_ip_address {
>   UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
>   };
>   struct {
> - UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * 
> IPV6_ADDRESS_SIZEINBYTES];
> - UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * 
> IPV6_ADDRESS_SIZEINBYTES];
> + UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH
> + * IPV6_ADDRESS_SIZEINBYTES];
> + UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH
> + * IPV6_ADDRESS_SIZEINBYTES];

Put the '*' on the first line, otherwise your brain wants to think this
is a pointer somehow.

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] usb: gadget: fsl: Add FSL USB Gadget entry in platform device id

2014-03-19 Thread gre...@linuxfoundation.org
On Wed, Mar 19, 2014 at 02:25:25PM +, suresh.gu...@freescale.com wrote:
> Hi
> 
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Saturday, March 15, 2014 7:10 AM
> > To: Gupta Suresh-B42813
> > Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-usb@vger.kernel.org;
> > linux-ker...@vger.kernel.org
> > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > platform device id
> > 
> > On Fri, Mar 14, 2014 at 08:52:19PM +, suresh.gu...@freescale.com
> > wrote:
> > > Hi,
> > > Thanks for reviewing my patches.
> > > Please find my comments inline
> > >
> > > -Original Message-
> > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > Sent: Thursday, March 13, 2014 8:56 PM
> > > To: Gupta Suresh-B42813
> > > Cc: ba...@ti.com; gre...@linuxfoundation.org;
> > > linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org; Gupta
> > > Suresh-B42813
> > > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > > platform device id
> > >
> > > On Thu, Mar 13, 2014 at 07:35:31PM +0530, Suresh Gupta wrote:
> > > > From: Suresh Gupta 
> > > >
> > > > Add FSL USB Gadget entry in platform device id table
> > >
> > > why this tab ?
> > > [SuresH] I will remove it in next version.
> > >
> > > > Signed-off-by: Suresh Gupta 
> > > > ---
> > > >  drivers/usb/gadget/fsl_udc_core.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/drivers/usb/gadget/fsl_udc_core.c
> > > > b/drivers/usb/gadget/fsl_udc_core.c
> > > > index b7dea4e..35b20e6 100644
> > > > --- a/drivers/usb/gadget/fsl_udc_core.c
> > > > +++ b/drivers/usb/gadget/fsl_udc_core.c
> > > > @@ -2654,6 +2654,8 @@ static const struct platform_device_id
> > fsl_udc_devtype[] = {
> > > > }, {
> > > > .name = "imx-udc-mx51",
> > > > }, {
> > > > +   .name = "fsl-usb2-udc",
> > >
> > > why aren't you just using chipidea ?
> > > [SuresH] This is our legacy driver for all previous and existing ppc
> > > socs. Many of our customers are already using this, and we need to
> > > support them on this driver. We do have plans to shift to chipidea,
> > > but after some time.
> > 
> > cool, you already have plans, so we will see a new glue layer for v3.16
> > right ? Which means I don't need to take this patch either.
> > 
> we do have plans, but in remote future. Right now, we need to support
> customers on the present legacy driver. We'll phase out this driver 
> slowly when we integrate chipidea. At this time I would request you 
> to please accept this patch

Even if Felipe takes the patch, I'll reject it as you should be doing
the correct thing here, and if it's accepted, it will never be
changed...

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: Support for new USB Modem 4G drive

2014-03-19 Thread Dan Williams
On Wed, 2014-03-19 at 13:22 -0300, Julio Araujo wrote:
> Hi Dan,
> 
> Thanks for your answer.
> I would like to inform you that I'm using an Ubuntu 12.04 TLS
> julio@mynote:~$ uname -a
> Linux mynote 3.8.0-36-generic #52~precise1-Ubuntu SMP Mon Feb 3 21:54:46 
> UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
> 
> Another thing that I've been done was a search in the google for any 
> info regarding to this 4G Modem and then I found this link: 
> http://linuxnomicro.blogspot.com.br/2012/03/modem-olivetti-olicard-155-no-ubuntu.html
> Unfortunately it is in pt-br, but basically it is saying to create a 
> file called "14-olicardmodules.rules" in the patch /etc/udev/rules.d/ 
> with the follow information:
> ATTRS{idVendor}=="0b3c",ATTRS{idProduct}=="c004",RUN+="/sbin/modprobe 
> usbserial vendor=0x0b3c product=0xc004"
> KERNEL==”ttyUSB[23]“,ACTION==”add”,ATTRS{idVendor}==”0b3c”,ATTRS{idProduct}==”c004″,RUN+=”/bin/sleep
>  
> 2″
> I changed the value "c004" to "f017", but even with this file the 4G 
> modem does not work and then I removed the file from this patch.

>From the information below, it appears the modem is not being switched
correctly to modem mode from storage mode.  The tool that does that is
usb_modeswitch, but usb_modeswitch does not have specific support for
your new device.

So the next steps are for you to contact the usb_modeswitch project and
work with them to get the modem successfully switched from storage mode
to modem mode.

http://www.draisberghof.de/usb_modeswitch/

Dan

> Follow below the printout that you requested:
> julio@mynote:~$ sudo lsusb -v -d 0b3c:f017
> 
> Bus 001 Device 004: ID 0b3c:f017 Olivetti Techcenter
> Device Descriptor:
>bLength18
>bDescriptorType 1
>bcdUSB   2.00
>bDeviceClass0 (Defined at Interface level)
>bDeviceSubClass 0
>bDeviceProtocol 0
>bMaxPacketSize064
>idVendor   0x0b3c Olivetti Techcenter
>idProduct  0xf017
>bcdDevice0.00
>iManufacturer   3 USBModem
>iProduct2 Olicard 500
>iSerial 0
>bNumConfigurations  1
>Configuration Descriptor:
>  bLength 9
>  bDescriptorType 2
>  wTotalLength   55
>  bNumInterfaces  2
>  bConfigurationValue 1
>  iConfiguration  1 USBModem Configuration
>  bmAttributes 0xc0
>Self Powered
>  MaxPower  500mA
>  Interface Descriptor:
>bLength 9
>bDescriptorType 4
>bInterfaceNumber0
>bAlternateSetting   0
>bNumEndpoints   2
>bInterfaceClass 8 Mass Storage
>bInterfaceSubClass  6 SCSI
>bInterfaceProtocol 80 Bulk-Only
>iInterface  0
>Endpoint Descriptor:
>  bLength 7
>  bDescriptorType 5
>  bEndpointAddress 0x01  EP 1 OUT
>  bmAttributes2
>Transfer TypeBulk
>Synch Type   None
>Usage Type   Data
>  wMaxPacketSize 0x0200  1x 512 bytes
>  bInterval   0
>Endpoint Descriptor:
>  bLength 7
>  bDescriptorType 5
>  bEndpointAddress 0x81  EP 1 IN
>  bmAttributes2
>Transfer TypeBulk
>Synch Type   None
>Usage Type   Data
>  wMaxPacketSize 0x0200  1x 512 bytes
>  bInterval   0
>  Interface Descriptor:
>bLength 9
>bDescriptorType 4
>bInterfaceNumber1
>bAlternateSetting   0
>bNumEndpoints   2
>bInterfaceClass 8 Mass Storage
>bInterfaceSubClass  6 SCSI
>bInterfaceProtocol 80 Bulk-Only
>iInterface  0
>Endpoint Descriptor:
>  bLength 7
>  bDescriptorType 5
>  bEndpointAddress 0x02  EP 2 OUT
>  bmAttributes2
>Transfer TypeBulk
>Synch Type   None
>Usage Type   Data
>  wMaxPacketSize 0x0200  1x 512 bytes
>  bInterval   0
>Endpoint Descriptor:
>  bLength 7
>  bDescriptorType 5
>  bEndpointAddress 0x82  EP 2 IN
>  bmAttributes2
>Transfer TypeBulk
>Synch Type   None
>Usage Type   Data
>  wMaxPacketSize 0x0200  1x 512 bytes
>  bInterval   0
> Device Qualifier (for other device speed):
>bLength10
>bDescriptorType 6

Re: Support for new USB Modem 4G drive

2014-03-19 Thread Julio Araujo

Hi Dan,

Thanks for your answer.
I would like to inform you that I'm using an Ubuntu 12.04 TLS
julio@mynote:~$ uname -a
Linux mynote 3.8.0-36-generic #52~precise1-Ubuntu SMP Mon Feb 3 21:54:46 
UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


Another thing that I've been done was a search in the google for any 
info regarding to this 4G Modem and then I found this link: 
http://linuxnomicro.blogspot.com.br/2012/03/modem-olivetti-olicard-155-no-ubuntu.html
Unfortunately it is in pt-br, but basically it is saying to create a 
file called "14-olicardmodules.rules" in the patch /etc/udev/rules.d/ 
with the follow information:
ATTRS{idVendor}=="0b3c",ATTRS{idProduct}=="c004",RUN+="/sbin/modprobe 
usbserial vendor=0x0b3c product=0xc004"
KERNEL==”ttyUSB[23]“,ACTION==”add”,ATTRS{idVendor}==”0b3c”,ATTRS{idProduct}==”c004″,RUN+=”/bin/sleep 
2″
I changed the value "c004" to "f017", but even with this file the 4G 
modem does not work and then I removed the file from this patch.


Follow below the printout that you requested:
julio@mynote:~$ sudo lsusb -v -d 0b3c:f017

Bus 001 Device 004: ID 0b3c:f017 Olivetti Techcenter
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize064
  idVendor   0x0b3c Olivetti Techcenter
  idProduct  0xf017
  bcdDevice0.00
  iManufacturer   3 USBModem
  iProduct2 Olicard 500
  iSerial 0
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   55
bNumInterfaces  2
bConfigurationValue 1
iConfiguration  1 USBModem Configuration
bmAttributes 0xc0
  Self Powered
MaxPower  500mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass 8 Mass Storage
  bInterfaceSubClass  6 SCSI
  bInterfaceProtocol 80 Bulk-Only
  iInterface  0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01  EP 1 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber1
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass 8 Mass Storage
  bInterfaceSubClass  6 SCSI
  bInterfaceProtocol 80 Bulk-Only
  iInterface  0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02  EP 2 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82  EP 2 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0200  1x 512 bytes
bInterval   0
Device Qualifier (for other device speed):
  bLength10
  bDescriptorType 6
  bcdUSB   2.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize064
  bNumConfigurations  1
Device Status: 0x
  (Bus Powered)
julio@mynote:~$

If you need anything else, please let me know.

Thanks,
Julio


Em 19-03-2014 10:16, Dan Williams escreveu:

On Wed, 2014-03-19 at 06:25 -0300, Julio Araujo wrote:

Hello,

My name is Julio and I'm trying to use a USB Modem 4G model OLICARD500
from the manufacture Olivetti and I got the follow message from syslog:
Mar 19 05:23:29 mynote kernel: [  265.072844] usbserial_generic
1-1.3:1.0: Tell linux-usb@vger.kernel.org to add your device to a proper
driver.
Mar 19 05:23:29 mynote kernel: [  265.072852] usbserial_generic
1-1.3:1.0: generic conve

Re: [PATCH 0/6] Fix line over 80 characters warning in bcm.

2014-03-19 Thread Sergei Shtylyov

Hello.

On 03/19/2014 02:32 PM, Heena Sirwani wrote:


This patchset consists of patches that fix line over 80 characters
warning in bcm module in Adapter.h.Please review the patches that
follow.


   It's very strange that you broke this change up into 6 patches. You're 
fixing the same issue in the same file in each of the patches -- why not do 
this in a single patch?



Heena Sirwani (6):
   staging: bcm: Fix line over 80 characters.
   staging: bcm: Fix line over 80 characters.
   staging: bcm: Fix line over 80 characters.
   staging: bcm: Fix line over 80 characters.
   staging: bcm: Fix line over 80 characters.
   staging: bcm: Fix line over 80 characters.



  drivers/staging/bcm/Adapter.h |   61 +++--
  1 file changed, 40 insertions(+), 21 deletions(-)


WBR, Sergei

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


RE: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in platform device id

2014-03-19 Thread suresh.gu...@freescale.com
Hi Ramneek,

Do you understand, what Greg want to communicate. 


Thanks
SuresH

> -Original Message-
> From: gre...@linuxfoundation.org [mailto:gre...@linuxfoundation.org]
> Sent: Wednesday, March 19, 2014 10:22 PM
> To: Gupta Suresh-B42813
> Cc: ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> platform device id
> 
> On Wed, Mar 19, 2014 at 02:25:25PM +, suresh.gu...@freescale.com
> wrote:
> > Hi
> >
> > > -Original Message-
> > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > Sent: Saturday, March 15, 2014 7:10 AM
> > > To: Gupta Suresh-B42813
> > > Cc: ba...@ti.com; gre...@linuxfoundation.org;
> > > linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
> > > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > > platform device id
> > >
> > > On Fri, Mar 14, 2014 at 08:52:19PM +, suresh.gu...@freescale.com
> > > wrote:
> > > > Hi,
> > > > Thanks for reviewing my patches.
> > > > Please find my comments inline
> > > >
> > > > -Original Message-
> > > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > > Sent: Thursday, March 13, 2014 8:56 PM
> > > > To: Gupta Suresh-B42813
> > > > Cc: ba...@ti.com; gre...@linuxfoundation.org;
> > > > linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org; Gupta
> > > > Suresh-B42813
> > > > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > > > platform device id
> > > >
> > > > On Thu, Mar 13, 2014 at 07:35:31PM +0530, Suresh Gupta wrote:
> > > > > From: Suresh Gupta 
> > > > >
> > > > >   Add FSL USB Gadget entry in platform device id table
> > > >
> > > > why this tab ?
> > > > [SuresH] I will remove it in next version.
> > > >
> > > > > Signed-off-by: Suresh Gupta 
> > > > > ---
> > > > >  drivers/usb/gadget/fsl_udc_core.c | 2 ++
> > > > >  1 file changed, 2 insertions(+)
> > > > >
> > > > > diff --git a/drivers/usb/gadget/fsl_udc_core.c
> > > > > b/drivers/usb/gadget/fsl_udc_core.c
> > > > > index b7dea4e..35b20e6 100644
> > > > > --- a/drivers/usb/gadget/fsl_udc_core.c
> > > > > +++ b/drivers/usb/gadget/fsl_udc_core.c
> > > > > @@ -2654,6 +2654,8 @@ static const struct platform_device_id
> > > fsl_udc_devtype[] = {
> > > > >   }, {
> > > > >   .name = "imx-udc-mx51",
> > > > >   }, {
> > > > > + .name = "fsl-usb2-udc",
> > > >
> > > > why aren't you just using chipidea ?
> > > > [SuresH] This is our legacy driver for all previous and existing
> > > > ppc socs. Many of our customers are already using this, and we
> > > > need to support them on this driver. We do have plans to shift to
> > > > chipidea, but after some time.
> > >
> > > cool, you already have plans, so we will see a new glue layer for
> > > v3.16 right ? Which means I don't need to take this patch either.
> > >
> > we do have plans, but in remote future. Right now, we need to support
> > customers on the present legacy driver. We'll phase out this driver
> > slowly when we integrate chipidea. At this time I would request you to
> > please accept this patch
> 
> Even if Felipe takes the patch, I'll reject it as you should be doing the
> correct thing here, and if it's accepted, it will never be changed...
> 
> 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 v4 03/11] usb: chipidea: host: init otg port number.

2014-03-19 Thread Sergei Shtylyov

Hello.

On 03/19/2014 01:01 PM, Li Jun wrote:


Init otg_port number of otg capable host to be 1 at host start.



Signed-off-by: Li Jun 
---
  drivers/usb/chipidea/host.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)



diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 4b609bc..5ec8ccd 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -80,8 +80,13 @@ static int host_start(struct ci_hdrc *ci)
ret = usb_add_hcd(hcd, 0, 0);
if (ret)
goto disable_reg;
-   else
+   else {


   All arms of the *if* statement should have {} if at least one arm has it 
-- see Documentation/CodingStyle.



ci->hcd = hcd;
+   if (ci_host_is_otg(ci)) {
+   ci->transceiver->otg->host = &hcd->self;
+   ci->transceiver->otg->host->otg_port = 1;


   Might be worth declaring a variable equal to 'ci->transceiver->otg' first...


+   }
+   }


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 1/5] staging: wlags49_h2: Enclose macro in a do-while loop

2014-03-19 Thread Jelena Bjelja
Fix the following checkpatch.pl issues in wl_netdev.c:
ERROR: Macros with multiple statements should be enclosed in a do -
while loop

Signed-off-by: Jelena Bjelja 
---
 drivers/staging/wlags49_h2/wl_netdev.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wlags49_h2/wl_netdev.c 
b/drivers/staging/wlags49_h2/wl_netdev.c
index 255d291..0e553ae 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -107,9 +107,11 @@
  * macros
  
**/
 #define BLOCK_INPUT(buf, len) \
-desc->buf_addr = buf; \
-desc->BUF_SIZE = len; \
-status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
+   do { \
+   desc->buf_addr = buf; \
+   desc->BUF_SIZE = len; \
+   status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0); \
+   } while (0)
 
 #define BLOCK_INPUT_DMA(buf, len) memcpy( buf, desc_next->buf_addr, pktlen )
 
-- 
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 0/5] staging: wlags49_h2: Fix checkpatch issues in wl_netdev.c

2014-03-19 Thread Jelena Bjelja
This patchset fixes most of the checkpatch.pl issues in wl_netdev.c

Jelena Bjelja (5):
  staging: wlags49_h2: Enclose macro in a do-while loop
  Delete unnecessary spaces
  Remove trailing whitespace
  staging: wlags49_h2: Do not use assignment in if condition
  staging: wlags49_h2: Delete unnecessary braces

 drivers/staging/wlags49_h2/wl_netdev.c |   39 ++--
 1 file changed, 17 insertions(+), 22 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


[PATCH 3/5] Remove trailing whitespace

2014-03-19 Thread Jelena Bjelja
Remove trailing whitespace in wl_netdev.c

Signed-off-by: Jelena Bjelja 
---
 drivers/staging/wlags49_h2/wl_netdev.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlags49_h2/wl_netdev.c 
b/drivers/staging/wlags49_h2/wl_netdev.c
index 8e571b2..eb428ae 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -172,7 +172,7 @@ int wl_config(struct net_device *dev, struct ifmap *map)
 
/*
 * The only thing we care about here is a port change.
-* Since this not needed, ignore the request. 
+* Since this not needed, ignore the request.
 */
DBG_TRACE(DbgInfo, "%s: %s called.\n", dev->name, __func__);
 
-- 
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 2/5] Delete unnecessary spaces

2014-03-19 Thread Jelena Bjelja
Fix the following checkpatch.pl issues in wl_netdev.c:

ERROR: space prohibited after that open parenthesis '('
#116: FILE: drivers/staging/wlags49_h2/wl_netdev.c:116:

ERROR: space prohibited before that close parenthesis ')'
#116: FILE: drivers/staging/wlags49_h2/wl_netdev.c:116:

Signed-off-by: Jelena Bjelja 
---
 drivers/staging/wlags49_h2/wl_netdev.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlags49_h2/wl_netdev.c 
b/drivers/staging/wlags49_h2/wl_netdev.c
index 0e553ae..8e571b2 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -113,7 +113,7 @@
status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0); \
} while (0)
 
-#define BLOCK_INPUT_DMA(buf, len) memcpy( buf, desc_next->buf_addr, pktlen )
+#define BLOCK_INPUT_DMA(buf, len) memcpy(buf, desc_next->buf_addr, pktlen)
 
 
/***
  * function prototypes
-- 
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 4/5] staging: wlags49_h2: Do not use assignment in if condition

2014-03-19 Thread Jelena Bjelja
Fix the following checkpatch.pl issue in wl_netdev.c:
ERROR: do not use assignment in if condition

Signed-off-by: Jelena Bjelja 
---
 drivers/staging/wlags49_h2/wl_netdev.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wlags49_h2/wl_netdev.c 
b/drivers/staging/wlags49_h2/wl_netdev.c
index eb428ae..9dbbc15 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -1819,7 +1819,8 @@ int wl_rx_dma(struct net_device *dev)
 
DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
 
-   if (((lp = dev->priv) != NULL) && !(lp->flags & WVLAN2_UIL_BUSY)) {
+   lp = dev->priv;
+   if ((lp != NULL) && !(lp->flags & WVLAN2_UIL_BUSY)) {
 
 #ifdef USE_RTS
if (lp->useRTS == 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 5/5] staging: wlags49_h2: Delete unnecessary braces

2014-03-19 Thread Jelena Bjelja
Fix the following checkpatch.pl warnings in wl_netdev.c:
WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Jelena Bjelja 
---
 drivers/staging/wlags49_h2/wl_netdev.c |   24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/wlags49_h2/wl_netdev.c 
b/drivers/staging/wlags49_h2/wl_netdev.c
index 9dbbc15..1a0ddf4 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -225,17 +225,15 @@ struct net_device_stats *wl_stats(struct net_device *dev)
 #ifdef USE_WDS
 
for (count = 0; count < NUM_WDS_PORTS; count++) {
-   if (dev == lp->wds_port[count].dev) {
+   if (dev == lp->wds_port[count].dev)
pStats = &(lp->wds_port[count].stats);
-   }
}
 
 #endif /* USE_WDS */
 
/* If pStats is still NULL, then the device is not a WDS port */
-   if (pStats == NULL) {
+   if (pStats == NULL)
pStats = &(lp->stats);
-   }
 
wl_unlock(lp, &flags);
 
@@ -578,9 +576,8 @@ void wl_tx_timeout(struct net_device *dev)
 #endif /* USE_WDS */
 
/* If pStats is still NULL, then the device is not a WDS port */
-   if (pStats == NULL) {
+   if (pStats == NULL)
pStats = &(lp->stats);
-   }
 
/* Accumulate the timeout error */
pStats->tx_errors++;
@@ -663,9 +660,8 @@ int wl_send(struct wl_private *lp)
}
}
 
-   if (lp->txF.skb == NULL) {
+   if (lp->txF.skb == NULL)
return FALSE;
-   }
 
/* If the device has resources (FIDs) available, then Tx the packet */
/* Format the TxRequest and send it to the adapter */
@@ -926,9 +922,8 @@ int wl_rx(struct net_device *dev)
DBG_ERROR(DbgInfo,
  "Rx request to card 
FAILED\n");
 
-   if (port == 0) {
+   if (port == 0)
lp->stats.rx_dropped++;
-   }
 #ifdef USE_WDS
else {
lp->wds_port[port -
@@ -942,9 +937,8 @@ int wl_rx(struct net_device *dev)
} else {
DBG_ERROR(DbgInfo, "Could not alloc skb\n");
 
-   if (port == 0) {
+   if (port == 0)
lp->stats.rx_dropped++;
-   }
 #ifdef USE_WDS
else {
lp->wds_port[port -
@@ -1657,9 +1651,8 @@ void wl_wds_netif_carrier_on(struct wl_private *lp)
 
if (lp != NULL) {
for (count = 0; count < NUM_WDS_PORTS; count++) {
-   if (lp->wds_port[count].is_registered) {
+   if (lp->wds_port[count].is_registered)
netif_carrier_on(lp->wds_port[count].dev);
-   }
}
}
 }  /* wl_wds_netif_carrier_on */
@@ -1936,9 +1929,8 @@ int wl_rx_dma(struct net_device *dev)
DBG_ERROR(DbgInfo,
  "Could not alloc skb\n");
 
-   if (port == 0) {
+   if (port == 0)
lp->stats.rx_dropped++;
-   }
 #ifdef USE_WDS
else {
lp->wds_port[port -
-- 
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


Failure to recognize device for 45 minutes and Device Disconnects

2014-03-19 Thread Mike Mitchell
Please help me narrow down this perplexing mystery:
1. USB Mic device takes ~45 minutes to recognize after warm start.
2. Same device disconnect sporadically, usually about an hour after it
was last used.
3. Otherwise device works fine for days on end.

Host: Intel NUC dccp847dye
Device: CAD U7 Mic
Kernel:3.5.0-47-generic #71~precise1-Ubuntu SMP Wed Feb 19 22:05:41
UTC 2014 i686 i686 i386 GNU/Linux

USBMon trap of first activity when device is connected:
f69900c0 3707165147 S Ci:2:001:0 s a3 00  0001 0004 4 <
f69900c0 3707165199 C Ci:2:001:0 0 4 = 03050400
f69900c0 3707165204 S Ci:2:001:0 s a3 00  0002 0004 4 <
f69900c0 3707165208 C Ci:2:001:0 0 4 = 0001
f3dbd600 3707165211 S Ii:2:001:1 -115:2048 4 <
f69900c0 3707165250 S Ci:2:001:0 s a3 00  0001 0004 4 <
f69900c0 3707165254 C Ci:2:001:0 0 4 = 03050400
f69900c0 3707165258 S Co:2:001:0 s 23 01 0012 0001  0
f69900c0 3707165262 C Co:2:001:0 0 0
f6b7b300 3707181165 S Ci:2:001:0 s a3 00  0001 0004 4 <
f6b7b300 3707181184 C Ci:2:001:0 0 4 = 0305
f6b7b300 3707181190 S Ci:2:002:0 s 80 00   0002 2 <
f6b7b300 3707181332 C Ci:2:002:0 0 2 = 0300
f6b7b300 3707181354 S Co:2:002:0 s 00 01 0001   0
f6b7b300 3707181494 C Co:2:002:0 0 0
f6b7b300 3707181525 S Ci:2:002:0 s a3 00  0001 0004 4 <
f6b7b300 3707181576 C Ci:2:002:0 0 4 = 01010100
f6b7b300 3707181651 S Co:2:002:0 s 23 01 0010 0001  0
f6b7b300 3707181701 C Co:2:002:0 0 0
f6b7b300 3707181779 S Ci:2:002:0 s a3 00  0002 0004 4 <
f6b7b300 3707181826 C Ci:2:002:0 0 4 = 0001
f6b7b300 3707181880 S Ci:2:002:0 s a3 00  0003 0004 4 <
f6b7b300 3707181955 C Ci:2:002:0 0 4 = 0001
f6b7b300 3707181984 S Ci:2:002:0 s a3 00  0004 0004 4 <
f6b7b300 3707182124 C Ci:2:002:0 0 4 = 0001
f6b7b300 3707182189 S Ci:2:002:0 s a3 00  0005 0004 4 <
f6b7b300 3707182328 C Ci:2:002:0 0 4 = 0001
f6b7b300 3707182354 S Ci:2:002:0 s a3 00  0006 0004 4 <
f6b7b300 3707182451 C Ci:2:002:0 0 4 = 0001
f6b7b300 3707182463 S Ci:2:002:0 s a3 00  0007 0004 4 <
f6b7b300 3707182576 C Ci:2:002:0 0 4 = 0001
f6b7b300 3707182638 S Ci:2:002:0 s a3 00  0008 0004 4 <
f6b7b300 3707182745 C Ci:2:002:0 0 4 = 0001
f6dfaf00 3707285161 S Ii:2:002:1 -115:2048 2 <
f69906c0 3707285208 S Ci:2:002:0 s a3 00  0001 0004 4 <
f69906c0 3707285332 C Ci:2:002:0 0 4 = 0101
f69906c0 3707285406 S Co:2:002:0 s 23 03 0004 0001  0
f69906c0 3707285462 C Co:2:002:0 0 0
f69906c0 3707301135 S Ci:2:002:0 s a3 00  0001 0004 4 <
f69906c0 3707301224 C Ci:2:002:0 0 4 = 03011000
f6b7b6c0 3707357171 S Co:2:002:0 s 23 01 0014 0001  0
f6b7b6c0 3707357376 C Co:2:002:0 0 0
f6990540 3707357440 S Ci:2:000:0 s 80 06 0100  0040 64 <
f6990540 3707357575 C Ci:2:000:0 0 18 = 12011001 0040 8c0d0800 00010001 0001
f6990540 3707357598 S Co:2:002:0 s 23 03 0004 0001  0
f6990540 3707357743 C Co:2:002:0 0 0
f6990840 3707373108 S Ci:2:002:0 s a3 00  0001 0004 4 <
f6990840 3707373211 C Ci:2:002:0 0 4 = 03011000
f6dfaf00 3707425421 C Ii:2:002:1 0:2048 2 = 0200
f6dfaf00 3707425442 S Ii:2:002:1 -115:2048 2 <
f6b7b480 3707429152 S Co:2:002:0 s 23 01 0014 0001  0
f6b7b480 3707429371 C Co:2:002:0 0 0
f6b7b480 3707429410 S Co:2:000:0 s 00 05 0003   0
f6b7b480 3707429592 C Co:2:000:0 0 0
f6b7b480 3707449172 S Ci:2:003:0 s 80 06 0100  0012 18 <
f6b7b480 3707449462 C Ci:2:003:0 0 18 = 12011001 0040 8c0d0800 00010001 0001
f6b7b480 3707449674 S Ci:2:003:0 s 80 06 0200  0009 9 <
f6b7b480 3707449846 C Ci:2:003:0 0 9 = 0902e000 040100a0 32
f6b7b480 3707449913 S Ci:2:003:0 s 80 06 0200  00e0 224 <
f6b7b480 3707450214 C Ci:2:003:0 0 224 = 0902e000 040100a0 32090400
0101 0a24 01000147 00020102 0c240201
f6b7b480 3707450294 S Ci:2:003:0 s 80 06 0300  00ff 255 <
f6b7b480 3707450494 C Ci:2:003:0 0 4 = 04030904
f6b7b480 3707450523 S Ci:2:003:0 s 80 06 0301 0409 00ff 255 <
f6b7b480 3707450707 C Ci:2:003:0 0 56 = 38034300 2d004d00 65006400
69006100 20005500 53004200 20004100 75006400
f6b7bc00 3707451430 S Co:2:003:0 s 00 09 0001   0
f6b7bc00 3707451577 C Co:2:003:0 0 0
f6b7b840 3707452108 S Ci:2:002:0 s a3 00  0001 0004 4 <
f6b7b840 3707452200 C Ci:2:002:0 0 4 = 0301
f69906c0 3707478962 S Ci:2:003:0 s 80 06 0301 0409 00ff 255 <
f69906c0 3707479200 C Ci:2:003:0 0 56 = 38034300 2d004d00 65006400
69006100 20005500 53004200 20004100 75006400
f69906c0 3707479372 S Co:2:003:0 s 01 0b 0001 0001  0
f69906c0 3707479575 C Co:2:003:0 0 0
f69906c0 3707479699 S Co:2:003:0 s 22 01 0100 0001 0003 3 = 80bb00
f69906c0 3707479950 C Co:2:003:0 0 3 >
f69906c0 3707480033 S Ci:2:003:0 s a2 81 0100 0001 0003 3 <
f69906c0 3707480203 C Ci:2:003:0 0 3 = 80bb00
f69906c0 3707480692 S Co:2:003:0 s 01 0b  0001  0
f69906c0 3707480825 C Co:2:003:0 0 0
f69906c0 3707480980 S Co:2:003:0 s 01 0b 0001 0002  0
f69906c0 3707481200 C Co:2:003:0 0 0
f69906c0 3707481332 S Co:2:003:0 s 22 01 0100 0082 0003 3 = 80bb00
f69906c0 3707481574 C Co:2:003:0 0 3 >
f69906c0 3707481889 S C

Re: Failure to recognize device for 45 minutes and Device Disconnects

2014-03-19 Thread Alan Stern
On Wed, 19 Mar 2014, Mike Mitchell wrote:

> Please help me narrow down this perplexing mystery:
> 1. USB Mic device takes ~45 minutes to recognize after warm start.
> 2. Same device disconnect sporadically, usually about an hour after it
> was last used.
> 3. Otherwise device works fine for days on end.
> 
> Host: Intel NUC dccp847dye
> Device: CAD U7 Mic
> Kernel:3.5.0-47-generic #71~precise1-Ubuntu SMP Wed Feb 19 22:05:41
> UTC 2014 i686 i686 i386 GNU/Linux
> 
> USBMon trap of first activity when device is connected:

This trace doesn't show a 45-minute delay.  It also doesn't show a 
disconnect.  Everything appears to be working normally.

The 3.5 kernel is getting old.  Can you try something more recent, such
as 3.13?

Alan Stern

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


Re: [PATCH 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM

2014-03-19 Thread David Miller
From: Ben Chan 
Date: Mon, 17 Mar 2014 21:00:06 -0700

> On Mon, Mar 17, 2014 at 6:41 PM, David Miller  wrote:
>> From: Ben Chan 
>> Date: Mon, 17 Mar 2014 17:46:27 -0700
>>
>>> Thanks again for the review and tip. I've submitted patch v2 to
>>> address the le16_to_cpu conversion.
>>
>> When you update a patch from a series, you should repost the entire
>> patch set, rather than just the patch which changes.
>>
>> This avoids any and all ambiguity of which patches go with which
>> others.
> 
> Thanks for pointing that out. I've submitted the whole patch set as v3
> (bumped the revision to avoid confusion).

I hate to ask for a repost, but:

1) Please put Greg KH's ACK into patch #1, patchwork doesn't carry ACKs
   from one submission to the next, as it shouldn't.

2) Please give a leading "[PATCH 0/2] ..." posting explaining at a high
   level what this series is doing.

Also, make it explicit what tree you want me to apply this too, and if
the changes are relevant for -stable.

--
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 1/2] USB: cdc: add MBIM extended functional descriptor structure

2014-03-19 Thread David Miller
From: Bjørn Mork 
Date: Tue, 18 Mar 2014 09:35:57 +0100

> Or will patchwork keep track of tags across different patch
> versions?

It doesn't, and should not.  It has no idea if the patch changed or
not, the ACK'er might not still agree with the patch if any changes
were made.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/5] Delete unnecessary spaces

2014-03-19 Thread Greg KH
On Wed, Mar 19, 2014 at 07:45:52PM +0100, Jelena Bjelja wrote:
> Fix the following checkpatch.pl issues in wl_netdev.c:

Your subject is missing some prefixes :(

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


Deadlock in usb-storage error handling

2014-03-19 Thread Alan Stern
On Wed, 19 Mar 2014, Andreas Reis wrote:

> I've uploaded a dmesg with the new debugging patch to bugzilla:
> https://bugzilla.kernel.org/attachment.cgi?id=130041

Thanks.  I have now managed to reproduce many of the features of this
problem on my own computer.

James, I will need your help (or help from somebody who understands the 
SCSI error handler) to figure out how this problem should be fixed.

Basically, usb-storage deadlocks when the SCSI error handler invokes
the eh_device_reset_handler callback while a command is running.  The
command has timed out and will never complete normally, because the
device's firmware has crashed.  But usb-storage's device-reset routine
waits for the current command to finish, which brings everything to a
standstill.

Is this design wrong?  That is, should the device-reset routine wait 
for currently executing commands to finish, or should it abort them, or 
what?

Or should the SCSI error handler abort the running command before 
invoking the eh_device_reset_handler callback?

For the record, and in case anyone is curious, here's the detailed
sequence of events during my test:

sd issues a READ(10) command.  For whatever reason, the device
goes nuts and the command times out.

scsi_times_out() calls scsi_abort_command(), which queues an
abort request.

scmd_eh_abort_handler() calls scsi_try_to_abort_cmd(), which
succeeds in aborting the READ.

The READ command is retried (I didn't trace through the details
of this).  The retry fails with a Unit Attention (SK=6, 
ASC=0x29, Reset or Bus Device Reset Occurred).

The READ command is retried a second time, and it times out 
again.

This time around, scsi_times_out() calls scsi_abort_command()
unsuccessfully (because the SCSI_EH_ABORT_SCHEDULED flag is
still set).

As a result, scsi_error_handler() calls scsi_unjam_host(), 
which calls scsi_eh_get_sense().

That routine calls scsi_request_sense(), which goes into
scsi_send_eh_cmnd().

The calls to shost->hostt->queuecommand() all fail, because the
READ command is still running and usb-storage has a queue
depth of 1.  The error messages produced by these failures are
disconcerting but not dangerous.

Since the REQUEST SENSE command was never issued, 
scsi_eh_get_sense() returns 0.

scsi_unjam_host() goes on to call scsi_eh_abort_cmds(), which
does essentially nothing because the SCSI_EH_CANCEL_CMD flag
for the only command on work_q is clear.  
scsi_eh_test_devices() returns 0 because check_list is empty
and work_q isn't.

scsi_unjam_host() then calls scsi_eh_ready_devs().  This
routine ends up calling scsi_eh_bus_device_reset(), at which 
point usb-storage deadlocks as described above.

(On Andreas's system, the first READ retry times out as opposed to the
second retry as on my computer.  I doubt this makes any difference.)

I can't tell if this is all working as intended or if it went off the 
tracks somewhere.

Thanks for any guidance.

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 net-next v4 0/2] adjust MTU as indicated by MBIM extended functional descriptor

2014-03-19 Thread Ben Chan
The MBIM extended functional descriptor, defined in "Universal Serial Bus
Communications Class Subclass Specification for Mobile Broadband Interface
Model, Revision 1.0, Errata-1" by USB-IF, indicates the operator preferred MTU
value via a wMTU field.

This patch set ensures that the initial MTU value set by cdc_ncm on a MBIM net
device does not exceed the wMTU value, provided the MBIM device exposes a MBIM
extended functional descriptor.

* Changelog
v2: Fixed a le16_to_cpu conversion issue in patch 2/2 pointed out by
Bjørn Mork 
v3: No code changes. Resubmitted to include patch 1/2 as suggested by
David Miller 
v4: No code changes. Resubmitted as suggested by David Miller:
- Added a summary of the patch set
- Carried the ACK from Greg Kroah-Hartman 
- Added a specified the tree (net-next) to apply the patch set to

Ben Chan (2):
  USB: cdc: add MBIM extended functional descriptor structure
  net: cdc_ncm: respect operator preferred MTU reported by MBIM

 drivers/net/usb/cdc_ncm.c| 17 +
 include/linux/usb/cdc_ncm.h  |  1 +
 include/uapi/linux/usb/cdc.h | 12 
 3 files changed, 30 insertions(+)

-- 
1.9.0.279.gdc9e3eb

--
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: Deadlock in usb-storage error handling

2014-03-19 Thread Dan Williams
On Wed, Mar 19, 2014 at 1:31 PM, Alan Stern  wrote:
> On Wed, 19 Mar 2014, Andreas Reis wrote:
>
>> I've uploaded a dmesg with the new debugging patch to bugzilla:
>> https://bugzilla.kernel.org/attachment.cgi?id=130041
>
> Thanks.  I have now managed to reproduce many of the features of this
> problem on my own computer.
>
> James, I will need your help (or help from somebody who understands the
> SCSI error handler) to figure out how this problem should be fixed.
>
> Basically, usb-storage deadlocks when the SCSI error handler invokes
> the eh_device_reset_handler callback while a command is running.  The
> command has timed out and will never complete normally, because the
> device's firmware has crashed.  But usb-storage's device-reset routine
> waits for the current command to finish, which brings everything to a
> standstill.
>
> Is this design wrong?  That is, should the device-reset routine wait
> for currently executing commands to finish, or should it abort them, or
> what?
>
> Or should the SCSI error handler abort the running command before
> invoking the eh_device_reset_handler callback?
>
> For the record, and in case anyone is curious, here's the detailed
> sequence of events during my test:
>
> sd issues a READ(10) command.  For whatever reason, the device
> goes nuts and the command times out.
>
> scsi_times_out() calls scsi_abort_command(), which queues an
> abort request.
>
> scmd_eh_abort_handler() calls scsi_try_to_abort_cmd(), which
> succeeds in aborting the READ.
>
> The READ command is retried (I didn't trace through the details
> of this).  The retry fails with a Unit Attention (SK=6,
> ASC=0x29, Reset or Bus Device Reset Occurred).
>
> The READ command is retried a second time, and it times out
> again.
>
> This time around, scsi_times_out() calls scsi_abort_command()
> unsuccessfully (because the SCSI_EH_ABORT_SCHEDULED flag is
> still set).
>
> As a result, scsi_error_handler() calls scsi_unjam_host(),
> which calls scsi_eh_get_sense().
>
> That routine calls scsi_request_sense(), which goes into
> scsi_send_eh_cmnd().
>
> The calls to shost->hostt->queuecommand() all fail, because the
> READ command is still running and usb-storage has a queue
> depth of 1.  The error messages produced by these failures are
> disconcerting but not dangerous.
>
> Since the REQUEST SENSE command was never issued,
> scsi_eh_get_sense() returns 0.
>
> scsi_unjam_host() goes on to call scsi_eh_abort_cmds(), which
> does essentially nothing because the SCSI_EH_CANCEL_CMD flag
> for the only command on work_q is clear.
> scsi_eh_test_devices() returns 0 because check_list is empty
> and work_q isn't.
>
> scsi_unjam_host() then calls scsi_eh_ready_devs().  This
> routine ends up calling scsi_eh_bus_device_reset(), at which
> point usb-storage deadlocks as described above.
>
> (On Andreas's system, the first READ retry times out as opposed to the
> second retry as on my computer.  I doubt this makes any difference.)
>
> I can't tell if this is all working as intended or if it went off the
> tracks somewhere.
>
> Thanks for any guidance.
>

It seems to me we need an ->eh_strategy_handler() that understands the
usb transport and will escalate to device reset around the time
scsi_abort_command() fails.
--
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 net-next v4 2/2] net: cdc_ncm: respect operator preferred MTU reported by MBIM

2014-03-19 Thread Ben Chan
According to "Universal Serial Bus Communications Class Subclass
Specification for Mobile Broadband Interface Model, Revision 1.0,
Errata-1" published by USB-IF, the wMTU field of the MBIM extended
functional descriptor indicates the operator preferred MTU for IP data
streams.

This patch modifies cdc_ncm_setup to ensure that the MTU value set on
the usbnet device does not exceed the operator preferred MTU indicated
by wMTU if the MBIM device exposes a MBIM extended functional
descriptor.

Signed-off-by: Ben Chan 
---
 drivers/net/usb/cdc_ncm.c   | 17 +
 include/linux/usb/cdc_ncm.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index dbff290..e8711a8 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -74,6 +74,7 @@ static int cdc_ncm_setup(struct usbnet *dev)
u8 iface_no;
int err;
int eth_hlen;
+   u16 mbim_mtu;
u16 ntb_fmt_supported;
__le16 max_datagram_size;
 
@@ -261,6 +262,14 @@ out:
/* set MTU to max supported by the device if necessary */
if (dev->net->mtu > ctx->max_datagram_size - eth_hlen)
dev->net->mtu = ctx->max_datagram_size - eth_hlen;
+
+   /* do not exceed operater preferred MTU */
+   if (ctx->mbim_extended_desc) {
+   mbim_mtu = le16_to_cpu(ctx->mbim_extended_desc->wMTU);
+   if (mbim_mtu != 0 && mbim_mtu < dev->net->mtu)
+   dev->net->mtu = mbim_mtu;
+   }
+
return 0;
 }
 
@@ -399,6 +408,14 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct 
usb_interface *intf, u8 data_
ctx->mbim_desc = (const struct usb_cdc_mbim_desc *)buf;
break;
 
+   case USB_CDC_MBIM_EXTENDED_TYPE:
+   if (buf[0] < sizeof(*(ctx->mbim_extended_desc)))
+   break;
+
+   ctx->mbim_extended_desc =
+   (const struct usb_cdc_mbim_extended_desc *)buf;
+   break;
+
default:
break;
}
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index c3fa807..bdf05fb 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -93,6 +93,7 @@ struct cdc_ncm_ctx {
 
const struct usb_cdc_ncm_desc *func_desc;
const struct usb_cdc_mbim_desc *mbim_desc;
+   const struct usb_cdc_mbim_extended_desc *mbim_extended_desc;
const struct usb_cdc_ether_desc *ether_desc;
 
struct usb_interface *control;
-- 
1.9.0.279.gdc9e3eb

--
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 net-next v4 1/2] USB: cdc: add MBIM extended functional descriptor structure

2014-03-19 Thread Ben Chan
This patch adds the MBIM extended functional descriptor structure
defined in "Universal Serial Bus Communications Class Subclass
Specification for Mobile Broadband Interface Model, Revision 1.0,
Errata-1" published by USB-IF.

Signed-off-by: Ben Chan 
Acked-by: Greg Kroah-Hartman 
---
 include/uapi/linux/usb/cdc.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h
index f35aa0a..b6a9cdd 100644
--- a/include/uapi/linux/usb/cdc.h
+++ b/include/uapi/linux/usb/cdc.h
@@ -56,6 +56,7 @@
 #define USB_CDC_OBEX_TYPE  0x15
 #define USB_CDC_NCM_TYPE   0x1a
 #define USB_CDC_MBIM_TYPE  0x1b
+#define USB_CDC_MBIM_EXTENDED_TYPE 0x1c
 
 /* "Header Functional Descriptor" from CDC spec  5.2.3.1 */
 struct usb_cdc_header_desc {
@@ -205,6 +206,17 @@ struct usb_cdc_mbim_desc {
__u8bmNetworkCapabilities;
 } __attribute__ ((packed));
 
+/* "MBIM Extended Functional Descriptor" from CDC MBIM spec 1.0 errata-1 */
+struct usb_cdc_mbim_extended_desc {
+   __u8bLength;
+   __u8bDescriptorType;
+   __u8bDescriptorSubType;
+
+   __le16  bcdMBIMExtendedVersion;
+   __u8bMaxOutstandingCommandMessages;
+   __le16  wMTU;
+} __attribute__ ((packed));
+
 /*-*/
 
 /*
-- 
1.9.0.279.gdc9e3eb

--
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: Deadlock in usb-storage error handling

2014-03-19 Thread James Bottomley
On Wed, 2014-03-19 at 16:31 -0400, Alan Stern wrote:
> On Wed, 19 Mar 2014, Andreas Reis wrote:
> 
> > I've uploaded a dmesg with the new debugging patch to bugzilla:
> > https://bugzilla.kernel.org/attachment.cgi?id=130041
> 
> Thanks.  I have now managed to reproduce many of the features of this
> problem on my own computer.
> 
> James, I will need your help (or help from somebody who understands the 
> SCSI error handler) to figure out how this problem should be fixed.
> 
> Basically, usb-storage deadlocks when the SCSI error handler invokes
> the eh_device_reset_handler callback while a command is running.  The
> command has timed out and will never complete normally, because the
> device's firmware has crashed.  But usb-storage's device-reset routine
> waits for the current command to finish, which brings everything to a
> standstill.
> 
> Is this design wrong?  That is, should the device-reset routine wait 
> for currently executing commands to finish, or should it abort them, or 
> what?

In some sense, yes, but not necessarily from the Point of View of USB.
What we assume in SCSI is that commands are forgettable, meaning there's
always some operation we can perform (be it abort or reset) that causes
the device to forget about all outstanding commands and reset its
internal state machine to a known good state.

The cardinal SCSI assumption is that after we've successfully done an
abort or reset on a command that it will never come back to us from the
device.

> Or should the SCSI error handler abort the running command before 
> invoking the eh_device_reset_handler callback?

So this is rooted in the "Abort can be a Problem" issue:  Abort
sometimes works well (and it's not very disruptive) but sometimes if the
device is having a problem in its command state machine, adding another
command (which is what the abort is) doesn't actually do anything, so we
need error escalation to reset.  We can't wait for the abort or other
commands to complete because they never will.  The reset is expected to
clear everything from the device (including the pending aborts).

> For the record, and in case anyone is curious, here's the detailed
> sequence of events during my test:
> 
>   sd issues a READ(10) command.  For whatever reason, the device
>   goes nuts and the command times out.
> 
>   scsi_times_out() calls scsi_abort_command(), which queues an
>   abort request.
> 
>   scmd_eh_abort_handler() calls scsi_try_to_abort_cmd(), which
>   succeeds in aborting the READ.
> 
>   The READ command is retried (I didn't trace through the details
>   of this).  The retry fails with a Unit Attention (SK=6, 
>   ASC=0x29, Reset or Bus Device Reset Occurred).
> 
>   The READ command is retried a second time, and it times out 
>   again.
> 
>   This time around, scsi_times_out() calls scsi_abort_command()
>   unsuccessfully (because the SCSI_EH_ABORT_SCHEDULED flag is
>   still set).

>From the first time we sent the abort?  That sounds like a problem in
our state tracking.

>   As a result, scsi_error_handler() calls scsi_unjam_host(), 
>   which calls scsi_eh_get_sense().
> 
>   That routine calls scsi_request_sense(), which goes into
>   scsi_send_eh_cmnd().

I thought USB was autosense, so when it reports check condition, we
should already have sense ... or are we calling request_sense without
being sent a check condition status?

>   The calls to shost->hostt->queuecommand() all fail, because the
>   READ command is still running and usb-storage has a queue
>   depth of 1.  The error messages produced by these failures are
>   disconcerting but not dangerous.
> 
>   Since the REQUEST SENSE command was never issued, 
>   scsi_eh_get_sense() returns 0.
> 
>   scsi_unjam_host() goes on to call scsi_eh_abort_cmds(), which
>   does essentially nothing because the SCSI_EH_CANCEL_CMD flag
>   for the only command on work_q is clear.  
>   scsi_eh_test_devices() returns 0 because check_list is empty
>   and work_q isn't.
> 
>   scsi_unjam_host() then calls scsi_eh_ready_devs().  This
>   routine ends up calling scsi_eh_bus_device_reset(), at which 
>   point usb-storage deadlocks as described above.

OK, so in the case where the command can never complete (because the fw
has crashed), what should be the process for resetting the device so it
can again function?

James

> (On Andreas's system, the first READ retry times out as opposed to the
> second retry as on my computer.  I doubt this makes any difference.)
> 
> I can't tell if this is all working as intended or if it went off the 
> tracks somewhere.
> 
> Thanks for any guidance.
> 
> Alan Stern
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 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 "

[PATCH v7 16/16] usb: documentation for usb port power off mechanisms

2014-03-19 Thread Dan Williams
From: Lan Tianyu 

describe the mechanisms for controlling port power policy and
discovering the port power state.

Cc: Oliver Neukum 
[oliver]: fixes, clarification of wakeup vs port-power-control
Signed-off-by: Lan Tianyu 
[sarah]: wordsmithing
[djbw]: updates for peer port changes
Signed-off-by: Dan Williams 
---
 Documentation/usb/power-management.txt |  242 
 1 files changed, 240 insertions(+), 2 deletions(-)

diff --git a/Documentation/usb/power-management.txt 
b/Documentation/usb/power-management.txt
index 1392b61d6ebe..6c3e0f04f6cb 100644
--- a/Documentation/usb/power-management.txt
+++ b/Documentation/usb/power-management.txt
@@ -2,8 +2,27 @@
 
 Alan Stern 
 
-   October 28, 2010
-
+  Last-updated: February 2014
+
+
+   Contents:
+   -
+   * What is Power Management?
+   * What is Remote Wakeup?
+   * When is a USB device idle?
+   * Forms of dynamic PM
+   * The user interface for dynamic PM
+   * Changing the default idle-delay time
+   * Warnings
+   * The driver interface for Power Management
+   * The driver interface for autosuspend and autoresume
+   * Other parts of the driver interface
+   * Mutual exclusion
+   * Interaction between dynamic PM and system PM
+   * xHCI hardware link PM
+   * USB Port Power Control
+   * User Interface for Port Power Control
+   * Suggested Userspace Port Power Policy
 
 
What is Power Management?
@@ -516,3 +535,222 @@ relevant attribute files is usb2_hardware_lpm.
driver will enable hardware LPM for the device. You
can write y/Y/1 or n/N/0 to the file to enable/disable
USB2 hardware LPM manually. This is for test purpose mainly.
+
+
+   USB Port Power Control
+   --
+
+In addition to suspending endpoint devices and enabling hardware
+controlled link power management, the USB subsystem also has the
+capability to disable power to ports under some conditions.  Power is
+controlled through Set/ClearPortFeature(PORT_POWER) requests to a hub.
+In the case of a root or platform-internal hub the host controller
+driver translates PORT_POWER requests into platform firmware (ACPI)
+method calls to set the port power state. For more background see the
+Linux Plumbers Conference 2012 slides [1] and video [2]:
+
+Upon receiving a ClearPortFeature(PORT_POWER) request a USB port is
+logically off, and may trigger the actual loss of VBUS to the port [3].
+VBUS may be maintained in the case where a hub gangs multiple ports into
+a shared power well causing power to remain until all ports in the gang
+are turned off.  VBUS may also be maintained by hub ports configured for
+a charging application.  In any event a logically off port will lose
+connection with its device, not respond to hotplug events, and not
+respond to remote wakeup events*.
+
+WARNING: turning off a port may result in the inability to hot add a device.
+Please see "User Interface for Port Power Control" for details.
+
+As far as the effect on the device itself it is similar to what a device
+goes through during system suspend, i.e. the power session is lost.  Any
+USB device or driver that misbehaves with system suspend will be
+similarly affected by a port power cycle event.  For this reason the
+implementation shares the same device recovery path (and honors the same
+quirks) as the system resume path for the hub.
+
+[1]: http://dl.dropbox.com/u/96820575/sarah-sharp-lpt-port-power-off2-mini.pdf
+[2]: 
http://linuxplumbers.ubicast.tv/videos/usb-port-power-off-kerneluserspace-api/
+[3]: USB 3.1 Section 10.12
+* wakeup note: if a device is configured to send wakeup events the port
+  power control implementation will block poweroff attempts on that
+  port.
+
+
+   User Interface for Port Power Control
+   -
+
+The port power control mechanism uses the PM runtime system.  Poweroff is
+requested by clearing the power/pm_qos_no_power_off flag of the port device
+(defaults to 1).  If the port is disconnected it will immediately receive a
+ClearPortFeature(PORT_POWER) request.  Otherwise, it will honor the pm runtime
+rules and require the attached child device and all descendants to be 
suspended.
+This mechanism is dependent on the hub advertising port power switching in its
+hub descriptor (wHubCharacteristics logical power switching mode field).
+
+Note, some interface devices/drivers do not support autosuspend.  Userspace may
+need to unbind the interface drivers before the usb_device will suspend.  An
+unbound interface device is suspended by default.  When unbinding, be careful
+to unbind interface drivers, not the driver of the parent usb device.  Also,
+leave hub interface drivers bound.  If the driver for the usb device (not
+interface) is unbound the kernel is no longer able to resume the device.  If a

[PATCH v7 03/16] usb: cleanup setting udev->removable from port_dev->connect_type

2014-03-19 Thread Dan Williams
Once usb-acpi has set the port's connect type the usb_device's
->removable attribute can be set in the standard location
set_usb_port_removable().

This also changes behavior in the case where the firmware says that the
port connect type is unknown.  In that case just use the default setting
determined from the hub descriptor.

Note, we no longer pass udev->portnum to acpi_find_child_device() in the
root hub case since:
1/ the usb-core sets this to zero
2/ acpi always expects zero
...just pass zero.

Suggested-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   22 +-
 drivers/usb/core/usb-acpi.c |   34 ++
 2 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a946cf5c4222..10c9b52ca0b9 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2291,6 +2291,22 @@ static void set_usb_port_removable(struct usb_device 
*udev)
udev->removable = USB_DEVICE_REMOVABLE;
else
udev->removable = USB_DEVICE_FIXED;
+
+   /*
+* Platform firmware may have populated an alternative value for
+* removable.  If the parent port has a known connect_type use
+* that instead.
+*/
+   switch (hub->ports[udev->portnum - 1]->connect_type) {
+   case USB_PORT_CONNECT_TYPE_HOT_PLUG:
+   udev->removable = USB_DEVICE_REMOVABLE;
+   break;
+   case USB_PORT_CONNECT_TYPE_HARD_WIRED:
+   udev->removable = USB_DEVICE_FIXED;
+   break;
+   default: /* use what was set above */
+   break;
+   }
 }
 
 /**
@@ -2360,11 +2376,7 @@ int usb_new_device(struct usb_device *udev)
 
device_enable_async_suspend(&udev->dev);
 
-   /*
-* check whether the hub marks this port as non-removable. Do it
-* now so that platform-specific data can override it in
-* device_add()
-*/
+   /* check whether the hub or firmware marks this port as non-removable */
if (udev->parent)
set_usb_port_removable(udev);
 
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index f91ef0220066..ce0f4e8d81cb 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -136,8 +136,8 @@ out:
 
 static struct acpi_device *usb_acpi_find_companion(struct device *dev)
 {
-   int port1;
struct usb_device *udev;
+   struct acpi_device *adev;
acpi_handle *parent_handle;
 
/*
@@ -155,40 +155,18 @@ static struct acpi_device *usb_acpi_find_companion(struct 
device *dev)
 */
if (is_usb_device(dev)) {
udev = to_usb_device(dev);
-   port1 = udev->portnum;
-   if (udev->parent) {
-   struct usb_hub *hub;
-
-   hub = usb_hub_to_struct_hub(udev->parent);
-   /*
-* According usb port's connect type to set usb device's
-* removability.
-*/
-   switch (hub->ports[port1 - 1]->connect_type) {
-   case USB_PORT_CONNECT_TYPE_HOT_PLUG:
-   udev->removable = USB_DEVICE_REMOVABLE;
-   break;
-   case USB_PORT_CONNECT_TYPE_HARD_WIRED:
-   udev->removable = USB_DEVICE_FIXED;
-   break;
-   default:
-   udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN;
-   break;
-   }
-
+   if (udev->parent)
return NULL;
-   }
 
-   /* root hub's parent is the usb hcd. */
-   return acpi_find_child_device(ACPI_COMPANION(dev->parent),
-   port1, false);
+   /* root hub is only child (_ADR=0) under it's parent, the hcd */
+   adev = ACPI_COMPANION(dev->parent);
+   return acpi_find_child_device(adev, 0, false);
} else if (is_usb_port(dev)) {
struct usb_port *port_dev = to_usb_port(dev);
-   struct acpi_device *adev = NULL;
+   int port1 = port_dev->portnum;
 
/* Get the struct usb_device point of port's hub */
udev = to_usb_device(dev->parent->parent);
-   port1 = port_dev->portnum;
 
/*
 * The root hub ports' parent is the root hub. The non-root-hub

--
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 v7 10/16] usb: usb3 ports do not support FEAT_C_ENABLE

2014-03-19 Thread Dan Williams
The port pm_runtime implementation unconditionally clears FEAT_C_ENABLE
after clearing PORT_POWER, but the bit is reserved on usb3 hub ports.
We expect khubd to be prevented from running because the port state is
not RPM_ACTIVE, so we need to clear any errors for usb2 ports.

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 191d7c3c9791..4917473de203 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -136,7 +136,8 @@ static int usb_port_runtime_suspend(struct device *dev)
set_bit(port1, hub->busy_bits);
retval = usb_hub_set_port_power(hdev, hub, port1, false);
usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION);
-   usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE);
+   if (!port_dev->is_superspeed)
+   usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE);
clear_bit(port1, hub->busy_bits);
usb_autopm_put_interface(intf);
 

--
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 v7 07/16] usb: sysfs link peer ports

2014-03-19 Thread Dan Williams
The usb topology after this change will have symlinks between usb3 ports
and their usb2 peers, for example:

usb2/2-1/2-1:1.0/2-1-port1/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port1
usb2/2-1/2-1:1.0/2-1-port2/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port2
usb2/2-1/2-1:1.0/2-1-port3/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port3
usb2/2-1/2-1:1.0/2-1-port4/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port4
usb2/2-0:1.0/usb2-port1/peer=> ../../../usb3/3-0:1.0/usb3-port1
usb2/2-0:1.0/usb2-port2/peer=> ../../../usb3/3-0:1.0/usb3-port2
usb2/2-0:1.0/usb2-port3/peer=> ../../../usb3/3-0:1.0/usb3-port3
usb2/2-0:1.0/usb2-port4/peer=> ../../../usb3/3-0:1.0/usb3-port4

usb3/3-1/3-1:1.0/usb3-1-port1/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port1
usb3/3-1/3-1:1.0/usb3-1-port2/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port2
usb3/3-1/3-1:1.0/usb3-1-port3/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port3
usb3/3-1/3-1:1.0/usb3-1-port4/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port4
usb3/3-0:1.0/usb3-port1/peer   => ../../../usb2/2-0:1.0/usb2-port1
usb3/3-0:1.0/usb3-port2/peer   => ../../../usb2/2-0:1.0/usb2-port2
usb3/3-0:1.0/usb3-port3/peer   => ../../../usb2/2-0:1.0/usb2-port3
usb3/3-0:1.0/usb3-port4/peer   => ../../../usb2/2-0:1.0/usb2-port4

Introduce link_peers_report() to notify on all link_peers() failure
cases.

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |   39 ++-
 1 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index d29e9dc8ea9f..b7f5225cee2b 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -151,10 +151,12 @@ static struct device_driver usb_port_driver = {
.owner = THIS_MODULE,
 };
 
-static void link_peers(struct usb_port *left, struct usb_port *right)
+static int link_peers(struct usb_port *left, struct usb_port *right)
 {
+   int rc;
+
if (left->peer == right && right->peer == left)
-   return;
+   return 0;
 
if (left->peer || right->peer) {
struct usb_port *lpeer = left->peer;
@@ -164,11 +166,36 @@ static void link_peers(struct usb_port *left, struct 
usb_port *right)
dev_name(&left->dev), dev_name(&right->dev),
dev_name(&left->dev), lpeer,
dev_name(&right->dev), rpeer);
-   return;
+   return -EBUSY;
+   }
+
+   rc = sysfs_create_link(&left->dev.kobj, &right->dev.kobj, "peer");
+   if (rc)
+   return rc;
+   rc = sysfs_create_link(&right->dev.kobj, &left->dev.kobj, "peer");
+   if (rc) {
+   sysfs_remove_link(&left->dev.kobj, "peer");
+   return rc;
}
 
left->peer = right;
right->peer = left;
+
+   return 0;
+}
+
+static void link_peers_report(struct usb_port *left, struct usb_port *right)
+{
+   int rc;
+
+   rc = link_peers(left, right);
+   if (rc == 0) {
+   dev_dbg(&left->dev, "peered to %s\n", dev_name(&right->dev));
+   } else {
+   dev_warn(&left->dev, "failed to peer to %s (%d)\n",
+   dev_name(&right->dev), rc);
+   pr_warn_once("usb: port power management may be unreliable\n");
+   }
 }
 
 static void unlink_peers(struct usb_port *left, struct usb_port *right)
@@ -177,7 +204,9 @@ static void unlink_peers(struct usb_port *left, struct 
usb_port *right)
"%s and %s are not peers?\n",
dev_name(&left->dev), dev_name(&right->dev));
 
+   sysfs_remove_link(&left->dev.kobj, "peer");
right->peer = NULL;
+   sysfs_remove_link(&right->dev.kobj, "peer");
left->peer = NULL;
 }
 
@@ -206,7 +235,7 @@ static int match_location(struct usb_device *peer_hdev, 
void *p)
for (port1 = 1; port1 <= peer_hdev->maxchild; port1++) {
peer = peer_hub->ports[port1 - 1];
if (peer && peer->location == port_dev->location) {
-   link_peers(port_dev, peer);
+   link_peers_report(port_dev, peer);
return 1; /* done */
}
}
@@ -269,7 +298,7 @@ static void find_and_link_peer(struct usb_hub *hub, int 
port1)
 */
peer = peer_hub->ports[port1 - 1];
if (peer && peer->location == 0)
-   link_peers(port_dev, peer);
+   link_peers_report(port_dev, peer);
 }
 
 int usb_hub_create_port_device(struct usb_hub *hub, int port1)

--
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 v7 13/16] usb: introduce port status lock

2014-03-19 Thread Dan Williams
In general we do not want khubd to act on port status changes that are
the result of in progress resets or USB runtime PM operations.
Specifically port power control testing has been able to trigger an
unintended disconnect in hub_port_connect_change(), paraphrasing:

if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
udev->state != USB_STATE_NOTATTACHED) {
if (portstatus & USB_PORT_STAT_ENABLE) {
/* Nothing to do */
} else if (udev->state == USB_STATE_SUSPENDED &&
udev->persist_enabled) {
...
} else {
/* Don't resuscitate */;
}
}

...by falling to the "Don't resuscitate" path or missing
USB_PORT_STAT_CONNECTION because usb_port_resume() was in the middle of
modifying the port status.

So, we want a new lock to hold off khubd for a given port while the
child device is being suspended, resumed, or reset.  The lock ordering
rules are now usb_lock_device() => usb_lock_port().  This is mandated by
the device core which may hold the device_lock on the usb_device before
invoking usb_port_{suspend|resume} which in turn take the status_lock on
the usb_port.  We attempt to hold the status_lock for the duration of a
port_event() run, and drop/re-acquire it when needing to take the
device_lock.  The lock is also dropped/re-acquired during
hub_port_reconnect().

This patch also deletes hub->busy_bits as all use cases are now covered
by port PM runtime synchronization or the port->status_lock and it
pushes down usb_device_lock() into usb_remote_wakeup().

Signed-off-by: Dan Williams 
---
 drivers/usb/core/hcd.c  |2 -
 drivers/usb/core/hub.c  |   97 +--
 drivers/usb/core/hub.h  |4 +-
 drivers/usb/core/port.c |6 ---
 drivers/usb/core/usb.h  |6 +++
 5 files changed, 78 insertions(+), 37 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 6d12d7720632..eed16015f868 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2263,9 +2263,7 @@ static void hcd_resume_work(struct work_struct *work)
struct usb_hcd *hcd = container_of(work, struct usb_hcd, wakeup_work);
struct usb_device *udev = hcd->self.root_hub;
 
-   usb_lock_device(udev);
usb_remote_wakeup(udev);
-   usb_unlock_device(udev);
 }
 
 /**
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 10f420626204..194ff3303ee9 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2764,6 +2764,20 @@ static int port_is_power_on(struct usb_hub *hub, 
unsigned portstatus)
return ret;
 }
 
+static void usb_lock_port(struct usb_port *port_dev)
+   __acquires(&port_dev->status_lock)
+{
+   mutex_lock(&port_dev->status_lock);
+   __acquire(&port_dev->status_lock);
+}
+
+static void usb_unlock_port(struct usb_port *port_dev)
+   __releases(&port_dev->status_lock)
+{
+   mutex_unlock(&port_dev->status_lock);
+   __release(&port_dev->status_lock);
+}
+
 #ifdef CONFIG_PM
 
 /* Check if a port is suspended(USB2.0 port) or in U3 state(USB3.0 port) */
@@ -2986,6 +3000,8 @@ int usb_port_suspend(struct usb_device *udev, 
pm_message_t msg)
int status;
boolreally_suspend = true;
 
+   usb_lock_port(port_dev);
+
/* enable remote wakeup when appropriate; this lets the device
 * wake up the upstream hub (including maybe the root hub).
 *
@@ -3080,6 +3096,8 @@ int usb_port_suspend(struct usb_device *udev, 
pm_message_t msg)
}
 
usb_mark_last_busy(hub->hdev);
+
+   usb_unlock_port(port_dev);
return status;
 }
 
@@ -3219,13 +3237,13 @@ int usb_port_resume(struct usb_device *udev, 
pm_message_t msg)
}
}
 
+   usb_lock_port(port_dev);
+
/* Skip the initial Clear-Suspend step for a remote wakeup */
status = hub_port_status(hub, port1, &portstatus, &portchange);
if (status == 0 && !port_is_suspended(hub, portstatus))
goto SuspendCleared;
 
-   set_bit(port1, hub->busy_bits);
-
/* see 7.1.7.7; affects power usage, but not budgeting */
if (hub_is_superspeed(hub->hdev))
status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0);
@@ -3264,8 +3282,6 @@ int usb_port_resume(struct usb_device *udev, pm_message_t 
msg)
}
}
 
-   clear_bit(port1, hub->busy_bits);
-
status = check_port_resume_type(udev,
hub, port1, status, portchange, portstatus);
if (status == 0)
@@ -3283,16 +3299,18 @@ int usb_port_resume(struct usb_device *udev, 
pm_message_t msg)
usb_unlocked_enable_lpm(udev);
}
 
+   usb_unlock_port(port_dev);
+
return status;
 }
 
 #ifdef CONFIG_PM_RUNTIME
 
-/* caller has locked udev */
 int usb_remot

[PATCH v7 01/16] usb: disable port power control if not supported in wHubCharacteristics

2014-03-19 Thread Dan Williams
A hub indicates whether it supports per-port power control via the
wHubCharacteristics field in its descriptor.  If it is not supported
a hub will still emulate ClearPortPower(PORT_POWER) requests by
stopping the link state machine.  However, since this does not save
power do not bother suspending.

This also consolidates support checks into a
hub_is_port_power_switchable() helper.

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |8 ++--
 drivers/usb/core/hub.h  |   10 ++
 drivers/usb/core/port.c |   13 -
 3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 2d74dfb9c989..998f028fdea3 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -818,8 +818,6 @@ static unsigned hub_power_on(struct usb_hub *hub, bool 
do_delay)
int port1;
unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
unsigned delay;
-   u16 wHubCharacteristics =
-   le16_to_cpu(hub->descriptor->wHubCharacteristics);
 
/* Enable power on each port.  Some hubs have reserved values
 * of LPSM (> 2) in their descriptors, even though they are
@@ -827,7 +825,7 @@ static unsigned hub_power_on(struct usb_hub *hub, bool 
do_delay)
 * but only emulate it.  In all cases, the ports won't work
 * unless we send these messages to the hub.
 */
-   if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2)
+   if (hub_is_port_power_switchable(hub))
dev_dbg(hub->intfdev, "enabling power on all ports\n");
else
dev_dbg(hub->intfdev, "trying to enable port power on "
@@ -4395,8 +4393,6 @@ static void hub_port_connect_change(struct usb_hub *hub, 
int port1,
struct usb_device *hdev = hub->hdev;
struct device *hub_dev = hub->intfdev;
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
-   unsigned wHubCharacteristics =
-   le16_to_cpu(hub->descriptor->wHubCharacteristics);
struct usb_device *udev;
int status, i;
unsigned unit_load;
@@ -4481,7 +4477,7 @@ static void hub_port_connect_change(struct usb_hub *hub, 
int port1,
test_bit(port1, hub->removed_bits)) {
 
/* maybe switch power back on (e.g. root hub was reset) */
-   if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
+   if (hub_is_port_power_switchable(hub)
&& !port_is_power_on(hub, portstatus))
set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
 
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index df629a310e44..baf5b48b79f7 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -111,6 +111,16 @@ extern int hub_port_debounce(struct usb_hub *hub, int 
port1,
 extern int usb_clear_port_feature(struct usb_device *hdev,
int port1, int feature);
 
+static inline bool hub_is_port_power_switchable(struct usb_hub *hub)
+{
+   __le16 hcs;
+
+   if (!hub)
+   return false;
+   hcs = hub->descriptor->wHubCharacteristics;
+   return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM;
+}
+
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
int port1)
 {
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 51542f852393..3a7dd99706aa 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -171,12 +171,15 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
 
pm_runtime_set_active(&port_dev->dev);
 
-   /* It would be dangerous if user space couldn't
-* prevent usb device from being powered off. So don't
-* enable port runtime pm if failed to expose port's pm qos.
+   /*
+* Do not enable port runtime pm if the hub does not support
+* power switching.  Also, userspace must have final say of
+* whether a port is permitted to power-off.  Do not enable
+* runtime pm if we fail to expose pm_qos_no_power_off.
 */
-   if (!dev_pm_qos_expose_flags(&port_dev->dev,
-   PM_QOS_FLAG_NO_POWER_OFF))
+   if (hub_is_port_power_switchable(hub)
+   && dev_pm_qos_expose_flags(&port_dev->dev,
+   PM_QOS_FLAG_NO_POWER_OFF) == 0)
pm_runtime_enable(&port_dev->dev);
 
device_enable_async_suspend(&port_dev->dev);

--
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 v7 02/16] usb: rename usb_port device objects

2014-03-19 Thread Dan Williams
The current port name "portX" is ambiguous.  Before adding more port
messages rename ports to "-portX"

This is an ABI change, but the suspicion is that it will go unnoticed as
the port power control implementation has been broken since its
introduction.  If however, someone was relying on the old name we can
add sysfs links from the old name to the new name.

Additionally, it unifies/simplifies port dev_printk messages and modifies
instances of:
dev_XXX(hub->intfdev, ..."port %d"...
dev_XXX(&hdev->dev, ..."port%d"...
into:
dev_XXX(&port_dev->dev, ...

Now that the names are unique usb_port devices it would be nice if they
could be included in /sys/bus/usb.  However, it turns out that this
breaks 'lsusb -t'.  For now, create a dummy port driver so that print
messages are prefixed "usb 1-1-port3" rather than the
subsystem-ambiguous " 1-1-port3".

Finally, it corrects an odd usage of sscanf("port%d") in usb-acpi.c.

Suggested-by: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |  273 ++-
 drivers/usb/core/port.c |   10 +-
 drivers/usb/core/usb-acpi.c |   60 +
 drivers/usb/core/usb.h  |4 -
 4 files changed, 158 insertions(+), 189 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 998f028fdea3..a946cf5c4222 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -412,30 +412,35 @@ static int set_port_feature(struct usb_device *hdev, int 
port1, int feature)
NULL, 0, 1000);
 }
 
+static char *to_led_name(int selector)
+{
+   switch (selector) {
+   case HUB_LED_AMBER:
+   return "amber";
+   case HUB_LED_GREEN:
+   return "green";
+   case HUB_LED_OFF:
+   return "off";
+   case HUB_LED_AUTO:
+   return "auto";
+   default:
+   return "??";
+   }
+}
+
 /*
  * USB 2.0 spec Section 11.24.2.7.1.10 and table 11-7
  * for info about using port indicators
  */
-static void set_port_led(
-   struct usb_hub *hub,
-   int port1,
-   int selector
-)
+static void set_port_led(struct usb_hub *hub, int port1, int selector)
 {
-   int status = set_port_feature(hub->hdev, (selector << 8) | port1,
+   struct usb_port *port_dev = hub->ports[port1 - 1];
+   int status;
+
+   status = set_port_feature(hub->hdev, (selector << 8) | port1,
USB_PORT_FEAT_INDICATOR);
-   if (status < 0)
-   dev_dbg (hub->intfdev,
-   "port %d indicator %s status %d\n",
-   port1,
-   ({ char *s; switch (selector) {
-   case HUB_LED_AMBER: s = "amber"; break;
-   case HUB_LED_GREEN: s = "green"; break;
-   case HUB_LED_OFF: s = "off"; break;
-   case HUB_LED_AUTO: s = "auto"; break;
-   default: s = "??"; break;
-   } s; }),
-   status);
+   dev_dbg(&port_dev->dev, "indicator %s status %d\n",
+   to_led_name(selector), status);
 }
 
 #defineLED_CYCLE_PERIOD((2*HZ)/3)
@@ -909,20 +914,20 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int 
port1)
msleep(HUB_DEBOUNCE_STEP);
}
if (total_time >= HUB_DEBOUNCE_TIMEOUT)
-   dev_warn(hub->intfdev, "Could not disable port %d after %d 
ms\n",
-   port1, total_time);
+   dev_warn(&hub->ports[port1 - 1]->dev,
+   "Could not disable after %d ms\n", total_time);
 
return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT);
 }
 
 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
 {
+   struct usb_port *port_dev = hub->ports[port1 - 1];
struct usb_device *hdev = hub->hdev;
int ret = 0;
 
-   if (hub->ports[port1 - 1]->child && set_state)
-   usb_set_device_state(hub->ports[port1 - 1]->child,
-   USB_STATE_NOTATTACHED);
+   if (port_dev->child && set_state)
+   usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
if (!hub->error) {
if (hub_is_superspeed(hub->hdev))
ret = hub_usb3_port_disable(hub, port1);
@@ -931,8 +936,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, 
int set_state)
USB_PORT_FEAT_ENABLE);
}
if (ret && ret != -ENODEV)
-   dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
-   port1, ret);
+   dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
return ret;
 }
 
@@ -943,7 +947,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, 
int set_state)
  */
 static void hub_port_logical_disc

[PATCH v7 05/16] usb: assign usb3 external hub port peers

2014-03-19 Thread Dan Williams
Given that root hub port peers are already established, external hub peer
ports can be determined by traversing the device topology:

1/ ascend to the parent hub and find the upstream port_dev

2/ walk ->peer to find the peer port

3/ descend to the peer hub via ->child

4/ find the port with the matching port id

Note that this assumes the port labeling scheme required by the
specification [1].

[1]: usb3 3.1 section 10.3.3

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |   32 
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 0d36610af156..fd53257de6a9 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -181,15 +181,18 @@ static void unlink_peers(struct usb_port *left, struct 
usb_port *right)
left->peer = NULL;
 }
 
-/* set the default peer port for root hubs */
+/*
+ * Set the default peer port for root hubs, or via the upstream peer
+ * relationship for all other hubs
+ */
 static void find_and_link_peer(struct usb_hub *hub, int port1)
 {
struct usb_port *port_dev = hub->ports[port1 - 1], *peer;
struct usb_device *hdev = hub->hdev;
+   struct usb_device *peer_hdev;
+   struct usb_hub *peer_hub;
 
if (!hdev->parent) {
-   struct usb_hub *peer_hub;
-   struct usb_device *peer_hdev;
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
struct usb_hcd *peer_hcd = hcd->shared_hcd;
 
@@ -197,15 +200,28 @@ static void find_and_link_peer(struct usb_hub *hub, int 
port1)
return;
 
peer_hdev = peer_hcd->self.root_hub;
-   peer_hub = usb_hub_to_struct_hub(peer_hdev);
-   if (!peer_hub || port1 > peer_hdev->maxchild)
+   } else {
+   struct usb_port *upstream;
+   struct usb_device *parent = hdev->parent;
+   struct usb_hub *parent_hub = usb_hub_to_struct_hub(parent);
+
+   if (!parent_hub)
return;
 
-   peer = peer_hub->ports[port1 - 1];
+   upstream = parent_hub->ports[hdev->portnum - 1];
+   if (!upstream || !upstream->peer)
+   return;
 
-   if (peer)
-   link_peers(port_dev, peer);
+   peer_hdev = upstream->peer->child;
}
+
+   peer_hub = usb_hub_to_struct_hub(peer_hdev);
+   if (!peer_hub || port1 > peer_hdev->maxchild)
+   return;
+
+   peer = peer_hub->ports[port1 - 1];
+   if (peer)
+   link_peers(port_dev, peer);
 }
 
 int usb_hub_create_port_device(struct usb_hub *hub, int port1)

--
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 v7 12/16] usb: synchronize port poweroff and khubd

2014-03-19 Thread Dan Williams
If a port is powered-off, or in the process of being powered-off, prevent
khubd from operating on it.  Otherwise, the following sequence of events
leading to an unintended disconnect may occur:

Events:
(0) 
(1) hub 2-2:1.0: hub_resume
(2) hub 2-2:1.0: port 1: status 0301 change 
(3) hub 2-2:1.0: state 7 ports 4 chg 0002 evt 
(4) hub 2-2:1.0: port 1, power off status , change , 12 Mb/s
(5) usb 2-2.1: USB disconnect, device number 5

Description:
(1) hub is resumed before sending a ClearPortFeature request
(2) hub_activate() notices the port is connected and sets
hub->change_bits for the port
(3) hub_events() starts, but at the same time the port suspends
(4) hub_connect_change() sees the disabled port and triggers disconnect

Most of the code thrash here is just indenting the portions of
port_event() that require the port to be runtime pm active.

Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c |   91 +++-
 1 files changed, 51 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index e0c593ea7a0e..10f420626204 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4761,51 +4761,56 @@ static void port_event(struct usb_hub *hub, int port1)
USB_PORT_FEAT_C_PORT_CONFIG_ERROR);
}
 
-   if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange))
-   connect_change = 1;
-
-   /*
-* Warm reset a USB3 protocol port if it's in
-* SS.Inactive state.
-*/
-   if (hub_port_warm_reset_required(hub, portstatus)) {
-   int status;
+   /* take port actions that require the port to be powered on */
+   if (pm_runtime_active(&port_dev->dev)) {
+   if (hub_handle_remote_wakeup(hub, port1,
+   portstatus, portchange))
+   connect_change = 1;
 
-   dev_dbg(&port_dev->dev, "do warm reset\n");
-   if (!udev || !(portstatus & USB_PORT_STAT_CONNECTION)
-   || udev->state == USB_STATE_NOTATTACHED) {
-   status = hub_port_reset(hub, port1, NULL,
-   HUB_BH_RESET_TIME, true);
-   if (status < 0)
-   hub_port_disable(hub, port1, 1);
-   } else {
+   /*
+* Warm reset a USB3 protocol port if it's in
+* SS.Inactive state.
+*/
+   if (hub_port_warm_reset_required(hub, portstatus)) {
+   int status;
+
+   dev_dbg(&port_dev->dev, "do warm reset\n");
+   if (!udev || !(portstatus & USB_PORT_STAT_CONNECTION)
+   || udev->state == 
USB_STATE_NOTATTACHED) {
+   status = hub_port_reset(hub, port1, NULL,
+   HUB_BH_RESET_TIME, true);
+   if (status < 0)
+   hub_port_disable(hub, port1, 1);
+   } else {
+   usb_lock_device(udev);
+   status = usb_reset_device(udev);
+   usb_unlock_device(udev);
+   connect_change = 0;
+   }
+   /*
+* On disconnect USB3 protocol ports transit from U0 to
+* SS.Inactive to Rx.Detect. If this happens a warm-
+* reset is not needed, but a (re)connect may happen
+* before khubd runs and sees the disconnect, and the
+* device may be an unknown state.
+*
+* If the port went through SS.Inactive without khubd
+* seeing it the C_LINK_STATE change flag will be set,
+* and we reset the dev to put it in a known state.
+*/
+   } else if (udev && hub_is_superspeed(hub->hdev) &&
+   (portchange & USB_PORT_STAT_C_LINK_STATE) &&
+   (portstatus & USB_PORT_STAT_CONNECTION)) {
usb_lock_device(udev);
-   status = usb_reset_device(udev);
+   usb_reset_device(udev);
usb_unlock_device(udev);
connect_change = 0;
}
-   /*
-* On disconnect USB3 protocol ports transit from U0 to
-* SS.Inactive to Rx.Detect. If this happens a warm-
-* reset is not needed, but a (re)connect may happen
-* before khubd runs and sees the disconnect, and the
-* device may be an unknown state.
-*
-* If the port went through SS.Inactive without khubd
-* seeing it the C_LINK_STATE change flag will be set,
-* and we reset the d

[PATCH v7 04/16] usb: assign default peer ports for root hubs

2014-03-19 Thread Dan Williams
Assume that the peer of a superspeed port is the port with the same id
on the shared_hcd root hub.  This identification scheme is required of
external hubs by the USB3 spec [1].  However, for root hubs, tier mismatch
may be in effect [2].  Tier mismatch can only be enumerated via platform
firmware.  For now, simply perform the nominal association.

A new lock 'usb_port_peer_mutex' is introduced to synchronize port
device add/remove with peer lookups.  It protects peering against
changes to hcd->shared_hcd, hcd->self.root_hub, hdev->maxchild, and
port_dev->child pointers.

[1]: usb 3.1 section 10.3.3
[2]: xhci 1.1 appendix D

Cc: Alan Stern 
[alan: usb_port_peer_mutex locking scheme]
Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hcd.c  |   43 +++-
 drivers/usb/core/hub.c  |   42 ++-
 drivers/usb/core/hub.h  |2 +
 drivers/usb/core/port.c |   73 ---
 drivers/usb/core/usb.h  |1 +
 5 files changed, 134 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 9c4e2922b04d..6d12d7720632 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2454,11 +2454,13 @@ struct usb_hcd *usb_create_shared_hcd(const struct 
hc_driver *driver,
mutex_init(hcd->bandwidth_mutex);
dev_set_drvdata(dev, hcd);
} else {
+   mutex_lock(&usb_port_peer_mutex);
hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex;
hcd->primary_hcd = primary_hcd;
primary_hcd->primary_hcd = primary_hcd;
hcd->shared_hcd = primary_hcd;
primary_hcd->shared_hcd = hcd;
+   mutex_unlock(&usb_port_peer_mutex);
}
 
kref_init(&hcd->kref);
@@ -2510,18 +2512,25 @@ EXPORT_SYMBOL_GPL(usb_create_hcd);
  * deallocated.
  *
  * Make sure to only deallocate the bandwidth_mutex when the primary HCD is
- * freed.  When hcd_release() is called for the non-primary HCD, set the
- * primary_hcd's shared_hcd pointer to null (since the non-primary HCD will be
- * freed shortly).
+ * freed.  When hcd_release() is called for either hcd in a peer set
+ * invalidate the peer's ->shared_hcd and ->primary_hcd pointers to
+ * block new peering attempts
  */
-static void hcd_release (struct kref *kref)
+static void hcd_release(struct kref *kref)
 {
struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
 
+   mutex_lock(&usb_port_peer_mutex);
if (usb_hcd_is_primary_hcd(hcd))
kfree(hcd->bandwidth_mutex);
-   else
-   hcd->shared_hcd->shared_hcd = NULL;
+   if (hcd->shared_hcd) {
+   struct usb_hcd *peer = hcd->shared_hcd;
+
+   peer->shared_hcd = NULL;
+   if (peer->primary_hcd == hcd)
+   peer->primary_hcd = NULL;
+   }
+   mutex_unlock(&usb_port_peer_mutex);
kfree(hcd);
 }
 
@@ -2589,6 +2598,21 @@ static int usb_hcd_request_irqs(struct usb_hcd *hcd,
return 0;
 }
 
+/*
+ * Before we free this root hub, flush in-flight peering attempts
+ * and disable peer lookups
+ */
+static void usb_put_invalidate_rhdev(struct usb_hcd *hcd)
+{
+   struct usb_device *rhdev;
+
+   mutex_lock(&usb_port_peer_mutex);
+   rhdev = hcd->self.root_hub;
+   hcd->self.root_hub = NULL;
+   mutex_unlock(&usb_port_peer_mutex);
+   usb_put_dev(rhdev);
+}
+
 /**
  * usb_add_hcd - finish generic HCD structure initialization and register
  * @hcd: the usb_hcd structure to initialize
@@ -2649,7 +2673,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
retval = -ENOMEM;
goto err_allocate_root_hub;
}
+   mutex_lock(&usb_port_peer_mutex);
hcd->self.root_hub = rhdev;
+   mutex_unlock(&usb_port_peer_mutex);
 
switch (hcd->speed) {
case HCD_USB11:
@@ -2758,7 +2784,7 @@ err_hcd_driver_start:
 err_request_irq:
 err_hcd_driver_setup:
 err_set_rh_speed:
-   usb_put_dev(hcd->self.root_hub);
+   usb_put_invalidate_rhdev(hcd);
 err_allocate_root_hub:
usb_deregister_bus(&hcd->self);
 err_register_bus:
@@ -2838,7 +2864,6 @@ void usb_remove_hcd(struct usb_hcd *hcd)
free_irq(hcd->irq, hcd);
}
 
-   usb_put_dev(hcd->self.root_hub);
usb_deregister_bus(&hcd->self);
hcd_buffer_destroy(hcd);
if (hcd->remove_phy && hcd->phy) {
@@ -2846,6 +2871,8 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_put_phy(hcd->phy);
hcd->phy = NULL;
}
+
+   usb_put_invalidate_rhdev(hcd);
 }
 EXPORT_SYMBOL_GPL(usb_remove_hcd);
 
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 10c9b52ca0b9..c71f59125a08 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -55,6 +55,9 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
 
 static struct task_struct *khubd_task;
 

[PATCH v7 06/16] usb: find internal hub tier mismatch via acpi

2014-03-19 Thread Dan Williams
ACPI identifies peer ports by setting their 'group_token' and
'group_position' _PLD data to the same value.  If a platform has tier
mismatch [1] , ACPI can override the default (USB3 defined) peer port
association for internal hubs.  External hubs follow the default peer
association scheme.

Location data is cached as an opaque cookie in usb_port_location data.

Note that we only consider the group_token and group_position attributes
from the _PLD data as ACPI specifies that group_token is a unique
identifier.

When we find port location data for a port then we assume that the
firmware will also describe its peer port.  This allows the
implementation to only ever set the peer once.  This leads to a question
about what happens when a pm runtime event occurs while the peer
associations are still resolving.  Since we only ever set the peer
information once, a USB3 port needs to be prevented from suspending
while its ->peer pointer is NULL (implemented in a subsequent patch).

There is always the possibility that firmware mis-identifies the ports,
but there is not much the kernel can do in that case.

[1]: xhci 1.1 appendix D figure 131
[2]: acpi 5 section 6.1.8

[alan]: don't do default peering when acpi data present
Suggested-by: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.h  |2 ++
 drivers/usb/core/port.c |   56 ---
 drivers/usb/core/usb-acpi.c |   41 ++-
 drivers/usb/core/usb.h  |6 +
 4 files changed, 83 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index d51feb68165b..6858a55eceb5 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -83,6 +83,7 @@ struct usb_hub {
  * @port_owner: port's owner
  * @peer: related usb2 and usb3 ports (share the same connector)
  * @connect_type: port's connect type
+ * @location: opaque representation of platform connector location
  * @portnum: port index num based one
  * @power_is_on: port's power state
  * @did_runtime_put: port has done pm_runtime_put().
@@ -93,6 +94,7 @@ struct usb_port {
struct dev_state *port_owner;
struct usb_port *peer;
enum usb_port_connect_type connect_type;
+   usb_port_location_t location;
u8 portnum;
unsigned power_is_on:1;
unsigned did_runtime_put:1;
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index fd53257de6a9..d29e9dc8ea9f 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -182,8 +182,42 @@ static void unlink_peers(struct usb_port *left, struct 
usb_port *right)
 }
 
 /*
- * Set the default peer port for root hubs, or via the upstream peer
- * relationship for all other hubs
+ * For each usb hub device in the system check to see if it is in the
+ * peer domain of the given port_dev, and if it is check to see if it
+ * has a port that matches the given port by location
+ */
+static int match_location(struct usb_device *peer_hdev, void *p)
+{
+   int port1;
+   struct usb_hcd *hcd, *peer_hcd;
+   struct usb_port *port_dev = p, *peer;
+   struct usb_hub *peer_hub = usb_hub_to_struct_hub(peer_hdev);
+   struct usb_device *hdev = to_usb_device(port_dev->dev.parent->parent);
+
+   if (!peer_hub)
+   return 0;
+
+   hcd = bus_to_hcd(hdev->bus);
+   peer_hcd = bus_to_hcd(peer_hdev->bus);
+   /* peer_hcd is provisional until we verify it against the known peer */
+   if (peer_hcd != hcd->shared_hcd)
+   return 0;
+
+   for (port1 = 1; port1 <= peer_hdev->maxchild; port1++) {
+   peer = peer_hub->ports[port1 - 1];
+   if (peer && peer->location == port_dev->location) {
+   link_peers(port_dev, peer);
+   return 1; /* done */
+   }
+   }
+
+   return 0;
+}
+
+/*
+ * Find the peer port either via explicit platform firmware "location"
+ * data, the peer hcd for root hubs, or the upstream peer relationship
+ * for all other hubs.
  */
 static void find_and_link_peer(struct usb_hub *hub, int port1)
 {
@@ -192,7 +226,17 @@ static void find_and_link_peer(struct usb_hub *hub, int 
port1)
struct usb_device *peer_hdev;
struct usb_hub *peer_hub;
 
-   if (!hdev->parent) {
+   /*
+* If location data is available then we can only peer this port
+* by a location match, not the default peer (lest we create a
+* situation where we need to go back and undo a default peering
+* when the port is later peered by location data)
+*/
+   if (port_dev->location) {
+   /* we link the peer in match_location() if found */
+   usb_for_each_dev(port_dev, match_location);
+   return;
+   } else if (!hdev->parent) {
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
struct usb_hcd *peer_hcd = hcd->shared_hcd;
 
@@ 

[PATCH v7 00/16] port power control reworks

2014-03-19 Thread Dan Williams
Status:
To date Alan has acked 9 of 16 patches (patch 1, 2, and 4 - 10), thanks
Alan!  Of course, if others want to jump in please feel free.

Changes since v6 [1] [2] are simply rebasing/testing on top of current
usb-next (commit 6aec044cc2f5 "USB: unbind all interfaces before
rebinding any"), fixing up the collisions with commit a82b76f7fa61 "usb:
Reset USB-3 devices on USB-3 link bounce" and recording Alan's acks.

=

This series addresses the following disconnect scenarios when attempting
to use port power-off.  

1/ Superspeed devices downgrade to their hispeed connection when
   rx-detection fails on the superspeed pins.  Address this by
   preventing superspeed port poweroff/suspension until the peer port is
   suspended, and powering on the superspeed port before the hispeed
   port is resumed.  This depends on the ability to identify peer ports
   (patches 4-7, and patch 8 implements the policy).

2/ khubd prematurely disconnects ports that are in the process of being
   resumed or reset.  After this series khubd will ignore ports in the
   pm-runtime-suspended or suspending state, or force active ports in the
   resuming state (patch 12).  While it is running it holds a new port
   status lock to synchronize the port status changes of
   usb_port_{suspend|resume} and usb_reset_and_verify_device() (patch 13).

3/ Superspeed devices fail to reconnect after a 2 second timeout  This
   event has two causes:

   3.1/ Repeated {Set|Clear}PortFeature(PORT_POWER) toggles results in
the the device switching to its hispeed connection (due to
perceived instability of the superspeed connection).  Address
this by arranging for the child device to be woken up
and complete a resume cycle when the parent port resumes (patch 14).

   3.2/ Devices may require a warm reset when recovering the power
session.  When the child device is woken up per above and the
port timed out on reconnect, force a warm-reset during the
child's reset-resume (patch 15).

[1] v6 part1: http://marc.info/?l=linux-usb&m=139362948508700&w=2
[2] v6 part2: http://marc.info/?l=linux-usb&m=139474608015248&w=2

---
[PATCH v7 01/16] usb: disable port power control if not supported in 
wHubCharacteristics
[PATCH v7 02/16] usb: rename usb_port device objects
[PATCH v7 03/16] usb: cleanup setting udev->removable from 
port_dev->connect_type
[PATCH v7 04/16] usb: assign default peer ports for root hubs
[PATCH v7 05/16] usb: assign usb3 external hub port peers
[PATCH v7 06/16] usb: find internal hub tier mismatch via acpi
[PATCH v7 07/16] usb: sysfs link peer ports
[PATCH v7 08/16] usb: block suspension of superspeed port while hispeed peer is 
active
[PATCH v7 09/16] usb: don't clear FEAT_C_ENABLE on usb_port_runtime_resume 
failure
[PATCH v7 10/16] usb: usb3 ports do not support FEAT_C_ENABLE
[PATCH v7 11/16] usb: refactor port handling in hub_events()
[PATCH v7 12/16] usb: synchronize port poweroff and khubd
[PATCH v7 13/16] usb: introduce port status lock
[PATCH v7 14/16] usb: resume (wakeup) child device when port is powered on
[PATCH v7 15/16] usb: force warm reset to break link re-connect livelock
[PATCH v7 16/16] usb: documentation for usb port power off mechanisms

 Documentation/usb/power-management.txt |  242 +
 drivers/usb/core/hcd.c |   45 +-
 drivers/usb/core/hub.c |  855 +---
 drivers/usb/core/hub.h |   34 +
 drivers/usb/core/port.c|  293 ++-
 drivers/usb/core/usb-acpi.c|  107 ++--
 drivers/usb/core/usb.h |   17 -
 7 files changed, 1087 insertions(+), 506 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 v7 11/16] usb: refactor port handling in hub_events()

2014-03-19 Thread Dan Williams
In preparation for synchronizing port handling with pm_runtime
transitions refactor port handling into its own subroutine.

We expect that clearing some status flags will be required regardless of
the port state, so handle those first and group all non-trivial actions
at the bottom of the routine.

This also splits off the bottom half of hub_port_connect_change() into
hub_port_reconnect() in prepartion for introducing a port->status_lock.
hub_port_reconnect() will expect the port lock to not be held while
hub_port_connect_change() expects to enter with it held.

Other cleanups include:
1/ reflowing to 80 columns
2/ replacing redundant usages of 'hub->hdev' with 'hdev'
3/ consolidate clearing of ->change_bits() in hub_port_connect_change

Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c |  379 
 1 files changed, 190 insertions(+), 189 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 31c88d5cf738..e0c593ea7a0e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4390,66 +4390,15 @@ hub_power_remaining (struct usb_hub *hub)
return remaining;
 }
 
-/* Handle physical or logical connection change events.
- * This routine is called when:
- * a port connection-change occurs;
- * a port enable-change occurs (often caused by EMI);
- * usb_reset_and_verify_device() encounters changed descriptors (as from
- * a firmware download)
- * caller already locked the hub
- */
-static void hub_port_connect_change(struct usb_hub *hub, int port1,
-   u16 portstatus, u16 portchange)
+static void hub_port_reconnect(struct usb_hub *hub, int port1, u16 portstatus,
+   u16 portchange)
 {
+   int status, i;
+   unsigned unit_load;
struct usb_device *hdev = hub->hdev;
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
struct usb_port *port_dev = hub->ports[port1 - 1];
-   struct usb_device *udev;
-   int status, i;
-   unsigned unit_load;
-
-   dev_dbg(&port_dev->dev, "status %04x, change %04x, %s\n",
-   portstatus, portchange, portspeed(hub, portstatus));
-
-   if (hub->has_indicators) {
-   set_port_led(hub, port1, HUB_LED_AUTO);
-   hub->indicator[port1-1] = INDICATOR_AUTO;
-   }
-
-#ifdef CONFIG_USB_OTG
-   /* during HNP, don't repeat the debounce */
-   if (hdev->bus->is_b_host)
-   portchange &= ~(USB_PORT_STAT_C_CONNECTION |
-   USB_PORT_STAT_C_ENABLE);
-#endif
-
-   /* Try to resuscitate an existing device */
-   udev = port_dev->child;
-   if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
-   udev->state != USB_STATE_NOTATTACHED) {
-   usb_lock_device(udev);
-   if (portstatus & USB_PORT_STAT_ENABLE) {
-   status = 0; /* Nothing to do */
-
-#ifdef CONFIG_PM_RUNTIME
-   } else if (udev->state == USB_STATE_SUSPENDED &&
-   udev->persist_enabled) {
-   /* For a suspended device, treat this as a
-* remote wakeup event.
-*/
-   status = usb_remote_wakeup(udev);
-#endif
-
-   } else {
-   status = -ENODEV;   /* Don't resuscitate */
-   }
-   usb_unlock_device(udev);
-
-   if (status == 0) {
-   clear_bit(port1, hub->change_bits);
-   return;
-   }
-   }
+   struct usb_device *udev = port_dev->child;
 
/* Disconnect any existing devices under this port */
if (udev) {
@@ -4458,7 +4407,6 @@ static void hub_port_connect_change(struct usb_hub *hub, 
int port1,
usb_phy_notify_disconnect(hcd->phy, udev->speed);
usb_disconnect(&port_dev->child);
}
-   clear_bit(port1, hub->change_bits);
 
/* We can forget about a "removed" device when there's a physical
 * disconnect or the connect status changes.
@@ -4640,6 +4588,66 @@ done:
hub_port_disable(hub, port1, 1);
if (hcd->driver->relinquish_port && !hub->hdev->parent)
hcd->driver->relinquish_port(hcd, port1);
+
+}
+
+/* Handle physical or logical connection change events.
+ * This routine is called when:
+ * a port connection-change occurs;
+ * a port enable-change occurs (often caused by EMI);
+ * usb_reset_and_verify_device() encounters changed descriptors (as from
+ * a firmware download)
+ * caller already locked the hub
+ */
+static void hub_port_connect_change(struct usb_hub *hub, int port1,
+   u16 portstatus, u16 portchange)
+{
+   struct usb_port *port_dev = hub->ports[port1 - 1];
+   struct usb_device *udev = port_dev->child;
+   str

[PATCH v7 14/16] usb: resume (wakeup) child device when port is powered on

2014-03-19 Thread Dan Williams
Unconditionally wake up the child device when the power session is
recovered.

This address the following scenarios:

1/ The device may need a reset on power-session loss, without this
   change port power-on recovery exposes khubd to scenarios that
   usb_port_resume() is set to handle.  Prior to port power control the
   only time a power session would be lost is during dpm_suspend of the
   hub.  In that scenario usb_port_resume() is guaranteed to be called
   prior to khubd running for that port.  With this change we wakeup the
   child device as soon as possible (prior to khubd running again for this
   port).

   Although khubd has facilities to wake a child device it will only do
   so if the portstatus / portchange indicates a suspend state.  In the
   case of port power control we are not coming from a hub-port-suspend
   state.  This implemenation extends usb_wake_notification() for the
   port rpm_resume case.

2/ This mechanism rate limits port power toggling.  The minimum port
   power on/off period is now gated by the child device suspend/resume
   latency.  Empirically this mitigates devices downgrading their connection
   on perceived instability of the host connection.  This ratelimiting is
   really only relevant to port power control testing, but it is a nice
   side effect of closing the above race.  Namely, the race of khubd for
   the given port running while a usb_port_resume() event is pending.

3/ Going forward we are finding that power-session recovery requires
   warm-resets (http://marc.info/?t=13865923293&r=1&w=2).  This
   mechanism allows for warm-resets to be requested at the same point in
   the resume path for hub dpm_suspend power session losses, or port
   rpm_suspend power session losses.

4/ If the device *was* disconnected the only time we'll know for sure is
   after a failed resume, so it's necessary for usb_port_runtime_resume()
   to expedite a usb_port_resume() to clean up the removed device.  The
   reasoning for this is "least surprise" for the user. Turning on a port
   means that hotplug detection is again enabled for the port, it is
   surprising that devices that were removed while the port was off are not
   disconnected until they are attempted to be used.  As a user "why would
   I try to use a device I removed from the system?"

1, 2, and 4 are not a problem in the system dpm_resume case because,
although the power-session is lost, khubd is frozen until after device
resume.  For the port rpm_resume use runtime-pm-synchronization to
guarantee the same sequence of events.  When a usb_wakeup_notification()
is invoked the port device is in the RPM_RESUMING state.  khubd in turn
performs a pm_runtime_barrier() on the port device to flush the port
recovery, holds the port active while it resumes the child, and
completes child device resume before acting on the current portstatus.

Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   40 +---
 drivers/usb/core/port.c |2 ++
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 194ff3303ee9..6c666796fd21 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -606,9 +606,11 @@ void usb_kick_khubd(struct usb_device *hdev)
  * USB 3.0 hubs do not report the port link state change from U3 to U0 when the
  * device initiates resume, so the USB core will not receive notice of the
  * resume through the normal hub interrupt URB.
+ *
+ * This is also called by usb_port_runtime_resume() to arrange for the child
+ * device to be woken up as part of the power session recovery for the port.
  */
-void usb_wakeup_notification(struct usb_device *hdev,
-   unsigned int portnum)
+void usb_wakeup_notification(struct usb_device *hdev, unsigned int port1)
 {
struct usb_hub *hub;
 
@@ -617,7 +619,11 @@ void usb_wakeup_notification(struct usb_device *hdev,
 
hub = usb_hub_to_struct_hub(hdev);
if (hub) {
-   set_bit(portnum, hub->wakeup_bits);
+   struct usb_port *port_dev = hub->ports[port1 - 1];
+
+   dev_dbg(&port_dev->dev, "%s\n", __func__);
+   if (!test_and_set_bit(port1, hub->wakeup_bits))
+   pm_runtime_get(&port_dev->dev);
kick_khubd(hub);
}
 }
@@ -4677,28 +4683,33 @@ static void hub_port_connect_change(struct usb_hub 
*hub, int port1,
 
 /* Returns 1 if there was a remote wakeup and a connect status change. */
 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port,
-   u16 portstatus, u16 portchange)
+   u16 portstatus, u16 portchange, int wakeup_change)
__must_hold(&port_dev->status_lock)
 {
struct usb_port *port_dev = hub->ports[port - 1];
+   int connect_change = 0, do_wakeup = 1;
struct usb_device *hdev;
struct usb_device *udev;
-   int connect_change = 0;
int ret;
 

[PATCH v7 15/16] usb: force warm reset to break link re-connect livelock

2014-03-19 Thread Dan Williams
Resuming a powered down port sometimes results in the port state being
stuck in the training sequence.

 hub 3-0:1.0: debounce: port 1: total 2000ms stable 0ms status 0x2e0
 port1: can't get reconnection after setting port  power on, status -110
 hub 3-0:1.0: port 1 status .02e0 after resume, -19
 usb 3-1: can't resume, status -19
 hub 3-0:1.0: logical disconnect on port 1

In the case above we wait for the port re-connect timeout of 2 seconds
and observe that the port status is USB_SS_PORT_LS_POLLING (although it
is likely toggling between this state and USB_SS_PORT_LS_RX_DETECT).
This is indicative of a case where the device is failing to progress the
link training state machine.

It is resolved by issuing a warm reset to get the hub and device link
state machines back in sync.

 hub 3-0:1.0: debounce: port 1: total 2000ms stable 0ms status 0x2e0
 usb usb3: port1 usb_port_runtime_resume requires warm reset
 hub 3-0:1.0: port 1 not warm reset yet, waiting 50ms
 usb 3-1: reset SuperSpeed USB device number 2 using xhci_hcd

After a reconnect timeout when we expect the device to be present, force
a warm reset of the device.  Note that we can not simply look at the
link status to determine if a warm reset is required as any of the
training states USB_SS_PORT_LS_POLLING, USB_SS_PORT_LS_RX_DETECT, or
USB_SS_PORT_LS_COMP_MOD are valid states that do not indicate the need
for warm reset by themselves.

Cc: Alan Stern 
Cc: Kukjin Kim 
Cc: Vincent Palatin 
Cc: Lan Tianyu 
Cc: Ksenia Ragiadakou 
Cc: Vivek Gautam 
Cc: Douglas Anderson 
Cc: Felipe Balbi 
Cc: Sunil Joshi 
Cc: Hans de Goede 
Acked-by: Julius Werner 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   23 ---
 drivers/usb/core/hub.h  |2 ++
 drivers/usb/core/port.c |   20 
 3 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 6c666796fd21..ed4df806dc50 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2543,10 +2543,12 @@ static int hub_port_reset(struct usb_hub *hub, int 
port1,
 /* Is a USB 3.0 port in the Inactive or Compliance Mode state?
  * Port worm reset is required to recover
  */
-static bool hub_port_warm_reset_required(struct usb_hub *hub, u16 portstatus)
+static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
+u16 portstatus)
 {
return hub_is_superspeed(hub->hdev) &&
-   (((portstatus & USB_PORT_STAT_LINK_STATE) ==
+   (test_bit(port1, hub->warm_reset_bits) ||
+   ((portstatus & USB_PORT_STAT_LINK_STATE) ==
  USB_SS_PORT_LS_SS_INACTIVE) ||
 ((portstatus & USB_PORT_STAT_LINK_STATE) ==
  USB_SS_PORT_LS_COMP_MOD)) ;
@@ -2586,7 +2588,7 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
if ((portstatus & USB_PORT_STAT_RESET))
return -EBUSY;
 
-   if (hub_port_warm_reset_required(hub, portstatus))
+   if (hub_port_warm_reset_required(hub, port1, portstatus))
return -ENOTCONN;
 
/* Device went away? */
@@ -2686,8 +2688,9 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
if (status < 0)
goto done;
 
-   if (hub_port_warm_reset_required(hub, portstatus))
+   if (hub_port_warm_reset_required(hub, port1, portstatus))
warm = true;
+   clear_bit(port1, hub->warm_reset_bits);
}
 
/* Reset the port */
@@ -2725,7 +2728,8 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
&portstatus, &portchange) < 0)
goto done;
 
-   if (!hub_port_warm_reset_required(hub, portstatus))
+   if (!hub_port_warm_reset_required(hub, port1,
+   portstatus))
goto done;
 
/*
@@ -2812,8 +2816,13 @@ static int check_port_resume_type(struct usb_device 
*udev,
 {
struct usb_port *port_dev = hub->ports[port1 - 1];
 
+   /* Is a warm reset needed to recover the connection? */
+   if (udev->reset_resume
+   && hub_port_warm_reset_required(hub, port1, portstatus)) {
+   /* pass */;
+   }
/* Is the device still present? */
-   if (status || port_is_suspended(hub, portstatus) ||
+   else if (status || port_is_suspended(hub, portstatus) ||
!port_is_power_on(hub, portstatus) ||
!(portstatus & USB_PORT_STAT_CONNECTION)) {
if (status >= 0)
@@ -4816,7 +4825,7 @@ static void port_event(struct usb_hub *hub, int port1)
 * Warm reset a USB3 protocol port if it's in
 * SS.Inactive state.
 */
-   if (hub_port_warm_reset_required(hub

[PATCH v7 09/16] usb: don't clear FEAT_C_ENABLE on usb_port_runtime_resume failure

2014-03-19 Thread Dan Williams
Three reasons:
1/ It's an invalid operation on usb3 ports
2/ There's no guarantee of when / if a usb2 port has entered an error
   state relative to PORT_POWER request
3/ The port is active / powered at this point, so khubd will clear it as
   a matter of course

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 24faa88a25c4..191d7c3c9791 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -106,7 +106,6 @@ static int usb_port_runtime_resume(struct device *dev)
if (retval < 0)
dev_dbg(&port_dev->dev, "can't get reconnection after 
setting port  power on, status %d\n",
retval);
-   usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE);
retval = 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 v7 08/16] usb: block suspension of superspeed port while hispeed peer is active

2014-03-19 Thread Dan Williams
ClearPortFeature(PORT_POWER) on a usb3 port places the port in either a
DSPORT.Powered-off-detect / DSPORT.Powered-off-reset loop, or the
DSPORT.Powered-off state.  There is no way to ensure that RX
terminations will persist in this state, so it is possible a device will
degrade to its usb2 connection.  Prevent this by blocking power-off of a
usb3 port while its usb2 peer is active, and powering on a usb3 port
before its usb2 peer.

By default the latency between peer power-on events is 0.  In order for
the device to not see usb2 active while usb3 is still powering up inject
the hub recommended power_on_good delay.

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   22 +++---
 drivers/usb/core/hub.h  |   14 +
 drivers/usb/core/port.c |   72 +++
 3 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c71f59125a08..31c88d5cf738 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -36,11 +36,6 @@
 #define USB_VENDOR_GENESYS_LOGIC   0x05e3
 #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND   0x01
 
-static inline int hub_is_superspeed(struct usb_device *hdev)
-{
-   return (hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS);
-}
-
 /* Protect struct usb_device->state and ->children members
  * Note: Both are also protected by ->dev.sem, except that ->state can
  * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
@@ -818,14 +813,9 @@ int usb_hub_clear_tt_buffer(struct urb *urb)
 }
 EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffer);
 
-/* If do_delay is false, return the number of milliseconds the caller
- * needs to delay.
- */
-static unsigned hub_power_on(struct usb_hub *hub, bool do_delay)
+static void hub_power_on(struct usb_hub *hub, bool do_delay)
 {
int port1;
-   unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
-   unsigned delay;
 
/* Enable power on each port.  Some hubs have reserved values
 * of LPSM (> 2) in their descriptors, even though they are
@@ -844,12 +834,8 @@ static unsigned hub_power_on(struct usb_hub *hub, bool 
do_delay)
else
usb_clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_POWER);
-
-   /* Wait at least 100 msec for power to become stable */
-   delay = max(pgood_delay, (unsigned) 100);
if (do_delay)
-   msleep(delay);
-   return delay;
+   msleep(hub_power_on_good_delay(hub));
 }
 
 static int hub_hub_status(struct usb_hub *hub,
@@ -1053,7 +1039,9 @@ static void hub_activate(struct usb_hub *hub, enum 
hub_activation_type type)
 * for HUB_POST_RESET, but it's easier not to.
 */
if (type == HUB_INIT) {
-   delay = hub_power_on(hub, false);
+   unsigned delay = hub_power_on_good_delay(hub);
+
+   hub_power_on(hub, false);
PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func2);
queue_delayed_work(system_power_efficient_wq,
&hub->init_work,
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 6858a55eceb5..8d63a420fb45 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -98,6 +98,7 @@ struct usb_port {
u8 portnum;
unsigned power_is_on:1;
unsigned did_runtime_put:1;
+   unsigned is_superspeed:1;
 };
 
 #define to_usb_port(_dev) \
@@ -125,6 +126,19 @@ static inline bool hub_is_port_power_switchable(struct 
usb_hub *hub)
return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM;
 }
 
+static inline int hub_is_superspeed(struct usb_device *hdev)
+{
+   return hdev->descriptor.bDeviceProtocol == USB_HUB_PR_SS;
+}
+
+static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)
+{
+   unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
+
+   /* Wait at least 100 msec for power to become stable */
+   return max(delay, 100U);
+}
+
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
int port1)
 {
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index b7f5225cee2b..24faa88a25c4 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -76,16 +76,25 @@ static int usb_port_runtime_resume(struct device *dev)
struct usb_device *hdev = to_usb_device(dev->parent->parent);
struct usb_interface *intf = to_usb_interface(dev->parent);
struct usb_hub *hub = usb_hub_to_struct_hub(hdev);
+   struct usb_port *peer = port_dev->peer;
int port1 = port_dev->portnum;
int retval;
 
if (!hub)
return -EINVAL;
 
+   /*
+* Power on our usb3 peer before this usb2 port to prevent a usb3
+* device from degrading to its usb2 c

[PATCH 1/2] coding style: fix quoted string split across lines

2014-03-19 Thread Cédric Cabessa
Signed-off-by: Cédric Cabessa 
---
 drivers/staging/usbip/stub_tx.c  | 16 
 drivers/staging/usbip/usbip_common.c | 10 --
 drivers/staging/usbip/vhci_sysfs.c   |  4 ++--
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c
index cd5326a..1622563 100644
--- a/drivers/staging/usbip/stub_tx.c
+++ b/drivers/staging/usbip/stub_tx.c
@@ -74,12 +74,12 @@ void stub_complete(struct urb *urb)
/* OK */
break;
case -ENOENT:
-   dev_info(&urb->dev->dev, "stopped by a call to usb_kill_urb() "
-"because of cleaning up a virtual connection\n");
+   dev_info(&urb->dev->dev,
+"stopped by a call to usb_kill_urb() because of 
cleaning up a virtual connection\n");
return;
case -ECONNRESET:
-   dev_info(&urb->dev->dev, "unlinked by a call to "
-"usb_unlink_urb()\n");
+   dev_info(&urb->dev->dev,
+"unlinked by a call to usb_unlink_urb()\n");
break;
case -EPIPE:
dev_info(&urb->dev->dev, "endpoint %d is stalled\n",
@@ -89,8 +89,9 @@ void stub_complete(struct urb *urb)
dev_info(&urb->dev->dev, "device removed?\n");
break;
default:
-   dev_info(&urb->dev->dev, "urb completion with non-zero status "
-"%d\n", urb->status);
+   dev_info(&urb->dev->dev,
+"urb completion with non-zero status %d\n",
+urb->status);
break;
}
 
@@ -228,8 +229,7 @@ static int stub_send_ret_submit(struct stub_device *sdev)
 
if (txsize != sizeof(pdu_header) + urb->actual_length) {
dev_err(&sdev->interface->dev,
-   "actual length of urb %d does not "
-   "match iso packet sizes %zu\n",
+   "actual length of urb %d does not match 
iso packet sizes %zu\n",
urb->actual_length,
txsize-sizeof(pdu_header));
kfree(iov);
diff --git a/drivers/staging/usbip/usbip_common.c 
b/drivers/staging/usbip/usbip_common.c
index 2a11233..184fa70 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -178,8 +178,8 @@ static void usbip_dump_usb_ctrlrequest(struct 
usb_ctrlrequest *cmd)
}
 
pr_debug("   ");
-   pr_debug("bRequestType(%02X) bRequest(%02X) wValue(%04X) wIndex(%04X) "
-"wLength(%04X) ", cmd->bRequestType, cmd->bRequest,
+   pr_debug("bRequestType(%02X) bRequest(%02X) wValue(%04X) wIndex(%04X) 
wLength(%04X) ",
+cmd->bRequestType, cmd->bRequest,
 cmd->wValue, cmd->wIndex, cmd->wLength);
pr_debug("\n   ");
 
@@ -290,8 +290,7 @@ void usbip_dump_header(struct usbip_header *pdu)
 
switch (pdu->base.command) {
case USBIP_CMD_SUBMIT:
-   pr_debug("USBIP_CMD_SUBMIT: "
-"x_flags %u x_len %u sf %u #p %d iv %d\n",
+   pr_debug("USBIP_CMD_SUBMIT: x_flags %u x_len %u sf %u #p %d iv 
%d\n",
 pdu->u.cmd_submit.transfer_flags,
 pdu->u.cmd_submit.transfer_buffer_length,
 pdu->u.cmd_submit.start_frame,
@@ -688,8 +687,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
 
if (total_length != urb->actual_length) {
dev_err(&urb->dev->dev,
-   "total length of iso packets %d not equal to actual "
-   "length of buffer %d\n",
+   "total length of iso packets %d not equal to actual 
length of buffer %d\n",
total_length, urb->actual_length);
 
if (ud->side == USBIP_STUB)
diff --git a/drivers/staging/usbip/vhci_sysfs.c 
b/drivers/staging/usbip/vhci_sysfs.c
index 82dd49f..e098032 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/staging/usbip/vhci_sysfs.c
@@ -47,8 +47,8 @@ static ssize_t status_show(struct device *dev, struct 
device_attribute *attr,
 * up /proc/net/{tcp,tcp6}. Also, a userland program may remember a
 * port number and its peer IP address.
 */
-   out += sprintf(out, "prt sta spd bus dev socket   "
-  "local_busid\n");
+   out += sprintf(out,
+  "prt sta spd bus dev socket   local_busid\n");
 
for (i = 0; i < VHCI_NPORTS; i++) {
struct vhci_device *vdev = port_to_vdev(i);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord..

[PATCH 0/2] coding style for drivers/staging/usbip

2014-03-19 Thread Cédric Cabessa
Various coding style fixes for drivers/staging/usbip

Cédric Cabessa (2):
  coding style: fix quoted string split across lines
  coding style: fix line over 80 characters

 drivers/staging/usbip/stub_tx.c  | 16 
 drivers/staging/usbip/usbip_common.c | 10 --
 drivers/staging/usbip/vhci_hcd.c | 33 ++---
 drivers/staging/usbip/vhci_sysfs.c   |  4 ++--
 4 files changed, 36 insertions(+), 27 deletions(-)

-- 
1.8.3.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 2/2] coding style: fix line over 80 characters

2014-03-19 Thread Cédric Cabessa
Signed-off-by: Cédric Cabessa 
---
 drivers/staging/usbip/vhci_hcd.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index f690668..1e84577 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -271,12 +271,14 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
}
break;
case USB_PORT_FEAT_POWER:
-   usbip_dbg_vhci_rh(" ClearPortFeature: 
USB_PORT_FEAT_POWER\n");
+   usbip_dbg_vhci_rh(
+   " ClearPortFeature: USB_PORT_FEAT_POWER\n");
dum->port_status[rhport] = 0;
dum->resuming = 0;
break;
case USB_PORT_FEAT_C_RESET:
-   usbip_dbg_vhci_rh(" ClearPortFeature: 
USB_PORT_FEAT_C_RESET\n");
+   usbip_dbg_vhci_rh(
+   " ClearPortFeature: USB_PORT_FEAT_C_RESET\n");
switch (dum->vdev[rhport].speed) {
case USB_SPEED_HIGH:
dum->port_status[rhport] |=
@@ -335,15 +337,17 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 
if (dum->vdev[rhport].ud.status ==
VDEV_ST_NOTASSIGNED) {
-   usbip_dbg_vhci_rh(" enable rhport %d (status 
%u)\n",
- rhport,
- dum->vdev[rhport].ud.status);
+   usbip_dbg_vhci_rh(
+   " enable rhport %d (status %u)\n",
+   rhport,
+   dum->vdev[rhport].ud.status);
dum->port_status[rhport] |=
USB_PORT_STAT_ENABLE;
}
}
((__le16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
-   ((__le16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 
16);
+   ((__le16 *) buf)[1] =
+   cpu_to_le16(dum->port_status[rhport] >> 16);
 
usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
  ((u16 *)buf)[1]);
@@ -355,10 +359,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
case SetPortFeature:
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
-   usbip_dbg_vhci_rh(" SetPortFeature: 
USB_PORT_FEAT_SUSPEND\n");
+   usbip_dbg_vhci_rh(
+   " SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
break;
case USB_PORT_FEAT_RESET:
-   usbip_dbg_vhci_rh(" SetPortFeature: 
USB_PORT_FEAT_RESET\n");
+   usbip_dbg_vhci_rh(
+   " SetPortFeature: USB_PORT_FEAT_RESET\n");
/* if it's already running, disconnect first */
if (dum->port_status[rhport] & USB_PORT_STAT_ENABLE) {
dum->port_status[rhport] &=
@@ -530,7 +536,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb 
*urb,
 
case USB_REQ_GET_DESCRIPTOR:
if (ctrlreq->wValue == cpu_to_le16(USB_DT_DEVICE << 8))
-   usbip_dbg_vhci_hc("Not yet?:Get_Descriptor to 
device 0 (get max pipe size)\n");
+   usbip_dbg_vhci_hc(
+   "Not yet?:Get_Descriptor to device 0 
(get max pipe size)\n");
 
if (vdev->udev)
usb_put_dev(vdev->udev);
@@ -539,7 +546,9 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb 
*urb,
 
default:
/* NOT REACHED */
-   dev_err(dev, "invalid request to devnum 0 bRequest %u, 
wValue %u\n", ctrlreq->bRequest,
+   dev_err(dev,
+   "invalid request to devnum 0 bRequest %u, 
wValue %u\n",
+   ctrlreq->bRequest,
ctrlreq->wValue);
ret =  -EINVAL;
goto no_need_xmit;
@@ -1060,7 +1069,9 @@ static int vhci_hcd_suspend(struct platform_device *pdev, 
pm_message_t state)
spin_unlock(&the_controller->lock);
 
if (connected > 0) {
-   dev_info(&pdev->dev, "We have %d active connection%s. Do not 
suspend.\n", connected, (connected == 1 ? "" : "s"));
+   dev_info(&pdev->dev,
+"We have %d active conn

[PATCH] staging: octeon-usb: prevent memory corruption

2014-03-19 Thread Aaro Koskinen
octeon-hcd will crash the kernel when SLOB is used. This usually happens
after the 18-byte control transfer when a device descriptor is read.
The DMA engine is always transfering full 32-bit words and if the
transfer is shorter, some random garbage appears after the buffer.
The problem is not visible with SLUB since it rounds up the allocations
to word boundary, and the extra bytes will go undetected.

Fix by providing quirk functions for DMA map/unmap that allocate a bigger
temporary buffer when necessary. Tested by booting EdgeRouter Lite
to USB stick root file system with SLAB, SLOB and SLUB kernels.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=72121
Reported-by: Sergey Popov 
Signed-off-by: Aaro Koskinen 
---
 drivers/staging/octeon-usb/octeon-hcd.c | 108 
 1 file changed, 108 insertions(+)

diff --git a/drivers/staging/octeon-usb/octeon-hcd.c 
b/drivers/staging/octeon-usb/octeon-hcd.c
index 5a001d9..9c152f9 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+++ b/drivers/staging/octeon-usb/octeon-hcd.c
@@ -465,6 +465,112 @@ struct octeon_hcd {
 #define USB_FIFO_ADDRESS(channel, usb_index) (CVMX_USBCX_GOTGCTL(usb_index) + 
((channel)+1)*0x1000)
 
 /**
+ * struct octeon_temp_buffer - a bounce buffer for USB transfers
+ * @temp_buffer: the newly allocated temporary buffer (including meta-data)
+ * @orig_buffer: the original buffer passed by the USB stack
+ * @data:   the newly allocated temporary buffer (excluding meta-data)
+ *
+ * Both the DMA engine and FIFO mode will always transfer full 32-bit words. If
+ * the buffer is too short, we need to allocate a temporary one, and this 
struct
+ * represents it.
+ */
+struct octeon_temp_buffer {
+   void *temp_buffer;
+   void *orig_buffer;
+   u8 data[0];
+};
+
+/**
+ * octeon_alloc_temp_buffer - allocate a temporary buffer for USB transfer
+ *(if needed)
+ * @urb:   URB.
+ * @mem_flags: Memory allocation flags.
+ *
+ * This function allocates a temporary bounce buffer whenever it's needed
+ * due to HW limitations.
+ */
+static int octeon_alloc_temp_buffer(struct urb *urb, gfp_t mem_flags)
+{
+   struct octeon_temp_buffer *temp;
+
+   if (urb->num_sgs || urb->sg ||
+   (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) ||
+   !(urb->transfer_buffer_length % sizeof(u32)))
+   return 0;
+
+   temp = kmalloc(ALIGN(urb->transfer_buffer_length, sizeof(u32)) +
+  sizeof(*temp), mem_flags);
+   if (!temp)
+   return -ENOMEM;
+
+   temp->temp_buffer = temp;
+   temp->orig_buffer = urb->transfer_buffer;
+   if (usb_urb_dir_out(urb))
+   memcpy(temp->data, urb->transfer_buffer,
+  urb->transfer_buffer_length);
+   urb->transfer_buffer = temp->data;
+   urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;
+
+   return 0;
+}
+
+/**
+ * octeon_free_temp_buffer - free a temporary buffer used by USB transfers.
+ * @urb: URB.
+ *
+ * Frees a buffer allocated by octeon_alloc_temp_buffer().
+ */
+static void octeon_free_temp_buffer(struct urb *urb)
+{
+   struct octeon_temp_buffer *temp;
+
+   if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
+   return;
+
+   temp = container_of(urb->transfer_buffer, struct octeon_temp_buffer,
+   data);
+   if (usb_urb_dir_in(urb))
+   memcpy(temp->orig_buffer, urb->transfer_buffer,
+  urb->actual_length);
+   urb->transfer_buffer = temp->orig_buffer;
+   urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
+   kfree(temp->temp_buffer);
+}
+
+/**
+ * octeon_map_urb_for_dma - Octeon-specific map_urb_for_dma().
+ * @hcd:   USB HCD structure.
+ * @urb:   URB.
+ * @mem_flags: Memory allocation flags.
+ */
+static int octeon_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
+ gfp_t mem_flags)
+{
+   int ret;
+
+   ret = octeon_alloc_temp_buffer(urb, mem_flags);
+   if (ret)
+   return ret;
+
+   ret = usb_hcd_map_urb_for_dma(hcd, urb, mem_flags);
+   if (ret)
+   octeon_free_temp_buffer(urb);
+
+   return ret;
+}
+
+/**
+ * octeon_unmap_urb_for_dma - Octeon-specific unmap_urb_for_dma()
+ * @hcd:   USB HCD structure.
+ * @urb:   URB.
+ */
+static void octeon_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
+{
+   usb_hcd_unmap_urb_for_dma(hcd, urb);
+   octeon_free_temp_buffer(urb);
+}
+
+/**
  * Read a USB 32bit CSR. It performs the necessary address swizzle
  * for 32bit CSRs and logs the value in a readable format if
  * debugging is on.
@@ -3369,6 +3475,8 @@ static const struct hc_driver octeon_hc_driver = {
.get_frame_number   = octeon_usb_get_frame_number,
.hub_status_data= octeon_usb_hub_status_data,
.hub_control= octeon_usb_hub_control,
+   .map_urb_for_dma= 

Re: usbnet: driver_info->stop required to stop USB interrupts?

2014-03-19 Thread Grant Grundler
On Tue, Mar 18, 2014 at 6:40 PM, Grant Grundler  wrote:
> On Tue, Mar 18, 2014 at 6:09 PM, Julius Werner  wrote:
>> I think a better place for this would be in usbnet_probe() (together
>> with all the other dev->xxx initialization).
>
> Definitely better.
>
> @@ -1536,6 +1536,7 @@ usbnet_probe (struct usb_interface *udev, const struct 
> usb
> dev->driver_name = name;
> dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
> | NETIF_MSG_PROBE | NETIF_MSG_LINK);
> +   init_waitqueue_head(&dev->wait);
> skb_queue_head_init (&dev->rxq);
> skb_queue_head_init (&dev->txq);
> skb_queue_head_init (&dev->done);

Oliver,
So even with this additional change to usbnet_probe, the device is
reporting a link but can't transmit packets.
I've tried with three different USB dongles (AX88178, AX88772B, SMSC75xx).

In the last case, I ran "ifconfig eth0 192.168.1.100" and then tried
to ping 192.168.1.1. "ifconfig eth0" then reports "RX packets 0 bytes
0" and "TX packets 0 bytes 10796". The TX packets != bytes seems odd
and suggests (to me) that data getting discarded someplace in the
stack. I confirmed by running tcpdump on the other end of the link
(192.168.1.1 side) and got nothing from 192.168.1.100.

I believe the "10796" TX bytes is due to the connection manager
"trying really hard" to get an IP address (via DHCP).

Your patch looks like it should work. But it's missing something and I
don't have a clue what it is. Ideas?

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


Re: [PATCH 1/2] coding style: fix quoted string split across lines

2014-03-19 Thread Greg Kroah-Hartman
On Wed, Mar 19, 2014 at 11:04:56PM +0100, Cédric Cabessa wrote:
> Signed-off-by: Cédric Cabessa 

In the future, please pick a subject line that says what part of the
kernel you are changing.  For example, this patch would be:
staging: usbip: fix quoted string split across lines

I'll fix these 2 up but in the future, please be more explicit.

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/2] extcon: of: Remove unnecessary function call by using the name of device_node

2014-03-19 Thread Chanwoo Choi
Hi,

On 03/19/2014 09:08 PM, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Tuesday 18 March 2014 05:34 PM, Chanwoo Choi wrote:
>> This patch remove unnecessary function call in of_extcon_get_extcon_dev()
>> by using the name of device_node structure.
>>
>> Signed-off-by: Chanwoo Choi 
>> ---
>>  drivers/extcon/of_extcon.c | 12 ++--
>>  1 file changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
>> index 72173ec..0a29f82 100644
>> --- a/drivers/extcon/of_extcon.c
>> +++ b/drivers/extcon/of_extcon.c
>> @@ -32,7 +32,6 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct device 
>> *dev, int index)
>>  {
>>  struct device_node *node;
>>  struct extcon_dev *edev;
>> -struct platform_device *extcon_parent_dev;
>>  
>>  if (!dev->of_node) {
>>  dev_dbg(dev, "device does not have a device node entry\n");
>> @@ -46,16 +45,9 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct device 
>> *dev, int index)
>>  return ERR_PTR(-ENODEV);
>>  }
>>  
>> -extcon_parent_dev = of_find_device_by_node(node);
>> -if (!extcon_parent_dev) {
>> -dev_dbg(dev, "unable to find device by node\n");
>> -return ERR_PTR(-EPROBE_DEFER);
>> -}
>> -
>> -edev = extcon_get_extcon_dev(dev_name(&extcon_parent_dev->dev));
>> +edev = extcon_get_extcon_dev(node->name);
> 
> Since you no longer want to use device names I think you should add this too 
> to
> warn users if they rely on using the device name.

Previous of_extcon_get_extcon_dev() support only platform device using 
of_find_device_by_node.

If extcon device is based on i2c/spi/pci and so on, of_extcon_get_extcon_dev() 
can't
find device instance for device name. So, I change device name from the name of 
platform device
to the name of dt node.


> diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
> index bc4c789..025eb39 100644
> --- a/drivers/extcon/extcon-class.c
> +++ b/drivers/extcon/extcon-class.c
> @@ -601,7 +601,6 @@ int extcon_dev_register(struct extcon_dev *edev)
> edev->dev.class = extcon_class;
> edev->dev.release = extcon_dev_release;
> 
> -   edev->name = edev->name ? edev->name : dev_name(edev->dev.parent);
> //The user should always pass the 'name' as we no longer use device name while
> getting extcon device. And this name should also be the 'node' name?
> if (IS_ERR_OR_NULL(edev->name)) {
> dev_err(&edev->dev,
> "extcon device name is null\n");
> 
> Btw changing to node name from device name breaks dwc3 in OMAP5 and you would
> need this too..
> 
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index 2aea4bc..cea8cd3 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -188,6 +188,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
> 
> palmas_usb->edev.supported_cable = palmas_extcon_cable;
> palmas_usb->edev.dev.parent = palmas_usb->dev;
> +   palmas_usb->edev.name = "palmas_usb";
> palmas_usb->edev.mutually_exclusive = mutually_exclusive;
> 
> status = extcon_dev_register(&palmas_usb->edev);
> 
> Cheers
> Kishon
> 

If node name is same as extcon device name, don't need some modification.
Also, you can modify node name in some OMAP dts file insead of modification of 
extcon-palmas.c

Thanks,
Chanwoo Choi


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


Re: [PATCH 1/2] extcon: of: Remove unnecessary function call by using the name of device_node

2014-03-19 Thread Kishon Vijay Abraham I
Hi,

On Thursday 20 March 2014 07:52 AM, Chanwoo Choi wrote:
> Hi,
> 
> On 03/19/2014 09:08 PM, Kishon Vijay Abraham I wrote:
>> Hi,
>>
>> On Tuesday 18 March 2014 05:34 PM, Chanwoo Choi wrote:
>>> This patch remove unnecessary function call in of_extcon_get_extcon_dev()
>>> by using the name of device_node structure.
>>>
>>> Signed-off-by: Chanwoo Choi 
>>> ---
>>>  drivers/extcon/of_extcon.c | 12 ++--
>>>  1 file changed, 2 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
>>> index 72173ec..0a29f82 100644
>>> --- a/drivers/extcon/of_extcon.c
>>> +++ b/drivers/extcon/of_extcon.c
>>> @@ -32,7 +32,6 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct device 
>>> *dev, int index)
>>>  {
>>> struct device_node *node;
>>> struct extcon_dev *edev;
>>> -   struct platform_device *extcon_parent_dev;
>>>  
>>> if (!dev->of_node) {
>>> dev_dbg(dev, "device does not have a device node entry\n");
>>> @@ -46,16 +45,9 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct 
>>> device *dev, int index)
>>> return ERR_PTR(-ENODEV);
>>> }
>>>  
>>> -   extcon_parent_dev = of_find_device_by_node(node);
>>> -   if (!extcon_parent_dev) {
>>> -   dev_dbg(dev, "unable to find device by node\n");
>>> -   return ERR_PTR(-EPROBE_DEFER);
>>> -   }
>>> -
>>> -   edev = extcon_get_extcon_dev(dev_name(&extcon_parent_dev->dev));
>>> +   edev = extcon_get_extcon_dev(node->name);
>>
>> Since you no longer want to use device names I think you should add this too 
>> to
>> warn users if they rely on using the device name.
> 
> Previous of_extcon_get_extcon_dev() support only platform device using 
> of_find_device_by_node.
> 
> If extcon device is based on i2c/spi/pci and so on, 
> of_extcon_get_extcon_dev() can't
> find device instance for device name. So, I change device name from the name 
> of platform device
> to the name of dt node.

That's fine. But we have to fix extcon_dev_register() too, to not use device
names right? We have to warn extcon users not to use device names right?
> 
> 
>> diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
>> index bc4c789..025eb39 100644
>> --- a/drivers/extcon/extcon-class.c
>> +++ b/drivers/extcon/extcon-class.c
>> @@ -601,7 +601,6 @@ int extcon_dev_register(struct extcon_dev *edev)
>> edev->dev.class = extcon_class;
>> edev->dev.release = extcon_dev_release;
>>
>> -   edev->name = edev->name ? edev->name : dev_name(edev->dev.parent);
>> //The user should always pass the 'name' as we no longer use device name 
>> while
>> getting extcon device. And this name should also be the 'node' name?
>> if (IS_ERR_OR_NULL(edev->name)) {
>> dev_err(&edev->dev,
>> "extcon device name is null\n");
>>
>> Btw changing to node name from device name breaks dwc3 in OMAP5 and you would
>> need this too..
>>
>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>> index 2aea4bc..cea8cd3 100644
>> --- a/drivers/extcon/extcon-palmas.c
>> +++ b/drivers/extcon/extcon-palmas.c
>> @@ -188,6 +188,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>
>> palmas_usb->edev.supported_cable = palmas_extcon_cable;
>> palmas_usb->edev.dev.parent = palmas_usb->dev;
>> +   palmas_usb->edev.name = "palmas_usb";
>> palmas_usb->edev.mutually_exclusive = mutually_exclusive;
>>
>> status = extcon_dev_register(&palmas_usb->edev);
>>
>> Cheers
>> Kishon
>>
> 
> If node name is same as extcon device name, don't need some modification.
> Also, you can modify node name in some OMAP dts file insead of modification 
> of extcon-palmas.c

node name in OMAP dts is already 'palmas_usb'. But since we were not setting
'edev.name' in extcon-palmas.c, extcon_dev_register used device name of palmas
(palmas_usb.7 in my case). So extcon-palmas.c needs the fix.

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


RE: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in platform device id

2014-03-19 Thread suresh.gu...@freescale.com
Ignore last mail, was not intended for you. 

> -Original Message-
> From: Gupta Suresh-B42813
> Sent: Wednesday, March 19, 2014 11:33 PM
> To: 'gre...@linuxfoundation.org'
> Cc: ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: RE: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> platform device id
> 
> Hi Ramneek,
> 
> Do you understand, what Greg want to communicate.
> 
> 
> Thanks
> SuresH
> 
> > -Original Message-
> > From: gre...@linuxfoundation.org [mailto:gre...@linuxfoundation.org]
> > Sent: Wednesday, March 19, 2014 10:22 PM
> > To: Gupta Suresh-B42813
> > Cc: ba...@ti.com; linux-usb@vger.kernel.org;
> > linux-ker...@vger.kernel.org
> > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > platform device id
> >
> > On Wed, Mar 19, 2014 at 02:25:25PM +, suresh.gu...@freescale.com
> > wrote:
> > > Hi
> > >
> > > > -Original Message-
> > > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > > Sent: Saturday, March 15, 2014 7:10 AM
> > > > To: Gupta Suresh-B42813
> > > > Cc: ba...@ti.com; gre...@linuxfoundation.org;
> > > > linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
> > > > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry in
> > > > platform device id
> > > >
> > > > On Fri, Mar 14, 2014 at 08:52:19PM +,
> > > > suresh.gu...@freescale.com
> > > > wrote:
> > > > > Hi,
> > > > > Thanks for reviewing my patches.
> > > > > Please find my comments inline
> > > > >
> > > > > -Original Message-
> > > > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > > > Sent: Thursday, March 13, 2014 8:56 PM
> > > > > To: Gupta Suresh-B42813
> > > > > Cc: ba...@ti.com; gre...@linuxfoundation.org;
> > > > > linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org; Gupta
> > > > > Suresh-B42813
> > > > > Subject: Re: [PATCH] usb: gadget: fsl: Add FSL USB Gadget entry
> > > > > in platform device id
> > > > >
> > > > > On Thu, Mar 13, 2014 at 07:35:31PM +0530, Suresh Gupta wrote:
> > > > > > From: Suresh Gupta 
> > > > > >
> > > > > > Add FSL USB Gadget entry in platform device id table
> > > > >
> > > > > why this tab ?
> > > > > [SuresH] I will remove it in next version.
> > > > >
> > > > > > Signed-off-by: Suresh Gupta 
> > > > > > ---
> > > > > >  drivers/usb/gadget/fsl_udc_core.c | 2 ++
> > > > > >  1 file changed, 2 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/usb/gadget/fsl_udc_core.c
> > > > > > b/drivers/usb/gadget/fsl_udc_core.c
> > > > > > index b7dea4e..35b20e6 100644
> > > > > > --- a/drivers/usb/gadget/fsl_udc_core.c
> > > > > > +++ b/drivers/usb/gadget/fsl_udc_core.c
> > > > > > @@ -2654,6 +2654,8 @@ static const struct platform_device_id
> > > > fsl_udc_devtype[] = {
> > > > > > }, {
> > > > > > .name = "imx-udc-mx51",
> > > > > > }, {
> > > > > > +   .name = "fsl-usb2-udc",
> > > > >
> > > > > why aren't you just using chipidea ?
> > > > > [SuresH] This is our legacy driver for all previous and existing
> > > > > ppc socs. Many of our customers are already using this, and we
> > > > > need to support them on this driver. We do have plans to shift
> > > > > to chipidea, but after some time.
> > > >
> > > > cool, you already have plans, so we will see a new glue layer for
> > > > v3.16 right ? Which means I don't need to take this patch either.
> > > >
> > > we do have plans, but in remote future. Right now, we need to
> > > support customers on the present legacy driver. We'll phase out this
> > > driver slowly when we integrate chipidea. At this time I would
> > > request you to please accept this patch
> >
> > Even if Felipe takes the patch, I'll reject it as you should be doing
> > the correct thing here, and if it's accepted, it will never be
> changed...
> >
> > 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/2] extcon: of: Remove unnecessary function call by using the name of device_node

2014-03-19 Thread Chanwoo Choi
Hi,

On 03/20/2014 02:20 PM, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Thursday 20 March 2014 07:52 AM, Chanwoo Choi wrote:
>> Hi,
>>
>> On 03/19/2014 09:08 PM, Kishon Vijay Abraham I wrote:
>>> Hi,
>>>
>>> On Tuesday 18 March 2014 05:34 PM, Chanwoo Choi wrote:
 This patch remove unnecessary function call in of_extcon_get_extcon_dev()
 by using the name of device_node structure.

 Signed-off-by: Chanwoo Choi 
 ---
  drivers/extcon/of_extcon.c | 12 ++--
  1 file changed, 2 insertions(+), 10 deletions(-)

 diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
 index 72173ec..0a29f82 100644
 --- a/drivers/extcon/of_extcon.c
 +++ b/drivers/extcon/of_extcon.c
 @@ -32,7 +32,6 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct 
 device *dev, int index)
  {
struct device_node *node;
struct extcon_dev *edev;
 -  struct platform_device *extcon_parent_dev;
  
if (!dev->of_node) {
dev_dbg(dev, "device does not have a device node entry\n");
 @@ -46,16 +45,9 @@ struct extcon_dev *of_extcon_get_extcon_dev(struct 
 device *dev, int index)
return ERR_PTR(-ENODEV);
}
  
 -  extcon_parent_dev = of_find_device_by_node(node);
 -  if (!extcon_parent_dev) {
 -  dev_dbg(dev, "unable to find device by node\n");
 -  return ERR_PTR(-EPROBE_DEFER);
 -  }
 -
 -  edev = extcon_get_extcon_dev(dev_name(&extcon_parent_dev->dev));
 +  edev = extcon_get_extcon_dev(node->name);
>>>
>>> Since you no longer want to use device names I think you should add this 
>>> too to
>>> warn users if they rely on using the device name.
>>
>> Previous of_extcon_get_extcon_dev() support only platform device using 
>> of_find_device_by_node.
>>
>> If extcon device is based on i2c/spi/pci and so on, 
>> of_extcon_get_extcon_dev() can't
>> find device instance for device name. So, I change device name from the name 
>> of platform device
>> to the name of dt node.
> 
> That's fine. But we have to fix extcon_dev_register() too, to not use device
> names right? We have to warn extcon users not to use device names right?

I don't think so. extcon_get_edev_by_phandle() shows wrong node->name as 
following:
The consumer could detect the cause of problem which can't get extcon device 
after
checking error log message.

edev = extcon_get_extcon_dev(node->name);
if (!edev) {
dev_err(dev, "unable to get extcon device : %s\n", node->name);
return ERR_PTR(-ENODEV);
}

I don't want to add more log message.

>>
>>
>>> diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
>>> index bc4c789..025eb39 100644
>>> --- a/drivers/extcon/extcon-class.c
>>> +++ b/drivers/extcon/extcon-class.c
>>> @@ -601,7 +601,6 @@ int extcon_dev_register(struct extcon_dev *edev)
>>> edev->dev.class = extcon_class;
>>> edev->dev.release = extcon_dev_release;
>>>
>>> -   edev->name = edev->name ? edev->name : dev_name(edev->dev.parent);
>>> //The user should always pass the 'name' as we no longer use device name 
>>> while
>>> getting extcon device. And this name should also be the 'node' name?
>>> if (IS_ERR_OR_NULL(edev->name)) {
>>> dev_err(&edev->dev,
>>> "extcon device name is null\n");
>>>
>>> Btw changing to node name from device name breaks dwc3 in OMAP5 and you 
>>> would
>>> need this too..
>>>
>>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>>> index 2aea4bc..cea8cd3 100644
>>> --- a/drivers/extcon/extcon-palmas.c
>>> +++ b/drivers/extcon/extcon-palmas.c
>>> @@ -188,6 +188,7 @@ static int palmas_usb_probe(struct platform_device 
>>> *pdev)
>>>
>>> palmas_usb->edev.supported_cable = palmas_extcon_cable;
>>> palmas_usb->edev.dev.parent = palmas_usb->dev;
>>> +   palmas_usb->edev.name = "palmas_usb";
>>> palmas_usb->edev.mutually_exclusive = mutually_exclusive;
>>>
>>> status = extcon_dev_register(&palmas_usb->edev);
>>>
>>> Cheers
>>> Kishon
>>>
>>
>> If node name is same as extcon device name, don't need some modification.
>> Also, you can modify node name in some OMAP dts file insead of modification 
>> of extcon-palmas.c
> 
> node name in OMAP dts is already 'palmas_usb'. But since we were not setting
> 'edev.name' in extcon-palmas.c, extcon_dev_register used device name of palmas
> (palmas_usb.7 in my case). So extcon-palmas.c needs the fix.

For example,
I used extcon provider/consumer driver in dts as following:
extcon-max14577.c set device name as edev->name and then dt node name of 
max14577
set "max14577-muic" which is same as device name(dev_name(&pdev->dev)).

I don't need to modify extcon-max14577.c

In drivers/extcon/extcon-max14577.c
...
info->edev->name = dev_name(&pdev->dev);
...
In dts.
i2c@1388 {