From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796416033; b=V3hBf2Th9ffU/Ysl2ZDI7unjuyGOpvm576uSTGXu7SstPfSu0OTyTw4/P5p9HCUbuEH7 yhM9jcHSuY7wjEQ/h3CgKddum3UkEh85r1Z5S00Y+yh4yNWPywnaGkidj65U9vqBFnIIE RElibI6gE0p99HHlEDToWww+BnF4dKuxKsRrT50Q5f4uLuOwdAQroPAWJNlRpT3gn5+Ty +rHtPy2w63raQ/0OeQuBldK5Y9JfPoVaKI0rQM7CJYhYuNyQYF/JmhiUXl+BMvT7K7dws OP7QIiYRhk+lAlD+po6pr3Nnfkf+3/pM9rdOIzFeTFZZHfR1aqqBfTsgbR50m2aEYoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796416033; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=2JagPfSnn3Dvf5xG8I5Mijf8UWexIkB2w1YWWEHF/Mo=; b=yRN5aUzI0A/3jMMkBemP3abFQXxqUbtGoc98bLL4e+Ln9+wTHYunf909gfId+xgZWgTq ars97Pxjegb7ym5252CJc4mj+XNKh/RXR41Dr7CCt8ZU4PxuXFR2/kbujWBItHrBUX+hI SUflq2OnoZtPuRl24AKiVkW0ofVJtNugt2vJWTbblGFV+7swH43BXVb9NdtzLSQf/kw/U TEvsVk+yQQ5SM40zgJWqOrH4x0iqj76KgmSxaH0QYrUi+7eJnUDDjg+7eaCX96peF4gP8 2UphH2CrhEN00o6oGUIen0gSYOmcUkhCFqfH7cJ0+dpN66+3c75hngAdmdMsc2JgDEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mezsPE33; arc=none smtp.remote-ip=74.125.82.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63A44606A32D for ; Fri, 4 Dec 2026 20:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63A44606A32D 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mezsPE33 Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-1a2af4c8d00so737269c88.0 for ; Fri, 04 Dec 2026 12:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796416032; x=1797020832; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=2JagPfSnn3Dvf5xG8I5Mijf8UWexIkB2w1YWWEHF/Mo=; b=mezsPE33LUuOWi7X8ySqbvAx2u5CEIeP8SkHwCzujMBGnPGx9yuLPXrrB60ItRLh+3 PK6a40DXQ8g4XrxAnY+ZEwlsW6kCMnpcpojU46PEP4A4V3hgsVq+LX2bznDGvAD+5wKb 891bFC4hyV7j6W6IJ6OAu0HA7GZps+pOW0hMssKXR10JSLIxr9BGWSO9ywBfpokXD3S/ o/7ZM/3FnM/QpOkqahwplXa4fReClt7QYesgcpSMbzGkYHci6bEHkDLTS4oPRaWsgy39 aD6x6evy+mzTH0eIX97HDf2CULduZOrcG6LG0xQzU5WfoTjxsHjV85QjnHC27LfrX6z2 Fvig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796416032; x=1797020832; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2JagPfSnn3Dvf5xG8I5Mijf8UWexIkB2w1YWWEHF/Mo=; b=KHIvqAPkjM/PR3OmYZ4V8ewovr9kK3SjKVLttVh5xypI1N9DXPRVrd8NzVRbQCckT2 qCZCOPcXooBOyME1UhCB31wys6wlo2KAJkxin6gq4fncneCoOc2PRMub8sNryffsp+7Y Hgc8dc7MoCBV7RfECaLiuOyYrtzL4kfwD5lZ8XAutXgpD5KNTi9KPF5IzcUO1Y+JcGE5 IpEHSphKJZlo4mkwqZflRVzPiQ8pCrHMGgVmiudqKuTYjL5pUNvPbsTeOsVbAg5n9wUS LVq0hA1aWTa0foA/wEX6AGmxGXoIyfH9z++cYDntCqlm7HVGJpiqpSYmOZiEeTMo5IQr W65Q== X-Forwarded-Encrypted: i=1; AL+hErFVr4rBatPoxGQeNz5nuFBIqe44E9JrAmDbM3nbCBNpA8ZL5rjSgocFIsGE19TdMeUqSp3gNN4td66g4e4=@vger.kernel.org X-Gm-Message-State: APuU4Z+Unp7InvFEAVl45ul88K4wu/3NiRdXlx5PUtIv0LwOpo8T68YU HoGQn9P75mFQwwMB0e+TxU85ihbj4SlGzpq4yiy9BJUuCjrK7kKm+XyQ X-Gm-Gg: AZFdTZdlBPZ2ngfou4fyvwWtal7u2sHCCp6Vac1jxWPMCkWyRcwQrQlrF4UpIhJIFhl BjYAFTaaohN++h/7a+QyZVC81kJH1m64jNlanDJD4s2uREZWdaIRcInZUDIEBM5zBIkpVW+8Fdz dQ8JWk9sAOGsxKA9F4I3SyYo5qT/lDWgd/DuDhNjguW9XP8858fysVfda7/XDoT+OWuVQzGuedd n9D228Xoz49SXVeIR6jXEG05otnNxosOztYdS994pDA/M/Sbiq25qnnUesv0BwXTiexOxVadEUf L4XlwNozOmPF6JhLSTrC4FpAQeAwToXlLyHzVn14qwoLYOxZve+hCIYKWpLGHb+ahVEBvxouzO7 cdRdt4Mi3xVlzAfYhO2c8Abc0X1x3cHii+rsOPRCyBn8+G5OTAB08IsYyoJYWDVj6cQJ2U482eY kikcR8Tiiz2G1+0+hR+2JL46Bq4Ll1Heh2FQeoGlgRn+b9H3rhNEc7uKavw6c3hJQHFmuRjxD3H /8bcbghq4HlldzhUAm+SJR/RjBmAaH3uT+v8n3vBt/D4VALBh5SdB/kIbYBPkpdrxxcxwwOGY4l tMbz/5uI6zK6Qau6e1VZ5qkRdrj9nyyasNPaCLFTBi4IkQ5/0yQapxAqqTVrnVvA6gqIGQ== X-Received: by 2002:a05:701b:4590:20b0:1b3:aee5:20c5 with SMTP id a92af1059eb24-1b5d7114170mr2564609c88.22.1796416032333; Fri, 04 Dec 2026 12:27:12 -0800 (PST) Received: from google.com ([2a00:79e0:2ebe:8:17a1:4895:5021:5d36]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d644171bsm9482218c88.7.2026.12.04.12.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:27:11 -0800 (PST) Date: Fri, 4 Dec 2026 12:27:08 -0800 From: Dmitry Torokhov To: Andy Shevchenko 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: On Fri, Dec 04, 2026 at 10:21:00PM +0200, Andy Shevchenko wrote: > 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? I was trying to say that I think Cesar's patch introduces a leak on non-ACPI systems... > > Cesar, based on Dmitry's answer can you apply his series and develop the > missing piece on top? > Thanks. -- Dmitry