Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp957865lqs; Wed, 6 Mar 2024 01:48:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpv3TtYyxMuF2OaMzhCkCtC29EPproeczAPcjbEl4HBeYOi2RTVJ3YufhAJfkXoTNGgK+E6vtiG5M0rIK1p4N2JrYvlvjtIKIolSLmWg== X-Google-Smtp-Source: AGHT+IHBeNgIDep86E8xkGByFNIguLmoy4wlQPZks0letXcPOAjW+g44YzW86xIeDzjKnuGIzomf X-Received: by 2002:a05:6a00:1898:b0:6e5:138:acf with SMTP id x24-20020a056a00189800b006e501380acfmr16668333pfh.10.1709718503121; Wed, 06 Mar 2024 01:48:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709718503; cv=pass; d=google.com; s=arc-20160816; b=IHPkjcIgzpj9tQ3ISFqR5FJFMHs5ARimwaZfsqf0ftdgsyzuwj50LtWcZdvj6secbu 1qKyJXfmg4qMfFTnblAFakeIy49UcRjQSUTOd1cfzNGFB0G9vXRqqL0M7apmn9YMABf9 eryg3//xuXGz5Z1A4F6QGkJnfAnj+rLso3M0P2xZosarhXK7qma2fC1yTXfmN1pYTgk7 lRu8Vs2Gx/5WM+dBkcRVXzKuc2EItXrye+v4RJwCVE8rneQvgOy3+ixuLcE6TtnuYqUr 7g7C0RicG6ZQCCGkwmY6og7ozTGUT4lu6BVkL3vbJXZ2yD4vb13P5BcdcAaNiGYey76u jHEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=qkqt8dEmmlTcLYpeoo+RLVm9X92pye6PGGcOjeLLYQM=; fh=Zu19K7WP0T+wmhzxc9+ewdD8MZWakdPvfywCoJbEYaY=; b=antMk1/aqAacTqGBXTtyaiOuV3ikuZogegT9bol5sHF1d0wEbfW18PIwgNg8XPP9OA sdPjsqagNIM9MlacmtCkeuTZK4HM0kt4a2YBT6j756lbLzjgIOHTEOt8qB5M5QynmlSQ 9yHGWIXFc2VPteAVmJ42YsqdOk7nZWP5OqVOdyg7XVnw0bdaNrL/MJo/Ms/+PHF+1gyf sTC63IwB6D/BT06nJM0kMhk3N8llGSInvRKBJLy+puQ5rO6fthLrSgqk7KNngV0nF0td tMY+RkFTGrrGNkI8jCKRtflvm1PvrlATaRmaWhjQiVhmbCb7Ss9/Kc/NGzhVdLWae7M9 rmMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UhnuIwHe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-93611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93611-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c2-20020a056a000ac200b006e61aa762c1si5661405pfl.361.2024.03.06.01.48.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 01:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UhnuIwHe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-93611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93611-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7E1AFB298F8 for ; Wed, 6 Mar 2024 09:18:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E4055DF0B; Wed, 6 Mar 2024 09:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UhnuIwHe" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04D651426B; Wed, 6 Mar 2024 09:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716660; cv=none; b=MQGTo3SNKE9nC55InXvMapB7eMrsnqam1m5lqbzxoOs4QzycVYJMqD6meBC5Vmd2TXTUgP6mrEf8rQRBUYldRv5e/d4QFdiyHzA85TtAhKDWJ9wJbIHTB4P9v0AaXPexOR3WyiHa9itZiQ8ufCwBMByC8BGWnmTUd9Vz3Z8SVTc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716660; c=relaxed/simple; bh=JCzzi0CCK6mpbkxHx7yxf1dGanKXYtS2e3YouRCYaL4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=bkC0ZFYlJQKMW3h4/dihbPbB0mD1G0FbVnF9iHBeJY4FFf8qkr/4A1Rqx0nwiz/CbFJXH0ackxm57mviyBRJq0HmobN/e3VlCJeLTvfmyx2VBVbhsjgYpNg72BvtJzPLnztPG4PQ16tNmN56fEUD9dKvo2sSKNAID90HYyV6zt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UhnuIwHe; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-56715a6aa55so3876475a12.2; Wed, 06 Mar 2024 01:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709716657; x=1710321457; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=qkqt8dEmmlTcLYpeoo+RLVm9X92pye6PGGcOjeLLYQM=; b=UhnuIwHeJX5Z80SIoneyRQgpDNELOflYwzJFW+jOOECiscL3pFj4+fCyxIdVBoX9eD V6MthgRgZWfMQE4ftc/lv3VXmfrqHsDzrHdf4gY6MCfHOWELsSgOrmh2Lw/Bt52CaYPm gGnSofHHdCNanQJ4tuvSrHRv06yaZgvCStijlcb4tMgCwBjMyDad1W9AqrrVm6Q1PsU6 myQ5yKfdGj5Z5BRrzgE81GgGFCDXoA1aTkDTVUwJyg/8596Wp80v7hRR7zWyK097+/yC HckUHaOSdTLzKcFK+AR5hnY5QxRDMAuz3DfMY/QPch/217S60WOj0nkaGQHjrSyL2OF1 2mfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709716657; x=1710321457; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qkqt8dEmmlTcLYpeoo+RLVm9X92pye6PGGcOjeLLYQM=; b=WnopKL8N9z7GAuqt1jXbBrCxmYk/UqQoQ6J/3u1QpMc9+W+AB7pmV4bgmlwJ6iH8NH eAYmkDYfnBJm7abwvrfxsT1UUoZX4X0y1iaeXNUfJBuI9mEc1K1jWCdRAG8CmeENAxxr Lk0qIJYFWfnGjhmr1gMrmxTB53iPaqtEIkWyluaXybFIiIWF+ZaqOqYZj0ws0o94qo7d ycnqCkH/c6SzhU8BwxzOMxeq7q/6NlsWB3ntFSrNj4WoIshQuLTy6rNFvj9vfuZH0Eqt ZvfTGkfYwn6L0Yi7M2GvhijyIdDnfGG9HJtVkyAIMn8supY9ONX67qUdvvpUkPOAZaOW +pKw== X-Forwarded-Encrypted: i=1; AJvYcCWHBzwdDFZCSDw9m0eo7LjQ3toHD1N9+JEEG4C6q4R0ZM9ufCEAyVUSIB22Tu4N7RrFSmEW2KNWmajCS+shUEYhYAxa6+QNEcmrSStX+r0jB60JC0fD1Rm1+eVJtlzU3wB5AyEfy1lgl/Ih3trzD+glMOlHnyXc7LwrAwpgd5AiIQ== X-Gm-Message-State: AOJu0YyTkdtoSTuBPGk/tQXmeXHy08hhhDDM92mMyImyEvddTxraGmcW GxHxtT536K8r2a9mX/NEnComXIxIit7nCPujd5ZPPMEfihVsIodh X-Received: by 2002:a05:6402:323:b0:566:a822:990e with SMTP id q3-20020a056402032300b00566a822990emr9600720edw.38.1709716657310; Wed, 06 Mar 2024 01:17:37 -0800 (PST) Received: from ?IPv6:2003:f6:ef1b:2000:944c:cbc7:1e1c:2c47? (p200300f6ef1b2000944ccbc71e1c2c47.dip0.t-ipconnect.de. [2003:f6:ef1b:2000:944c:cbc7:1e1c:2c47]) by smtp.gmail.com with ESMTPSA id c8-20020aa7d608000000b0056470bf320asm6714469edr.43.2024.03.06.01.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 01:17:37 -0800 (PST) Message-ID: <39147ed6f3ece627ee0c18d90e00b37e636553f2.camel@gmail.com> Subject: Re: [PATCH v4 2/2] of: dynamic: Synchronize of_changeset_destroy() with the devlink removals From: Nuno =?ISO-8859-1?Q?S=E1?= To: Herve Codina , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Saravana Kannan Cc: Lizhi Hou , Max Zhen , Sonal Santan , Stefano Stabellini , Jonathan Cameron , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Luca Ceresoli , Nuno Sa , Thomas Petazzoni , stable@vger.kernel.org Date: Wed, 06 Mar 2024 10:21:02 +0100 In-Reply-To: <20240306085007.169771-3-herve.codina@bootlin.com> References: <20240306085007.169771-1-herve.codina@bootlin.com> <20240306085007.169771-3-herve.codina@bootlin.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2024-03-06 at 09:50 +0100, Herve Codina wrote: > In the following sequence: > =C2=A0 1) of_platform_depopulate() > =C2=A0 2) of_overlay_remove() >=20 > During the step 1, devices are destroyed and devlinks are removed. > During the step 2, OF nodes are destroyed but > __of_changeset_entry_destroy() can raise warnings related to missing > of_node_put(): > =C2=A0 ERROR: memory leak, expected refcount 1 instead of 2 ... >=20 > Indeed, during the devlink removals performed at step 1, the removal > itself releasing the device (and the attached of_node) is done by a job > queued in a workqueue and so, it is done asynchronously with respect to > function calls. > When the warning is present, of_node_put() will be called but wrongly > too late from the workqueue job. >=20 > In order to be sure that any ongoing devlink removals are done before > the of_node destruction, synchronize the of_changeset_destroy() with the > devlink removals. >=20 > Fixes: 80dd33cf72d1 ("drivers: base: Fix device link removal") > Cc: stable@vger.kernel.org > Signed-off-by: Herve Codina > --- LGTM Reviewed-by: Nuno Sa > =C2=A0drivers/of/dynamic.c | 7 +++++++ > =C2=A01 file changed, 7 insertions(+) >=20 > diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c > index 3bf27052832f..169e2a9ae22f 100644 > --- a/drivers/of/dynamic.c > +++ b/drivers/of/dynamic.c > @@ -9,6 +9,7 @@ > =C2=A0 > =C2=A0#define pr_fmt(fmt) "OF: " fmt > =C2=A0 > +#include > =C2=A0#include > =C2=A0#include > =C2=A0#include > @@ -667,6 +668,12 @@ void of_changeset_destroy(struct of_changeset *ocs) > =C2=A0{ > =C2=A0 struct of_changeset_entry *ce, *cen; > =C2=A0 > + /* > + * Wait for any ongoing device link removals before destroying some > of > + * nodes. > + */ > + device_link_wait_removal(); > + > =C2=A0 list_for_each_entry_safe_reverse(ce, cen, &ocs->entries, node) > =C2=A0 __of_changeset_entry_destroy(ce); > =C2=A0}