The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v5 0/7] driver core: remove software node from platform devices on device release
@ 2026-05-12 11:59 Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 1/7] platform/surface: gpe: use platform_device_register_full() Bartosz Golaszewski
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski,
	Andy Shevchenko

This fixes an issue in platform device code where, if we specify a
software node for a platform device using struct platform_device_info,
it will not be removed on device .release().

This is an extended approach from v4 where we also first introduce
necessary changes in drivers where the fix may cause a regression.

Merging strategy: Danilo suggested that the new interface we add in this
series as well as prerequisite driver changes can still land in v7.1 so I
think the entire series should go upstream through the driver core. The first
5 patches are part of the fix and the remaining two add tests which
can't really do harm.

DRM and platform maintainers: please Ack the two driver patches in this
series.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v5:
- Provide a helper for users of platform_device_alloc() that wish to
  assign a software node to a platform device
- Rework drivers that could regress after the swnode leak fix
- Split the series into several patches as necessary
- Link to v4: https://patch.msgid.link/20260430-swnode-remove-on-dev-unreg-v4-0-01574da0aed3@oss.qualcomm.com

Changes in v4:
- Drop redundant !pdevinfo->swnode check in
  platform_device_register_full()
- Handle all three combinations with which two software nodes can be
  assigned to a platform device
- Extend the new kunit test to verify all three combinations
- Link to v3: https://patch.msgid.link/20260428-swnode-remove-on-dev-unreg-v3-0-533bdc71b22e@oss.qualcomm.com

Changes in v3:
- Make sure the reference of the primary software node we possibly take,
  is always released by moving the get() before calls that may fail
- Don't allow passing two software nodes
- Add a test case for that situation
- Link to v2: https://patch.msgid.link/20260423-swnode-remove-on-dev-unreg-v2-0-0e5213cde2ed@oss.qualcomm.com

Changes in v2:
- Change the order between removing the software node and dropping the
  reference to the device's OF node
- Address a situation where a software node is used as the primary
  firmware node
- Add a patch adding a new kunit helper
- Add another test case
- Link to v1: https://patch.msgid.link/20260410-swnode-remove-on-dev-unreg-v1-0-cd7d305f3db2@oss.qualcomm.com

---
Bartosz Golaszewski (7):
      platform/surface: gpe: use platform_device_register_full()
      driver core: platform: make the swnode check stricter
      driver core: platform: provide platform_device_add_software_node()
      drm/xe/i2c: use platform_device_add_software_node()
      driver core: platform: remove software node on release()
      kunit: provide kunit_software_node_register()
      driver core: platform: tests: add test cases for correct swnode removal

 drivers/base/platform.c                  |  44 +++++++-
 drivers/base/test/platform-device-test.c | 168 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_i2c.c              |  21 ++--
 drivers/platform/surface/surface_gpe.c   |  36 ++-----
 include/kunit/fwnode.h                   |  19 ++++
 include/linux/platform_device.h          |   3 +
 lib/kunit/Makefile                       |   3 +-
 lib/kunit/fwnode.c                       |  52 ++++++++++
 8 files changed, 307 insertions(+), 39 deletions(-)
---
base-commit: 5d6919055dec134de3c40167a490f33c74c12581
change-id: 20260410-swnode-remove-on-dev-unreg-42bfc4b23ba8

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v5 1/7] platform/surface: gpe: use platform_device_register_full()
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 2/7] driver core: platform: make the swnode check stricter Bartosz Golaszewski
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski

