Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2840878lqp; Mon, 25 Mar 2024 10:40:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbwUbyh0XyuInQ4qw6NQMIT8J1c4gBu81g7keCxDpACuirTI22F4m+ZhJNbvrXNoSFBGhtWgyUHlMFUMfIttybdYAcXPBvergPJXsrHA== X-Google-Smtp-Source: AGHT+IGLt3fMKz1bMc/0YFjDHgdFRLb38wo6et+OQ6trJH5t6dLnfZ2D1ujFoy0zcmgPCdkCbT6w X-Received: by 2002:a17:906:3e5a:b0:a46:98fb:e81a with SMTP id t26-20020a1709063e5a00b00a4698fbe81amr5047589eji.1.1711388405138; Mon, 25 Mar 2024 10:40:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711388405; cv=pass; d=google.com; s=arc-20160816; b=G49ekgVCyvqpcgKRKlhygDve0VaZSkHfl8dGJNieMWVP4qpXn7m7IQqckkpc89B/pB S+Vq8GLHBbZLG4PnSAP0YVq1newZjBM/H7A8l3OHfeHfTiHNYDY6rdbn70A4676qh6Wg L8om5QAzIvPEjLzfKdxElA3x+ZoFKzE5UnJDAi7G+13BcnGwJ4gQdweC+1bDeqzt4yg8 LuiRuWqNdacKeafKxdREre2yaZA5GJrMoBEVsTqzPQNam0eP+rqC/R06VMyYixd1sey4 07DFe2+sizU1232CPqzIuLqHn8ZSoeM2bnwgPdI1KK19piOp7Cjdd3FFDE11bpi/s7Zz oFjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qGjr09xifQyFSkyKkNvdVMJHu8YDK+1hTHbALKnpSRU=; fh=bTZik+42/9Ir500dlr3sCMB2tmWVuqeaNJUtiD3H4OY=; b=07XGTL+e/SbfRJpgGlAX5EE7QTfpYMHI1aW6O8KWKJRV0GQxVLpTxM2cFbcyxCU4gM fgWgR1yCjjnAEnghcedEClw0YmGrcJrRRqOAORzXizViq2vAQngrofef/U6TKRs9bdEo gDEnrKzSutSXVb+Ep9Yodb4VzjThOKFTu6j7GZAMeeAqHqPGJdJhbkeiM8e+lPwoTCym A6AwFAhn4B155wUhCK/R7uERHQWWTCzSuXQSWfdztNA0FQlFDj/QeCVcGZfsSK9kmZzL FnBstUG6oE+JNcuHaB82/OUANQT1DfGxio/t7cVmfwrEgS0dK8LwHRbAqbuJwoUQ2uu7 9gCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sh1wH5Sj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h18-20020a1709066d9200b00a498917eaf3si1203829ejt.684.2024.03.25.10.40.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:40:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117493-linux.lists.archive=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=Sh1wH5Sj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117493-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117493-linux.lists.archive=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 DA8421F21CD8 for ; Mon, 25 Mar 2024 17:40:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EECF0149C5E; Mon, 25 Mar 2024 16:44:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sh1wH5Sj" 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 142B312D747; Mon, 25 Mar 2024 16:44:03 +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=1711385044; cv=none; b=n5eqUGgW8rKoGOvgMcxnvV/CInMWdMjKyqlTUT+dCxZGnWfqeTnMBzlgVpV6Pgse+Cu2VuNL9gM9EndtzzLW9SxRQZlz7rHwdmXRj0yNzPfSCSKTOAlGA7t/+cFHPTRE3pBsTjlWhjUEm35SZjcrQXH/DmMWVUG47nVMPCB+gAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711385044; c=relaxed/simple; bh=84lb1y+TpjyavnkWNmwchbU884Msl6lsLUlg6T6K2bo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kAz/3HgKB/MLXJwEQMu4x5WRB5kzMeFYWMWXawYw5d3Gs3hEsP/FnYmZxderb4n7zSf4O2aYVXESclnYHicBNWTiOlliCrZwqHqj1YMX1BGdGirLOHLIrlz+ALt3flDgHpz+gmoVZ6Qc8U5uLLetNqJvu9wjiiZ3CIBDD+2ojD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sh1wH5Sj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AEA0C433C7; Mon, 25 Mar 2024 16:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711385043; bh=84lb1y+TpjyavnkWNmwchbU884Msl6lsLUlg6T6K2bo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Sh1wH5Sj3Lqqu5aNqrEAtLB2OUcyRZ67//17Djc+hwmqvqKd8UyaqpBP25ZGdE9zW r1a+IUdVJfByjvFc7kTzQaJIS39mYunvmw842g+D5kj7vlVCBv42uJaoAm+Dsr0Ou5 iJpcD8ICTfFn9MZFrRK85ta0LpLmTo3z4RCTsB35vQlvbuNHd53tybRLWd3HhoHtaF ZlVr5Z7lI/JDWM9AFgMp/zTjI0zVBSy49uAHIxJpS+SeJkEfjDUizK4ViiAsoIDp0G 2rmo1UEVy8ibTSgPuU13Kg97JgagmhMELwdvpey+yUzeYfSe0kDdQACII+gcCE/O6F 9nUNDizpDDSbA== Date: Mon, 25 Mar 2024 11:44:01 -0500 From: Rob Herring To: Herve Codina Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , 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 , Luca Ceresoli , Nuno Sa , Thomas Petazzoni , stable@vger.kernel.org Subject: Re: [PATCH v6 1/2] driver core: Introduce device_link_wait_removal() Message-ID: <20240325164401.GA276583-robh@kernel.org> References: <20240325152140.198219-1-herve.codina@bootlin.com> <20240325152140.198219-2-herve.codina@bootlin.com> 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-Disposition: inline In-Reply-To: <20240325152140.198219-2-herve.codina@bootlin.com> On Mon, Mar 25, 2024 at 04:21:25PM +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. > > Cc: stable@vger.kernel.org > Signed-off-by: Herve Codina > Tested-by: Luca Ceresoli > Reviewed-by: Nuno Sa > Reviewed-by: Saravana Kannan > --- > drivers/base/core.c | 26 +++++++++++++++++++++++--- > include/linux/device.h | 1 + > 2 files changed, 24 insertions(+), 3 deletions(-) Greg, can you ack and I'll take this series. Rob