[PATCH 3/3] usb: core: lpm: remove usb3_lpm_enabled in usb_device

2015-11-11 Thread Lu Baolu
Commit 8306095fd2c1 ("USB: Disable USB 3.0 LPM in critical sections.")
adds usb3_lpm_enabled member to struct usb_device. There is no reference
to this member now. Hence, it could be removed.

Signed-off-by: Lu Baolu 
---
 include/linux/usb.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 211664f..036e4a5 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -583,7 +583,6 @@ struct usb_device {
unsigned usb2_hw_lpm_besl_capable:1;
unsigned usb2_hw_lpm_enabled:1;
unsigned usb2_hw_lpm_allowed:1;
-   unsigned usb3_lpm_enabled:1;
unsigned usb3_lpm_u1_enabled:1;
unsigned usb3_lpm_u2_enabled:1;
int string_langid;
-- 
2.1.4

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


[PATCH 0/3] usb: core: lpm: add sysfs node for usb3 lpm permit

2015-11-11 Thread Lu Baolu
Hi,

This patch series is about to add a sysfs attribute, through which
users can disable or enable USB3 LPM (link power management) from
a USB port. Once LPM is disabled from the USB port, LPM between the
downstreaming device and the hub port will not be activated. This
helps users to use any LPM-unfriendly USB devices on any released
Linux kernels.

This patch series contains a fix and a cleanup as well.

Thanks,
Baolu

Lu Baolu (3):
  usb: core: lpm: fix usb3_hardware_lpm sysfs node
  usb: core: lpm: add sysfs node for usb3 lpm permit
  usb: core: lpm: remove usb3_lpm_enabled in usb_device

 Documentation/ABI/testing/sysfs-bus-usb | 27 +++---
 Documentation/usb/power-management.txt  | 11 ++--
 drivers/usb/core/hub.c  | 33 +---
 drivers/usb/core/hub.h  |  5 +-
 drivers/usb/core/port.c | 89 -
 drivers/usb/core/sysfs.c| 31 ++--
 include/linux/usb.h |  3 +-
 7 files changed, 172 insertions(+), 27 deletions(-)

-- 
2.1.4

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


[PATCH 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node

2015-11-11 Thread Lu Baolu
Commit 655fe4effe0f ("usbcore: add sysfs support to xHCI usb3
hardware LPM") introduced usb3_hardware_lpm sysfs node. This
doesn't show the correct status of USB3 U1 and U2 LPM status.

This patch fixes this by replacing usb3_hardware_lpm with two
nodes, usb3_hardware_lpm_u1 (for U1) and usb3_hardware_lpm_u2
(for U2), and recording the U1/U2 LPM status in right places.

This patch should be back-ported to kernels as old as 4.3,
that contains Commit 655fe4effe0f ("usbcore: add sysfs support
to xHCI usb3 hardware LPM").

Cc: sta...@vger.kernel.org
Signed-off-by: Lu Baolu 
---
 Documentation/ABI/testing/sysfs-bus-usb | 16 +---
 Documentation/usb/power-management.txt  | 11 ++-
 drivers/usb/core/hub.c  | 20 ++--
 drivers/usb/core/sysfs.c| 31 ++-
 include/linux/usb.h |  2 ++
 5 files changed, 57 insertions(+), 23 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 3a4abfc..136ba17 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -134,19 +134,21 @@ Description:
enabled for the device. Developer can write y/Y/1 or n/N/0 to
the file to enable/disable the feature.
 
-What:  /sys/bus/usb/devices/.../power/usb3_hardware_lpm
-Date:  June 2015
+What:  /sys/bus/usb/devices/.../power/usb3_hardware_lpm_u1
+   /sys/bus/usb/devices/.../power/usb3_hardware_lpm_u2
+Date:  November 2015
 Contact:   Kevin Strasser 
+   Lu Baolu 
 Description:
If CONFIG_PM is set and a USB 3.0 lpm-capable device is plugged
in to a xHCI host which supports link PM, it will check if U1
and U2 exit latencies have been set in the BOS descriptor; if
-   the check is is passed and the host supports USB3 hardware LPM,
+   the check is passed and the host supports USB3 hardware LPM,
USB3 hardware LPM will be enabled for the device and the USB
-   device directory will contain a file named
-   power/usb3_hardware_lpm. The file holds a string value (enable
-   or disable) indicating whether or not USB3 hardware LPM is
-   enabled for the device.
+   device directory will contain two files named
+   power/usb3_hardware_lpm_u1 and power/usb3_hardware_lpm_u2. These
+   files hold a string value (enable or disable) indicating whether
+   or not USB3 hardware LPM U1 or U2 is enabled for the device.
 
 What:  /sys/bus/usb/devices/.../removable
 Date:  February 2012
diff --git a/Documentation/usb/power-management.txt 
b/Documentation/usb/power-management.txt
index 4a15c90..0a94ffe 100644
--- a/Documentation/usb/power-management.txt
+++ b/Documentation/usb/power-management.txt
@@ -537,17 +537,18 @@ relevant attribute files are usb2_hardware_lpm and 
usb3_hardware_lpm.
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.
 
-   power/usb3_hardware_lpm
+   power/usb3_hardware_lpm_u1
+   power/usb3_hardware_lpm_u2
 
When a USB 3.0 lpm-capable device is plugged in to a
xHCI host which supports link PM, it will check if U1
and U2 exit latencies have been set in the BOS
descriptor; if the check is is passed and the host
supports USB3 hardware LPM, USB3 hardware LPM will be
-   enabled for the device and this file will be created.
-   The file holds a string value (enable or disable)
-   indicating whether or not USB3 hardware LPM is
-   enabled for the device.
+   enabled for the device and these files will be created.
+   The files hold a string value (enable or disable)
+   indicating whether or not USB3 hardware LPM U1 or U2
+   is enabled for the device.
 
USB Port Power Control
--
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bdeadc1..4eb7369 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3875,17 +3875,23 @@ static void usb_enable_link_state(struct usb_hcd *hcd, 
struct usb_device *udev,
return;
}
 
-   if (usb_set_lpm_timeout(udev, state, timeout))
+   ret = usb_set_lpm_timeout(udev, state, timeout);
+   if (ret)
/* If we can't set the parent hub U1/U2 timeout,
 * device-initiated LPM won't be allowed either, so let the xHCI
 * host know that this link state won't be enabled.
 */
hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state);
-
/* Only a configured device will acc

[PATCH 2/3] usb: core: lpm: add sysfs node for usb3 lpm permit

2015-11-11 Thread Lu Baolu
USB3 LPM is default on in Linux kernel if both xHCI host controller
and the USB devices declare to be LPM-capable. Unfortunately, some
devices are known to work well with LPM disabled, but to be broken
if LPM is enabled, although it declares the LPM capability.  Users
won't be able to use this kind of devices, until someone puts them
in the kernel blacklist and gets the kernel upgraded.

This patch adds a sysfs node to permit or forbit USB3 LPM U1 or U2
entry for a port. The settings apply to both before and after device
enumeration. Supported values are "0" - neither u1 nor u2 permitted,
"u1" - only u1 is permitted, "u2" - only u2 is permitted, "u1_u2" -
both u1 and u2 are permitted. With this interface, users can use an
LPM-unfriendly USB device on a released Linux kernel.

Signed-off-by: Lu Baolu 
Signed-off-by: Zhuang Jin Can 
---
 Documentation/ABI/testing/sysfs-bus-usb | 11 
 drivers/usb/core/hub.c  | 15 +-
 drivers/usb/core/hub.h  |  5 +-
 drivers/usb/core/port.c | 89 -
 4 files changed, 116 insertions(+), 4 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 136ba17..0bd731c 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -189,6 +189,17 @@ Description:
The file will read "hotplug", "wired" and "not used" if the
information is available, and "unknown" otherwise.
 
+What:  /sys/bus/usb/devices/.../(hub interface)/portX/usb3_lpm_permit
+Date:  November 2015
+Contact:   Lu Baolu 
+Description:
+   Some USB3.0 devices are not friendly to USB3 LPM.  
usb3_lpm_permit
+   attribute allows enabling/disabling usb3 lpm of a port. It takes
+   effect both before and after a usb device is enumerated. 
Supported
+   values are "0" if both u1 and u2 are NOT permitted, "u1" if 
only u1
+   is permitted, "u2" if only u2 is permitted, "u1_u2" if both u1 
and
+   u2 are permitted.
+
 What:  /sys/bus/usb/devices/.../power/usb2_lpm_l1_timeout
 Date:  May 2013
 Contact:   Mathias Nyman 
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4eb7369..9df568e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4007,6 +4007,8 @@ EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm);
 void usb_enable_lpm(struct usb_device *udev)
 {
struct usb_hcd *hcd;
+   struct usb_hub *hub;
+   struct usb_port *port_dev;
 
if (!udev || !udev->parent ||
udev->speed != USB_SPEED_SUPER ||
@@ -4026,8 +4028,17 @@ void usb_enable_lpm(struct usb_device *udev)
if (udev->lpm_disable_count > 0)
return;
 
-   usb_enable_link_state(hcd, udev, USB3_LPM_U1);
-   usb_enable_link_state(hcd, udev, USB3_LPM_U2);
+   hub = usb_hub_to_struct_hub(udev->parent);
+   if (!hub)
+   return;
+
+   port_dev = hub->ports[udev->portnum - 1];
+
+   if (port_dev->usb3_lpm_u1_permit)
+   usb_enable_link_state(hcd, udev, USB3_LPM_U1);
+
+   if (port_dev->usb3_lpm_u2_permit)
+   usb_enable_link_state(hcd, udev, USB3_LPM_U2);
 }
 EXPORT_SYMBOL_GPL(usb_enable_lpm);
 
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 688817f..45d070d 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -92,6 +92,8 @@ struct usb_hub {
  * @status_lock: synchronize port_event() vs usb_port_{suspend|resume}
  * @portnum: port index num based one
  * @is_superspeed cache super-speed status
+ * @usb3_lpm_u1_permit: whether USB3 U1 LPM is permitted.
+ * @usb3_lpm_u2_permit: whether USB3 U2 LPM is permitted.
  */
 struct usb_port {
struct usb_device *child;
@@ -104,6 +106,8 @@ struct usb_port {
struct mutex status_lock;
u8 portnum;
unsigned int is_superspeed:1;
+   unsigned int usb3_lpm_u1_permit:1;
+   unsigned int usb3_lpm_u2_permit:1;
 };
 
 #define to_usb_port(_dev) \
@@ -155,4 +159,3 @@ static inline int hub_port_debounce_be_stable(struct 
usb_hub *hub,
 {
return hub_port_debounce(hub, port1, false);
 }
-
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 2106183..cb18ce0 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -50,6 +50,72 @@ static ssize_t connect_type_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(connect_type);
 
+static ssize_t usb3_lpm_permit_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   struct usb_port *port_dev = to_usb_port(dev);
+   const char *p;
+
+   if (port_dev->usb3_lpm_u1_permit) {
+   if (port_dev->usb3_lpm_u2_permit)
+   p = "u1_u2";
+   else
+   p = "u1";
+   } else {
+   if (port_dev->usb3_lpm_u2_per

[PATCH v4] USB: serial: add Moxa UPORT 11x0 driver

2015-11-11 Thread Mathieu OTHACEHE
Add a driver which supports :

- UPort 1110  : 1 port RS-232 USB to Serial Hub.
- UPort 1130  : 1 port RS-422/485 USB to Serial Hub.
- UPort 1130I : 1 port RS-422/485 USB to Serial Hub with Isolation.
- UPort 1150  : 1 port RS-232/422/485 USB to Serial Hub.
- UPort 1150I : 1 port RS-232/422/485 USB to Serial Hub with Isolation.

This driver is based on GPL MOXA driver written by Hen Huang and available
on MOXA website. The original driver was based on io_ti serial driver.

Signed-off-by: Mathieu OTHACEHE 
---
 drivers/usb/serial/Kconfig   |   16 +
 drivers/usb/serial/Makefile  |1 +
 drivers/usb/serial/mxu11x0.c | 1101 ++
 3 files changed, 1118 insertions(+)
 create mode 100644 drivers/usb/serial/mxu11x0.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 56ecb8b..f612dda 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -475,6 +475,22 @@ config USB_SERIAL_MOS7840
  To compile this driver as a module, choose M here: the
  module will be called mos7840.  If unsure, choose N.
 
+config USB_SERIAL_MXUPORT11
+   tristate "USB Moxa UPORT 11x0 Serial Driver"
+   ---help---
+ Say Y here if you want to use a MOXA UPort 11x0 Serial hub.
+
+ This driver supports:
+
+ - UPort 1110  : 1 port RS-232 USB to Serial Hub.
+ - UPort 1130  : 1 port RS-422/485 USB to Serial Hub.
+ - UPort 1130I : 1 port RS-422/485 USB to Serial Hub with Isolation.
+ - UPort 1150  : 1 port RS-232/422/485 USB to Serial Hub.
+ - UPort 1150I : 1 port RS-232/422/485 USB to Serial Hub with 
Isolation.
+
+ To compile this driver as a module, choose M here: the
+ module will be called mxu11x0.
+
 config USB_SERIAL_MXUPORT
tristate "USB Moxa UPORT Serial Driver"
---help---
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 349d9df..f3fa5e5 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_USB_SERIAL_METRO)+= 
metro-usb.o
 obj-$(CONFIG_USB_SERIAL_MOS7720)   += mos7720.o
 obj-$(CONFIG_USB_SERIAL_MOS7840)   += mos7840.o
 obj-$(CONFIG_USB_SERIAL_MXUPORT)   += mxuport.o
+obj-$(CONFIG_USB_SERIAL_MXUPORT11) += mxu11x0.o
 obj-$(CONFIG_USB_SERIAL_NAVMAN)+= navman.o
 obj-$(CONFIG_USB_SERIAL_OMNINET)   += omninet.o
 obj-$(CONFIG_USB_SERIAL_OPTICON)   += opticon.o
diff --git a/drivers/usb/serial/mxu11x0.c b/drivers/usb/serial/mxu11x0.c
new file mode 100644
index 000..af29526
--- /dev/null
+++ b/drivers/usb/serial/mxu11x0.c
@@ -0,0 +1,1101 @@
+/*
+ *
+ * USB Moxa UPORT 11x0 Serial Driver
+ *
+ * Copyright (C) 2007 MOXA Technologies Co., Ltd.
+ * Copyright (C) 2015 Mathieu Othacehe 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ *
+ * Supports the following Moxa USB to serial converters:
+ *  UPort 1110,  1 port RS-232 USB to Serial Hub.
+ *  UPort 1130,  1 port RS-422/485 USB to Serial Hub.
+ *  UPort 1130I, 1 port RS-422/485 USB to Serial Hub with isolation
+ *protection.
+ *  UPort 1150,  1 port RS-232/422/485 USB to Serial Hub.
+ *  UPort 1150I, 1 port RS-232/422/485 USB to Serial Hub with isolation
+ *  protection.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Vendor and product ids */
+#define MXU1_VENDOR_ID 0x110a
+#define MXU1_1110_PRODUCT_ID   0x1110
+#define MXU1_1130_PRODUCT_ID   0x1130
+#define MXU1_1150_PRODUCT_ID   0x1150
+#define MXU1_1151_PRODUCT_ID   0x1151
+#define MXU1_1131_PRODUCT_ID   0x1131
+
+/* Commands */
+#define MXU1_GET_VERSION   0x01
+#define MXU1_GET_PORT_STATUS   0x02
+#define MXU1_GET_PORT_DEV_INFO 0x03
+#define MXU1_GET_CONFIG0x04
+#define MXU1_SET_CONFIG0x05
+#define MXU1_OPEN_PORT 0x06
+#define MXU1_CLOSE_PORT0x07
+#define MXU1_START_PORT0x08
+#define MXU1_STOP_PORT 0x09
+#define MXU1_TEST_PORT 0x0A
+#define MXU1_PURGE_PORT0x0B
+#define MXU1_RESET_EXT_DEVICE  0x0C
+#define MXU1_GET_OUTQUEUE  0x0D
+#define MXU1_WRITE_DATA0x80
+#define MXU1_READ_DATA 0x81
+#define MXU1_REQ_TYPE_CLASS0x82
+

Re: [PATCH v5 6/7] usb: gadget: f_midi: set altsettings only for MIDIStreaming interface

2015-11-11 Thread Felipe Ferreri Tonello
Hi Sergei,

On 10/11/15 18:43, Sergei Shtylyov wrote:
> Hello.
> 
> On 11/10/2015 08:52 PM, Felipe F. Tonello wrote:
> 
>> This avoids duplication of USB requests for OUT endpoint and
>> re-enabling endpoints.
>>
>> Signed-off-by: Felipe F. Tonello 
>> ---
>>   drivers/usb/gadget/function/f_midi.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/function/f_midi.c
>> b/drivers/usb/gadget/function/f_midi.c
>> index 76ea53c..615d632 100644
>> --- a/drivers/usb/gadget/function/f_midi.c
>> +++ b/drivers/usb/gadget/function/f_midi.c
>> @@ -75,6 +75,7 @@ struct f_midi {
>>   struct usb_ep*in_ep, *out_ep;
>>   struct snd_card*card;
>>   struct snd_rawmidi*rmidi;
>> +u8ms_id;
> 
>   Why 'ms_id' is not aligned with the above field names?

It is actually aligned. Perhaps because of the +?

Here is from my local git diff:

--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -75,6 +75,7 @@ struct f_midi {
struct usb_ep   *in_ep, *out_ep;
struct snd_card *card;
struct snd_rawmidi  *rmidi;
+   u8  ms_id;

struct snd_rawmidi_substream *in_substream[MAX_PORTS];
struct snd_rawmidi_substream *out_substream[MAX_PORTS];


-- 
Felipe


0x92698E6A.asc
Description: application/pgp-keys


Re: [PATCH v4] USB: serial: add Moxa UPORT 11x0 driver

2015-11-11 Thread Johan Hovold
On Wed, Nov 11, 2015 at 10:35:47AM +0100, Mathieu OTHACEHE wrote:
> Add a driver which supports :
> 
> - UPort 1110  : 1 port RS-232 USB to Serial Hub.
> - UPort 1130  : 1 port RS-422/485 USB to Serial Hub.
> - UPort 1130I : 1 port RS-422/485 USB to Serial Hub with Isolation.
> - UPort 1150  : 1 port RS-232/422/485 USB to Serial Hub.
> - UPort 1150I : 1 port RS-232/422/485 USB to Serial Hub with Isolation.
> 
> This driver is based on GPL MOXA driver written by Hen Huang and available
> on MOXA website. The original driver was based on io_ti serial driver.
> 
> Signed-off-by: Mathieu OTHACEHE 
> ---

Thanks for the v4. It'll be a few days still before I have a chance to
review it.

What changed since v3 (and v2)?

Please include a summary of the changes below the cutoff line (i.e.
here) when you send a new revision of a patch.

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


Re: [PATCH 3/3] usb: core: lpm: remove usb3_lpm_enabled in usb_device

2015-11-11 Thread kbuild test robot
Hi Lu,

[auto build test WARNING on v4.3-rc7]
[also build test WARNING on next-2015]

url:
https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-core-lpm-add-sysfs-node-for-usb3-lpm-permit/2015-160805
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/linux/usb.h:614: warning: No description found for parameter 
'usb3_lpm_u1_enabled'
   include/linux/usb.h:614: warning: No description found for parameter 
'usb3_lpm_u2_enabled'
>> include/linux/usb.h:614: warning: Excess struct/union/enum/typedef member 
>> 'usb3_lpm_enabled' description in 'usb_device'

vim +614 include/linux/usb.h

f476fbab Randy Dunlap 2008-02-13  598   unsigned long active_duration;
15123006 Sarah Sharp  2007-12-21  599  
645daaab Alan Stern   2006-08-30  600  #ifdef CONFIG_PM
f476fbab Randy Dunlap 2008-02-13  601   unsigned long connect_time;
f476fbab Randy Dunlap 2008-02-13  602  
f476fbab Randy Dunlap 2008-02-13  603   unsigned do_remote_wakeup:1;
f476fbab Randy Dunlap 2008-02-13  604   unsigned reset_resume:1;
bfd1e910 Alan Stern   2012-10-19  605   unsigned port_is_suspended:1;
645daaab Alan Stern   2006-08-30  606  #endif
b1d8dfb0 Inaky Perez-Gonzalez 2008-04-08  607   struct wusb_dev *wusb_dev;
c6515272 Sarah Sharp  2009-04-27  608   int slot_id;
0846e7e9 Matthew Garrett  2012-02-03  609   enum usb_device_removable 
removable;
17f34867 Mathias Nyman2013-05-23  610   struct usb2_lpm_parameters 
l1_params;
51e0a012 Sarah Sharp  2012-02-20  611   struct usb3_lpm_parameters 
u1_params;
51e0a012 Sarah Sharp  2012-02-20  612   struct usb3_lpm_parameters 
u2_params;
1ea7e0e8 Sarah Sharp  2012-04-24  613   unsigned lpm_disable_count;
^1da177e Linus Torvalds   2005-04-16 @614  };
^1da177e Linus Torvalds   2005-04-16  615  #define  to_usb_device(d) 
container_of(d, struct usb_device, dev)
^1da177e Linus Torvalds   2005-04-16  616  
1e429018 Matthew Wilcox   2010-04-30  617  static inline struct usb_device 
*interface_to_usbdev(struct usb_interface *intf)
1e429018 Matthew Wilcox   2010-04-30  618  {
1e429018 Matthew Wilcox   2010-04-30  619   return 
to_usb_device(intf->dev.parent);
1e429018 Matthew Wilcox   2010-04-30  620  }
1e429018 Matthew Wilcox   2010-04-30  621  
^1da177e Linus Torvalds   2005-04-16  622  extern struct usb_device 
*usb_get_dev(struct usb_device *dev);

:: The code at line 614 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH v3 0/5] usb: usbtmc: Add support for missing functions in USBTMC-USB488 spec

2015-11-11 Thread Dave Penkler
Implement support for the USB488 defined READ_STATUS_BYTE ioctl (1/5)
and SRQ notifications with fasync (2/5) and poll/select (3/5) in order
to be able to synchronize with variable duration instrument operations.

Add ioctls for other USB488 requests: REN_CONTROL, GOTO_LOCAL and
LOCAL_LOCKOUT. (4/5)

Add convenience ioctl to return all device capabilities (5/5)

 PATCH Changelog:

v3 - Split into multiple patches as per gregkh request

V2 - Fix V1 bug: not waking sleepers on disconnect.
   - Correct sparse warnings.

V1 - Original patch

 Testing:
All functions tested ok on an USBTMC-USB488 compliant oscilloscope

Dave Penkler (5):
  Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE
operation.
  Add support for USBTMC USB488 SRQ notification with fasync
  Add support for receiving USBTMC USB488 SRQ notifications via
poll/select
  Add ioctl to retrieve USBTMC-USB488 capabilities
  Add ioctls to enable and disable local controls on an instrument

 drivers/usb/class/usbtmc.c   | 358 +++
 include/uapi/linux/usb/tmc.h |  30 +++-
 2 files changed, 385 insertions(+), 3 deletions(-)

-- 
2.5.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 v3 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.

2015-11-11 Thread Dave Penkler
Background:
When performing a read on an instrument that is executing a function
that runs longer than the USB timeout the instrument may hang and require
a device reset to recover. The READ_STATUS_BYTE operation always returns
even when the instrument is busy permitting to poll for the appropriate
condition. This capability is refered to in instrument application notes
on synchronizing acquisitions for other platforms.

Signed-off-by: Dave Penkler 
---
 drivers/usb/class/usbtmc.c   | 223 +++
 include/uapi/linux/usb/tmc.h |   2 +
 2 files changed, 225 insertions(+)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 7a11a82..c1593e7 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -87,6 +87,20 @@ struct usbtmc_device_data {
u8 bTag_last_write; /* needed for abort */
u8 bTag_last_read;  /* needed for abort */
 
+
+   /* data for interrupt in endpoint handling */
+   u8 bNotify1;
+   u8 bNotify2;
+   u16ifnum;
+   u8 iin_bTag;
+   u8*iin_buffer;
+   atomic_t   iin_data_valid;
+   unsigned int   iin_ep;
+   intiin_ep_present;
+   intiin_interval;
+   struct urb*iin_urb;
+   u16iin_wMaxPacketSize;
+
u8 rigol_quirk;
 
/* attributes from the USB TMC spec for this device */
@@ -99,6 +113,7 @@ struct usbtmc_device_data {
struct usbtmc_dev_capabilities  capabilities;
struct kref kref;
struct mutex io_mutex;  /* only one i/o function running at a time */
+   wait_queue_head_t waitq;
 };
 #define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref)
 
@@ -373,6 +388,91 @@ exit:
return rv;
 }
 
+static int usbtmc488_ioctl_read_stb(struct usbtmc_device_data *data,
+   unsigned long arg)
+{
+   u8 *buffer;
+   struct device *dev;
+   int rv;
+   u8 tag, stb;
+
+   dev = &data->intf->dev;
+
+   dev_dbg(dev, "Enter ioctl_read_stb iin_ep_present: %d\n",
+   data->iin_ep_present);
+
+   buffer = kmalloc(8, GFP_KERNEL);
+   if (!buffer)
+   return -ENOMEM;
+
+
+   atomic_set(&data->iin_data_valid, 0);
+
+   rv = usb_control_msg(data->usb_dev,
+   usb_rcvctrlpipe(data->usb_dev, 0),
+   USBTMC488_REQUEST_READ_STATUS_BYTE,
+   USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+   data->iin_bTag,
+   data->ifnum,
+   buffer, 0x03, USBTMC_TIMEOUT);
+
+   if (rv < 0) {
+   dev_err(dev, "stb usb_control_msg returned %d\n", rv);
+   goto exit;
+   }
+
+   if (buffer[0] != USBTMC_STATUS_SUCCESS) {
+   dev_err(dev, "control status returned %x\n",
+   buffer[0]);
+   rv = -EIO;
+   goto exit;
+   }
+
+   if (data->iin_ep_present) {
+
+   rv = wait_event_interruptible_timeout(
+   data->waitq,
+   (atomic_read(&data->iin_data_valid) != 0),
+   USBTMC_TIMEOUT
+   );
+
+   if (rv < 0) {
+   dev_dbg(dev, "wait interrupted %d\n", rv);
+   goto exit;
+   }
+
+   if (rv == 0) {
+   dev_dbg(dev, "wait timed out\n");
+   rv = -ETIME;
+   goto exit;
+   }
+
+   tag = data->bNotify1 & 0x7f;
+
+   if (tag != data->iin_bTag) {
+   dev_err(dev, "expected bTag %x got %x\n",
+   data->iin_bTag, tag);
+   }
+
+   stb = data->bNotify2;
+   } else {
+   stb = buffer[2];
+   }
+
+   rv = copy_to_user((void __user *)arg, &stb, sizeof(stb));
+   if (rv)
+   rv = -EFAULT;
+
+ exit:
+   /* bump interrupt bTag */
+   data->iin_bTag += 1;
+   if (data->iin_bTag > 127)
+   data->iin_bTag = 2;
+
+   kfree(buffer);
+   return rv;
+}
+
 /*
  * Sends a REQUEST_DEV_DEP_MSG_IN message on the Bulk-IN endpoint.
  * @transfer_size: number of bytes to request from the device.
@@ -1069,6 +1169,11 @@ static long usbtmc_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
case USBTMC_IOCTL_ABORT_BULK_IN:
retval = usbtmc_ioctl_abort_bulk_in(data);
break;
+
+   case USBTMC488_IOCTL_READ_STB:
+   retval = usbtmc488_ioctl_read_stb(data, arg);
+   break;
+
}
 
 skip_io_on_zombie:
@@ -1092,6 +1197,69 @@ static struct usb_class_driver usbtmc_class = {
.minor_base =   USBTMC_MINOR_BASE,
 };
 
+static void usbtmc_interrupt(struct urb *urb)
+{
+   struct u

[PATCH v3 2/5] Add support for USBTMC USB488 SRQ notification with fasync

2015-11-11 Thread Dave Penkler
Background:
By configuring an instrument's event status register various conditions
can be reported via an SRQ notification. This complements the synchronous
polling approach using the READ_STATUS_BYTE ioctl with an asynchronous
notification.

Signed-off-by: Dave Penkler 
---
 drivers/usb/class/usbtmc.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index c1593e7..2239cd0 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -100,6 +100,7 @@ struct usbtmc_device_data {
intiin_interval;
struct urb*iin_urb;
u16iin_wMaxPacketSize;
+   atomic_t   srq_asserted;
 
u8 rigol_quirk;
 
@@ -114,6 +115,7 @@ struct usbtmc_device_data {
struct kref kref;
struct mutex io_mutex;  /* only one i/o function running at a time */
wait_queue_head_t waitq;
+   struct fasync_struct *fasync;
 };
 #define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref)
 
@@ -408,6 +410,9 @@ static int usbtmc488_ioctl_read_stb(struct 
usbtmc_device_data *data,
 
atomic_set(&data->iin_data_valid, 0);
 
+   /* must issue read_stb before using poll or select */
+   atomic_set(&data->srq_asserted, 0);
+
rv = usb_control_msg(data->usb_dev,
usb_rcvctrlpipe(data->usb_dev, 0),
USBTMC488_REQUEST_READ_STATUS_BYTE,
@@ -1181,6 +1186,13 @@ skip_io_on_zombie:
return retval;
 }
 
+static int usbtmc_fasync(int fd, struct file *file, int on)
+{
+   struct usbtmc_device_data *data = file->private_data;
+
+   return fasync_helper(fd, file, on, &data->fasync);
+}
+
 static const struct file_operations fops = {
.owner  = THIS_MODULE,
.read   = usbtmc_read,
@@ -1188,6 +1200,7 @@ static const struct file_operations fops = {
.open   = usbtmc_open,
.release= usbtmc_release,
.unlocked_ioctl = usbtmc_ioctl,
+   .fasync = usbtmc_fasync,
.llseek = default_llseek,
 };
 
@@ -1218,6 +1231,16 @@ static void usbtmc_interrupt(struct urb *urb)
wake_up_interruptible(&data->waitq);
goto exit;
}
+   /* check for SRQ notification */
+   if ((data->iin_buffer[0] & 0x7f) == 1) {
+   if (data->fasync)
+   kill_fasync(&data->fasync,
+   SIGIO, POLL_IN);
+
+   atomic_set(&data->srq_asserted, 1);
+   wake_up_interruptible(&data->waitq);
+   goto exit;
+   }
}
dev_warn(&data->intf->dev, "invalid notification: %x\n",
data->iin_buffer[0]);
@@ -1284,6 +1307,7 @@ static int usbtmc_probe(struct usb_interface *intf,
mutex_init(&data->io_mutex);
init_waitqueue_head(&data->waitq);
atomic_set(&data->iin_data_valid, 0);
+   atomic_set(&data->srq_asserted, 0);
data->zombie = 0;
 
/* Determine if it is a Rigol or not */
-- 
2.5.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 v3 3/5] Add support for receiving USBTMC USB488 SRQ notifications via poll/select

2015-11-11 Thread Dave Penkler
Background:
In many situations operations on multiple instruments need to be
synchronized. poll/select provide a convenient way of waiting on a number
of different instruments and other peripherals simultaneously.

Signed-off-by: Dave Penkler 
---
 drivers/usb/class/usbtmc.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 2239cd0..bb9a6ab 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1193,6 +1194,27 @@ static int usbtmc_fasync(int fd, struct file *file, int 
on)
return fasync_helper(fd, file, on, &data->fasync);
 }
 
+static unsigned int usbtmc_poll(struct file *file, poll_table *wait)
+{
+   struct usbtmc_device_data *data = file->private_data;
+   unsigned int mask = 0;
+
+   mutex_lock(&data->io_mutex);
+
+   if (data->zombie) {
+   mask = POLLHUP | POLLERR;
+   goto no_poll;
+   }
+
+   poll_wait(file, &data->waitq, wait);
+
+   mask = (atomic_read(&data->srq_asserted)) ? POLLIN | POLLRDNORM : 0;
+
+no_poll:
+   mutex_unlock(&data->io_mutex);
+   return mask;
+}
+
 static const struct file_operations fops = {
.owner  = THIS_MODULE,
.read   = usbtmc_read,
@@ -1201,6 +1223,7 @@ static const struct file_operations fops = {
.release= usbtmc_release,
.unlocked_ioctl = usbtmc_ioctl,
.fasync = usbtmc_fasync,
+   .poll   = usbtmc_poll,
.llseek = default_llseek,
 };
 
-- 
2.5.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 v3 4/5] Add ioctl to retrieve USBTMC-USB488 capabilities

2015-11-11 Thread Dave Penkler
This is a convenience function to obtain an instrument's capabilities
from its file descriptor without having to access sysfs from the user
program.

Signed-off-by: Dave Penkler 
---
 drivers/usb/class/usbtmc.c   | 12 
 include/uapi/linux/usb/tmc.h | 21 ++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index bb9a6ab..deca4b5 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -103,6 +103,9 @@ struct usbtmc_device_data {
u16iin_wMaxPacketSize;
atomic_t   srq_asserted;
 
+   /* coalesced usb488_caps from usbtmc_dev_capabilities */
+   u8 usb488_caps;
+
u8 rigol_quirk;
 
/* attributes from the USB TMC spec for this device */
@@ -1001,6 +1004,7 @@ static int get_capabilities(struct usbtmc_device_data 
*data)
data->capabilities.device_capabilities = buffer[5];
data->capabilities.usb488_interface_capabilities = buffer[14];
data->capabilities.usb488_device_capabilities = buffer[15];
+   data->usb488_caps = (buffer[14] & 0x07) | ((buffer[15] & 0x0f) << 4);
rv = 0;
 
 err_out:
@@ -1176,6 +1180,14 @@ static long usbtmc_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
retval = usbtmc_ioctl_abort_bulk_in(data);
break;
 
+   case USBTMC488_IOCTL_GET_CAPS:
+   retval = copy_to_user((void __user *)arg,
+   &data->usb488_caps,
+   sizeof(data->usb488_caps));
+   if (retval)
+   retval = -EFAULT;
+   break;
+
case USBTMC488_IOCTL_READ_STB:
retval = usbtmc488_ioctl_read_stb(data, arg);
break;
diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
index 49060ea..2606664 100644
--- a/include/uapi/linux/usb/tmc.h
+++ b/include/uapi/linux/usb/tmc.h
@@ -2,12 +2,14 @@
  * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
  * Copyright (C) 2008 Novell, Inc.
  * Copyright (C) 2008 Greg Kroah-Hartman 
+ * Copyright (C) 2015 Dave Penkler 
  *
  * This file holds USB constants defined by the USB Device Class
- * Definition for Test and Measurement devices published by the USB-IF.
+ * and USB488 Subclass Definitions for Test and Measurement devices
+ * published by the USB-IF.
  *
- * It also has the ioctl definitions for the usbtmc kernel driver that
- * userspace needs to know about.
+ * It also has the ioctl and capability definitions for the
+ * usbtmc kernel driver that userspace needs to know about.
  */
 
 #ifndef __LINUX_USB_TMC_H
@@ -40,6 +42,19 @@
 #define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4)
 #define USBTMC_IOCTL_CLEAR_OUT_HALT_IO(USBTMC_IOC_NR, 6)
 #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
+#define USBTMC488_IOCTL_GET_CAPS   _IO(USBTMC_IOC_NR, 17)
 #define USBTMC488_IOCTL_READ_STB   _IOR(USBTMC_IOC_NR, 18, unsigned char)
 
+/* Driver encoded usb488 capabilities */
+#define USBTMC488_CAPABILITY_TRIGGER 1
+#define USBTMC488_CAPABILITY_SIMPLE  2
+#define USBTMC488_CAPABILITY_REN_CONTROL 2
+#define USBTMC488_CAPABILITY_GOTO_LOCAL  2
+#define USBTMC488_CAPABILITY_LOCAL_LOCKOUT   2
+#define USBTMC488_CAPABILITY_488_DOT_2   4
+#define USBTMC488_CAPABILITY_DT1 16
+#define USBTMC488_CAPABILITY_RL1 32
+#define USBTMC488_CAPABILITY_SR1 64
+#define USBTMC488_CAPABILITY_FULL_SCPI   128
+
 #endif
-- 
2.5.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 v3 5/5] Add ioctls to enable and disable local controls on an instrument

2015-11-11 Thread Dave Penkler
These ioctls provide support for the USBTMC-USB488 control requests
for REN_CONTROL, GO_TO_LOCAL and LOCAL_LOCKOUT

Signed-off-by: Dave Penkler 
---
 drivers/usb/class/usbtmc.c   | 76 
 include/uapi/linux/usb/tmc.h |  9 +-
 2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index deca4b5..646bfff 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -482,6 +482,68 @@ static int usbtmc488_ioctl_read_stb(struct 
usbtmc_device_data *data,
return rv;
 }
 
+static int usbtmc488_ioctl_simple(struct usbtmc_device_data *data,
+   unsigned long arg,
+   unsigned int cmd)
+{
+   u8 *buffer;
+   struct device *dev;
+   int rv;
+   unsigned int val;
+   u16 wValue;
+
+   dev = &data->intf->dev;
+
+   if (0 == (data->usb488_caps & USBTMC488_CAPABILITY_SIMPLE))
+   return -EINVAL;
+
+   buffer = kmalloc(8, GFP_KERNEL);
+   if (!buffer)
+   return -ENOMEM;
+
+
+   if (cmd == USBTMC488_REQUEST_REN_CONTROL) {
+   rv = copy_from_user(&val, (void __user *)arg, sizeof(val));
+   if (rv) {
+   rv = -EFAULT;
+   goto exit;
+   }
+   wValue = (val) ? 1 : 0;
+   } else {
+   wValue = 0;
+   }
+
+   rv = usb_control_msg(data->usb_dev,
+   usb_rcvctrlpipe(data->usb_dev, 0),
+   cmd,
+   USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+   wValue,
+   data->ifnum,
+   buffer, 0x01, USBTMC_TIMEOUT);
+
+   if (rv < 0) {
+   dev_err(dev, "simple usb_control_msg failed %d\n", rv);
+   goto exit;
+   } else if (rv != 1) {
+   dev_warn(dev, "simple usb_control_msg returned %d\n", rv);
+   rv = -EIO;
+   goto exit;
+   }
+
+   if (buffer[0] != USBTMC_STATUS_SUCCESS) {
+   dev_err(dev, "simple control status returned %x\n",
+   buffer[0]);
+   rv = -EIO;
+   goto exit;
+   } else {
+   rv = 0;
+   }
+
+ exit:
+   kfree(buffer);
+   return rv;
+}
+
 /*
  * Sends a REQUEST_DEV_DEP_MSG_IN message on the Bulk-IN endpoint.
  * @transfer_size: number of bytes to request from the device.
@@ -1192,6 +1254,20 @@ static long usbtmc_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
retval = usbtmc488_ioctl_read_stb(data, arg);
break;
 
+   case USBTMC488_IOCTL_REN_CONTROL:
+   retval = usbtmc488_ioctl_simple(data, arg,
+   USBTMC488_REQUEST_REN_CONTROL);
+   break;
+
+   case USBTMC488_IOCTL_GOTO_LOCAL:
+   retval = usbtmc488_ioctl_simple(data, arg,
+   USBTMC488_REQUEST_GOTO_LOCAL);
+   break;
+
+   case USBTMC488_IOCTL_LOCAL_LOCKOUT:
+   retval = usbtmc488_ioctl_simple(data, arg,
+   
USBTMC488_REQUEST_LOCAL_LOCKOUT);
+   break;
}
 
 skip_io_on_zombie:
diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
index 2606664..fe9663f 100644
--- a/include/uapi/linux/usb/tmc.h
+++ b/include/uapi/linux/usb/tmc.h
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
  * Copyright (C) 2008 Novell, Inc.
@@ -32,7 +33,10 @@
 #define USBTMC_REQUEST_CHECK_CLEAR_STATUS  6
 #define USBTMC_REQUEST_GET_CAPABILITIES7
 #define USBTMC_REQUEST_INDICATOR_PULSE 64
-#define USBTMC488_REQUEST_READ_STATUS_BYTE  128
+#define USBTMC488_REQUEST_READ_STATUS_BYTE 128
+#define USBTMC488_REQUEST_REN_CONTROL  160
+#define USBTMC488_REQUEST_GOTO_LOCAL   161
+#define USBTMC488_REQUEST_LOCAL_LOCKOUT162
 
 /* Request values for USBTMC driver's ioctl entry point */
 #define USBTMC_IOC_NR  91
@@ -44,6 +48,9 @@
 #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
 #define USBTMC488_IOCTL_GET_CAPS   _IO(USBTMC_IOC_NR, 17)
 #define USBTMC488_IOCTL_READ_STB   _IOR(USBTMC_IOC_NR, 18, unsigned char)
+#define USBTMC488_IOCTL_REN_CONTROL_IOW(USBTMC_IOC_NR, 19, unsigned char)
+#define USBTMC488_IOCTL_GOTO_LOCAL _IO(USBTMC_IOC_NR, 20)
+#define USBTMC488_IOCTL_LOCAL_LOCKOUT  _IO(USBTMC_IOC_NR, 21)
 
 /* Driver encoded usb488 capabilities */
 #define USBTMC488_CAPABILITY_TRIGGER 1
-- 
2.5.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-inf

[PATCH] fix compare_const_fl.cocci warnings

2015-11-11 Thread Julia Lawall
Move constants to the right of binary operators.

Semantic patch information:
 Depends on personal taste in some cases.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

CC: Dave Penkler 
Signed-off-by: Fengguang Wu 
Signed-off-by: Julia Lawall 

---

This is what Coccinelle generates.  But it would really be more normal in
the form !(x&y).

 usbtmc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -494,7 +494,7 @@ static int usbtmc488_ioctl_simple(struct

dev = &data->intf->dev;

-   if (0 == (data->usb488_caps & USBTMC488_CAPABILITY_SIMPLE))
+   if ((data->usb488_caps & USBTMC488_CAPABILITY_SIMPLE) == 0)
return -EINVAL;

buffer = kmalloc(8, GFP_KERNEL);
--
To unsubscribe from this list: send the line "unsubscribe 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] USB: serial: add Moxa UPORT 11x0 driver

2015-11-11 Thread Mathieu OTHACEHE
Hi Johan

Ok, I'll include a changelog in future patches. Here is the current changlog :

Changes in v2:
* Use generic implementation for read/write code
* Use TIOCSRS485/TIOCGRS485 instead of moxa specific ioctl
* Other problems pointed out by Johan review

Changes in v3:
* Drop unused defines
* Fix style problems
* Remove port identification code since this driver is for one-port devices only
* Fix debug messages
* Use a mutex to protect shadow_mc
* Use usb_serial_generic_open and close
* Other problems pointed out by Johan review

Changes in v4:
* mxu1_startup return -ENODEV on purpose if the firmware was downloaded.
It avoids port_probe to fail since the device is reset.

Thanks,
Mathieu

On Wed, Nov 11, 2015 at 10:40:04AM +0100, Johan Hovold wrote:
> On Wed, Nov 11, 2015 at 10:35:47AM +0100, Mathieu OTHACEHE wrote:
> > Add a driver which supports :
> > 
> > - UPort 1110  : 1 port RS-232 USB to Serial Hub.
> > - UPort 1130  : 1 port RS-422/485 USB to Serial Hub.
> > - UPort 1130I : 1 port RS-422/485 USB to Serial Hub with Isolation.
> > - UPort 1150  : 1 port RS-232/422/485 USB to Serial Hub.
> > - UPort 1150I : 1 port RS-232/422/485 USB to Serial Hub with Isolation.
> > 
> > This driver is based on GPL MOXA driver written by Hen Huang and available
> > on MOXA website. The original driver was based on io_ti serial driver.
> > 
> > Signed-off-by: Mathieu OTHACEHE 
> > ---
> 
> Thanks for the v4. It'll be a few days still before I have a chance to
> review it.
> 
> What changed since v3 (and v2)?
> 
> Please include a summary of the changes below the cutoff line (i.e.
> here) when you send a new revision of a patch.
> 
> Thanks,
> Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] usb: core: lpm: remove usb3_lpm_enabled in usb_device

2015-11-11 Thread Alan Stern
On Wed, 11 Nov 2015, Lu Baolu wrote:

> Commit 8306095fd2c1 ("USB: Disable USB 3.0 LPM in critical sections.")
> adds usb3_lpm_enabled member to struct usb_device. There is no reference
> to this member now. Hence, it could be removed.
> 
> Signed-off-by: Lu Baolu 
> ---
>  include/linux/usb.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 211664f..036e4a5 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -583,7 +583,6 @@ struct usb_device {
>   unsigned usb2_hw_lpm_besl_capable:1;
>   unsigned usb2_hw_lpm_enabled:1;
>   unsigned usb2_hw_lpm_allowed:1;
> - unsigned usb3_lpm_enabled:1;
>   unsigned usb3_lpm_u1_enabled:1;
>   unsigned usb3_lpm_u2_enabled:1;
>   int string_langid;

You forgot to remove the kerneldoc for this field.  And you forgot to 
add kerneldoc for usb3_lpm_u[12]_enabled.

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: scsi-sd fails with error "Invalid field in cdb" for SATA-to-USB adapter JMicron

2015-11-11 Thread Alan Stern
On Tue, 10 Nov 2015, Dmitry Katsubo wrote:

> On 10/11/2015 16:00, Alan Stern wrote:
> > On Tue, 10 Nov 2015, Dmitry Katsubo wrote:
> >
> >> Hello everyone,
> >>
> >> Sorry for cross-posting from linux-s...@vger.kernel.org
> >>
> >> In continuation to the issue described in [1] and [2]:
> >>
> >> Unfortunately, I still suffer from the same problem on Linux kernel
> >> v4.2.3. The problem is in detailed described in [3], in particular I see
> >> the following in dmesg:
> >>
> >> sd 6:0:0:0: [sdd] 234441648 512-byte logical blocks: (120 GB/111 GiB)
> >> sd 6:0:0:0: [sdd] 4096-byte physical blocks
> >> sd 6:0:0:0: [sdd] Write Protect is off
> >> sd 6:0:0:0: [sdd] Mode Sense: 53 00 10 08
> >> sd 6:0:0:0: [sdd] Write cache: enabled, read cache: enabled, supports
> >> DPO and FUA
> >> ...
> >> sd 6:0:0:0: [sdd] tag#0 FAILED Result: hostbyte=DID_OK
> >> driverbyte=DRIVER_SENSE
> >> sd 6:0:0:0: [sdd] tag#0 Sense Key : Illegal Request [current]
> >> sd 6:0:0:0: [sdd] tag#0 Add. Sense: Invalid field in cdb
> >> sd 6:0:0:0: [sdd] tag#0 CDB: Write(10) 2a 08 00 00 10 80 00 00 08 00
> >> blk_update_request: critical target error, dev sdd, sector 4224
> >> BTRFS: lost page write due to I/O error on /dev/sdd1
> >> BTRFS: bdev /dev/sdd1 errs: wr 9, rd 0, flush 0, corrupt 0, gen 0
> >>
> >> I believe that according to patches [4], [5] I should see something like
> >> "Disabling FUA" in logs, but that is not the case
> >>
> >> Any information about how to fix the problem is appreciated.
> >>
> >> # lsusb
> >> Bus 001 Device 007: ID 152d:0567 JMicron Technology Corp. / JMicron USA
> >> Technology Corp.
> >
> > Please post the output from lsusb -v.  Probably your device has a
> > bcdDevice value that's outside the range in the blacklist entry.
> 
> Many thanks for looking into that.
> 
> Bus 001 Device 007: ID 152d:0567 JMicron Technology Corp. / JMicron USA 
> Technology Corp.
> Device Descriptor:
>bLength18
>bDescriptorType 1
>bcdUSB   2.10
>bDeviceClass0 (Defined at Interface level)
>bDeviceSubClass 0
>bDeviceProtocol 0
>bMaxPacketSize064
>idVendor   0x152d JMicron Technology Corp. / JMicron USA 
> Technology Corp.
>idProduct  0x0567
>bcdDevice1.16

Yes, that's the problem.  The blacklist entry only covers bcdDevice = 
1.14.  The line in unusual_devs.h should be changed from

UNUSUAL_DEV(  0x152d, 0x0567, 0x0114, 0x0114,

to

UNUSUAL_DEV(  0x152d, 0x0567, 0x0114, 0x0116,

Would you like to write a patch to do this?

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] usb: phy: msm: fix connect/disconnect bug for dragonboard OTG port

2015-11-11 Thread Tim Bird


On 11/10/2015 07:14 PM, Peter Chen wrote:
> On Tue, Nov 10, 2015 at 04:46:51PM -0800, Tim Bird wrote:
>> This fixes a bug where if you disconnect and re-connect the USB cable,
>> the gadget driver stops working.
>>
>> Add support for async_irq to wake up driver from low power mode.
>> Without this, the power management code never calls resume.
>> Also, have the phy driver kick the gadget driver (chipidea otg)
>> by having the chipidea driver register with it, for vbus connect
>> notifications.
>>
>> Signed-off-by: Tim Bird 
>> ---
>>  drivers/usb/chipidea/udc.c|  6 ++
>>  drivers/usb/phy/phy-msm-usb.c | 16 
>>  include/linux/usb/msm_hsusb.h |  1 +
>>  3 files changed, 23 insertions(+)
>>
>> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
>> index 8223fe7..06234cd 100644
>> --- a/drivers/usb/chipidea/udc.c
>> +++ b/drivers/usb/chipidea/udc.c
>> @@ -1890,6 +1890,12 @@ static int udc_start(struct ci_hdrc *ci)
>>  
>>  ci->gadget.ep0 = &ci->ep0in->ep;
>>  
>> +if (ci->usb_phy) {
>> +retval = otg_set_peripheral(ci->usb_phy->otg, &ci->gadget);
>> +if (retval)
>> +goto destroy_eps;
>> +}
>> +
>>  retval = usb_add_gadget_udc(dev, &ci->gadget);
>>  if (retval)
>>  goto destroy_eps;
> 
> Although it looks no affect for other drivers, it is better you
> can split patches between controller and phy, then I can have a test.

OK.

> In fact, most of phy-msm-usb.c's implementations (except USB PHY related)
> are included in chipidea drivers, hope you can try it in future.

I would like to do this.  I'm pretty confused about the relationship between
ehci, chipidea and the phy code, with regard to managing the controller
hardware.  Is there a phy in mainline that is a good example of having most
of the controller support in the chipidea driver rather than in the phy?

Thanks!
 
>> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
>> index 80eb991..eb80f92 100644
>> --- a/drivers/usb/phy/phy-msm-usb.c
>> +++ b/drivers/usb/phy/phy-msm-usb.c
>> @@ -1731,6 +1731,12 @@ static int msm_otg_probe(struct platform_device *pdev)
>>  return motg->irq;
>>  }
>>  
>> +motg->async_irq = platform_get_irq_byname(pdev, "async_irq");
>> +if (motg->async_irq < 0) {
>> +dev_info(&pdev->dev, "platform_get_irq for async_irq failed\n");
>> +motg->async_irq = 0;
>> +}
>> +
> 
> dev_err

OK - I'll change this.  I've listed the async_irq as optional in the binding 
doc,
so I don't actually error out, but I was unsure the appropriate error level for
this message.

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


Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread Alexander Aring
Hi,

On Tue, Nov 10, 2015 at 11:21:56PM +, John Youn wrote:
> On 11/9/2015 12:43 PM, Stefan Wahren wrote:
> > Hi,
> > 
> > Am 09.11.2015 um 12:53 schrieb Marek Szyprowski:
> >> Hello,
> >>
> >>
> >> This change looks reasonable, I remember the similar issue was in
> >> s3c-hsotg driver
> >> and it caused kernel ops on driver probe, when bootloader left dwc2
> >> enabled.
> >> The other way of solving it would be to add
> >> irq_set_status_flags(irq, IRQ_NOAUTOEN);
> >> before devm_request_irq() and then call enable_irq(irq) after
> >> dwc2_lowlevel_hw_enable().
> >>
> >> Best regards
> > 
> > unfortunately this fixes only the oops. I need to revert commit 
> > 09a75e85779014 ("usb: dwc2: refactor common low-level hw code to 
> > platform.c") to get USB working again.
> > 
> > In dwc2_lowlevel_hw_init the following statement on Raspberry Pi seems 
> > to never come true:
> > 
> > if (!hsotg->phy && !hsotg->uphy && !hsotg->plat) {
> > dev_err(hsotg->dev, "no platform data or transceiver defined\n");
> > return -EPROBE_DEFER;
> > }
> > 
> > This looks wrong to me. According to dwc2 binding the PHY could be 
> > optional, isn't it?
> > 
> > Best regards
> > Stefan
> > 
> 
> 
> The gadget side required it but it looks like the host side
> didn't.
> 
> When Marek did the low-level hw refactor, some of the gadget
> stuff was brought up to the common layer, including the returning
> of -EPROBE_DEFER when no phys are defined.
> 

So the issue according [0] should be fixed? That's good to know, I was
in the state that it isn't fixed and would reply with some "ping, what I
should do now". But why I wasn't cc'ed for that fix.

Anyway..., is the issue [0] fixed now or not?

- Alex

[0] http://marc.info/?l=linux-usb&m=144585173030738&w=2
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 6/7] usb: gadget: f_midi: set altsettings only for MIDIStreaming interface

2015-11-11 Thread Sergei Shtylyov

Hello.

On 11/11/2015 12:38 PM, Felipe Ferreri Tonello wrote:


This avoids duplication of USB requests for OUT endpoint and
re-enabling endpoints.

Signed-off-by: Felipe F. Tonello 
---
   drivers/usb/gadget/function/f_midi.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_midi.c
b/drivers/usb/gadget/function/f_midi.c
index 76ea53c..615d632 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -75,6 +75,7 @@ struct f_midi {
   struct usb_ep*in_ep, *out_ep;
   struct snd_card*card;
   struct snd_rawmidi*rmidi;
+u8ms_id;


   Why 'ms_id' is not aligned with the above field names?


It is actually aligned. Perhaps because of the +?


  No, + should not affect this, it only affects things when a line doesn't 
start with a tab.



Here is from my local git diff:

--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -75,6 +75,7 @@ struct f_midi {
 struct usb_ep   *in_ep, *out_ep;
 struct snd_card *card;
 struct snd_rawmidi  *rmidi;
+   u8  ms_id;


   Unfortunately, tabs got replaces with spaces in this fragment.

[...]

MBR, 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 1/2] cdc_acm: Ignore Infineon Flash Loader utility

2015-11-11 Thread Daniele Palmas
Hi Johan,

2015-11-06 12:24 GMT+01:00 Johan Hovold :
> On Thu, Nov 05, 2015 at 01:57:43PM +0100, Jonas Jonsson wrote:
>> Some modems, such as the Telit UE910, are using an Infineon Flash Loader
>> utility. It has two interfaces, 2/2/0 (Abstract Modem) and 10/0/0 (CDC
>> Data). The latter can be used as a serial interface to upgrade the
>> firmware of the modem. However, that isn't possible when the cdc-acm
>> driver takes control of the device.
>
> Why can't you just use the tty device that the cdc-acm driver provides?

I have the same problem reported by Jonas.

Telit flashing procedure does not work with the cdc-acm driver.

Moreover, the device 0x058b/0x0041 is in itself a flashing device, so
/* Infineon Flashloader driver */ section of usb-serial-simple seems a
good place for it.

Since the procedure is working properly with only bulk endpoints I suspect
that on the firmware side the definition of the device is not correct.

Best regards,
Daniele

>
> Thanks,
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe 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] WIP: usb: dwc2: host: Support immediate retries for split transactions

2015-11-11 Thread Douglas Anderson
In some cases, like when you've got a "Microsoft Wireless Keyboard 2000"
connected to dwc2 with a hub, expected that we'll get some transfer
errors sometimes.  The controller is expected to try at least 3 times
before giving up.  See figure "Figure A-67. Normal HS CSPLIT 3 Strikes
Smash" in the USB spec.

The dwc2 controller has a way to support this by using the "EC_MC"
field.  The Raspberry Pi driver has logic for setting this right.  See
fiq_fsm_queue_split_transaction() in their "dwc_otg_hcd.c".  Let's use
the same logic.

After making this change, we no longer get dropped characters from the
above mentioned keyboard.  Other devices on the same bus as the keyboard
also behave more properly.

Thanks for Julius Werner for the expert analysis and suggestions.

Signed-off-by: Douglas Anderson 
---
 drivers/usb/dwc2/core.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index ef73e498e98f..dcb4cd1d3b34 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -1707,6 +1707,7 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
u32 hcchar;
u32 hctsiz = 0;
u16 num_packets;
+   u32 ec_mc;
 
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "%s()\n", __func__);
@@ -1743,6 +1744,13 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
hctsiz |= chan->xfer_len << TSIZ_XFERSIZE_SHIFT &
  TSIZ_XFERSIZE_MASK;
+
+   /* For split set ec_mc for immediate retries */
+   if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
+   chan->ep_type == USB_ENDPOINT_XFER_ISOC)
+   ec_mc = 3;
+   else
+   ec_mc = 1;
} else {
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "no split\n");
@@ -1805,6 +1813,9 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
hctsiz |= chan->xfer_len << TSIZ_XFERSIZE_SHIFT &
  TSIZ_XFERSIZE_MASK;
+
+   /* The ec_mc gets the multi_count for non-split */
+   ec_mc = chan->multi_count;
}
 
chan->start_pkt_count = num_packets;
@@ -1855,8 +1866,7 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
hcchar = dwc2_readl(hsotg->regs + HCCHAR(chan->hc_num));
hcchar &= ~HCCHAR_MULTICNT_MASK;
-   hcchar |= chan->multi_count << HCCHAR_MULTICNT_SHIFT &
- HCCHAR_MULTICNT_MASK;
+   hcchar |= (ec_mc << HCCHAR_MULTICNT_SHIFT) & HCCHAR_MULTICNT_MASK;
dwc2_hc_set_even_odd_frame(hsotg, chan, &hcchar);
 
if (hcchar & HCCHAR_CHDIS)
-- 
2.6.0.rc2.230.g3dd15c0

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


[REPOST PATCH] usb: dwc2: host: Support immediate retries for split transactions

2015-11-11 Thread Douglas Anderson
In some cases, like when you've got a "Microsoft Wireless Keyboard 2000"
connected to dwc2 with a hub, expected that we'll get some transfer
errors sometimes.  The controller is expected to try at least 3 times
before giving up.  See figure "Figure A-67. Normal HS CSPLIT 3 Strikes
Smash" in the USB spec.

The dwc2 controller has a way to support this by using the "EC_MC"
field.  The Raspberry Pi driver has logic for setting this right.  See
fiq_fsm_queue_split_transaction() in their "dwc_otg_hcd.c".  Let's use
the same logic.

After making this change, we no longer get dropped characters from the
above mentioned keyboard.  Other devices on the same bus as the keyboard
also behave more properly.

Thanks for Julius Werner for the expert analysis and suggestions.

Signed-off-by: Douglas Anderson 
---
Repost without the WIP in tags (sorry for that).

 drivers/usb/dwc2/core.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index ef73e498e98f..dcb4cd1d3b34 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -1707,6 +1707,7 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
u32 hcchar;
u32 hctsiz = 0;
u16 num_packets;
+   u32 ec_mc;
 
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "%s()\n", __func__);
@@ -1743,6 +1744,13 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
hctsiz |= chan->xfer_len << TSIZ_XFERSIZE_SHIFT &
  TSIZ_XFERSIZE_MASK;