Creating a software node for a given set of properties and adding it to
a platform device can be achieved with a single call to
platform_device_register_full(). There's nothing in this driver that
suggests using the more fine-grained interfaces was intentional so
switch to using the high-level helper.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/platform/surface/surface_gpe.c | 36 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/platform/surface/surface_gpe.c b/drivers/platform/surface/surface_gpe.c
index b359413903b13c4f8e8b284ef7ae6f6db3f47d72..b8bb47b0d91f036ee5073d21534f8f26a4d5ed15 100644
--- a/drivers/platform/surface/surface_gpe.c
+++ b/drivers/platform/surface/surface_gpe.c
@@ -290,9 +290,9 @@ static struct platform_device *surface_gpe_device;
 
 static int __init surface_gpe_init(void)
 {
+	struct platform_device_info pdevinfo;
 	const struct dmi_system_id *match;
 	struct platform_device *pdev;
-	struct fwnode_handle *fwnode;
 	int status;
 
 	match = dmi_first_match(dmi_lid_device_table);
@@ -305,34 +305,20 @@ static int __init surface_gpe_init(void)
 	if (status)
 		return status;
 
-	fwnode = fwnode_create_software_node(match->driver_data, NULL);
-	if (IS_ERR(fwnode)) {
-		status = PTR_ERR(fwnode);
-		goto err_node;
-	}
-
-	pdev = platform_device_alloc("surface_gpe", PLATFORM_DEVID_NONE);
-	if (!pdev) {
-		status = -ENOMEM;
-		goto err_alloc;
+	pdevinfo = (struct platform_device_info){
+		.name = "surface_gpe",
+		.id = PLATFORM_DEVID_NONE,
+		.properties = match->driver_data,
+	};
+
+	pdev = platform_device_register_full(&pdevinfo);
+	if (IS_ERR(pdev)) {
+		platform_driver_unregister(&surface_gpe_driver);
+		return PTR_ERR(pdev);
 	}
 
-	pdev->dev.fwnode = fwnode;
-
-	status = platform_device_add(pdev);
-	if (status)
-		goto err_add;
-
 	surface_gpe_device = pdev;
 	return 0;
-
-err_add:
-	platform_device_put(pdev);
-err_alloc:
-	fwnode_remove_software_node(fwnode);
-err_node:
-	platform_driver_unregister(&surface_gpe_driver);
-	return status;
 }
 module_init(surface_gpe_init);
 

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 2/7] driver core: platform: make the swnode check stricter
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 1/7] platform/surface: gpe: use platform_device_register_full() Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node() Bartosz Golaszewski
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski

Check all three possible situations in which two software nodes for a
single platform device can be created/assigned in
platform_device_register_full() and bail-out early.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 75b4698d0e582e67adafa78c312d75c72fd654cf..18f33bec36726490255bc7ca3c4ab07d9b7606b0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -848,7 +848,13 @@ struct platform_device *platform_device_register_full(const struct platform_devi
 	int ret;
 	struct platform_device *pdev;
 
-	if (pdevinfo->swnode && pdevinfo->properties)
+	/*
+	 * Only one software node per device is allowed. Make sure we don't
+	 * accept or create two.
+	 */
+	if ((pdevinfo->swnode && pdevinfo->properties) ||
+	    (pdevinfo->swnode && is_software_node(pdevinfo->fwnode)) ||
+	    (pdevinfo->properties && is_software_node(pdevinfo->fwnode)))
 		return ERR_PTR(-EINVAL);
 
 	pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node()
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 1/7] platform/surface: gpe: use platform_device_register_full() Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 2/7] driver core: platform: make the swnode check stricter Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 16:31   ` Danilo Krummrich
  2026-05-12 11:59 ` [PATCH v5 4/7] drm/xe/i2c: use platform_device_add_software_node() Bartosz Golaszewski
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski

The software node added to the platform device in
platform_device_register_full() is currently not removed on device
release. In order to fix this, we need to first convert all drivers that
use platform_device_alloc() and then assign a software node as the
primary firmware node to using device_add_software_node() for correct
reference counting.

To that end: provide platform_device_add_software_node() in line with
other existing helpers like platform_device_add_data().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c         | 25 ++++++++++++++++++++++++-
 include/linux/platform_device.h |  3 +++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 18f33bec36726490255bc7ca3c4ab07d9b7606b0..f617e02b171f6e59a3c40504a71f8915a41e8514 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -613,6 +613,10 @@ static void platform_device_release(struct device *dev)
  *
  * Create a platform device object which can have other objects attached
  * to it, and which will have attached objects freed when it is released.
+ *
+ * Note: devices allocated with this function must not have the following
+ * members assigned manually: swnode, resources and dev->platform_data.
+ * Please use the provided helper interfaces.
  */
 struct platform_device *platform_device_alloc(const char *name, int id)
 {
@@ -687,6 +691,25 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
 }
 EXPORT_SYMBOL_GPL(platform_device_add_data);
 
