Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4110390img; Tue, 26 Mar 2019 03:14:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmK2eCQU0S56fWbtJD31L+cF4v9WTShXPII5xrHm2JjMn+H7rwDg12BAlcF1Nn12+yFtgl X-Received: by 2002:a63:78ce:: with SMTP id t197mr14955545pgc.314.1553595293998; Tue, 26 Mar 2019 03:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553595293; cv=none; d=google.com; s=arc-20160816; b=xBK0PrCwTx5I+CbZBkBGGzqTLyMfgp33wCKtyHXyhhdN46JcglnjCy2dbvEhGPwAYc x3z+GLFrt5HUkn0dSdmZEYb5noq6oj9LEa/ur7eDieYSozr27BywHEzxW3bX2UBHnO6G C5lJNQ0ZBwC8ukxRR6TKBsXOw4613qs99hSL86imLoAo1mQcab+44NdPgyjZsaA1uofM 7SgUnIS0xPhC54E+1jmi8X2fIa1fG9SFdcCUsoeOjqnew5U5/kHeuYGggoRODfoYu0wk BuotATMFi8NvZBlQbGIyiLWCRYfnNVAC+rhGPPuZsGujCpvKxR7g0rl5e5kpubgZZZKj zUTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=rOoAO3A2eaYKCuTKRRYrxgQiSuwUKG5bweszIMunU3U=; b=sQecJcyjjgs3L4oSvSjRqj9qnn1Zntki4o7R2DI24em9DiE2Ojy8lbVrvXTd2dEm1p 9xA6/Zk+g950bpqhE/OTwGgwEwSbfv+pWoAAAXeRzxomMIM1n8S+gO8jU8jORFd1C7dt 2vq+znRWa9f1jQXe9m634ZPIK+cBuYrDPYcU0INsF33y9vfYPjaNeXVRl8KdxIOxhpWI 9SJHSCwVQWZ1SHvI5l3Dw7gBQ97UTvHmb96NqHHT0WmuwzRYqcOuQs52SeVOm3kzDTNk F2R3zfN6VSflqe9Hh25os+0uvav5yFSobjZTgmH7czVjMufddvHfZmgct2S3WKJw/l+P iDYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j71si16022885pfc.280.2019.03.26.03.14.39; Tue, 26 Mar 2019 03:14:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731267AbfCZKMb (ORCPT + 99 others); Tue, 26 Mar 2019 06:12:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:50308 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726258AbfCZKMb (ORCPT ); Tue, 26 Mar 2019 06:12:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0A2CDAE3D; Tue, 26 Mar 2019 10:12:30 +0000 (UTC) Message-ID: <1553594441.2729.7.camel@suse.com> Subject: Re: [PATCH] usb: cdc-acm: fix race during wakeup blocking TX traffic From: Oliver Neukum To: Romain Izard , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Date: Tue, 26 Mar 2019 11:00:41 +0100 In-Reply-To: <20190322155302.28414-1-romain.izard.pro@gmail.com> References: <20190322155302.28414-1-romain.izard.pro@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Oliver Neukum > --- > 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); > - } > } > > /*