Linux driver-core infrastructure
 help / color / mirror / Atom feed
* [PATCH 0/1]  Add a shared software node test case to driver core
@ 2026-11-18 22:30 Stuart Summers
  2026-11-18 22:30 ` [PATCH 1/1] driver core: platform: tests: add a shared software node test case Stuart Summers
  0 siblings, 1 reply; 5+ messages in thread
From: Stuart Summers @ 2026-11-18 22:30 UTC (permalink / raw)
  Cc: driver-core, bartosz.golaszewski, balasubramani.vivekanandan,
	intel-xe, heikki.krogerus, dakr, andriy.shevchenko,
	Stuart Summers

Original patch was posted here:
https://patchwork.freedesktop.org/series/177785/

This is just a resubmit with a fixed up commit message and this
cover letter.

After dropping that assisted-by tag, just a quick note that I did
use claude opus in the development here.

Stuart Summers (1):
  driver core: platform: tests: add a shared software node test case

 drivers/base/test/platform-device-test.c | 57 ++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

-- 
2.43.0


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

* [PATCH 1/1] driver core: platform: tests: add a shared software node test case
  2026-11-18 22:30 [PATCH 0/1] Add a shared software node test case to driver core Stuart Summers
@ 2026-11-18 22:30 ` Stuart Summers
  2026-11-19 20:50   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Stuart Summers @ 2026-11-18 22:30 UTC (permalink / raw)
  Cc: driver-core, bartosz.golaszewski, balasubramani.vivekanandan,
	intel-xe, heikki.krogerus, dakr, andriy.shevchenko,
	Stuart Summers

Cover the pattern used by drm/xe + i2c-designware, where a software node
assigned as a platform device's primary firmware node is handed to a
second device via device_set_node(), and make sure removing that second
device leaves the owner's node intact.

A potential fix for this issue in the drm/xe driver is being discussed
in [1].

The signature in this case looks like this:
Oops: general protection fault, probably for non-canonical address
0x6b6b6b6b6b6b6b73
RIP: platform_device_release+0x6f/0x80

Link: https://patchwork.freedesktop.org/series/175858/ [1]
Signed-off-by: Stuart Summers <stuart.summers@intel.com>
---
 drivers/base/test/platform-device-test.c | 57 ++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/drivers/base/test/platform-device-test.c b/drivers/base/test/platform-device-test.c
index 9ce563f76aad..378ba7fab2ac 100644
--- a/drivers/base/test/platform-device-test.c
+++ b/drivers/base/test/platform-device-test.c
@@ -420,9 +420,66 @@ static void platform_device_two_swnodes(struct kunit *test)
 			    "Expected errno == -EINVAL, got: %pe", pdev);
 }
 
+static void platform_device_swnode_sharer_release(struct device *dev)
+{
+}
+
+/*
+ * A software node assigned as a platform device's primary firmware node may be
+ * shared with other devices: i2c-designware passes dev_fwnode() of its platform
+ * device down to the i2c adapter device it creates. Check that removing the
+ * sharing device leaves the owner's software node intact.
+ */
+static void platform_device_swnode_shared(struct kunit *test)
+{
+	static const struct property_entry properties[] = {
+		PROPERTY_ENTRY_STRING("compatible", "test,shared-swnode"),
+		{ }
+	};
+	struct fwnode_handle *fwnode;
+	struct platform_device *pdev;
+	struct device *shared;
+	int ret;
+
+	pdev = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
+
+	fwnode = fwnode_create_software_node(properties, NULL);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fwnode);
+	platform_device_set_fwnode(pdev, fwnode);
+
+	ret = platform_device_add(pdev);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	/*
+	 * A second, non-platform device referencing the same fwnode, like the
+	 * i2c adapter device created by i2c-designware.
+	 */
+	shared = kunit_kzalloc(test, sizeof(*shared), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shared);
+
+	device_initialize(shared);
+	shared->release = platform_device_swnode_sharer_release;
+	ret = dev_set_name(shared, "test-swnode-sharer");
+	KUNIT_ASSERT_EQ(test, ret, 0);
+	device_set_node(shared, dev_fwnode(&pdev->dev));
+
+	ret = device_add(shared);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	device_unregister(shared);
+
+	/* The owner must still have its software node. */
+	KUNIT_EXPECT_PTR_EQ(test, dev_fwnode(&pdev->dev), fwnode);
+
+	platform_device_unregister(pdev);
+	fwnode_remove_software_node(fwnode);
+}
+
 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_swnode_shared),
 	KUNIT_CASE(platform_device_two_swnodes),
 	{}
 };
-- 
2.43.0


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

