From c9c4558f7874676e31ea7a74caafcf09ebbc03ed Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 10 Feb 2011 15:33:10 +0100 Subject: usb_wwan: fix error in marking device busy This fixes two errors: - the device is busy if a message was recieved even if resubmission fails - the device is not busy if resubmission fails due to -EPERM Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb_wwan.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers/usb/serial/usb_wwan.c') diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index b004b2a485c..7bd06854f87 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -305,11 +305,16 @@ static void usb_wwan_indat_callback(struct urb *urb) /* Resubmit urb so we continue receiving */ if (status != -ESHUTDOWN) { err = usb_submit_urb(urb, GFP_ATOMIC); - if (err && err != -EPERM) - printk(KERN_ERR "%s: resubmit read urb failed. " - "(%d)", __func__, err); - else + if (err) { + if (err != -EPERM) { + printk(KERN_ERR "%s: resubmit read urb failed. " + "(%d)", __func__, err); + /* busy also in error unless we are killed */ + usb_mark_last_busy(port->serial->dev); + } + } else { usb_mark_last_busy(port->serial->dev); + } } } -- cgit v1.2.3 From 3d06bf152abcc3895a0f3afa21d762d84c9aecbc Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 10 Feb 2011 15:33:17 +0100 Subject: usb_wwan: fix runtime PM in error case An error in the write code path would permanently disable runtime PM in this driver Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb_wwan.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/serial/usb_wwan.c') diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 7bd06854f87..07cdc6cd106 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -261,6 +261,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, intfdata->in_flight--; spin_unlock_irqrestore(&intfdata->susp_lock, flags); + usb_autopm_put_interface_async(port->serial->interface); continue; } } -- cgit v1.2.3 From 433508ae30f13c0bf6905e576c42899a8535f0bb Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 10 Feb 2011 15:33:23 +0100 Subject: usb_wwan: data consistency in error case As soon as the first error happens, the write must be stopped, lest we send mutilated messages. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb_wwan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/serial/usb_wwan.c') diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 07cdc6cd106..84fe1b6ba11 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -262,7 +262,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, spin_unlock_irqrestore(&intfdata->susp_lock, flags); usb_autopm_put_interface_async(port->serial->interface); - continue; + break; } } -- cgit v1.2.3 From 16871dcac74c63227aa92e0012f3004a648c2062 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 10 Feb 2011 15:33:29 +0100 Subject: usb_wwan: error case of resume If an error happens during resumption. The remaining data has to be cleanly discarded and the pm counters have to be adjusted. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb_wwan.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'drivers/usb/serial/usb_wwan.c') diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 84fe1b6ba11..fe5e48eb969 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -664,6 +664,18 @@ int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message) } EXPORT_SYMBOL(usb_wwan_suspend); +static void unbusy_queued_urb(struct urb *urb, struct usb_wwan_port_private *portdata) +{ + int i; + + for (i = 0; i < N_OUT_URB; i++) { + if (urb == portdata->out_urbs[i]) { + clear_bit(i, &portdata->out_busy); + break; + } + } +} + static void play_delayed(struct usb_serial_port *port) { struct usb_wwan_intf_private *data; @@ -675,8 +687,17 @@ static void play_delayed(struct usb_serial_port *port) data = port->serial->private; while ((urb = usb_get_from_anchor(&portdata->delayed))) { err = usb_submit_urb(urb, GFP_ATOMIC); - if (!err) + if (!err) { data->in_flight++; + } else { + /* we have to throw away the rest */ + do { + unbusy_queued_urb(urb, portdata); + //extremely dirty + atomic_dec(&port->serial->interface->dev.power.usage_count); + } while ((urb = usb_get_from_anchor(&portdata->delayed))); + break; + } } } -- cgit v1.2.3 From 9a91aedca2f4ef24344b7cd8f56570e620fbe4d5 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Thu, 10 Feb 2011 15:33:37 +0100 Subject: usb_wwan: fix error case in close() The device never needs to be resumed in close(). But the counters must be balanced. As resumption can fail, but the counters must be balanced, use the _no_resume() version which cannot fail. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb_wwan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb/serial/usb_wwan.c') diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index fe5e48eb969..817e6ff8de8 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -424,6 +424,7 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port) spin_lock_irq(&intfdata->susp_lock); portdata->opened = 1; spin_unlock_irq(&intfdata->susp_lock); + /* this balances a get in the generic USB serial code */ usb_autopm_put_interface(serial->interface); return 0; @@ -450,7 +451,8 @@ void usb_wwan_close(struct usb_serial_port *port) usb_kill_urb(portdata->in_urbs[i]); for (i = 0; i < N_OUT_URB; i++) usb_kill_urb(portdata->out_urbs[i]); - usb_autopm_get_interface(serial->interface); + /* balancing - important as an error cannot be handled*/ + usb_autopm_get_interface_no_resume(serial->interface); serial->interface->needs_remote_wakeup = 0; } } -- cgit v1.2.3