[PATCH 8/9 v2] usb: usb251xb: Add max power/current dts property support

2017-09-16 Thread Serge Semin
This parameters may be varied in accordance with hardware specifics.
So lets add the corresponding settings to the usb251x driver dts
specification.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt   |  6 ++
 drivers/usb/misc/usb251xb.c  | 20 
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index 3d84626d3..dd59a32e7 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -44,6 +44,12 @@ Optional properties :
device connected.
  - sp-disabled-ports : Specifies the ports which will be self-power disabled
  - bp-disabled-ports : Specifies the ports which will be bus-power disabled
+ - sp-max-{power,current} : Indicates the power/current consumed by hub from
+   an upstream port (VBUS) when operation as a self-powered hub. The value
+   is given in mA in a 0 - 100 range (default is 1mA).
+ - bp-max-{power,current} : Indicates the power/current consumed by hub from
+   an upstream port (VBUS) when operation as a bus-powered hub. The value
+   is given in mA in a 0 - 510 range (default is 100mA).
  - power-on-time-ms : Specifies the time it takes from the time the host
initiates the power-on sequence to a port until the port has adequate
power. The value is given in ms in a 0 - 510 range (default is 100ms).
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index c308b0006..71994b883 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -497,6 +497,22 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
}
}
 
+   hub->max_power_sp = USB251XB_DEF_MAX_POWER_SELF;
+   if (!of_property_read_u32(np, "sp-max-power", &property_u32))
+   hub->max_power_sp = min_t(u8, property_u32 / 2, 50);
+
+   hub->max_power_bp = USB251XB_DEF_MAX_POWER_BUS;
+   if (!of_property_read_u32(np, "bp-max-power", &property_u32))
+   hub->max_power_bp = min_t(u8, property_u32 / 2, 255);
+
+   hub->max_current_sp = USB251XB_DEF_MAX_CURRENT_SELF;
+   if (!of_property_read_u32(np, "sp-max-current", &property_u32))
+   hub->max_current_sp = min_t(u8, property_u32 / 2, 50);
+
+   hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
+   if (!of_property_read_u32(np, "bp-max-current", &property_u32))
+   hub->max_current_bp = min_t(u8, property_u32 / 2, 255);
+
hub->power_on_time = USB251XB_DEF_POWER_ON_TIME;
if (!of_property_read_u32(np, "power-on-time-ms", &property_u32))
hub->power_on_time = min_t(u8, property_u32 / 2, 255);
@@ -536,10 +552,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
/* The following parameters are currently not exposed to devicetree, but
 * may be as soon as needed.
 */
-   hub->max_power_sp = USB251XB_DEF_MAX_POWER_SELF;
-   hub->max_power_bp = USB251XB_DEF_MAX_POWER_BUS;
-   hub->max_current_sp = USB251XB_DEF_MAX_CURRENT_SELF;
-   hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE;
hub->boost_up = USB251XB_DEF_BOOST_UP;
hub->boost_57 = USB251XB_DEF_BOOST_57;
-- 
2.12.0

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


[PATCH 6/9 v2] usb: usb251xb: Add USB2517 LED settings

2017-09-16 Thread Serge Semin
USB2517 supports two LED modes: USB mode (default) and speed indication
mode. The last one can be switched on by corresponding dts property.
Since USB251xb hubs doesn't support LEDs settings, we need to ignore
this setting.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt |  1 +
 drivers/usb/misc/usb251xb.c| 14 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index 1682d4087..3d84626d3 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -37,6 +37,7 @@ Optional properties :
an invalid value is given, the default is used instead.
  - compound-device : indicate the hub is part of a compound device
  - port-mapping-mode : enable port mapping mode
+ - speed-led-mode : led speed indiation mode selection (usb2517 only)
  - string-support : enable string descriptor support (required for 
manufacturer,
product and serial string configuration)
  - non-removable-ports : Should specify the ports which have a non-removable
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 0834729d1..51cc53ddc 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -49,7 +49,7 @@
 #define USB251XB_ADDR_CONFIG_DATA_20x07
 #define USB251XB_DEF_CONFIG_DATA_2 0x20
 #define USB251XB_ADDR_CONFIG_DATA_30x08
-#define USB251XB_DEF_CONFIG_DATA_3 0x02
+#define USB251XB_DEF_CONFIG_DATA_3 0x00
 
 #define USB251XB_ADDR_NON_REMOVABLE_DEVICES0x09
 #define USB251XB_DEF_NON_REMOVABLE_DEVICES 0x00
