From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77F50C169C4 for ; Mon, 11 Feb 2019 15:45:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47A5B21855 for ; Mon, 11 Feb 2019 15:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549899940; bh=Uo3z+y6enUJIz7L7PHMEKzz0/jdjx+Xyc9eVCqkPwc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gkBp24ZAPfVtJ5c/O+/VaXYXHFoYdGrVB3s+mapoDHljCAA67m8WCHzCk3CSK697Z PF9Rvsj9f3ofc0dlZWm5uID1yCSmnITDcAp9i5GIDLf67Aq8E2UUcnCIZAu7tU5fvG p9NBPJwnw+RKIM1DF7zttDR24LHIfTcwxZZzKaFc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732604AbfBKOnV (ORCPT ); Mon, 11 Feb 2019 09:43:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:55390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732584AbfBKOnO (ORCPT ); Mon, 11 Feb 2019 09:43:14 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E8A821B18; Mon, 11 Feb 2019 14:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896193; bh=Uo3z+y6enUJIz7L7PHMEKzz0/jdjx+Xyc9eVCqkPwc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QMeuiUr6Vv3CV/i35xQ0YUxUMt5vw8D+WOaBpRx37r8o0RCMJpgtMLo3GZBVmcWSu NhH7de2F5et8GQMqlgPQwpSKlpUg1ugx8W7VTgynRMkJ8DaxazzjatgAr1PCfW/uK3 PBm/4h2FE9gfSYqhsejCFPvuAH+c/SUd+W2Ajd68= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Dan Williams , Alexander Duyck , Luis Chamberlain , Sasha Levin Subject: [PATCH 4.19 104/313] driver core: Move async_synchronize_full call Date: Mon, 11 Feb 2019 15:16:24 +0100 Message-Id: <20190211141900.805915141@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit c37d721c68ad88925ba0e72f6e14acb829a8c6bb ] Move the async_synchronize_full call out of __device_release_driver and into driver_detach. The idea behind this is that the async_synchronize_full call will only guarantee that any existing async operations are flushed. This doesn't do anything to guarantee that a hotplug event that may occur while we are doing the release of the driver will not be asynchronously scheduled. By moving this into the driver_detach path we can avoid potential deadlocks as we aren't holding the device lock at this point and we should not have the driver we want to flush loaded so the flush will take care of any asynchronous events the driver we are detaching might have scheduled. Fixes: 765230b5f084 ("driver-core: add asynchronous probing support for drivers") Reviewed-by: Bart Van Assche Reviewed-by: Dan Williams Signed-off-by: Alexander Duyck Reviewed-by: Luis Chamberlain Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/base/dd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 2607f859881a..7caa1adaf62a 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -926,9 +926,6 @@ static void __device_release_driver(struct device *dev, struct device *parent) drv = dev->driver; if (drv) { - if (driver_allows_async_probing(drv)) - async_synchronize_full(); - while (device_links_busy(dev)) { device_unlock(dev); if (parent && dev->bus->need_parent_lock) @@ -1034,6 +1031,9 @@ void driver_detach(struct device_driver *drv) struct device_private *dev_prv; struct device *dev; + if (driver_allows_async_probing(drv)) + async_synchronize_full(); + for (;;) { spin_lock(&drv->p->klist_devices.k_lock); if (list_empty(&drv->p->klist_devices.k_list)) { -- 2.19.1