+
+   /* For split set ec_mc for immediate retries */
+   if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
+   chan->ep_type == USB_ENDPOINT_XFER_ISOC)
+   ec_mc = 3;
+   else
+   ec_mc = 1;
} else {
if (dbg_hc(chan))
dev_vdbg(hsotg->dev, "no split\n");
@@ -1805,6 +1813,9 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
hctsiz |= chan->xfer_len << TSIZ_XFERSIZE_SHIFT &
  TSIZ_XFERSIZE_MASK;
+
+   /* The ec_mc gets the multi_count for non-split */
+   ec_mc = chan->multi_count;
}
 
chan->start_pkt_count = num_packets;
@@ -1855,8 +1866,7 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
 
hcchar = dwc2_readl(hsotg->regs + HCCHAR(chan->hc_num));
hcchar &= ~HCCHAR_MULTICNT_MASK;
-   hcchar |= chan->multi_count << HCCHAR_MULTICNT_SHIFT &
- HCCHAR_MULTICNT_MASK;
+   hcchar |= (ec_mc << HCCHAR_MULTICNT_SHIFT) & HCCHAR_MULTICNT_MASK;
dwc2_hc_set_even_odd_frame(hsotg, chan, &hcchar);
 
if (hcchar & HCCHAR_CHDIS)
-- 
2.6.0.rc2.230.g3dd15c0

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