+/**
+ * platform_device_add_software_node - add a software node to a platform device
+ * @pdev: platform device allocated with platform_device_alloc()
+ * @swnode: software node to assign to this device, does not need to be registered
+ *
+ * If this device is already associated with a primary firmware node, add the
+ * software node as the secondary firmware node. Otherwise, make it the primary
+ * firmware node. Register the software node if needed.
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
+ */
+int platform_device_add_software_node(struct platform_device *pdev,
+				      const struct software_node *swnode)
+{
+	return device_add_software_node(&pdev->dev, swnode);
+}
+EXPORT_SYMBOL_GPL(platform_device_add_software_node);
+
 /**
  * platform_device_add - add a platform device to device hierarchy
  * @pdev: platform device we're adding
@@ -881,7 +904,7 @@ struct platform_device *platform_device_register_full(const struct platform_devi
 		goto err;
 
 	if (pdevinfo->swnode) {
-		ret = device_add_software_node(&pdev->dev, pdevinfo->swnode);
+		ret = platform_device_add_software_node(pdev, pdevinfo->swnode);
 		if (ret)
 			goto err;
 	} else if (pdevinfo->properties) {
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 975400a472e30e2f98cc8f13bc36a63129bd4fcf..bd421506e98fc293c97121693e4bd18b703e41fa 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -19,6 +19,7 @@ struct irq_affinity;
 struct mfd_cell;
 struct property_entry;
 struct platform_device_id;
+struct software_node;
 
 struct platform_device {
 	const char	*name;
@@ -262,6 +263,8 @@ extern int platform_device_add_resources(struct platform_device *pdev,
 					 unsigned int num);
 extern int platform_device_add_data(struct platform_device *pdev,
 				    const void *data, size_t size);
+int platform_device_add_software_node(struct platform_device *pdev,
+				      const struct software_node *swnode);
 extern int platform_device_add(struct platform_device *pdev);
 extern void platform_device_del(struct platform_device *pdev);
 extern void platform_device_put(struct platform_device *pdev);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 4/7] drm/xe/i2c: use platform_device_add_software_node()
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2026-05-12 11:59 ` [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node() Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 16:24   ` Danilo Krummrich
  2026-05-12 11:59 ` [PATCH v5 5/7] driver core: platform: remove software node on release() Bartosz Golaszewski
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski

This driver intentionally uses the fine-grained approach to creating
platform devices. It assigns a software node as the primary firmware
node of the device it creates. Ahead of improving the reference counting
of platform device software nodes, switch to the new interface that
internally uses device_add_software_node(). While at it: define a static
software node with the provided set of properties instead of allocating
it dynamically and simplify the error path.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpu/drm/xe/xe_i2c.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
index 706783863d07d66b4685005d6649b3cd143ecc3b..7f4295e7dc74f112abff8427485b5c8a5ad71383 100644
--- a/drivers/gpu/drm/xe/xe_i2c.c
+++ b/drivers/gpu/drm/xe/xe_i2c.c
@@ -53,6 +53,10 @@ static const struct property_entry xe_i2c_adapter_properties[] = {
 	{ }
 };
 
+static const struct software_node xe_i2c_adapter_swnode = {
+	.properties = xe_i2c_adapter_properties,
+};
+
 static inline void xe_i2c_read_endpoint(struct xe_mmio *mmio, void *ep)
 {
 	u32 *val = ep;
@@ -96,10 +100,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
 	struct fwnode_handle *fwnode;
 	int ret;
 
-	fwnode = fwnode_create_software_node(xe_i2c_adapter_properties, NULL);
-	if (IS_ERR(fwnode))
-		return PTR_ERR(fwnode);
-
 	/*
 	 * Not using platform_device_register_full() here because we don't have
 	 * a handle to the platform_device before it returns. xe_i2c_notifier()
@@ -107,10 +107,12 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
 	 * platform_device_register_full() is done.
 	 */
 	pdev = platform_device_alloc(adapter_name, pci_dev_id(pci));
-	if (!pdev) {
-		ret = -ENOMEM;
-		goto err_fwnode_remove;
-	}
+	if (!pdev)
+		return -ENOMEM;
+
+	ret = platform_device_add_software_node(pdev, &xe_i2c_adapter_swnode);
+	if (ret)
+		goto err_pdev_put;
 
 	if (i2c->adapter_irq) {
 		struct resource res;
@@ -123,7 +125,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
 	}
 
 	pdev->dev.parent = i2c->drm_dev;
-	pdev->dev.fwnode = fwnode;
 	i2c->adapter_node = fwnode;
 	i2c->pdev = pdev;
 
@@ -135,8 +136,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
 
 err_pdev_put:
 	platform_device_put(pdev);
-err_fwnode_remove:
-	fwnode_remove_software_node(fwnode);
 
 	return ret;
 }

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 5/7] driver core: platform: remove software node on release()
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2026-05-12 11:59 ` [PATCH v5 4/7] drm/xe/i2c: use platform_device_add_software_node() Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 11:59 ` [PATCH v5 6/7] kunit: provide kunit_software_node_register() Bartosz Golaszewski
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski,
	Andy Shevchenko

If we pass a software node to a newly created device using struct
platform_device_info, it will not be removed when the device is
released. This may happen when a module creating the device is removed
or on failure in platform_device_add().

When we try to reuse that software node in a subsequent call to
platform_device_register_full(), it will fails with -EBUSY. Add the
missing call to device_remove_software_node() in release path.

In addition to the above change, make sure that we still function
correctly if a software node is used as the primary firmware node.

