From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756707AbbJIUrh (ORCPT ); Fri, 9 Oct 2015 16:47:37 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:47012 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751276AbbJIUrf (ORCPT ); Fri, 9 Oct 2015 16:47:35 -0400 From: "Rafael J. Wysocki" To: Grygorii Strashko Cc: Alan Stern , Greg Kroah-Hartman , Pavel Machek , Len Brown , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Thierry Reding Subject: Re: [PATCH 1/2] PM / sleep: ensure deferred probe workqueue is finished in wait_for_device_probe Date: Fri, 09 Oct 2015 23:16:10 +0200 Message-ID: <2953623.dd2aFp1rBS@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.1.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <5617D155.60700@ti.com> References: <5617D155.60700@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, October 09, 2015 09:38:13 AM Grygorii Strashko wrote: > On 10/08/2015 03:53 PM, Alan Stern wrote: > > On Thu, 8 Oct 2015, Rafael J. Wysocki wrote: > > > >>> @@ -391,6 +391,10 @@ int driver_probe_done(void) > >>> */ > >>> void wait_for_device_probe(void) > >>> { > >>> + /* wait for the deferred probe workqueue to finish */ > >>> + if (driver_deferred_probe_enable) > >>> + flush_workqueue(deferred_wq); > >>> + > >>> /* wait for the known devices to complete their probing */ > >>> wait_event(probe_waitqueue, atomic_read(&probe_count) == 0); > >>> async_synchronize_full(); > >> > >> I'm not sure if this is sufficient. > >> > >> Something may be added to the workqueue right after you've flushed it and > >> then be reporobed after the wait_event() in theory. Or am I missing anything? > > > > Maybe I'm missing part of this, but I think the point is to make sure > > that every probe which began or was queued before this function got > > called, has finished before the function returns. > > > > Thus, in the case at hand we want to defer all probes starting from > > some point in the system sleep transition. Grygorii sets his > > defer_all_probes variable and then calls this function. It waits for > > any probes that were initiated before the function call. Any probe > > that was initiated after the function call (for example, the ones > > you're concerned about between the flush_workqueue and wait_event) will > > see that defer_all_probes is set and so will defer itself. > > Yes. It will work as expected with the next patch. > For all other case, where this API is used alone - > it will make things more safe, but there is no way to completely block > scheduling of new probes. Well, in that case why don't you make it part of the second patch after all instead of making a false impression of fixing a more general problem? Thanks, Rafael