Re: [PATCH 8/8] USB: serial: fix minor-number allocation

2016-05-08 Thread Greg KH
On Sun, May 08, 2016 at 08:08:03PM +0200, Johan Hovold wrote:
> Due to a missing upper bound, invalid minor numbers could be assigned to
> ports. Such devices would later fail to register, but let's catch this
> early as intended and avoid having devices with only a subset of their
> ports registered (potentially the empty set).
> 
> Signed-off-by: Johan Hovold 
> ---
>  drivers/usb/serial/usb-serial.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> index 7ecf4ff86b9a..4d2b310de55d 100644
> --- a/drivers/usb/serial/usb-serial.c
> +++ b/drivers/usb/serial/usb-serial.c
> @@ -96,7 +96,8 @@ static int allocate_minors(struct usb_serial *serial, int 
> num_ports)
>   mutex_lock(&table_lock);
>   for (i = 0; i < num_ports; ++i) {
>   port = serial->port[i];
> - minor = idr_alloc(&serial_minors, port, 0, 0, GFP_KERNEL);
> + minor = idr_alloc(&serial_minors, port, 0,
> + USB_SERIAL_TTY_MINORS, GFP_KERNEL);
>   if (minor < 0)
>   goto error;
>   port->minor = minor;

Nice catch for this one, and all the others in this series.

Feel free to add:
Acked-by: Greg Kroah-Hartman 

to them all if you want.

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: usb: dwc2: regression on MyBook Live Duo / Canyonlands since 4.3.0-rc4

2016-05-08 Thread Benjamin Herrenschmidt
On Sun, 2016-05-08 at 13:44 +0200, Christian Lamparter wrote:
> On Sunday, May 08, 2016 08:40:55 PM Benjamin Herrenschmidt wrote:
> > 
> > On Sun, 2016-05-08 at 00:54 +0200, Christian Lamparter via Linuxppc-dev 
> > wrote:
> > > 
> > > I've been looking in getting the MyBook Live Duo's USB OTG port
> > > to function. The SoC is a APM82181. Which has a PowerPC 464 core
> > > and related to the supported canyonlands architecture in
> > > arch/powerpc/.
> > > 
> > > Currently in -next the dwc2 module doesn't load: 
> > Smells like the APM implementation is little endian. You might need to
> > use a flag to indicate what endian to use instead and set it
> > appropriately based on some DT properties.
> I tried. As per common-properties[0], I added little-endian; but it has no
> effect. I looked in dwc2_driver_probe and found no way of specifying the
> endian of the device. It all comes down to the dwc2_readl & dwc2_writel
> accessors. These - sadly - have been hardwired to use __raw_readl and
> __raw_writel. So, it's always "native-endian". While common-properties
> says little-endian should be preferred.

Right, I meant, you should produce a patch adding a runtime test inside
those functions based on a device-tree property, a bit like we do for
some of the HCDs like OHCI, EHCI etc...

Cheers,
Ben.

> > 
> > > 
> > > dwc2 4bff8.usbotg: dwc2_core_reset() HANG! AHB Idle GRSTCTL=80
> > > dwc2 4bff8.usbotg: Bad value for GSNPSID: 0x0a29544f
> > > 
> > > Looking at the Bad GSNPSID value: 0x0a29544f. It is obvious that
> > > this is an endian problem. git finds this patch:
> > > 
> > > commit 95c8bc3609440af5e4a4f760b8680caea7424396
> > > Author: Antti Seppälä 
> > > Date:   Thu Aug 20 21:41:07 2015 +0300
> > > 
> > > usb: dwc2: Use platform endianness when accessing registers
> > > 
> > > This patch is necessary to access dwc2 registers correctly on
> > > big-endian
> > > systems such as the mips based SoCs made by Lantiq. Then dwc2 can
> > > be
> > > used to replace ifx-hcd driver for Lantiq platforms found e.g. in
> > > OpenWrt.
> > > 
> > > The patch was autogenerated with the following commands:
> > > $EDITOR core.h
> > > sed -i "s/\/dwc2_readl/g" *.c hcd.h hw.h
> > > sed -i "s/\/dwc2_writel/g" *.c hcd.h hw.h
> > > 
> > > Some files were then hand-edited to fix checkpatch.pl warnings
> > > about
> > > too long lines.
> > > 
> > > which unfortunately, broke the USB-OTG port on the MyBook Live Duo.
> > > Reverting to the readl / writel:
> > > 
> > > --- 
> > > diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> > > index 3c58d63..c021c1f 100644
> > > --- a/drivers/usb/dwc2/core.h
> > > +++ b/drivers/usb/dwc2/core.h
> > > @@ -66,7 +66,7 @@
> > >  
> > >  static inline u32 dwc2_readl(const void __iomem *addr)
> > >  {
> > > - u32 value = __raw_readl(addr);
> > > + u32 value = readl(addr);
> > >  
> > >   /* In order to preserve endianness __raw_* operation is
> > > used. Therefore
> > >    * a barrier is needed to ensure IO access is not re-ordered 
> > > across
> > > @@ -78,7 +78,7 @@ static inline u32 dwc2_readl(const void __iomem
> > > *addr)
> > >  
> > >  static inline void dwc2_writel(u32 value, void __iomem *addr)
> > >  {
> > > - __raw_writel(value, addr);
> > > + writel(value, addr);
> > >  
> > >   /*
> > >    * In order to preserve endianness __raw_* operation is
> > > used. Therefore
> > > 
> > > ---
> > > 
> > > restores the dwc-otg port to full working order:
> > > dwc2 4bff8.usbotg: Specified GNPTXFDEP=1024 > 256
> > > dwc2 4bff8.usbotg: EPs: 3, shared fifos, 2042 entries in SPRAM
> > > dwc2 4bff8.usbotg: DWC OTG Controller
> > > dwc2 4bff8.usbotg: new USB bus registered, assigned bus number 1
> > > dwc2 4bff8.usbotg: irq 33, io mem 0x
> > > hub 1-0:1.0: USB hub found
> > > hub 1-0:1.0: 1 port detected
> > > root@mbl:~# usb 1-1: new high-speed USB device number 2 using dwc2
> > > 
> > > So, what to do?
>  ^^^
> 
> Regards,
> Christian
> 
> [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

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


[PATCH 1/1] USB: FHCI: avoid redundant condition

2016-05-08 Thread Heinrich Schuchardt
The right part of the following or expression is only evaluated if
td is nonzero.
!td || (td && td.status == USB_TD_INPROGRESS)
So no need to check td again.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/host/fhci-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index a9609a3..2f162fa 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -288,7 +288,7 @@ static int scan_ed_list(struct fhci_usb *usb,
list_for_each_entry(ed, list, node) {
td = ed->td_head;
 
-   if (!td || (td && td->status == USB_TD_INPROGRESS))
+   if (!td || td->status == USB_TD_INPROGRESS)
continue;
 
if (ed->state != FHCI_ED_OPER) {
-- 
2.1.4

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


[PATCH 1/1] usb: net2272: avoid shifting 0

2016-05-08 Thread Heinrich Schuchardt
Remove redundant code.
Or'ing with a shifted value of zero is a NOP.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/gadget/udc/net2272.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c
index 18f5ebd..777eeba 100644
--- a/drivers/usb/gadget/udc/net2272.c
+++ b/drivers/usb/gadget/udc/net2272.c
@@ -664,7 +664,6 @@ net2272_request_dma(struct net2272 *dev, unsigned ep, u32 
buf,
/* Setup PLX 9054 DMA mode */
writel((1 << LOCAL_BUS_WIDTH) |
(1 << TA_READY_INPUT_ENABLE) |
-   (0 << LOCAL_BURST_ENABLE) |
(1 << DONE_INTERRUPT_ENABLE) |
(1 << LOCAL_ADDRESSING_MODE) |
(1 << DEMAND_MODE) |
@@ -688,7 +687,6 @@ net2272_request_dma(struct net2272 *dev, unsigned ep, u32 
buf,
 #endif
 
net2272_write(dev, DMAREQ,
-   (0 << DMA_BUFFER_VALID) |
(1 << DMA_REQUEST_ENABLE) |
(1 << DMA_CONTROL_DACK) |
(dev->dma_eot_polarity << EOT_POLARITY) |
@@ -779,8 +777,6 @@ net2272_kick_dma(struct net2272_ep *ep, struct 
net2272_request *req)
 
/* deassert dreq */
net2272_write(ep->dev, DMAREQ,
-   (0 << DMA_BUFFER_VALID) |
-   (0 << DMA_REQUEST_ENABLE) |
(1 << DMA_CONTROL_DACK) |
(ep->dev->dma_eot_polarity << EOT_POLARITY) |
(ep->dev->dma_dack_polarity << DACK_POLARITY) |
@@ -1363,8 +1359,6 @@ net2272_usb_reset(struct net2272 *dev)
net2272_write(dev, IRQSTAT1, ~(1 << SUSPEND_REQUEST_INTERRUPT));
 
net2272_write(dev, DMAREQ,
-   (0 << DMA_BUFFER_VALID) |
-   (0 << DMA_REQUEST_ENABLE) |
(1 << DMA_CONTROL_DACK) |
(dev->dma_eot_polarity << EOT_POLARITY) |
(dev->dma_dack_polarity << DACK_POLARITY) |
@@ -1542,9 +1536,7 @@ net2272_handle_dma(struct net2272_ep *ep)
 
/* Ensure DREQ is de-asserted */
net2272_write(ep->dev, DMAREQ,
-   (0 << DMA_BUFFER_VALID)
- | (0 << DMA_REQUEST_ENABLE)
- | (1 << DMA_CONTROL_DACK)
+   (1 << DMA_CONTROL_DACK)
  | (ep->dev->dma_eot_polarity << EOT_POLARITY)
  | (ep->dev->dma_dack_polarity << DACK_POLARITY)
  | (ep->dev->dma_dreq_polarity << DREQ_POLARITY)
@@ -2087,7 +2079,7 @@ static irqreturn_t net2272_irq(int irq, void *_dev)
dev->rdk1.plx9054_base_addr + INTCSR);
}
if ((intcsr & DMA_CHANNEL_0_TEST) == DMA_CHANNEL_0_TEST) {
-   writeb((1 << CHANNEL_CLEAR_INTERRUPT | (0 << CHANNEL_ENABLE)),
+   writeb(1 << CHANNEL_CLEAR_INTERRUPT,
dev->rdk1.plx9054_base_addr + DMACSR0);
 
dmareq = net2272_read(dev, DMAREQ);
@@ -2369,7 +2361,7 @@ net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 
*dev)
(1 << LOCAL_INTERRUPT_INPUT_ENABLE),
dev->rdk1.plx9054_base_addr + INTCSR);
 
-   writeb((1 << CHANNEL_CLEAR_INTERRUPT | (0 << CHANNEL_ENABLE)),
+   writeb(1 << CHANNEL_CLEAR_INTERRUPT,
dev->rdk1.plx9054_base_addr + DMACSR0);
 
/* reset */
@@ -2377,7 +2369,6 @@ net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 
*dev)
(1 << DMA_CTL_DACK) |
(1 << DMA_TIMEOUT_ENABLE) |
(1 << USER) |
-   (0 << MPX_MODE) |
(1 << BUSWIDTH) |
(1 << NET2272_RESET),
dev->base_addr + EPLD_IO_CONTROL_REGISTER);
-- 
2.1.4

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


[PATCH 1/1] usb: gadget: hid: remove redundant breaks

2016-05-08 Thread Heinrich Schuchardt
Code after goto is never reached.
Remove redundant breaks.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/gadget/function/f_hid.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 51980c5..6ee81e5 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -449,7 +449,6 @@ static int hidg_setup(struct usb_function *f,
   hidg_desc_copy.bLength);
memcpy(req->buf, &hidg_desc_copy, length);
goto respond;
-   break;
}
case HID_DT_REPORT:
VDBG(cdev, "USB_REQ_GET_DESCRIPTOR: REPORT\n");
@@ -457,13 +456,11 @@ static int hidg_setup(struct usb_function *f,
   hidg->report_desc_length);
memcpy(req->buf, hidg->report_desc, length);
goto respond;
-   break;
 
default:
VDBG(cdev, "Unknown descriptor request 0x%x\n",
 value >> 8);
goto stall;
-   break;
}
break;
 
-- 
2.1.4

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


[PATCH 1/1] usb: gadget: avoid exposing kernel stack

2016-05-08 Thread Heinrich Schuchardt
Function in_rq_cur copies random bytes from the stack.
Zero the memory instead.

Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/gadget/function/f_uac2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/function/f_uac2.c 
b/drivers/usb/gadget/function/f_uac2.c
index 186d4b1..23cba7b 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1292,6 +1292,7 @@ in_rq_cur(struct usb_function *fn, const struct 
usb_ctrlrequest *cr)
 
if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) {
struct cntrl_cur_lay3 c;
+   memset(&c, 0, sizeof(struct cntrl_cur_lay3));
 
if (entity_id == USB_IN_CLK_ID)
c.dCUR = p_srate;
-- 
2.1.4

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


[PATCH 1/1] usb: gadget: f_tcm: out of bound access in usbg_drop_tpg

2016-05-08 Thread Heinrich Schuchardt
Commit dc8c46a5ae77 ("usb: gadget: f_tcm: convert to new function
interface with backward compatibility") introduced a possible out
of bounds memory access:

If tpg is not found in function usbg_drop_tpg,
tpg_instances[TPG_INSTANCES] is accessed.

Fixes: dc8c46a5ae77 ("usb: gadget: f_tcm: convert to new function interface 
with backward compatibility")
Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/gadget/function/f_tcm.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c 
b/drivers/usb/gadget/function/f_tcm.c
index 2ace029..9ab94b6 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1454,16 +1454,18 @@ static void usbg_drop_tpg(struct se_portal_group 
*se_tpg)
for (i = 0; i < TPG_INSTANCES; ++i)
if (tpg_instances[i].tpg == tpg)
break;
-   if (i < TPG_INSTANCES)
+   if (i < TPG_INSTANCES) {
tpg_instances[i].tpg = NULL;
-   opts = container_of(tpg_instances[i].func_inst,
-   struct f_tcm_opts, func_inst);
-   mutex_lock(&opts->dep_lock);
-   if (opts->has_dep)
-   module_put(opts->dependent);
-   else
-   configfs_undepend_item_unlocked(&opts->func_inst.group.cg_item);
-   mutex_unlock(&opts->dep_lock);
+   opts = container_of(tpg_instances[i].func_inst,
+   struct f_tcm_opts, func_inst);
+   mutex_lock(&opts->dep_lock);
+   if (opts->has_dep)
+   module_put(opts->dependent);
+   else
+   configfs_undepend_item_unlocked(
+   &opts->func_inst.group.cg_item);
+   mutex_unlock(&opts->dep_lock);
+   }
mutex_unlock(&tpg_instances_lock);
 
kfree(tpg);
-- 
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] usb/host/fotg210: remove dead code in create_sysfs_files

2016-05-08 Thread Colin King
From: Colin Ian King 

The goto in create_sysfs_files is never executed, so remove it
and clean up the code.

Signed-off-by: Colin Ian King 
---
 drivers/usb/host/fotg210-hcd.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 360a5e9..66efa9a 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -4795,14 +4795,8 @@ static DEVICE_ATTR(uframe_periodic_max, 0644, 
show_uframe_periodic_max,
 static inline int create_sysfs_files(struct fotg210_hcd *fotg210)
 {
struct device *controller = fotg210_to_hcd(fotg210)->self.controller;
-   int i = 0;
 
-   if (i)
-   goto out;
-
-   i = device_create_file(controller, &dev_attr_uframe_periodic_max);
-out:
-   return i;
+   return device_create_file(controller, &dev_attr_uframe_periodic_max);
 }
 
 static inline void remove_sysfs_files(struct fotg210_hcd *fotg210)
-- 
2.8.1

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


Re: [GIT PULL] USB-serial fixes for v4.6-rc7

2016-05-08 Thread Johan Hovold
On Sat, May 07, 2016 at 07:46:14PM +0200, Greg Kroah-Hartman wrote:
> On Thu, May 05, 2016 at 12:13:11PM +0200, Johan Hovold wrote:
> > Hi Greg,
> > 
> > Here are some new modem device ids for the option driver. These have all
> > been in linux-next over night and could go into -rc7 unless you prefer
> > to hold them off for v4.7.
> 
> I'd prefer to hold them off for 4.7, can I just pull these into my -next
> branch for now?

Please do so.

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


[PATCH 6/8] USB: serial: mxuport: fix use-after-free in probe error path

2016-05-08 Thread Johan Hovold
The interface read and event URBs are submitted in attach, but were
never explicitly unlinked by the driver. Instead the URBs would have
been killed by usb-serial core on disconnect.

In case of a late probe error (e.g. due to failed minor allocation),
disconnect is never called and we could end up with active URBs for an
unbound interface. This in turn could lead to deallocated memory being
dereferenced in the completion callbacks.

Fixes: ee467a1f2066 ("USB: serial: add Moxa UPORT 12XX/14XX/16XX
driver")
Cc: stable  # v3.14

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/mxuport.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index 31a8b47f1ac6..c6596cbcc4b6 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -1259,6 +1259,15 @@ static int mxuport_attach(struct usb_serial *serial)
return 0;
 }
 
+static void mxuport_release(struct usb_serial *serial)
+{
+   struct usb_serial_port *port0 = serial->port[0];
+   struct usb_serial_port *port1 = serial->port[1];
+
+   usb_serial_generic_close(port1);
+   usb_serial_generic_close(port0);
+}
+
 static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
struct mxuport_port *mxport = usb_get_serial_port_data(port);
@@ -1361,6 +1370,7 @@ static struct usb_serial_driver mxuport_device = {
.probe  = mxuport_probe,
.port_probe = mxuport_port_probe,
.attach = mxuport_attach,
+   .release= mxuport_release,
.calc_num_ports = mxuport_calc_num_ports,
.open   = mxuport_open,
.close  = mxuport_close,
-- 
2.7.3

--
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 8/8] USB: serial: fix minor-number allocation

2016-05-08 Thread Johan Hovold
Due to a missing upper bound, invalid minor numbers could be assigned to
ports. Such devices would later fail to register, but let's catch this
early as intended and avoid having devices with only a subset of their
ports registered (potentially the empty set).

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/usb-serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 7ecf4ff86b9a..4d2b310de55d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -96,7 +96,8 @@ static int allocate_minors(struct usb_serial *serial, int 
num_ports)
mutex_lock(&table_lock);
for (i = 0; i < num_ports; ++i) {
port = serial->port[i];
-   minor = idr_alloc(&serial_minors, port, 0, 0, GFP_KERNEL);
+   minor = idr_alloc(&serial_minors, port, 0,
+   USB_SERIAL_TTY_MINORS, GFP_KERNEL);
if (minor < 0)
goto error;
port->minor = minor;
-- 
2.7.3

--
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/8] USB: serial: io_edgeport: fix memory leaks in probe error path

2016-05-08 Thread Johan Hovold
URBs and buffers allocated in attach for Epic devices would never be
deallocated in case of a later probe error (e.g. failure to allocate
minor numbers) as disconnect is then never called.

Fix by moving deallocation to release and making sure that the
URBs are first unlinked.

Fixes: f9c99bb8b3a1 ("USB: usb-serial: replace shutdown with disconnect,
release")
Cc: stable  # v2.6.31

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/io_edgeport.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index edd568bc0de5..11c05ce2f35f 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2959,16 +2959,9 @@ static void edge_disconnect(struct usb_serial *serial)
 {
struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
 
-   /* stop reads and writes on all ports */
-   /* free up our endpoint stuff */
if (edge_serial->is_epic) {
usb_kill_urb(edge_serial->interrupt_read_urb);
-   usb_free_urb(edge_serial->interrupt_read_urb);
-   kfree(edge_serial->interrupt_in_buffer);
-
usb_kill_urb(edge_serial->read_urb);
-   usb_free_urb(edge_serial->read_urb);
-   kfree(edge_serial->bulk_in_buffer);
}
 }
 
@@ -2981,6 +2974,16 @@ static void edge_release(struct usb_serial *serial)
 {
struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
 
+   if (edge_serial->is_epic) {
+   usb_kill_urb(edge_serial->interrupt_read_urb);
+   usb_free_urb(edge_serial->interrupt_read_urb);
+   kfree(edge_serial->interrupt_in_buffer);
+
+   usb_kill_urb(edge_serial->read_urb);
+   usb_free_urb(edge_serial->read_urb);
+   kfree(edge_serial->bulk_in_buffer);
+   }
+
kfree(edge_serial);
 }
 
-- 
2.7.3

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


[PATCH 0/8] USB: serial: fix interface URB leaks and use-after-free

2016-05-08 Thread Johan Hovold
This series fixes a number of issues where resources were not properly
released on probe errors. Typically, URBs allocated and submitted in an
attach callback were never unlinked or released in a matching release
callback. This could lead to memory leaks and use-after-free bugs as
we could end up with unbound interfaces with active URBs.

Included is also a couple of minor fixes and clean ups of the keyspan
driver, and a fix of how we deal with minor-number exhaustion in core.

Johan


Johan Hovold (8):
  USB: serial: io_edgeport: fix memory leaks in attach error path
  USB: serial: io_edgeport: fix memory leaks in probe error path
  USB: serial: keyspan: fix use-after-free in probe error path
  USB: serial: keyspan: fix URB unlink
  USB: serial: keyspan: fix debug and error messages
  USB: serial: mxuport: fix use-after-free in probe error path
  USB: serial: quatech2: fix use-after-free in probe error path
  USB: serial: fix minor-number allocation

 drivers/usb/serial/io_edgeport.c | 56 +--
 drivers/usb/serial/keyspan.c | 72 ++--
 drivers/usb/serial/mxuport.c | 10 ++
 drivers/usb/serial/quatech2.c|  1 +
 drivers/usb/serial/usb-serial.c  |  3 +-
 5 files changed, 90 insertions(+), 52 deletions(-)

-- 
2.7.3

--
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/8] USB: serial: keyspan: fix use-after-free in probe error path

2016-05-08 Thread Johan Hovold
The interface instat and indat URBs were submitted in attach, but never
unlinked in release before deallocating the corresponding transfer
buffers.

In the case of a late probe error (e.g. due to failed minor allocation),
disconnect would not have been called before release, causing the
buffers to be freed while the URBs are still in use. We'd also end up
with active URBs for an unbound interface.

Fixes: f9c99bb8b3a1 ("USB: usb-serial: replace shutdown with disconnect,
release")
Cc: stable  # v2.6.31

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/keyspan.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index b6bd8e4a6486..1cf05883f48c 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -2376,6 +2376,10 @@ static void keyspan_release(struct usb_serial *serial)
 
s_priv = usb_get_serial_data(serial);
 
+   /* Make sure to unlink the URBs submitted in attach. */
+   usb_kill_urb(s_priv->instat_urb);
+   usb_kill_urb(s_priv->indat_urb);
+
usb_free_urb(s_priv->instat_urb);
usb_free_urb(s_priv->indat_urb);
usb_free_urb(s_priv->glocont_urb);
-- 
2.7.3

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


[PATCH 5/8] USB: serial: keyspan: fix debug and error messages

2016-05-08 Thread Johan Hovold
The URB status is signed and should be printed using %d rather than %x.

Also print endpoint addresses consistently using %x rather than %d, and
merge a broken-up error message string.

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/keyspan.c | 42 +-
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 86d54932843d..1f9414bdd649 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -255,7 +255,7 @@ static int keyspan_write(struct tty_struct *tty,
return count;
}
 
-   dev_dbg(&port->dev, "%s - endpoint %d flip %d\n",
+   dev_dbg(&port->dev, "%s - endpoint %x flip %d\n",
__func__, usb_pipeendpoint(this_urb->pipe), flip);
 
if (this_urb->status == -EINPROGRESS) {
@@ -300,7 +300,7 @@ static void usa26_indat_callback(struct urb *urb)
endpoint = usb_pipeendpoint(urb->pipe);
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint 
%d.\n",
+   dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint 
%x\n",
__func__, status, endpoint);
return;
}
@@ -393,7 +393,8 @@ static void usa26_instat_callback(struct urb *urb)
serial =  urb->context;
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, 
status);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
+   __func__, status);
return;
}
if (urb->actual_length != 9) {
@@ -452,7 +453,7 @@ static void usa28_indat_callback(struct urb *urb)
 
do {
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on 
endpoint %d.\n",
+   dev_dbg(&urb->dev->dev, "%s - nonzero status %d on 
endpoint %x\n",
__func__, status, usb_pipeendpoint(urb->pipe));
return;
}
@@ -511,7 +512,8 @@ static void usa28_instat_callback(struct urb *urb)
serial =  urb->context;
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, 
status);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
+   __func__, status);
return;
}
 
@@ -591,7 +593,8 @@ static void usa49_instat_callback(struct urb *urb)
serial =  urb->context;
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, 
status);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
+   __func__, status);
return;
}
 
