From patchwork Mon Feb 5 12:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 196792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp837557dyb; Mon, 5 Feb 2024 04:26:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyCAFsegDLibMv33Arvm/CH5pm5MQizrmNx/tTK0Gyv8tY2GZuPXv1TmaAyJ04bi5ldOdk X-Received: by 2002:a17:906:a84a:b0:a37:b496:f0ab with SMTP id dx10-20020a170906a84a00b00a37b496f0abmr1871188ejb.14.1707135977250; Mon, 05 Feb 2024 04:26:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707135977; cv=pass; d=google.com; s=arc-20160816; b=l7azN0uOQdu/MpHHrSC6SrlYjlhD4frMCKMmXIW8nXcBD1ZGMPdu7KUtt0nkgvHwKC PXeNwm5VCIKG2Iw7MW/YQDSa3jks82aAj7QcTGBy0u4NWiCoftra7JKj5iWlW55ctpPc sh9ndP9kQ4LjHB1Wb0SGcyyclRa9PivHm7EgfFjYgZWopaf+26KI77zIbxm16Sl/sAK8 t3E7f+1MfFCjOYBJv/43UbBqEMGMSCijSu5oQqbeDKPSkZElivlUIdgfBqXjz7kVPnFQ e3uMoXCNr3Y1tf5M08Bp8YzH/DLfJ+nJ9UoFw6ebAp6ASmWZ1dX9mSrJCqlyDanKDcqi 1sIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=LWC70hBwcYvNIErAJlvTGYTySej5b8z/SPLw2+iq0eQ=; fh=ZFP2nHvec3fonbbTDe0JRwRMYnCd5mmgQvlXr6cew8A=; b=M3gJCOZ+fbEl8k3mkAPl6OmHsWE4aGLi0J+8vRRplCfb7osFSRCaBbwi/1TrCfOX4N fb1eSAWK64f2dtQtAOcMIb0dbGjao3S7ZH33396zOHv5h7zfw0bpvL1Ttnw6E0O9MKsu jWLj5D5uiHDdVthLT6ZgOK7SmKeQV/9qg8LQWH6liTPRU69qfCKyc6pMfttXizYN11LV E/tP6PrY+qCXBpnyHV8T9av0h2lu3qqG+vEhxROJwiRUWn80FSfG7ykVaz0MW+Rz3Aas 4FKTxqmJUTIFJHgldLbJM6Xc9MarDynefTzrwvOJAwKQ+DLp1jBgmvyFTJ3QLTIH3/gl SVQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BeEkOPAo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-52576-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52576-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXmkOy012VqP67I5Vznz1b2ASFI1ucQOqgcafcAcC7mLbOUQRs7Yo6E0LIKyQhuG/eoB0GTy7QHz/obeN6gZRzv900blw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h25-20020a1709063b5900b00a371a8f2bcesi3369052ejf.813.2024.02.05.04.26.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 04:26:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52576-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BeEkOPAo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-52576-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52576-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A68FE1F249BE for ; Mon, 5 Feb 2024 12:16:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B5B12C183; Mon, 5 Feb 2024 12:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BeEkOPAo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADEB61BDD9; Mon, 5 Feb 2024 12:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707134974; cv=none; b=OhS4X3pp3w7TsXsPc8DVVxNNq9wSZmniK6KCFi4navZyLtKTxLTEJnD8Glqyj0YdpTUgfji4W2/70xX40rKW/lNYMODHHoHcbQ4eI5RbWdLbgBoHCNY3daundtn9NO0HpUYBV669xs2HIEKWZ4VTpKAreF4FTTrSoiC5kZyh+rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707134974; c=relaxed/simple; bh=76bLnTFW8hOss6IF1pWTx33Eugtw/u1ls0YA9hmCWJA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ca8Dkl/FhF3QKsk7zml+ZdrALFX534sntgNGbhR3zrqEjCzwDesYjMEFuBQ17CIMvAB6xl5MNic3thf+cUwE+JGVIi++6LOFc/Scua/Sy5XPvqF7mDoyOOWNua4MyXdpMiUGcEHNtq5fAZ6GnDLx17mitDNBnuRJwzNv8v4u5Sw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BeEkOPAo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 45979C433B1; Mon, 5 Feb 2024 12:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707134974; bh=76bLnTFW8hOss6IF1pWTx33Eugtw/u1ls0YA9hmCWJA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BeEkOPAoDv3chM+cAnfF5sgZRJD+P+xxeL/K+BBHS5at2/1Gi2+l1bWs8aaYvPucf XcoXBie0Jn+6ZWjon2DIURx5TZvYoGVQSG8d13zNY9HdU+rMJyAUDOehijidCe08s7 goBwyQh8IlalNMRGy8mubR47Se4m+W4BD1MEyxRrI6DG861k4xIiI0xyIZwCsHI+aC kSYsjcquM/yFejppnINsiPz6ImRnpzE1JMqfdcoCZricpEO84Uuc7ePwsSH/UzpNtx 4Op3VGcVQO+8mpnEQ4CW0rNdz8ZZuvZOOtKxYPhSiXZSV0MpDrETq5mibcvy7wQAE7 s09GZ1V+VXGGg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2518FC4828D; Mon, 5 Feb 2024 12:09:34 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Mon, 05 Feb 2024 13:09:33 +0100 Subject: [PATCH v2 2/2] of: dynamic: flush devlinks workqueue before destroying the changeset Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240205-fix-device-links-overlays-v2-2-5344f8c79d57@analog.com> References: <20240205-fix-device-links-overlays-v2-0-5344f8c79d57@analog.com> In-Reply-To: <20240205-fix-device-links-overlays-v2-0-5344f8c79d57@analog.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , Rob Herring , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1707134972; l=1506; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=YDuksPxVzpgUXsXtMiptrKAHNtqa9E4wT61h67KKExU=; b=+pR9xIxPkbxkT8MxATu4NfCBUJ+zzK6rP+cyMoqKYeDDvSxTJi8Gd3uvMlCO1CEC8rqyBMLCI WWMLTeb8A1LDHRH9Rh6EZ0RqMEszqHesQn9jA8kbQP8zEix/vgTjyD3 X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790061814374320678 X-GMAIL-MSGID: 1790061814374320678 From: Nuno Sa Device links will drop their supplier + consumer refcounts asynchronously. That means that the refcount of the of_node attached to these devices will also be dropped asynchronously and so we cannot guarantee the DT overlay assumption that the of_node refcount must be 1 in __of_changeset_entry_destroy(). Given the above, call the new fwnode_links_flush_queue() helper to flush the devlink workqueue so we can be sure that all links are dropped before doing the proper checks. Signed-off-by: Nuno Sa --- drivers/of/dynamic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 3bf27052832f..b7153c72c9c9 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "of_private.h" @@ -518,6 +519,13 @@ EXPORT_SYMBOL(of_changeset_create_node); static void __of_changeset_entry_destroy(struct of_changeset_entry *ce) { + /* + * device links drop their device references (and hence their of_node + * references) asynchronously on a dedicated workqueue. Hence we need + * to flush it to make sure everything is done before doing the below + * checks. + */ + fwnode_links_flush_queue(); if (ce->action == OF_RECONFIG_ATTACH_NODE && of_node_check_flag(ce->np, OF_OVERLAY)) { if (kref_read(&ce->np->kobj.kref) > 1) {