From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796415666; b=bkEx5tY17lLmIsZwfhWMvi61GUaQxpybYiYtQoHLKO96zhK6/VBJsmxAlbqP1QvgscP3 2T8t83a77xYgRdv08OeP05JzxMnTpxV4JguICrFsxl5vgOcN3ss8chtR2I5LjOWEo8Qzp yZukjT3NAEAwUkUCJ+FurpVhCYtD+F25KwtzF95tmH0jgsoCZjsNEOK6o5Z7hmYPuYycY g6J3sg1OBAuyJyGWmx+3ODEmIIqAkDJ2NYucW9koYDRJita7d19lqrtNvvUfdBhXlhGpy Iy7TE35Zoc1ZMw9OPoDscUFqIOFvs0ojIKXzqBtkxmD7xIqtsyxmE26It1nr4MzrXCg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796415666; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=AvJgieb1XYS5pT/JSeYc6bY2LG0bzS+ueuojJGt4MdY=; b=fszv4YAI7R8DRVEESLWyvCLGdjtsMbioTshBSPfeojNW8FesBszWv0+uFR8vfmZuKcaZ gPEoTQQpbgu57DMrzulW2qqveN/AFzrh662j3C9av7DVyTCon0Y3JVXDNuJC8JGOAtCja 4RYEUlA/QzTibMa7msrJFJiL5YxhQYfcQkqy5anfAIS72umwAgtaI3Rw9WAmt6sUqYe38 BIbizWBoP5/tq2DZJ83YaIh3/83u/fI9Ee17rwvjYiB2CThoOXL/YAiVrEfowE95G7nl3 ZW3ZX59gZm1ZlbcMtSSpabK9vb86PvnPOBgNHVvckF5A4b2Zrp+N1T+E6ZGWPDWafRw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GHLGELm6; arc=none smtp.remote-ip=192.198.163.4 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.4]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D119606A32C; Fri, 4 Dec 2026 20:21:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3D119606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GHLGELm6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796415666; x=1827951666; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=wp/flPBOEuMGS1VQfixjnQbKuEuOhivoLP+HBkZ/co8=; b=GHLGELm6eZZQzLiAqsbly1zkJ52Vzjyzvvh5LjndSEt/JfQ2TIrbPu3f ESP8hMNt0KVT8ITyjox0pRQ9acH1Dff4RKHlf6UiNc4kUHoCWeLV04f// 45krD3W7MhCUQkdRz7p60+2M2EfvvjU1Em6VUK3/K4Ik1D+WYCnqAtS9L 7/9VA6fA7NOe2SyIVyaZOi6uM9HZSHCqQ94OxXC8c52VFip4FO7Jxoae/ jEUmMVNxoj4lAHchX329NZ79mb+xMu5Ob419eoYNZ8/2c47tZSlSvx1kp yb+IGrA+6uBzMw619h73Fr2WrDE6cC5JHOokNI+Wz/ct17SOrRrwV7wqx A==; X-CSE-ConnectionGUID: GtcRKlqfT/i04Krg/Sr1/A== X-CSE-MsgGUID: lVKHqKvXQUC1UsRypKXQVQ== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="158852" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="158852" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa114.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 12:21:06 -0800 X-CSE-ConnectionGUID: HBzP9DODTE+l9uJOhsq7zw== X-CSE-MsgGUID: AJkr0YdRSlG9zH3qtlx8Ew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="14318300" Received: from alekseim-mobl.ger.corp.intel.com (HELO localhost) ([10.245.245.10]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 12:21:03 -0800 Date: Fri, 4 Dec 2026 22:21:00 +0200 From: Andy Shevchenko To: Dmitry Torokhov Cc: Cesar Cibrian , Lee Jones , mfd@lists.linux.dev, Heikki Krogerus , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich , Bartosz Golaszewski , Johan Hovold Subject: Re: [PATCH] mfd: core: Remove software node after unregistering platform device Message-ID: References: <20261204181605.22364-1-cesarcibrian.ai@gmail.com> <8d70cb6010e7451c7ddbbfc448abd424@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8d70cb6010e7451c7ddbbfc448abd424@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Fri, Dec 04, 2026 at 12:12:00PM -0800, Dmitry Torokhov wrote: > On Fri, Dec 04, 2026 at 09:47:14PM +0200, Andy Shevchenko wrote: > > On Fri, Dec 04, 2026 at 10:16:05AM -0800, Cesar Cibrian wrote: > > > mfd_add_device() attaches cell->swnode before calling > > > platform_device_add(), but mfd_remove_devices_fn() calls > > > device_remove_software_node() before platform_device_unregister(). > > > > > > If the child driver propagates dev_fwnode() to a sub-device (for > > > example, i2c-designware sharing its fwnode with the i2c_adapter > > > device on Intel LPSS), removing the software node first clears > > > fwnode->secondary while the sub-device is still registered. When > > > platform_device_unregister() subsequently tears down the child, > > > software_node_notify_remove() sees dev_to_swnode() == NULL on the > > > sub-device and skips cleanup, leaking a swnode reference and > > > leaving a stale sysfs symlink that triggers a warning on rebind: > > > > > > sysfs: cannot create duplicate filename '/kernel/software_nodes/node0/i2c-0' > > > > > > Move device_remove_software_node() after platform_device_unregister() > > > (device_for_each_child_reverse() holds a reference on dev throughout > > > mfd_remove_devices_fn()). Because acpi_unbind_one() calls > > > set_primary_fwnode(dev, NULL), which skips clearing fn->secondary > > > when fn == dev->parent->fwnode, also clear the parent's secondary > > > fwnode when the child shared its parent's fwnode so rebinding does > > > not fail with -EBUSY. > > > > I believe it's a local hack against bigger issue which is discussed here > > https://lore.kernel.org/lkml/20261202-swnode-shared-primary-fix-v1-0-7ff23caaa1ed@gmail.com/ > > > > I Cc'ed people from that thread. Meanwhile, can you test the proposed series > > and confirm if it fixes your issue or not? Dmitry, thanks for chiming in! > My series will not fix this on its own. We still need to reorder > software node removal so it stays intact while child devices are being > torn down. > > What my series does fix is the shared_fwnode/set_secondary_fwnode() > workaround in this patch. Once device_del() unbinds the driver first and > tears down i2c_adapter while the secondary link is intact, > set_primary_fwnode(&pdev->dev, NULL) sees that pdev->dev attached the > secondary node, moves it onto pdev->dev.fwnode, and clears fn->secondary > automatically. > > Also, on non-ACPI shared primary nodes where acpi_unbind_one() does not > run, clearing dev->parent's secondary fwnode before calling > device_remove_software_node(&pdev->dev) makes dev_to_swnode(&pdev->dev) > return NULL and actually leaks cell->swnode's reference. Hmm... Does it mean that your series fixes the issue on non-ACPI cases as well? Cesar, based on Dmitry's answer can you apply his series and develop the missing piece on top? -- With Best Regards, Andy Shevchenko