Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2681410imj; Mon, 11 Feb 2019 06:58:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ1/bhheU6rP+Rgaso1Q6O1a6sa0RuPGESiZz8E+gHnvX7xxtyUIcTi0NESd2A0kHHlwn1Z X-Received: by 2002:a17:902:ba85:: with SMTP id k5mr11108517pls.130.1549897101653; Mon, 11 Feb 2019 06:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897101; cv=none; d=google.com; s=arc-20160816; b=kpECPEdByDsRafsW6oDULatbZdLgZuvmqdLT7ctyJSHkcJZnhb0c8WBEp6o7fcmnZ1 DCyV8R2VgI2DgBXyDUMVBXQ8bi5oXpby39tzL6gUaXFJaRYlSYV38hA3BhRGLlWRKaTj 6QrSqNksi/JFltge7febwqOMPeu4lZt3Pq9f+e186yNfyesq8JehXJOjs4yIaA6sk8bM BMS4xwCjzMi530k/AowNs55r60bukYwBRZa4lHokduV2XNXzrgwxGqvzpYdxblimCGVx NXPXABMCT1J4vo6BVu4R8kLt67IkgGqVMZJeXsmXZj1LYgT35HoT82Huq8fCWarZMSrS ap2Q== 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=FCoDiAaU34sRjz9VqGWqwjXW8oMcH6B8pMr6Lc9JdGU=; b=bXRLtR6xMsM3u689dcRS0JHw8AMG1P2Uw3ep2NOPp0fBlAcoQr3kRa8On6/pZktuIf BG+Xe4qHyWGWZOv4o++2zk4gV7H50GYME+7/vvOfqaEf63Hd5and9INqFxa9e9/RydT/ HbzlO3m+d9V8FthwBmaZuqrEcXgCl4O+11AHp1nN7P+s7/3kL+kJ796haGjhB3zDqfHt Tb/x6fgXLp+N/7pSM8NU2WJGkMA1ZtId43Z3zO2pLhT3cPI6Yp9S2z5N1J7EI+HyZFog UvIoqNT7I+D5G5+Nn37lulO9wy9gKftu0jMYdfJRXAW6sR+rawCNgxF5glcEuhKVltqv QLNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NkztoeRW; 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 j5si10414048plk.225.2019.02.11.06.58.05; Mon, 11 Feb 2019 06:58:21 -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=NkztoeRW; 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 S2389299AbfBKO5I (ORCPT + 99 others); Mon, 11 Feb 2019 09:57:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:44456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389286AbfBKO5H (ORCPT ); Mon, 11 Feb 2019 09:57:07 -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 1BAD52229E; Mon, 11 Feb 2019 14:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897026; bh=ypmoBlZBlkwuUwWBqu8EhsRh8S1JjS763Y8Nj2GHi74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NkztoeRWB1McI6PNtIocJqea5yrjytgz9jDhHA/SvLjXo4PsHR9iEzdiLUHO0p9aI 43Hf/eaasn16tGB4KjEotxnnYGDnL9TWY/e/syMlhkv4g4rJdFkEIU5wK7vISRdWEJ ZSyCP9lDy99AQkyjQYnJW5a/7szVktUpBRwcBvt0= 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.14 067/205] driver core: Move async_synchronize_full call Date: Mon, 11 Feb 2019 15:17:45 +0100 Message-Id: <20190211141833.140397122@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 55fc31f6fe7f..d928cc6d0638 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -813,9 +813,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) @@ -920,6 +917,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