@@ -646,7 +649,7 @@ static void usa49_indat_callback(struct urb *urb)
endpoint = usb_pipeendpoint(urb->pipe);
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint 
%d.\n",
+   dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint 
%x\n",
__func__, status, endpoint);
return;
}
@@ -698,7 +701,8 @@ static void usa49wg_indat_callback(struct urb *urb)
serial = urb->context;
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, 
status);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
+   __func__, status);
return;
}
 
@@ -774,8 +778,8 @@ static void usa90_indat_callback(struct urb *urb)
endpoint = usb_pipeendpoint(urb->pipe);
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint 
%d.\n",
-   __func__, status, endpoint);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status %d on endpoint 
%x\n",
+   __func__, status, endpoint);
return;
}
 
@@ -847,7 +851,8 @@ static void usa90_instat_callback(struct urb *urb)
serial =  urb->context;
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, 
status);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
+   __func__, status);
return;
}
if (urb->actual_length < 14) {
@@ -912,7 +917,8 @@ static void usa67_instat_callback(struct urb *urb)
serial = urb->context;
 
if (status) {
-   dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, 
status);
+   dev_dbg(&urb->dev->dev, "%s - nonzero status: %d\n",
+   __func__, status);
return;
}
 
@@ -1215,8 +1221,8 @@ static struct usb_endpoint_descriptor const 
*find_ep(struct usb_seri

[PATCH 7/8] USB: serial: quatech2: fix use-after-free in probe error path

2016-05-08 Thread Johan Hovold
The interface read URB is submitted in attach, but was only unlinked by
the driver at disconnect.

In case of a late probe error (e.g. due to failed minor allocation),
disconnect is never called and we would end up with active URBs for an
unbound interface. This in turn could lead to deallocated memory being
dereferenced in the completion callback.

Fixes: f7a33e608d9a ("USB: serial: add quatech2 usb to serial driver")
Cc: stable  # v3.5: 40d04738491d
Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/quatech2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 2df8ad5ede89..85acb50a7ee2 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -141,6 +141,7 @@ static void qt2_release(struct usb_serial *serial)
 
serial_priv = usb_get_serial_data(serial);
 
+   usb_kill_urb(serial_priv->read_urb);
usb_free_urb(serial_priv->read_urb);
kfree(serial_priv->read_buffer);
kfree(serial_priv);
-- 
2.7.3

--
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/8] USB: serial: io_edgeport: fix memory leaks in attach error path

