Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2931205imm; Thu, 24 May 2018 19:17:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZroZpeExhF4qIu6JVapSoWq9ugHd+ycR1WGGCVTZw0BmA1Sgpnn9Hag9P0NmyUk7QRb1yW7 X-Received: by 2002:a17:902:20e8:: with SMTP id v37-v6mr541280plg.354.1527214675167; Thu, 24 May 2018 19:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527214675; cv=none; d=google.com; s=arc-20160816; b=iNz9IjE17yEX30WwusohgaRJR0dgg3lV5DBE8aX6PzGcunacg4wfQBFDPfZJb69J9x dEwc8KxMs5k5vGL+JXZbUOPWfhvLrqFtruGDxm2gc6kPLf9eZxZ8fLkYKkc7xzBLvVnu qSMubanE0P50emwOeHV50QhM0dnFwLyOhsOciGH9IPoMjzONXqrDHdzB3rHsTRW7H3zF HnRJr+WVBxQKJh6AaUiqoi4d6A7qDpGU/DbzayHizaatmw9vxbtyuQjtRjbwfC7cV5Ni 2REFPMcO0aNnnTnuBgb5tEU6xDizclRxVkH3S6ME+1CLhPl6mVZuavhDde9hZhe3r4Lu AH1A== 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=T44OOzRVAmGPWMuaMXz6dNu85+VbeTmN5NnOKRxEq/E=; b=g3Nzn0HWDI7OaXcKO/3Lzq7TZJP7mlotCHKzVYOAzcZ0NofujE7xadq4R/hPCEmhCk w/K5L4B7LGa4txpqZRY0EjMz6X0zEAn8S1RGBQwgQtL3RvMuJGCj9UKXfPMMOt/DV/jf Ugbz1SxDYS1wfZSdBNkvtAznDLhgAi3MhLKw9m2xbDVZGNlhcFvVsCxScRZwK/gVnGzl 8g2cpuoOcItn6ABPhI2aboE69m1+0nTJMVnqYe4K6VVfW+dlV+/BSHdElYGN7hL1T3oN 1pa3CtpBCibr8PNDyMhw+DPGpDWgGSNpIYafd8jMgetdmvq4FPSWKPQWM3po3f7lfOvU FnuQ== 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 a11-v6si3412689plt.39.2018.05.24.19.17.40; Thu, 24 May 2018 19:17:55 -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 S970630AbeEXPDA (ORCPT + 99 others); Thu, 24 May 2018 11:03:00 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:55244 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S970650AbeEXPC6 (ORCPT ); Thu, 24 May 2018 11:02:58 -0400 Received: (qmail 18061 invoked by uid 2102); 24 May 2018 11:02:57 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 24 May 2018 11:02:57 -0400 Date: Thu, 24 May 2018 11:02:57 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Martin Liu cc: gregkh@linuxfoundation.org, , , Subject: Re: [RFC] driver core: don't hold dev's parent lock when using async probe In-Reply-To: <20180524140021.GA214888@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 Thu, 24 May 2018, Martin Liu wrote: > On Tue, May 22, 2018 at 01:09:44PM -0400, Alan Stern wrote: > > On Tue, 22 May 2018, martin_liu wrote: > > > > > not sure if we still need 'bf74ad5bc417 ("[PATCH] Hold the > > > device's parent's lock during probe and remove")' since it has > > > been there over 10 years. If we still need it and hard to fix it > > > , the simple way is to find a place not to allow USB subsystem > > > drivers to have async probe capability. Any suggestion is welcome. > > > > I don't think the "allows_async_probing" attribute is the best way to > > attack this. Some other approach, like a special-purpose flag, might > > be better. > > > > Yes, USB still needs to have parent's locks held during probing. > > Here's the reason. A USB device can have multiple interfaces, each > > bound to its own driver. A driver may sometimes need to issue a reset, > > but in USB there's no way to reset a single interface. Only the entire > > device can be reset, and of course this affects all the interfaces. > > Therefore a driver needs to acquire the device lock before it can issue > > a reset. > > > > The problem is that the driver's thread may already hold the device > > lock. During a normal probe sequence, for example, the interfaces get > > probed by the hub driver while it owns the device lock. But for probes > > under other circumstances (for example, if the user writes to the > > driver's "bind" attribute in sysfs), the device lock might not be held. > > > > A driver cannot tell these two cases apart. The only way to make it > > work all the time is to have the caller _always_ hold the device lock > > while the driver is probed (or the removed, for that matter). > > > > Alan Stern > > Thanks for the reply and more detail about the backgroud. I'd like to > have a conclusion about it. Please kindly correct me if my understanding > is wrong. Regarding to the "special-purpose flag", do you mean we could > find a place in USB subsystem to have the flag set (not sure if it's > easy to find it). Driver core would be base on the flag to decide if we > need to hold the device's parent's lock. Yes, except that the flag would not be in the USB subsystem. It would be in the device, device_type, or bus_type structure, so that the driver core could access it. Alan Stern