Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp991196lqs; Wed, 6 Mar 2024 03:07:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWRNYpVdPaWmlpkVegFfd+eRDwiBbO79J5aoWHQck1gtjFrnjicG3S4Z28uoNkRu0Ovyms3jzSTZ6WnKvqJLFwO4wGg9cz7DqtPzEK/lQ== X-Google-Smtp-Source: AGHT+IEQm7PBVLOYrCv5imEeewl6C23g7Kvl5tNdBC4xoI2CFkFoKybUbpUZnHdmuNZEttYHDVhi X-Received: by 2002:a05:620a:4626:b0:787:ef33:4e0a with SMTP id br38-20020a05620a462600b00787ef334e0amr5697870qkb.28.1709723265313; Wed, 06 Mar 2024 03:07:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709723265; cv=pass; d=google.com; s=arc-20160816; b=SKO5NBGEs/C9gP231jV9clE4nJ4gu0smhwSGiUg9Aos+FXhN/Jg+kD/7rKfP3F/fu3 QynD5RJFZZM1nD3eYvdUAOPczNFls4NZ2GmGm7GzhPwVvPBygaoDTs1FuJMCZzxFqSr7 baJBu9uyyED0vwu23OvjCdcuxr1t0yOuXFJIbsz+CVre0tTohpHlCV9HId2sFPrxP9Q0 Y0oWo8o7ygl3F7/7evajSMgRSuXY0/FqrY3mFec45HLZsszIOzurQVYC7Q53DQgJS1Qi HZtchDAa3ACGuS8zOJllfxM8KklzvUbbWxbVsQj8pGd3evgL7C9GgHkbTGGp8Hk1ilpC kRtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=LkpSPLFwPA6sIr441GTPKMTLs5vOapZYIPq9ZxQdhg8=; fh=jsz1DORfJp9gBGcJQM3cETWRyADoFl+7+Bj2o4KUwoU=; b=ynW9JOC55tso4QB5Qr84N6UAd7RmsTgUGh2Wqe9poHCPbmRPgF2FsmPzwxL+FQjlYE RZAAUoz89UkAuWFgvTbAb+wzmgOXw0zoSryJZiOf2YDMh1b9BgvU/8LDvCRdH9oLdB47 FKF0ENqiENO5QKS3KCu49Zth5DBNHqL8gkqrOV/2xx3hakUPOI4ojrDtGLwe48LZO2E/ NJavYtsDixsv+2/GWU95+w7y1yBcYjb1PTb540xDKUqWWkpsBKst75F3X3MJWUrYOPQD IRdLYijXrDYSzecnSgbxS7Q7LJaOkq01S5Uqoyj7TCqlmpEoHX7iQv9lagERIHoavCqE IQvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Wlal6nzd; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-93832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dt44-20020a05620a47ac00b0078821b62975si8188576qkb.744.2024.03.06.03.07.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 03:07:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Wlal6nzd; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-93832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0EF0C1C21CF5 for ; Wed, 6 Mar 2024 11:07:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95DF877F0B; Wed, 6 Mar 2024 11:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Wlal6nzd" Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 0D876762D9; Wed, 6 Mar 2024 11:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709723244; cv=none; b=GVo4ScYLU/sGVURcQAWe/tZEz83ke7pI1ktAUEHwvKYmGi7+CDVsn3hYVqbA4H5+cH5z8Q+IttxJitXhtfZFRGHeBW8PiZhuDTFUaJrWb6EYWC383veOOtpYAXCMYlRkJwWD7xtf02Ub/DLGp8OGF7p6RvcC6LqXzgCLooAqyM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709723244; c=relaxed/simple; bh=dhUYkisSRgaEsKU54+0TtX8xvTK2vt6Z1QeO97lvAIQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e8NZSW7cRyeSP3sYLEfRzvXb3PgyPnWoP12XOYEU5+XWR/kb0PRTW6JPDUIXWlXDLiG6C6Bs4Q3HZXFZ/rApSH+ZGflILk36ciVAY/iDJQuSn9Xl3sMx0EGsTEQb8V6C6hxdUnhzqTi8NWl/SfTFTlOax6tNqJCVLGlmSdaUKsA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Wlal6nzd; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 9772540006; Wed, 6 Mar 2024 11:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709723240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LkpSPLFwPA6sIr441GTPKMTLs5vOapZYIPq9ZxQdhg8=; b=Wlal6nzd3buzIfRLQsB5cqSN6nx1HoJ3I03GuUShz7k5AzVIlhhZC/dQJkiMZHplmw5yof UpOVZQRDUKyhnoanVLdafiTX3NSMPhUEbKzTbHfmJF8jyeK0M9UP6a4UrtHayFyGyMd1LC QdB+DLPHvRrphVoG5UHHTtm9Goze7bOlCWUrBN6kDe9ZHo8LUK5FSQOyIU1hBGqFV/mdq/ tDNGvii0WMUeOFmd8obQtT1y1wzKIMbJ0CUH+L+Y4fJjM8SuaOGlIcoubDNWGnwQl/igqd 3g1Tx7tHd3ztaOX9luNqHyTYCYGGES545n9dLDTlndXjMr+2KAg7hwnDvd7t3Q== Date: Wed, 6 Mar 2024 12:07:17 +0100 From: Luca Ceresoli To: Herve Codina Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Saravana Kannan , 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 , Nuno Sa , Thomas Petazzoni , stable@vger.kernel.org Subject: Re: [PATCH v4 2/2] of: dynamic: Synchronize of_changeset_destroy() with the devlink removals Message-ID: <20240306120717.524bcd36@booty> 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> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: luca.ceresoli@bootlin.com On Wed, 6 Mar 2024 09:50:03 +0100 Herve Codina wrote: > In the following sequence: > 1) of_platform_depopulate() > 2) of_overlay_remove() > > 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(): > ERROR: memory leak, expected refcount 1 instead of 2 ... > > 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. > > 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. > > Fixes: 80dd33cf72d1 ("drivers: base: Fix device link removal") > Cc: stable@vger.kernel.org > Signed-off-by: Herve Codina > --- > drivers/of/dynamic.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > 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 @@ > > #define pr_fmt(fmt) "OF: " fmt > > +#include > #include > #include > #include > @@ -667,6 +668,12 @@ void of_changeset_destroy(struct of_changeset *ocs) > { > struct of_changeset_entry *ce, *cen; > > + /* > + * Wait for any ongoing device link removals before destroying some of > + * nodes. > + */ > + device_link_wait_removal(); Tested-by: Luca Ceresoli And no problem appeared in my tests due to the removed unlock/lock around device_link_wait_removal(). Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com