From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796415123; b=2ZY+tJLoytjqzG/p4J1SNBQjtYvcQLJJVWeJy57VrXD9nFIBDMBmWjBiL8FmmKivjs9T O/44NlTUKOnu8oY46RZUA/SndkkZebdrynhrZHXNcn3qL/qtpCspHmPtQaJwCamFyhpQ5 qIV/a8kvovWWsQP0lqqglpUz7CpsL5SjHwmZsNh9Kfwfr8cjLc/nHSedJqQe7XBzMgoJx TxuNUQXKqqMLRLedaPpC+UY56Xp9e5Z3XBl04aeL6HRe1BGdqII0BEYerCyPDochSOXPm wkVGBquhgkOjq88PTLNefCdo/Q6hh0Y89n6LdlHFNkuhJpxZ29AxHylVKsllA3LZkWw== 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=wdPJYYnrVd/BBrdG6fQnnKMndW9Ln5nlh/TLUZC3fAicHi1NiEnRNNHpf49HYcz55aoB oMvsZhvk249wd/SAYxnYxz5P5FV7PPX/oipi4yZrXNhD0WtTtRNAIS9LTy+6OaZVn4doi YnYNfR59ZaxKG+jsia5sbbmV24uSG0KdNSP33g/ltyU4vESa5bZB/ssSXP8DgkRqvKRu4 xXw+yJ4HHW1HPqbNk/g3co4IIfkeV61d2L4KzgNGDjV1LObdXEwGtPz0ZEWVLWO7w2cYn PRwFCkamwQ7Fak80MFwXN7dnC99imTEpTDLeATGak7Oxy242Hs8yqXhGACPnM9V+slg== 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.47 Received: from mail-dl1-f47.google.com (mail-dl1-f47.google.com [74.125.82.47]) (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 8C718606A338 for ; Fri, 4 Dec 2026 20:12:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8C718606A338 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-f47.google.com with SMTP id a92af1059eb24-1a2af4c8d00so701325c88.0 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=WE0Vnfdw7xEs3BVDibSPdkbReTap+m+vo5Wc9B7Vs2f3dsqEQsUVGh3b31IxNXp/Nc bn24VqpbB7Je0ppJCc8595HlFSBakCl/59iBzMo44TiUEpX5x/AczbWKIyIYRtSj2uKY +U7ao7BYnPBHWeSWlT/cdyKEd6M3Bj8wyy5yDEaCMj7gHgtXf+h1V+PbF3Bw2ZcZE1f3 1ISkubxcOw7JxoKnnXlqafEB5DR9x8sDIqpVECGw3bZR3jyH9A3Xo0LRlZdsN/2G38bE MWrwQcg7vPDUvfkSJy6mN6oH3dS9UX2wfNsosg7T6Ix3nAK5BNvQ7/bOnQG2XoIlUoUn THsQ== X-Forwarded-Encrypted: i=1; AL+hErG0dB0TPdup/x+cIkZ3qRezT1jZ6W2C/BN9vTAXE0HBrej7WeB4a9ya64+AkX5vaxnfpEsBdlfBAN4=@vger.kernel.org X-Gm-Message-State: APuU4Z+l8CLe28/QfRaS9twI2HjtoSY2p2HcsjhN9fDHe4pliT2iQ97U eYYCQ+SrxMKjaXpUDm7Tj9HvQDDil+qIn/Q5OtezodhaHM/cTIxT/CWd X-Gm-Gg: AZFdTZePZ+jSRwmobVktbbxy7L3gGwSiLvQ5VXPaSwnKKImmnMprLV5p1eAF8GODGkB lLKRX6DSYkMIBb8pHrSKVtS4R26Adz136krhjZH+u/lnIi9CjicZJA+RSFDq524MlKiuB5G5sUs FLpQK3WcJt4Klf5cBPAgcy8nEfumTvhC8QxPQY4u2G9kkw6XigbHw2GiReqX1belNtt3hTFM+5o WP+jWEz5i+fdZvzfQ2EXNcSlhpp7QWNyRbVyTYc3dUzfvqwqQJFRmBWXrb8984iOU2/gp4+SgVf 5lyZewguzK+icHpPTHjlLQO1ce7eZKTCshqKUvq0BYHtiUHWPJ5G8KIiUp8J3WWvp0UAH1TvQFm 6o5H+PVUddyNL4Ta+rOrDI5AeiDXhVjBce1z9kKuzYaJT1ie+D2U7fT1QB1E/P5D5udr1WceMJo IVf4WhhsVdqBFokRXADjbqesFTucHKPbyJqV/gQWNtUSaWQHzQPQYBBuHH0PjlzkKjI8OWJiHoU PozEoTZFAzNHoENlAISrCIFoKRhu4rEYihULDjHfySbUAAsD5qGHPFFzZFr5cVO8yIirwADnM06 ZMKoNA301GZBAncDWjORkxUuVQpauGWQ+Z4DaUGbwmx/fAfKI1F9rpLKeK6/9BDgKlKtOg== 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-i2c@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