Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3628405imu; Mon, 28 Jan 2019 08:05:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN5/o0E5UlZDa9F90kXIqlWRnKrgHMke7cxhiMceh10l+71rcc9xGMXrvZfXiaBb9T8Q4Zj5 X-Received: by 2002:a17:902:1005:: with SMTP id b5mr22455948pla.310.1548691555118; Mon, 28 Jan 2019 08:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691555; cv=none; d=google.com; s=arc-20160816; b=Zs93QbIXlKrH/fuZPgs84xbzqd7Ri5lpzP0aFC5D4CHmTNKnkKC+PHJQaF1Ur8Bfkg Nsgwj/5BDTLqc89PFmNinesTsP6JL11f0xjlTRbfZMRIRKq9cTDulk8sVtC5Y1nkGZQQ sJJC35u2co7Rjt7OQ9qQ1vcz7G4jIqJKGG6yzMyEJOnRakxSKW/h7m+yE129+p56TUyn x/NvicXqIU7Kail2OkWorMDANWRTGqhzGDA3djGTm/X0EM+wficF5xwei5oZL9uL5flr OmpSDdnpYKjI8fNZLiJ00gb/p6vlnOiOfbVTwEVAqZcxOzwJNB+7jwVRrQyX7n32v+s+ V0bQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tRILFm77vCyoI3D6ymnxmUgBbl+j0z2fMQ9CkNZ8McA=; b=an6HxLG7L/HPnq6/167yLNNuYKxTX1skJx1eqYm8C4d0mTeJ4FCDZfeGYv3ENc9SnT bEe31SX7Z3nSElKuGty4wcmYhQFWIy4hKq18Wjc7UvUlcpeZ5eHJxJvsurfrPZikmXYv bvg0IUDeKX8iHZjuxGkCKi/PeDn9/Ca/hJ+iU91lNazrT+KBa8IxxYmDlJ8UZFcod7Fa nM7L+PFi7GEHDP9EvbhR0oqPMa0E3DZxHiRSmgh1WY7DR230TiFF7YwlTh4qfkPM3V+C J6hZPnUQOgCJhVy7ElNosKveo8SOPmYpz46HLzWdwuY4GV/ithQ/yNm4AqNgvOJWGons Bniw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="zW4D/Zvn"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si34040654pfg.254.2019.01.28.08.05.40; Mon, 28 Jan 2019 08:05:55 -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="zW4D/Zvn"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731681AbfA1QEs (ORCPT + 99 others); Mon, 28 Jan 2019 11:04:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:50692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731665AbfA1QEr (ORCPT ); Mon, 28 Jan 2019 11:04:47 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EDB92147A; Mon, 28 Jan 2019 16:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691487; bh=zZimf+VoLvqfH4G0DQU5ZzF5LxZa94Ry+vS+/eljLOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zW4D/Zvn9ajUqOKN1m3Gn8avaTsHnRhkTb0XebWfeE9C3oVCwu29A77y6Ebjba6s0 31tqH9UOBrMYEDAzSF435JazE7DhDUtVGDEk5WQdkteWgDeSnaC+Uzg8R+/yXYIQ2M WTKgcAPaaIEuyf5iH1WvU0svYbDW4zy7Dym27tg0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Duyck , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 111/258] driver core: Move async_synchronize_full call Date: Mon, 28 Jan 2019 10:56:57 -0500 Message-Id: <20190128155924.51521-111-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck [ 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