* Re: [PATCH 1/1] driver core: platform: tests: add a shared software node test case
  2026-11-18 22:30 ` [PATCH 1/1] driver core: platform: tests: add a shared software node test case Stuart Summers
@ 2026-11-19 20:50   ` Andy Shevchenko
  2026-11-19 22:37     ` Summers, Stuart
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-11-19 20:50 UTC (permalink / raw)
  To: Stuart Summers
  Cc: driver-core, bartosz.golaszewski, balasubramani.vivekanandan,
	intel-xe, heikki.krogerus, dakr

On Wed, Nov 18, 2026 at 10:30:23PM +0000, Stuart Summers wrote:
> Cover the pattern used by drm/xe + i2c-designware, where a software node
> assigned as a platform device's primary firmware node is handed to a
> second device via device_set_node(), and make sure removing that second
> device leaves the owner's node intact.
> 
> A potential fix for this issue in the drm/xe driver is being discussed
> in [1].
> 
> The signature in this case looks like this:

> Oops: general protection fault, probably for non-canonical address
> 0x6b6b6b6b6b6b6b73

This probably was a single line, make it so in the commit message despite its
length.

> RIP: platform_device_release+0x6f/0x80

...

Test cases are always warmly welcome!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/1] driver core: platform: tests: add a shared software node test case
  2026-11-19 20:50   ` Andy Shevchenko
@ 2026-11-19 22:37     ` Summers, Stuart
  2026-11-19 23:39       ` Danilo Krummrich
  0 siblings, 1 reply; 5+ messages in thread
From: Summers, Stuart @ 2026-11-19 22:37 UTC (permalink / raw)
  To: andriy.shevchenko@linux.intel.com
  Cc: intel-xe@lists.freedesktop.org, Vivekanandan, Balasubramani,
	driver-core@lists.linux.dev, bartosz.golaszewski@oss.qualcomm.com,
	dakr@kernel.org, heikki.krogerus@linux.intel.com

On Thu, 2026-11-19 at 22:50 +0200, Andy Shevchenko wrote:
> On Wed, Nov 18, 2026 at 10:30:23PM +0000, Stuart Summers wrote:
> > Cover the pattern used by drm/xe + i2c-designware, where a software
> > node
> > assigned as a platform device's primary firmware node is handed to
> > a
> > second device via device_set_node(), and make sure removing that
> > second
> > device leaves the owner's node intact.
> > 
> > A potential fix for this issue in the drm/xe driver is being
> > discussed
> > in [1].
> > 
> > The signature in this case looks like this:
> 
> > Oops: general protection fault, probably for non-canonical address
> > 0x6b6b6b6b6b6b6b73
> 
> This probably was a single line, make it so in the commit message
> despite its
> length.

Thanks for the review! Would you like me to fix that up and resend?
I'll likely need help merging so is this something that can be fixed up
as part of the merge?

Thanks,
Stuart

> 
> > RIP: platform_device_release+0x6f/0x80
> 
> ...
> 
> Test cases are always warmly welcome!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 


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

* Re: [PATCH 1/1] driver core: platform: tests: add a shared software node test case
  2026-11-19 22:37     ` Summers, Stuart
@ 2026-11-19 23:39       ` Danilo Krummrich
  0 siblings, 0 replies; 5+ messages in thread
From: Danilo Krummrich @ 2026-11-19 23:39 UTC (permalink / raw)
  To: Summers, Stuart
  Cc: andriy.shevchenko@linux.intel.com, intel-xe@lists.freedesktop.org,
	Vivekanandan, Balasubramani, driver-core@lists.linux.dev,
	bartosz.golaszewski@oss.qualcomm.com,
	heikki.krogerus@linux.intel.com

On Thu Nov 19, 2026 at 11:37 PM CET, Stuart Summers wrote:
> On Thu, 2026-11-19 at 22:50 +0200, Andy Shevchenko wrote:
>> On Wed, Nov 18, 2026 at 10:30:23PM +0000, Stuart Summers wrote:
>> > Cover the pattern used by drm/xe + i2c-designware, where a software
>> > node
>> > assigned as a platform device's primary firmware node is handed to
>> > a
>> > second device via device_set_node(), and make sure removing that
>> > second
>> > device leaves the owner's node intact.
>> > 
>> > A potential fix for this issue in the drm/xe driver is being
>> > discussed
>> > in [1].
>> > 
>> > The signature in this case looks like this:
>> 
>> > Oops: general protection fault, probably for non-canonical address
>> > 0x6b6b6b6b6b6b6b73
>> 
>> This probably was a single line, make it so in the commit message
>> despite its
>> length.
>
> Thanks for the review! Would you like me to fix that up and resend?
> I'll likely need help merging so is this something that can be fixed up
> as part of the merge?

This can be fixed up on apply.

Did you check the Sashiko feedback?

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

end of thread, other threads:[~2026-11-19 23:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 22:30 [PATCH 0/1] Add a shared software node test case to driver core Stuart Summers
2026-11-18 22:30 ` [PATCH 1/1] driver core: platform: tests: add a shared software node test case Stuart Summers
2026-11-19 20:50   ` Andy Shevchenko
2026-11-19 22:37     ` Summers, Stuart
2026-11-19 23:39       ` Danilo Krummrich

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