Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3428380imm; Tue, 29 May 2018 07:07:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrx4ofFzzr2a5TcBtilJSttMIejTBCPEhFJymokAsyf5LD1yaOnONLdC5p+LKfYDlslC94P X-Received: by 2002:a63:93:: with SMTP id 141-v6mr14281891pga.322.1527602872546; Tue, 29 May 2018 07:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527602872; cv=none; d=google.com; s=arc-20160816; b=A+iAuOW+dyNufw/lZaCFRi99mutM/AjkOqL7r9hzu0oUC5rFawGnGKsMWL81YBWtQG BFNqoZ9+kU5nOi+6VIWZRvKKRbd+faPM3gHDkdc+JLhjX8qKBSWcLA7rW6VlHlNrAdnk yHAt7WGqCM5m60YYvwQqECt4Fk0dXO0idcwXngIji357EeleunRpvCeUUtXaewZIuLyF Z1AAyG6/CXZKFYd6f9xJ9lepvGzQYsaR4QY+rcfwb8cry9U+xOU7QIqAKBxARosYOFWi 5c9JnrAovTePNNFr+zZ2VX7STkAftXRTr2Gq9gYQ039ps6Y8jaKIDfTkg5vCyguTNk0Y /bCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=DrtSlmA8m4gQcHv9m74rT4mNxm3yJUmQNXNrvoyQNL0=; b=R5XyFRpQFmfd8q+6XWTrXqWl5aOBmv2s5v0VqJRf0woLeEJqXN/+oh9ecGWgkoJyeo 8EF9emnumhcCuahuI6edN0NerS7rjYvKQ3kvkfAJ+GGax0wZWc0tgYMJadV4x1yJYRMt vvkFpPP74rkQ08Ulhn1FswnK+N7ymj++aQ3sPlCurHLH84LbD68GUwu4zRWY5y013Fso Gyan4z9YBPYCMtIhriRBpb9lfia9Z2DwUfrJvv+KLoM8+XgANzf96CVJCAFUHExK9IWQ Y1Gz4Q7urYmtpnPXnTJAgJJupzbYcgfVmgl9+TF6vcOn/EdNsdNW4T1J6actJxCgiExY mlKA== 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 p7-v6si31453935plk.293.2018.05.29.07.07.38; Tue, 29 May 2018 07:07:52 -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 S934856AbeE2OHK (ORCPT + 99 others); Tue, 29 May 2018 10:07:10 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:45510 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S934175AbeE2OHJ (ORCPT ); Tue, 29 May 2018 10:07:09 -0400 Received: (qmail 1752 invoked by uid 2102); 29 May 2018 10:07:07 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 29 May 2018 10:07:07 -0400 Date: Tue, 29 May 2018 10:07:07 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: martin_liu cc: heikki.krogerus@linux.intel.com, , , , , Subject: Re: [RFC PATCH v2] driver core: hold dev's parent lock when needed In-Reply-To: <20180529070719.164626-1-liumartin@google.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 May 2018, martin_liu wrote: > SOC have internal I/O buses that can't be proved for devices. The > devices on the buses can be accessed directly without additinal > configuration required. This type of bus is represented as > "simple-bus". In some platforms, we name "soc" with "simple-bus" > attribute and many devices are hooked under it desribed in DT > (device tree). > > In commit 'bf74ad5bc417 introduce ("[PATCH] Hold the device's > parent's lock during probe and remove")' to solve USB subsystem > lock sequence since usb device's characteristic. Thus "soc" > needs to be locked whenever a device and driver's probing > happen under "soc" bus. During this period, an async driver > tries to probe a device which is under the "soc" bus would be > blocked until previous driver finish the probing and release "soc" > lock. And the next probing under the "soc" bus need to wait for > async finish. Because of that, driver's async probe for init > time improvement will be shadowed. > > Since many devices don't have USB devices' characteristic, they > actually don't need parent's lock. Thus, we introduce a lock flag > in device struct and driver core would lock the parent lock base > on the flag. For usbsystem, we set this flag when its device and > driver is matched and to keep original lock behavior in driver > core. > > Async probe could have more benefit after this patch. > > Signed-off-by: martin_liu > Suggested-by: Alan Stern > --- > Changes in v2: > - take Alan's suggestion to introudce a flag to guide driver > core to hold device parent's lock. > > [v1]: https://lkml.org/lkml/2018/5/22/545 > > Currently, I have the flag set in USB subsystem match function. > Since I'm not familar with USB part, need some feedback to know > if they cover all the cases that original case driver core > protects. The match function is not the right place. Take Greg's suggestion and put the new flag in the bus_type structure instead. > drivers/base/bus.c | 16 ++++++++-------- > drivers/base/dd.c | 8 ++++---- > drivers/usb/common/ulpi.c | 16 ++++++++++++---- > drivers/usb/core/driver.c | 9 +++++++-- > drivers/usb/core/usb-acpi.c | 6 +++++- > drivers/usb/serial/bus.c | 4 +++- > include/linux/device.h | 1 + > 7 files changed, 40 insertions(+), 20 deletions(-) > > diff --git a/drivers/base/bus.c b/drivers/base/bus.c > index ef6183306b40..18ea94caec02 100644 > --- a/drivers/base/bus.c > +++ b/drivers/base/bus.c > @@ -184,10 +184,10 @@ static ssize_t unbind_store(struct device_driver *drv, const char *buf, > > dev = bus_find_device_by_name(bus, NULL, buf); > if (dev && dev->driver == drv) { > - if (dev->parent) /* Needed for USB */ > + if (dev->parent && dev->need_parent_lock)/* Needed for USB */ The new need_parent_lock flag is self-explanatory. You can remove the "Needed for USB" comments here and elsewhere; instead just have a single comment where the flag is defined. Alan Stern