Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp484183rdb; Thu, 30 Nov 2023 09:41:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEPEeL+7lO4kC+uZmslnFBSn58qc5VEBUSMivb1k90pWL2C7K89wb0YU+A58PPBlqiDAkq X-Received: by 2002:a05:6a20:8427:b0:18a:e4ed:cc41 with SMTP id c39-20020a056a20842700b0018ae4edcc41mr27046456pzd.23.1701366108456; Thu, 30 Nov 2023 09:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701366108; cv=none; d=google.com; s=arc-20160816; b=JrlfOnZvxCrHKq+smJIzRSitpN9CX4SmxA3/0sbFBTnez4mWV6dv1ys2SoiD4yNpDO a5L3FtHA6ipldze5wT5fT6WBvw1g1tfpBiWJC+ltF9sP7/1z1WNqeUc8ot8yAiRoGYVm dQ+fa+oLeF67mYpx3PVZo7ubqXT6GHdZuTQdaucvE6+JVhj28ay3JA4tuM1X1uEUcTUa NsdqFJfab5BhInXAPjMIxXBogGXLXDgiFnBeyAdJT9BAV0Rd69tYlhJMtgraky2+tj1/ QLUHDw1UtkmlUnOhdML1Z3XZqbrt3L0NcSGOJWHj8N+9ZiEXu4VfMOg8Kg1veKvvF+SX UJRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yvt6xwQtma5BgVNgEWdmqb5WwlVdI81bFmTFIjob+Mc=; fh=hxCb8OzaXBuSbXNrdSfbxd9E+OOUaTeXTLLu8usFTUA=; b=GRAEPuiLFDNICsLmnOJQiCxzupMgA7N9oi+p/owI5Zw1COp8FD9q0LhH/HqKb124ER pRPX29JzbuiHYm3Paado8XgNC3JQJvhiASRQBXPEZmD76cn3VMJsSn8zSpHV7aE31T1i UnDhytMfxzMjqFD+DrcPLe9swJ85zmTR56Wqqmd+mZ1Yig70tJS+m4eE/62aqsThJoTb 1hLPdnb7CF9+htBxG6qObopuulZlI1O3vcxdax37ufUCzKTdPjc3Vgf9njF7BJZehu49 uP+nIdTRq4aj1Iq5OZtEbArhyqSNm1J7VykrwNAck3A2izV1u5XSEzXXsJEeKR4qDbRN HBkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YoKRgwhA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bo23-20020a056a02039700b005bd335981e2si1909178pgb.678.2023.11.30.09.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 09:41:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=YoKRgwhA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D798B82CB86B; Thu, 30 Nov 2023 09:41:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345951AbjK3Rl0 (ORCPT + 99 others); Thu, 30 Nov 2023 12:41:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232284AbjK3RlZ (ORCPT ); Thu, 30 Nov 2023 12:41:25 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B547131; Thu, 30 Nov 2023 09:41:31 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPA id 96FB71BF204; Thu, 30 Nov 2023 17:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701366090; 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; bh=yvt6xwQtma5BgVNgEWdmqb5WwlVdI81bFmTFIjob+Mc=; b=YoKRgwhAp78MJzd93oCesNXjw7Ycio+S7kvwK1i6xHARYrwsm3Wa6UMaMTzGYHM8bjZoWR vaHXZBcUrq/VEkYwbGp3kQyUbUGz+EuKc2OEqsZQEITDz+ovTU3Qk6lmBb8NzvOyCEzm6E RFWjvcAbKVUmLyk/eJJ31bDYUqdblg+w5aQPk+WE94qXsxAT/ABy63L31xjvdwnbtOEstw Gulzu+gVIApBU7xqWc65mKE10z1INu57LVSxd3I2penHHX204ZOcvU8VHNC9ybVkDedMJg N9pz+nzZ8VUMA9UROmEldwIbDjtSo6GR5bTN7ODHKx4Cc28ukjYUNszj73f6uQ== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand Cc: 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 , Herve Codina Subject: [PATCH 0/2] Synchronize DT overlay removal with devlink removals Date: Thu, 30 Nov 2023 18:41:07 +0100 Message-ID: <20231130174126.688486-1-herve.codina@bootlin.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 09:41:44 -0800 (PST) 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 the 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 == 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). Best regards, Hervé Herve Codina (2): driver core: Introduce device_link_wait_removal() of: overlay: Synchronize of_overlay_remove() with the devlink removals 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