Fixes: 0fc434bc2c45 ("driver core: platform: allow attaching software nodes when creating devices")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/platform.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f617e02b171f6e59a3c40504a71f8915a41e8514..d2f40b348f193db842aa7c17c9c41be59a03d35f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -599,6 +599,7 @@ static void platform_device_release(struct device *dev)
 	struct platform_object *pa = container_of(dev, struct platform_object,
 						  pdev.dev);
 
+	device_remove_software_node(dev);
 	of_node_put(pa->pdev.dev.of_node);
 	kfree(pa->pdev.dev.platform_data);
 	kfree(pa->pdev.mfd_cell);
@@ -895,6 +896,16 @@ struct platform_device *platform_device_register_full(const struct platform_devi
 		pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
 	}
 
+	/*
+	 * If the primary firmware node is a software node and there's no
+	 * secondary firmware node, the primary will be affected by the call
+	 * to device_remove_software_node() in platform_device_release() and
+	 * its reference count will be dropped by one. Take another reference
+	 * here to make it have no effect.
+	 */
+	if (is_software_node(pdevinfo->fwnode))
+		fwnode_handle_get(pdevinfo->fwnode);
+
 	ret = platform_device_add_resources(pdev, pdevinfo->res, pdevinfo->num_res);
 	if (ret)
 		goto err;

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 6/7] kunit: provide kunit_software_node_register()
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2026-05-12 11:59 ` [PATCH v5 5/7] driver core: platform: remove software node on release() Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 15:28   ` Andy Shevchenko
  2026-05-12 11:59 ` [PATCH v5 7/7] driver core: platform: tests: add test cases for correct swnode removal Bartosz Golaszewski
  2026-05-12 15:07 ` [PATCH v5 0/7] driver core: remove software node from platform devices on device release Danilo Krummrich
  7 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski

Implement a helper for registering kunit test-managed software nodes.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 include/kunit/fwnode.h | 19 ++++++++++++++++++
 lib/kunit/Makefile     |  3 ++-
 lib/kunit/fwnode.c     | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/include/kunit/fwnode.h b/include/kunit/fwnode.h
new file mode 100644
index 0000000000000000000000000000000000000000..e1554ace64b8a5899aff9f4b4247e5157826a49b
--- /dev/null
+++ b/include/kunit/fwnode.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * KUnit resource management helpers firmware nodes.
+ *
+ * Copyright (C) Qualcomm Technologies, Inc. and/or its subsidiaries
+ */
+
+#ifndef _KUNIT_FWNODE_H
+#define _KUNIT_FWNODE_H
+
+struct kunit;
+struct fwnode_handle;
+struct software_node;
+
+struct fwnode_handle *
+kunit_software_node_register(struct kunit *test,
+			     const struct software_node *node);
+
+#endif /* _KUNIT_FWNODE_H */
diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile
index 656f1fa35abcc635e67d5b4cb1bc586b48415ac5..7549a701791b5b7eaa8e0637b6818cdfd0b655a8 100644
--- a/lib/kunit/Makefile
+++ b/lib/kunit/Makefile
@@ -10,7 +10,8 @@ kunit-objs +=				test.o \
 					executor.o \
 					attributes.o \
 					device.o \
-					platform.o
+					platform.o \
+					fwnode.o
 
 ifeq ($(CONFIG_KUNIT_DEBUGFS),y)
 kunit-objs +=				debugfs.o
