Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2650368imj; Mon, 11 Feb 2019 06:28:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IYR3p5eYuWepzlLbMobPt3qwoRDUKcruBf0Hfm6YhwQs2A+Csk6ZuHChbj6CGfyVozGtZ7a X-Received: by 2002:a65:6110:: with SMTP id z16mr34014557pgu.330.1549895321270; Mon, 11 Feb 2019 06:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895321; cv=none; d=google.com; s=arc-20160816; b=kpPti8zxmny/ixsaNWn4+8PYP0pbjfrOYLCoyQLrP54xQUuHcqRk12Zl62/kuVL5+p Za1xTdBoVby2U4TYf0jMuZt2Yx1gpce3DR+91kNEoSiRaSew029VRFkDm9VaHpOqMy1E 3kERpzxS2TjXPDP/sKkRiOjQmYN9X0rWAsBcO+eTDxMcdobwsIdzQkjItofuvaz9dvBo cH5Q76DhXn2Qz0McvaoQipwwbAJUf4Bj/ASVoLxej4OUJihx/C4g8m92gi0uKnHsl/GF 7FzovRqQwRgxUCd7i3wQyDi8BNTGrNpUrB9TkoWDpvxb7f+yP/Up6Ga74pCzMweZ0DwH EioQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DFB6UAAW9re3DjtE02yOyvMcakYIJ/GFriAQwftY+GM=; b=kndfVDIVaQjzmymYuiVeobmFy2yawJR6eKnxK2YlYhnzj0DSIGCGP35Wpj1BD7QgVs jWL+lAzklS2v0+eVAd1zhTe6Gnb1ixcXWwA9IFwOuEtMGK1L7MW2bUMr4vXTW/gNRJF9 DdmiuTx1V7mrAKkR/IMHhzh6Inc5oeL5ZBcPTOUpsPLAHvv/wdrHrBRejxC/CnIURD0E DBNX3dVDJqUz3h0Udo4ZbfmoVd2aqJbc/yv8esuslaLSMXawrUZlr0+2A8ClWVfcuQob zcO94Orj6yYCMy5yar8yj4tHG9QF4+iTaUDS5IJYEwQPzs6josEl+1T2jm4I2PN1Ly+r yk/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NRaelivm; 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 j1si9732474pff.42.2019.02.11.06.28.25; Mon, 11 Feb 2019 06:28:41 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=NRaelivm; 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 S1729579AbfBKO0f (ORCPT + 99 others); Mon, 11 Feb 2019 09:26:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:60302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729561AbfBKO02 (ORCPT ); Mon, 11 Feb 2019 09:26:28 -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 11B7820838; Mon, 11 Feb 2019 14:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895187; bh=IKVVP/0qmcJZKA0RLuxJsOMVxWKnYUB9ky3Zn8Ab6qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRaelivmOu2W2B3Oo5DnZJWLFlDpvs6blyic/FFfI7//myQjFUwM/4UVH48E6eppY lz9OTYTEb78iZ14SbqNuYlDcJxwMuKusCXdnfpqvkSuVicnh0gSobTGQ7Jmd5zEQNc ANvAvgqjxr3ghYjLV6GJHeEM0hg0iPbbMfxjjEZU= 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.20 123/352] driver core: Move async_synchronize_full call Date: Mon, 11 Feb 2019 15:15:50 +0100 Message-Id: <20190211141854.054167163@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 dbba123e058d..9d6604b50d75 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -928,9 +928,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) @@ -1036,6 +1033,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