Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp229704lqs; Mon, 4 Mar 2024 23:22:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuAwlKuPB18GoAFVwqx1e7frkMs3rDzz6lxRAxF6OoZHv9gEuMK5bu62xfz+jjjoEnkn9D7om30yws/RVRFVtdwKA0bKnzzIoFnu6N8g== X-Google-Smtp-Source: AGHT+IF8qjaYjbBtTBE/cjq/UpIF3UlC0DRr6Lf8IarQ3MS32iXu9JETE8JwhaTw7ZwPyGop3YPj X-Received: by 2002:a05:6820:296:b0:5a1:2a9f:c7a6 with SMTP id q22-20020a056820029600b005a12a9fc7a6mr1022197ood.0.1709623368121; Mon, 04 Mar 2024 23:22:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709623368; cv=pass; d=google.com; s=arc-20160816; b=My+DejyhdOZrdiR+vYPXVdyanIu0WWziblPMkUwXMSgAgA0dRo2z9lJ8cdM5UDcpA3 15m87i/3j9rk0XfYo5nNWVSgvROO6A4j7Fbmc42i5exMjoQJN1ezerj4t+9oD4wMdsx3 cRSAVNBgcu/LJJKSu9TKAGc6cYcF7PHtueGqvnKRljLNhcwZZ9k5dZnMcQsyHuxm+VsZ naEUhjQwkaVREWe9xv+J/xxmw7gdZvkkl08m/wOvia5yUeH9ZqSH4dsUnbXXcW2Nx9qR YXLQBclD9xew0qpgN5lS5ENiw3biWWN+kyRCseTtb2uQcPUaDmlz/FdjRYg783/BNX3F RKTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=SIYTczHVdxaeGArMm3hbe+IIsqq3i7S0WVZ3zb5Tdpk=; fh=Y6RU5p+te3s/KFJM8t52vXqBkKNTeLBDiD10bTLKxzs=; b=0J7VvYD/MmA349nqTN/+Vj0EMsCekCCYxoTKTpr9iAlssJhttYE1yI/wcTRqsodZUG H1Y8dGWcXrmCWdWHBv/EjjMpUh76SIgtcZVivBTaTfx7pql+nLERNtOREPndyFhBLcSn 1kVlShLYqAJBXgYwta6OwsRUc40pY4a7ZbrgWM62jbKcy6e7ig2Xx6LZaNzAZ3ZD9OZw ZZrjw9Jd3BGsfdJ7Re/crJSI4AhISedHX0D6tZqcqG8OS9cPCtYkRTHB39yMmEieVgKD 38YqsaLBM7Z89si0sGWEQNaDBzNp1P71doe9ZTI4v3PhJdqkaBXKopJk3pDk/N1Q7QnY AiCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RcYPXvoe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-91780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2-20020a656b82000000b005d771540eb9si10259413pgw.206.2024.03.04.23.22.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 23:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RcYPXvoe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-91780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D29DB20AB7 for ; Tue, 5 Mar 2024 07:14:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CADFA7E59C; Tue, 5 Mar 2024 07:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RcYPXvoe" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 0B8817D3FE; Tue, 5 Mar 2024 07:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709622857; cv=none; b=E9gP+bgxV4SlUWdETaDzK+MCc7oLJR4+mzLpe5X699Gk9KKd0iCQQVEr+rByQEVZX62OXbRobDTDufkbPxxmPeOURD36QDVHD1tzAR1XIDvXC25dZSFykA1kW9uK1st6cg83gKDGL8o4lIQR4ReH7L/+YMSBOR5VIDCilPdxkk0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709622857; c=relaxed/simple; bh=SIYTczHVdxaeGArMm3hbe+IIsqq3i7S0WVZ3zb5Tdpk=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=VmTg2XtLjcBWnavXudby+s+mGqGWDdUTyowmpIx9UkJUCT9xI9RKjuciK3KeOcD3MdG/3akjoo9Qh6iZELxKx+hmeLDFPiNIyzOXHkLmPaB3zjArFh3620oOyKMieaCmG9fo7zt/hT0ZGXG9WNOstYUERcco1YVPzkEKSLDpaas= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RcYPXvoe; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5658082d2c4so7267237a12.1; Mon, 04 Mar 2024 23:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709622854; x=1710227654; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=SIYTczHVdxaeGArMm3hbe+IIsqq3i7S0WVZ3zb5Tdpk=; b=RcYPXvoecgP7AKGs75WELWboEyeAfCL5PsVBnVAqmUa7CBbgtg+soUdvC5+oQaGmRF 870+T6Wznka/SqNdmD8TbqXh/wMnNchQH0Ri+Xf9M5d66RVMFKhbxoMuwswXmg/0WX53 7J9sbPj0Ze3fuRY6haBdWdE8835vOZBvjFkQ4sqocWRk6ohiFqneTd5sdNFhDwqo38wt 80qi/S4QQcxOZmhIaBg/KK0qCEstcUbK4s4PwVpaUTMQ/EuJStdVCe3oakkOP1R5i5XM uIlDQVbqH7jnkXApA24J4Se1zX5S/kP6s2jV8PpZyW5uijOgyM9hqfJkc984bMb9aI1+ W9IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709622854; x=1710227654; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SIYTczHVdxaeGArMm3hbe+IIsqq3i7S0WVZ3zb5Tdpk=; b=w2w7tSz+K0IOuaoyCg+D+FaccYeXpbWZglvezNug/FEPZ0gpdYqf8ihne1iHTqvvai ZThAlh56iSBvZSA2opLDBvkkzvOAoC3FfFSy6EC1SxHGerOwJs4o5OFFicv+yam+69Vs n3ABZKwBN1FrptQu5RUDCmYWexfygBxTNBLcQ+Gi72pu0a22KqKMhm5iGe9o8ud9/SQG 74WRmELELluHzPmvTRQEFiblLH2rb7b0X+e0MGuyGSioe8SgKWin/NrPcFa17cGU00VQ qdBh1Xxb19T6GTt2WsemyZ55ItSggWhBRH1uZ6rBRCghuXjrjAcSfIpdCzsYxnpMwLs3 aRqw== X-Forwarded-Encrypted: i=1; AJvYcCWD7rPzGGH9Oc4Z4nCTA2f9EHbc/OvSNttn4Il+TWHA1Qh7kEwJkGG7/gAenRuwLd766wkyxrZ3f/Aqh4SKo2VNQrkC/UBpRIlV94rNwl8aORHjpNOeVBAoMtC/DMQjZm5L7jKgNY6VoQ== X-Gm-Message-State: AOJu0YyHjjquVV2t3nw9olRnR3LfdzvwW7soKWAIQfr502ChALQGfW/b 063LPd3Qt6zERbS0+7pMgLtD78Z1JxR2zGyHjQKf2Q3Inh8BxQCY X-Received: by 2002:a50:8dc7:0:b0:566:131a:26ee with SMTP id s7-20020a508dc7000000b00566131a26eemr7127162edh.35.1709622853937; Mon, 04 Mar 2024 23:14:13 -0800 (PST) Received: from ?IPv6:2003:f6:ef1b:2000:15d4:fc17:481e:8afe? (p200300f6ef1b200015d4fc17481e8afe.dip0.t-ipconnect.de. [2003:f6:ef1b:2000:15d4:fc17:481e:8afe]) by smtp.gmail.com with ESMTPSA id h26-20020aa7c95a000000b005663b0d7243sm5455225edt.83.2024.03.04.23.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 23:14:13 -0800 (PST) Message-ID: Subject: Re: [PATCH v3 0/2] Synchronize DT overlay removal with devlink removals From: Nuno =?ISO-8859-1?Q?S=E1?= To: Saravana Kannan , 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 Date: Tue, 05 Mar 2024 08:17:38 +0100 In-Reply-To: References: <20240229105204.720717-1-herve.codina@bootlin.com> <20240304150248.GA211460-robh@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2024-03-04 at 22:17 -0800, Saravana Kannan wrote: > On Mon, Mar 4, 2024 at 7:02=E2=80=AFAM Rob Herring wrot= e: > >=20 > > On Thu, Feb 29, 2024 at 11:52:01AM +0100, Herve Codina wrote: > > > Hi, > >=20 > > Please CC Saravana on this. >=20 > Nuno, this is why I was replying to the older series. I didn't even > get this one. Arghh, I see... In lot's of replies I was mentioning you :) - Nuno S=C3=A1 >=20 > >=20 > > >=20 > > > In the following sequence: > > > =C2=A0 of_platform_depopulate(); /* Remove devices from a DT overlay = node */ > > > =C2=A0 of_overlay_remove(); /* Remove the DT overlay node itself */ > > >=20 > > > Some warnings are raised by __of_changeset_entry_destroy() which=C2= =A0 was > > > called from of_overlay_remove(): > > > =C2=A0 ERROR: memory leak, expected refcount 1 instead of 2 ... > > >=20 > > > 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. > > >=20 > > > 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(). > > >=20 > > > 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). > > >=20 > > > Compared to the previous iteration: > > > =C2=A0 > > > https://lore.kernel.org/linux-kernel/20231130174126.688486-1-herve.co= dina@bootlin.com/ > > > this v3 series: > > > - add the missing device.h > > >=20 > > > This series handles cases reported by Luca [1] and Nuno [2]. > > > =C2=A0 [1]: https://lore.kernel.org/all/20231220181627.341e8789@booty= / > > > =C2=A0 [2]: > > > https://lore.kernel.org/all/20240205-fix-device-links-overlays-v2-2-5= 344f8c79d57@analog.com/ > > >=20 > > > Best regards, > > > Herv=C3=A9 > > >=20 > > > Changes v2 -> v3 > > > =C2=A0 - Patch 1 > > > =C2=A0=C2=A0=C2=A0 No changes > > >=20 > > > =C2=A0 - Patch 2 > > > =C2=A0=C2=A0=C2=A0 Add missing device.h > > >=20 > > > Changes v1 -> v2 > > > =C2=A0 - Patch 1 > > > =C2=A0=C2=A0=C2=A0 Rename the workqueue to 'device_link_wq' > > > =C2=A0=C2=A0=C2=A0 Add 'Fixes' tag and Cc stable > > >=20 > > > =C2=A0 - Patch 2 > > > =C2=A0=C2=A0=C2=A0 Add device.h inclusion. > > > =C2=A0=C2=A0=C2=A0 Call device_link_wait_removal() later in the overl= ay removal > > > =C2=A0=C2=A0=C2=A0 sequence (i.e. in free_overlay_changeset() functio= n). > > > =C2=A0=C2=A0=C2=A0 Drop of_mutex lock while calling device_link_wait_= removal(). > > > =C2=A0=C2=A0=C2=A0 Add=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 'Fixes' ta= g and Cc stable > > >=20 > > > Herve Codina (2): > > > =C2=A0 driver core: Introduce device_link_wait_removal() > > > =C2=A0 of: overlay: Synchronize of_overlay_remove() with the devlink = removals > > >=20 > > > =C2=A0drivers/base/core.c=C2=A0=C2=A0=C2=A0 | 26 ++++++++++++++++++++= +++--- > > > =C2=A0drivers/of/overlay.c=C2=A0=C2=A0 | 10 +++++++++- > > > =C2=A0include/linux/device.h |=C2=A0 1 + > > > =C2=A03 files changed, 33 insertions(+), 4 deletions(-) > > >=20 > > > -- > > > 2.43.0 > > >=20