From patchwork Fri Jan 28 03:41:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1585461 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=oA1/b1iN; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=WGDiY57h; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JlNYS009Nz9t5H for ; Fri, 28 Jan 2022 14:41:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 577F383841; Fri, 28 Jan 2022 04:41:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1643341305; bh=VQ8CSTtBXfR4jWqNHjDgaYvEXFjOgJ5rDUOpwUPAMh0=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=oA1/b1iNeKZm6z1gl+1iZdZf2ODS7pt2u3RZpL6MLhbWiKpC7WHTpS2cf4d4FxAQW fjBa318qZY46X7RAwjSLmXSdgxXB6DHz1AejCwzjFbStJSUf3nKacPr7y+UPTDOZNH Zic9KKy5nYweU5+AGHkEAzcikqzw4LLBGMfdTNJvPsewy91hO7h/adbtGeKJ0Z5WGA 0Y612/UqHT/Wy8fe6zi7N1Db1goKeWxpTK8f36KYaEjISVlWVfBgyqTlMfAZqz9Nis wPZXuRuzGImtr3TOwSa6uUNPY7LiBboxnu9KFpWH4sycpszGj8v66k5Mn+LO6qyh13 8Y/on23VkF6XA== Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 485AC83831; Fri, 28 Jan 2022 04:41:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1643341304; bh=VQ8CSTtBXfR4jWqNHjDgaYvEXFjOgJ5rDUOpwUPAMh0=; h=From:To:Cc:Subject:Date:From; b=WGDiY57hYhl3PI0G9tdpcJrlV7ylJjRRAdcCYitMJRdBw2mtgA6OyGO0kKQlwSGUb RhUt97+Yso2kDFEOHjIL9GvwdxH8eFVAmfxTebAbhaRAXRbw3WfnIb+Xn2H0bDkdPk caUpCPL8BCk/WVVBL/ZKFDgM5k0f98vaeOTqx7IhLzYLnPuyjTizkSB9Vu9NLQHnIi rEhAj0KcYHU0KFjGv/f+pmeNoLQUmGnSb1EsLiNgYqwwGORKgpCZFVHJs+OpiAcLNO q+GK/pHMG2JDD8k+HNxijLxovu6tBaivNonuLRWvHw3K/ObfYeHy8xcP4jh/V+NvCx dkRAXCCbWpubQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass Subject: [PATCH] dm: core: Check flags before removing devices Date: Fri, 28 Jan 2022 04:41:37 +0100 Message-Id: <20220128034137.1410935-1-marex@denx.de> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Calling device_chld_remove() before flags_remove() means all devices get removed no matter whether they should be removed late or not. This breaks teardown of eMMC when booting and other critical boot paths. Fixes: c51d2e704a1 ("dm: core: Avoid partially removing devices") Signed-off-by: Marek Vasut Cc: Simon Glass --- drivers/core/device-remove.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c index e6ec6ff4212..0454f55c330 100644 --- a/drivers/core/device-remove.c +++ b/drivers/core/device-remove.c @@ -207,14 +207,6 @@ int device_remove(struct udevice *dev, uint flags) if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)) return 0; - /* - * If the child returns EKEYREJECTED, continue. It just means that it - * didn't match the flags. - */ - ret = device_chld_remove(dev, NULL, flags); - if (ret && ret != -EKEYREJECTED) - return ret; - /* * Remove the device if called with the "normal" remove flag set, * or if the remove flag matches any of the drivers remove flags @@ -228,6 +220,14 @@ int device_remove(struct udevice *dev, uint flags) return ret; } + /* + * If the child returns EKEYREJECTED, continue. It just means that it + * didn't match the flags. + */ + ret = device_chld_remove(dev, NULL, flags); + if (ret && ret != -EKEYREJECTED) + return ret; + ret = uclass_pre_remove_device(dev); if (ret) return ret;