Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2061490rdb; Tue, 20 Feb 2024 16:20:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQe0zoKSMxw4hDIMfSrBn+IFEbRBhQWGN4rqhL0QJrT7C5ahNu4AT34Y4y6fYGQaZFECIwkDij643SwbUsg1bpPR5tAnS/evLIfDo49w== X-Google-Smtp-Source: AGHT+IGp7JOBHcTKuyfmlYveP6ALySWLfVF/c0lUBzkTZWlRdEXvU4lrEU1vcWmUJbY9sFsi++K2 X-Received: by 2002:a1f:c483:0:b0:4ca:80c5:753d with SMTP id u125-20020a1fc483000000b004ca80c5753dmr5876260vkf.4.1708474826732; Tue, 20 Feb 2024 16:20:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708474826; cv=pass; d=google.com; s=arc-20160816; b=XBQJ4SkmIysusirEtKWdRVsF1d6Ja1VWlL7aqCnXs5/WyXBdii3vEcJaIZLL4H0OdP UZ0kFoRaXCI9Pd6UrhgXvi87JtifKBHi3jqSHLYEm8zqbflM2rzHmBXf2RKnIXiKsMHG RXGKeHlRCVVh87IRXNw8y96NmpmejJllBVJ2CstD0WiEwjCYrI3WS8MsM4rU19vGlq5j jPRiakgg0rtj0YUFz4iZ18k+C1yVcFRzcBzXdPmokq08nbmnh858U53Cx0ZYDX9bOzfZ YnoC3lMg8sS56uqcJ7aacLL89s+4Z5ymvFEJm+Ia/crRksCoNp4juWLPWWOPX0r6i5/M 2Mqg== 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=Y/TQWtFPNQYwuUbM58vJfJouHPDo5TFgHn3V4mtboY0=; fh=rz3T9IhkUqve2KcCNngfRxGLVDD9tZ1dBaRxaamoDws=; b=CTOKQ4FKuOSewJqJbQHZBj3wXpbbkYBn6DaBBxdctJRxYEkQ6bAIGm3UMn3mOvnxdV ZM7/Nt7RxExBjvH8N3osohLzZ2MMmIfV6efpjEIBs8S26553LDZ4vtlgiWIgN2e9izJH HzjU17cDauv4N9oKDQAu/o8ry8BCOpkj/4ZWxPz5o0grbLlC/LDtSFzUAknznpub71zM WGIhJOxe+DrKGZEG59MSX9Mrwx7ponCtFtZ9yC+FXkT5IYCiOKyEmOoW9PgPXIy9icdy c0ZC+XDj5mpGXN8TrO0k1nX8uBeVrO+bpdEwL02LlAcKHlo88elJwxy/p3dml0IMp+pa mYOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cbe9sLT6; 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-73857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 fv15-20020a056214240f00b0068f8b4085ffsi3520026qvb.567.2024.02.20.16.20.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 16:20:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73857-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=@google.com header.s=20230601 header.b=cbe9sLT6; 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-73857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73857-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CE0431C218FD for ; Wed, 21 Feb 2024 00:20:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF38D1FDD; Wed, 21 Feb 2024 00:20:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cbe9sLT6" Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 6FF87386 for ; Wed, 21 Feb 2024 00:19:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708474800; cv=none; b=E4MeWeOf3h+91S2fht7RjQccoT726KXDB+ScUprohJLRwZCt1HmqCK7P456ZpjTF4VyDWIkb+fKTffpsxBRnQXrrWmVOCuywx5q6+JeNuUuB4TP337a6OMiJu3+pVMvzf1Qr7ianlMrA6oxOIYueZvtLRKV3q3U/zAEI7CI2BNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708474800; c=relaxed/simple; bh=3OGmQp9jl/lZp1xDC/yACtLHUmqxrcuBnE1lkKvfFjc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IYnDQGsH7Qr3bLUQ+3PhbhcI8ka+Vu5XmFB8FkyL9MIf50xC1XfEv7IWlGb2Ad7LVUge8I7vP/GsjIxm6W+c+lbHMxP330D6pvgJczUyN0kf/ZENGcK0VLtUFOtn3svFOCJ5z+bJNv5CcHSFji62yg1R4kx56YZZz9jRayA5eO8= 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=cbe9sLT6; arc=none smtp.client-ip=209.85.160.176 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-qt1-f176.google.com with SMTP id d75a77b69052e-428405a0205so77981cf.1 for ; Tue, 20 Feb 2024 16:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708474797; x=1709079597; 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=Y/TQWtFPNQYwuUbM58vJfJouHPDo5TFgHn3V4mtboY0=; b=cbe9sLT6NBJ53qnrkItt+QfhMVdbzUzxbsjZGYYta/jIRaVA3Xk8RT4cT8e8dDjCbH 0gwgLbIxQmRTppKGo+kKLZP3UbS2yHLox8LXJLN6he6yzFGFEA3jP1X2ykWNMkfOXgMu +VQJduYJ6FtTrdXn2s3G1suduUjpwyaP1qzIOQMZckXaVJw/i1Izew7CvpVdgL6yW6fr 4BGslG7cGIo8+tC21MdK6F5wEcY629fFiIO7K4yCjO6eDFWoCxcBgzKLxW6jaLHnSIkx 8+l2pvySGCy9FTu8g4nfBPniqnhE74DhYPNMH1BXSIohvs2UsPVLGLI34AT1SgULfbwD wJsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708474797; x=1709079597; 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=Y/TQWtFPNQYwuUbM58vJfJouHPDo5TFgHn3V4mtboY0=; b=gVje25sjcuAYX/HGu6xfqDNsQYC7lW7tFaHar0Swmu87s70a7S1CqknDIe7l2ar9ka iC/jlmbNT/VMhgrxFi/qo3+JGqwRfdshAqQN/Naq9eWOQK7Xrm+9Hz7UhdWavEcMZrxA zrN8txJtL1CyStS62GGXf6FOM1jsD16pJ3OIzvjqGBZQD1bE2VozrTXqZRg7UsjEQQX5 Qt4GjIrrYNQT9Y/lH1+AxGKAlPg2F2naPDqUJG5a6m8qNPgVWkNh/v+IdKzYmS/c6DjM KI/LoAl8q9TxK4U4HR2v/eFKxdQqHqzDXyi68BnHEv9VfjpwfzcnoDXsT8QupMcb7TzZ gjtA== X-Forwarded-Encrypted: i=1; AJvYcCUt7UH5qgN6mjZT1HMQrRq3/LoyIQKslITLWzf2ooY3xddtBHbaXpA69w5Ztxqi3vao1ZwMAcCCgrkQuR4D6wLKILKkjyF97c6uNHPS X-Gm-Message-State: AOJu0Yw+Jsii4IrvPetV9HuhatfVNGF2g0nyJGefkB1ajvcClICew2E8 LGoiazaoEL6owH1WeTE9XtYUGotmGgKUrwP7OvJ02JmptOw4PzWprHUHJ7Z4/1RXmiPcf2lwjzk X86v0wIsg4QKWktZJFsiaEEbiduLXuHSkmDS1 X-Received: by 2002:ac8:6ed1:0:b0:42c:5fd3:dc85 with SMTP id f17-20020ac86ed1000000b0042c5fd3dc85mr43812qtv.7.1708474797183; Tue, 20 Feb 2024 16:19:57 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231130174126.688486-1-herve.codina@bootlin.com> <20231206171540.GA2697853-robh@kernel.org> In-Reply-To: From: Saravana Kannan Date: Tue, 20 Feb 2024 16:19:21 -0800 Message-ID: Subject: Re: [PATCH 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 , Thomas Petazzoni , Nuno Sa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 6, 2023 at 7:09=E2=80=AFPM Saravana Kannan wrote: > > On Wed, Dec 6, 2023 at 9:15=E2=80=AFAM Rob Herring wrot= e: > > > > On Thu, Nov 30, 2023 at 06:41:07PM +0100, Herve Codina wrote: > > > Hi, > > > > +Saravana for comment > > I'll respond to this within a week -- very swamped at the moment. The > main thing I want to make sure is that we don't cause an indirect > deadlock with this wait(). I'll go back and look at why we added the > work queue and then check for device/devlink locking issues. > Sorry about the long delay, but I finally got back to this because Nuno nudged me to review a similar patch they sent. I'll leave some easy to address comments in the patches. -Saravana > -Saravana > > > > > Looks okay to me though. > > > > > > > > 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 = the > > > of_platform_depopulate(), jobs are put in a workqueue. > > > These jobs drop the reference to the devices. When a device is no mor= e > > > referenced (refcount =3D=3D 0), it is released and the reference to i= ts > > > 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 call= s. > > > > > > In the sequence provided, the jobs are run too late, after the call t= o > > > __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() i= n > > > 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). > > > > > > Best regards, > > > Herv=C3=A9 > > > > > > Herve Codina (2): > > > driver core: Introduce device_link_wait_removal() > > > of: overlay: Synchronize of_overlay_remove() with the devlink remov= als > > > > > > drivers/base/core.c | 26 +++++++++++++++++++++++--- > > > drivers/of/overlay.c | 6 ++++++ > > > include/linux/device.h | 1 + > > > 3 files changed, 30 insertions(+), 3 deletions(-) > > > > > > -- > > > 2.42.0 > > >