[PATCH] USB: serial: option: add support for Novatel MiFi USB620L

2015-11-11 Thread Aleksander Morgado
Also known as Verizon U620L.

The device is modeswitched from 1410:9020 to 1410:9022 by selecting the 4th USB
configuration:

 $ sudo usb_modeswitch –v 0x1410 –p 0x9020 –u 4

This configuration provides a ECM interface as well as TTYs ('Enterprise Mode'
according to the U620 Linux integration guide).

Signed-off-by: Aleksander Morgado 
---
 drivers/usb/serial/option.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 685fef7..2ab2a33 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -161,6 +161,7 @@ static void option_instat_callback(struct urb *urb);
 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED0x9001
 #define NOVATELWIRELESS_PRODUCT_E362   0x9010
 #define NOVATELWIRELESS_PRODUCT_E371   0x9011
+#define NOVATELWIRELESS_PRODUCT_U620L  0x9022
 #define NOVATELWIRELESS_PRODUCT_G2 0xA010
 #define NOVATELWIRELESS_PRODUCT_MC551  0xB001
 
@@ -1052,6 +1053,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_E371, 0xff, 0xff, 0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_U620L, 0xff, 0x00, 0x00) },
 
{ USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
{ USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
-- 
2.6.2

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


Re: [PATCH v3 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.

2015-11-11 Thread Andy Shevchenko
On Wed, Nov 11, 2015 at 1:16 PM, Dave Penkler  wrote:
> Background:
> When performing a read on an instrument that is executing a function
> that runs longer than the USB timeout the instrument may hang and require
> a device reset to recover. The READ_STATUS_BYTE operation always returns
> even when the instrument is busy permitting to poll for the appropriate
> condition. This capability is refered to in instrument application notes
> on synchronizing acquisitions for other platforms.
>

Won't comment precisely by line, but common nitpicks about style:
 - added empty lines where no need
 - redundant parens
 - pieces of code takes whole line when they are quite fit tail of previous one.

And why malloc for 8 bytes?

> Signed-off-by: Dave Penkler 
> ---
>  drivers/usb/class/usbtmc.c   | 223 
> +++
>  include/uapi/linux/usb/tmc.h |   2 +
>  2 files changed, 225 insertions(+)
>
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index 7a11a82..c1593e7 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -87,6 +87,20 @@ struct usbtmc_device_data {
> u8 bTag_last_write; /* needed for abort */
> u8 bTag_last_read;  /* needed for abort */
>
> +
> +   /* data for interrupt in endpoint handling */
> +   u8 bNotify1;
> +   u8 bNotify2;
> +   u16ifnum;
> +   u8 iin_bTag;
> +   u8*iin_buffer;
> +   atomic_t   iin_data_valid;
> +   unsigned int   iin_ep;
> +   intiin_ep_present;
> +   intiin_interval;
> +   struct urb*iin_urb;
> +   u16iin_wMaxPacketSize;
> +
> u8 rigol_quirk;
>
> /* attributes from the USB TMC spec for this device */
> @@ -99,6 +113,7 @@ struct usbtmc_device_data {
> struct usbtmc_dev_capabilities  capabilities;
> struct kref kref;
> struct mutex io_mutex;  /* only one i/o function running at a time */
> +   wait_queue_head_t waitq;
>  };
>  #define to_usbtmc_data(d) container_of(d, struct usbtmc_device_data, kref)
>
> @@ -373,6 +388,91 @@ exit:
> return rv;
>  }
>
> +static int usbtmc488_ioctl_read_stb(struct usbtmc_device_data *data,
> +   unsigned long arg)
> +{
> +   u8 *buffer;
> +   struct device *dev;
> +   int rv;
> +   u8 tag, stb;
> +
> +   dev = &data->intf->dev;
> +
> +   dev_dbg(dev, "Enter ioctl_read_stb iin_ep_present: %d\n",
> +   data->iin_ep_present);
> +
> +   buffer = kmalloc(8, GFP_KERNEL);
> +   if (!buffer)
> +   return -ENOMEM;
> +
> +
> +   atomic_set(&data->iin_data_valid, 0);
> +
> +   rv = usb_control_msg(data->usb_dev,
> +   usb_rcvctrlpipe(data->usb_dev, 0),
> +   USBTMC488_REQUEST_READ_STATUS_BYTE,
> +   USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
> +   data->iin_bTag,
> +   data->ifnum,
> +   buffer, 0x03, USBTMC_TIMEOUT);
> +
> +   if (rv < 0) {
> +   dev_err(dev, "stb usb_control_msg returned %d\n", rv);
> +   goto exit;
> +   }
> +
> +   if (buffer[0] != USBTMC_STATUS_SUCCESS) {
> +   dev_err(dev, "control status returned %x\n",
> +   buffer[0]);
> +   rv = -EIO;
> +   goto exit;
> +   }
> +
> +   if (data->iin_ep_present) {
> +
> +   rv = wait_event_interruptible_timeout(
> +   data->waitq,
> +   (atomic_read(&data->iin_data_valid) != 0),
> +   USBTMC_TIMEOUT
> +   );
> +
> +   if (rv < 0) {
> +   dev_dbg(dev, "wait interrupted %d\n", rv);
> +   goto exit;
> +   }
> +
> +   if (rv == 0) {
> +   dev_dbg(dev, "wait timed out\n");
> +   rv = -ETIME;
> +   goto exit;
> +   }
> +
> +   tag = data->bNotify1 & 0x7f;
> +
> +   if (tag != data->iin_bTag) {
> +   dev_err(dev, "expected bTag %x got %x\n",
> +   data->iin_bTag, tag);
> +   }
> +
> +   stb = data->bNotify2;
> +   } else {
> +   stb = buffer[2];
> +   }
> +
> +   rv = copy_to_user((void __user *)arg, &stb, sizeof(stb));
> +   if (rv)
> +   rv = -EFAULT;
> +
> + exit:
> +   /* bump interrupt bTag */
> +   data->iin_bTag += 1;
> +   if (data->iin_bTag > 127)
> +   data->iin_bTag = 2;
> +
> +   kfree(buffer);
> +   return rv;
> +}
> +
>  /*
>   * Sends a REQUEST_DEV_DEP_MSG_IN message on the Bulk-IN endpoint.
>   * @transfer_size: number of bytes to request from the device.
> @@ -1069,6 +11

Re: [PATCH v3 3/5] Add support for receiving USBTMC USB488 SRQ notifications via poll/select

2015-11-11 Thread Andy Shevchenko
On Wed, Nov 11, 2015 at 1:16 PM, Dave Penkler  wrote:
> Background:
> In many situations operations on multiple instruments need to be
> synchronized. poll/select provide a convenient way of waiting on a number
> of different instruments and other peripherals simultaneously.
>
> Signed-off-by: Dave Penkler 
> ---
>  drivers/usb/class/usbtmc.c | 23 +++
>  1 file changed, 23 insertions(+)
>
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index 2239cd0..bb9a6ab 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -1193,6 +1194,27 @@ static int usbtmc_fasync(int fd, struct file *file, 
> int on)
> return fasync_helper(fd, file, on, &data->fasync);
>  }
>
> +static unsigned int usbtmc_poll(struct file *file, poll_table *wait)
> +{
> +   struct usbtmc_device_data *data = file->private_data;
> +   unsigned int mask = 0;

Redundant assignment.

> +
> +   mutex_lock(&data->io_mutex);
> +
> +   if (data->zombie) {
> +   mask = POLLHUP | POLLERR;
> +   goto no_poll;
> +   }
> +
> +   poll_wait(file, &data->waitq, wait);
> +
> +   mask = (atomic_read(&data->srq_asserted)) ? POLLIN | POLLRDNORM : 0;
> +
> +no_poll:
> +   mutex_unlock(&data->io_mutex);
> +   return mask;
> +}
> +
>  static const struct file_operations fops = {
> .owner  = THIS_MODULE,
> .read   = usbtmc_read,
> @@ -1201,6 +1223,7 @@ static const struct file_operations fops = {
> .release= usbtmc_release,
> .unlocked_ioctl = usbtmc_ioctl,
> .fasync = usbtmc_fasync,
> +   .poll   = usbtmc_poll,
> .llseek = default_llseek,
>  };
>
> --
> 2.5.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



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


Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread John Youn
On 11/11/2015 9:57 AM, Alexander Aring wrote:
> Hi,
> 
> On Tue, Nov 10, 2015 at 11:21:56PM +, John Youn wrote:
>> On 11/9/2015 12:43 PM, Stefan Wahren wrote:
>>> Hi,
>>>
>>> Am 09.11.2015 um 12:53 schrieb Marek Szyprowski:
 Hello,


 This change looks reasonable, I remember the similar issue was in
 s3c-hsotg driver
 and it caused kernel ops on driver probe, when bootloader left dwc2
 enabled.
 The other way of solving it would be to add
 irq_set_status_flags(irq, IRQ_NOAUTOEN);
 before devm_request_irq() and then call enable_irq(irq) after
 dwc2_lowlevel_hw_enable().

 Best regards
>>>
>>> unfortunately this fixes only the oops. I need to revert commit 
>>> 09a75e85779014 ("usb: dwc2: refactor common low-level hw code to 
>>> platform.c") to get USB working again.
>>>
>>> In dwc2_lowlevel_hw_init the following statement on Raspberry Pi seems 
>>> to never come true:
>>>
>>> if (!hsotg->phy && !hsotg->uphy && !hsotg->plat) {
>>> dev_err(hsotg->dev, "no platform data or transceiver defined\n");
>>> return -EPROBE_DEFER;
>>> }
>>>
>>> This looks wrong to me. According to dwc2 binding the PHY could be 
>>> optional, isn't it?
>>>
>>> Best regards
>>> Stefan
>>>
>>
>>
>> The gadget side required it but it looks like the host side
>> didn't.
>>
>> When Marek did the low-level hw refactor, some of the gadget
>> stuff was brought up to the common layer, including the returning
>> of -EPROBE_DEFER when no phys are defined.
>>
> 
> So the issue according [0] should be fixed? That's good to know, I was
> in the state that it isn't fixed and would reply with some "ping, what I
> should do now". But why I wasn't cc'ed for that fix.
> 
> Anyway..., is the issue [0] fixed now or not?
> 
> - Alex
> 
> [0] http://marc.info/?l=linux-usb&m=144585173030738&w=2
> 


Hi Alex,

I'll post a couple patches shortly, one of which should fix it.

Appreciate if you can review or test.

Regards,
John

--
To unsubscribe from this list: send the line "unsubscribe 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 RESEND 0/2] usb: dwc2: Fix issues with getting PHY during probe

2015-11-11 Thread John Youn
This series address a couple issues with setting up and checking the
PHY during probe.

Resending to linux-usb list with fixed up headers and fixed cover
letter subject.

John Youn (2):
  usb: dwc2: Make PHY optional
  usb: dwc2: Return errors from PHY

 drivers/usb/dwc2/platform.c | 36 ++--
 1 file changed, 26 insertions(+), 10 deletions(-)

-- 
2.5.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe 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 RESEND 1/2] usb: dwc2: Make PHY optional

2015-11-11 Thread John Youn
Fixes commit 09a75e85
"usb: dwc2: refactor common low-level hw code to platform.c"

The above commit consolidated the low-level phy access into a common
location. This change introduced a check from the gadget requiring
that a PHY is specified. This requirement never existed on the host
side and broke some platforms when it was moved into platform.c.

The gadget doesn't require the PHY either so remove the check.

Reported-by: Stefan Wahren 
Cc: Marek Szyprowski 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/platform.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 5127d74..b129c52 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -231,11 +231,6 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
hsotg->phyif = GUSBCFG_PHYIF8;
}
 
-   if (!hsotg->phy && !hsotg->uphy && !hsotg->plat) {
-   dev_err(hsotg->dev, "no platform data or transceiver 
defined\n");
-   return -EPROBE_DEFER;
-   }
-
/* Clock */
hsotg->clk = devm_clk_get(hsotg->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
2.5.0.GIT

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


Re: [PATCH v3 4/5] Add ioctl to retrieve USBTMC-USB488 capabilities

2015-11-11 Thread Andy Shevchenko
On Wed, Nov 11, 2015 at 1:20 PM, Dave Penkler  wrote:
> This is a convenience function to obtain an instrument's capabilities
> from its file descriptor without having to access sysfs from the user
> program.
>
> Signed-off-by: Dave Penkler 
> ---
>  drivers/usb/class/usbtmc.c   | 12 
>  include/uapi/linux/usb/tmc.h | 21 ++---
>  2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index bb9a6ab..deca4b5 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -103,6 +103,9 @@ struct usbtmc_device_data {
> u16iin_wMaxPacketSize;
> atomic_t   srq_asserted;
>
> +   /* coalesced usb488_caps from usbtmc_dev_capabilities */
> +   u8 usb488_caps;
> +
> u8 rigol_quirk;
>
> /* attributes from the USB TMC spec for this device */
> @@ -1001,6 +1004,7 @@ static int get_capabilities(struct usbtmc_device_data 
> *data)
> data->capabilities.device_capabilities = buffer[5];
> data->capabilities.usb488_interface_capabilities = buffer[14];
> data->capabilities.usb488_device_capabilities = buffer[15];
> +   data->usb488_caps = (buffer[14] & 0x07) | ((buffer[15] & 0x0f) << 4);
> rv = 0;
>
>  err_out:
> @@ -1176,6 +1180,14 @@ static long usbtmc_ioctl(struct file *file, unsigned 
> int cmd, unsigned long arg)
> retval = usbtmc_ioctl_abort_bulk_in(data);
> break;
>
> +   case USBTMC488_IOCTL_GET_CAPS:
> +   retval = copy_to_user((void __user *)arg,
> +   &data->usb488_caps,
> +   sizeof(data->usb488_caps));
> +   if (retval)
> +   retval = -EFAULT;
> +   break;
> +
> case USBTMC488_IOCTL_READ_STB:
> retval = usbtmc488_ioctl_read_stb(data, arg);
> break;
> diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
> index 49060ea..2606664 100644
> --- a/include/uapi/linux/usb/tmc.h
> +++ b/include/uapi/linux/usb/tmc.h
> @@ -2,12 +2,14 @@
>   * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
>   * Copyright (C) 2008 Novell, Inc.
>   * Copyright (C) 2008 Greg Kroah-Hartman 
> + * Copyright (C) 2015 Dave Penkler 
>   *
>   * This file holds USB constants defined by the USB Device Class
> - * Definition for Test and Measurement devices published by the USB-IF.
> + * and USB488 Subclass Definitions for Test and Measurement devices
> + * published by the USB-IF.
>   *

> - * It also has the ioctl definitions for the usbtmc kernel driver that
> - * userspace needs to know about.
> + * It also has the ioctl and capability definitions for the
> + * usbtmc kernel driver that userspace needs to know about.

Do not see what's changed here.

>   */
>
>  #ifndef __LINUX_USB_TMC_H
> @@ -40,6 +42,19 @@
>  #define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4)
>  #define USBTMC_IOCTL_CLEAR_OUT_HALT_IO(USBTMC_IOC_NR, 6)
>  #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
> +#define USBTMC488_IOCTL_GET_CAPS   _IO(USBTMC_IOC_NR, 17)
>  #define USBTMC488_IOCTL_READ_STB   _IOR(USBTMC_IOC_NR, 18, unsigned char)
>
> +/* Driver encoded usb488 capabilities */
> +#define USBTMC488_CAPABILITY_TRIGGER 1
> +#define USBTMC488_CAPABILITY_SIMPLE  2
> +#define USBTMC488_CAPABILITY_REN_CONTROL 2
> +#define USBTMC488_CAPABILITY_GOTO_LOCAL  2
> +#define USBTMC488_CAPABILITY_LOCAL_LOCKOUT   2
> +#define USBTMC488_CAPABILITY_488_DOT_2   4
> +#define USBTMC488_CAPABILITY_DT1 16
> +#define USBTMC488_CAPABILITY_RL1 32
> +#define USBTMC488_CAPABILITY_SR1 64
> +#define USBTMC488_CAPABILITY_FULL_SCPI   128
> +
>  #endif
> --
> 2.5.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



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe 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 RESEND 2/2] usb: dwc2: Return errors from PHY

2015-11-11 Thread John Youn
When searching for PHYs, any error was treated as if the PHY did not
exist or was not specified (-ENODEV). Thus the probe function did not
correctly return error conditions such as -EPROBE_DEFER.

Fixed so that only -ENODEV is ignored and any other error is returned.

Reported-by: Alexander Aring 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/platform.c | 31 ++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index b129c52..0a0e44e 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -214,14 +214,35 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 */
hsotg->phy = devm_phy_get(hsotg->dev, "usb2-phy");
if (IS_ERR(hsotg->phy)) {
-   hsotg->phy = NULL;
+   ret = PTR_ERR(hsotg->phy);
+   if (ret == -ENODEV) {
+   hsotg->phy = NULL;
+   } else if (ret == -EPROBE_DEFER) {
+   return ret;
+   } else {
+   dev_err(hsotg->dev, "error getting phy %d\n", ret);
+   return ret;
+   }
+   }
+
+   if (!hsotg->phy) {
hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(hsotg->uphy))
-   hsotg->uphy = NULL;
-   else
-   hsotg->plat = dev_get_platdata(hsotg->dev);
+   if (IS_ERR(hsotg->uphy)) {
+   ret = PTR_ERR(hsotg->uphy);
+   if (ret == -ENODEV) {
+   hsotg->uphy = NULL;
+   } else if (ret == -EPROBE_DEFER) {
+   return ret;
+   } else {
+   dev_err(hsotg->dev, "error getting "
+   "usb phy %d\n", ret);
+   return ret;
+   }
+   }
}
 
+   hsotg->plat = dev_get_platdata(hsotg->dev);
+
if (hsotg->phy) {
/*
 * If using the generic PHY framework, check if the PHY bus
-- 
2.5.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe 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 5/5] Add ioctls to enable and disable local controls on an instrument

2015-11-11 Thread Andy Shevchenko
On Wed, Nov 11, 2015 at 1:21 PM, Dave Penkler  wrote:
> These ioctls provide support for the USBTMC-USB488 control requests
> for REN_CONTROL, GO_TO_LOCAL and LOCAL_LOCKOUT
>
> Signed-off-by: Dave Penkler 
> ---
>  drivers/usb/class/usbtmc.c   | 76 
> 
>  include/uapi/linux/usb/tmc.h |  9 +-
>  2 files changed, 84 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index deca4b5..646bfff 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -482,6 +482,68 @@ static int usbtmc488_ioctl_read_stb(struct 
> usbtmc_device_data *data,
> return rv;
>  }
>
> +static int usbtmc488_ioctl_simple(struct usbtmc_device_data *data,
> +   unsigned long arg,
> +   unsigned int cmd)
> +{
> +   u8 *buffer;
> +   struct device *dev;
> +   int rv;
> +   unsigned int val;
> +   u16 wValue;
> +
> +   dev = &data->intf->dev;
> +
> +   if (0 == (data->usb488_caps & USBTMC488_CAPABILITY_SIMPLE))

Other way around.

> +   return -EINVAL;
> +
> +   buffer = kmalloc(8, GFP_KERNEL);
> +   if (!buffer)
> +   return -ENOMEM;
> +

Redundant empty line.

> +
> +   if (cmd == USBTMC488_REQUEST_REN_CONTROL) {
> +   rv = copy_from_user(&val, (void __user *)arg, sizeof(val));
> +   if (rv) {
> +   rv = -EFAULT;
> +   goto exit;
> +   }
> +   wValue = (val) ? 1 : 0;

!!val;

> +   } else {
> +   wValue = 0;
> +   }
> +
> +   rv = usb_control_msg(data->usb_dev,
> +   usb_rcvctrlpipe(data->usb_dev, 0),
> +   cmd,
> +   USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
> +   wValue,
> +   data->ifnum,
> +   buffer, 0x01, USBTMC_TIMEOUT);
> +
> +   if (rv < 0) {
> +   dev_err(dev, "simple usb_control_msg failed %d\n", rv);
> +   goto exit;
> +   } else if (rv != 1) {
> +   dev_warn(dev, "simple usb_control_msg returned %d\n", rv);
> +   rv = -EIO;
> +   goto exit;
> +   }
> +
> +   if (buffer[0] != USBTMC_STATUS_SUCCESS) {
> +   dev_err(dev, "simple control status returned %x\n",
> +   buffer[0]);
> +   rv = -EIO;
> +   goto exit;
> +   } else {
> +   rv = 0;
> +   }
> +
> + exit:
> +   kfree(buffer);
> +   return rv;
> +}
> +
>  /*
>   * Sends a REQUEST_DEV_DEP_MSG_IN message on the Bulk-IN endpoint.
>   * @transfer_size: number of bytes to request from the device.
> @@ -1192,6 +1254,20 @@ static long usbtmc_ioctl(struct file *file, unsigned 
> int cmd, unsigned long arg)
> retval = usbtmc488_ioctl_read_stb(data, arg);
> break;
>
> +   case USBTMC488_IOCTL_REN_CONTROL:
> +   retval = usbtmc488_ioctl_simple(data, arg,
> +   
> USBTMC488_REQUEST_REN_CONTROL);
> +   break;
> +
> +   case USBTMC488_IOCTL_GOTO_LOCAL:
> +   retval = usbtmc488_ioctl_simple(data, arg,
> +   USBTMC488_REQUEST_GOTO_LOCAL);
> +   break;
> +
> +   case USBTMC488_IOCTL_LOCAL_LOCKOUT:
> +   retval = usbtmc488_ioctl_simple(data, arg,
> +   
> USBTMC488_REQUEST_LOCAL_LOCKOUT);
> +   break;
> }
>
>  skip_io_on_zombie:
> diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
> index 2606664..fe9663f 100644
> --- a/include/uapi/linux/usb/tmc.h
> +++ b/include/uapi/linux/usb/tmc.h
> @@ -1,3 +1,4 @@
> +
>  /*
>   * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
>   * Copyright (C) 2008 Novell, Inc.
> @@ -32,7 +33,10 @@
>  #define USBTMC_REQUEST_CHECK_CLEAR_STATUS  6
>  #define USBTMC_REQUEST_GET_CAPABILITIES7
>  #define USBTMC_REQUEST_INDICATOR_PULSE 64
> -#define USBTMC488_REQUEST_READ_STATUS_BYTE  128
> +#define USBTMC488_REQUEST_READ_STATUS_BYTE 128
> +#define USBTMC488_REQUEST_REN_CONTROL  160
> +#define USBTMC488_REQUEST_GOTO_LOCAL   161
> +#define USBTMC488_REQUEST_LOCAL_LOCKOUT162
>
>  /* Request values for USBTMC driver's ioctl entry point */
>  #define USBTMC_IOC_NR  91
> @@ -44,6 +48,9 @@
>  #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
>  #define USBTMC488_IOCTL_GET_CAPS   _IO(USBTMC_IOC_NR, 17)
>  #define USBTMC488_IOCTL_READ_STB   _IOR(USBTMC_IOC_NR, 18, unsigned char)
> +#define USBTMC488_IOCTL_REN_CONTROL_IOW(USBTMC_IOC_NR, 19, unsigned char)
> +#define USBTMC488_IOCTL_GOTO_LOCAL _IO(U

Re: [PATCH v3 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.

2015-11-11 Thread Sergei Shtylyov

Hello.

On 11/11/2015 10:03 PM, Andy Shevchenko wrote:


Background:
When performing a read on an instrument that is executing a function
that runs longer than the USB timeout the instrument may hang and require
a device reset to recover. The READ_STATUS_BYTE operation always returns
even when the instrument is busy permitting to poll for the appropriate
condition. This capability is refered to in instrument application notes


   Referred.


on synchronizing acquisitions for other platforms.


Won't comment precisely by line, but common nitpicks about style:
  - added empty lines where no need
  - redundant parens
  - pieces of code takes whole line when they are quite fit tail of previous 
one.

And why malloc for 8 bytes?


   To be able to do DMA with this buffer, apparently.


Signed-off-by: Dave Penkler 


[patch skipped]

   It's a good tone to skip the parts you're not commenting on, so others 
wouldn't have to scroll in vain.


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 v3 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.

2015-11-11 Thread Andy Shevchenko
On Wed, Nov 11, 2015 at 9:48 PM, Sergei Shtylyov
 wrote:
> On 11/11/2015 10:03 PM, Andy Shevchenko wrote:

>> Won't comment precisely by line, but common nitpicks about style:
>>   - added empty lines where no need
>>   - redundant parens
>>   - pieces of code takes whole line when they are quite fit tail of
>> previous one.
>>
>> And why malloc for 8 bytes?

>It's a good tone to skip the parts you're not commenting on, so others
> wouldn't have to scroll in vain.

Isn't obvious from my comment that no scroll is needed?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe 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] Documentation: dt-bindings: add async_irq to msm_hsusb

2015-11-11 Thread Rob Herring
On Tue, Nov 10, 2015 at 04:46:50PM -0800, Tim Bird wrote:
> Add optional async_irq to msm_hsusb binding doc.
> 
> Signed-off-by: Tim Bird 

Acked-by: Rob Herring 

> ---
>  Documentation/devicetree/bindings/usb/msm-hsusb.txt | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
> b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
> index 8654a3e..7ba1dff 100644
> --- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
> +++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
> @@ -23,7 +23,12 @@ Required properties:
>"qcom,usb-otg-snps" for chipsets with Synopsys 28nm PHY
>  
>  - regs: Offset and length of the register set in the memory map
> -- interrupts:   interrupt-specifier for the OTG interrupt.
> +- interrupts:   interrupt-specifier for the OTG interrupts
> +
> +- interrupt-names: Should contain the following:
> +  "core_irq"USB core interrupt
> +  "async_irq"   Asynchronous interrupt to wake up from low power mode
> +(optional)
>  
>  - clocks:   A list of phandle + clock-specifier pairs for the
>  clocks listed in clock-names
> @@ -89,7 +94,8 @@ Example HSUSB OTG controller device node:
>  usb@f9a55000 {
>  compatible = "qcom,usb-otg-snps";
>  reg = <0xf9a55000 0x400>;
> -interrupts = <0 134 0>;
> +interrupts = <0 134 0>, <0 140 0>;
> +interrupt-names = "core_irq", "async_irq";
>  dr_mode = "peripheral";
>  
>  clocks = <&gcc GCC_XO_CLK>, <&gcc GCC_USB_HS_SYSTEM_CLK>,
> -- 
> 1.8.2.2
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND 2/2] usb: dwc2: Return errors from PHY

2015-11-11 Thread Sergei Shtylyov

Hello.

On 11/11/2015 10:36 PM, John Youn wrote:


When searching for PHYs, any error was treated as if the PHY did not
exist or was not specified (-ENODEV). Thus the probe function did not
correctly return error conditions such as -EPROBE_DEFER.

Fixed so that only -ENODEV is ignored and any other error is returned.

Reported-by: Alexander Aring 
Signed-off-by: John Youn 
---
  drivers/usb/dwc2/platform.c | 31 ++-
  1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index b129c52..0a0e44e 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -214,14 +214,35 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 */
hsotg->phy = devm_phy_get(hsotg->dev, "usb2-phy");
if (IS_ERR(hsotg->phy)) {
-   hsotg->phy = NULL;
+   ret = PTR_ERR(hsotg->phy);
+   if (ret == -ENODEV) {
+   hsotg->phy = NULL;
+   } else if (ret == -EPROBE_DEFER) {
+   return ret;
+   } else {
+   dev_err(hsotg->dev, "error getting phy %d\n", ret);
+   return ret;
+   }


   This is asking to be a *switch* statement.


+   }
+
+   if (!hsotg->phy) {
hsotg->uphy = devm_usb_get_phy(hsotg->dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(hsotg->uphy))
-   hsotg->uphy = NULL;
-   else
-   hsotg->plat = dev_get_platdata(hsotg->dev);
+   if (IS_ERR(hsotg->uphy)) {
+   ret = PTR_ERR(hsotg->uphy);
+   if (ret == -ENODEV) {
+   hsotg->uphy = NULL;
+   } else if (ret == -EPROBE_DEFER) {
+   return ret;
+   } else {
+   dev_err(hsotg->dev, "error getting "
+   "usb phy %d\n", ret);
+   return ret;
+   }


   This too.

[...]

MBR, 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 v3 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.

2015-11-11 Thread Greg Kroah-Hartman
On Wed, Nov 11, 2015 at 09:03:14PM +0200, Andy Shevchenko wrote:
> On Wed, Nov 11, 2015 at 1:16 PM, Dave Penkler  wrote:
> > Background:
> > When performing a read on an instrument that is executing a function
> > that runs longer than the USB timeout the instrument may hang and require
> > a device reset to recover. The READ_STATUS_BYTE operation always returns
> > even when the instrument is busy permitting to poll for the appropriate
> > condition. This capability is refered to in instrument application notes
> > on synchronizing acquisitions for other platforms.
> >
> 
> Won't comment precisely by line, but common nitpicks about style:
>  - added empty lines where no need
>  - redundant parens
>  - pieces of code takes whole line when they are quite fit tail of previous 
> one.
> 
> And why malloc for 8 bytes?

That's a requirement of the USB stack, any data you send on it has to be
malloced.

--
To unsubscribe from this list: send the line "unsubscribe 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 RESEND] USB: serial: cp210x: Add tx_empty()

2015-11-11 Thread Konstantin Shkolnyy
Without this function, when the port is closed the data in the chip's
transmit FIFO are lost. If the actual byte count is reported the close
can be delayed until all data are sent.

Signed-off-by: Konstantin Shkolnyy 
---
 drivers/usb/serial/cp210x.c | 60 +
 1 file changed, 60 insertions(+)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index e91b654..756e432 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -38,6 +38,7 @@ static void cp210x_change_speed(struct tty_struct *, struct 
usb_serial_port *,
struct ktermios *);
 static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
struct ktermios*);
+static bool cp210x_tx_empty(struct usb_serial_port *port);
 static int cp210x_tiocmget(struct tty_struct *);
 static int cp210x_tiocmset(struct tty_struct *, unsigned int, unsigned int);
 static int cp210x_tiocmset_port(struct usb_serial_port *port,
@@ -215,6 +216,7 @@ static struct usb_serial_driver cp210x_device = {
.close  = cp210x_close,
.break_ctl  = cp210x_break_ctl,
.set_termios= cp210x_set_termios,
+   .tx_empty   = cp210x_tx_empty,
.tiocmget   = cp210x_tiocmget,
.tiocmset   = cp210x_tiocmset,
.port_probe = cp210x_port_probe,
@@ -301,6 +303,18 @@ static struct usb_serial_driver * const serial_drivers[] = 
{
 #define CONTROL_WRITE_DTR  0x0100
 #define CONTROL_WRITE_RTS  0x0200
 
+/* CP210X_GET_COMM_STATUS returns these 0x13 bytes */
+#define CP210X_COMM_STATUS_SIZE 0x13
+struct cp210x_comm_status {
+   __le32   ulErrors;
+   __le32   ulHoldReasons;
+   __le32   ulAmountInInQueue;
+   __le32   ulAmountInOutQueue;
+   u8   bEofReceived;
+   u8   bWaitForImmediate;
+   u8   bReserved;
+};
+
 /*
  * CP210X_PURGE - 16 bits passed in wValue of USB request.
  * SiLabs app note AN571 gives a strange description of the 4 bits:
@@ -551,6 +565,52 @@ static void cp210x_close(struct usb_serial_port *port)
 }
 
 /*
+ * Read how many bytes are waiting in the TX queue.
+ */
+static int cp210x_get_tx_queue_byte_count(struct usb_serial_port *port,
+   u32 *count)
+{
+   struct usb_serial *serial = port->serial;
+   struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
+   struct cp210x_comm_status *sts;
+   int result;
+
+   sts = kmalloc(CP210X_COMM_STATUS_SIZE, GFP_KERNEL);
+   if (!sts)
+   return -ENOMEM;
+
+   result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+   CP210X_GET_COMM_STATUS, REQTYPE_INTERFACE_TO_HOST, 0x,
+   port_priv->bInterfaceNumber, sts, CP210X_COMM_STATUS_SIZE,
+   USB_CTRL_GET_TIMEOUT);
+   if (result == CP210X_COMM_STATUS_SIZE) {
+   *count = le32_to_cpu(sts->ulAmountInOutQueue);
+   result = 0;
+   } else {
+   dev_dbg(&port->dev, "%s error: size=%d result=%d\n",
+   __func__, CP210X_COMM_STATUS_SIZE, result);
+   if (result >= 0)
+   result = -EPROTO;
+   }
+
+   kfree(sts);
+
+   return result;
+}
+
+static bool cp210x_tx_empty(struct usb_serial_port *port)
+{
+   int err;
+   u32 count;
+
+   err = cp210x_get_tx_queue_byte_count(port, &count);
+   if (!err && count)
+   return false;
+
+   return true;
+}
+
+/*
  * cp210x_get_termios
  * Reads the baud rate, data bits, parity, stop bits and flow control mode
  * from the device, corrects any unsupported values, and configures the
-- 
1.8.4.5

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


Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread John Youn
On 11/8/2015 2:13 AM, Stefan Wahren wrote:
> Hi Stephen,
> 
> Am 08.11.2015 um 06:06 schrieb Stephen Warren:
>> On 11/07/2015 05:16 PM, Stefan Wahren wrote:
>>> Hi,
>>> [...]
>>>* phys (optional)
>>>* phy-names (optional)
>>>
>>> So here are my questions:
>>>
>>> How to fix the kernel oops in dwc2 driver?
>>
>> Do you know exactly what causes the crash; you've bisected to the
>> specific commit, but I don't think mentioned why that commit causes an
>> issue.
> 
> The stacktrace in my initial mail shows a invalid paging request on 
> hsotg->regs in dwc2_is_controller_alive() which is called by 
> dwc2_handle_common_intr(). I must clarify the problem description. It's 
> reproducable on Raspberry Pi since 09a75e857790, but the real problem 
> seems to has been in the driver before. Looking at dwc2_driver_probe() 
> that the irq responsable for dwc2_handle_common_intr is requested BEFORE 
> hsotg->regs, hsotg->dr_mode and hsotg->lock are initialized.
> 
> I attached a patch which avoids this race by moving the request behind 
> dwc2_lowlevel_hw_init(). Not sure about that, but the oops disappear.
> 
>>
>>> Should we specify dr_mode = "host" for all Raspberry Pi variants in DT?
>>
>> It's optional so the driver must work without it. However, that value
>> seems appropriate, so you could certainly add it.
> 
> That's not the first platform, which shows me that dr_mode is only 
> optional for the case that the controller is really used for USB OTG. 
> AFAIK the OTG ID pin of the Raspberry PI A and B are tied to GND. But 
> the dwc2 driver doesn't know about that.
> 
>>
>>> Which clock should be referenced by USB host in DT?
>>>
>>> Do we need a USB PHY DT node and driver for bcm2835?
>>
>> I don't think there's a separate PHY module in bcm2835 is there?
>> Certainly there is no documentation, binding, or driver for it that I'm
>> aware of. I haven't checked the RPi Foundation downstream kernel though.
>>
> 
> I took a little deeper look into dwc2. According to 
> dwc2_lowlevel_hw_init() the USB PHY is required and clk is optional. I'm 
> confused :-(
> 
> Here is the draft for avoiding the oops:
> 
> --->8
> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> index 5859b0f..0e80087 100644
> --- a/drivers/usb/dwc2/platform.c
> +++ b/drivers/usb/dwc2/platform.c
> @@ -341,20 +341,6 @@ static int dwc2_driver_probe(struct platform_device 
> *dev)
>   if (retval)
>   return retval;
> 
> - irq = platform_get_irq(dev, 0);
> - if (irq < 0) {
> - dev_err(&dev->dev, "missing IRQ resource\n");
> - return irq;
> - }
> -
> - dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
> - irq);
> - retval = devm_request_irq(hsotg->dev, irq,
> -   dwc2_handle_common_intr, IRQF_SHARED,
> -   dev_name(hsotg->dev), hsotg);
> - if (retval)
> - return retval;
> -
>   res = platform_get_resource(dev, IORESOURCE_MEM, 0);
>   hsotg->regs = devm_ioremap_resource(&dev->dev, res);
>   if (IS_ERR(hsotg->regs))
> @@ -389,6 +375,20 @@ static int dwc2_driver_probe(struct platform_device 
> *dev)
> 
>   dwc2_set_all_params(hsotg->core_params, -1);
> 
> + irq = platform_get_irq(dev, 0);
> + if (irq < 0) {
> + dev_err(&dev->dev, "missing IRQ resource\n");
> + return irq;
> + }
> +
> + dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
> + irq);
> + retval = devm_request_irq(hsotg->dev, irq,
> +   dwc2_handle_common_intr, IRQF_SHARED,
> +   dev_name(hsotg->dev), hsotg);
> + if (retval)
> + return retval;
> +
>   retval = dwc2_lowlevel_hw_enable(hsotg);
>   if (retval)
>   return retval;
> 
> 

Looks good to me. Could you submit a patch for this?

Regards,
John

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


Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread Stefan Wahren

Hi John,

Am 11.11.2015 um 00:21 schrieb John Youn:

On 11/9/2015 12:43 PM, Stefan Wahren wrote:

Hi,


The gadget side required it but it looks like the host side
didn't.

When Marek did the low-level hw refactor, some of the gadget
stuff was brought up to the common layer, including the returning
of -EPROBE_DEFER when no phys are defined.

I think this requirement can be removed. At least only enforce it
for the gadget as before.

Could you see if the following fixes it?


the patch looks okay, but it didn't get USB working after applying your 
patch in combination with my patch.


devm_phy_get(hsotg->dev, "usb2-phy") failed, but ret has a value of -38. 
I don't know where this strange value comes from.


I also experience issues with my rootfs, so i think could be a problem 
with my build or the linux-next version. Tomorrow i will try the patches 
on top of Felipe's repo.


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


Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread Stefan Wahren

Am 11.11.2015 um 22:58 schrieb John Youn:

On 11/8/2015 2:13 AM, Stefan Wahren wrote:

--->8
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 5859b0f..0e80087 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -341,20 +341,6 @@ static int dwc2_driver_probe(struct platform_device
*dev)
if (retval)
return retval;

-   irq = platform_get_irq(dev, 0);
-   if (irq < 0) {
-   dev_err(&dev->dev, "missing IRQ resource\n");
-   return irq;
-   }
-
-   dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
-   irq);
-   retval = devm_request_irq(hsotg->dev, irq,
- dwc2_handle_common_intr, IRQF_SHARED,
- dev_name(hsotg->dev), hsotg);
-   if (retval)
-   return retval;
-
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
hsotg->regs = devm_ioremap_resource(&dev->dev, res);
if (IS_ERR(hsotg->regs))
@@ -389,6 +375,20 @@ static int dwc2_driver_probe(struct platform_device
*dev)

dwc2_set_all_params(hsotg->core_params, -1);

+   irq = platform_get_irq(dev, 0);
+   if (irq < 0) {
+   dev_err(&dev->dev, "missing IRQ resource\n");
+   return irq;
+   }
+
+   dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
+   irq);
+   retval = devm_request_irq(hsotg->dev, irq,
+ dwc2_handle_common_intr, IRQF_SHARED,
+ dev_name(hsotg->dev), hsotg);
+   if (retval)
+   return retval;
+
retval = dwc2_lowlevel_hw_enable(hsotg);
if (retval)
return retval;




Looks good to me. Could you submit a patch for this?



If i get USB working on the Pi then i will send you a clean patch.

Stefan


Regards,
John




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


Re: [PATCH 1/1] usblp: do not set TASK_INTERRUPTIBLE before lock

2015-11-11 Thread Pete Zaitcev
On Mon,  2 Nov 2015 10:27:00 +0100
Jiri Slaby  wrote:

> Signed-off-by: Jiri Slaby 
> --- a/drivers/usb/class/usblp.c
> +++ b/drivers/usb/class/usblp.c
> @@ -884,11 +884,11 @@ static int usblp_wwait(struct usblp *usblp, int 
> nonblock)
>  
>   add_wait_queue(&usblp->wwait, &waita);
>   for (;;) {
> - set_current_state(TASK_INTERRUPTIBLE);
>   if (mutex_lock_interruptible(&usblp->mut)) {
>   rc = -EINTR;
>   break;
>   }
> + set_current_state(TASK_INTERRUPTIBLE);
>   rc = usblp_wtest(usblp, nonblock);
>   mutex_unlock(&usblp->mut);
>   if (rc <= 0)

I'm fully onboard with this. In the original "big cleanup" 317c67b8f,
I got this right. But then I either missed that mutex_lock_interruptible()
can set the state, or it didn't do it back then (it was in 2007), and
the 7f477358e introduced the existing code.

Acked-By: Pete Zaitcev 

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


Re: [RFC] usb: dwc2: hcd: fix split schedule issue

2015-11-11 Thread Doug Anderson
John,

On Fri, Nov 6, 2015 at 2:04 AM, Yunzhi Li  wrote:
> hi John ,
>
>   As we talked yesterday, I tried to fix the split schedule sequence. This
> patch will
> avoid scheduling SSPLIT-IN packet for another device between
> SSPLIT-OUT-begin and
> SSPLIT-OUT-end, now the keyboard and Jebra audio speaker could work together
> well, but
> I'm not sure if this is exactly the right way to schedule split transfers
> and if there
> is any dide effect with this patch. Please help review this patch. Thanks.
>
>> Fix dwc2 split schedule sequence issue. Not schedule a SSPLIT_IN
>> packet between SSPLIT-begin and SSPLIT-end.
>>
>> Signed-off-by: Yunzhi Li 
>> ---
>>   drivers/usb/dwc2/hcd.c | 4 
>>   1 file changed, 4 insertions(+)

Did you have any thoughts on this patch?  Although this patch didn't
fix the problems I was seeing with the Microsoft Wireless Keyboard
(see the patch I sent out earlier which does seem to fix it), I can
confirm that in a different setup (HUB goes to USB audio + mouse) that
this patch does fix some problems.

That being said, it feels to me like a band-aid rather than an actual
fix (I'm talking out of my rear end, though, since my USB experience
is lacking at best).  It feels like perhaps we're just not keeping
track the xact_pos correctly, but of course I don't know that for
sure...

Anyway, just fishing...  ;)

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


Re: [PATCH 3/3] usb: core: lpm: remove usb3_lpm_enabled in usb_device

2015-11-11 Thread Lu, Baolu



On 11/11/2015 11:10 PM, Alan Stern wrote:

On Wed, 11 Nov 2015, Lu Baolu wrote:


Commit 8306095fd2c1 ("USB: Disable USB 3.0 LPM in critical sections.")
adds usb3_lpm_enabled member to struct usb_device. There is no reference
to this member now. Hence, it could be removed.

Signed-off-by: Lu Baolu 
---
  include/linux/usb.h | 1 -
  1 file changed, 1 deletion(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 211664f..036e4a5 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -583,7 +583,6 @@ struct usb_device {
unsigned usb2_hw_lpm_besl_capable:1;
unsigned usb2_hw_lpm_enabled:1;
unsigned usb2_hw_lpm_allowed:1;
-   unsigned usb3_lpm_enabled:1;
unsigned usb3_lpm_u1_enabled:1;
unsigned usb3_lpm_u2_enabled:1;
int string_langid;

You forgot to remove the kerneldoc for this field.  And you forgot to
add kerneldoc for usb3_lpm_u[12]_enabled.


Yes. I will fix this in v2.



Alan Stern


Thanks,
Baolu



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



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


[PATCH v2 3/3] usb: core: lpm: remove usb3_lpm_enabled in usb_device

2015-11-11 Thread Lu Baolu
Commit 8306095fd2c1 ("USB: Disable USB 3.0 LPM in critical sections.")
adds usb3_lpm_enabled member to struct usb_device. There is no reference
to this member now. Hence, it could be removed.

Signed-off-by: Lu Baolu 
---
 include/linux/usb.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index b79925d..89533ba 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -510,7 +510,6 @@ struct usb3_lpm_parameters {
  * @usb2_hw_lpm_besl_capable: device can perform USB2 hardware BESL LPM
  * @usb2_hw_lpm_enabled: USB2 hardware LPM is enabled
  * @usb2_hw_lpm_allowed: Userspace allows USB 2.0 LPM to be enabled
- * @usb3_lpm_enabled: USB3 hardware LPM enabled
  * @usb3_lpm_u1_enabled: USB3 hardware U1 LPM enabled
  * @usb3_lpm_u2_enabled: USB3 hardware U2 LPM enabled
  * @string_langid: language ID for strings
@@ -585,7 +584,6 @@ struct usb_device {
unsigned usb2_hw_lpm_besl_capable:1;
unsigned usb2_hw_lpm_enabled:1;
unsigned usb2_hw_lpm_allowed:1;
-   unsigned usb3_lpm_enabled:1;
unsigned usb3_lpm_u1_enabled:1;
unsigned usb3_lpm_u2_enabled:1;
int string_langid;
-- 
2.1.4

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


[PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node

2015-11-11 Thread Lu Baolu
Commit 655fe4effe0f ("usbcore: add sysfs support to xHCI usb3
hardware LPM") introduced usb3_hardware_lpm sysfs node. This
doesn't show the correct status of USB3 U1 and U2 LPM status.

This patch fixes this by replacing usb3_hardware_lpm with two
nodes, usb3_hardware_lpm_u1 (for U1) and usb3_hardware_lpm_u2
(for U2), and recording the U1/U2 LPM status in right places.

This patch should be back-ported to kernels as old as 4.3,
that contains Commit 655fe4effe0f ("usbcore: add sysfs support
to xHCI usb3 hardware LPM").

Cc: sta...@vger.kernel.org
Signed-off-by: Lu Baolu 
---
 Documentation/ABI/testing/sysfs-bus-usb | 16 +---
 Documentation/usb/power-management.txt  | 11 ++-
 drivers/usb/core/hub.c  | 20 ++--
 drivers/usb/core/sysfs.c| 31 ++-
 include/linux/usb.h |  4 
 5 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 3a4abfc..136ba17 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -134,19 +134,21 @@ Description:
enabled for the device. Developer can write y/Y/1 or n/N/0 to
the file to enable/disable the feature.
 
-What:  /sys/bus/usb/devices/.../power/usb3_hardware_lpm
-Date:  June 2015
+What:  /sys/bus/usb/devices/.../power/usb3_hardware_lpm_u1
+   /sys/bus/usb/devices/.../power/usb3_hardware_lpm_u2
+Date:  November 2015
 Contact:   Kevin Strasser 
+   Lu Baolu 
 Description:
If CONFIG_PM is set and a USB 3.0 lpm-capable device is plugged
in to a xHCI host which supports link PM, it will check if U1
and U2 exit latencies have been set in the BOS descriptor; if
-   the check is is passed and the host supports USB3 hardware LPM,
+   the check is passed and the host supports USB3 hardware LPM,
USB3 hardware LPM will be enabled for the device and the USB
-   device directory will contain a file named
-   power/usb3_hardware_lpm. The file holds a string value (enable
-   or disable) indicating whether or not USB3 hardware LPM is
-   enabled for the device.
+   device directory will contain two files named
+   power/usb3_hardware_lpm_u1 and power/usb3_hardware_lpm_u2. These
+   files hold a string value (enable or disable) indicating whether
+   or not USB3 hardware LPM U1 or U2 is enabled for the device.
 
 What:  /sys/bus/usb/devices/.../removable
 Date:  February 2012
diff --git a/Documentation/usb/power-management.txt 
b/Documentation/usb/power-management.txt
index 4a15c90..0a94ffe 100644
--- a/Documentation/usb/power-management.txt
+++ b/Documentation/usb/power-management.txt
@@ -537,17 +537,18 @@ relevant attribute files are usb2_hardware_lpm and 
usb3_hardware_lpm.
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.
 
-   power/usb3_hardware_lpm
+   power/usb3_hardware_lpm_u1
+   power/usb3_hardware_lpm_u2
 
When a USB 3.0 lpm-capable device is plugged in to a
xHCI host which supports link PM, it will check if U1
and U2 exit latencies have been set in the BOS
descriptor; if the check is is passed and the host
supports USB3 hardware LPM, USB3 hardware LPM will be
-   enabled for the device and this file will be created.
-   The file holds a string value (enable or disable)
-   indicating whether or not USB3 hardware LPM is
-   enabled for the device.
+   enabled for the device and these files will be created.
+   The files hold a string value (enable or disable)
+   indicating whether or not USB3 hardware LPM U1 or U2
+   is enabled for the device.
 
USB Port Power Control
--
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bdeadc1..4eb7369 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3875,17 +3875,23 @@ static void usb_enable_link_state(struct usb_hcd *hcd, 
struct usb_device *udev,
return;
}
 
-   if (usb_set_lpm_timeout(udev, state, timeout))
+   ret = usb_set_lpm_timeout(udev, state, timeout);
+   if (ret)
/* If we can't set the parent hub U1/U2 timeout,
 * device-initiated LPM won't be allowed either, so let the xHCI
 * host know that this link state won't be enabled.
 */
hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state);
-
/* Only a configured device will a

[PATCH v2 0/3] usb: core: lpm: add sysfs node for usb3 lpm permit

2015-11-11 Thread Lu Baolu
Hi,

This patch series is about to add a sysfs attribute, through which
users can disable or enable USB3 LPM (link power management) from
a USB port. Once LPM is disabled from the USB port, LPM between the
downstreaming device and the hub port will not be activated. This
helps users to use any LPM-unfriendly USB devices on any released
Linux kernels.

This patch series contains a fix and a cleanup as well.

Change log:
v1->v2:
Fix the "make htmldoc" warning reported by 0-day robot.

Thanks,
Baolu

Lu Baolu (3):
  usb: core: lpm: fix usb3_hardware_lpm sysfs node
  usb: core: lpm: add sysfs node for usb3 lpm permit
  usb: core: lpm: remove usb3_lpm_enabled in usb_device

 Documentation/ABI/testing/sysfs-bus-usb | 27 +++---
 Documentation/usb/power-management.txt  | 11 ++--
 drivers/usb/core/hub.c  | 33 +---
 drivers/usb/core/hub.h  |  5 +-
 drivers/usb/core/port.c | 89 -
 drivers/usb/core/sysfs.c| 31 ++--
 include/linux/usb.h |  6 ++-
 7 files changed, 174 insertions(+), 28 deletions(-)

-- 
2.1.4

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


[PATCH v2 2/3] usb: core: lpm: add sysfs node for usb3 lpm permit

2015-11-11 Thread Lu Baolu
USB3 LPM is default on in Linux kernel if both xHCI host controller
and the USB devices declare to be LPM-capable. Unfortunately, some
devices are known to work well with LPM disabled, but to be broken
if LPM is enabled, although it declares the LPM capability.  Users
won't be able to use this kind of devices, until someone puts them
in the kernel blacklist and gets the kernel upgraded.

This patch adds a sysfs node to permit or forbit USB3 LPM U1 or U2
entry for a port. The settings apply to both before and after device
enumeration. Supported values are "0" - neither u1 nor u2 permitted,
"u1" - only u1 is permitted, "u2" - only u2 is permitted, "u1_u2" -
both u1 and u2 are permitted. With this interface, users can use an
LPM-unfriendly USB device on a released Linux kernel.

Signed-off-by: Lu Baolu 
Signed-off-by: Zhuang Jin Can 
---
 Documentation/ABI/testing/sysfs-bus-usb | 11 
 drivers/usb/core/hub.c  | 15 +-
 drivers/usb/core/hub.h  |  5 +-
 drivers/usb/core/port.c | 89 -
 4 files changed, 116 insertions(+), 4 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 136ba17..0bd731c 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -189,6 +189,17 @@ Description:
The file will read "hotplug", "wired" and "not used" if the
information is available, and "unknown" otherwise.
 
+What:  /sys/bus/usb/devices/.../(hub interface)/portX/usb3_lpm_permit
+Date:  November 2015
+Contact:   Lu Baolu 
+Description:
+   Some USB3.0 devices are not friendly to USB3 LPM.  
usb3_lpm_permit
+   attribute allows enabling/disabling usb3 lpm of a port. It takes
+   effect both before and after a usb device is enumerated. 
Supported
+   values are "0" if both u1 and u2 are NOT permitted, "u1" if 
only u1
+   is permitted, "u2" if only u2 is permitted, "u1_u2" if both u1 
and
+   u2 are permitted.
+
 What:  /sys/bus/usb/devices/.../power/usb2_lpm_l1_timeout
 Date:  May 2013
 Contact:   Mathias Nyman 
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4eb7369..9df568e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4007,6 +4007,8 @@ EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm);
 void usb_enable_lpm(struct usb_device *udev)
 {
struct usb_hcd *hcd;
+   struct usb_hub *hub;
+   struct usb_port *port_dev;
 
if (!udev || !udev->parent ||
udev->speed != USB_SPEED_SUPER ||
@@ -4026,8 +4028,17 @@ void usb_enable_lpm(struct usb_device *udev)
if (udev->lpm_disable_count > 0)
return;
 
-   usb_enable_link_state(hcd, udev, USB3_LPM_U1);
-   usb_enable_link_state(hcd, udev, USB3_LPM_U2);
+   hub = usb_hub_to_struct_hub(udev->parent);
+   if (!hub)
+   return;
+
+   port_dev = hub->ports[udev->portnum - 1];
+
+   if (port_dev->usb3_lpm_u1_permit)
+   usb_enable_link_state(hcd, udev, USB3_LPM_U1);
+
+   if (port_dev->usb3_lpm_u2_permit)
+   usb_enable_link_state(hcd, udev, USB3_LPM_U2);
 }
 EXPORT_SYMBOL_GPL(usb_enable_lpm);
 
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 688817f..45d070d 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -92,6 +92,8 @@ struct usb_hub {
  * @status_lock: synchronize port_event() vs usb_port_{suspend|resume}
  * @portnum: port index num based one
  * @is_superspeed cache super-speed status
+ * @usb3_lpm_u1_permit: whether USB3 U1 LPM is permitted.
+ * @usb3_lpm_u2_permit: whether USB3 U2 LPM is permitted.
  */
 struct usb_port {
struct usb_device *child;
@@ -104,6 +106,8 @@ struct usb_port {
struct mutex status_lock;
u8 portnum;
unsigned int is_superspeed:1;
+   unsigned int usb3_lpm_u1_permit:1;
+   unsigned int usb3_lpm_u2_permit:1;
 };
 
 #define to_usb_port(_dev) \
@@ -155,4 +159,3 @@ static inline int hub_port_debounce_be_stable(struct 
usb_hub *hub,
 {
return hub_port_debounce(hub, port1, false);
 }
-
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 2106183..cb18ce0 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -50,6 +50,72 @@ static ssize_t connect_type_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(connect_type);
 
+static ssize_t usb3_lpm_permit_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   struct usb_port *port_dev = to_usb_port(dev);
+   const char *p;
+
+   if (port_dev->usb3_lpm_u1_permit) {
+   if (port_dev->usb3_lpm_u2_permit)
+   p = "u1_u2";
+   else
+   p = "u1";
+   } else {
+   if (port_dev->usb3_lpm_u2_per

Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port

2015-11-11 Thread Lu, Baolu

Hi Dave,

Which device are you testing with? This implementation was developed
and tested on Intel Skylake devices.

It doesn't surprise me if it doesn't work with other silicons. But it do
remind me to create a verified-list and put those known-to-work devices
in it.

Thanks,
Baolu

On 11/11/2015 10:25 AM, Dave Young wrote:

Hi,

On 11/11/15 at 09:32am, Lu, Baolu wrote:


On 11/10/2015 05:39 PM, Dave Young wrote:

Hi,

On 11/09/15 at 03:38pm, Lu Baolu wrote:

This patch series adds support for early printk through USB3 debug port.
USB3 debug port is described in xHCI specification as an optional extended
capability.


I did a test with your previous patchset with the manually wired cable.
debug host detected the remote device, but later the devie automaticlly
disconnected and earlyprintk hangs.

Hi Dave,

What I have done is:

Retested it, seems it is not stable. I got a sucessful boot with earlyprintk
But only once and there was no "Press Y to continue", I just blindly pressed Y.

The other tests failed.

Since it is not convinience to test, do you have way to enable the dbc
after kernel boot? like echo 1 to a sysfs file to enable it.

(1) Build a new kernel for debug target with this patch series applied.
(2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
  "keep" option for early printk doesn't support yet. (That's my next
  target.)

(3) Boot the debug host, and disable USB runtime suspend:

# echo on > /sys/bus/pci/devices//power/control
# echo on | tee /sys/bus/usb/devices/*/power/control

(4) Boot the debug target. Check the dmesg message on debug host.

# tail -f /var/log/kern.log

Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed USB
device number 4 using xhci_hcd
Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit latency
is zeroed, disabling LPM.
Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device
found, idVendor=1d6b, idProduct=0004
Nov 12 01:27:50 allen-ult kernel: [ 1815.02] usb 4-3: New USB device
strings: Mfr=1, Product=2, SerialNumber=3
Nov 12 01:27:50 allen-ult kernel: [ 1815.03] usb 4-3: Product: Remote
GDB
Nov 12 01:27:50 allen-ult kernel: [ 1815.04] usb 4-3: Manufacturer:
Linux
Nov 12 01:27:50 allen-ult kernel: [ 1815.05] usb 4-3: SerialNumber: 0001
Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc
converter detected
Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc converter
now attached to ttyUSB0

(5) Host has completed enumeration of debug device. Start "minicom" on debug
host.


Most times I have no chance to run minicom before the usb disconnection here.


Welcome to minicom 2.7

OPTIONS: I18n
Compiled on Jan  1 2014, 17:13:19.
Port /dev/ttyUSB0, 01:28:02

Press CTRL-A Z for help on special keys

Press Y to continue...

(6) You should be able to see "Press Y to continue..." (if not, try pressing
Enter key)
Press Y key, debug target should go ahead with boot and early boot messages
should show in mincom.

Press Y to continue...
[0.00] Initializing cgroup subsys cpuset
[0.00] Initializing cgroup subsys cpu
[0.00] Initializing cgroup subsys cpuacct
[0.00] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 4.8.4
(Ubuntu 4.8.4-2ubuntu1~14.04) 5
[0.00] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+
root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
[0.00] KERNEL supported cpus:

[...skipped...]

[0.00]  Offload RCU callbacks from CPUs: 0-7.
[0.00] Console: colour dummy device 80x25
[0.00] console [tty0] enabled
[0.00] bootconsole [earlyxdbc0] disabled


So "the devie automaticlly disconnected and earlyprintk hangs" happens in
which step?


Here is some log on host side.

[ 1568.052135] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
[ 1568.063416] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1568.063750] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1568.063751] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1568.063752] usb 2-2: Product: Remote GDB
[ 1568.063753] usb 2-2: Manufacturer: Linux
[ 1568.063754] usb 2-2: SerialNumber: 0001
[ 1568.065580] usb_debug 2-2:1.0: xhci_dbc converter detected
[ 1568.066309] usb 2-2: xhci_dbc converter now attached to ttyUSB0
[ 1580.464706] usb 2-2: USB disconnect, device number 5
[ 1580.464996] xhci_dbc ttyUSB0: xhci_dbc converter now disconnected from 
ttyUSB0
[ 1580.465062] usb_debug 2-2:1.0: device disconnected
[ 1580.670743] usb 2-2: new SuperSpeed USB device number 6 using xhci_hcd
[ 1580.682068] usb 2-2: LPM exit latency is zeroed, disabling LPM.
[ 1580.682667] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
[ 1580.682672] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1580.682675] usb 2-2: Product: Remote GDB
[ 1580.682678] usb 2-2: Manufacturer: Linux
[ 1580.682681] usb 2-2: SerialNumber: 0001
[ 1580.685190] usb_debug 2-2:1.0: xhci

Re: [RFC] usb: dwc2: hcd: fix split schedule issue

2015-11-11 Thread John Youn
On 11/11/2015 4:22 PM, Doug Anderson wrote:
> John,
> 
> On Fri, Nov 6, 2015 at 2:04 AM, Yunzhi Li  wrote:
>> hi John ,
>>
>>   As we talked yesterday, I tried to fix the split schedule sequence. This
>> patch will
>> avoid scheduling SSPLIT-IN packet for another device between
>> SSPLIT-OUT-begin and
>> SSPLIT-OUT-end, now the keyboard and Jebra audio speaker could work together
>> well, but
>> I'm not sure if this is exactly the right way to schedule split transfers
>> and if there
>> is any dide effect with this patch. Please help review this patch. Thanks.
>>
>>> Fix dwc2 split schedule sequence issue. Not schedule a SSPLIT_IN
>>> packet between SSPLIT-begin and SSPLIT-end.
>>>
>>> Signed-off-by: Yunzhi Li 
>>> ---
>>>   drivers/usb/dwc2/hcd.c | 4 
>>>   1 file changed, 4 insertions(+)
> 
> Did you have any thoughts on this patch?  Although this patch didn't
> fix the problems I was seeing with the Microsoft Wireless Keyboard
> (see the patch I sent out earlier which does seem to fix it), I can
> confirm that in a different setup (HUB goes to USB audio + mouse) that
> this patch does fix some problems.
> 
> That being said, it feels to me like a band-aid rather than an actual
> fix (I'm talking out of my rear end, though, since my USB experience
> is lacking at best).  It feels like perhaps we're just not keeping
> track the xact_pos correctly, but of course I don't know that for
> sure...
> 
> Anyway, just fishing...  ;)
> 
> -Doug
> 

Hi Doug,

I also feel it is not quite right as the SSPLIT should be able to
happen during the SSPLIT of another device. I tried to reproduce
and see the same scheduling but don't see any hang due to it.

Yunzhi, any details on what kind of hub and keyboard you are
using? I have the same Jabra 410 speaker.

Regards,
John




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


Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread John Youn
On 11/11/2015 3:20 PM, Stefan Wahren wrote:
> Hi John,
> 
> Am 11.11.2015 um 00:21 schrieb John Youn:
>> On 11/9/2015 12:43 PM, Stefan Wahren wrote:
>>> Hi,
>>
>> The gadget side required it but it looks like the host side
>> didn't.
>>
>> When Marek did the low-level hw refactor, some of the gadget
>> stuff was brought up to the common layer, including the returning
>> of -EPROBE_DEFER when no phys are defined.
>>
>> I think this requirement can be removed. At least only enforce it
>> for the gadget as before.
>>
>> Could you see if the following fixes it?
> 
> the patch looks okay, but it didn't get USB working after applying your 
> patch in combination with my patch.
> 
> devm_phy_get(hsotg->dev, "usb2-phy") failed, but ret has a value of -38. 
> I don't know where this strange value comes from.

Anyone know where the -38 (-ENOSYS) might be coming from for rpi?
I couldn't see anything obvious.

Do you know if any PHY is defined?

> 
> I also experience issues with my rootfs, so i think could be a problem 
> with my build or the linux-next version. Tomorrow i will try the patches 
> on top of Felipe's repo.
> 

Could you also try this patch that I submitted earlier which just
makes the phy optional and leaves the error handling the same?

http://marc.info/?l=linux-usb&m=144727055711457&w=2

Regards,
John

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


Re: [RFC] usb: dwc2: hcd: fix split schedule issue

2015-11-11 Thread Doug Anderson
John,

On Wed, Nov 11, 2015 at 8:29 PM, John Youn  wrote:
> I also feel it is not quite right as the SSPLIT should be able to
> happen during the SSPLIT of another device. I tried to reproduce
> and see the same scheduling but don't see any hang due to it.
>
> Yunzhi, any details on what kind of hub and keyboard you are
> using? I have the same Jabra 410 speaker.

I saw it with a standard Logitech mouse.  It wasn't a hang, but the
mouse effectively became non-functional (behaved like it hung) when
you started playing audio.  Once the audio stream stopped, the mouse
would work again.  I was using the same Jabra 410 as well.

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 2: Dev 6, If 0, Class=Human Interface Device,
Driver=usbhid, 1.5M
|__ Port 3: Dev 5, If 0, Class=Audio, Driver=snd-usb-audio, 12M
|__ Port 3: Dev 5, If 1, Class=Audio, Driver=snd-usb-audio, 12M
|__ Port 3: Dev 5, If 2, Class=Audio, Driver=snd-usb-audio, 12M
|__ Port 3: Dev 5, If 3, Class=Human Interface Device, Driver=, 12M

Bus 002 Device 005: ID 0b0e:0412 GN Netcom
Bus 002 Device 006: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 002 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

We've also had some discussion of this patch in our bug tracker at
.

I'll keep digging tomorrow, too.

-Doug
--
To unsubscribe from this list: send the line "unsubscribe 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/3] usb: renesas_usbhs: gadget: modifications for g_audio

2015-11-11 Thread Yoshihiro Shimoda
This patch is based on the latest Felipe's usb.git / testing/next branch.
(The commit id = 81e9d14a53eb1abfbe6ac828a87a2deb4702b5f1)

Yoshihiro Shimoda (3):
  usb: renesas_usbhs: gadget: Fix NULL pointer dereference in
usbhsg_ep_dequeue()
  usb: renesas_usbhs: Modify pipe configuration
  usb: renesas_usbhs: Modify ep.caps.type_xxx and
usb_ep_maxpacket_limit()

 drivers/usb/renesas_usbhs/common.c |  69 ++--
 drivers/usb/renesas_usbhs/mod_gadget.c |  30 ++---
 drivers/usb/renesas_usbhs/mod_host.c   |  11 ++--
 drivers/usb/renesas_usbhs/pipe.c   | 112 -
 drivers/usb/renesas_usbhs/pipe.h   |   1 -
 include/linux/usb/renesas_usbhs.h  |  18 +-
 6 files changed, 103 insertions(+), 138 deletions(-)

-- 
1.9.1

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


[PATCH 1/3] usb: renesas_usbhs: gadget: Fix NULL pointer dereference in usbhsg_ep_dequeue()

2015-11-11 Thread Yoshihiro Shimoda
This patch fixes an issue that NULL pointer dereference happens when
a gadget driver calls usb_ep_dequeue() after usb_ep_disable().

Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index de4f97d..8f7a78e 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -131,7 +131,8 @@ static void __usbhsg_queue_pop(struct usbhsg_uep *uep,
struct device *dev = usbhsg_gpriv_to_dev(gpriv);
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
 
-   dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe));
+   if (pipe)
+   dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe));
 
ureq->req.status = status;
spin_unlock(usbhs_priv_to_lock(priv));
@@ -685,7 +686,13 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct 
usb_request *req)
struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
 
-   usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
+   if (pipe)
+   usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
+
+   /*
+* To dequeue a request, this driver should call the usbhsg_queue_pop()
+* even if the pipe is NULL.
+*/
usbhsg_queue_pop(uep, ureq, -ECONNRESET);
 
return 0;
-- 
1.9.1

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


[PATCH 2/3] usb: renesas_usbhs: Modify pipe configuration

2015-11-11 Thread Yoshihiro Shimoda
The current code has info->bufnmb_last to calculate the BUFNMB bits of
PIPEBUF register. However, since the bufnmb_last is initialized in
the usbhs_pipe_init() only, this driver is possible to set unexpected
value to the register if usb_ep_{enable,disable}() are called many times.

So, this patch modifies the pipe configuration via struct
renesas_usbhs_driver_param to simplify the code. Also this patch changes:
 - a double buffer configuration
 - isochronous buffer size from 512 to 1024

Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/common.c   |  69 +++--
 drivers/usb/renesas_usbhs/mod_host.c |  11 ++--
 drivers/usb/renesas_usbhs/pipe.c | 112 ---
 drivers/usb/renesas_usbhs/pipe.h |   1 -
 include/linux/usb/renesas_usbhs.h|  18 +-
 5 files changed, 82 insertions(+), 129 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index 7b98e1d..f023ee9 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -302,37 +302,37 @@ static void usbhsc_set_buswait(struct usbhs_priv *priv)
  */
 
 /* commonly used on old SH-Mobile SoCs */
-static u32 usbhsc_default_pipe_type[] = {
-   USB_ENDPOINT_XFER_CONTROL,
-   USB_ENDPOINT_XFER_ISOC,
-   USB_ENDPOINT_XFER_ISOC,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_INT,
-   USB_ENDPOINT_XFER_INT,
-   USB_ENDPOINT_XFER_INT,
-   USB_ENDPOINT_XFER_INT,
+static struct renesas_usbhs_driver_pipe_config usbhsc_default_pipe[] = {
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_CONTROL, 64, 0x00, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_ISOC, 1024, 0x08, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_ISOC, 1024, 0x18, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x28, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x38, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x48, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x04, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x05, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x06, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x07, false),
 };
 
 /* commonly used on newer SH-Mobile and R-Car SoCs */
-static u32 usbhsc_new_pipe_type[] = {
-   USB_ENDPOINT_XFER_CONTROL,
-   USB_ENDPOINT_XFER_ISOC,
-   USB_ENDPOINT_XFER_ISOC,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_INT,
-   USB_ENDPOINT_XFER_INT,
-   USB_ENDPOINT_XFER_INT,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
-   USB_ENDPOINT_XFER_BULK,
+static struct renesas_usbhs_driver_pipe_config usbhsc_new_pipe[] = {
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_CONTROL, 64, 0x00, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_ISOC, 1024, 0x08, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_ISOC, 1024, 0x28, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x48, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x58, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x68, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x04, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x05, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_INT, 64, 0x06, false),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x78, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x88, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0x98, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0xa8, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0xb8, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0xc8, true),
+   RENESAS_USBHS_PIPE(USB_ENDPOINT_XFER_BULK, 512, 0xd8, true),
 };
 
 /*
@@ -559,10 +559,9 @@ static int usbhs_probe(struct platform_device *pdev)
switch (priv->dparam.type) {
case USBHS_TYPE_RCAR_GEN2:
priv->pfunc = usbhs_rcar2_ops;
-   if (!priv->dparam.pipe_type) {
-   priv->dparam.pipe_type = usbhsc_new_pipe_type;
-   priv->dparam.pipe_size =
-   ARRAY_SIZE(usbhsc_new_pipe_type);
+   if (!priv->dparam.pipe_configs) {
+   priv->dparam.pipe_configs = usbhsc_new_pipe;
+   priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe);
}
brea

[PATCH 3/3] usb: renesas_usbhs: Modify ep.caps.type_xxx and usb_ep_maxpacket_limit()

2015-11-11 Thread Yoshihiro Shimoda
This patch modifies the ep.caps.type_{iso,bulk,int} setting and
the second argument of usb_ep_maxpacket_limit() using
the dparam.pipe_configs.

In the previous code, all the type_{iso,bulk,int} were set to true.
However, to avoid waste time for finding suitable pipe in usb_ep_enable(),
this driver should set correct type.
Also the second argument of usb_ep_maxpacket_limit() was set to 512
even if the pipe is isochronous or interrupt. So, this driver could
not bind a gadget driver like the g_audio driver.

Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index 8f7a78e..657f967 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -1042,6 +1042,8 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
struct usbhsg_gpriv *gpriv;
struct usbhsg_uep *uep;
struct device *dev = usbhs_priv_to_dev(priv);
+   struct renesas_usbhs_driver_pipe_config *pipe_configs =
+   usbhs_get_dparam(priv, pipe_configs);
int pipe_size = usbhs_get_dparam(priv, pipe_size);
int i;
int ret;
@@ -,13 +1113,16 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
gpriv->gadget.ep0 = &uep->ep;
usb_ep_set_maxpacket_limit(&uep->ep, 64);
uep->ep.caps.type_control = true;
-   }
-   /* init normal pipe */
-   else {
-   usb_ep_set_maxpacket_limit(&uep->ep, 512);
-   uep->ep.caps.type_iso = true;
-   uep->ep.caps.type_bulk = true;
-   uep->ep.caps.type_int = true;
+   } else {
+   /* init normal pipe */
+   if (pipe_configs[i].type == USB_ENDPOINT_XFER_ISOC)
+   uep->ep.caps.type_iso = true;
+   if (pipe_configs[i].type == USB_ENDPOINT_XFER_BULK)
+   uep->ep.caps.type_bulk = true;
+   if (pipe_configs[i].type == USB_ENDPOINT_XFER_INT)
+   uep->ep.caps.type_int = true;
+   usb_ep_set_maxpacket_limit(&uep->ep,
+  pipe_configs[i].bufsize);
list_add_tail(&uep->ep.ep_list, &gpriv->gadget.ep_list);
}
uep->ep.caps.dir_in = true;
-- 
1.9.1

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


Re: [PATCH v3 00/12] usb: early: add support for early printk through USB3 debug port

2015-11-11 Thread Dave Young
Hi, Baolu

On 11/12/15 at 10:45am, Lu, Baolu wrote:
> Hi Dave,
> 
> Which device are you testing with? This implementation was developed
> and tested on Intel Skylake devices.
> 
> It doesn't surprise me if it doesn't work with other silicons. But it do
> remind me to create a verified-list and put those known-to-work devices
> in it.
> 

I have not got time to do more test. What infomation do you want? 
lsusb -v?


> Thanks,
> Baolu
> 
> On 11/11/2015 10:25 AM, Dave Young wrote:
> >Hi,
> >
> >On 11/11/15 at 09:32am, Lu, Baolu wrote:
> >>
> >>On 11/10/2015 05:39 PM, Dave Young wrote:
> >>>Hi,
> >>>
> >>>On 11/09/15 at 03:38pm, Lu Baolu wrote:
> This patch series adds support for early printk through USB3 debug port.
> USB3 debug port is described in xHCI specification as an optional extended
> capability.
> 
> >>>I did a test with your previous patchset with the manually wired cable.
> >>>debug host detected the remote device, but later the devie automaticlly
> >>>disconnected and earlyprintk hangs.
> >>Hi Dave,
> >>
> >>What I have done is:
> >Retested it, seems it is not stable. I got a sucessful boot with earlyprintk
> >But only once and there was no "Press Y to continue", I just blindly pressed 
> >Y.
> >
> >The other tests failed.
> >
> >Since it is not convinience to test, do you have way to enable the dbc
> >after kernel boot? like echo 1 to a sysfs file to enable it.
> >>(1) Build a new kernel for debug target with this patch series applied.
> >>(2) Add "earlyprintk=xdbc" to the kernel option of debug target. The
> >>  "keep" option for early printk doesn't support yet. (That's my next
> >>  target.)
> >>
> >>(3) Boot the debug host, and disable USB runtime suspend:
> >>
> >># echo on > /sys/bus/pci/devices//power/control
> >># echo on | tee /sys/bus/usb/devices/*/power/control
> >>
> >>(4) Boot the debug target. Check the dmesg message on debug host.
> >>
> >># tail -f /var/log/kern.log
> >>
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.983374] usb 4-3: new SuperSpeed USB
> >>device number 4 using xhci_hcd
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999595] usb 4-3: LPM exit latency
> >>is zeroed, disabling LPM.
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.999899] usb 4-3: New USB device
> >>found, idVendor=1d6b, idProduct=0004
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.02] usb 4-3: New USB device
> >>strings: Mfr=1, Product=2, SerialNumber=3
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.03] usb 4-3: Product: Remote
> >>GDB
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.04] usb 4-3: Manufacturer:
> >>Linux
> >>Nov 12 01:27:50 allen-ult kernel: [ 1815.05] usb 4-3: SerialNumber: 0001
> >>Nov 12 01:27:50 allen-ult kernel: [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc
> >>converter detected
> >>Nov 12 01:27:50 allen-ult kernel: [ 1816.000360] usb 4-3: xhci_dbc converter
> >>now attached to ttyUSB0
> >>
> >>(5) Host has completed enumeration of debug device. Start "minicom" on debug
> >>host.
> >>
> >Most times I have no chance to run minicom before the usb disconnection here.
> >
> >>Welcome to minicom 2.7
> >>
> >>OPTIONS: I18n
> >>Compiled on Jan  1 2014, 17:13:19.
> >>Port /dev/ttyUSB0, 01:28:02
> >>
> >>Press CTRL-A Z for help on special keys
> >>
> >>Press Y to continue...
> >>
> >>(6) You should be able to see "Press Y to continue..." (if not, try pressing
> >>Enter key)
> >>Press Y key, debug target should go ahead with boot and early boot messages
> >>should show in mincom.
> >>
> >>Press Y to continue...
> >>[0.00] Initializing cgroup subsys cpuset
> >>[0.00] Initializing cgroup subsys cpu
> >>[0.00] Initializing cgroup subsys cpuacct
> >>[0.00] Linux version 4.3.0-rc7+ (allen@blu-skl) (gcc version 4.8.4
> >>(Ubuntu 4.8.4-2ubuntu1~14.04) 5
> >>[0.00] Command line: BOOT_IMAGE=/boot/vmlinuz-4.3.0-rc7+
> >>root=UUID=5a2fb856-0238-4b6e-aa45-beeccb7
> >>[0.00] KERNEL supported cpus:
> >>
> >>[...skipped...]
> >>
> >>[0.00]  Offload RCU callbacks from CPUs: 0-7.
> >>[0.00] Console: colour dummy device 80x25
> >>[0.00] console [tty0] enabled
> >>[0.00] bootconsole [earlyxdbc0] disabled
> >>
> >>
> >>So "the devie automaticlly disconnected and earlyprintk hangs" happens in
> >>which step?
> >>
> >Here is some log on host side.
> >
> >[ 1568.052135] usb 2-2: new SuperSpeed USB device number 5 using xhci_hcd
> >[ 1568.063416] usb 2-2: LPM exit latency is zeroed, disabling LPM.
> >[ 1568.063750] usb 2-2: New USB device found, idVendor=1d6b, idProduct=0004
> >[ 1568.063751] usb 2-2: New USB device strings: Mfr=1, Product=2, 
> >SerialNumber=3
> >[ 1568.063752] usb 2-2: Product: Remote GDB
> >[ 1568.063753] usb 2-2: Manufacturer: Linux
> >[ 1568.063754] usb 2-2: SerialNumber: 0001
> >[ 1568.065580] usb_debug 2-2:1.0: xhci_dbc converter detected
> >[ 1568.066309] usb 2-2: xhci_dbc converter now attached to ttyUSB0
> >[ 1580.464706] usb 2-2: USB disconnect, device number 5
> >[ 1580.464996] xh

Re: usb: dwc2: regression during boot on Raspberry Pi

2015-11-11 Thread Stefan Wahren

Am 12.11.2015 um 05:39 schrieb John Youn:

On 11/11/2015 3:20 PM, Stefan Wahren wrote:

Hi John,

Am 11.11.2015 um 00:21 schrieb John Youn:

On 11/9/2015 12:43 PM, Stefan Wahren wrote:

Hi,


The gadget side required it but it looks like the host side
didn't.

When Marek did the low-level hw refactor, some of the gadget
stuff was brought up to the common layer, including the returning
of -EPROBE_DEFER when no phys are defined.

I think this requirement can be removed. At least only enforce it
for the gadget as before.

Could you see if the following fixes it?


the patch looks okay, but it didn't get USB working after applying your
patch in combination with my patch.

devm_phy_get(hsotg->dev, "usb2-phy") failed, but ret has a value of -38.
I don't know where this strange value comes from.


Anyone know where the -38 (-ENOSYS) might be coming from for rpi?
I couldn't see anything obvious.


I found it. In case IS_ENABLED(CONFIG_GENERIC_PHY) is false
the function devm_phy_get is replace by the following stub:

static inline struct phy *devm_phy_get(struct device *dev, const char 
*string)

{
return ERR_PTR(-ENOSYS);
}



Do you know if any PHY is defined?


This is one reason for the whole discussion. Currently there is no USB 
PHY in the device tree neither a USB PHY driver for the Raspberry Pi.






I also experience issues with my rootfs, so i think could be a problem
with my build or the linux-next version. Tomorrow i will try the patches
on top of Felipe's repo.



Could you also try this patch that I submitted earlier which just
makes the phy optional and leaves the error handling the same?

http://marc.info/?l=linux-usb&m=144727055711457&w=2


This patch was part of the draft i tested before and has no influence.



Regards,
John




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


[PATCH 1/2] usb: chipidea: imx: fix a possible NULL dereference

2015-11-11 Thread LABBE Corentin
of_match_device could return NULL, and so cause a NULL pointer
dereference later. Renaming tmp_dev to of_id (like all others do) in the
process.

Reported-by: coverity (CID 1324135)
Signed-off-by: LABBE Corentin 
---
 drivers/usb/chipidea/usbmisc_imx.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/usbmisc_imx.c 
b/drivers/usb/chipidea/usbmisc_imx.c
index fcea4eb..ab8b027 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -500,7 +500,11 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
 {
struct resource *res;
struct imx_usbmisc *data;
-   struct of_device_id *tmp_dev;
+   const struct of_device_id *of_id;
+
+   of_id = of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
+   if (!of_id)
+   return -ENODEV;
 
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -513,9 +517,7 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
if (IS_ERR(data->base))
return PTR_ERR(data->base);
 
-   tmp_dev = (struct of_device_id *)
-   of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
-   data->ops = (const struct usbmisc_ops *)tmp_dev->data;
+   data->ops = (const struct usbmisc_ops *)of_id->data;
platform_set_drvdata(pdev, data);
 
return 0;
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe 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] usb: chipidea: imx: fix a possible NULL dereference

2015-11-11 Thread LABBE Corentin
of_match_device could return NULL, and so cause a NULL pointer
dereference later.

Reported-by: coverity (CID 1324138)
Signed-off-by: LABBE Corentin 
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 6ccbf60..a021bd5 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -145,9 +145,14 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
.flags  = CI_HDRC_SET_NON_ZERO_TTHA,
};
int ret;
-   const struct of_device_id *of_id =
-   of_match_device(ci_hdrc_imx_dt_ids, &pdev->dev);
-   const struct ci_hdrc_imx_platform_flag *imx_platform_flag = of_id->data;
+   const struct of_device_id *of_id;
+   const struct ci_hdrc_imx_platform_flag *imx_platform_flag;
+
+   of_id = of_match_device(ci_hdrc_imx_dt_ids, &pdev->dev);
+   if (!of_id)
+   return -ENODEV;
+
+   imx_platform_flag = of_id->data;
 
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
-- 
2.4.10

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


[PATCH] usb: phy: msm: fix a possible NULL dereference

2015-11-11 Thread LABBE Corentin
of_match_device could return NULL, and so cause a NULL pointer
dereference later. Renaming id to of_id (like all others do) in the
process.

Reported-by: coverity (CID 1324133)
Signed-off-by: LABBE Corentin 
---
 drivers/usb/phy/phy-msm-usb.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 80eb991..c4a66cf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1506,20 +1506,23 @@ static int msm_otg_read_dt(struct platform_device 
*pdev, struct msm_otg *motg)
 {
struct msm_otg_platform_data *pdata;
struct extcon_dev *ext_id, *ext_vbus;
-   const struct of_device_id *id;
+   const struct of_device_id *of_id;
struct device_node *node = pdev->dev.of_node;
struct property *prop;
int len, ret, words;
u32 val, tmp[3];
 
+   of_id = of_match_device(msm_otg_dt_match, &pdev->dev);
+   if (!of_id)
+   return -ENODEV;
+
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
 
motg->pdata = pdata;
 
-   id = of_match_device(msm_otg_dt_match, &pdev->dev);
-   pdata->phy_type = (enum msm_usb_phy_type) id->data;
+   pdata->phy_type = (enum msm_usb_phy_type)of_id->data;
 
motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
if (IS_ERR(motg->link_rst))
-- 
2.4.10

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


[PATCH] usb: phy: phy-mxs-usb: fix a possible NULL dereference

2015-11-11 Thread LABBE Corentin
of_match_device could return NULL, and so cause a NULL pointer
dereference later.

Signed-off-by: LABBE Corentin 
---
 drivers/usb/phy/phy-mxs-usb.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 4d863eb..b7536af 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -452,10 +452,13 @@ static int mxs_phy_probe(struct platform_device *pdev)
struct clk *clk;
struct mxs_phy *mxs_phy;
int ret;
-   const struct of_device_id *of_id =
-   of_match_device(mxs_phy_dt_ids, &pdev->dev);
+   const struct of_device_id *of_id;
struct device_node *np = pdev->dev.of_node;
 
+   of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev);
+   if (!of_id)
+   return -ENODEV;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base))
-- 
2.4.10

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