Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759728AbZJGRYh (ORCPT ); Wed, 7 Oct 2009 13:24:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759703AbZJGRYh (ORCPT ); Wed, 7 Oct 2009 13:24:37 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:42002 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1759627AbZJGRYg (ORCPT ); Wed, 7 Oct 2009 13:24:36 -0400 Date: Wed, 7 Oct 2009 13:23:59 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Alan Cox cc: Oliver Neukum , Greg KH , Kernel development list , USB list Subject: Re: [PATCH 4/5] usb_serial: Kill port mutex In-Reply-To: <20091007174611.439a7a5a@lxorguk.ukuu.org.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2211 Lines: 52 On Wed, 7 Oct 2009, Alan Cox wrote: > On Wed, 7 Oct 2009 12:03:08 -0400 (EDT) > Alan Stern wrote: > > > On Wed, 7 Oct 2009, Oliver Neukum wrote: > > > > > We will need some generic way to autoresume from open. > > > Resume will need to lock against open() and need to be called > > > from within open(). Any ideas for an unugly interface? > > > > It's not quite that bad. Resume doesn't need to lock against open. > > If open is called while resume is running then when it tries to do its > > own resume, it will either block (waiting for the pm_mutex) or return > > immediately (if it sees the device is already resumed). > > It would probably be cleaner if they could lock against each other What you mean isn't clear. After all, open sometimes has to call resume. So how could resume lock against open? > > A more interesting question is how to synchronize both open/close and > > suspend/resume against throttle/unthrottle. > > throttle and unthrottle can sleep and obviously have to as they do a fair > bit of work sometimes (xon/xoff, mode line waggling etc) > > The current ordering here is quite ugly because we open the ldisc before > the tty which means the ldisc sometimes calls unthrottle before the tty > is opened which is not nice. On the close side we have the same thing via > tty_ldisc_release. > > We can take the port->mutex lock in the throttle/unthrottle methods as > far as I can see - there are no obvious problem cases. We do call > ->throttle and ->unthrottle from the ldisc open but this occurs outside > of any call to the tty driver open/close method so I don't see any > deadlock. > > It adds an ordering of termios lock before port mutex when taking both > but that's not a problem and really implicit in the structure of the code > anyway. Does this imply that unthrottle should try to autoresume? There does appear to be a potential race between unthrottle and autosuspend. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/