Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp991786lqs; Wed, 6 Mar 2024 03:09:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8sl3lav5LdQkElBhvSOxiUiUkL7Iwsd8xRDuLz1aiZ6Qx3cQbDhE34GPxkHuDrBmyoSqrn4m51kQiOLTL7/99kr3dgCVevV2CEwFKNg== X-Google-Smtp-Source: AGHT+IGqc01VCdImctS3m7PJiCe+Q+ODbdC/l7tc8m2VwNfQ4bNnaCEpJriLIy0gLmVekSVPNScJ X-Received: by 2002:a17:902:e84c:b0:1dc:a84b:e83c with SMTP id t12-20020a170902e84c00b001dca84be83cmr7076278plg.25.1709723341488; Wed, 06 Mar 2024 03:09:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709723341; cv=pass; d=google.com; s=arc-20160816; b=WJ0UwF/hM7bVa8geqn13+5ZkShAdOOm3ruyiRWEzJHQODpeeTgY3Cp+dAsHmUTTGUT gFPqBs9cp3bTdRNGIIfCAIZ2NAwBUFpFJiruPGASeF2vvTVfkZQQ7e4XhcUDBOqx6PUr MwVz/n/9B+YQU9JKZTR4jhlYi3Vwgf2g2zsrDc3kjv8GPv4c22Hw4DgbSbv0lgkIw9Md Fz2M7jUjiBqwdsKVxUrpe79haErR7Z7OYuAOLwEf8kmUBEQkZ4M6QWUpXZ5zZ0utiVfW gj6pfqh7btxKLobEMiztaJUBOuOnP6oW/V+7NdEXm7BNbvJFOvcJozfhjudFcmSipkUB iFug== 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=ZIfGVlbA1FFow5uYZDJCt17nXjkwv9ja0Xnzy8zYKwg=; fh=jsz1DORfJp9gBGcJQM3cETWRyADoFl+7+Bj2o4KUwoU=; b=tVR0j9ZoNh5Vc0CZe1myDlI2VHBrACVgAc8c6LKA0FAZfgxMpyefqpi9sy5iKvfFhY uEk8X8UOGQpec7UO56RRgaf6moxb8Phs93iYDPN70SdCuXYlMyfXUNxWINqyKp3jNt8v 46xoJudAAhGpnw2HOX1Mwn/HoMP0Hn1f2cqpDo76wyU1K9VQwg9nJm+V63xHL7yak+Xk Tib+HSv+xV5mUUdpot/5ayOCWmYyf89qFdSjPkaWkMgUHDn7QA4vuCeD3qiLMr7l5Y39 I5f2ajm7ufxse8G8imZ5k4n26OQhPtDY4QCk6Umvzfo1TF2UiapY9dySMxFHU7LFLUki bJ7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bwroREav; 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-93831-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q17-20020a170902e31100b001dc8570604fsi11160209plc.440.2024.03.06.03.09.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 03:09:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93831-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bwroREav; 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-93831-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93831-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 41BF328349F for ; Wed, 6 Mar 2024 11:07:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B85AE7602F; Wed, 6 Mar 2024 11:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="bwroREav" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.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 DE3896CDCD; Wed, 6 Mar 2024 11:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709723240; cv=none; b=FVqw/itcLsc8QHtHaPY6hByQt+7vSuLLPSu+ry/NGqerepL1jB4iIY5LQ6Nvhimn61dnsKm9Ler07HvtD1xagMqi1M2GzEaBZx+8htmYhzuQ7ERDaq4PGxz7KpOdvCfdOrwRDCTFhvuHa9HV/7Umca1z7+zqnXVZKKehxnPsqjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709723240; c=relaxed/simple; bh=TeypHYztStanyeG63312ZYZhlqpeV7uIu2AEyXDDxv4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IX4DPwwbc9OSN2pF0M2pKPA28hrG8gWPIjkaY+N5XibBMq2x6puQsRAUQekF8NlUAr5fqKb42D/EIZv730yUbIKN2G0kHC8gppoXKRMk0Jw/XsAXQCCum79FyChisvUUf4IePPoXl+rSsoK9btMxbBf8q7pP18s/xpQSclTcG+Q= 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=bwroREav; arc=none smtp.client-ip=217.70.183.201 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 56A6F1BF208; Wed, 6 Mar 2024 11:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709723236; 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=ZIfGVlbA1FFow5uYZDJCt17nXjkwv9ja0Xnzy8zYKwg=; b=bwroREavWNoesHITsTtxo5nGKtTkiEl3iUl3Cgs62Z7ke4ai6/wPmPA1ZB3KJL3PJbRZKN dvHRenJRQkqLszi4TQfOpR9kdW1jIVnwuQtR0ha5IkfBwdA++v1/mOTq5I+hj6QhfhCFSm Y1HSZuwqLSRSHlqaqYZx3IsAhhyKpJ2EYUinnXulj/t3KLPikY0FyNx1uiDxCJ0L043opQ M+EwRgyF2V9ZQ0CBkRe/U3Z2V+N+uqcf7swidw+dAx2Nrh9b7SHnAgO7ZccdEnEOY98KhH wNmwLz3go2zkv8/PvQ5j63ftEWzVUIwDo63qIGBCqPqHfdcsnLDYXhvoebp6zQ== Date: Wed, 6 Mar 2024 12:07:13 +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 1/2] driver core: Introduce device_link_wait_removal() Message-ID: <20240306120713.6d7b9344@booty> In-Reply-To: <20240306085007.169771-2-herve.codina@bootlin.com> References: <20240306085007.169771-1-herve.codina@bootlin.com> <20240306085007.169771-2-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:02 +0100 Herve Codina wrote: > The commit 80dd33cf72d1 ("drivers: base: Fix device link removal") > introduces a workqueue to release the consumer and supplier devices used > in the devlink. > In the job queued, devices are release and in turn, when all the > references to these devices are dropped, the release function of the > device itself is called. > > Nothing is present to provide some synchronisation with this workqueue > in order to ensure that all ongoing releasing operations are done and > so, some other operations can be started safely. > > For instance, in the following sequence: > 1) of_platform_depopulate() > 2) of_overlay_remove() > > During the step 1, devices are released and related devlinks are removed > (jobs pushed in the workqueue). > During the step 2, OF nodes are destroyed but, without any > synchronisation with devlink removal jobs, of_overlay_remove() can raise > warnings related to missing of_node_put(): > ERROR: memory leak, expected refcount 1 instead of 2 > > Indeed, the missing of_node_put() call is going to be done, too late, > from the workqueue job execution. > > Introduce device_link_wait_removal() to offer a way to synchronize > operations waiting for the end of devlink removals (i.e. end of > workqueue jobs). > Also, as a flushing operation is done on the workqueue, the workqueue > used is moved from a system-wide workqueue to a local one. > > Fixes: 80dd33cf72d1 ("drivers: base: Fix device link removal") > Cc: stable@vger.kernel.org > Signed-off-by: Herve Codina Tested-by: Luca Ceresoli -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com