From: Oliver Neukum <oneukum@suse.com>
To: Romain Izard <romain.izard.pro@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: usb: cdc-acm: fix race during wakeup blocking TX traffic
Date: Tue, 26 Mar 2019 11:00:41 +0100 [thread overview]
Message-ID: <1553594441.2729.7.camel@suse.com> (raw)
On Fr, 2019-03-22 at 16:53 +0100, Romain Izard wrote:
> When the kernel is compiled with preemption enabled, the URB completion
> handler can run in parallel with the work responsible for waking up the
> tty layer. If the URB handler sets the EVENT_TTY_WAKEUP bit during the
> call to tty_port_tty_wakeup() to signal that there is room for additional
> input, it will be cleared at the end of this call. As a result, TX traffic
> on the upper layer will be blocked.
Good catch.
> This can be seen with a kernel configured with CONFIG_PREEMPT, and a fast
> modem connected with PPP running over a USB CDC-ACM port.
>
> Use test_and_clear_bit() instead, which ensures that each wakeup requested
> by the URB completion code will trigger a call to tty_port_tty_wakeup().
>
> Fixes: 1aba579f3cf5 cdc-acm: handle read pipe errors
> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Oliver Neukum <oneukum@suse.com>
> ---
> drivers/usb/class/cdc-acm.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> index 739f8960811a..ec666eb4b7b4 100644
> --- a/drivers/usb/class/cdc-acm.c
> +++ b/drivers/usb/class/cdc-acm.c
> @@ -558,10 +558,8 @@ static void acm_softint(struct work_struct *work)
> clear_bit(EVENT_RX_STALL, &acm->flags);
> }
>
> - if (test_bit(EVENT_TTY_WAKEUP, &acm->flags)) {
> + if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))
> tty_port_tty_wakeup(&acm->port);
> - clear_bit(EVENT_TTY_WAKEUP, &acm->flags);
> - }
> }
>
> /*
next reply other threads:[~2019-03-26 10:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-26 10:00 Oliver Neukum [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-03-22 15:53 usb: cdc-acm: fix race during wakeup blocking TX traffic Romain Izard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1553594441.2729.7.camel@suse.com \
--to=oneukum@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=romain.izard.pro@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).