* [PATCH] cdc-acm: Kill ACM_READY() macro completely
[not found] <13234763473078@kroah.org>
@ 2011-12-10 0:51 ` Havard Skinnemoen
2011-12-10 3:32 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Havard Skinnemoen @ 2011-12-10 0:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, davej, jslaby, linux-kernel, Havard Skinnemoen
The ACM_READY() macro doesn't seem to do anything useful, and it may
prevent tty_wait_until_sent() from working properly when called from
close.
Previously, acm_tty_chars_in_buffer() returned 0 whenever
acm->port.count was 0. This means close() could return before all the
data has actually been written.
Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
---
Hi Greg,
Thanks for picking up my patch. Unfortunately, it's not completely bug-free.
This fixes an issue I found while testing the patch: After writing something to
/dev/ttyACM0, the process would hang for a fairly long time (10-15 seconds)
when closing the device. This is because port.count drops to 0 before
tty_wait_until_sent_from_close() is called, which causes ACM_READY() to return
false, any outstanding writes never get reaped because the workqueue doesn't
get scheduled, tty_wait_until_sent never sees any progress and eventually times
out.
Please feel free to fold this into "cdc-acm: Fix potential deadlock (lockdep
warning)", or let me know if you want me to send you a v2 of that patch
instead.
drivers/usb/class/cdc-acm.c | 10 +---------
1 files changed, 1 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3027ada..d9d9340 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -60,8 +60,6 @@ static struct acm *acm_table[ACM_TTY_MINORS];
static DEFINE_MUTEX(acm_table_lock);
-#define ACM_READY(acm) (acm && acm->dev && acm->port.count)
-
/*
* acm_table accessors
*/
@@ -319,9 +317,6 @@ static void acm_ctrl_irq(struct urb *urb)
goto exit;
}
- if (!ACM_READY(acm))
- goto exit;
-
usb_mark_last_busy(acm->dev);
data = (unsigned char *)(dr + 1);
@@ -481,8 +476,7 @@ static void acm_write_bulk(struct urb *urb)
spin_lock_irqsave(&acm->write_lock, flags);
acm_write_done(acm, wb);
spin_unlock_irqrestore(&acm->write_lock, flags);
- if (ACM_READY(acm))
- schedule_work(&acm->work);
+ schedule_work(&acm->work);
}
static void acm_softint(struct work_struct *work)
@@ -492,8 +486,6 @@ static void acm_softint(struct work_struct *work)
dev_vdbg(&acm->data->dev, "%s\n", __func__);
- if (!ACM_READY(acm))
- return;
tty = tty_port_tty_get(&acm->port);
if (!tty)
return;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cdc-acm: Kill ACM_READY() macro completely
2011-12-10 0:51 ` [PATCH] cdc-acm: Kill ACM_READY() macro completely Havard Skinnemoen
@ 2011-12-10 3:32 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2011-12-10 3:32 UTC (permalink / raw)
To: Havard Skinnemoen; +Cc: alan, davej, jslaby, linux-kernel
On Fri, Dec 09, 2011 at 04:51:54PM -0800, Havard Skinnemoen wrote:
> The ACM_READY() macro doesn't seem to do anything useful, and it may
> prevent tty_wait_until_sent() from working properly when called from
> close.
>
> Previously, acm_tty_chars_in_buffer() returned 0 whenever
> acm->port.count was 0. This means close() could return before all the
> data has actually been written.
>
> Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
> ---
> Hi Greg,
>
> Thanks for picking up my patch. Unfortunately, it's not completely bug-free.
>
> This fixes an issue I found while testing the patch: After writing something to
> /dev/ttyACM0, the process would hang for a fairly long time (10-15 seconds)
> when closing the device. This is because port.count drops to 0 before
> tty_wait_until_sent_from_close() is called, which causes ACM_READY() to return
> false, any outstanding writes never get reaped because the workqueue doesn't
> get scheduled, tty_wait_until_sent never sees any progress and eventually times
> out.
>
> Please feel free to fold this into "cdc-acm: Fix potential deadlock (lockdep
> warning)", or let me know if you want me to send you a v2 of that patch
> instead.
I'll just apply this one, as I can't merge it together as I already
applied it.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-10 3:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <13234763473078@kroah.org>
2011-12-10 0:51 ` [PATCH] cdc-acm: Kill ACM_READY() macro completely Havard Skinnemoen
2011-12-10 3:32 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.