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=1796415123; b=drRkz0qdZfqSePJ5f1jKJYqbVIHuy2VoyMirqGa/aHAZH/R/RZLlRuNruype+nLJh1yJ PiOCKOHojOqalm/+2fhtK1Ud+Mxm59sfRTVAaQHWV7OnPMC0LKVd2qRdUVxKfgDquBbxF RJVLssUWwhSvNQMqlCzYU5WDEYYsK3zaoti0HgKKvf4rf22Rp8JbTLkz5bsar/CvG2F6/ UEjX5UWrCxFOTAzPjv3769MIKM7hXkqwsQPAd/KtELAg9KSBkyDg/OWMTi7d+4+kcV2sZ sp1PRzR0llv7m77dmi3Loj5/6GD3bVmdXZdQle5HNqKD7XwxQ1Hz1YVwUfJAPICYKoQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796415123; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding: Content-Disposition; bh=On5q+gkZsDbLqUTUkQHVABiP/IAaziuPDHbbOJ9z8KQ=; b=at5s0lN9I2E+80Ri7EaUftMCJaTf/4a1fDUllPHrVgRgecDPrYErd/3UmsZVDYosySSz jzF81BkVGE7jGZftQj7rTG7XiZknVa3IepgAy2hr/DJzaUbjAryLUa/uiHF95xOtYbenB 79K+S5dogb/2hF6RZN5yGZwb7RPxAC8dYcnF6eZHnlmRjtWUjUiANpVFH4qbn3QYl0P4Y pC4t2Yy/5yGx7r+R8ZfGqKMyatf2gTFpYRCTxWYn8SC59sWJYPriMAHLiZmHAPDrsVN4B IiGoNNoqsZ22joNr4SWxFh4UAXiMS/FFEO+7T5DzpN5kg42ph4li/ltraCknxJsijCg== 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=Gv0hkkgI; 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 83886606A334 for ; Fri, 4 Dec 2026 20:12:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 83886606A334 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=Gv0hkkgI Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-1b5adf7eacdso428778c88.1 for ; Fri, 04 Dec 2026 12:12:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796415123; x=1797019923; darn=vger.kernel.org; h=content-disposition:content-transfer-encoding:content-type :mime-version:references:in-reply-to:subject:cc:to:from:message-id :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=On5q+gkZsDbLqUTUkQHVABiP/IAaziuPDHbbOJ9z8KQ=; b=Gv0hkkgIUZ7C+lj6oVH+UjEggzz3VUyh6XE+CnZeBJk+iUhMtWGXO9nu5QC4Ia2vJu QsqwuMRcUB1fpPjEDR15slm40SMGJMpg8TQvOxmGvAe8lPba5AIfgSCnC5pC8LoxxuZR beRFwlAumS3MOu9/52z+8SQ22mwHBOmSytWyYKijjKJqKm92icZKDERZS3JaCI3xpDe6 wMqAq+uKQeTzfPWtukGvLxVnxywO3b5oJNDTe1uNBhF4Z5C+1VF3ZBu+zdQRlXl6Mu04 wuka0Pyv0hfXUbEdCvNRk0EgfgijChEqRcJ9cWb6vg29OG2APUF3cQk/yP9W4PJjhL6M kFsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796415123; x=1797019923; h=content-disposition:content-transfer-encoding:content-type :mime-version:references:in-reply-to:subject:cc:to:from:message-id :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=On5q+gkZsDbLqUTUkQHVABiP/IAaziuPDHbbOJ9z8KQ=; b=qlbrX/E8j2N0yF3Hzp6gXNu5arwqg9jycGET7YUn933onclu4GTDZ2lsbQxkaNSjSR 8NfowcvJCRCxfZCyjjlcC7YRPiDQQ56cIg2kc7zhirBdt27iu06OTCCKKZO8hVoIB/gO dMKI2SRWq/b19g1e7U5fL2YdNmuG7HlJzQ1Mgn4mCdj3KrRVDutqHCStBvOvrOYRTEZ1 KY4ENEmihTIhmj8jH449T7p3iaCIUOEkUnosYJD+FQPh4xWSLO5l4EqszcyM+BGGTWUV 7yxwMgw1viFK4sTUWnCWSKfY/QajZ8LW+TbOvsqEBuMrjX8qPgt8krS6yTTQXYcmHfjr 5k7w== X-Forwarded-Encrypted: i=1; AL+hErGMfabHgrRCIwvxs3IeYQ4U5GITi83vHzBF267KM8lkZK0FsjGETNtV6sKcKMiA56E+9SP42BxTebA4@vger.kernel.org X-Gm-Message-State: APuU4Z8fgEoFbCBvlyUpm5gAhp3Jij1Ciwsmt4JQ/fdkyWORvzIhHtPz Thupa5dx2heuRQ5DZ0U0TacDAFae+70EB2UCNqNdrQ4hGs08/iPElyWL X-Gm-Gg: AZFdTZcHusTtanNz+y6BWVvEu4GxiHaf+RzV46pmEjUWI983Cjy9L8+v74GuqZ1X4qF RhSAFL7VGLCSZEKDRvXeOnFOcgX4LNGACbUMwEBtmrByrMs/65GbLAPz2Pv+KjVTtKWdJeZD68o LWa9qpbVwA++V9P13G1BayxboAPHqTlNaRkhdfSDjy2YTygd4CiU6m/nswBKLmOK5HKZNf/SmtV HATL07TWWedUg/jjed7oMTlmw/MciR/iA70oaHJJn5Tyf8GbunVx12NpgH2ISqqwO1MRxEnGXH4 CkLeDnl/iBlttFS60zdDGm7jVnnOJOKf8fdEmU+xJASs1BYWAhASFoTTuxlpZ7aLruS98AjD/mN ZZfchBFdAUBspsOq3SX20jBj2ob3MNcom+mbwCu3d0jrv6tXxzKRcbLcUPXP2ES4OZ8poSje85v /HDJehIHl+gUHJ2pUINBGBfEX2bhBrC6yLBVxI5EvXddcPuDBDYY5xrfIZVCkxFO9yn2b5EKwLw srNkyy1XxBoagbEF5F2LeexC7hfrBI7iJ4lmxjl+KY35y5zX1dt8tb0jos5am5d4/n7shL6ZyoS NCEoaKKE1XRZjdvlbRhyxjCHsGhBO1wQGiXzmyw92HlqWg42v7PIwF4VyTyCly5igxkTxA== X-Received: by 2002:a05:701b:4204:10b0:168:3243:c911 with SMTP id a92af1059eb24-1b5d7233433mr2956544c88.37.1796415122375; Fri, 04 Dec 2026 12:12:02 -0800 (PST) Received: from localhost ([2a00:79e0:2ebe:8:17a1:4895:5021:5d36]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d644109esm10344603c88.8.2026.12.04.12.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:12:01 -0800 (PST) Date: Fri, 04 Dec 2026 12:12:00 -0800 Message-ID: <8d70cb6010e7451c7ddbbfc448abd424@gmail.com> From: Dmitry Torokhov To: Andy Shevchenko , Cesar Cibrian Cc: 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 In-Reply-To: References: <20261204181605.22364-1-cesarcibrian.ai@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-Transfer-Encoding: 7bit Content-Disposition: inline Hi Andy, 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? 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. Thanks. -- Dmitry