All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>
Cc: Johan Hovold <johan@kernel.org>,
	 Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	 Daniel Scally <djrscally@gmail.com>,
	 Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	 Sakari Ailus <sakari.ailus@linux.intel.com>,
	 Bartosz Golaszewski <brgl@kernel.org>,
	driver-core@lists.linux.dev,  linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] software node: replace owner pointer with managed bitfield
Date: Wed, 02 Dec 2026 17:34:50 -0800	[thread overview]
Message-ID: <20261202-swnode-shared-primary-fix-v1-2-7ff23caaa1ed@gmail.com> (raw)
In-Reply-To: <20261202-swnode-shared-primary-fix-v1-0-7ff23caaa1ed@gmail.com>

Per-device secondary software node ownership is now tracked uniformly
with DEV_FLAG_SWNODE_ADDED, which also covers shared firmware nodes as
addressed by commit f8623ce59649 ("software node: only let the owner
release a managed node").

Replace the redundant, un-refcounted, never-cleared owner pointer in
struct swnode with a single managed bitfield packed alongside the
existing allocated flag.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/base/swnode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index da36f91f6434..f9ef8f40d760 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -29,8 +29,6 @@ struct swnode {
 	struct fwnode_handle fwnode;
 	const struct software_node *node;
 	int id;
-	/* Device the managed node's lifetime is tied to. */
-	struct device *owner;
 
 	/* hierarchy */
 	struct ida child_ids;
@@ -39,6 +37,7 @@ struct swnode {
 	struct swnode *parent;
 
 	unsigned int allocated:1;
+	unsigned int managed:1;
 };
 
 static DEFINE_IDA(swnode_root_ids);
@@ -1148,7 +1147,7 @@ int device_create_managed_software_node(struct device *dev,
 	if (IS_ERR(fwnode))
 		return PTR_ERR(fwnode);
 
-	to_swnode(fwnode)->owner = dev;
+	to_swnode(fwnode)->managed = 1;
 	set_secondary_fwnode(dev, fwnode);
 	dev_set_swnode_added(dev);
 
@@ -1214,7 +1213,7 @@ void software_node_notify_remove(struct device *dev)
 	if (dev_test_and_clear_swnode_notified(dev))
 		swnode_put(swnode);
 
-	if (swnode->owner == dev && dev_test_and_clear_swnode_added(dev)) {
+	if (swnode->managed && dev_test_and_clear_swnode_added(dev)) {
 		set_secondary_fwnode(dev, NULL);
 		swnode_put(swnode);
 	}

-- 
2.56.1.915.g69d5ec7298-goog


  parent reply	other threads:[~2026-12-03  1:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  1:34 [PATCH 0/3] driver core: swnode: fix release with shared primary fwnode Dmitry Torokhov
2026-12-03  1:34 ` [PATCH 1/3] driver core: swnode: only release owned secondary software nodes Dmitry Torokhov
2026-12-05 23:03   ` Danilo Krummrich
2026-12-03  1:34 ` Dmitry Torokhov [this message]
2026-12-03  1:34 ` [PATCH 3/3] driver core: platform: tests: add shared primary fwnode swnode tests Dmitry Torokhov
2026-12-03 11:35 ` [PATCH 0/3] driver core: swnode: fix release with shared primary fwnode Andy Shevchenko
2026-12-05 21:00 ` Cesar Cibrian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202-swnode-shared-primary-fix-v1-2-7ff23caaa1ed@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@kernel.org \
    --cc=dakr@kernel.org \
    --cc=djrscally@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=johan@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.