diff --git a/lib/kunit/fwnode.c b/lib/kunit/fwnode.c
new file mode 100644
index 0000000000000000000000000000000000000000..bc8bf06762dd71a741a3419c1ca04028d6ad3ec8
--- /dev/null
+++ b/lib/kunit/fwnode.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) Qualcomm Technologies, Inc. and/or its subsidiaries
+ */
+
+#include <kunit/fwnode.h>
+#include <kunit/test.h>
+
+#include <linux/fwnode.h>
+#include <linux/property.h>
+
+static void kunit_software_node_unregister(void *data)
+{
+	const struct software_node *swnode = data;
+
+	software_node_unregister(swnode);
+}
+
+/**
+ * kunit_software_node_register() - Register a KUnit-managed software node
+ * @test: test context
+ * @swnode: Software node to register
+ *
+ * Register a test-managed software node and return its firmware node handle.
+ * The software node is unregistered after the test case completes.
+ *
+ * Return: Firmware node handle of the registered software node or IS_ERR()
+ * on failure.
+ */
+struct fwnode_handle *
+kunit_software_node_register(struct kunit *test,
+			     const struct software_node *swnode)
+{
+	struct fwnode_handle *fwnode;
+	int ret;
+
+	ret = software_node_register(swnode);
+	if (ret)
+		return ERR_PTR(ret);
+
+	fwnode = software_node_fwnode(swnode);
+	if (WARN_ON(!fwnode))
+		return ERR_PTR(-ENOENT);
+
+	ret = kunit_add_action_or_reset(test, kunit_software_node_unregister,
+					(void *)swnode);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return fwnode;
+}
+EXPORT_SYMBOL_GPL(kunit_software_node_register);

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v5 7/7] driver core: platform: tests: add test cases for correct swnode removal
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2026-05-12 11:59 ` [PATCH v5 6/7] kunit: provide kunit_software_node_register() Bartosz Golaszewski
@ 2026-05-12 11:59 ` Bartosz Golaszewski
  2026-05-12 15:07 ` [PATCH v5 0/7] driver core: remove software node from platform devices on device release Danilo Krummrich
  7 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 11:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter
  Cc: brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Bartosz Golaszewski

Extend the kunit module for platform devices with test cases verifying
that the same software node can be added to platform devices repeatedly.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/base/test/platform-device-test.c | 168 +++++++++++++++++++++++++++++++
 1 file changed, 168 insertions(+)

diff --git a/drivers/base/test/platform-device-test.c b/drivers/base/test/platform-device-test.c
index 6355a2231b741791b54eb78af42e13f31f745184..3e42c205fc935ab1dd2066e257d4ecf837c9ad79 100644
--- a/drivers/base/test/platform-device-test.c
+++ b/drivers/base/test/platform-device-test.c
@@ -1,12 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <kunit/fwnode.h>
 #include <kunit/platform_device.h>
 #include <kunit/resource.h>
 
 #include <linux/device.h>
 #include <linux/device/bus.h>
+#include <linux/fwnode.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 
 #define DEVICE_NAME "test"
 
@@ -253,9 +256,174 @@ static struct kunit_suite platform_device_match_test_suite = {
 	.test_cases = platform_device_match_tests,
 };
 
+static int platform_device_swnode_test_probe(struct platform_device *pdev)
+{
+	return 0;
+}
+
+static struct platform_driver platform_swnode_test_driver = {
+	.probe = platform_device_swnode_test_probe,
+	.driver = {
+		.name = DEVICE_NAME,
+	},
+};
+
+static const struct software_node platform_device_test_swnode = { };
+
+/*
+ * Check that reusing a software node works correctly. If the call to
+ * platform_device_register_full() fails after adding the secondary firmware
+ * node, the software node must be unregistered in the device's release()
+ * callback or the subsequent call to platform_device_register_full() will fail
+ * with -EBUSY due to the software node aleady having been registered.
+ */
+static void platform_device_swnode_add_twice(struct kunit *test)
+{
+	struct platform_device_info pdevinfo;
+	struct platform_device *pdev;
+	struct fwnode_handle fwnode;
+	int ret;
+
+	ret = kunit_platform_driver_register(test, &platform_swnode_test_driver);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	fwnode_init(&fwnode, NULL);
+	pdevinfo = (struct platform_device_info){
+		.name = DEVICE_NAME,
+		.id = PLATFORM_DEVID_NONE,
+		.fwnode = &fwnode,
+		.swnode = &platform_device_test_swnode,
+	};
+
+	pdev = platform_device_register_full(&pdevinfo);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
+
+	wait_for_device_probe();
+	KUNIT_ASSERT_TRUE(test, device_is_bound(&pdev->dev));
+
+	platform_device_unregister(pdev);
+
+	pdev = platform_device_register_full(&pdevinfo);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
+
+	wait_for_device_probe();
+	KUNIT_ASSERT_TRUE(test, device_is_bound(&pdev->dev));
+
+	platform_device_unregister(pdev);
+}
+
+/*
+ * Check that passing a software node as the primary firmware node of the
+ * platform device does not result in it being unregistered by the call to
+ * device_remove_software_node() in its release path.
+ */
+static void platform_device_swnode_as_primary(struct kunit *test)
+{
+	struct platform_device_info pdevinfo;
+	struct platform_device *pdev;
+	struct fwnode_handle *fwnode;
+	int ret;
+
+	ret = kunit_platform_driver_register(test, &platform_swnode_test_driver);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	fwnode = kunit_software_node_register(test, &platform_device_test_swnode);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fwnode);
+
+	pdevinfo = (struct platform_device_info){
+		.name = DEVICE_NAME,
+		.id = PLATFORM_DEVID_NONE,
+		.fwnode = fwnode,
+	};
+
+	pdev = platform_device_register_full(&pdevinfo);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
+
+	wait_for_device_probe();
+	KUNIT_ASSERT_TRUE(test, device_is_bound(&pdev->dev));
+
+	platform_device_unregister(pdev);
+
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, software_node_fwnode(&platform_device_test_swnode));
+}
+
+static const struct software_node platform_device_test_primary_swnode = { };
+
+/*
+ * Check that passing two software nodes to platform_device_register_full()
+ * fails.
+ */
+static void platform_device_two_swnodes(struct kunit *test)
+{
+	static const struct property_entry properties[] = {
+		PROPERTY_ENTRY_U32("foo", 42),
+		{ }
+	};
+
+	struct platform_device_info pdevinfo;
+	struct platform_device *pdev;
+	struct fwnode_handle *fwnode;
+	int ret;
+
+	ret = kunit_platform_driver_register(test, &platform_swnode_test_driver);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	fwnode = kunit_software_node_register(test, &platform_device_test_swnode);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fwnode);
+
+	pdevinfo = (struct platform_device_info){
+		.name = DEVICE_NAME,
+		.id = PLATFORM_DEVID_NONE,
+		.fwnode = fwnode,
+		.swnode = &platform_device_test_swnode,
+	};
+
+	pdev = platform_device_register_full(&pdevinfo);
+	KUNIT_ASSERT_TRUE(test, IS_ERR(pdev));
+	KUNIT_ASSERT_EQ_MSG(test, PTR_ERR(pdev), -EINVAL,
+			    "Expected errno == -EINVAL, got: %pe", pdev);
+
+	pdevinfo = (struct platform_device_info){
+		.name = DEVICE_NAME,
+		.id = PLATFORM_DEVID_NONE,
+		.swnode = &platform_device_test_swnode,
+		.properties = properties,
+	};
+
+	pdev = platform_device_register_full(&pdevinfo);
+	KUNIT_ASSERT_TRUE(test, IS_ERR(pdev));
+	KUNIT_ASSERT_EQ_MSG(test, PTR_ERR(pdev), -EINVAL,
+			    "Expected errno == -EINVAL, got: %pe", pdev);
+
+	pdevinfo = (struct platform_device_info){
+		.name = DEVICE_NAME,
+		.id = PLATFORM_DEVID_NONE,
+		.fwnode = fwnode,
+		.properties = properties,
+	};
+
+	pdev = platform_device_register_full(&pdevinfo);
+	KUNIT_ASSERT_TRUE(test, IS_ERR(pdev));
+	KUNIT_ASSERT_EQ_MSG(test, PTR_ERR(pdev), -EINVAL,
+			    "Expected errno == -EINVAL, got: %pe", pdev);
+}
+
+static struct kunit_case platform_device_swnode_tests[] = {
+	KUNIT_CASE(platform_device_swnode_add_twice),
+	KUNIT_CASE(platform_device_swnode_as_primary),
+	KUNIT_CASE(platform_device_two_swnodes),
+	{}
+};
+
+static struct kunit_suite platform_device_swnode_test_suite = {
+	.name = "platform-device-swnode",
+	.test_cases = platform_device_swnode_tests,
+};
+
 kunit_test_suites(
 	&platform_device_devm_test_suite,
 	&platform_device_match_test_suite,
+	&platform_device_swnode_test_suite,
 );
 
 MODULE_DESCRIPTION("Test module for platform devices");

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 0/7] driver core: remove software node from platform devices on device release
  2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2026-05-12 11:59 ` [PATCH v5 7/7] driver core: platform: tests: add test cases for correct swnode removal Bartosz Golaszewski
