Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp60813yba; Mon, 1 Apr 2019 01:37:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjdHQAr1IIMLNSSB+7bN4ExseMbjj5TPYkjZkbbYge/gvOURohrXrgxuByu0/xKs5PhpV+ X-Received: by 2002:a17:902:e684:: with SMTP id cn4mr39374412plb.71.1554107843267; Mon, 01 Apr 2019 01:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554107843; cv=none; d=google.com; s=arc-20160816; b=UaGrVj1eRpRcXmYCYyLWpTODVNFNXC6dPZoRZgpjUvMv4PWM2ZE+sQgaUWALiF6G+C VdOHuxrOhYKXc8AOG//LH3bUFsnkJR4ateS9/3uyv8occUv2p3u+RaeewoIsYEp+grp/ 1snshZbwNwu6UbkYExrMjFDKI6InoGvOpWcp9XpmyeCJWFxYfjc5UI1YJ4Ch5AWBu25a 1xn9w516P9GMHKCYZR23ZrbsAHw6ZfzgOiYuUv35Ccq1Gf0R6xjuGZM33oTlAuATbyl+ 9BXGHuczrjfZmA6bTrPI2awddDTgDlravnNz/EX9Azds3WNp67eHs37+kYEdhhTv+Ze/ o20Q== 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=xVE+sziiAS6qXB1ef1RbZaVcURHOrsCFUl0T+cq2njE=; b=kzAdfb7VTLGoFuDeF68re9vEaZ0hzvsz+AebSxNSDR5Rfpd8EU1YgdFSwaPi8XRsHs bYFshUxv0TBTw4/hd5prs1JBBxB1Q1hKVKE1iOAfEx9a6J6wF3p2NYOrtYT4UCcdRfQJ q+njru/RWl0chvPM496KKvsLK/jb961oYen7fgLEGrW3ZIt1d4CQ2773l2CDBO5gKi5x ffTN45KBYePHMcXBdPAGENFptDUaaMSDp+09QnhUi4t2lGg5+wbwUc+4FsZbLvDd9Hze IS4r2oXm+Dsgc4ffhYSVRd1HxHOzxQyQSLK/ntY1xi7Lu+Hrtoz3Q5vBp2RZa3FSGZya LbLQ== 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 w25si8473391pgl.346.2019.04.01.01.37.07; Mon, 01 Apr 2019 01:37:23 -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 S1731974AbfDAIfB (ORCPT + 99 others); Mon, 1 Apr 2019 04:35:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:53302 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725867AbfDAIfB (ORCPT ); Mon, 1 Apr 2019 04:35:01 -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 E7894AF1E; Mon, 1 Apr 2019 08:34:59 +0000 (UTC) Message-ID: <1554107689.6310.17.camel@suse.com> Subject: Re: [RESEND PATCH V3 1/3] USB: serial: f81232: clear overrun flag From: Oliver Neukum To: "Ji-Ze Hong (Peter Hong)" , peter_hong@fintek.com.tw, johan@kernel.org, gregkh@linuxfoundation.org Cc: "Ji-Ze Hong (Peter Hong)" , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Date: Mon, 01 Apr 2019 10:34:49 +0200 In-Reply-To: <1554098453-31278-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1554098453-31278-1-git-send-email-hpeter+linux_kernel@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 Mo, 2019-04-01 at 14:00 +0800, Ji-Ze Hong (Peter Hong) wrote: Hi, I am afraid there is a race condiion in this code. > @@ -315,6 +318,7 @@ static void f81232_process_read_urb(struct urb *urb) > > if (lsr & UART_LSR_OE) { > port->icount.overrun++; > + schedule_work(&priv->lsr_work); Unconditionally scheduled > tty_insert_flip_char(&port->port, 0, > TTY_OVERRUN); > } [..] > +static int f81232_suspend(struct usb_serial *serial, pm_message_t message) > +{ > + struct f81232_private *port_priv; > + > + port_priv = usb_get_serial_port_data(serial->port[0]); > + flush_work(&port_priv->lsr_work); > + > + return 0; > +} > + > static struct usb_serial_driver f81232_device = { > .driver = { > .owner = THIS_MODULE, > @@ -655,6 +688,7 @@ static struct usb_serial_driver f81232_device = { > .read_int_callback = f81232_read_int_callback, > .port_probe = f81232_port_probe, > .port_remove = f81232_port_remove, > + .suspend = f81232_suspend, Please have a look at: int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) { struct usb_serial *serial = usb_get_intfdata(intf); int i, r = 0; serial->suspending = 1; /* * serial->type->suspend() MUST return 0 in system sleep context, * otherwise, the resume callback has to recover device from * previous suspend failure. */ if (serial->type->suspend) { r = serial->type->suspend(serial, message); if (r < 0) { serial->suspending = 0; goto err_out; } } for (i = 0; i < serial->num_ports; ++i) usb_serial_port_poison_urbs(serial->port[i]); err_out: return r; } EXPORT_SYMBOL(usb_serial_suspend); As you can see, the suspend method is called first and then the URBs are poisoned. That means that after you have flushed the work, it may be submitted again. The fix would be to test the 'suspending' flag before you schedule work (and recheck the need to schedule it during resume) Regards Oliver