Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp77565yba; Mon, 1 Apr 2019 02:04:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF6W08+uwVN1Gpokw4enPzqH0LDCqptykAXQ0eaLZUrdPy2FAMxaD2dSpabQ/ETPb+uEYr X-Received: by 2002:a63:9dc4:: with SMTP id i187mr51381986pgd.259.1554109441728; Mon, 01 Apr 2019 02:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554109441; cv=none; d=google.com; s=arc-20160816; b=kKpBILCHvT9gRSEMlDlpqJkF4kpdxRwoTOAAsFDJmpb9k8GK6F9oKIsPncQ1b7prKt KIjXwstsWuPRwVdOO5Swk9aFPJQ/V1nmfQzpKo3Z7B6sy7wbRis3q3FrfEBzjBlcAdIj ja8vWOr5PHBBybOWD39raDK6QxFjcjXidHsjswZU2CB1b4dGUsY5hg3gJad0sAA/CeML fzOY1WMArTJ8mTBbd1HUOA7HeJBqZl2rufg7Ld+Ya+Hohtgw2mJF+SAg0voZHS52ZCBx 9JZ+OjU2tXZt6qgiuVIiEwMmZLZdX8/mXN1Bzl3TghUmgYcNaUHYDKleXl/88P3GnjG5 oJOw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=zRrI2gVcSPBOrRDl3Z3EFWOVjgSWQsnIxpjQ7VgJeec=; b=DIJLlTe1Y4EoGQlN1HgWeBy83bGRnEmTVtmij7CGNVxNxjb3qDl3KgFl7Eo5lH9S4b 2k380KxO6oryGaja9X/LpwppOmZPwDvmgfPa5jz7uRThfbNzh0II8cRXr5OCpGfkIcW7 o1qTevjsdGaPg7wDp8/lxXcao+B8NvdXszhfgdlSKK/x99Pi1pgtl15F3WAC9V+UvOen TrmcFRyXcTdl9LJfqvh7odwwjR9TeEmEx32/AnNQfFjOVsmpkkeDEd93/NNP/1KNHwCD HVXhuCK+sOkPjkmbON/m++MnfJbfzFH6D75zMQ4Hn1QmlK1p0Vokm9hZo/Dt486IaPDv kGnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jhqpuxI2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si7948079pgs.568.2019.04.01.02.03.45; Mon, 01 Apr 2019 02:04:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jhqpuxI2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728718AbfDAJBf (ORCPT + 99 others); Mon, 1 Apr 2019 05:01:35 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42948 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbfDAJBd (ORCPT ); Mon, 1 Apr 2019 05:01:33 -0400 Received: by mail-pg1-f196.google.com with SMTP id p6so4414715pgh.9; Mon, 01 Apr 2019 02:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zRrI2gVcSPBOrRDl3Z3EFWOVjgSWQsnIxpjQ7VgJeec=; b=jhqpuxI2W57TdZ98GoyXXh67S0yptz5ctASjZ/w9uNesNn1PUIscT5i4wClAi0MMrx W2qrtWF8K7u0miclnNJjYFns4YAHSaeyv+dKP2t3CMcLykRZMyD7uB86FKV7dD5iQwJF IZvmDdND7Pwgj2kKgi6jPxY8N4FCI9irQnvG8s3++DviXBdxHPP3NrOBRw+HaewJZHvH DILcUwMEN8BbL8oHcYHEhFfDCygacbzR+9NDNVSUhNuwn89AkEWZNb1mzyRPWrxMgb1z mJh+oAjDLn3MlUolxL1FEurQ6z/kQn0kyMpOzF6sMV3eiAcLjyyffx4S9dglxXylJmOe 2hog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zRrI2gVcSPBOrRDl3Z3EFWOVjgSWQsnIxpjQ7VgJeec=; b=gWe+r9TqddKuPAvpdcTuoM9VUesuv6qN3hR5f7xpchJKmq82R3dt9fK0OfwJwogi46 u7DhtPi5Ph9G7eLZOPG1bq/DRdqsYP63iIqG8D/clcCgdOISTSN4WrVl7QL4UeOWwfP1 +VJ9sqBoqfShXKN1JhJQrJFzOPN9+ONr+LVa+OD33AHFBD7Z0m5bjoL5uisKWGs5bUzZ 6mrnLo9zBEVdcKxLzYHAgtkEPU8IrD81o2RwzlIJGrFDc9zaPSH/Taz9XEL8a2wGIjyJ yg9/z0XM12iPgQmRSvK3dnAx8GRmEmXMfzBq0Um6AmpTClgShZoJWFGXegQQ5ZLspH6F L0yg== X-Gm-Message-State: APjAAAWkWhQ0nbISq7b+xyWZ6s4vQkAqRTEPMBuFS783quBoK9DOG6W/ F9E0YjMLYmWpkX6a8pJqatfydGJK X-Received: by 2002:aa7:8615:: with SMTP id p21mr37410708pfn.98.1554109291698; Mon, 01 Apr 2019 02:01:31 -0700 (PDT) Received: from [192.168.1.58] (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id i3sm12825414pfa.90.2019.04.01.02.01.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 02:01:30 -0700 (PDT) Subject: Re: [RESEND PATCH V3 1/3] USB: serial: f81232: clear overrun flag To: Oliver Neukum , 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 References: <1554098453-31278-1-git-send-email-hpeter+linux_kernel@gmail.com> <1554107689.6310.17.camel@suse.com> From: "Ji-Ze Hong (Peter Hong)" Message-ID: Date: Mon, 1 Apr 2019 17:01:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1554107689.6310.17.camel@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oliver Neukum 於 2019/4/1 下午 04:34 寫道: > 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) Thanks for report the race condition issue. It's seems the same bug in f81534.c. I'll try to fix it on f81232.c then fix f81534.c too. -- With Best Regards, Peter Hong