@ 2026-05-12 15:07 ` Danilo Krummrich
  7 siblings, 0 replies; 14+ messages in thread
From: Danilo Krummrich @ 2026-05-12 15:07 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Dmitry Torokhov,
	Brendan Higgins, David Gow, Rae Moar, Andy Shevchenko,
	Maximilian Luz, Hans de Goede, Ilpo Järvinen, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel, Andy Shevchenko

On Tue May 12, 2026 at 1:59 PM CEST, Bartosz Golaszewski wrote:
> The first 5 patches are part of the fix and the remaining two add tests which
> can't really do harm.

I think we only need patch 1,3,4 as prerequisites to not introduce a regression
with the fix in patch 5. 2,6,7 can go through -next subsequently?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 6/7] kunit: provide kunit_software_node_register()
  2026-05-12 11:59 ` [PATCH v5 6/7] kunit: provide kunit_software_node_register() Bartosz Golaszewski
@ 2026-05-12 15:28   ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-05-12 15:28 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter, brgl, driver-core,
	linux-kernel, linux-kselftest, kunit-dev, platform-driver-x86,
	intel-xe, dri-devel

On Tue, May 12, 2026 at 3:00 PM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> Implement a helper for registering kunit test-managed software nodes.

...

> @@ -10,7 +10,8 @@ kunit-objs +=                         test.o \
>                                         executor.o \
>                                         attributes.o \
>                                         device.o \
> -                                       platform.o
> +                                       platform.o \
> +                                       fwnode.o

