Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2021583yba; Mon, 15 Apr 2019 03:21:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNEcwHDZLGj1bT9c9Brf6+43j2SYhwZ1YBHrodY/Jh2YXV62+Jl7YgGe5ynHoFpmiNgMqD X-Received: by 2002:aa7:8719:: with SMTP id b25mr74291340pfo.90.1555323694711; Mon, 15 Apr 2019 03:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555323694; cv=none; d=google.com; s=arc-20160816; b=XLCTrz2wHYnLznHiJwonxH1OIaulKOBNuF8I8W7fDolkQT26epJl5W2kIORz2OsV2A DYKdKrLipbAPLMzF4pAEzo4hpNyz9YeIix5ff0wWxgLjohEX+ljDSq2rtjvq1Hq5HQ/0 GFO3nSsHDUNxdq5oC8Qiyf5UK63EiMe78IbwNQLzvQue8NnUrLXismNkE24Ju8SkZIxj J5AT77Yui+IiR5bdYzMLZQU5Z2Mn3/KSOdjRouvdeTJT5Ue/yWYwl+wybvgujjZGXsiN 4QqrcgZUb3cCppuXz59cg2DEG1AuMOAPShR3e7tlp4db93BvX+qozan/26kP4c/aO/gh vK4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bqYAp/he9RcQe+K1USjID00PfUaljcvAy/YDV5xrNu0=; b=CGjN9ACBVfrQMkFzurs7nZ8XyDTq0qXByj86BL0muO1sTwZRk4Gxh/E1U0f12T7sag SuiJcFsOGFCQxF9nHU0xzUX4sga4Fr5odSxnyYj1Q5CNdR0xlw9UQGeYH0wJoZU9DSg3 vmfyXAOlvkxAtPv1s3+ae8WlcRW5E/YxotJFiwgWQmWhcM3S1JtP5CV0lBCVp0xknutO ntSwzT5alQ7Ol6KhmbFR8R6/zWxGRFMzKY9pXsZtLYZ6sO57sCJtFCFHRpwI52PCWdZa 694+c6HyI2m4Dzcv1FzCj8MQzGisWn35qOvjawDZVgK51cDgs/K2zCJBuzkhTPR4OnJ2 E4cg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23si43344514plk.109.2019.04.15.03.21.18; Mon, 15 Apr 2019 03:21:34 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727218AbfDOKUQ (ORCPT + 99 others); Mon, 15 Apr 2019 06:20:16 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40554 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbfDOKUQ (ORCPT ); Mon, 15 Apr 2019 06:20:16 -0400 Received: by mail-lj1-f196.google.com with SMTP id q66so15087726ljq.7; Mon, 15 Apr 2019 03:20:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bqYAp/he9RcQe+K1USjID00PfUaljcvAy/YDV5xrNu0=; b=Vtf3SlckqOS7vf76vmPSNdYxbvfTbiHI+3KhZdypAzY8FDSiIh9sJgQ+mBl199wZhk nlorY1Jyy+s2xa367/6cEOuAiUnmZT1DBtsJU94/KrSeuwgIDtq7Hx5LMhWoYq8hAdKz qPKOu1kyza8JR7Lu2AWMI73MenlcZygZXHEQiZ/izyDC7jURVUBkMrXj+zRNiOk3pl/m QeFwnUZBzFx4Eow5s+tb7e2JpyyRA1j0T0nrybeh7P0uSbV+Ssinzrt2vwtdwXWv9MNj Y8d3ZMUFZk37uiPpRm2p/vWShfnOLUqE8MIu50MRE9b0zGFYS33SOvKUOarxuPIJbSiQ 3qVA== X-Gm-Message-State: APjAAAUM5hO6pvl0+AErmWL+sdQ8qeYeh9RwmtEIU8Owtq1rUgzj14ha zYbfB32kXNOoJWR+dPxoW7w= X-Received: by 2002:a2e:895a:: with SMTP id b26mr38057860ljk.89.1555323613764; Mon, 15 Apr 2019 03:20:13 -0700 (PDT) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id d23sm2805988lfj.64.2019.04.15.03.20.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Apr 2019 03:20:12 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1hFyio-0000Bc-6P; Mon, 15 Apr 2019 12:20:18 +0200 Date: Mon, 15 Apr 2019 12:20:18 +0200 From: Johan Hovold To: "Ji-Ze Hong (Peter Hong)" Cc: peter_hong@fintek.com.tw, johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Ji-Ze Hong (Peter Hong)" , Oliver Neukum Subject: Re: [PATCH V6 1/3] USB: serial: f81232: clear overrun flag Message-ID: <20190415102018.GD29656@localhost> References: <1554280832-29286-1-git-send-email-hpeter+linux_kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1554280832-29286-1-git-send-email-hpeter+linux_kernel@gmail.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 03, 2019 at 04:40:30PM +0800, Ji-Ze Hong (Peter Hong) wrote: > The F81232 will report data and LSR with bulk like following format: > bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]... > > LSR will auto clear frame/parity/break error flag when reading by H/W, > but overrrun will only cleared when reading LSR. So this patch add a > worker to read LSR when overrun and flush the worker on close() & > suspend(). > > Cc: Oliver Neukum > Signed-off-by: Ji-Ze Hong (Peter Hong) > --- > V6: > 1: Add deferred_lsr_work_needed to re-trigger when f81232_resume() > > v5: > 1: Source code base revert to v3 and remove all v4 changes. > 2: Add serial->suspending check in f81232_process_read_urb() > before schedule_work(&priv->lsr_work) to avoid race condition. > > v4: > 1: Add serial->suspending check in f81232_lsr_worker() to avoid > re-trigger > 2: Add port_priv-lsr_work_resched to re-trigger LSR worker > > v3: > 1: Add flush_work(&port_priv->lsr_work) in f81232_suspend(). > > v2: > 1: Add flush_work(&port_priv->lsr_work) in f81232_close(). > > drivers/usb/serial/f81232.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > +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); Note that usb-serial core doesn't manage the interrupt urb for you, so there's already a bug in this driver which should be fixed in a preparatory patch (i.e. resubmit the interrupt urb on resume). And if you stop the bulk-in and interrupt urbs explicitly here, you can safely flush the lsr work without any races afterwards. Also note that the interrupt work is currently never flushed on suspend or close either... Another thing to fix first. There's also a layering violation here, since you're accessing the child port data from a parent interface driver callback. The port driver could have been unbound and you'd get a NULL deref here. Iterating over the interface's ports, and checking if it's been opened (as you need to do on resume anyway) might be enough though. Johan