2016-05-08 Thread Johan Hovold
Private data, URBs and buffers allocated for Epic devices during
attach were never released on errors (e.g. missing endpoints).

Fixes: 6e8cf7751f9f ("USB: add EPIC support to the io_edgeport driver")
Cc: stable  # v2.6.21
Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/io_edgeport.c | 39 ---
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index f3007ecdd1b4..edd568bc0de5 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2849,14 +2849,16 @@ static int edge_startup(struct usb_serial *serial)
/* not set up yet, so do it now */
edge_serial->interrupt_read_urb =
usb_alloc_urb(0, GFP_KERNEL);
-   if (!edge_serial->interrupt_read_urb)
-   return -ENOMEM;
+   if (!edge_serial->interrupt_read_urb) {
+   response = -ENOMEM;
+   break;
+   }
 
edge_serial->interrupt_in_buffer =
kmalloc(buffer_size, GFP_KERNEL);
if (!edge_serial->interrupt_in_buffer) {
-   
usb_free_urb(edge_serial->interrupt_read_urb);
-   return -ENOMEM;
+   response = -ENOMEM;
+   break;
}
edge_serial->interrupt_in_endpoint =
endpoint->bEndpointAddress;
@@ -2884,14 +2886,16 @@ static int edge_startup(struct usb_serial *serial)
/* not set up yet, so do it now */
edge_serial->read_urb =
usb_alloc_urb(0, GFP_KERNEL);
-   if (!edge_serial->read_urb)
-   return -ENOMEM;
+   if (!edge_serial->read_urb) {
+   response = -ENOMEM;
+   break;
+   }
 
