Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp872172lqc; Fri, 8 Mar 2024 14:30:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXZZpshacMo2MlFp2bDowNNG0R9ScO0rAbHjd8X66R/TiHX1smLkOt3HO7PmFcuperXtTHGRTiYv3q/4I4sSUe6/NHz4CVcqPGG0Knlg== X-Google-Smtp-Source: AGHT+IEWO9aZKu5TAHs7KsaqrKhFa89PHJWVahwe87HNJ0oKlnC4umQlXDREXVftctNpEs+DvNQd X-Received: by 2002:a17:906:7fd1:b0:a45:6d18:a80d with SMTP id r17-20020a1709067fd100b00a456d18a80dmr15160ejs.62.1709937018914; Fri, 08 Mar 2024 14:30:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709937018; cv=pass; d=google.com; s=arc-20160816; b=yQbsf5wrZU/7LpRzDnYAUfOgpfsX6tHTVtvTkBXKKl+ucmer2kRzhHQdcX5H1Sei6C Qjd1oEc/PZE31aIVAZg1WbRGlFk48uMz653s5TCH2BqMRjHT+1TKdWksQ0XfvTntEiGy /Y64kqHF06hWgOUH2kzEgEF970tCgfgZtDDTwXUF26LDKAXJKFKd8zxr8mPz7cRx/++0 oAzWCWQeg7Thlc870Ddv/GRcbH7ARYRI3o6F+6CIlzlh5egbiB7y7zd692U51BETLmpE Sbx+TvNU03G97DT0u16v9HAzv2+jNI+rhTwuj6Ofq5lEdEM4SOQzCDUo58fVVoT4UDpK DvwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=dw6aI2U8iMgTI80Vy6Cngmp1NxQFU6KchYrZWU57JZc=; fh=Dc/eihmJhE8mIN/Tl4mlkTgYYBRrN5S05KaehtqBxcA=; b=hDWGblpUAs2UhuGiLSaYrQZdvvVTfeQi14xcMFtdivmWK7mFDIHUTfTKx+jV1Zu9/M Tu1i0KUuWLURwBZ6IVYJfyRt54ZSd4vzI6tWKilcDULsIaLe3CwEzDkOd9ALh/ovlxE6 1S+OV99hPmKVqcAEhzJrBG/optT9yRypzldBJfldA8fYH46Puj9PzgHyT51LPf3ek+42 9hbCk/lpFG2yOkES54GJ0s71SBRynNXgF+LIzcoK4JQdaTf+h6JRTW9es7iyVRQM+Mu0 W0GYY4KqNsthSE47v2o4xzg3uP0KcXJTR8tHRJ7NIFb5+mSegQT9FT+OQ6ZJl5k6nM63 P2Jw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="RMXM/1Z4"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i22-20020a1709063c5600b00a3f2418fcb8si190465ejg.396.2024.03.08.14.30.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 14:30:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97653-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=@google.com header.s=20230601 header.b="RMXM/1Z4"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-97653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7BAE81F2266E for ; Fri, 8 Mar 2024 22:30:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68B572D047; Fri, 8 Mar 2024 22:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RMXM/1Z4" Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 9D5BF1DA4D for ; Fri, 8 Mar 2024 22:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709937012; cv=none; b=FWmB+XsNmzHSbDRnUrNDnoxBOwNvX8P24MXafw7rYMKnNFQdtGAklgpbz793sK9vSY7ZNJBOauxqyO/DzvRwIJYPy5dZC48/IFskwGDYUJYtvns2b6vO3LQbxdEJwuQ8flLDYZBvYPqUD6BQqLfxQkRNiUx9ImaOq9hOk8ffxhA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709937012; c=relaxed/simple; bh=9Yb0tKGCphHgv9gug9eNGiabFxNTTgVWrqYM7xEelTY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=jAaNoDCxxszrWXSfSd2lAEXtuQLz6iem/H/S3KIXx60Llq/NWulO8hicO9gQVH8GCX0hZ0s89dAoffkqPi+86ZYOoUImddYugjaky9KdODBosHFgi6LUgaR7bKtss+HxqECHlUfuUmeOXaS5F6GlqXOYADCrjAsAXhbpaxxc//Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RMXM/1Z4; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-566b160f6eeso1356a12.1 for ; Fri, 08 Mar 2024 14:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709937009; x=1710541809; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dw6aI2U8iMgTI80Vy6Cngmp1NxQFU6KchYrZWU57JZc=; b=RMXM/1Z4z5WvK1JBUjmaCvSsev/xeWI2Y2teE4rFz/rEKRW/r0YFPSBW/aXBucH1cE iFyEb7Fssk+641d7jiffEHsZHdtPdTxeMYoClieH1WxNhendz8/UdDxR9+sHGXd98Vvf 50wvLL9xNv39nBbwDUtJvKTELb9xhh0/mht+xFdSTlxyBdCkDWoDVq1/95a7XNZx2sAx Kqy8LeV1GBxOUM7VLT4Ge7bbTh630AdGFxkkPszwHftl/XUiJDJCMX49j1F+O9X/QVp1 NBrx+SHZG9Tvmr1PXDhzr2399poNHtiwX1mym+Epe7qQhbrBT/iJ8ohO/Qem4wbD0PbI JTow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709937009; x=1710541809; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dw6aI2U8iMgTI80Vy6Cngmp1NxQFU6KchYrZWU57JZc=; b=sCZRyZNIPEycC79joedsjOkwMeCoTVOiIX0yyT3r+2T9i05z+yRkFgMQSZF/sPDfzx 52LDIhynuCGT7kJIFJXZvNZ7aO06OAk8PMbX3MmOGHI2BjLN8N9ytyeZOsXOqcgmB6k5 aR+tGsC1hlcAuPx7bsabePo9K3g70DpoWuGf10zx5KQ3uJD3V4zeBPmpMbrqAjktJ9IZ hDYvleAicoEvIYGv7ZXQhNgKecMYGooZAdwY2xh1qJcXaSkieYTU4O9sBjM27xjrktLs NfGPWxNp6PtBcfYprswLzIJdXTveio+mOYZvEJVu9z0waxyfO8R+tE+scbDcnpwytviC IYSA== X-Forwarded-Encrypted: i=1; AJvYcCW7nVdR9MWSiiszn+H9mFKMnj9BakwkbdDC6TONyvnTzJnpweuOYq9S05NxavhFhruOAj94IHm9Ygen7YfyFRVWCRIp2jDjBp+Qwe6f X-Gm-Message-State: AOJu0YwpLI1uNbdScYlTcr4qxgpJ2b7hPOMmXJXPc110ODw39cAqKv5R +72X71d83N4ZOCbQ5xzx4aTg9c8CQOljgRxZIuofFfAJVr94N+7LbJqsxAxoymvhjiozfmm6Bbj 6PqU5exN7U/4syy1bmiGZu9CibdvA8wKo0FqL X-Received: by 2002:a05:6402:190d:b0:567:6314:c894 with SMTP id e13-20020a056402190d00b005676314c894mr721781edz.2.1709937008675; Fri, 08 Mar 2024 14:30:08 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240307111036.225007-1-herve.codina@bootlin.com> <20240308200548.GA1189199-robh@kernel.org> In-Reply-To: <20240308200548.GA1189199-robh@kernel.org> From: Saravana Kannan Date: Fri, 8 Mar 2024 14:29:28 -0800 Message-ID: Subject: Re: [PATCH v5 0/2] Synchronize DT overlay removal with devlink removals To: Rob Herring Cc: Herve Codina , Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 8, 2024 at 12:05=E2=80=AFPM Rob Herring wrote= : > > On Thu, Mar 07, 2024 at 12:09:59PM +0100, Herve Codina wrote: > > Hi, > > > > In the following sequence: > > of_platform_depopulate(); /* Remove devices from a DT overlay node */ > > of_overlay_remove(); /* Remove the DT overlay node itself */ > > > > Some warnings are raised by __of_changeset_entry_destroy() which was > > called from of_overlay_remove(): > > ERROR: memory leak, expected refcount 1 instead of 2 ... > > > > The issue is that, during the device devlink removals triggered from th= e > > of_platform_depopulate(), jobs are put in a workqueue. > > These jobs drop the reference to the devices. When a device is no more > > referenced (refcount =3D=3D 0), it is released and the reference to its > > of_node is dropped by a call to of_node_put(). > > These operations are fully correct except that, because of the > > workqueue, they are done asynchronously with respect to function calls. > > > > In the sequence provided, the jobs are run too late, after the call to > > __of_changeset_entry_destroy() and so a missing of_node_put() call is > > detected by __of_changeset_entry_destroy(). > > > > This series fixes this issue introducing device_link_wait_removal() in > > order to wait for the end of jobs execution (patch 1) and using this > > function to synchronize the overlay removal with the end of jobs > > execution (patch 2). > > > > Compared to the previous iteration: > > https://lore.kernel.org/linux-kernel/20240306085007.169771-1-herve.co= dina@bootlin.com/ > > this v5 series: > > - Remove a 'Fixes' tag > > - Update a comment > > - Add 'Tested-by' and ''Reviewed-by' tags > > > > This series handles cases reported by Luca [1] and Nuno [2]. > > [1]: https://lore.kernel.org/all/20231220181627.341e8789@booty/ > > [2]: https://lore.kernel.org/all/20240205-fix-device-links-overlays-v= 2-2-5344f8c79d57@analog.com/ > > > > Best regards, > > Herv=C3=A9 > > > > Changes v4 -> v5 > > - Patch 1 > > Remove the 'Fixes' tag > > Add 'Tested-by: Luca Ceresoli ' > > Add 'Reviewed-by: Nuno Sa ' > > > > - Patch 2 > > Update comment as suggested > > Add 'Reviewed-by: Saravana Kannan ' > > Add 'Tested-by: Luca Ceresoli ' > > Add 'Reviewed-by: Nuno Sa ' > > > > Changes v3 -> v4 > > - Patch 1 > > Uses flush_workqueue() instead of drain_workqueue(). > > > > - Patch 2 > > Remove unlock/re-lock when calling device_link_wait_removal() > > Move device_link_wait_removal() call to of_changeset_destroy() > > Update commit log > > > > Changes v2 -> v3 > > - Patch 1 > > No changes > > > > - Patch 2 > > Add missing device.h > > > > Changes v1 -> v2 > > - Patch 1 > > Rename the workqueue to 'device_link_wq' > > Add 'Fixes' tag and Cc stable > > > > - Patch 2 > > Add device.h inclusion. > > Call device_link_wait_removal() later in the overlay removal > > sequence (i.e. in free_overlay_changeset() function). > > Drop of_mutex lock while calling device_link_wait_removal(). > > Add 'Fixes' tag and Cc stable > > > > Herve Codina (2): > > driver core: Introduce device_link_wait_removal() > > of: dynamic: Synchronize of_changeset_destroy() with the devlink > > removals > > > > drivers/base/core.c | 26 +++++++++++++++++++++++--- > > drivers/of/dynamic.c | 12 ++++++++++++ > > include/linux/device.h | 1 + > > 3 files changed, 36 insertions(+), 3 deletions(-) > > This looks good to me. I can take this given the user is DT. Looking for > a R-by from Saravana and Ack from Greg. A R-by from Rafael would be > great too. Reviewed-by: Saravana Kannan -Saravana