From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796416033; b=cm6sA0TD6afjwJnFpMMH/ULbMe8a49yryVcCPgEtMPtZ+GltQbR3iIicX3rxsZybV2n1 AG3q39D/jp+zo9jGM5tbdrTJWkcFywsh01xB2noXGN041dpAQwDl+LkDD0UJt1CD7TNAO /+WJlmLdqDuCRXJ/vkbb6lxyACpUk7VjFvgskbIk+S1Ee14dDbpflAI9bAYS2BQv/G+O4 8xFQLB6RpwweZZ2Em6EJStWvy2riqikxWKUVwouTb3mQ03dRKcqKwnn1zJBuLIDWP3cgf XKoPaqaspsfOkIXh3Bo9WnOAdbETw3CTG9M3bdWqgYmkknxUcoO1ZLrfyRkCLLt9VcQ== 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=WzaFfNJ//selAWIe4vEzmagNBrsZyw+qfNtBP+jkG3hnAkFeoEnLdpU0bDlFQUENWF+/ rhCkEc+nMjNT6cKG+38CwA48eKk5+ueyj/UbXkkgkokVeXkywcXNTNmaaViUHBSpcucB4 HKrJHrZEhYRFQxmaOIabyASYpchf5R4bUdaWq99XTK2K6j1a6bqER0kHLEgsSbznnC5Uj 6nkQfcZzBHTy0ubHwXNXPS6LzncfNkKdZR71FhqJMMUP2stHXub+wyjhrnsSHakDUkL5k dycogEUacYGaQRMcVYgMeLQcr4hZHIMSMGkdr4hH2Ik7+bZlJpTBnV3wUTeJjnp594w== 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.53 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (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 5CFF9606A32C for ; Fri, 4 Dec 2026 20:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5CFF9606A32C 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, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mezsPE33 Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-1b5adf7eacdso451497c88.1 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=Jc4ePOwK5IbAbkjQIGgUWFLpPHkWMQewe10F9DEDkDmA5YSo8TnSaHj3GFCykDPBS4 IFuR3hBwhhHcI3ujVGxF0rBhnSFSHBduHKtBrnv59421skZeeYGof+8UFxypz0oE9weI 5ydWZbNITIsCbAj4iy4kF454i6oZQ58EZsF8Q4m0ZKs2DStqOeUzHkRzk+PBvY6s5a4t IsYlzVBbfM1blkwccUo5XM08hpf6fniYgrH/06atLD2Vvdbf6sxIw7MosJGOlMNmFjB4 FwAZWesJTVJRUqt8BRVw+a5dnkTCdoPCQRahIkiQ6jm1gkPMCHWM7tx+eHTqZPYKuB5f nvcA== X-Forwarded-Encrypted: i=1; AL+hErER0cgnV29v/1knnCfJ5DOLIFQbnZQpy/8dFLCYe2m8IZ3NX0lqbYvMAwXxhQ7K/EOuqa4B1EV+9mKE@vger.kernel.org X-Gm-Message-State: APuU4Z8a+hxXhtLfgwyEJblE2493QOIpA6V+LUN48G15iKe9vWwUGgtp KMHotrK3em/QpcjwagroYo2HGRIti5Y4ktIEYvTOW9t01b/OF2r5y0fP X-Gm-Gg: AZFdTZcqNoyreHfbjKlHTGY058WDVQaVfM0yv4KfVWDERItaYwmaZ/YIsUcbS3Z/hVx r/fhseEZhneNo+5n8O4xdVx8PWHHfscrehuk9Un65S/AZkQd7xs/C1iFAec5XeT5zbRf5J+rCkM VhlylO6f1X7RDDM9sANvvKsFbuBR/AzQQysunSfnkAl5dU0PcfdtHcHJf//Q0G3nC4SUQ1MosCG YCNFZgHZYwBhHUNHocPAMC2Y54Hyc9TxjvdIR2hbGJhKuYgfvPn6+MzXeM5XE4JVtvkCPbUPYUy ME3YsCmTWIcOKgmjBSxWhXYt6bcTQQQmKTurjmPLmHEE5Z6w0V8KcLVw0iSaMXbzWJyLfqjrUIb N4VuD2YRTCnwsgef/CYXm6h46lBm+UGt1pKyl/OFquziRqB6hPCIgqF0hcwLtKfnrZU3uoHCEq+ +Rasp4qCeeyTPJHeBUPKk6Fs8ORnPv6DqGqxlmMErGGhISLLnwnPLD/me8PCUD/BCtgfRdHYHal U2WPFz7YHRJq36O+UYr1UHSVvNyvafnp1f8ihS6K835T0tCMesM1f4KPZRM/sa5czx08jiaN1BE 79huxZTuqNZlzRVVp1Rm0N1yIzoJ7HzPgRCqZPhQ9e91YRL0fGqvUJZA+ihIrMaHxAt5mQ== 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-acpi@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