edge_serial->bulk_in_buffer =
kmalloc(buffer_size, GFP_KERNEL);
if (!edge_serial->bulk_in_buffer) {
-   usb_free_urb(edge_serial->read_urb);
-   return -ENOMEM;
+   response = -ENOMEM;
+   break;
}
edge_serial->bulk_in_endpoint =
endpoint->bEndpointAddress;
@@ -2917,9 +2921,22 @@ static int edge_startup(struct usb_serial *serial)
}
}
 
-   if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
-   dev_err(ddev, "Error - the proper endpoints were not 
found!\n");
-   return -ENODEV;
+   if (response || !interrupt_in_found || !bulk_in_found ||
+   !bulk_out_found) {
+   if (!response) {
+   dev_err(ddev, "expected endpoints not found\n");
+   response = -ENODEV;
+   }
+
+   usb_free_urb(edge_serial->interrupt_read_urb);
+   kfree(edge_serial->interrupt_in_buffer);
+
+   usb_free_urb(edge_serial->read_urb);
+   kfree(edge_serial->bulk_in_buffer);
+
+   kfree(edge_serial);
+
+   return response;
}
 
/* start interrupt read for this edgeport this interrupt will
-- 
2.7.3

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


[PATCH 4/8] USB: serial: keyspan: fix URB unlink

2016-05-08 Thread Johan Hovold
A driver must not rely on the URB status field to try to determine if an
URB is active.

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/keyspan.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 1cf05883f48c..86d54932843d 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1082,12 +1082,6 @@ static int keyspan_open(struct tty_struct *tty, struct 
usb_serial_port *port)
return 0;
 }
 
-static inline void stop_urb(struct urb *urb)
-{
-   if (urb && urb->status == -EINPROGRESS)
-   usb_kill_urb(urb);
-}
-
 static void keyspan_dtr_rts(struct usb_serial_port *port, int on)
 {
struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
@@ -1114,10 +1108,10 @@ static void keyspan_close(struct usb_serial_port *port)
p_priv->out_flip = 0;
p_priv->in_flip = 0;
 
-   stop_urb(p_priv->inack_urb);
+   usb_kill_urb(p_priv->inack_urb);
for (i = 0; i < 2; i++) {
-   stop_urb(p_priv->in_urbs[i]);
-   stop_urb(p_priv->out_urbs[i]);
+   usb_kill_urb(p_priv->in_urbs[i]);
+   usb_kill_urb(p_priv->out_urbs[i]);
}
 }
 
@@ -2365,9 +2359,9 @@ static void keyspan_disconnect(struct usb_serial *serial)
 
s_priv = usb_get_serial_data(serial);
 
-   stop_urb(s_priv->instat_urb);
-   stop_urb(s_priv->glocont_urb);
-   stop_urb(s_priv->indat_urb);
+   usb_kill_urb(s_priv->instat_urb);
+   usb_kill_urb(s_priv->glocont_urb);
+   usb_kill_urb(s_priv->indat_urb);
 }
 
 static void keyspan_release(struct usb_serial *serial)
@@ -2495,11 +2489,11 @@ static int keyspan_port_remove(struct usb_serial_port 
*port)
 
p_priv = usb_get_serial_port_data(port);
 
-   stop_urb(p_priv->inack_urb);
-   stop_urb(p_priv->outcont_urb);
+   usb_kill_urb(p_priv->inack_urb);
+   usb_kill_urb(p_priv->outcont_urb);
for (i = 0; i < 2; i++) {
-   stop_urb(p_priv->in_urbs[i]);
-   stop_urb(p_priv->out_urbs[i]);
+   usb_kill_urb(p_priv->in_urbs[i]);
+   usb_kill_urb(p_priv->out_urbs[i]);
}
 
usb_free_urb(p_priv->inack_urb);
-- 
2.7.3

--
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: intermittent USB disconnection, (sb_reset_and_verify_device Failed to disable LTM)

2016-05-08 Thread Greg KH
On Sun, May 08, 2016 at 02:54:29PM +0200, Daniel Duris wrote:
> Every few seconds or minutes intermittent eth0 disconnection occurs (via USB 
> adapter DA200 on Dell XPS computer):
> 
> [ 7745.623668] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
>.
> [ 7745.626674] usb 4-1.4: USB disconnect, device number 10
> [ 7746.656564] usb 4-1.4: new SuperSpeed USB device number 11 using xhci_hcd
> [ 7746.673199] usb 4-1.4: New USB device found, idVendor=0bda, idProduct=8153
> [ 7746.673212] usb 4-1.4: New USB device strings: Mfr=1, Product=2, 
> SerialNumber=6
> [ 7746.673220] usb 4-1.4: Product: USB 10/100/1000 LAN
> [ 7746.673225] usb 4-1.4: Manufacturer: Realtek
> [ 7746.673231] usb 4-1.4: SerialNumber: BA00
> [ 7746.756934] usb 4-1.4: reset SuperSpeed USB device number 11 using xhci_hcd
> [ 7746.810066] r8152 4-1.4:1.0 eth0: v1.08.3
> [ 7748.395902] r8152 4-1.4:1.0 enx00249b17d689: renamed from eth0
> [ 7748.425032] IPv6: ADDRCONF(NETDEV_UP): enx00249b17d689: link is not ready
> [ 7748.472777] IPv6: ADDRCONF(NETDEV_UP): enx00249b17d689: link is not ready
> [ 7751.025643] IPv6: ADDRCONF(NETDEV_CHANGE): enx00249b17d689: link becomes 
> ready
> 
> Connection is reestablished after short time, but this happens regularly and 
> without any obvious reason.
> 
> ~$ lsusb
> Bus 004 Device 021: ID 0bda:8153 Realtek Semiconductor Corp. 
> Bus 004 Device 002: ID 05e3:0617 Genesys Logic, Inc. 
> Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
> Bus 003 Device 004: ID 0835:2a01 Action Star Enterprise Co., Ltd 
> Bus 003 Device 006: ID 04ca:0022 Lite-On Technology Corp. 
> Bus 003 Device 005: ID 045e:0745 Microsoft Corp. Nano Transceiver v1.0 for 
> Bluetooth
> Bus 003 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
> Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
> Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
> Bus 001 Device 004: ID 0bda:5682 Realtek Semiconductor Corp. 
> Bus 001 Device 003: ID 04f3:20d0 Elan Microelectronics Corp. 
> Bus 001 Device 002: ID 0a5c:6412 Broadcom Corp. 
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> 
> 
> $ lspci
> 00:00.0 Host bridge: Intel Corporation Sky Lake Host Bridge/DRAM Registers 
> (rev 08)
> 00:02.0 VGA compatible controller: Intel Corporation Sky Lake Integrated 
> Graphics (rev 07)
> 00:04.0 Signal processing controller: Intel Corporation Skylake Processor 
> Thermal Subsystem (rev 08)
> 00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI 
> Controller (rev 21)
> 00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP 
> Thermal subsystem (rev 21)
> 00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP 
> Serial IO I2C Controller (rev 21)
> 00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP 
> Serial IO I2C Controller (rev 21)
> 00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME 
> HECI (rev 21)
> 00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller 
> [AHCI mode] (rev 21)
> 00:1c.0 PCI bridge: Intel Corporation Device 9d10 (rev f1)
> 00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port 
> (rev f1)
> 00:1c.5 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port 
> (rev f1)
> 00:1d.0 PCI bridge: Intel Corporation Device 9d18 (rev f1)
> 00:1f.0 ISA bridge: Intel Corporation Sunrise Point-LP LPC Controller (rev 21)
> 00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
> 00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
> 00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
> 01:00.0 PCI bridge: Intel Corporation Device 1576
> 02:00.0 PCI bridge: Intel Corporation Device 1576
> 02:01.0 PCI bridge: Intel Corporation Device 1576
> 02:02.0 PCI bridge: Intel Corporation Device 1576
> 39:00.0 USB controller: Intel Corporation Device 15b5
> 3a:00.0 Network controller: Broadcom Corporation BCM4350 802.11ac Wireless 
> Network Adapter (rev 08)
> 3b:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI 
> Express Card Reader (rev 01)
> 3c:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD 
> Controller (rev 01)
> 
> Occurence of events (randomly taken from the dmesg log, but there plenty more 
> occurences):
> [8633.975439] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
> [9341.314307] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
> [9389.611835] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
> [9619.560212] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM

What kernel version is this?

thanks,

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


Re: intermittent USB disconnection, (sb_reset_and_verify_device Failed to disable LTM)

2016-05-08 Thread Daniel Duris
Every few seconds or minutes intermittent eth0 disconnection occurs (via USB 
adapter DA200 on Dell XPS computer):

[ 7745.623668] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
   .
[ 7745.626674] usb 4-1.4: USB disconnect, device number 10
[ 7746.656564] usb 4-1.4: new SuperSpeed USB device number 11 using xhci_hcd
[ 7746.673199] usb 4-1.4: New USB device found, idVendor=0bda, idProduct=8153
[ 7746.673212] usb 4-1.4: New USB device strings: Mfr=1, Product=2, 
SerialNumber=6
[ 7746.673220] usb 4-1.4: Product: USB 10/100/1000 LAN
[ 7746.673225] usb 4-1.4: Manufacturer: Realtek
[ 7746.673231] usb 4-1.4: SerialNumber: BA00
[ 7746.756934] usb 4-1.4: reset SuperSpeed USB device number 11 using xhci_hcd
[ 7746.810066] r8152 4-1.4:1.0 eth0: v1.08.3
[ 7748.395902] r8152 4-1.4:1.0 enx00249b17d689: renamed from eth0
[ 7748.425032] IPv6: ADDRCONF(NETDEV_UP): enx00249b17d689: link is not ready
[ 7748.472777] IPv6: ADDRCONF(NETDEV_UP): enx00249b17d689: link is not ready
[ 7751.025643] IPv6: ADDRCONF(NETDEV_CHANGE): enx00249b17d689: link becomes 
ready

Connection is reestablished after short time, but this happens regularly and 
without any obvious reason.

~$ lsusb
Bus 004 Device 021: ID 0bda:8153 Realtek Semiconductor Corp. 
Bus 004 Device 002: ID 05e3:0617 Genesys Logic, Inc. 
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0835:2a01 Action Star Enterprise Co., Ltd 
Bus 003 Device 006: ID 04ca:0022 Lite-On Technology Corp. 
Bus 003 Device 005: ID 045e:0745 Microsoft Corp. Nano Transceiver v1.0 for 
Bluetooth
Bus 003 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0bda:5682 Realtek Semiconductor Corp. 
Bus 001 Device 003: ID 04f3:20d0 Elan Microelectronics Corp. 
Bus 001 Device 002: ID 0a5c:6412 Broadcom Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


$ lspci
00:00.0 Host bridge: Intel Corporation Sky Lake Host Bridge/DRAM Registers (rev 
08)
00:02.0 VGA compatible controller: Intel Corporation Sky Lake Integrated 
Graphics (rev 07)
00:04.0 Signal processing controller: Intel Corporation Skylake Processor 
Thermal Subsystem (rev 08)
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI 
Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP 
Thermal subsystem (rev 21)
00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial 
IO I2C Controller (rev 21)
00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP Serial 
IO I2C Controller (rev 21)
00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI 
(rev 21)
00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller 
[AHCI mode] (rev 21)
00:1c.0 PCI bridge: Intel Corporation Device 9d10 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port 
(rev f1)
00:1c.5 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port 
(rev f1)
00:1d.0 PCI bridge: Intel Corporation Device 9d18 (rev f1)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-LP LPC Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
01:00.0 PCI bridge: Intel Corporation Device 1576
02:00.0 PCI bridge: Intel Corporation Device 1576
02:01.0 PCI bridge: Intel Corporation Device 1576
02:02.0 PCI bridge: Intel Corporation Device 1576
39:00.0 USB controller: Intel Corporation Device 15b5
3a:00.0 Network controller: Broadcom Corporation BCM4350 802.11ac Wireless 
Network Adapter (rev 08)
3b:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI 
Express Card Reader (rev 01)
3c:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD 
Controller (rev 01)

Occurence of events (randomly taken from the dmesg log, but there plenty more 
occurences):
[8633.975439] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
[9341.314307] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
[9389.611835] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM
[9619.560212] usb 4-1.4: usb_reset_and_verify_device Failed to disable LTM



On 08.05.2016 14:49, Greg KH wrote:
> On Sun, May 08, 2016 at 02:46:12PM +0200, Daniel Duris wrote:
>> https://bugzilla.kernel.org/show_bug.cgi?id=117811
> Please provide the details here.
>
> 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: intermittent USB disconnection, (sb_reset_and_verify_device Failed to disable LTM)

2016-05-08 Thread Greg KH
On Sun, May 08, 2016 at 02:46:12PM +0200, Daniel Duris wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=117811

Please provide the details here.

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


intermittent USB disconnection, (sb_reset_and_verify_device Failed to disable LTM)

2016-05-08 Thread Daniel Duris
https://bugzilla.kernel.org/show_bug.cgi?id=117811

--- Comment #1 from Greg Kroah-Hartman  ---
On Sun, May 08, 2016 at 11:25:34AM +, bugzilla-dae...@bugzilla.kernel.org
wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=117811
>
> Bug ID: 117811
>Summary: intermittent USB disconnection
> (sb_reset_and_verify_device Failed to disable LTM)
>Product: Drivers
>Version: 2.5
> Kernel Version: 4.6.0-040600rc6

Please send to the linux-usb@vger.kernel.org mailing list.

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


Re: usb: dwc2: regression on MyBook Live Duo / Canyonlands since 4.3.0-rc4

2016-05-08 Thread Christian Lamparter
On Sunday, May 08, 2016 08:40:55 PM Benjamin Herrenschmidt wrote:
> On Sun, 2016-05-08 at 00:54 +0200, Christian Lamparter via Linuxppc-dev 
> wrote:
> > I've been looking in getting the MyBook Live Duo's USB OTG port
> > to function. The SoC is a APM82181. Which has a PowerPC 464 core
> > and related to the supported canyonlands architecture in
> > arch/powerpc/.
> > 
> > Currently in -next the dwc2 module doesn't load: 
> 
> Smells like the APM implementation is little endian. You might need to
> use a flag to indicate what endian to use instead and set it
> appropriately based on some DT properties.
I tried. As per common-properties[0], I added little-endian; but it has no
effect. I looked in dwc2_driver_probe and found no way of specifying the
endian of the device. It all comes down to the dwc2_readl & dwc2_writel
accessors. These - sadly - have been hardwired to use __raw_readl and
__raw_writel. So, it's always "native-endian". While common-properties
says little-endian should be preferred.

> > dwc2 4bff8.usbotg: dwc2_core_reset() HANG! AHB Idle GRSTCTL=80
> > dwc2 4bff8.usbotg: Bad value for GSNPSID: 0x0a29544f
> > 
> > Looking at the Bad GSNPSID value: 0x0a29544f. It is obvious that
> > this is an endian problem. git finds this patch:
> > 
> > commit 95c8bc3609440af5e4a4f760b8680caea7424396
> > Author: Antti Seppälä 
> > Date:   Thu Aug 20 21:41:07 2015 +0300
> > 
> > usb: dwc2: Use platform endianness when accessing registers
> > 
> > This patch is necessary to access dwc2 registers correctly on
> > big-endian
> > systems such as the mips based SoCs made by Lantiq. Then dwc2 can
> > be
> > used to replace ifx-hcd driver for Lantiq platforms found e.g. in
> > OpenWrt.
> > 
> > The patch was autogenerated with the following commands:
> > $EDITOR core.h
> > sed -i "s/\/dwc2_readl/g" *.c hcd.h hw.h
> > sed -i "s/\/dwc2_writel/g" *.c hcd.h hw.h
> > 
> > Some files were then hand-edited to fix checkpatch.pl warnings
> > about
> > too long lines.
> > 
> > which unfortunately, broke the USB-OTG port on the MyBook Live Duo.
> > Reverting to the readl / writel:
> > 
> > --- 
> > diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> > index 3c58d63..c021c1f 100644
> > --- a/drivers/usb/dwc2/core.h
> > +++ b/drivers/usb/dwc2/core.h
> > @@ -66,7 +66,7 @@
> >  
> >  static inline u32 dwc2_readl(const void __iomem *addr)
> >  {
> > -   u32 value = __raw_readl(addr);
> > +   u32 value = readl(addr);
> >  
> > /* In order to preserve endianness __raw_* operation is
> > used. Therefore
> >  * a barrier is needed to ensure IO access is not re-ordered 
> > across
> > @@ -78,7 +78,7 @@ static inline u32 dwc2_readl(const void __iomem
> > *addr)
> >  
> >  static inline void dwc2_writel(u32 value, void __iomem *addr)
> >  {
> > -   __raw_writel(value, addr);
> > +   writel(value, addr);
> >  
> > /*
> >  * In order to preserve endianness __raw_* operation is
> > used. Therefore
> > 
> > ---
> > 
> > restores the dwc-otg port to full working order:
> > dwc2 4bff8.usbotg: Specified GNPTXFDEP=1024 > 256
> > dwc2 4bff8.usbotg: EPs: 3, shared fifos, 2042 entries in SPRAM
> > dwc2 4bff8.usbotg: DWC OTG Controller
> > dwc2 4bff8.usbotg: new USB bus registered, assigned bus number 1
> > dwc2 4bff8.usbotg: irq 33, io mem 0x
> > hub 1-0:1.0: USB hub found
> > hub 1-0:1.0: 1 port detected
> > root@mbl:~# usb 1-1: new high-speed USB device number 2 using dwc2
> > 
> > So, what to do?
 ^^^

Regards,
Christian

[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: usb: dwc2: regression on MyBook Live Duo / Canyonlands since 4.3.0-rc4

2016-05-08 Thread Benjamin Herrenschmidt
On Sun, 2016-05-08 at 00:54 +0200, Christian Lamparter via Linuxppc-dev 
wrote:
> Hello,
> 
> I've been looking in getting the MyBook Live Duo's USB OTG port
> to function. The SoC is a APM82181. Which has a PowerPC 464 core
> and related to the supported canyonlands architecture in
> arch/powerpc/.
> 
> Currently in -next the dwc2 module doesn't load: 

Smells like the APM implementation is little endian. You might need to
use a flag to indicate what endian to use instead and set it
appropriately based on some DT properties.

> dwc2 4bff8.usbotg: dwc2_core_reset() HANG! AHB Idle GRSTCTL=80
> dwc2 4bff8.usbotg: Bad value for GSNPSID: 0x0a29544f
> 
> Looking at the Bad GSNPSID value: 0x0a29544f. It is obvious that
> this is an endian problem. git finds this patch:
> 
> commit 95c8bc3609440af5e4a4f760b8680caea7424396
> Author: Antti Seppälä 
> Date:   Thu Aug 20 21:41:07 2015 +0300
> 
> usb: dwc2: Use platform endianness when accessing registers
> 
> This patch is necessary to access dwc2 registers correctly on
> big-endian
> systems such as the mips based SoCs made by Lantiq. Then dwc2 can
> be
> used to replace ifx-hcd driver for Lantiq platforms found e.g. in
> OpenWrt.
> 
> The patch was autogenerated with the following commands:
> $EDITOR core.h
> sed -i "s/\/dwc2_readl/g" *.c hcd.h hw.h
> sed -i "s/\/dwc2_writel/g" *.c hcd.h hw.h
> 
> Some files were then hand-edited to fix checkpatch.pl warnings
> about
> too long lines.
> 
> which unfortunately, broke the USB-OTG port on the MyBook Live Duo.
> Reverting to the readl / writel:
> 
> --- 
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index 3c58d63..c021c1f 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -66,7 +66,7 @@
>  
>  static inline u32 dwc2_readl(const void __iomem *addr)
>  {
> - u32 value = __raw_readl(addr);
> + u32 value = readl(addr);
>  
>   /* In order to preserve endianness __raw_* operation is
> used. Therefore
>    * a barrier is needed to ensure IO access is not re-ordered 
> across
> @@ -78,7 +78,7 @@ static inline u32 dwc2_readl(const void __iomem
> *addr)
>  
>  static inline void dwc2_writel(u32 value, void __iomem *addr)
>  {
> - __raw_writel(value, addr);
> + writel(value, addr);
>  
>   /*
>    * In order to preserve endianness __raw_* operation is
> used. Therefore
> 
> ---
> 
> restores the dwc-otg port to full working order:
> dwc2 4bff8.usbotg: Specified GNPTXFDEP=1024 > 256
> dwc2 4bff8.usbotg: EPs: 3, shared fifos, 2042 entries in SPRAM
> dwc2 4bff8.usbotg: DWC OTG Controller
> dwc2 4bff8.usbotg: new USB bus registered, assigned bus number 1
> dwc2 4bff8.usbotg: irq 33, io mem 0x
> hub 1-0:1.0: USB hub found
> hub 1-0:1.0: 1 port detected
> root@mbl:~# usb 1-1: new high-speed USB device number 2 using dwc2
> 
> So, what to do?
> 
> Regards,
> Christian
> ___
> Linuxppc-dev mailing list
> linuxppc-...@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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


Re: [PATCH 1/2] usb-audio: correct speed checking

2016-05-08 Thread Takashi Iwai
On Wed, 04 May 2016 14:18:39 +0200,
Oliver Neukum wrote:
> 
> Allow handling SS+ USB devices correctly.
> 
> Signed-off-by: Oliver Neukum 

Thanks, applied both patches now.


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