You may put it after device.o, 1 line less to change.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 4/7] drm/xe/i2c: use platform_device_add_software_node()
  2026-05-12 11:59 ` [PATCH v5 4/7] drm/xe/i2c: use platform_device_add_software_node() Bartosz Golaszewski
@ 2026-05-12 16:24   ` Danilo Krummrich
  0 siblings, 0 replies; 14+ messages in thread
From: Danilo Krummrich @ 2026-05-12 16:24 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Dmitry Torokhov,
	Brendan Higgins, David Gow, Rae Moar, Andy Shevchenko,
	Maximilian Luz, Hans de Goede, Ilpo Järvinen, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel

On Tue May 12, 2026 at 1:59 PM CEST, Bartosz Golaszewski wrote:
> diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
> index 706783863d07d66b4685005d6649b3cd143ecc3b..7f4295e7dc74f112abff8427485b5c8a5ad71383 100644
> --- a/drivers/gpu/drm/xe/xe_i2c.c
> +++ b/drivers/gpu/drm/xe/xe_i2c.c
> @@ -53,6 +53,10 @@ static const struct property_entry xe_i2c_adapter_properties[] = {
>  	{ }
>  };
>  
> +static const struct software_node xe_i2c_adapter_swnode = {
> +	.properties = xe_i2c_adapter_properties,
> +};
> +
>  static inline void xe_i2c_read_endpoint(struct xe_mmio *mmio, void *ep)
>  {
>  	u32 *val = ep;
> @@ -96,10 +100,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
>  	struct fwnode_handle *fwnode;
>  	int ret;
>  
> -	fwnode = fwnode_create_software_node(xe_i2c_adapter_properties, NULL);
> -	if (IS_ERR(fwnode))
> -		return PTR_ERR(fwnode);
> -
>  	/*
>  	 * Not using platform_device_register_full() here because we don't have
>  	 * a handle to the platform_device before it returns. xe_i2c_notifier()
> @@ -107,10 +107,12 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
>  	 * platform_device_register_full() is done.
>  	 */
>  	pdev = platform_device_alloc(adapter_name, pci_dev_id(pci));
> -	if (!pdev) {
> -		ret = -ENOMEM;
> -		goto err_fwnode_remove;
> -	}
> +	if (!pdev)
> +		return -ENOMEM;
> +
> +	ret = platform_device_add_software_node(pdev, &xe_i2c_adapter_swnode);

By calling platform_device_add_software_node() the platform device technically
takes ownership of the struct software_node managing its lifetime, by removing
it in release().

However, this is not properly reflected by the
platform_device_add_software_node() API, as it just stores the pointer given by
the driver, which in this case is a pointer to module memory.

The platform device is reference counted and can outlive the module.

So, I think analogous to platform_device_add_data() we need to make a copy of
the struct software_node in platform_device_add_software_node().

> +	if (ret)
> +		goto err_pdev_put;
>  
>  	if (i2c->adapter_irq) {
>  		struct resource res;
> @@ -123,7 +125,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
>  	}
>  
>  	pdev->dev.parent = i2c->drm_dev;
> -	pdev->dev.fwnode = fwnode;
>  	i2c->adapter_node = fwnode;
>  	i2c->pdev = pdev;
>  
> @@ -135,8 +136,6 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
>  
>  err_pdev_put:
>  	platform_device_put(pdev);
> -err_fwnode_remove:
> -	fwnode_remove_software_node(fwnode);

There is another call to this in  xe_i2c_unregister_adapter(), which I think was
missed.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node()
  2026-05-12 11:59 ` [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node() Bartosz Golaszewski
@ 2026-05-12 16:31   ` Danilo Krummrich
  2026-05-12 18:15     ` Dmitry Torokhov
  2026-05-13 11:55     ` Bartosz Golaszewski
  0 siblings, 2 replies; 14+ messages in thread
From: Danilo Krummrich @ 2026-05-12 16:31 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Dmitry Torokhov,
	Brendan Higgins, David Gow, Rae Moar, Andy Shevchenko,
	Maximilian Luz, Hans de Goede, Ilpo Järvinen, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel

On Tue May 12, 2026 at 1:59 PM CEST, Bartosz Golaszewski wrote:
> +int platform_device_add_software_node(struct platform_device *pdev,
> +				      const struct software_node *swnode)
> +{
> +	return device_add_software_node(&pdev->dev, swnode);

I think this should be device_create_managed_software_node(), see also [1].

That said, now that I see the resulting code and the corresponding subleties, I
think we should reconsider your (well predicted) "temporary
platform_device_release_full()" idea for -fixes, while iterating this for -next.

[1] https://lore.kernel.org/driver-core/DIGU67TAWF7W.1DWZMO4XAVK7G@kernel.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node()
  2026-05-12 16:31   ` Danilo Krummrich
@ 2026-05-12 18:15     ` Dmitry Torokhov
  2026-05-13 11:55     ` Bartosz Golaszewski
  1 sibling, 0 replies; 14+ messages in thread
From: Dmitry Torokhov @ 2026-05-12 18:15 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Bartosz Golaszewski, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Andy Shevchenko,
	Maximilian Luz, Hans de Goede, Ilpo Järvinen, Matthew Brost,
	Thomas Hellström, Rodrigo Vivi, David Airlie, Simona Vetter,
	brgl, driver-core, linux-kernel, linux-kselftest, kunit-dev,
	platform-driver-x86, intel-xe, dri-devel

On Tue, May 12, 2026 at 06:31:44PM +0200, Danilo Krummrich wrote:
> On Tue May 12, 2026 at 1:59 PM CEST, Bartosz Golaszewski wrote:
> > +int platform_device_add_software_node(struct platform_device *pdev,
> > +				      const struct software_node *swnode)
> > +{
> > +	return device_add_software_node(&pdev->dev, swnode);
> 
> I think this should be device_create_managed_software_node(), see also [1].

The main issue is that we do not know if the software node is registered
or not when platform device is registered, and are trying to use
heuristic to figure it out and decide if we need to clean it up or not.

You need a new variant of device_add_software_node()
(device_set_software_node ?) that would bump up reference of already
registered software nodes but if node is not registered yet created it
as managed.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node()
  2026-05-12 16:31   ` Danilo Krummrich
  2026-05-12 18:15     ` Dmitry Torokhov
@ 2026-05-13 11:55     ` Bartosz Golaszewski
  1 sibling, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-13 11:55 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Bartosz Golaszewski, Greg Kroah-Hartman, Rafael J. Wysocki,
	Dmitry Torokhov, Brendan Higgins, David Gow, Rae Moar,
	Andy Shevchenko, Maximilian Luz, Hans de Goede,
	Ilpo Järvinen, Matthew Brost, Thomas Hellström,
	Rodrigo Vivi, David Airlie, Simona Vetter, driver-core,
	linux-kernel, linux-kselftest, kunit-dev, platform-driver-x86,
	intel-xe, dri-devel

On Tue, May 12, 2026 at 6:31 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> On Tue May 12, 2026 at 1:59 PM CEST, Bartosz Golaszewski wrote:
> > +int platform_device_add_software_node(struct platform_device *pdev,
> > +                                   const struct software_node *swnode)
> > +{
> > +     return device_add_software_node(&pdev->dev, swnode);
>
> I think this should be device_create_managed_software_node(), see also [1].
>
> That said, now that I see the resulting code and the corresponding subleties, I
> think we should reconsider your (well predicted) "temporary
> platform_device_release_full()" idea for -fixes, while iterating this for -next.
>

Agreed, I think it's much safer this way.

Bart

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-05-13 11:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 11:59 [PATCH v5 0/7] driver core: remove software node from platform devices on device release Bartosz Golaszewski
2026-05-12 11:59 ` [PATCH v5 1/7] platform/surface: gpe: use platform_device_register_full() Bartosz Golaszewski
2026-05-12 11:59 ` [PATCH v5 2/7] driver core: platform: make the swnode check stricter Bartosz Golaszewski
2026-05-12 11:59 ` [PATCH v5 3/7] driver core: platform: provide platform_device_add_software_node() Bartosz Golaszewski
2026-05-12 16:31   ` Danilo Krummrich
2026-05-12 18:15     ` Dmitry Torokhov
2026-05-13 11:55     ` Bartosz Golaszewski
2026-05-12 11:59 ` [PATCH v5 4/7] drm/xe/i2c: use platform_device_add_software_node() Bartosz Golaszewski
2026-05-12 16:24   ` Danilo Krummrich
2026-05-12 11:59 ` [PATCH v5 5/7] driver core: platform: remove software node on release() Bartosz Golaszewski
2026-05-12 11:59 ` [PATCH v5 6/7] kunit: provide kunit_software_node_register() Bartosz Golaszewski
2026-05-12 15:28   ` Andy Shevchenko
2026-05-12 11:59 ` [PATCH v5 7/7] driver core: platform: tests: add test cases for correct swnode removal Bartosz Golaszewski
2026-05-12 15:07 ` [PATCH v5 0/7] driver core: remove software node from platform devices on device release Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox