RE: [PATCH net 1/2] r8152: fix the sw rx checksum is unavailable

2016-11-17 Thread Hayes Wang
Mark Lord [mailto:ml...@pobox.com]
> Sent: Thursday, November 17, 2016 9:42 PM
[...]
> What the above sample shows, is the URB transfer buffer ran out of space in 
> the
> middle
> of a packet, and the hardware then tried to just continue that same packet in 
> the
> next URB,
> without an rx_desc header inserted.  The r8152.c driver always assumes the URB
> buffer begins
> with an rx_desc, so of course this behaviour produces really weird effects, 
> and
> system crashes, etc..

The USB device wouldn't know the address and size of buffer. Only
the USB host controller knows. Therefore, the device sends the
data to host, and the host fills the memory. According to your
description, it seems the host splits the data from the device
into two different buffers (or URB transfers). I wonder if it would
occur. As far as I know, the host wouldn't allow the buffer size
less than the data length.

Our hw engineers need the log from the USB analyzer to confirm
what the device sends to the host. However, I don't think you
have USB analyzer to do this. I would try to reproduce the issue.
But, I am busy, so I don't think I would response quickly.

Besides, the maximum data length which the RTL8152 would send to
the host is 16KB. That is, if the agg_buf_sz is 16KB, the host
wouldn't split it. However, you still see problems for it.

[...]
> It is not clear to me how the chip decides when to forward an rx URB to the 
> host.
> If you could describe how that part works for us, then it would help in 
> further
> understanding why fast systems (eg. a PC) don't generally notice the issue,
> while much slower embedded systems do see the issue regularly.

The driver expects the rx buffer would be

rx_desc + a packet + padding to 8 alignment + 
rx_desc + a packet + padding to 8 alignment + ...

Therefore, when a urb transfer is completed, the driver parsers
the buffer by this way. After the buffer is handled, it would
be submitted to the host, until the transfer is completed again.
If the submitting fail, the driver would try again later. The
urb->actual_length means how much data the host fills. The drive
uses it to check the end of the data. The urb->status mean if
the transfer is successful. The driver submits the urb to the
host directly if the status is not successful.

Best Regards,
Hayes

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


[PATCH v2 5/5] cdc-acm: handle read pipe errors

2016-11-17 Thread Ladislav Michl
Read urbs are submitted back only on success, causing read pipe
running out of urbs after few errors. No more characters can
be read from tty device then until it is reopened and no errors
are reported.
Fix that by always submitting urbs back and clearing stall on
-EPIPE.

Signed-off-by: Ladislav Michl 
---
Changes:
 - v2: None

 drivers/usb/class/cdc-acm.c | 60 +
 drivers/usb/class/cdc-acm.h |  3 +++
 2 files changed, 53 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 77162a0..2d34cac 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -429,27 +429,41 @@ static void acm_read_bulk_callback(struct urb *urb)
dev_vdbg(>data->dev, "got urb %d, len %d, status %d\n",
rb->index, urb->actual_length, status);
 
+   set_bit(rb->index, >read_urbs_free);
+
if (!acm->dev) {
-   set_bit(rb->index, >read_urbs_free);
dev_dbg(>data->dev, "%s - disconnected\n", __func__);
return;
}
 
-   if (status) {
-   set_bit(rb->index, >read_urbs_free);
-   if ((status != -ENOENT) || (urb->actual_length == 0))
-   return;
+   switch (status) {
+   case 0:
+   usb_mark_last_busy(acm->dev);
+   acm_process_read_urb(acm, urb);
+   break;
+   case -EPIPE:
+   set_bit(EVENT_RX_STALL, >flags);
+   schedule_work(>work);
+   return;
+   case -ENOENT:
+   case -ECONNRESET:
+   case -ESHUTDOWN:
+   dev_dbg(>data->dev,
+   "%s - urb shutting down with status: %d\n",
+   __func__, status);
+   return;
+   default:
+   dev_dbg(>data->dev,
+   "%s - nonzero urb status received: %d\n",
+   __func__, status);
+   break;
}
 
-   usb_mark_last_busy(acm->dev);
-
-   acm_process_read_urb(acm, urb);
/*
 * Unthrottle may run on another CPU which needs to see events
 * in the same order. Submission has an implict barrier
 */
smp_mb__before_atomic();
-   set_bit(rb->index, >read_urbs_free);
 
/* throttle device if requested by tty */
spin_lock_irqsave(>read_lock, flags);
@@ -479,14 +493,30 @@ static void acm_write_bulk(struct urb *urb)
spin_lock_irqsave(>write_lock, flags);
acm_write_done(acm, wb);
spin_unlock_irqrestore(>write_lock, flags);
+   set_bit(EVENT_TTY_WAKEUP, >flags);
schedule_work(>work);
 }
 
 static void acm_softint(struct work_struct *work)
 {
+   int i;
struct acm *acm = container_of(work, struct acm, work);
 
-   tty_port_tty_wakeup(>port);
+   if (test_bit(EVENT_RX_STALL, >flags)) {
+   if (!(usb_autopm_get_interface(acm->data))) {
+   for (i = 0; i < acm->rx_buflimit; i++)
+   usb_kill_urb(acm->read_urbs[i]);
+   usb_clear_halt(acm->dev, acm->in);
+   acm_submit_read_urbs(acm, GFP_KERNEL);
+   usb_autopm_put_interface(acm->data);
+   }
+   clear_bit(EVENT_RX_STALL, >flags);
+   }
+
+   if (test_bit(EVENT_TTY_WAKEUP, >flags)) {
+   tty_port_tty_wakeup(>port);
+   clear_bit(EVENT_TTY_WAKEUP, >flags);
+   }
 }
 
 /*
@@ -1643,6 +1673,15 @@ static int acm_reset_resume(struct usb_interface *intf)
 
 #endif /* CONFIG_PM */
 
+static int acm_pre_reset(struct usb_interface *intf)
+{
+   struct acm *acm = usb_get_intfdata(intf);
+
+   clear_bit(EVENT_RX_STALL, >flags);
+
+   return 0;
+}
+
 #define NOKIA_PCSUITE_ACM_INFO(x) \
USB_DEVICE_AND_INTERFACE_INFO(0x0421, x, \
USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
@@ -1884,6 +1923,7 @@ static struct usb_driver acm_driver = {
.resume =   acm_resume,
.reset_resume = acm_reset_resume,
 #endif
+   .pre_reset =acm_pre_reset,
.id_table = acm_ids,
 #ifdef CONFIG_PM
.supports_autosuspend = 1,
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 58ddd25..1db974d 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -103,6 +103,9 @@ struct acm {
spinlock_t write_lock;
struct mutex mutex;
bool disconnected;
+   unsigned long flags;
+#  define EVENT_TTY_WAKEUP 0
+#  define EVENT_RX_STALL   1
struct usb_cdc_line_coding line;/* bits, stop, parity */
struct work_struct work;/* work queue entry for 
line discipline waking up */
unsigned int ctrlin;/* input control lines 
(DCD, DSR, RI, break, overruns) */
-- 
2.1.4


--
To 

[PATCH v2 4/5] cdc-acm: store in and out pipes in acm structure

2016-11-17 Thread Ladislav Michl
Clearing stall needs pipe descriptor, store it in acm structure.

Signed-off-by: Ladislav Michl 
---
Changes:
 - v2: None

 drivers/usb/class/cdc-acm.c | 27 ++-
 drivers/usb/class/cdc-acm.h |  1 +
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 83f471a..77162a0 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1349,8 +1349,15 @@ static int acm_probe(struct usb_interface *intf,
spin_lock_init(>read_lock);
mutex_init(>mutex);
acm->is_int_ep = usb_endpoint_xfer_int(epread);
-   if (acm->is_int_ep)
+   if (acm->is_int_ep) {
acm->bInterval = epread->bInterval;
+   acm->in = usb_rcvintpipe(usb_dev, epread->bEndpointAddress);
+   } else
+   acm->in = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
+   if (usb_endpoint_xfer_int(epwrite))
+   acm->out = usb_sndintpipe(usb_dev, epwrite->bEndpointAddress);
+   else
+   acm->out = usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress);
tty_port_init(>port);
acm->port.ops = _port_ops;
init_usb_anchor(>delayed);
@@ -1386,16 +1393,12 @@ static int acm_probe(struct usb_interface *intf,
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
urb->transfer_dma = rb->dma;
if (acm->is_int_ep) {
-   usb_fill_int_urb(urb, acm->dev,
-usb_rcvintpipe(usb_dev, 
epread->bEndpointAddress),
-rb->base,
+   usb_fill_int_urb(urb, acm->dev, acm->in, rb->base,
 acm->readsize,
 acm_read_bulk_callback, rb,
 acm->bInterval);
} else {
-   usb_fill_bulk_urb(urb, acm->dev,
- usb_rcvbulkpipe(usb_dev, 
epread->bEndpointAddress),
- rb->base,
+   usb_fill_bulk_urb(urb, acm->dev, acm->in, rb->base,
  acm->readsize,
  acm_read_bulk_callback, rb);
}
@@ -1411,12 +1414,10 @@ static int acm_probe(struct usb_interface *intf,
goto alloc_fail7;
 
if (usb_endpoint_xfer_int(epwrite))
-   usb_fill_int_urb(snd->urb, usb_dev,
-   usb_sndintpipe(usb_dev, 
epwrite->bEndpointAddress),
+   usb_fill_int_urb(snd->urb, usb_dev, acm->out,
NULL, acm->writesize, acm_write_bulk, snd, 
epwrite->bInterval);
else
-   usb_fill_bulk_urb(snd->urb, usb_dev,
-   usb_sndbulkpipe(usb_dev, 
epwrite->bEndpointAddress),
+   usb_fill_bulk_urb(snd->urb, usb_dev, acm->out,
NULL, acm->writesize, acm_write_bulk, snd);
snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
if (quirks & SEND_ZERO_PACKET)
@@ -1488,8 +1489,8 @@ static int acm_probe(struct usb_interface *intf,
}
 
if (quirks & CLEAR_HALT_CONDITIONS) {
-   usb_clear_halt(usb_dev, usb_rcvbulkpipe(usb_dev, 
epread->bEndpointAddress));
-   usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, 
epwrite->bEndpointAddress));
+   usb_clear_halt(usb_dev, acm->in);
+   usb_clear_halt(usb_dev, acm->out);
}
 
return 0;
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 1f1eabf..58ddd25 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -83,6 +83,7 @@ struct acm {
struct usb_device *dev; /* the corresponding 
usb device */
struct usb_interface *control;  /* control interface */
struct usb_interface *data; /* data interface */
+   unsigned in, out;   /* i/o pipes */
struct tty_port port;   /* our tty port data */
struct urb *ctrlurb;/* urbs */
u8 *ctrl_buffer;/* buffers of urbs */
-- 
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 3/5] cdc-acm: refactor killing urbs

2016-11-17 Thread Ladislav Michl
Move urb killing code into separate function and use it
instead of copying that code pattern over.

Signed-off-by: Ladislav Michl 
---
Changes:
 - v2: None

 drivers/usb/class/cdc-acm.c | 43 ---
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 6e3c110..83f471a 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -158,6 +158,17 @@ static inline int acm_set_control(struct acm *acm, int 
control)
 #define acm_send_break(acm, ms) \
acm_ctrl_msg(acm, USB_CDC_REQ_SEND_BREAK, ms, NULL, 0)
 
+static void acm_kill_urbs(struct acm *acm)
+{
+   int i;
+
+   usb_kill_urb(acm->ctrlurb);
+   for (i = 0; i < ACM_NW; i++)
+   usb_kill_urb(acm->wb[i].urb);
+   for (i = 0; i < acm->rx_buflimit; i++)
+   usb_kill_urb(acm->read_urbs[i]);
+}
+
 /*
  * Write buffer management.
  * All of these assume proper locks taken by the caller.
@@ -607,7 +618,6 @@ static void acm_port_shutdown(struct tty_port *port)
struct acm *acm = container_of(port, struct acm, port);
struct urb *urb;
struct acm_wb *wb;
-   int i;
 
/*
 * Need to grab write_lock to prevent race with resume, but no need to
@@ -629,11 +639,7 @@ static void acm_port_shutdown(struct tty_port *port)
usb_autopm_put_interface_async(acm->control);
}
 
-   usb_kill_urb(acm->ctrlurb);
-   for (i = 0; i < ACM_NW; i++)
-   usb_kill_urb(acm->wb[i].urb);
-   for (i = 0; i < acm->rx_buflimit; i++)
-   usb_kill_urb(acm->read_urbs[i]);
+   acm_kill_urbs(acm);
 }
 
 static void acm_tty_cleanup(struct tty_struct *tty)
@@ -1517,24 +1523,10 @@ static int acm_probe(struct usb_interface *intf,
return rv;
 }
 
-static void stop_data_traffic(struct acm *acm)
-{
-   int i;
-
-   usb_kill_urb(acm->ctrlurb);
-   for (i = 0; i < ACM_NW; i++)
-   usb_kill_urb(acm->wb[i].urb);
-   for (i = 0; i < acm->rx_buflimit; i++)
-   usb_kill_urb(acm->read_urbs[i]);
-
-   cancel_work_sync(>work);
-}
-
 static void acm_disconnect(struct usb_interface *intf)
 {
struct acm *acm = usb_get_intfdata(intf);
struct tty_struct *tty;
-   int i;
 
/* sibling interface is already cleaning up */
if (!acm)
@@ -1560,15 +1552,11 @@ static void acm_disconnect(struct usb_interface *intf)
tty_kref_put(tty);
}
 
-   stop_data_traffic(acm);
+   acm_kill_urbs(acm);
+   cancel_work_sync(>work);
 
tty_unregister_device(acm_tty_driver, acm->minor);
 
-   usb_free_urb(acm->ctrlurb);
-   for (i = 0; i < ACM_NW; i++)
-   usb_free_urb(acm->wb[i].urb);
-   for (i = 0; i < acm->rx_buflimit; i++)
-   usb_free_urb(acm->read_urbs[i]);
acm_write_buffers_free(acm);
usb_free_coherent(acm->dev, acm->ctrlsize, acm->ctrl_buffer, 
acm->ctrl_dma);
acm_read_buffers_free(acm);
@@ -1599,7 +1587,8 @@ static int acm_suspend(struct usb_interface *intf, 
pm_message_t message)
if (cnt)
return 0;
 
-   stop_data_traffic(acm);
+   acm_kill_urbs(acm);
+   cancel_work_sync(>work);
 
return 0;
 }
-- 
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/5] cdc-acm: avoid interface_to_usbdev call

2016-11-17 Thread Ladislav Michl
Pointer to usb_device is already stored in acm structure.

Signed-off-by: Ladislav Michl 
---
Changes:
 - v2: None

 drivers/usb/class/cdc-acm.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 4320069..6e3c110 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1087,19 +1087,17 @@ static void acm_write_buffers_free(struct acm *acm)
 {
int i;
struct acm_wb *wb;
-   struct usb_device *usb_dev = interface_to_usbdev(acm->control);
 
for (wb = >wb[0], i = 0; i < ACM_NW; i++, wb++)
-   usb_free_coherent(usb_dev, acm->writesize, wb->buf, wb->dmah);
+   usb_free_coherent(acm->dev, acm->writesize, wb->buf, wb->dmah);
 }
 
 static void acm_read_buffers_free(struct acm *acm)
 {
-   struct usb_device *usb_dev = interface_to_usbdev(acm->control);
int i;
 
for (i = 0; i < acm->rx_buflimit; i++)
-   usb_free_coherent(usb_dev, acm->readsize,
+   usb_free_coherent(acm->dev, acm->readsize,
  acm->read_buffers[i].base, acm->read_buffers[i].dma);
 }
 
@@ -1535,7 +1533,6 @@ static void stop_data_traffic(struct acm *acm)
 static void acm_disconnect(struct usb_interface *intf)
 {
struct acm *acm = usb_get_intfdata(intf);
-   struct usb_device *usb_dev = interface_to_usbdev(intf);
struct tty_struct *tty;
int i;
 
@@ -1573,7 +1570,7 @@ static void acm_disconnect(struct usb_interface *intf)
for (i = 0; i < acm->rx_buflimit; i++)
usb_free_urb(acm->read_urbs[i]);
acm_write_buffers_free(acm);
-   usb_free_coherent(usb_dev, acm->ctrlsize, acm->ctrl_buffer, 
acm->ctrl_dma);
+   usb_free_coherent(acm->dev, acm->ctrlsize, acm->ctrl_buffer, 
acm->ctrl_dma);
acm_read_buffers_free(acm);
 
if (!acm->combined_interfaces)
-- 
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/5] cdc-acm: reindent log messages

2016-11-17 Thread Ladislav Michl
Use only one tab to indent dev_{(v)dbg,err} parameters.

Signed-off-by: Ladislav Michl 
---
Changes:
 - v2: add changelog text.

 drivers/usb/class/cdc-acm.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index fada988..4320069 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -133,8 +133,8 @@ static int acm_ctrl_msg(struct acm *acm, int request, int 
value,
buf, len, 5000);
 
dev_dbg(>control->dev,
-   "%s - rq 0x%02x, val %#x, len %#x, result %d\n",
-   __func__, request, value, len, retval);
+   "%s - rq 0x%02x, val %#x, len %#x, result %d\n",
+   __func__, request, value, len, retval);
 
usb_autopm_put_interface(acm->control);
 
@@ -291,13 +291,13 @@ static void acm_ctrl_irq(struct urb *urb)
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dev_dbg(>control->dev,
-   "%s - urb shutting down with status: %d\n",
-   __func__, status);
+   "%s - urb shutting down with status: %d\n",
+   __func__, status);
return;
default:
dev_dbg(>control->dev,
-   "%s - nonzero urb status received: %d\n",
-   __func__, status);
+   "%s - nonzero urb status received: %d\n",
+   __func__, status);
goto exit;
}
 
@@ -306,16 +306,16 @@ static void acm_ctrl_irq(struct urb *urb)
data = (unsigned char *)(dr + 1);
switch (dr->bNotificationType) {
case USB_CDC_NOTIFY_NETWORK_CONNECTION:
-   dev_dbg(>control->dev, "%s - network connection: %d\n",
-   __func__, dr->wValue);
+   dev_dbg(>control->dev,
+   "%s - network connection: %d\n", __func__, dr->wValue);
break;
 
case USB_CDC_NOTIFY_SERIAL_STATE:
newctrl = get_unaligned_le16(data);
 
if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
-   dev_dbg(>control->dev, "%s - calling hangup\n",
-   __func__);
+   dev_dbg(>control->dev,
+   "%s - calling hangup\n", __func__);
tty_port_tty_hangup(>port, false);
}
 
@@ -357,8 +357,8 @@ static void acm_ctrl_irq(struct urb *urb)
 exit:
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval && retval != -EPERM)
-   dev_err(>control->dev, "%s - usb_submit_urb failed: %d\n",
-   __func__, retval);
+   dev_err(>control->dev,
+   "%s - usb_submit_urb failed: %d\n", __func__, retval);
 }
 
 static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags)
@@ -372,8 +372,8 @@ static int acm_submit_read_urb(struct acm *acm, int index, 
gfp_t mem_flags)
if (res) {
if (res != -EPERM) {
dev_err(>data->dev,
-   "urb %d failed submission with %d\n",
-   index, res);
+   "urb %d failed submission with %d\n",
+   index, res);
}
set_bit(index, >read_urbs_free);
return res;
@@ -416,8 +416,7 @@ static void acm_read_bulk_callback(struct urb *urb)
int status = urb->status;
 
dev_vdbg(>data->dev, "got urb %d, len %d, status %d\n",
-   rb->index, urb->actual_length,
-   status);
+   rb->index, urb->actual_length, status);
 
if (!acm->dev) {
set_bit(rb->index, >read_urbs_free);
@@ -837,8 +836,8 @@ static int acm_tty_break_ctl(struct tty_struct *tty, int 
state)
 
retval = acm_send_break(acm, state ? 0x : 0);
if (retval < 0)
-   dev_dbg(>control->dev, "%s - send break failed\n",
-   __func__);
+   dev_dbg(>control->dev,
+   "%s - send break failed\n", __func__);
return retval;
 }
 
-- 
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 v3 4/4] usb: dwc2: pci: Add AHB burst property for HAPS

2016-11-17 Thread John Youn
Set the AHB burst to INCR for HAPS.

Signed-off-by: John Youn 
---
 drivers/usb/dwc2/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index a23329e..146b7ce 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -67,6 +67,7 @@ static int dwc2_pci_quirks(struct pci_dev *pdev, struct 
platform_device *dwc2)
if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS &&
pdev->device == PCI_PRODUCT_ID_HAPS_HSOTG) {
struct property_entry properties[] = {
+   PROPERTY_ENTRY_STRING("snps,ahb-burst", "INCR"),
{ },
};
 
-- 
2.10.0

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


[PATCH v3 3/4] usb: dwc2: Use the ahb_burst param

2016-11-17 Thread John Youn
Use the new ahb_burst (instead of ahbcfg) to program the GAHBCFG.HBSTLEN
in both host and gadget mode.

Signed-off-by: John Youn 
---
 drivers/usb/dwc2/gadget.c |  2 +-
 drivers/usb/dwc2/hcd.c|  8 +++-
 drivers/usb/dwc2/params.c | 10 --
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index b95930f..8869651 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3228,7 +3228,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
 
if (using_dma(hsotg)) {
dwc2_writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN |
-   (GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT),
+   (hsotg->params.ahb_burst << GAHBCFG_HBSTLEN_SHIFT),
hsotg->regs + GAHBCFG);
 
/* Set DDMA mode support in the core if needed */
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 911c3b3..d8b9bde 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -273,11 +273,9 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg)
 
case GHWCFG2_INT_DMA_ARCH:
dev_dbg(hsotg->dev, "Internal DMA Mode\n");
-   if (hsotg->params.ahbcfg != -1) {
-   ahbcfg &= GAHBCFG_CTRL_MASK;
-   ahbcfg |= hsotg->params.ahbcfg &
- ~GAHBCFG_CTRL_MASK;
-   }
+   ahbcfg &= ~GAHBCFG_HBSTLEN_MASK;
+   ahbcfg |= (hsotg->params.ahb_burst <<
+  GAHBCFG_HBSTLEN_SHIFT);
break;
 
case GHWCFG2_SLAVE_ONLY_ARCH:
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 02ccac7..e0fc9aa 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -988,15 +988,6 @@ static void dwc2_set_param_reload_ctl(struct dwc2_hsotg 
*hsotg, int val)
hsotg->params.reload_ctl = val;
 }
 