@@ -164,6 +164,7 @@ struct usb251xb {
 struct usb251xb_data {
u16 product_id;
u8 port_cnt;
+   bool led_support;
bool bat_support;
char product_str[USB251XB_STRING_BUFSIZE / 2]; /* ASCII string */
 };
@@ -171,6 +172,7 @@ struct usb251xb_data {
 static const struct usb251xb_data usb2512b_data = {
.product_id = 0x2512,
.port_cnt = 2,
+   .led_support = false,
.bat_support = true,
.product_str = "USB2512B",
 };
@@ -178,6 +180,7 @@ static const struct usb251xb_data usb2512b_data = {
 static const struct usb251xb_data usb2512bi_data = {
.product_id = 0x2512,
.port_cnt = 2,
+   .led_support = false,
.bat_support = true,
.product_str = "USB2512Bi",
 };
@@ -185,6 +188,7 @@ static const struct usb251xb_data usb2512bi_data = {
 static const struct usb251xb_data usb2513b_data = {
.product_id = 0x2513,
.port_cnt = 3,
+   .led_support = false,
.bat_support = true,
.product_str = "USB2513B",
 };
@@ -192,6 +196,7 @@ static const struct usb251xb_data usb2513b_data = {
 static const struct usb251xb_data usb2513bi_data = {
.product_id = 0x2513,
.port_cnt = 3,
+   .led_support = false,
.bat_support = true,
.product_str = "USB2513Bi",
 };
@@ -199,6 +204,7 @@ static const struct usb251xb_data usb2513bi_data = {
 static const struct usb251xb_data usb2514b_data = {
.product_id = 0x2514,
.port_cnt = 4,
+   .led_support = false,
.bat_support = true,
.product_str = "USB2514B",
 };
@@ -206,6 +212,7 @@ static const struct usb251xb_data usb2514b_data = {
 static const struct usb251xb_data usb2514bi_data = {
.product_id = 0x2514,
.port_cnt = 4,
+   .led_support = false,
.bat_support = true,
.product_str = "USB2514Bi",
 };
@@ -213,6 +220,7 @@ static const struct usb251xb_data usb2514bi_data = {
 static const struct usb251xb_data usb2517_data = {
.product_id = 0x2517,
.port_cnt = 7,
+   .led_support = true,
.bat_support = false,
.product_str = "USB2517",
 };
@@ -220,6 +228,7 @@ static const struct usb251xb_data usb2517_data = {
 static const struct usb251xb_data usb2517i_data = {
.product_id = 0x2517,
.port_cnt = 7,
+   .led_support = true,
.bat_support = false,
.product_str = "USB2517i",
 };
@@ -443,6 +452,9 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
if (of_get_property(np, "port-mapping-mode", NULL))
hub->conf_data3 |= BIT(3);
 
+   if (data->led_support && of_get_property(np, "speed-led-mode", NULL))
+   hub->conf_data3 |= BIT(1);
+
if (of_get_property(np, "string-support", NULL))
hub->conf_data3 |= BIT(0);
 
-- 
2.12.0

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


[PATCH 7/9 v2] usb: usb251xb: Fix property_u32 NULL pointer dereference

2017-09-16 Thread Serge Semin
The methods like of_property_read_u32 utilizing the specified
pointer permit only the pointer to a preallocated u32 storage as the
third argument. As a result the driver crashes on NULL pointer
dereference in case if "oc-delay-us" or "power-on-time-ms" declared
in dts file.

Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 51cc53ddc..c308b0006 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -348,7 +348,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
struct device *dev = hub->dev;
struct device_node *np = dev->of_node;
int len, err, i;
-   u32 *property_u32 = NULL;
+   u32 property_u32 = 0;
const u32 *cproperty_u32;
const char *cproperty_char;
char str[USB251XB_STRING_BUFSIZE / 2];
@@ -425,16 +425,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
if (of_get_property(np, "dynamic-power-switching", NULL))
hub->conf_data2 |= BIT(7);
 
-   if (!of_property_read_u32(np, "oc-delay-us", property_u32)) {
-   if (*property_u32 == 100) {
+   if (!of_property_read_u32(np, "oc-delay-us", &property_u32)) {
+   if (property_u32 == 100) {
/* 100 us*/
hub->conf_data2 &= ~BIT(5);
hub->conf_data2 &= ~BIT(4);
-   } else if (*property_u32 == 4000) {
+   } else if (property_u32 == 4000) {
/* 4 ms */
hub->conf_data2 &= ~BIT(5);
hub->conf_data2 |= BIT(4);
-   } else if (*property_u32 == 16000) {
+   } else if (property_u32 == 16000) {
/* 16 ms */
hub->conf_data2 |= BIT(5);
hub->conf_data2 |= BIT(4);
@@ -498,8 +498,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
}
 
hub->power_on_time = USB251XB_DEF_POWER_ON_TIME;
-   if (!of_property_read_u32(np, "power-on-time-ms", property_u32))
-   hub->power_on_time = min_t(u8, *property_u32 / 2, 255);
+   if (!of_property_read_u32(np, "power-on-time-ms", &property_u32))
+   hub->power_on_time = min_t(u8, property_u32 / 2, 255);
 
if (of_property_read_u16_array(np, "language-id", &hub->lang_id, 1))
hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
-- 
2.12.0

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


[PATCH 9/9 v2] usb: usb251xb: Use GPIO descriptor consumer interface

2017-09-16 Thread Serge Semin
The driver used to be developed with legacy GPIO API support. It's
better to use descriptor-based interface for several reasons. First
of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts
nodes, which is essential since different hardware may have different
GPIOs connectivity including the logical value inversion. Secondly,
by requesting the reset GPIO descriptor the driver prevent the other
applications from changing its value. And last but not least the
legacy GPIO interface should be avoided in the new code due to it
obsolescence.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt |  2 +-
 drivers/usb/misc/usb251xb.c| 34 +-
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index dd59a32e7..7c981d556 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -8,10 +8,10 @@ Required properties :
"microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b",
"microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi",
"microchip,usb2517", "microchip,usb2517i"
- - reset-gpios : Should specify the gpio for hub reset
  - reg : I2C address on the selected bus (default is <0x2C>)
 
 Optional properties :
+ - reset-gpios : Should specify the gpio for hub reset
  - skip-config : Skip Hub configuration, but only send the USB-Attach command
  - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424)
  - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 71994b883..c2dd9742f 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -3,6 +3,7 @@
  * Configuration via SMBus.
  *
  * Copyright (c) 2017 SKIDATA AG
+ * Copyright (c) 2017 T-platforms
  *
  * This work is based on the USB3503 driver by Dongjin Kim and
  * a not-accepted patch by Fabien Lahoudere, see:
@@ -20,12 +21,11 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 /* Internal Register Set Addresses & Default Values acc. to DS1692C */
@@ -127,7 +127,7 @@ struct usb251xb {
struct device *dev;
struct i2c_client *i2c;
u8 skip_config;
-   int gpio_reset;
+   struct gpio_desc *gpio_reset;
u16 vendor_id;
u16 product_id;
u16 device_id;
@@ -235,13 +235,13 @@ static const struct usb251xb_data usb2517i_data = {
 
 static void usb251xb_reset(struct usb251xb *hub, int state)
 {
-   if (!gpio_is_valid(hub->gpio_reset))
+   if (!hub->gpio_reset)
return;
 
-   gpio_set_value_cansleep(hub->gpio_reset, state);
+   gpiod_set_value_cansleep(hub->gpio_reset, state);
 
/* wait for hub recovery/stabilization */
-   if (state)
+   if (!state)
usleep_range(500, 750); /* >=500us at power on */
else
usleep_range(1, 10);/* >=1us at power down */
@@ -260,7 +260,7 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[0] = 0x01;
i2c_wb[1] = USB251XB_STATUS_COMMAND_ATTACH;
 
-   usb251xb_reset(hub, 1);
+   usb251xb_reset(hub, 0);
 
err = i2c_smbus_write_i2c_block_data(hub->i2c,
USB251XB_ADDR_STATUS_COMMAND, 2, i2c_wb);
@@ -310,7 +310,7 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[USB251XB_ADDR_PORT_MAP_7]= hub->port_map7;
i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH;
 
-   usb251xb_reset(hub, 1);
+   usb251xb_reset(hub, 0);
 
/* write registers */
for (i = 0; i < (USB251XB_I2C_REG_SZ / USB251XB_I2C_WRITE_SZ); i++) {
@@ -363,19 +363,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
else
hub->skip_config = 0;
 
-   hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0);
-   if (hub->gpio_reset == -EPROBE_DEFER)
+   hub->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+   if (PTR_ERR(hub->gpio_reset) == -EPROBE_DEFER) {
return -EPROBE_DEFER;
-   if (gpio_is_valid(hub->gpio_reset)) {
-   err = devm_gpio_request_one(dev, hub->gpio_reset,
-   GPIOF_OUT_INIT_LOW,
-   "usb251xb reset");
-   if (err) {
-   dev_err(dev,
-   "unable to request GPIO %d as reset pin (%d)\n",
-   hub->gpio_reset, err);
-   return err;
-   }
+   } else if (IS_ERR(hub->gpio_reset)) {
+   err = PTR_ERR(hub->gpio_reset);
+   dev_err(dev, "unable 

[PATCH 4/9 v2] usb: usb251xb: Add 5,6,7 ports boost settings

2017-09-16 Thread Serge Semin
USB electrical signaling drive strength boost bit is also supported
by USB2517 hub. Since it got three addition ports, the designers
needed to add one more register for initialization. It turned out
to be formerly reserved 0xF7. As before we just initialize it with
default zeros.

Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 3de0de93b..44fa7d084 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -94,8 +94,10 @@
 
 #define USB251XB_ADDR_BOOST_UP 0xF6
 #define USB251XB_DEF_BOOST_UP  0x00
-#define USB251XB_ADDR_BOOST_X  0xF8
-#define USB251XB_DEF_BOOST_X   0x00
+#define USB251XB_ADDR_BOOST_57 0xF7
+#define USB251XB_DEF_BOOST_57  0x00
+#define USB251XB_ADDR_BOOST_14 0xF8
+#define USB251XB_DEF_BOOST_14  0x00
 
 #define USB251XB_ADDR_PORT_SWAP0xFA
 #define USB251XB_DEF_PORT_SWAP 0x00
@@ -149,7 +151,8 @@ struct usb251xb {
char serial[USB251XB_STRING_BUFSIZE];
u8  bat_charge_en;
u8  boost_up;
-   u8  boost_x;
+   u8  boost_57;
+   u8  boost_14;
u8  port_swap;
u8  port_map12;
u8  port_map34;
@@ -280,7 +283,8 @@ static int usb251xb_connect(struct usb251xb *hub)
   USB251XB_STRING_BUFSIZE);
i2c_wb[USB251XB_ADDR_BATTERY_CHARGING_ENABLE] = hub->bat_charge_en;
i2c_wb[USB251XB_ADDR_BOOST_UP]  = hub->boost_up;
-   i2c_wb[USB251XB_ADDR_BOOST_X]   = hub->boost_x;
+   i2c_wb[USB251XB_ADDR_BOOST_57]  = hub->boost_57;
+   i2c_wb[USB251XB_ADDR_BOOST_14]  = hub->boost_14;
i2c_wb[USB251XB_ADDR_PORT_SWAP] = hub->port_swap;
i2c_wb[USB251XB_ADDR_PORT_MAP_12]   = hub->port_map12;
i2c_wb[USB251XB_ADDR_PORT_MAP_34]   = hub->port_map34;
@@ -517,7 +521,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE;
hub->boost_up = USB251XB_DEF_BOOST_UP;
-   hub->boost_x = USB251XB_DEF_BOOST_X;
+   hub->boost_57 = USB251XB_DEF_BOOST_57;
+   hub->boost_14 = USB251XB_DEF_BOOST_14;
hub->port_swap = USB251XB_DEF_PORT_SWAP;
hub->port_map12 = USB251XB_DEF_PORT_MAP_12;
hub->port_map34 = USB251XB_DEF_PORT_MAP_34;
-- 
2.12.0

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


[PATCH 5/9 v2] usb: usb251xb: Add battery enable setting flag

2017-09-16 Thread Serge Semin
Battery charging settings are supported by USB251xb hubs only.
USB2517i isn't one of them. So we need to reflect it within the
device-specific data structure. The driver doesn't support dts
property to change this setting, but instead defaults it with zero.
So the flag isn't used anywhere in the driver, but still can be helpful
in future, when necessity of corresponding dts setting arises.

Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 44fa7d084..0834729d1 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -164,54 +164,63 @@ struct usb251xb {
 struct usb251xb_data {
u16 product_id;
u8 port_cnt;
+   bool bat_support;
char product_str[USB251XB_STRING_BUFSIZE / 2]; /* ASCII string */
 };
 
 static const struct usb251xb_data usb2512b_data = {
.product_id = 0x2512,
.port_cnt = 2,
+   .bat_support = true,
.product_str = "USB2512B",
 };
 
 static const struct usb251xb_data usb2512bi_data = {
.product_id = 0x2512,
.port_cnt = 2,
+   .bat_support = true,
.product_str = "USB2512Bi",
 };
 
 static const struct usb251xb_data usb2513b_data = {
.product_id = 0x2513,
.port_cnt = 3,
+   .bat_support = true,
.product_str = "USB2513B",
 };
 
 static const struct usb251xb_data usb2513bi_data = {
.product_id = 0x2513,
.port_cnt = 3,
+   .bat_support = true,
.product_str = "USB2513Bi",
 };
 
 static const struct usb251xb_data usb2514b_data = {
.product_id = 0x2514,
.port_cnt = 4,
+   .bat_support = true,
.product_str = "USB2514B",
 };
 
 static const struct usb251xb_data usb2514bi_data = {
.product_id = 0x2514,
.port_cnt = 4,
+   .bat_support = true,
.product_str = "USB2514Bi",
 };
 
 static const struct usb251xb_data usb2517_data = {
.product_id = 0x2517,
.port_cnt = 7,
+   .bat_support = false,
.product_str = "USB2517",
 };
 
 static const struct usb251xb_data usb2517i_data = {
.product_id = 0x2517,
.port_cnt = 7,
+   .bat_support = false,
.product_str = "USB2517i",
 };
 
-- 
2.12.0

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


[PATCH 2/9 v2] usb: usb251xb: Add USB251x specific port count setting

2017-09-16 Thread Serge Semin
USB251xb as well as USB2517 datasheet states, that all these
hubs differ by number of ports declared as the last digit in the
model name. So USB2512 got two ports, USB2513 - three, and so on.
Such setting must be reflected in the device specific data
structure and corresponding dts property should be checked whether
it doesn't get out of available ports.

Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 96a8c20ac..5cb0e5570 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -154,46 +154,55 @@ struct usb251xb {
 
 struct usb251xb_data {
u16 product_id;
+   u8 port_cnt;
char product_str[USB251XB_STRING_BUFSIZE / 2]; /* ASCII string */
 };
 
 static const struct usb251xb_data usb2512b_data = {
.product_id = 0x2512,
+   .port_cnt = 2,
.product_str = "USB2512B",
 };
 
 static const struct usb251xb_data usb2512bi_data = {
.product_id = 0x2512,
+   .port_cnt = 2,
.product_str = "USB2512Bi",
 };
 
 static const struct usb251xb_data usb2513b_data = {
.product_id = 0x2513,
+   .port_cnt = 3,
.product_str = "USB2513B",
 };
 
 static const struct usb251xb_data usb2513bi_data = {
.product_id = 0x2513,
+   .port_cnt = 3,
.product_str = "USB2513Bi",
 };
 
 static const struct usb251xb_data usb2514b_data = {
.product_id = 0x2514,
+   .port_cnt = 4,
.product_str = "USB2514B",
 };
 
 static const struct usb251xb_data usb2514bi_data = {
.product_id = 0x2514,
+   .port_cnt = 4,
.product_str = "USB2514Bi",
 };
 
 static const struct usb251xb_data usb2517_data = {
.product_id = 0x2517,
+   .port_cnt = 7,
.product_str = "USB2517",
 };
 
 static const struct usb251xb_data usb2517i_data = {
.product_id = 0x2517,
+   .port_cnt = 7,
.product_str = "USB2517i",
 };
 
@@ -422,8 +431,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
for (i = 0; i < len / sizeof(u32); i++) {
u32 port = be32_to_cpu(cproperty_u32[i]);
 
-   if ((port >= 1) && (port <= 4))
+   if ((port >= 1) && (port <= data->port_cnt))
hub->non_rem_dev |= BIT(port);
+   else
+   dev_warn(dev, "port %u doesn't exist\n", port);
}
}
 
@@ -433,8 +444,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
for (i = 0; i < len / sizeof(u32); i++) {
u32 port = be32_to_cpu(cproperty_u32[i]);
 
-   if ((port >= 1) && (port <= 4))
+   if ((port >= 1) && (port <= data->port_cnt))
hub->port_disable_sp |= BIT(port);
+   else
+   dev_warn(dev, "port %u doesn't exist\n", port);
}
}
 
@@ -444,8 +457,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
for (i = 0; i < len / sizeof(u32); i++) {
u32 port = be32_to_cpu(cproperty_u32[i]);
 
-   if ((port >= 1) && (port <= 4))
+   if ((port >= 1) && (port <= data->port_cnt))
hub->port_disable_bp |= BIT(port);
+   else
+   dev_warn(dev, "port %u doesn't exist\n", port);
}
}
 
-- 
2.12.0

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


[PATCH 3/9 v2] usb: usb251xb: Add 5,6,7 ports mapping def setting

2017-09-16 Thread Serge Semin
USB2517 got three additionl downstream ports, which can
as well be mapped to another logical ports. USB2551xb driver
currently doesn't fully support such setting configuration
from dts file. This patch doesn't change this, but adds
usb2517 spcific ports default liner mapping.

Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 5cb0e5570..3de0de93b 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -103,7 +103,11 @@
 #define USB251XB_ADDR_PORT_MAP_12  0xFB
 #define USB251XB_DEF_PORT_MAP_12   0x00
 #define USB251XB_ADDR_PORT_MAP_34  0xFC
-#define USB251XB_DEF_PORT_MAP_34   0x00 /* USB2513B/i & USB2514B/i only */
+#define USB251XB_DEF_PORT_MAP_34   0x00 /* USB251{3B/i,4B/i,7/i} only */
+#define USB251XB_ADDR_PORT_MAP_56  0xFD
+#define USB251XB_DEF_PORT_MAP_56   0x00 /* USB2517/i only */
+#define USB251XB_ADDR_PORT_MAP_7   0xFE
+#define USB251XB_DEF_PORT_MAP_70x00 /* USB2517/i only */
 
 #define USB251XB_ADDR_STATUS_COMMAND   0xFF
 #define USB251XB_STATUS_COMMAND_SMBUS_DOWN 0x04
@@ -149,6 +153,8 @@ struct usb251xb {
u8  port_swap;
u8  port_map12;
u8  port_map34;
+   u8  port_map56;
+   u8  port_map7;
u8  status;
 };
 
@@ -278,6 +284,8 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[USB251XB_ADDR_PORT_SWAP] = hub->port_swap;
i2c_wb[USB251XB_ADDR_PORT_MAP_12]   = hub->port_map12;
i2c_wb[USB251XB_ADDR_PORT_MAP_34]   = hub->port_map34;
+   i2c_wb[USB251XB_ADDR_PORT_MAP_56]   = hub->port_map56;
+   i2c_wb[USB251XB_ADDR_PORT_MAP_7]= hub->port_map7;
i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH;
 
usb251xb_reset(hub, 1);
@@ -513,6 +521,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
hub->port_swap = USB251XB_DEF_PORT_SWAP;
hub->port_map12 = USB251XB_DEF_PORT_MAP_12;
hub->port_map34 = USB251XB_DEF_PORT_MAP_34;
+   hub->port_map56 = USB251XB_DEF_PORT_MAP_56;
+   hub->port_map7  = USB251XB_DEF_PORT_MAP_7;
 
return 0;
 }
-- 
2.12.0

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


[PATCH 1/9 v2] usb: usb251xb: Add USB2517i specific struct and IDs

2017-09-16 Thread Serge Semin
There are USB2517 and USB2517i hubs, which have almost the same
registers space as already supported USB251xbi series. The difference
it in DIDs and in few functions. This patch adds the USB2517/i data
structures to the driver, so it would have different setting depending
on the device discovered on i2c-bus.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt  |  3 ++-
 drivers/usb/misc/usb251xb.c | 21 -
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index 3957d4eda..1682d4087 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -6,7 +6,8 @@ Hi-Speed Controller.
 Required properties :
  - compatible : Should be "microchip,usb251xb" or one of the specific types:
"microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b",
-   "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi"
+   "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi",
+   "microchip,usb2517", "microchip,usb2517i"
  - reset-gpios : Should specify the gpio for hub reset
  - reg : I2C address on the selected bus (default is <0x2C>)
 
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 91f66d68b..96a8c20ac 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -38,6 +38,7 @@
 #define USB251XB_DEF_PRODUCT_ID_12 0x2512 /* USB2512B/12Bi */
 #define USB251XB_DEF_PRODUCT_ID_13 0x2513 /* USB2513B/13Bi */
 #define USB251XB_DEF_PRODUCT_ID_14 0x2514 /* USB2514B/14Bi */
+#define USB251XB_DEF_PRODUCT_ID_17 0x2517 /* USB2517i */
 
 #define USB251XB_ADDR_DEVICE_ID_LSB0x04
 #define USB251XB_ADDR_DEVICE_ID_MSB0x05
@@ -82,7 +83,7 @@
 
 #define USB251XB_ADDR_PRODUCT_STRING_LEN   0x14
 #define USB251XB_ADDR_PRODUCT_STRING   0x54
-#define USB251XB_DEF_PRODUCT_STRING"USB251xB/xBi"
+#define USB251XB_DEF_PRODUCT_STRING"USB251xB/xBi/7i"
 
 #define USB251XB_ADDR_SERIAL_STRING_LEN0x15
 #define USB251XB_ADDR_SERIAL_STRING0x92
@@ -186,6 +187,16 @@ static const struct usb251xb_data usb2514bi_data = {
.product_str = "USB2514Bi",
 };
 
+static const struct usb251xb_data usb2517_data = {
+   .product_id = 0x2517,
+   .product_str = "USB2517",
+};
+
+static const struct usb251xb_data usb2517i_data = {
+   .product_id = 0x2517,
+   .product_str = "USB2517i",
+};
+
 static void usb251xb_reset(struct usb251xb *hub, int state)
 {
if (!gpio_is_valid(hub->gpio_reset))
@@ -511,6 +522,12 @@ static const struct of_device_id usb251xb_of_match[] = {
.compatible = "microchip,usb2514bi",
.data = &usb2514bi_data,
}, {
+   .compatible = "microchip,usb2517",
+   .data = &usb2517_data,
+   }, {
+   .compatible = "microchip,usb2517i",
+   .data = &usb2517i_data,
+   }, {
/* sentinel */
}
 };
@@ -574,6 +591,8 @@ static const struct i2c_device_id usb251xb_id[] = {
{ "usb2513bi", 0 },
{ "usb2514b", 0 },
{ "usb2514bi", 0 },
+   { "usb2517", 0 },
+   { "usb2517i", 0 },
{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(i2c, usb251xb_id);
-- 
2.12.0

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


[PATCH 0/9 v2] usb: usb251xb: Add USB2517i hub support and fix some bugs

2017-09-16 Thread Serge Semin
Primarily it was intended to just add USB2517 hub support to the driver.
But after tests a bug and inconistency were discovered. So it was decided
to make the following changes:

Changelog v1:
- Add USB2517/i hub specifics support to the driver
- Fix property_u32 NULL-pointer dereference
- Add new {bus,self}-max-{power,curret} dts properties
- Replace legacy GPIO API usage with descriptor-based one

Changelog v2:
- Split first patch into smaller ones
- Fix invalid BOOST_14 register definition
- Combine copyrights adding patch into the last one

Serge Semin (9):
  usb: usb251xb: Add USB2517i specific struct and IDs
  usb: usb251xb: Add USB251x specific port count setting
  usb: usb251xb: Add 5,6,7 ports mapping def setting
  usb: usb251xb: Add 5,6,7 ports boost settings
  usb: usb251xb: Add battery enable setting flag
  usb: usb251xb: Add USB2517 LED settings
  usb: usb251xb: Fix property_u32 NULL pointer dereference
  usb: usb251xb: Add max power/current dts property support
  usb: usb251xb: Use GPIO descriptor consumer interface

 Documentation/devicetree/bindings/usb/usb251xb.txt |  12 +-
 drivers/usb/misc/usb251xb.c| 160 +++--
 2 files changed, 128 insertions(+), 44 deletions(-)

-- 
2.12.0

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


Dell WD15 dock causes system freezes

2017-09-16 Thread Piotr Kołaczkowski
Hello!

TL;DR:
I'm having troubles with Dell WD15 dock connected to USB-C of Dell
Precision 5520 laptop.
I'm seeing very frequent kernel freezes, sometimes panics,
particularly on logging into the desktop session.
I first created a ticket on Ubuntu Launchpad, but I have been directed
to here. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1701499

I've tried sending email to the linux-usb list from my private
address, pkola...@gmail.com, but somehow I didn't get any answer -
maybe my email didn't get through or just some incompatibility between
gmail and majordomo (or I don't know how to use it properly). If you
received a similar email previously, I'm sorry for duplicate.

Please at least confirm this email got to the list, because Gmail does
not display it in the inbox... Thanks.

As for the problems.

Hardware:
- Dell Precision 5520 Laptop
- WD15 USB-C Dock
- External Dell U3011 display connected to the dock
- Ethernet cable connected to the dock
- wireless Logitech USB mouse, connected to the laptop directly (nano-receiver)
- Logitech K290 keyboard connected to USB port of the dock

Software:
- Linux 4.12.13 / Linux 4.13.2 taken from Ubuntu ppa/mainline - either
version has this problem(s).
- Bios version: 1.5.0
- WD15 firmware: updated yesterday

Problems:
- If booted with the dock connected, system almost always totally
freezes right after logging into desktop session, always after
displaying the desktop and activating the external display, but before
establishing the ethernet connection. Freeze is total, can't move
mouse pointer, can't switch to TTY with Ctrl-Alt-F1.
- Hotplugging the dock after getting to the grahical login screen
works fine, but attempt to log in ends with freeze just as in the
previous point.
- Sometimes the system doesn't freeze, but ethernet connection doesn't come up.
- Sometimes ethernet connection disconnects and can't be reestablished
without reboot.
- System sometimes fails to resume in the following scenarios:
  -- suspend, disconnect dock, resume
  -- suspend, connect the dock, resume

What works fine:
- Suspend/resume without connecting/disconnecting the dock seems to be
working almost always fine.
- Hotplugging the dock after starting the desktop session works fine
(and is the only reliable workaround for the issue).
- System never freezes before showing LightDM login screen, and at
this point, external display, keyboard and ethernet connection work
fine.
- Laptop alone with no dock connected is perfectly stable.

I didn't spot anything suspicious repeating in the syslog. There have
been some General Protection Faults logged sometimes, but not every
freeze causes logging any error information.
I can send you some recent syslogs, if you wish.

Tell me what else I can do to help you debug the issue and fix it.
I can build kernel from source and test patches if you wish.

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


Fibocom L831-EAU and cdc_mbim

2017-09-16 Thread Andreas Böhler

Hey,

I recently bought a Thinkpad T470 notebook and added the Fibocom 
L831-EAU WWAN card. It's mbim-based, but unfortunately I can't get it to 
work correctly. In fact I'm experiencing similar issues to Patrick 
Chilton, who reported this behaviour a few months ago also on this list: 
https://www.spinics.net/lists/linux-usb/msg158286.html


After a new boot, the card works for me for a few minutes, then all 
transfers stall. Finally, I receive the infamous 'cdc_mbim 1-6:1.0: 
nonzero urb status received: -EPIPE' message in my system log.


I also tried to disable MBIM by adding an option to modprobe. During 
connect, pppd then just hangs up (again similar to what Patrick Chilton 
experienced).


I'm on Arch Linux and Kernel 4.12.13, I tried with and without 
NetworkManager/ModemManager.


Any ideas how I might be able to debug this?

Thanks,
Andreas

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


Gadget mode advice sought

2017-09-16 Thread g4
Greetings,

I'm trying to find the simplest way to develop a bulk mode gadget that
exposes a standard userland IO interface. I've not been able to find
anything suitable but if such a beast does exist please do point me in the
right direction. Failing that please read on.

The appliance collects data via video and other sensors. There is an
intermediate userland processing application that sources from video (V4L2),
SPI, etc.  and would write its output to the host via USB.

V4L2 on the target H3 SoC is only (currently) supported with a 3.4.X kernel.
Thus newer gadget FS options marked as experimental. This may be a
significant constraint, I am not yet sure.

This is an embedded appliance and g_zero does work. Thus I am minded to
extend g_zero, adding fileops etc. so it appears as a standard character
mode driver in /dev. Read() and write() would simply be hooked in to the
source_sink_complete() handler. Does this sense?

Any comments/thought much appreciated.

TAIA

Jerry.

--
To unsubscribe from this list: send the line "unsubscribe 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: Dell WD15 dock causes system freezes

2017-09-16 Thread Greg KH
On Sat, Sep 16, 2017 at 03:02:58PM +0200, Piotr Kołaczkowski wrote:
> Hello!
> 
> TL;DR:
> I'm having troubles with Dell WD15 dock connected to USB-C of Dell
> Precision 5520 laptop.
> I'm seeing very frequent kernel freezes, sometimes panics,
> particularly on logging into the desktop session.
> I first created a ticket on Ubuntu Launchpad, but I have been directed
> to here. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1701499
> 
> I've tried sending email to the linux-usb list from my private
> address, pkola...@gmail.com, but somehow I didn't get any answer -
> maybe my email didn't get through or just some incompatibility between
> gmail and majordomo (or I don't know how to use it properly). If you
> received a similar email previously, I'm sorry for duplicate.

html email is rejected by the mailing lists, odds are that is what
happened there.

> Please at least confirm this email got to the list, because Gmail does
> not display it in the inbox... Thanks.
> 
> As for the problems.
> 
> Hardware:
> - Dell Precision 5520 Laptop
> - WD15 USB-C Dock
> - External Dell U3011 display connected to the dock
> - Ethernet cable connected to the dock
> - wireless Logitech USB mouse, connected to the laptop directly 
> (nano-receiver)
> - Logitech K290 keyboard connected to USB port of the dock
> 
> Software:
> - Linux 4.12.13 / Linux 4.13.2 taken from Ubuntu ppa/mainline - either
> version has this problem(s).
> - Bios version: 1.5.0
> - WD15 firmware: updated yesterday
> 
> Problems:
> - If booted with the dock connected, system almost always totally
> freezes right after logging into desktop session, always after
> displaying the desktop and activating the external display, but before
> establishing the ethernet connection. Freeze is total, can't move
> mouse pointer, can't switch to TTY with Ctrl-Alt-F1.
> - Hotplugging the dock after getting to the grahical login screen
> works fine, but attempt to log in ends with freeze just as in the
> previous point.
> - Sometimes the system doesn't freeze, but ethernet connection doesn't come 
> up.
> - Sometimes ethernet connection disconnects and can't be reestablished
> without reboot.
> - System sometimes fails to resume in the following scenarios:
>   -- suspend, disconnect dock, resume
>   -- suspend, connect the dock, resume
> 
> What works fine:
> - Suspend/resume without connecting/disconnecting the dock seems to be
> working almost always fine.
> - Hotplugging the dock after starting the desktop session works fine
> (and is the only reliable workaround for the issue).
> - System never freezes before showing LightDM login screen, and at
> this point, external display, keyboard and ethernet connection work
> fine.
> - Laptop alone with no dock connected is perfectly stable.
> 
> I didn't spot anything suspicious repeating in the syslog. There have
> been some General Protection Faults logged sometimes, but not every
> freeze causes logging any error information.
> I can send you some recent syslogs, if you wish.

Having a kernel log for when something goes wrong would be great to have
those faults tell us a lot about what the problem might be.  Care to
send them?

Also, check to ensure that you have the latest BIOS update from Dell,
they have been fixing a lot of USB/Thunderbolt issues lately in them,
and I know my Dell laptops just resolved a lot of issues like this with
docking stations when I updated the BIOS.

Also, is this one of the docking stations that needs the firmware
updated?  There are 2 different ones, one a small one the size of a
matchbox, and the other a very large one with a huge power supply.  The
larger one can have its firmware updated and that would also be
something to check that you have the latest version (I don't know if you
can update it from Linux only, sorry, last time I looked I couldn't
figure it out, but that was over a year ago...)

thanks,

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


Yet another Seagate quirk for unusual_uas.h

2017-09-16 Thread Kris Lindgren
Hello all,

I have a Seagate External HDD PN: 9sean2-500 that works fine on USB2.0
ports (and older kernels) however when connected to usb3.0 port on
newer kernels, the drive fails any write access.

dmesg
[ 7232.155430] usb 1-1: new high-speed USB device number 3 using xhci_hcd
[ 7232.366548] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 7232.372833] scsi host6: usb-storage 1-1:1.0
[ 7232.40] [usb.001.003]
/sys/devices/pci:00/:00:14.0/usb1/1-1 added. (MTP mode)
[ 7233.378161] Check proc_name[usb-storage].
[ 7233.382213] scsi 6:0:0:0: Direct-Access Seagate  External
  SG12 PQ: 0 ANSI: 4
[ 7233.391359] Check proc_name[usb-storage].
[ 7233.395405] Check proc_name[usb-storage].
[ 7233.399446] Check proc_name[usb-storage].
[ 7233.403597] Check proc_name[usb-storage].
[ 7233.407925] sd 6:0:0:0: [sdc] 3907029164 512-byte logical blocks:
(2.00 TB/1.81 TiB)
[ 7233.408284] Check proc_name[usb-storage].
[ 7233.409122] sd 6:0:0:0: Attached scsi generic sg2 type 0
[ 7233.425138] Check proc_name[usb-storage].
[ 7233.429258] sd 6:0:0:0: [sdc] Write Protect is off
[ 7233.434082] sd 6:0:0:0: [sdc] Mode Sense: 1c 00 00 00
[ 7233.434725] sd 6:0:0:0: [sdc] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[ 7233.509519]  sdc: sdc1
[ 7233.514748] sd 6:0:0:0: [sdc] Attached SCSI disk
[ 7233.519392] Check proc_name[usb-storage].
[ 7234.604324] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.634329] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.648551] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.666908] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.680716] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.696723] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.709937] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.725250] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.739041] blk_update_request: critical target error, dev sdc, sector 0
[ 7234.894452] JBD2: recovery failed

lsusb:
# lsusb
Bus 002 Device 011: ID 0bc2:3332 Seagate RSS LLC
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 1005:b155 Apacer Technology, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

uname:
# uname -a
Linux NAS 4.2.8 #1 SMP Fri Sep 1 01:08:22 CST 2017 x86_64 GNU/Linux

I did some looking around and based upon a suse article I unloaded the
usb_storage and reloaded it with:
insmod /lib/modules/misc/usb-storage.ko quirks=0bc2:3332:uw

I also tried: quirks=0bc2:3332:u, quirks=0bc2:3332:t and both of those
still resulted in sector 0 errors.

Since then the drive works without any issues:
dmesg:
87955.810319] usbcore: deregistering interface driver usb-storage
[87955.817949] Check proc_name[usb-storage].
[87955.836434] Check proc_name[usb-storage].
[88077.114724] usb-storage 1-5:1.0: USB Mass Storage device detected
[88077.121004] scsi host7: usb-storage 1-5:1.0
[88077.125558] usbcore: registered new interface driver usb-storage
[88078.125454] Check proc_name[usb-storage].
[88078.129499] scsi 7:0:0:0: Direct-Access  USB DISK
MODULE  PMAP PQ: 0 ANSI: 0 CCS
[88078.139018] Check proc_name[usb-storage].
[88078.143076] Check proc_name[usb-storage].
[88078.147121] Check proc_name[usb-storage].
[88078.151230] Check proc_name[usb-storage].
[88078.155366] Check proc_name[usb-storage].
[88078.155800] sd 7:0:0:0: [sdb] 1007616 512-byte logical blocks: (515
MB/492 MiB)
[88078.159485] sd 7:0:0:0: [sdb] Write Protect is off
[88078.159490] sd 7:0:0:0: [sdb] Mode Sense: 23 00 00 00
[88078.166791] sd 7:0:0:0: [sdb] No Caching mode page found
[88078.166794] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[88078.183745] sd 7:0:0:0: Attached scsi generic sg1 type 0
[88078.184349]  sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 sdb6 >
[88078.196597] Check proc_name[usb-storage].
[88078.207147] sd 7:0:0:0: [sdb] Attached SCSI removable disk
[88078.215229] Check proc_name[usb-storage].
[88176.094207] xhci_hcd :00:14.0: Command completion event does
not match command
[88176.101804] xhci_hcd :00:14.0: Timeout while waiting for setup
device command
[88181.326070] xhci_hcd :00:14.0: Timeout while waiting for setup
device command
[88181.534044] usb 2-1: device not accepting address 9, error -62
[88183.336151] usb 2-1: new SuperSpeed USB device number 11 using xhci_hcd
[88183.357090] usb-storage 2-1:1.0: USB Mass Storage device detected
[88183.363355] usb-storage 2-1:1.0: Quirks match for vid 0bc2 pid 3332: 800200
[88183.370500] scsi host8: usb-storage 2-1:1.0
[88183.666134] [usb.002.011]
/sys/devices/pci:00/:00:14.0/usb2/2-1 added. (MTP mode)
[88184.375643] Check proc_name[usb-storage].
[88184.379689] scsi 8:0:0:0: Direct-Access Seagate  External
  SG12 PQ: 0 ANSI: 4
[88184.387937] Check proc_name[usb-storage].
[88184.391992] Check proc_name[usb-storage].
[88184.396033] Check proc_name[usb-sto

Re: HP Thunderbolt 3 Dock (90W): USB does not work

2017-09-16 Thread Matthias Lohr
These specific dmesg messages are from a 4.10.0 kernel, but 4.12,
4.13, 4.13.1 and 4.13.2 have the same problem. Here's the output from
a 4.13.2 kernel:

[...]
[   13.371999] usb 3-2: 2:1: cannot get freq at ep 0x1
[   13.538021] usb 3-2: 2:1: cannot get freq at ep 0x1
[...]

(full dmesg here: https://pastebin.com/1bqtgDJ3)

Best regards
Matthias

2017-09-14 19:41 GMT+02:00 Greg KH :
> On Wed, Sep 13, 2017 at 07:54:21AM +0200, Matthias Lohr wrote:
>> Hello,
>>
>> i'm using a Lenovo Carbon x1 (5th generation) with a HP Thunderbolt 3
>> dock (90W version). All ports are working, except USB Ports - for ~30
>> minutes. After ~30 minutes, also the USB ports get activated.
>>
>> While waiting for that, dmesg shows something like a "loop" through usb 
>> devices:
>>
>> [...]
>> [ 389.023845] usb 3-1: new high-speed USB device number 55 using xhci_hcd
>> [ 389.491841] usb 3-1: new high-speed USB device number 56 using xhci_hcd
>> [ 389.959928] usb 3-1: new high-speed USB device number 57 using xhci_hcd
>> [ 390.427925] usb 3-1: new high-speed USB device number 58 using xhci_hcd
>> [ 390.895832] usb 3-1: new high-speed USB device number 59 using xhci_hcd
>> [ 391.363817] usb 3-1: new high-speed USB device number 60 using xhci_hcd
>> [ 391.831818] usb 3-1: new high-speed USB device number 61 using xhci_hcd
>> [ 392.299759] usb 3-1: new high-speed USB device number 62 using xhci_hcd
>> [ 392.771813] usb 3-1: new high-speed USB device number 63 using xhci_hcd
>> [ 393.239765] usb 3-1: new high-speed USB device number 64 using xhci_hcd
>> [...]
>>
>> Some lines which might be interesting:
>> [ 13.908506] usb 3-2: 2:1: cannot get freq at ep 0x1
>> [ 14.058807] usb 3-2: 2:1: cannot get freq at ep 0x1
>> [ 14.210694] usb 3-2: 2:1: cannot get freq at ep 0x1
>
> what kernel version is this?
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html