-static void dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val)
-{
-   if (val != -1)
-   hsotg->params.ahbcfg = val;
-   else
-   hsotg->params.ahbcfg = GAHBCFG_HBSTLEN_INCR4 <<
-   GAHBCFG_HBSTLEN_SHIFT;
-}
-
 static void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val)
 {
if (DWC2_OUT_OF_BOUNDS(val, 0, 1)) {
@@ -1232,7 +1223,6 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_en_multiple_tx_fifo(hsotg,
params->en_multiple_tx_fifo);
dwc2_set_param_reload_ctl(hsotg, params->reload_ctl);
-   dwc2_set_param_ahbcfg(hsotg, params->ahbcfg);
dwc2_set_param_otg_ver(hsotg, params->otg_ver);
dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
-- 
2.10.0

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


[PATCH v3 0/4] usb: dwc2: Add AHB burst configuration

2016-11-17 Thread John Youn
This series adds a binding for AHB burst, reads it in, and configures
the controller for the specified burst type.

Tested on HAPS platform with DWC_hsotg IP version 3.30a.

v3:
* Split out binding documentation
* Squash bcm2835 comment with binding implementation
* Add warning for bcm2835

v2:
* Don't remove the bcm2835 ahbcfg param and document why.


John Youn (4):
  Documentation: devictree: dwc2: Add AHB burst binding
  usb: dwc2: Read in the AHB burst property
  usb: dwc2: Use the ahb_burst param
  usb: dwc2: pci: Add AHB burst property for HAPS

 Documentation/devicetree/bindings/usb/dwc2.txt |  2 +
 drivers/usb/dwc2/core.h|  9 +++
 drivers/usb/dwc2/gadget.c  |  2 +-
 drivers/usb/dwc2/hcd.c |  8 +--
 drivers/usb/dwc2/params.c  | 79 ++
 drivers/usb/dwc2/pci.c |  1 +
 6 files changed, 85 insertions(+), 16 deletions(-)

-- 
2.10.0

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


[PATCH v3 2/4] usb: dwc2: Read in the AHB burst property

2016-11-17 Thread John Youn
Read in the "snps,ahb-burst" property and set the internal parameter. If
this property is set, it overrides the legacy param value, except for
BCM2835, which can't set this value.

Cc: Stefan Wahren 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.h   |  9 +++
 drivers/usb/dwc2/params.c | 69 +++
 2 files changed, 78 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 9548d3e..75c238c 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -430,6 +430,12 @@ enum dwc2_ep0_state {
  * needed.
  * 0 - No (default)
  * 1 - Yes
+ * @ahb_burst:  Specifies the AHB burst.
+ *   0 - Single
+ *   1 - INCR
+ *   3 - INCR4 (default)
+ *   5 - INCR8
+ *   7 - INCR16
  * @g_dma:  Enables gadget dma usage (default: autodetect).
  * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect).
  * @g_rx_fifo_size:The periodic rx fifo size for the device, in
@@ -507,6 +513,9 @@ struct dwc2_core_params {
 * properties and cannot be set directly in this structure.
 */
 
+   /* Global parameters */
+   u8 ahb_burst;
+
/* Host parameters */
bool host_dma;
 
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a786256..02ccac7 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -93,6 +93,13 @@ static const struct dwc2_core_params params_bcm2835 = {
.host_ls_low_power_phy_clk  = 0,/* 48 MHz */
.ts_dline   = 0,
.reload_ctl = 0,
+
+   /*
+* Although this value would normally be invalid, for BCM2835,
+* the GAHBCFG.HBSTLEN field has a different meaning from that
+* defined by Synopsys. See the BCM2835 databook section 15.2
+* for details.
+*/
.ahbcfg = 0x10,
.uframe_sched   = 0,
.external_id_pin_ctl= -1,
@@ -1091,6 +1098,66 @@ static void dwc2_set_param_tx_fifo_sizes(struct 
dwc2_hsotg *hsotg)
}
 }
 
+static const char *const ahb_bursts[] = {
+   [GAHBCFG_HBSTLEN_SINGLE]= "SINGLE",
+   [GAHBCFG_HBSTLEN_INCR]  = "INCR",
+   [GAHBCFG_HBSTLEN_INCR4] = "INCR4",
+   [GAHBCFG_HBSTLEN_INCR8] = "INCR8",
+   [GAHBCFG_HBSTLEN_INCR16]= "INCR16",
+};
+
+static int dwc2_get_property_ahb_burst(struct dwc2_hsotg *hsotg)
+{
+   struct device_node *node = hsotg->dev->of_node;
+   const char *str = NULL;
+   int burst;
+   int ret;
+
+   ret = device_property_read_string(hsotg->dev,
+ "snps,ahb-burst", );
+   if (ret < 0) {
+   return ret;
+   } else if (of_device_is_compatible(node, "brcm,bcm2835-usb")) {
+   dev_warn(hsotg->dev,
+"snps,ahb-burst is not supported on this platform");
+   return -EINVAL;
+   }
+
+   burst = match_string(ahb_bursts,
+ARRAY_SIZE(ahb_bursts), str);
+   if (burst < 0) {
+   dev_err(hsotg->dev,
+   "Invalid parameter '%s' for ahb-burst\n", str);
+   }
+
+   return burst;
+}
+
+static void dwc2_set_ahb_burst(struct dwc2_hsotg *hsotg)
+{
+   struct dwc2_core_params *p = >params;
+   int burst;
+   int ret;
+
+   /* Default burst value */
+   burst = GAHBCFG_HBSTLEN_INCR4;
+
+   /* Get the legacy param value, if set. */
+   if (p->ahbcfg != -1) {
+   burst = (p->ahbcfg & GAHBCFG_HBSTLEN_MASK) >>
+   GAHBCFG_HBSTLEN_SHIFT;
+   }
+
+   /* Override it from devicetree, if set. */
+   ret = dwc2_get_property_ahb_burst(hsotg);
+   if (ret >= 0)
+   burst = ret;
+
+   /* Set the parameter */
+   p->ahb_burst = (u8)burst;
+   dev_dbg(hsotg->dev, "Setting ahb-burst to %d\n", burst);
+}
+
 static void dwc2_set_gadget_dma(struct dwc2_hsotg *hsotg)
 {
struct dwc2_hw_params *hw = >hw_params;
@@ -1171,6 +1238,8 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
dwc2_set_param_hibernation(hsotg, params->hibernation);
 
+   dwc2_set_ahb_burst(hsotg);
+
/*
 * Set devicetree-only parameters. These parameters do not
 * take any values from @params.
-- 
2.10.0

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


[PATCH v3 1/4] Documentation: devictree: dwc2: Add AHB burst binding

2016-11-17 Thread John Youn
Add the "snps,ahb-burst" property which controls the burst type to
perform on the AHB bus as a master in internal DMA mode.

Some platforms may see better or worse performance based on this
value. The HAPS platform is one example where all INCRx have worse
performance than INCR.

Other platforms (such as the Canyonlands board) report that the default
value causes system hangs.

Signed-off-by: John Youn 
Cc: Christian Lamparter 
---
 Documentation/devicetree/bindings/usb/dwc2.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index 6c7c2bce..9e7b4b4 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -26,6 +26,8 @@ Optional properties:
 Refer to phy/phy-bindings.txt for generic phy consumer properties
 - dr_mode: shall be one of "host", "peripheral" and "otg"
   Refer to usb/generic.txt
+- snps,ahb-burst: specifies the ahb burst length. Valid arguments are:
+  "SINGLE", "INCR", "INCR4", "INCR8", "INCR16". Defaults to "INCR4".
 - g-rx-fifo-size: size of rx fifo size in gadget mode.
 - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
 - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget 
mode.
-- 
2.10.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


Re: cdc_acm - fragmented notifications

2016-11-17 Thread Tobias Herzog
> If they mention it, it may be more widely used.
> I'd welcome a patch for the ACM driver.
> Would you provide one?

Thank you for your reply. I think I'll give it a try.

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


Re: [PATCH v2 2/4] usb: dwc2: Add binding for AHB burst

2016-11-17 Thread John Youn
On 11/17/2016 3:28 AM, Felipe Balbi wrote:
> 
> Hi,
> 
> John Youn  writes:
>> Add the "snps,ahb-burst" binding and read it in.
>>
>> This property controls which burst type to perform on the AHB bus as a
>> master in internal DMA mode. This overrides the legacy param value,
>> which we need to keep around for now since several platforms use it.
>>
>> Some platforms may see better or worse performance based on this
>> value. The HAPS platform is one example where all INCRx have worse
>> performance than INCR.
>>
>> Other platforms (such as the Canyonlands board) report that the default
>> value causes system hangs.
>>
>> Signed-off-by: John Youn 
>> Cc: Christian Lamparter 
> 
> it's getting rather late for this merge window. I still need an ack by
> Rob or any of the devicetree folks.
> 

Sure, no problem if it doesn't make it.

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] usb: gadget: f_fs: fix wrong parenthesis in ffs_func_req_match()

2016-11-17 Thread Felix Hädicke
Hello,
> Properly check the return code of ffs_func_revmap_intf() and
> ffs_func_revmap_ep() for a non-negative value.
>
> Instead of checking the return code, the comparison was performed for the last
> parameter of the function calls, because of wrong parenthesis.
>
> This also fixes the following static checker warning:
> drivers/usb/gadget/function/f_fs.c:3152 ffs_func_req_match()
> warn: always true condition '(((creq->wIndex)) >= 0) => (0-u16max >= 0)'
>
> Reported-by: Dan Carpenter 
> Signed-off-by: Felix Hädicke 
> ---
>  drivers/usb/gadget/function/f_fs.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c 
> b/drivers/usb/gadget/function/f_fs.c
> index 43aeed6..fcfdc6a 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -3028,11 +3028,11 @@ static bool ffs_func_req_match(struct usb_function *f,
>  
>   switch (creq->bRequestType & USB_RECIP_MASK) {
>   case USB_RECIP_INTERFACE:
> - return ffs_func_revmap_intf(func,
> - le16_to_cpu(creq->wIndex) >= 0);
> + return (ffs_func_revmap_intf(func,
> +  le16_to_cpu(creq->wIndex)) >= 0);
>   case USB_RECIP_ENDPOINT:
> - return ffs_func_revmap_ep(func,
> -   le16_to_cpu(creq->wIndex) >= 0);
> + return (ffs_func_revmap_ep(func,
> +le16_to_cpu(creq->wIndex)) >= 0);
>   default:
>   return (bool) (func->ffs->user_flags &
>  FUNCTIONFS_ALL_CTRL_RECIP);

is there a chance to get this fix into 4.9?

Regards,
Felix
--
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/3] usb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions

2016-11-17 Thread Roger Quadros
From: Felipe Balbi 

dwc3 revisions <=3.00a have a limitation where Port Disable command
doesn't work. Set the quirk-broken-port-ped property for such
controllers so XHCI core can do the necessary workaround.

[rog...@ti.com] Updated code from platform data to device property.

Signed-off-by: Felipe Balbi 
Signed-off-by: Roger Quadros 
---
 drivers/usb/dwc3/host.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index f6533c6..626d87d 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -21,11 +21,12 @@
 
 int dwc3_host_init(struct dwc3 *dwc)
 {
-   struct property_entry   props[2];
+   struct property_entry   props[3];
struct platform_device  *xhci;
int ret, irq;
struct resource *res;
struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
+   int prop_idx = 0;
 
irq = platform_get_irq_byname(dwc3_pdev, "host");
if (irq == -EPROBE_DEFER)
@@ -89,8 +90,22 @@ int dwc3_host_init(struct dwc3 *dwc)
 
memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props));
 
-   if (dwc->usb3_lpm_capable) {
-   props[0].name = "usb3-lpm-capable";
+   if (dwc->usb3_lpm_capable)
+   props[prop_idx++].name = "usb3-lpm-capable";
+
+   /**
+* WORKAROUND: dwc3 revisions <=3.00a have a limitation
+* where Port Disable command doesn't work.
+*
+* The suggested workaround is that we avoid Port Disable
+* completely.
+*
+* This following flag tells XHCI to do just that.
+*/
+   if (dwc->revision <= DWC3_REVISION_300A)
+   props[prop_idx++].name = "quirk-broken-port-ped";
+
+   if (prop_idx) {
ret = platform_device_add_properties(xhci, props);
if (ret) {
dev_err(dwc->dev, "failed to add properties to xHCI\n");
-- 
2.7.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] usb: gadget: serial: fix possible Oops caused by calling kthread_stop(NULL)

2016-11-17 Thread Felix Hädicke
Add check for NULL before calling kthread_stop().

There were cases in which gserial_console_exit() was called, but the
console thread was not started. This resulted in an invalid
kthread_stop(NULL) call.

Without this, the following Oops may occur:

BUG: unable to handle kernel 
NULL pointer dereference at 0018
IP: [] kthread_stop+0x16/0x110
...
CPU: 2 PID: 853 Comm: rmmod Not tainted 4.9.0-rc5 #3
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./Z77 Extreme3, 
BIOS P1.50 07/11/2013
task: 880419f6a100 task.stack: c90002e8c000
RIP: 0010:[]  [] kthread_stop+0x16/0x110
RSP: 0018:c90002e8fdb0  EFLAGS: 00010286
RAX: 0001 RBX:  RCX: 
RDX: 0001 RSI: 0246 RDI: 
RBP: c90002e8fdc8 R08:  R09: 0001
R10: 019d R11: 001f R12: 
R13: 88041b8d8400 R14: 0001 R15: 55fd59f5a1e0
FS:  7f82500be700() GS:88042f28() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0018 CR3: 00041bee2000 CR4: 001406e0
Stack:
  c0b8e720 88041b8d8400 c90002e8fdf0
 c0b8bb52 88041a106300 0001 880419fc2ea8
 c90002e8fe08 c0aed749 c0aef600 c90002e8fe20
Call Trace:
 [] gserial_free_line+0x72/0xb0 [u_serial]
 [] acm_free_instance+0x19/0x30 [usb_f_acm]
 [] usb_put_function_instance+0x20/0x30 [libcomposite]
 [] gs_unbind+0x3b/0x70 [g_serial]
 [] __composite_unbind+0x61/0xb0 [libcomposite]
 [] composite_unbind+0x13/0x20 [libcomposite]
 [] usb_gadget_remove_driver+0x3d/0x90 [udc_core]
 [] usb_gadget_unregister_driver+0x6e/0xc0 [udc_core]
 [] usb_composite_unregister+0x12/0x20 [libcomposite]
 [] cleanup+0x10/0xda8 [g_serial]
 [] SyS_delete_module+0x192/0x270
 [] ? exit_to_usermode_loop+0x90/0xb0
 [] entry_SYSCALL_64_fastpath+0x1e/0xad
Code: 89 c6 e8 6e ff ff ff 48 89 df e8 06 bd fd ff 5b 5d c3 0f 1f 00 0f 1f 
44 00 00 55 48 89 e5 41 55 41 54 49 89 fc 53 0f 1f 44 00 00  41 ff 44 24 18 
4c 89 e7 e8 bc f1 ff ff 48 85 c0 48 89 c3 74 
RIP  [] kthread_stop+0x16/0x110
 RSP 
CR2: 0018
---[ end trace 5b3336a407e1698c ]---

Signed-off-by: Felix Hädicke 
Tested-by: Peter Chen 
---
Changes in v2:
  - Add Tested-by: Peter Chen
  - Add oops dump

 drivers/usb/gadget/function/u_serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/u_serial.c 
b/drivers/usb/gadget/function/u_serial.c
index 5fedead..f58c775 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1256,7 +1256,8 @@ static void gserial_console_exit(void)
struct gscons_info *info = _info;
 
unregister_console(_cons);
-   kthread_stop(info->console_thread);
+   if (info->console_thread != NULL)
+   kthread_stop(info->console_thread);
gs_buf_free(>con_buf);
 }
 
-- 
2.10.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


[PATCH 2/3] usb: host: xhci-plat: enable BROKEN_PED quirk if platform requested

2016-11-17 Thread Roger Quadros
From: Felipe Balbi 

In case 'quirk-broken-port-ped' property is passed in via device property,
we should enable the corresponding BROKEN_PED quirk flag for XHCI core.

[rog...@ti.com] Updated code from platform data to device property
and added DT binding.

Signed-off-by: Felipe Balbi 
Signed-off-by: Roger Quadros 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
 drivers/usb/host/xhci-plat.c   | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 966885c..7790c81 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,7 @@ Required properties:
 Optional properties:
   - clocks: reference to a clock
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
+  - quirk-broken-port-ped: set if the controller has broken port disable 
mechanism
 
 Example:
usb@f0931000 {
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..e4de741 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -223,6 +223,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (device_property_read_bool(>dev, "usb3-lpm-capable"))
xhci->quirks |= XHCI_LPM_SUPPORT;
 
+   if (device_property_read_bool(>dev, "quirk-broken-port-ped"))
+   xhci->quirks |= XHCI_BROKEN_PORT_PED;
+
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
-- 
2.7.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: xhci: add quirk flag for broken PED bits

2016-11-17 Thread Roger Quadros
From: Felipe Balbi 

Some devices from Texas Instruments [1] suffer from
a silicon bug where Port Enabled/Disabled bit
should not be used to silence an erroneous device.

The bug is so that if port is disabled with PED
bit, an IRQ for device removal (or attachment)
will never fire.

Just for the sake of completeness, the actual
problem lies with SNPS USB IP and this affects
all known versions up to 3.00a. A separate
patch will be added to dwc3 to enabled this
quirk flag if version is <= 3.00a.

[1] - AM572x Silicon Errata http://www.ti.com/lit/er/sprz429j/sprz429j.pdf
Section i896— USB xHCI Port Disable Feature Does Not Work

Signed-off-by: Felipe Balbi 
Signed-off-by: Roger Quadros 
---
 drivers/usb/host/xhci-hub.c | 6 ++
 drivers/usb/host/xhci.h | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 0ef1690..c3c051d 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -458,6 +458,12 @@ static void xhci_disable_port(struct usb_hcd *hcd, struct 
xhci_hcd *xhci,
return;
}
 
+   if (xhci->quirks & XHCI_BROKEN_PORT_PED) {
+   xhci_dbg(xhci, "Broken Port Enabled/Disabled, ignoring "
+   "port disable request.\n");
+   return;
+   }
+
/* Write 1 to disable the port */
writel(port_status | PORT_PE, addr);
port_status = readl(addr);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index f945380..4f724aa 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1656,6 +1656,9 @@ struct xhci_hcd {
 #define XHCI_SSIC_PORT_UNUSED  (1 << 22)
 #define XHCI_NO_64BIT_SUPPORT  (1 << 23)
 #define XHCI_MISSING_CAS   (1 << 24)
+/* For controller with a broken Port Disable implementation */
+#define XHCI_BROKEN_PORT_PED(1 << 21)
+
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
/* There are two roothubs to keep track of bus suspend info for */
-- 
2.7.4

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


Re: [PATCH] usb: dwc3: avoid empty-body warning

2016-11-17 Thread Arnd Bergmann
On Thursday, November 17, 2016 1:23:43 PM CET Felipe Balbi wrote:
> Arnd Bergmann  writes:
> > Building with W=1, we get a warning about harmless empty statements:
> >
> > drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
> > drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 
> > 'if' statement [-Werror=empty-body]
> >
> > gcc does not warn about {} here, so maybe use that instead.
> > Alternatively, the code could be removed entirely as it does
> > nothing.
> >
> > Signed-off-by: Arnd Bergmann 
> > ---
> > This has been present in the driver for a while, but the code
> > just moved around, so it showed up as a new warning for me.
> > I hope to eventually address all W=1 warnings as they tend to
> > find real bugs elsewhere and we may as well fix it now that the
> > code has changed.
> 
> Thank you, the only problem is that now checkpatch.pl warns. I'll just
> remove the code and turn it into a comment. Authorship kept, let me know
> if you're okay with me adding your S-o-b:

Ah, good point. The same problem exists in other places too,
I have to remember this when sending patches. Maybe I can
add something like

#define do_nothing() do {} while (0) 

> 8<
> 
> From ea97b854e5c4437975c5d0e887488390410cfb30 Mon Sep 17 00:00:00 2001
> From: Arnd Bergmann 
> Date: Wed, 16 Nov 2016 16:37:30 +0100
> Subject: [PATCH] usb: dwc3: ep0: avoid empty-body warning
> 
> Building with W=1, we get a warning about harmless empty statements:
> 
> drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
> drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 
> 'if' statement [-Werror=empty-body]
> 
> Instead of adding empty braces which would introduce checkpatch.pl
> warnings, we're just removing the code which doesn't do anything and
> making sure we return 0 so USBCV tool is happy.
> 
> NYET-Signed-off-by: Arnd Bergmann 
> Signed-off-by: Felipe Balbi 

Looks good to me.

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


Re: [PATCH v2 2/4] usb: dwc2: Add binding for AHB burst

2016-11-17 Thread John Youn
On 11/17/2016 7:35 AM, Stefan Wahren wrote:
> Hi John,
> 
> Am 17.11.2016 um 00:47 schrieb John Youn:
>> Add the "snps,ahb-burst" binding and read it in.
>>
>> This property controls which burst type to perform on the AHB bus as a
>> master in internal DMA mode. This overrides the legacy param value,
>> which we need to keep around for now since several platforms use it.
>>
>> Some platforms may see better or worse performance based on this
>> value. The HAPS platform is one example where all INCRx have worse
>> performance than INCR.
>>
>> Other platforms (such as the Canyonlands board) report that the default
>> value causes system hangs.
>>
>> Signed-off-by: John Youn 
>> Cc: Christian Lamparter 
>> ---
>>  Documentation/devicetree/bindings/usb/dwc2.txt |  2 +
>>  drivers/usb/dwc2/core.h|  9 +
>>  drivers/usb/dwc2/params.c  | 56 
>> ++
>>  3 files changed, 67 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
>> b/Documentation/devicetree/bindings/usb/dwc2.txt
>> index 6c7c2bce..9e7b4b4 100644
>> --- a/Documentation/devicetree/bindings/usb/dwc2.txt
>> +++ b/Documentation/devicetree/bindings/usb/dwc2.txt
> 
> according to Documentation/devicetree/bindings/submitting-patches.txt
> this change should be a separate patch.

Ok

> 
>> @@ -26,6 +26,8 @@ Optional properties:
>>  Refer to phy/phy-bindings.txt for generic phy consumer properties
>>  - dr_mode: shall be one of "host", "peripheral" and "otg"
>>Refer to usb/generic.txt
>> +- snps,ahb-burst: specifies the ahb burst length. Valid arguments are:
>> +  "SINGLE", "INCR", "INCR4", "INCR8", "INCR16". Defaults to "INCR4".
> 
> This doesn't apply in case of the bcm2835. I would prefer this option is
> ignored in that case with a dev_warn("snps,ahb-burst is not supported on
> this platform").

Sure I'll add 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: AW: add usb option device

2016-11-17 Thread Dan Williams
On Wed, 2016-11-16 at 22:11 +0100, Giuseppe Lippolis wrote:
> > 
> > > 
> > > This will make option grab all the ports, as shown by your dmesg
> > > output.  But USB interfaces 0 and 1 are actually cdc-ether and
> > > should
> > > *not* be grabbed by option.
> 
> I also have another curiosity:
> Why the driver architecture doesn't recognize autonomously the cdc-
> ether
> Interface and only gets the serial ports?

I'm not 100% sure, but driver loading order is undependable enough (for
good reason) to be effectively random.  So you must do the right thing
in each driver for ID matching or you will sometimes get the wrong
result.  This also prevents people from being lazy :)

But also, it's not just about automatically loading.  You can
rmmod/modprobe any driver at any time (as long as it's a module and not
built-in) and if you don't do the right thing for ID matching, this
sequence ends up with the wrong driver bound:

rmmod cdc-ether
rmmod option
modprobe option
modprobe cdc-ether

Now option is bound to the ether port and cdc-ether can't bind to it.

The point is, drivers should *only* claim interfaces and devices they
actually should drive.  They should not claim interfaces they should
not or cannot drive.

Dan

> Thanks,
> Bye.
> 
> > 
> > -Ursprüngliche Nachricht-
> > Von: Oliver Neukum [mailto:oneu...@suse.com]
> > Gesendet: Mittwoch, 16. November 2016 21:57
> > An: Dan Williams 
> > Cc: Giuseppe Lippolis ; linux-...@vger.kern
> > el.org
> > Betreff: Re: add usb option device
> > 
> > On Wed, 2016-11-16 at 11:49 -0600, Dan Williams wrote:
> > > 
> > > This will make option grab all the ports, as shown by your dmesg
> > > output.  But USB interfaces 0 and 1 are actually cdc-ether and
> > > should
> > > *not* be grabbed by option.
> > > 
> > > You want to limit option to grabbing bInterfaceClass=255 to make
> > > sure
> > > it only gets the serial ports.
> > 
> > Hi,
> > 
> > what happens if you actually use these ethernet interfaces while
> > somebody
> > uses the serial interfaces?
> > 
> > Regards
> > Oliver
> > 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/4] usb: dwc2: Add binding for AHB burst

2016-11-17 Thread Stefan Wahren
Hi John,

Am 17.11.2016 um 00:47 schrieb John Youn:
> Add the "snps,ahb-burst" binding and read it in.
>
> This property controls which burst type to perform on the AHB bus as a
> master in internal DMA mode. This overrides the legacy param value,
> which we need to keep around for now since several platforms use it.
>
> Some platforms may see better or worse performance based on this
> value. The HAPS platform is one example where all INCRx have worse
> performance than INCR.
>
> Other platforms (such as the Canyonlands board) report that the default
> value causes system hangs.
>
> Signed-off-by: John Youn 
> Cc: Christian Lamparter 
> ---
>  Documentation/devicetree/bindings/usb/dwc2.txt |  2 +
>  drivers/usb/dwc2/core.h|  9 +
>  drivers/usb/dwc2/params.c  | 56 
> ++
>  3 files changed, 67 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
> b/Documentation/devicetree/bindings/usb/dwc2.txt
> index 6c7c2bce..9e7b4b4 100644
> --- a/Documentation/devicetree/bindings/usb/dwc2.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc2.txt

according to Documentation/devicetree/bindings/submitting-patches.txt
this change should be a separate patch.

> @@ -26,6 +26,8 @@ Optional properties:
>  Refer to phy/phy-bindings.txt for generic phy consumer properties
>  - dr_mode: shall be one of "host", "peripheral" and "otg"
>Refer to usb/generic.txt
> +- snps,ahb-burst: specifies the ahb burst length. Valid arguments are:
> +  "SINGLE", "INCR", "INCR4", "INCR8", "INCR16". Defaults to "INCR4".

This doesn't apply in case of the bcm2835. I would prefer this option is
ignored in that case with a dev_warn("snps,ahb-burst is not supported on
this platform").

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: [PATCH v3 1/1] usb: hub: Fix auto-remount of safely removed or ejected USB-3 devices

2016-11-17 Thread Mathias Nyman

On 17.11.2016 11:26, Greg KH wrote:

On Thu, Nov 17, 2016 at 11:14:14AM +0200, Mathias Nyman wrote:

USB-3 does not have any link state that will avoid negotiating a connection
with a plugged-in cable but will signal the host when the cable is
unplugged.

For USB-3 we used to first set the link to Disabled, then to RxDdetect to
be able to detect cable connects or disconnects. But in RxDetect the
connected device is detected again and eventually enabled.

Instead set the link into U3 and disable remote wakeups for the device.
This is what Windows does, and what Alan Stern suggested.

Cc: sta...@vger.kernel.org
Cc: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Mathias Nyman 


Can I put this in -next and get it some testing before going to Linus
for 4.10-rc1, or do you think it needs to get into 4.9-final due to
people complaining about this?  If so, is it a regression or just
something that we have never done before (I think the latter, but want
to make sure...)



Latter, -next is fine.

I think this has always been an issue with usb3.
I found bugs from 2011 where users complained about this.

-Mathias


 


--
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 0/6] musb-fixes for v4.9-rc6

2016-11-17 Thread Tony Lindgren
* Johan Hovold  [161117 01:20]:
> [ +CC: Tony ]
> 
> On Thu, Nov 17, 2016 at 08:10:55AM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Nov 16, 2016 at 01:21:21PM -0600, Bin Liu wrote:
> > > Hi Greg,
> > > 
> > > Hope this is not too late for -rc6. This set fixes a long standing musb
> > > regression introduced in v4.8.  Please let me know if any change is 
> > > needed.
> > 
> > As these were bugs in 4.8 (i.e. not a regression due to changes in
> > 4.9-rc1), can we just wait for 4.10-rc1 for these patches?
> 
> I believe that may have been a typo as this series fixes a number of
> regressions in 4.9. Most of the patches have either or both of
> 
> Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime
> PM for musb-core")
> Fixes: 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS
> 
> that went into 4.9, or are prerequisite clean ups (patch 1/6).
> 
> The exception being patch 4/6 that claims to fix a commit in 4.7.
> 
> The driver appeared to work well-enough for me in 4.8, but then again I
> only hit the debug splat triggered by 65b3f50ed6fa ("usb: musb: Add PM
> runtime support for MUSB DSPS) every other second (fixed by patch 2/6).

Heh these are for v4.9-rc yes, not v4.8 :) We made PM generic and
also enabled it for MUSB DSPS glue layer which caused tons of issues
to show up.

Regards,

Tony
--
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: crash by cdc_acm driver in kernels 4.8-rc1/5

2016-11-17 Thread Wim Osterholt
On Thu, Nov 17, 2016 at 10:14:34AM +0100, Wim Osterholt wrote:
> > For completeness I should also try with SMP unset. That is for tomorrow
> > then.
> 
> With CONFIG_SMP unset nothing goes wrong here either.
> It looks like it has been fixed in 4.9-rc5, but I should also double check
> several conbinations on my (slower) laptop.

Nov 17 15:07:49 localhost kernel: usb 4-1: new full-speed USB device number 2 
using uhci_hcd
Nov 17 15:07:49 localhost kernel: usb 4-1: New USB device found, idVendor=0572, 
idProduct=1340
Nov 17 15:07:49 localhost kernel: usb 4-1: New USB device strings: Mfr=1, 
Product=2, SerialNumber=3
Nov 17 15:07:49 localhost kernel: usb 4-1: Product: USB Modem
Nov 17 15:07:49 localhost kernel: usb 4-1: Manufacturer: Conexant
Nov 17 15:07:49 localhost kernel: usb 4-1: SerialNumber: 12345678
Nov 17 15:07:50 localhost mtp-probe[12956]: checking bus 4, device 2: 
"/sys/devices/pci:00/:00:1d.2/usb4/4-1"
Nov 17 15:07:50 localhost mtp-probe[12956]: bus: 4, device: 2 was not an MTP 
device
Nov 17 15:07:51 localhost kernel: Check point  1
Nov 17 15:07:51 localhost kernel: Check point  2
Nov 17 15:07:51 localhost kernel: Check point  3
Nov 17 15:07:51 localhost kernel: Check point  4
Nov 17 15:07:51 localhost kernel: Check point  5
Nov 17 15:07:51 localhost kernel: Check point  6
Nov 17 15:07:51 localhost kernel: Check point  7
Nov 17 15:07:51 localhost kernel: Check point  8
Nov 17 15:07:51 localhost kernel: Check point  9
Nov 17 15:07:51 localhost kernel: Check point  10
Nov 17 15:07:51 localhost kernel: BUG: unable to handle kernel NULL pointer 
dereference at 0249
Nov 17 15:07:51 localhost kernel: IP: [] acm_probe+0x559/0xe53 
[cdc_acm]
Nov 17 15:07:51 localhost kernel: *pde =  
Nov 17 15:07:51 localhost kernel: Oops:  [#1] SMP
...


You can get a few logs concatenated at
http://webserver.djo.tudelft.nl/insane488.logs

Usually the oops follows immediately after inserting the modem, but in one case
it took a few seconds extra before the oops. I think that is the one that
printed the full range of checkpoints.

On another 3 machines running 4.9-rc5 here  everything went fine on insertion.
Switching back to 4.8.8 produced the bug with outputs similar to the above.

Now back to the laptops to see if I can get confirmation of having seen the
oops at 4.9-rc5 in some way. I'm not sure now. 


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


Re: [PATCH net 1/2] r8152: fix the sw rx checksum is unavailable

2016-11-17 Thread Mark Lord

On 16-11-17 09:14 AM, Mark Lord wrote:
..

Using coherent buffers (non-cacheable, allocated with usb_alloc_coherent),


Note that the same behaviour also happens with the original kmalloc'd buffers.


I can get it to fail extremely regularly by simply reducing the buffer size
(agg_buf_sz) from 16KB down to 4KB.   This makes reproducing the issue
much much easier -- the same problems do happen with the larger 16KB size,
but much less often than with smaller sizes.


Increasing the buffer size to 64KB makes the problem much less frequent,
as one might expect.  Thus far I haven't seen it happen at all, but a longer
run (1-3 days) is needed to make sure.  This however is NOT a "fix".


So.. with a 4KB URB transfer_buffer size, along with a ton of added 
error-checking,
I see this behaviour every 10 (rx) URBs or so:

First URB (number 593):
[   34.260667] r8152_rx_bottom: 593 corrupted urb: head=bf014000 
urb_offset=2856/4096 pkt_len(1518) exceeds remainder(1216)
[   34.271931] r8152_dump_rx_desc: 044805ee 4008 006005dc 0602  
 rx_len=1518

Next URB (number 594):
[   34.281172] r8152_check_rx_desc: rx_desc looks bad.
[   34.286228] r8152_rx_bottom: 594 corrupted urb. head=bf018000 
urb_offset=0/304 len_used=24
[   34.294774] r8152_dump_rx_desc: 8300 8400 8500 8600 8700 
8800 rx_len=768

What the above sample shows, is the URB transfer buffer ran out of space in the 
middle
of a packet, and the hardware then tried to just continue that same packet in 
the next URB,
without an rx_desc header inserted.  The r8152.c driver always assumes the URB 
buffer begins
with an rx_desc, so of course this behaviour produces really weird effects, and 
system crashes, etc..

So until that driver bug is addressed, I would advise disabling hardware RX 
checksums
for all chip versions, not only for version 02.

It is not clear to me how the chip decides when to forward an rx URB to the 
host.
If you could describe how that part works for us, then it would help in further
understanding why fast systems (eg. a PC) don't generally notice the issue,
while much slower embedded systems do see the issue regularly.


That last part is critical to understanding things:
How does the chip decide that a URB is "full enough" before sending it to the 
host?
Why does a really fast host see fewer packets jammed together into a single URB 
than a slower host?

The answers will help understand if there are more bugs to be found/fixed,
or if everything is explained by what has been observed thus far.

To recap:  the hardware sometimes fills a URB to the very end, and then 
continues the
current packet at the first byte of the following URB.  The r8152.c driver does 
NOT
handle this situation; instead it always interprets the first 24 bytes of every 
URB
as an "rx_desc" structure, without any kind of sanity/validation.  This results 
in
buffer overruns (it trusts the packet length field, even though the URB is too 
small
to hold such a packet), and other semi-random behaviour.

Using software rx checksums prevents Bad Things(tm) happening from most of this,
but even that is not perfect given the severity of the bug.

Cheers
--
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: add usb option device

2016-11-17 Thread Dan Williams
On Thu, 2016-11-17 at 11:15 +0100, Johan Hovold wrote:
> On Wed, Nov 16, 2016 at 10:03:52PM +0100, Giuseppe Lippolis wrote:
> > 
> > Dear All,
> > thanks for the very interesting discussion.
> > 
> > > 
> > > > 
> > > > This will make option grab all the ports, as shown by your
> > > > dmesg
> > > > output.  But USB interfaces 0 and 1 are actually cdc-ether and
> > > > should
> > > > *not* be grabbed by option.
> > > > 
> > > > You want to limit option to grabbing bInterfaceClass=255 to
> > > > make sure
> > > > it only gets the serial ports.
> > > 
> > 
> > Actually the device have 2 cdc_ether interface and the others are
> > serial comm.
> > This is the bootlog of the original oem firmware:
> > 
> > hub 2-0:1.0: USB hub found
> > hub 2-0:1.0: 1 port detected
> > usb 2-1: new high speed USB device using rt3xxx-ehci and address 2
> > usb 2-1: configuration #1 chosen from 1 choice
> > usbcore: registered new interface driver cdc_ether
> > usbcore: registered new interface driver usbserial
> > drivers/usb/serial/usb-serial.c: USB Serial support registered for
> > generic
> > usbserial_generic 2-1:1.2: generic converter detected
> > usb 2-1: generic converter now attached to ttyUSB0
> > usbserial_generic 2-1:1.3: generic converter detected
> > usb 2-1: generic converter now attached to ttyUSB1
> > usbserial_generic 2-1:1.4: generic converter detected
> > usb 2-1: generic converter now attached to ttyUSB2
> > usbserial_generic 2-1:1.5: generic converter detected
> > usb 2-1: generic converter now attached to ttyUSB3
> > usbserial_generic 2-1:1.6: generic converter detected
> > usb 2-1: generic converter now attached to ttyUSB4
> > usbcore: registered new interface driver usbserial_generic
> > drivers/usb/serial/usb-serial.c: USB Serial Driver core
> > 
> > and at the end of the modem configuration:
> > usbnet0   Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
> >   inet
> > addr:77.25.169.193  Bcast:77.25.169.195  Mask:255.255.255.252
> >   inet6 addr: fe80:::feaa:/64 Scope:Link
> >   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
> >   RX packets:6 errors:0 dropped:0 overruns:0 frame:0
> >   TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
> >   collisions:0 txqueuelen:1000
> >   RX bytes:272 (272.0 B)  TX bytes:600 (600.0 B)
> > 
> > Therefore I also consider convenient preserve the first two
> > interface
> > for the cdc_ether.
> > Can you please clarify me the differences between black and white
> > list
> > and how to configure it?
> 
> If possible you want to tell the option driver which interfaces to
> bind
> to (white-listing) rather than specifying which not to bind to
> (black-listing). The latter typically means probing all interfaces,
> checking the black list, and then bailing out for unsupported
> interfaces.
> 
> By matching on the interface class it is sometimes possible to rely
> solely on white-listing, for example:
> 
>   USB_DEVICE_INTERFACE_CLASS(VID, PID, 0xff)

Johan said what I was going to say, though with a bit of ambiguity on
what you should do.  I'll try to be less ambiguous: you should do what
he says.  Look at how it's done for the D-Link DWM-221 B1 or OLICARD300
and do the same thing for your device.

While you're there, use the same 0x2001 vendor ID #define for the DWM-
221 and your device.

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


[PATCH v5 1/6] usb: separate out sysdev pointer from usb_bus

2016-11-17 Thread Sriram Dash
From: Arnd Bergmann 

For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices.

The idea here is that you pass in the parent of_node along with
the child device pointer, so it would behave exactly like the
parent already does. The difference is that it also handles all
the other attributes besides the mask.

sysdev will represent the physical device, as seen from firmware
or bus.Splitting the usb_bus->controller field into the
Linux-internal device (used for the sysfs hierarchy, for printks
and for power management) and a new pointer (used for DMA,
DT enumeration and phy lookup) probably covers all that we really
need.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Tested-by: Baolin Wang 
Cc: Felipe Balbi 
Cc: Grygorii Strashko 
Cc: Sinjan Kumar 
Cc: David Fisher 
Cc: Catalin Marinas 
Cc: "Thang Q. Nguyen" 
Cc: Yoshihiro Shimoda 
Cc: Stephen Boyd 
Cc: Bjorn Andersson 
Cc: Ming Lei 
Cc: Jon Masters 
Cc: Dann Frazier 
Cc: Peter Chen 
Cc: Leo Li 
---
Changes in v5:
  - No update

Changes in v4:
  - No update

Changes in v3: 
  - usb is_device_dma_capable instead of directly accessing 
dma props. 
 
Changes in v2: 
  - Split the patch wrt driver

 drivers/usb/core/buffer.c | 12 ++--
 drivers/usb/core/hcd.c| 48 ---
 drivers/usb/core/usb.c| 18 +-
 include/linux/usb.h   |  1 +
 include/linux/usb/hcd.h   |  3 +++
 5 files changed, 48 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 98e39f9..a6cd44a 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -63,7 +63,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)
int i, size;
 
if (!IS_ENABLED(CONFIG_HAS_DMA) ||
-   (!hcd->self.controller->dma_mask &&
+   (!is_device_dma_capable(hcd->self.sysdev) &&
 !(hcd->driver->flags & HCD_LOCAL_MEM)))
return 0;
 
@@ -72,7 +72,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)
if (!size)
continue;
snprintf(name, sizeof(name), "buffer-%d", size);
-   hcd->pool[i] = dma_pool_create(name, hcd->self.controller,
+   hcd->pool[i] = dma_pool_create(name, hcd->self.sysdev,
size, size, 0);
if (!hcd->pool[i]) {
hcd_buffer_destroy(hcd);
@@ -127,7 +127,7 @@ void *hcd_buffer_alloc(
 
/* some USB hosts just use PIO */
if (!IS_ENABLED(CONFIG_HAS_DMA) ||
-   (!bus->controller->dma_mask &&
+   (!is_device_dma_capable(bus->sysdev) &&
 !(hcd->driver->flags & HCD_LOCAL_MEM))) {
*dma = ~(dma_addr_t) 0;
return kmalloc(size, mem_flags);
@@ -137,7 +137,7 @@ void *hcd_buffer_alloc(
if (size <= pool_max[i])
return dma_pool_alloc(hcd->pool[i], mem_flags, dma);
}
-   return dma_alloc_coherent(hcd->self.controller, size, dma, mem_flags);
+   return dma_alloc_coherent(hcd->self.sysdev, size, dma, mem_flags);
 }
 
 void hcd_buffer_free(
@@ -154,7 +154,7 @@ void hcd_buffer_free(
return;
 
if (!IS_ENABLED(CONFIG_HAS_DMA) ||
-   (!bus->controller->dma_mask &&
+   (!is_device_dma_capable(bus->sysdev) &&
 !(hcd->driver->flags & HCD_LOCAL_MEM))) {
kfree(addr);
return;
@@ -166,5 +166,5 @@ void hcd_buffer_free(
return;
}
}
-   dma_free_coherent(hcd->self.controller, size, addr, dma);
+   dma_free_coherent(hcd->self.sysdev, size, addr, dma);
 }
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 479e223..f8feb08 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1073,6 +1073,7 @@ static void usb_deregister_bus (struct usb_bus *bus)
 static int register_root_hub(struct usb_hcd *hcd)
 {
struct device *parent_dev = hcd->self.controller;
+   struct device *sysdev = hcd->self.sysdev;
struct usb_device *usb_dev = hcd->self.root_hub;
const int devnum = 1;
int retval;
@@ -1119,7 +1120,7 @@ static int register_root_hub(struct usb_hcd *hcd)
/* Did the HC die before the root hub was registered? */
if (HCD_DEAD(hcd))
usb_hc_died (hcd);  /* This time clean up */
-   usb_dev->dev.of_node = parent_dev->of_node;
+   

[PATCH v5 5/6] usb: dwc3: use bus->sysdev for DMA configuration

2016-11-17 Thread Sriram Dash
From: Arnd Bergmann 

The dma ops for dwc3 devices are not set properly. So, use a
physical device sysdev, which will be inherited from parent,
to set the hardware / firmware parameters like dma.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Tested-by: Baolin Wang 
---
Changes in v5:
  - rebase to usb testing/next

Changes in v4:
  - removed the ifdefs for pci
  - made the sysdev as a device property
  - phy create lookup take up the correct device.

Changes in v3:
  - No update

Changes in v2:
  - integrate dwc3 driver changes together

 drivers/usb/dwc3/core.c | 27 ++-
 drivers/usb/dwc3/core.h |  3 +++
 drivers/usb/dwc3/dwc3-pci.c | 10 ++
 drivers/usb/dwc3/ep0.c  |  8 
 drivers/usb/dwc3/gadget.c   | 33 +
 drivers/usb/dwc3/host.c | 16 ++--
 6 files changed, 54 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e951448..e5fbab2 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -202,7 +202,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
 static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
struct dwc3_event_buffer *evt)
 {
-   dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
+   dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma);
 }
 
 /**
@@ -228,7 +228,7 @@ static struct dwc3_event_buffer 
*dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
if (!evt->cache)
return ERR_PTR(-ENOMEM);
 
-   evt->buf= dma_alloc_coherent(dwc->dev, length,
+   evt->buf= dma_alloc_coherent(dwc->sysdev, length,
>dma, GFP_KERNEL);
if (!evt->buf)
return ERR_PTR(-ENOMEM);
@@ -341,11 +341,11 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
if (!WARN_ON(dwc->scratchbuf))
return 0;
 
-   scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
+   scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf,
dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
DMA_BIDIRECTIONAL);
-   if (dma_mapping_error(dwc->dev, scratch_addr)) {
-   dev_err(dwc->dev, "failed to map scratch buffer\n");
+   if (dma_mapping_error(dwc->sysdev, scratch_addr)) {
+   dev_err(dwc->sysdev, "failed to map scratch buffer\n");
ret = -EFAULT;
goto err0;
}
@@ -369,7 +369,7 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
return 0;
 
 err1:
-   dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
+   dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *
DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
 
 err0:
@@ -388,7 +388,7 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
if (!WARN_ON(dwc->scratchbuf))
return;
 
-   dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
+   dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *
DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
kfree(dwc->scratchbuf);
 }
@@ -927,6 +927,13 @@ static void dwc3_get_properties(struct dwc3 *dwc)
dwc->dr_mode = usb_get_dr_mode(dev);
dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node);
 
+   dwc->sysdev_is_parent = device_property_read_bool(dev,
+   "linux,sysdev_is_parent");
+   if (dwc->sysdev_is_parent)
+   dwc->sysdev = dwc->dev->parent;
+   else
+   dwc->sysdev = dwc->dev;
+
dwc->has_lpm_erratum = device_property_read_bool(dev,
"snps,has-lpm-erratum");
device_property_read_u8(dev, "snps,lpm-nyet-threshold",
@@ -1097,12 +1104,6 @@ static int dwc3_probe(struct platform_device *pdev)
 
spin_lock_init(>lock);
 
-   if (!dev->dma_mask) {
-   dev->dma_mask = dev->parent->dma_mask;
-   dev->dma_parms = dev->parent->dma_parms;
-   dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
-   }
-
pm_runtime_set_active(dev);
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index ef81fa5..de5a857 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -819,6 +819,7 @@ struct dwc3_scratchpad_array {
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
+ * @sysdev_is_parent: true when dwc3 device has a parent driver
  * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
  * there's now 

[PATCH v5 4/6] usb: xhci: use bus->sysdev for DMA configuration

2016-11-17 Thread Sriram Dash
From: Arnd Bergmann 

For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices. So, set
the dma for xhci from sysdev. sysdev is pointing to device that
is known to the system firmware or hardware.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Tested-by: Baolin Wang 
---
Changes in v5:
  - No update

Changes in v4:
  - No update

Changes in v3:
  - No update

Changes in v2:
  - Separate out xhci driver changes apart

 drivers/usb/host/xhci-mem.c  | 12 ++--
 drivers/usb/host/xhci-plat.c | 33 ++---
 drivers/usb/host/xhci.c  | 15 +++
 3 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 48a26d378..eb32de9 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
unsigned int num_stream_ctxs,
struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
 {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
 
if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct 
xhci_hcd *xhci,
unsigned int num_stream_ctxs, dma_addr_t *dma,
gfp_t mem_flags)
 {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
 
if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -1644,7 +1644,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci,
 static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 {
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
 
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -1716,7 +1716,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 {
int num_sp;
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
 
if (!xhci->scratchpad)
return;
@@ -1792,7 +1792,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
 
 void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
int size;
int i, j, num_ports;
 
@@ -2334,7 +2334,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, 
gfp_t flags)
 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 {
dma_addr_t  dma;
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
unsigned intval, val2;
u64 val_64;
struct xhci_segment *seg;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..beb95c8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -139,6 +140,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 {
const struct of_device_id *match;
const struct hc_driver  *driver;
+   struct device   *sysdev;
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd  *hcd;
@@ -155,22 +157,39 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq < 0)
return -ENODEV;
 
+   /*
+* sysdev must point to a device that is known to the system firmware
+* or PCI hardware. We handle these three cases here:
+* 1. xhci_plat comes from firmware
+* 2. xhci_plat is child of a device from firmware (dwc3-plat)
+* 3. xhci_plat is grandchild of a pci device (dwc3-pci)
+*/
+   sysdev = >dev;
+   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   sysdev = sysdev->parent;
+#ifdef CONFIG_PCI
+   else if (sysdev->parent && sysdev->parent->parent &&
+sysdev->parent->parent->bus == _bus_type)
+   sysdev = sysdev->parent->parent;
+#endif
+
/* Try to set 64-bit DMA first */
-   if (WARN_ON(!pdev->dev.dma_mask))
+   if (WARN_ON(!sysdev->dma_mask))
/* Platform did not initialize dma_mask */
-   ret = dma_coerce_mask_and_coherent(>dev,
+   ret = dma_coerce_mask_and_coherent(sysdev,
   

[PATCH v5 3/6] usb: ehci: fsl: use bus->sysdev for DMA configuration

2016-11-17 Thread Sriram Dash
From: Arnd Bergmann 

For the dual role ehci fsl driver, sysdev will handle the dma
config.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
---
Changes in v5:
  - No update

Changes in v4:
  - No update
Changes in v3:
  - fix compile errors
Changes in v2:
  - fix compile warnings

 drivers/usb/host/ehci-fsl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 9f5ffb6..4d4ab42 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -96,8 +96,8 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
}
irq = res->start;
 
-   hcd = usb_create_hcd(_ehci_hc_driver, >dev,
-   dev_name(>dev));
+   hcd = __usb_create_hcd(_ehci_hc_driver, pdev->dev.parent,
+  >dev, dev_name(>dev), NULL);
if (!hcd) {
retval = -ENOMEM;
goto err1;
-- 
2.1.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 v5 2/6] usb: chipidea: use bus->sysdev for DMA configuration

2016-11-17 Thread Sriram Dash
From: Arnd Bergmann 

Set the dma for chipidea from sysdev. This is inherited from its
parent node. Also, do not set dma mask for child as it is not required
now.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Acked-by: Peter Chen 
---
Changes in v5:
  - No update

Changes in v4:
  - No update

Changes in v3:
  - No update

Changes in v2:
  - integrate chipidea driver changes together.

 drivers/usb/chipidea/core.c |  3 ---
 drivers/usb/chipidea/host.c |  3 ++-
 drivers/usb/chipidea/udc.c  | 10 ++
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 69426e6..8917a03 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -833,9 +833,6 @@ struct platform_device *ci_hdrc_add_device(struct device 
*dev,
}
 
pdev->dev.parent = dev;
-   pdev->dev.dma_mask = dev->dma_mask;
-   pdev->dev.dma_parms = dev->dma_parms;
-   dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
 
ret = platform_device_add_resources(pdev, res, nres);
if (ret)
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 111b0e0b..3218b49 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -116,7 +116,8 @@ static int host_start(struct ci_hdrc *ci)
if (usb_disabled())
return -ENODEV;
 
-   hcd = usb_create_hcd(_ehci_hc_driver, ci->dev, dev_name(ci->dev));
+   hcd = __usb_create_hcd(_ehci_hc_driver, ci->dev->parent,
+  ci->dev, dev_name(ci->dev), NULL);
if (!hcd)
return -ENOMEM;
 
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index a7b383d..891626a 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -423,7 +423,8 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct 
ci_hw_req *hwreq)
 
hwreq->req.status = -EALREADY;
 
-   ret = usb_gadget_map_request(>gadget, >req, hwep->dir);
+   ret = usb_gadget_map_request_by_dev(ci->dev->parent,
+   >req, hwep->dir);
if (ret)
return ret;
 
@@ -603,7 +604,8 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct 
ci_hw_req *hwreq)
list_del_init(>td);
}
 
-   usb_gadget_unmap_request(>ci->gadget, >req, hwep->dir);
+   usb_gadget_unmap_request_by_dev(hwep->ci->dev->parent,
+   >req, hwep->dir);
 
hwreq->req.actual += actual;
 
@@ -1904,13 +1906,13 @@ static int udc_start(struct ci_hdrc *ci)
INIT_LIST_HEAD(>gadget.ep_list);
 
/* alloc resources */
-   ci->qh_pool = dma_pool_create("ci_hw_qh", dev,
+   ci->qh_pool = dma_pool_create("ci_hw_qh", dev->parent,
   sizeof(struct ci_hw_qh),
   64, CI_HDRC_PAGE_SIZE);
if (ci->qh_pool == NULL)
return -ENOMEM;
 
-   ci->td_pool = dma_pool_create("ci_hw_td", dev,
+   ci->td_pool = dma_pool_create("ci_hw_td", dev->parent,
   sizeof(struct ci_hw_td),
   64, CI_HDRC_PAGE_SIZE);
if (ci->td_pool == NULL) {
-- 
2.1.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 v5 6/6] usb: dwc3: Do not set dma coherent mask

2016-11-17 Thread Sriram Dash
From: Arnd Bergmann 

The dma mask is correctly set up by the DT probe function, no
need to override it any more.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
---
Changes in v5:
  - No update

Changes in v4:
  - No update

Changes in v3:
  - No update

Changes in v2:
  - club the cleanup for dma coherent mask for device

 drivers/usb/dwc3/dwc3-exynos.c | 10 --
 drivers/usb/dwc3/dwc3-st.c |  1 -
 2 files changed, 11 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 2f1fb7e..e27899b 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -117,15 +116,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
if (!exynos)
return -ENOMEM;
 
-   /*
-* Right now device-tree probed devices don't get dma_mask set.
-* Since shared usb code relies on it, set it here for now.
-* Once we move to full device tree support this will vanish off.
-*/
-   ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
-
platform_set_drvdata(pdev, exynos);
 
exynos->dev = dev;
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 89a2f71..4d7439c 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -218,7 +218,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
if (IS_ERR(regmap))
return PTR_ERR(regmap);
 
-   dma_set_coherent_mask(dev, dev->coherent_dma_mask);
dwc3_data->dev = dev;
dwc3_data->regmap = regmap;
 
-- 
2.1.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 v5 0/6] inherit dma configuration from parent dev

2016-11-17 Thread Sriram Dash
For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices.

The idea here is that you pass in the parent of_node along
with the child device pointer, so it would behave exactly
like the parent already does. The difference is that it also
handles all the other attributes besides the mask.

Arnd Bergmann (6):
  usb: separate out sysdev pointer from usb_bus
  usb: chipidea: use bus->sysdev for DMA configuration
  usb: ehci: fsl: use bus->sysdev for DMA configuration
  usb: xhci: use bus->sysdev for DMA configuration
  usb: dwc3: use bus->sysdev for DMA configuration
  usb: dwc3: Do not set dma coherent mask

 drivers/usb/chipidea/core.c|  3 ---
 drivers/usb/chipidea/host.c|  3 ++-
 drivers/usb/chipidea/udc.c | 10 +
 drivers/usb/core/buffer.c  | 12 +--
 drivers/usb/core/hcd.c | 48 +-
 drivers/usb/core/usb.c | 18 
 drivers/usb/dwc3/core.c| 27 
 drivers/usb/dwc3/core.h|  3 +++
 drivers/usb/dwc3/dwc3-exynos.c | 10 -
 drivers/usb/dwc3/dwc3-pci.c| 10 +
 drivers/usb/dwc3/dwc3-st.c |  1 -
 drivers/usb/dwc3/ep0.c |  8 +++
 drivers/usb/dwc3/gadget.c  | 33 +++--
 drivers/usb/dwc3/host.c| 16 ++
 drivers/usb/host/ehci-fsl.c|  4 ++--
 drivers/usb/host/xhci-mem.c| 12 +--
 drivers/usb/host/xhci-plat.c   | 33 +++--
 drivers/usb/host/xhci.c| 15 +
 include/linux/usb.h|  1 +
 include/linux/usb/hcd.h|  3 +++
 20 files changed, 155 insertions(+), 115 deletions(-)

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


Re: [PATCH v2 2/4] usb: dwc2: Add binding for AHB burst

2016-11-17 Thread Felipe Balbi

Hi,

John Youn  writes:
> Add the "snps,ahb-burst" binding and read it in.
>
> This property controls which burst type to perform on the AHB bus as a
> master in internal DMA mode. This overrides the legacy param value,
> which we need to keep around for now since several platforms use it.
>
> Some platforms may see better or worse performance based on this
> value. The HAPS platform is one example where all INCRx have worse
> performance than INCR.
>
> Other platforms (such as the Canyonlands board) report that the default
> value causes system hangs.
>
> Signed-off-by: John Youn 
> Cc: Christian Lamparter 

it's getting rather late for this merge window. I still need an ack by
Rob or any of the devicetree folks.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: dwc3: avoid empty-body warning

2016-11-17 Thread Felipe Balbi

Hi,

Arnd Bergmann  writes:
> Building with W=1, we get a warning about harmless empty statements:
>
> drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
> drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 
> 'if' statement [-Werror=empty-body]
>
> gcc does not warn about {} here, so maybe use that instead.
> Alternatively, the code could be removed entirely as it does
> nothing.
>
> Signed-off-by: Arnd Bergmann 
> ---
> This has been present in the driver for a while, but the code
> just moved around, so it showed up as a new warning for me.
> I hope to eventually address all W=1 warnings as they tend to
> find real bugs elsewhere and we may as well fix it now that the
> code has changed.

Thank you, the only problem is that now checkpatch.pl warns. I'll just
remove the code and turn it into a comment. Authorship kept, let me know
if you're okay with me adding your S-o-b:

8<

From ea97b854e5c4437975c5d0e887488390410cfb30 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann 
Date: Wed, 16 Nov 2016 16:37:30 +0100
Subject: [PATCH] usb: dwc3: ep0: avoid empty-body warning

Building with W=1, we get a warning about harmless empty statements:

drivers/usb/dwc3/ep0.c: In function 'dwc3_ep0_handle_intf':
drivers/usb/dwc3/ep0.c:491:4: error: suggest braces around empty body in an 
'if' statement [-Werror=empty-body]

Instead of adding empty braces which would introduce checkpatch.pl
warnings, we're just removing the code which doesn't do anything and
making sure we return 0 so USBCV tool is happy.

NYET-Signed-off-by: Arnd Bergmann 
Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/ep0.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 2b22ea7263d8..4c0664640862 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -486,12 +486,13 @@ static int dwc3_ep0_handle_intf(struct dwc3 *dwc,
 
switch (wValue) {
case USB_INTRF_FUNC_SUSPEND:
-   if (wIndex & USB_INTRF_FUNC_SUSPEND_LP)
-   /* XXX enable Low power suspend */
-   ;
-   if (wIndex & USB_INTRF_FUNC_SUSPEND_RW)
-   /* XXX enable remote wakeup */
-   ;
+   /*
+* REVISIT: Ideally we would enable some low power mode here,
+* however it's unclear what we should be doing here.
+*
+* For now, we're not doing anything, just making sure we return
+* 0 so USB Command Verifier tests pass without any errors.
+*/
break;
default:
ret = -EINVAL;
-- 
2.10.1



-- 
balbi


signature.asc
Description: PGP signature


[PATCHv11 1/3] lib/string: add sysfs_match_string helper

2016-11-17 Thread Heikki Krogerus
Make a simple helper for matching strings with sysfs
attribute files. In most parts the same as match_string(),
except sysfs_match_string() uses sysfs_streq() instead of
strcmp() for matching. This is more convenient when used
with sysfs attributes.

Signed-off-by: Heikki Krogerus 
---
 include/linux/string.h | 10 ++
 lib/string.c   | 26 ++
 2 files changed, 36 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..c4011b2 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -135,6 +135,16 @@ static inline int strtobool(const char *s, bool *res)
 }
 
 int match_string(const char * const *array, size_t n, const char *string);
+int __sysfs_match_string(const char * const *array, size_t n, const char *s);
+
+/**
+ * sysfs_match_string - matches given string in an array
+ * @_a: array of strings
+ * @_s: string to match with
+ *
+ * Helper for __sysfs_match_string(). Calculates the size of @a automatically.
+ */
+#define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s)
 
 #ifdef CONFIG_BINARY_PRINTF
 int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
diff --git a/lib/string.c b/lib/string.c
index ed83562..c7a20cb 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -656,6 +656,32 @@ int match_string(const char * const *array, size_t n, 
const char *string)
 }
 EXPORT_SYMBOL(match_string);
 
+/**
+ * __sysfs_match_string - matches given string in an array
+ * @array: array of strings
+ * @n: number of strings in the array or -1 for NULL terminated arrays
+ * @str: string to match with
+ *
+ * Returns index of @str in the @array or -EINVAL, just like match_string().
+ * Uses sysfs_streq instead of strcmp for matching.
+ */
+int __sysfs_match_string(const char * const *array, size_t n, const char *str)
+{
+   const char *item;
+   int index;
+
+   for (index = 0; index < n; index++) {
+   item = array[index];
+   if (!item)
+   break;
+   if (!sysfs_streq(item, str))
+   return index;
+   }
+
+   return -EINVAL;
+}
+EXPORT_SYMBOL(__sysfs_match_string);
+
 #ifndef __HAVE_ARCH_MEMSET
 /**
  * memset - Fill a region of memory with the given value
-- 
2.10.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


[PATCHv11 0/3] USB Type-C Connector class

2016-11-17 Thread Heikki Krogerus
The USB Type-C class is meant to provide unified interface to the
userspace to present the USB Type-C ports in a system.

Changes since v10:
- Using ATTRIBUTE_GROUPS and DEVICE_ATTR marcos everywhere
- Moved sysfs_match_string to lib/string.c
- Rationalized uevents
- Calling ida_destroy

Changes since v9:
- Minor typec_wcove.c cleanup as proposed by Guenter Roeck. No
  function affect.

Changes since v8:
- checking sysfs_streq() result correctly in sysfs_strmatch
- fixed accessory check in supported_accessory_mode
- using "none" as the only string that can clear the preferred role

Changes since v7:
- Removed "type" attribute from partners
- Added supports_usb_power_delivery attribute for partner and cable

Changes since v6:
- current_vconn_role attr renamed to vconn_source (no API changes)
- Small documentation improvements proposed by Vincent Palatin

Changes since v5:
- Only updating the roles based on driver notifications
- Added MODULE_ALIAS for the WhiskeyCove module
- Including the patch that creates the actual platform device for the
  WhiskeyCove Type-C PHY in this series.

Changes since v4:
- Remove the port lock completely

Changes since v3:
- Documentation cleanup as proposed by Roger Quadros
- Setting partner altmodes member to NULL on removal and fixing a
  warning, as proposed by Guenter Roeck
- Added the following attributes for partners and cables:
  * supports_usb_power_delivery
  * id_header_vdo
- "id_header_vdo" is visible only when the partner or cable supports
  USB Power Delivery communication.
- Partner attribute "accessory" is hidden when the partner type is not
  "Accessory".

Changes since v2:
- Notification on role and alternate mode changes
- cleanups

Changes since v1:
- Completely rewrote alternate mode support
- Patners, cables and cable plugs presented as devices.


Heikki Krogerus (3):
  lib/string: add sysfs_match_string helper
  usb: USB Type-C connector class
  usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY

 Documentation/ABI/testing/sysfs-class-typec |  222 ++
 Documentation/usb/typec.txt |  103 +++
 MAINTAINERS |9 +
 drivers/usb/Kconfig |2 +
 drivers/usb/Makefile|2 +
 drivers/usb/typec/Kconfig   |   21 +
 drivers/usb/typec/Makefile  |2 +
 drivers/usb/typec/typec.c   | 1012 +++
 drivers/usb/typec/typec_wcove.c |  372 ++
 include/linux/string.h  |   10 +
 include/linux/usb/typec.h   |  252 +++
 lib/string.c|   26 +
 12 files changed, 2033 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-typec
 create mode 100644 Documentation/usb/typec.txt
 create mode 100644 drivers/usb/typec/Kconfig
 create mode 100644 drivers/usb/typec/Makefile
 create mode 100644 drivers/usb/typec/typec.c
 create mode 100644 drivers/usb/typec/typec_wcove.c
 create mode 100644 include/linux/usb/typec.h

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


[PATCHv11 3/3] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY

2016-11-17 Thread Heikki Krogerus
This adds driver for the USB Type-C PHY on Intel WhiskeyCove
PMIC which is available on some of the Intel Broxton SoC
based platforms.

Signed-off-by: Heikki Krogerus 
---
 drivers/usb/typec/Kconfig   |  14 ++
 drivers/usb/typec/Makefile  |   1 +
 drivers/usb/typec/typec_wcove.c | 372 
 3 files changed, 387 insertions(+)
 create mode 100644 drivers/usb/typec/typec_wcove.c

diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index b229fb9..7a345a4 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -4,4 +4,18 @@ menu "USB PD and Type-C drivers"
 config TYPEC
tristate
 
+config TYPEC_WCOVE
+   tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver"
+   depends on ACPI
+   depends on INTEL_SOC_PMIC
+   depends on INTEL_PMC_IPC
+   select TYPEC
+   help
+ This driver adds support for USB Type-C detection on Intel Broxton
+ platforms that have Intel Whiskey Cove PMIC. The driver can detect the
+ role and cable orientation.
+
+ To compile this driver as module, choose M here: the module will be
+ called typec_wcove
+
 endmenu
diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index 1012a8b..b9cb862 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_TYPEC)+= typec.o
+obj-$(CONFIG_TYPEC_WCOVE)  += typec_wcove.o
diff --git a/drivers/usb/typec/typec_wcove.c b/drivers/usb/typec/typec_wcove.c
new file mode 100644
index 000..953d59b
--- /dev/null
+++ b/drivers/usb/typec/typec_wcove.c
@@ -0,0 +1,372 @@
+/**
+ * typec_wcove.c - WhiskeyCove PMIC USB Type-C PHY driver
+ *
+ * Copyright (C) 2016 Intel Corporation
+ * Author: Heikki Krogerus 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define WCOVE_CHGRIRQ0 0x4e09
+#define WCOVE_PHYCTRL  0x5e07
+
+#define USBC_CONTROL1  0x7001
+#define USBC_CONTROL2  0x7002
+#define USBC_CONTROL3  0x7003
+#define USBC_CC1_CTRL  0x7004
+#define USBC_CC2_CTRL  0x7005
+#define USBC_STATUS1   0x7007
+#define USBC_STATUS2   0x7008
+#define USBC_STATUS3   0x7009
+#define USBC_IRQ1  0x7015
+#define USBC_IRQ2  0x7016
+#define USBC_IRQMASK1  0x7017
+#define USBC_IRQMASK2  0x7018
+
+/* Register bits */
+
+#define USBC_CONTROL1_MODE_DRP(r)  (((r) & ~0x7) | 4)
+
+#define USBC_CONTROL2_UNATT_SNKBIT(0)
+#define USBC_CONTROL2_UNATT_SRCBIT(1)
+#define USBC_CONTROL2_DIS_ST   BIT(2)
+
+#define USBC_CONTROL3_PD_DIS   BIT(1)
+
+#define USBC_CC_CTRL_VCONN_EN  BIT(1)
+
+#define USBC_STATUS1_DET_ONGOING   BIT(6)
+#define USBC_STATUS1_RSLT(r)   ((r) & 0xf)
+#define USBC_RSLT_NOTHING  0
+#define USBC_RSLT_SRC_DEFAULT  1
+#define USBC_RSLT_SRC_1_5A 2
+#define USBC_RSLT_SRC_3_0A 3
+#define USBC_RSLT_SNK  4
+#define USBC_RSLT_DEBUG_ACC5
+#define USBC_RSLT_AUDIO_ACC6
+#define USBC_RSLT_UNDEF15
+#define USBC_STATUS1_ORIENT(r) (((r) >> 4) & 0x3)
+#define USBC_ORIENT_NORMAL 1
+#define USBC_ORIENT_REVERSE2
+
+#define USBC_STATUS2_VBUS_REQ  BIT(5)
+
+#define USBC_IRQ1_ADCDONE1 BIT(2)
+#define USBC_IRQ1_OVERTEMP BIT(1)
+#define USBC_IRQ1_SHORTBIT(0)
+
+#define USBC_IRQ2_CC_CHANGEBIT(7)
+#define USBC_IRQ2_RX_PDBIT(6)
+#define USBC_IRQ2_RX_HRBIT(5)
+#define USBC_IRQ2_RX_CRBIT(4)
+#define USBC_IRQ2_TX_SUCCESS   BIT(3)
+#define USBC_IRQ2_TX_FAIL  BIT(2)
+
+#define USBC_IRQMASK1_ALL  (USBC_IRQ1_ADCDONE1 | USBC_IRQ1_OVERTEMP | \
+USBC_IRQ1_SHORT)
+
+#define USBC_IRQMASK2_ALL  (USBC_IRQ2_CC_CHANGE | USBC_IRQ2_RX_PD | \
+USBC_IRQ2_RX_HR | USBC_IRQ2_RX_CR | \
+USBC_IRQ2_TX_SUCCESS | USBC_IRQ2_TX_FAIL)
+
+struct wcove_typec {
+   struct mutex lock; /* device lock */
+   struct device *dev;
+   struct regmap *regmap;
+   struct typec_port *port;
+   struct typec_capability cap;
+   struct typec_connection con;
+   struct typec_partner partner;
+};
+
+enum wcove_typec_func {
+   WCOVE_FUNC_DRIVE_VBUS = 1,
+   WCOVE_FUNC_ORIENTATION,
+   WCOVE_FUNC_ROLE,
+   WCOVE_FUNC_DRIVE_VCONN,
+};
+
+enum wcove_typec_orientation {
+   WCOVE_ORIENTATION_NORMAL,
+  

[PATCHv11 2/3] usb: USB Type-C connector class

2016-11-17 Thread Heikki Krogerus
The purpose of USB Type-C connector class is to provide
unified interface for the user space to get the status and
basic information about USB Type-C connectors on a system,
control over data role swapping, and when the port supports
USB Power Delivery, also control over power role swapping
and Alternate Modes.

Signed-off-by: Heikki Krogerus 
---
 Documentation/ABI/testing/sysfs-class-typec |  222 ++
 Documentation/usb/typec.txt |  103 +++
 MAINTAINERS |9 +
 drivers/usb/Kconfig |2 +
 drivers/usb/Makefile|2 +
 drivers/usb/typec/Kconfig   |7 +
 drivers/usb/typec/Makefile  |1 +
 drivers/usb/typec/typec.c   | 1012 +++
 include/linux/usb/typec.h   |  252 +++
 9 files changed, 1610 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-typec
 create mode 100644 Documentation/usb/typec.txt
 create mode 100644 drivers/usb/typec/Kconfig
 create mode 100644 drivers/usb/typec/Makefile
 create mode 100644 drivers/usb/typec/typec.c
 create mode 100644 include/linux/usb/typec.h

diff --git a/Documentation/ABI/testing/sysfs-class-typec 
b/Documentation/ABI/testing/sysfs-class-typec
new file mode 100644
index 000..4fac77c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-typec
@@ -0,0 +1,222 @@
+USB Type-C port devices (eg. /sys/class/typec/usbc0/)
+
+What:  /sys/class/typec//current_data_role
+Date:  December 2016
+Contact:   Heikki Krogerus 
+Description:
+   The current USB data role the port is operating in. This
+   attribute can be used for requesting data role swapping on the
+   port. Swapping is supported as synchronous operation, so
+   write(2) to the attribute will not return until the operation
+   has finished. The attribute is notified about role changes so
+   that poll(2) on the attribute wakes up. Change on the role will
+   also generate uevent KOBJ_CHANGE on the port.
+
+   Valid values:
+   - host
+   - device
+
+What:  /sys/class/typec//current_power_role
+Date:  December 2016
+Contact:   Heikki Krogerus 
+Description:
+   The current power role of the port. This attribute can be used
+   to request power role swap on the port when the port supports
+   USB Power Delivery. Swapping is supported as synchronous
+   operation, so write(2) to the attribute will not return until
+   the operation has finished. The attribute is notified about role
+   changes so that poll(2) on the attribute wakes up. Change on the
+   role will also generate uevent KOBJ_CHANGE.
+
+   Valid values:
+   - source
+   - sink
+
+What:  /sys/class/typec//vconn_source
+Date:  December 2016
+Contact:   Heikki Krogerus 
+Description:
+   Shows is the port VCONN Source. This attribute can be used to
+   request VCONN swap to change the VCONN Source during connection
+   when both the port and the partner support USB Power Delivery.
+   Swapping is supported as synchronous operation, so write(2) to
+   the attribute will not return until the operation has finished.
+   The attribute is notified about VCONN source changes so that
+   poll(2) on the attribute wakes up. Change on VCONN source also
+   generates uevent KOBJ_CHANGE.
+
+   Valid values are:
+   - 0 when the port is not the VCONN Source
+   - 1 when the port is the VCONN Source
+
+What:  /sys/class/typec//power_operation_mode
+Date:  December 2016
+Contact:   Heikki Krogerus 
+Description:
+   Shows the current power operational mode the port is in.
+
+   Valid values:
+   - USB - Normal power levels defined in USB specifications
+   - BC1.2 - Power levels defined in Battery Charging Specification
+ v1.2
+   - USB Type-C 1.5A - Higher 1.5A current defined in USB Type-C
+   specification.
+   - USB Type-C 3.0A - Higher 3A current defined in USB Type-C
+   specification.
+- USB Power Delivery - The voltages and currents defined in USB
+  Power Delivery specification
+
+What:  /sys/class/typec//preferred_role
+Date:  December 2016
+Contact:   Heikki Krogerus 
+Description:

Re: [PATCH] dmaengine: cppi41: More PM runtime fixes

2016-11-17 Thread Vinod Koul
On Wed, Nov 16, 2016 at 10:24:15AM -0800, Tony Lindgren wrote:
> Fix use of u32 instead of int for checking for negative errors values
> as pointed out by Dan Carpenter .
> 
> And while testing the PM runtime error path by randomly returning
> failed values in runtime resume, I noticed two more places that need
> fixing:
> 
> - If pm_runtime_get_sync() fails in probe, we still need to do
>   pm_runtime_put_sync() to keep the use count happy. We could call
>   pm_runtime_put_noidle() on the error path, but we're just going
>   to call pm_runtime_disable() after that so pm_runtime_put_sync()
>   will do what we want
> 
> - We should print an error if pm_runtime_get_sync() fails in
>   cppi41_dma_alloc_chan_resources() so we know where it happens

Applied now. Would have been ideal if the patches were split per fix

Thanks
-- 
~Vinod
--
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: add usb option device

2016-11-17 Thread Johan Hovold
On Wed, Nov 16, 2016 at 10:03:52PM +0100, Giuseppe Lippolis wrote:
> Dear All,
> thanks for the very interesting discussion.
> 
> > > This will make option grab all the ports, as shown by your dmesg
> > > output.  But USB interfaces 0 and 1 are actually cdc-ether and should
> > > *not* be grabbed by option.
> > >
> > > You want to limit option to grabbing bInterfaceClass=255 to make sure
> > > it only gets the serial ports.
> >
> 
> Actually the device have 2 cdc_ether interface and the others are serial comm.
> This is the bootlog of the original oem firmware:
> 
> hub 2-0:1.0: USB hub found
> hub 2-0:1.0: 1 port detected
> usb 2-1: new high speed USB device using rt3xxx-ehci and address 2
> usb 2-1: configuration #1 chosen from 1 choice
> usbcore: registered new interface driver cdc_ether
> usbcore: registered new interface driver usbserial
> drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
> usbserial_generic 2-1:1.2: generic converter detected
> usb 2-1: generic converter now attached to ttyUSB0
> usbserial_generic 2-1:1.3: generic converter detected
> usb 2-1: generic converter now attached to ttyUSB1
> usbserial_generic 2-1:1.4: generic converter detected
> usb 2-1: generic converter now attached to ttyUSB2
> usbserial_generic 2-1:1.5: generic converter detected
> usb 2-1: generic converter now attached to ttyUSB3
> usbserial_generic 2-1:1.6: generic converter detected
> usb 2-1: generic converter now attached to ttyUSB4
> usbcore: registered new interface driver usbserial_generic
> drivers/usb/serial/usb-serial.c: USB Serial Driver core
> 
> and at the end of the modem configuration:
> usbnet0   Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
>   inet addr:77.25.169.193  Bcast:77.25.169.195  Mask:255.255.255.252
>   inet6 addr: fe80:::feaa:/64 Scope:Link
>   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>   RX packets:6 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:1000
>   RX bytes:272 (272.0 B)  TX bytes:600 (600.0 B)
> 
> Therefore I also consider convenient preserve the first two interface
> for the cdc_ether.
> Can you please clarify me the differences between black and white list
> and how to configure it?

If possible you want to tell the option driver which interfaces to bind
to (white-listing) rather than specifying which not to bind to
(black-listing). The latter typically means probing all interfaces,
checking the black list, and then bailing out for unsupported interfaces.

By matching on the interface class it is sometimes possible to rely
solely on white-listing, for example:

USB_DEVICE_INTERFACE_CLASS(VID, PID, 0xff)

would (only) bind to all interface with Vendor Specific Class.

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 v3 1/1] usb: hub: Fix auto-remount of safely removed or ejected USB-3 devices

2016-11-17 Thread Greg KH
On Thu, Nov 17, 2016 at 11:14:14AM +0200, Mathias Nyman wrote:
> USB-3 does not have any link state that will avoid negotiating a connection
> with a plugged-in cable but will signal the host when the cable is
> unplugged.
> 
> For USB-3 we used to first set the link to Disabled, then to RxDdetect to
> be able to detect cable connects or disconnects. But in RxDetect the
> connected device is detected again and eventually enabled.
> 
> Instead set the link into U3 and disable remote wakeups for the device.
> This is what Windows does, and what Alan Stern suggested.
> 
> Cc: sta...@vger.kernel.org
> Cc: Alan Stern 
> Acked-by: Alan Stern 
> Signed-off-by: Mathias Nyman 

Can I put this in -next and get it some testing before going to Linus
for 4.10-rc1, or do you think it needs to get into 4.9-final due to
people complaining about this?  If so, is it a regression or just
something that we have never done before (I think the latter, but want
to make sure...)

thanks,

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


Re: [PATCH 1/2] usb: gadget: serial: zero-initialize struct variable gscons_info

2016-11-17 Thread Felipe Balbi

Hi,

(no top-posting, please)

Felix Hädicke  writes:
> ok, thanks for the hint. I dind't know this.
>
> Just ignore this patch.

fair enough, then just resend patch 2/2 with Oops message in commit log
and Peter's Tested-by already added.

thanks

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 0/6] musb-fixes for v4.9-rc6

2016-11-17 Thread Johan Hovold
[ +CC: Tony ]

On Thu, Nov 17, 2016 at 08:10:55AM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 16, 2016 at 01:21:21PM -0600, Bin Liu wrote:
> > Hi Greg,
> > 
> > Hope this is not too late for -rc6. This set fixes a long standing musb
> > regression introduced in v4.8.  Please let me know if any change is needed.
> 
> As these were bugs in 4.8 (i.e. not a regression due to changes in
> 4.9-rc1), can we just wait for 4.10-rc1 for these patches?

I believe that may have been a typo as this series fixes a number of
regressions in 4.9. Most of the patches have either or both of

Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime
PM for musb-core")
Fixes: 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS

that went into 4.9, or are prerequisite clean ups (patch 1/6).

The exception being patch 4/6 that claims to fix a commit in 4.7.

The driver appeared to work well-enough for me in 4.8, but then again I
only hit the debug splat triggered by 65b3f50ed6fa ("usb: musb: Add PM
runtime support for MUSB DSPS) every other second (fixed by patch 2/6).

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 1/2] usb: gadget: serial: zero-initialize struct variable gscons_info

2016-11-17 Thread Felipe Balbi

Hi,

Felix Hädicke  writes:
> There can be cases when members of the gscons_info struct are used
> uninitialized, e. g. in, gserial_console_exit(), if gs_console_setup()
> was not called before.
>
> Signed-off-by: Felix Hädicke 
> ---
>  drivers/usb/gadget/function/u_serial.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/u_serial.c 
> b/drivers/usb/gadget/function/u_serial.c
> index e0cd1e4..5fedead 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -1043,7 +1043,7 @@ static struct tty_driver *gs_tty_driver;
>  
>  #ifdef CONFIG_U_SERIAL_CONSOLE
>  
> -static struct gscons_info gscons_info;
> +static struct gscons_info gscons_info = {};

this can't be needed. static variables are zero-initialized
"automatically".

-- 
balbi


signature.asc
Description: PGP signature


Re: crash by cdc_acm driver in kernels 4.8-rc1/5

2016-11-17 Thread Wim Osterholt
On Thu, Nov 17, 2016 at 02:57:33AM +0100, Wim Osterholt wrote:
> Now a retry of 4.9-rc5. I take the config of 4.8.8 and accept
> the default for the new options.
> SMP set.  No call trace appears.
> For completeness I should also try with SMP unset. That is for tomorrow
> then.

With CONFIG_SMP unset nothing goes wrong here either.
It looks like it has been fixed in 4.9-rc5, but I should also double check
several conbinations on my (slower) laptop.

Regards, Wim.
--
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/1] usb: hub: Fix auto-remount of safely removed or ejected USB-3 devices

2016-11-17 Thread Mathias Nyman
USB-3 does not have any link state that will avoid negotiating a connection
with a plugged-in cable but will signal the host when the cable is
unplugged.

For USB-3 we used to first set the link to Disabled, then to RxDdetect to
be able to detect cable connects or disconnects. But in RxDetect the
connected device is detected again and eventually enabled.

Instead set the link into U3 and disable remote wakeups for the device.
This is what Windows does, and what Alan Stern suggested.

Cc: sta...@vger.kernel.org
Cc: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Mathias Nyman 

---
Changes since v2:
- clear udev->do_remote_wakeup as suggested
- add Acked-by: Alan Stern as agreed

Changes since RFC-PATCH:
- send port_dev as an argument
- move checking and disabling remote wakeup to a function under CONFIG_PM
- set device state to USB_STATE_NOTATTACHED _after_ disabling remote wakup
  and port disable.
---
 drivers/usb/core/hub.c | 101 ++---
 1 file changed, 36 insertions(+), 65 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 76e80d8..71bf1c7 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -103,6 +103,8 @@
 
 static void hub_release(struct kref *kref);
 static int usb_reset_and_verify_device(struct usb_device *udev);
+static void hub_usb3_port_prepare_disable(struct usb_hub *hub,
+ struct usb_port *port_dev);
 
 static inline char *portspeed(struct usb_hub *hub, int portstatus)
 {
@@ -901,82 +903,28 @@ static int hub_set_port_link_state(struct usb_hub *hub, 
int port1,
 }
 
 /*
- * If USB 3.0 ports are placed into the Disabled state, they will no longer
- * detect any device connects or disconnects.  This is generally not what the
- * USB core wants, since it expects a disabled port to produce a port status
- * change event when a new device connects.
- *
- * Instead, set the link state to Disabled, wait for the link to settle into
- * that state, clear any change bits, and then put the port into the RxDetect
- * state.
+ * USB-3 does not have a similar link state as USB-2 that will avoid 
negotiating
+ * a connection with a plugged-in cable but will signal the host when the cable
+ * is unplugged. Disable remote wake and set link state to U3 for USB-3 devices
  */
-static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
-{
-   int ret;
-   int total_time;
-   u16 portchange, portstatus;
-
-   if (!hub_is_superspeed(hub->hdev))
-   return -EINVAL;
-
-   ret = hub_port_status(hub, port1, , );
-   if (ret < 0)
-   return ret;
-
-   /*
-* USB controller Advanced Micro Devices, Inc. [AMD] FCH USB XHCI
-* Controller [1022:7814] will have spurious result making the following
-* usb 3.0 device hotplugging route to the 2.0 root hub and recognized
-* as high-speed device if we set the usb 3.0 port link state to
-* Disabled. Since it's already in USB_SS_PORT_LS_RX_DETECT state, we
-* check the state here to avoid the bug.
-*/
-   if ((portstatus & USB_PORT_STAT_LINK_STATE) ==
-   USB_SS_PORT_LS_RX_DETECT) {
-   dev_dbg(>ports[port1 - 1]->dev,
-"Not disabling port; link state is RxDetect\n");
-   return ret;
-   }
-
-   ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
-   if (ret)
-   return ret;
-
-   /* Wait for the link to enter the disabled state. */
-   for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
-   ret = hub_port_status(hub, port1, , );
-   if (ret < 0)
-   return ret;
-
-   if ((portstatus & USB_PORT_STAT_LINK_STATE) ==
-   USB_SS_PORT_LS_SS_DISABLED)
-   break;
-   if (total_time >= HUB_DEBOUNCE_TIMEOUT)
-   break;
-   msleep(HUB_DEBOUNCE_STEP);
-   }
-   if (total_time >= HUB_DEBOUNCE_TIMEOUT)
-   dev_warn(>ports[port1 - 1]->dev,
-   "Could not disable after %d ms\n", total_time);
-
-   return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT);
-}
-
 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
 {
struct usb_port *port_dev = hub->ports[port1 - 1];
struct usb_device *hdev = hub->hdev;
int ret = 0;
 
-   if (port_dev->child && set_state)
-   usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
if (!hub->error) {
-   if (hub_is_superspeed(hub->hdev))
-   ret = hub_usb3_port_disable(hub, port1);
-   else
+   if (hub_is_superspeed(hub->hdev)) {
+   

Re: [PATHCv10 1/2] usb: USB Type-C connector class

2016-11-17 Thread Heikki Krogerus
On Wed, Nov 16, 2016 at 04:31:07PM +0100, Greg KH wrote:
> On Wed, Nov 16, 2016 at 05:20:24PM +0200, Heikki Krogerus wrote:
> > Hi Greg,
> > 
> > On Mon, Nov 14, 2016 at 10:51:48AM +0100, Greg KH wrote:
> > > > +static int sysfs_strmatch(const char * const *array, size_t n, const 
> > > > char *str)
> > > > +{
> > > > +   const char *item;
> > > > +   int index;
> > > > +
> > > > +   for (index = 0; index < n; index++) {
> > > > +   item = array[index];
> > > > +   if (!item)
> > > > +   break;
> > > > +   if (sysfs_streq(item, str))
> > > > +   return index;
> > > > +   }
> > > > +
> > > > +   return -EINVAL;
> > > > +}
> > > 
> > > should we make this a core sysfs function?
> > 
> > Last question before I send v11. Is the following (the helper) OK?
> > 
> > 
> > diff --git a/include/linux/string.h b/include/linux/string.h
> > index 26b6f6a..5606810 100644
> > --- a/include/linux/string.h
> > +++ b/include/linux/string.h
> > @@ -135,6 +135,16 @@ static inline int strtobool(const char *s, bool *res)
> >  }
> >  
> >  int match_string(const char * const *array, size_t n, const char *string);
> > +int __sysfs_strmatch(const char * const *array, size_t n, const char 
> > *string);
> > +
> > +/**
> > + * sysfs_strmatch - matches given string in an array
> > + * @a: array of strings
> > + * @s: string to match with
> > + *
> > + * Helper for __sysfs_strmatch(). Calculates the size of @a automatically.
> > + */
> > +#define sysfs_strmatch(a, s) __sysfs_strmatch(a, ARRAY_SIZE(a), s)
> 
> People will bikeshed the name.  Why not just use sysfs_match_string() as
> this does the same as match_string, but calls sysfs_string instead of
> strcmp().

Makes sense. I'll change the name.

Thanks,

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