Skip to contentSkip to conversation

software node: allow referencing firmware nodes

PATCH Jiawen Wu 3 participants 7 messages Dec 23, 2025 – Dec 24, 2025

Subsystems (6)
Sound ACPI GPIO SPI +2 more subsystems
lore
Share & tools
lore

Jiawen Wu

author
#0 lore raw

Hi Bartosz Golaszewski,

Quoted 24 lines
include/linux/property.h +4 -2
index 50b26589dd70d1..272bfbdea7bf4a 100644
@@ -355,19 +355,26 @@ struct software_node;
 
 /**
  * struct software_node_ref_args - Reference property with additional arguments
- * @node: Reference to a software node
+ * @swnode: Reference to a software node
+ * @fwnode: Alternative reference to a firmware node handle
  * @nargs: Number of elements in @args array
  * @args: Integer arguments
  */
 struct software_node_ref_args {
-	const struct software_node *node;
+	const struct software_node *swnode;
+	struct fwnode_handle *fwnode;
 	unsigned int nargs;
 	u64 args[NR_FWNODE_REFERENCE_ARGS];
 };
 
 #define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
 (const struct software_node_ref_args) {				\

include/linux/property.h struct software_node; · line 380

Quoted 10 lines
include/linux/property.h +6 -1
-	.node = _ref_,						\
+	.swnode = _Generic(_ref_,				\
+			   const struct software_node *: _ref_,	\
+			   default: NULL),			\
+	.fwnode = _Generic(_ref_,				\
+			   struct fwnode_handle *: _ref_,	\
+			   default: NULL),			\
 	.nargs = COUNT_ARGS(__VA_ARGS__),			\
 	.args = { __VA_ARGS__ },				\
 }

This change seems incompatible with my driver txgbe, since the software nodes are registered in " struct software_node * " but not " const struct software_node * ".

So when I pulled the net-next-6.19-rc1 that merged this patch, to probe my driver. The error logs shows:

[    5.243396] txgbe 0000:10:00.0 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    5.243399] txgbe 0000:10:00.0: failed to init phylink
[    5.576008] txgbe 0000:10:00.0: probe with driver txgbe failed with error -22
[    6.109548] txgbe 0000:10:00.1 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    6.109551] txgbe 0000:10:00.1: failed to init phylink
[    6.442044] txgbe 0000:10:00.1: probe with driver txgbe failed with error -22
#1 lore raw
Quoted 21 lines · Jiawen Wu
Quoted 4 lines

#define SOFTWARE_NODE_REFERENCE(_ref_, ...) \
(const struct software_node_ref_args) { \

Review

Quoted 10 lines
(quoted diff) +6 -1
-     .node = _ref_,                                          \
+     .swnode = _Generic(_ref_,                               \
+                        const struct software_node *: _ref_, \
+                        default: NULL),                      \
+     .fwnode = _Generic(_ref_,                               \
+                        struct fwnode_handle *: _ref_,       \
+                        default: NULL),                      \
      .nargs = COUNT_ARGS(__VA_ARGS__),                       \
      .args = { __VA_ARGS__ },                                \
 }

This change seems incompatible with my driver txgbe, since the software nodes are registered in " struct software_node * " but not " const struct software_node * ".

So when I pulled the net-next-6.19-rc1 that merged this patch, to probe my driver. The error logs shows:

Quoted 7 lines
[    5.243396] txgbe 0000:10:00.0 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    5.243399] txgbe 0000:10:00.0: failed to init phylink
[    5.576008] txgbe 0000:10:00.0: probe with driver txgbe failed with error -22
[    6.109548] txgbe 0000:10:00.1 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    6.109551] txgbe 0000:10:00.1: failed to init phylink
[    6.442044] txgbe 0000:10:00.1: probe with driver txgbe failed with error -22

This shouldn't have changed anything for existing software nodes - the pointer in struct software_node_ref_args has always been const. This would have failed at build-time if this was an issue. Have you bisected it to this very commit? What line is the -EINVAL assigned and for what reason?

Bart

author
#2 lore raw
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Jiawen Wu
Quoted 4 lines

#define SOFTWARE_NODE_REFERENCE(_ref_, ...) \
(const struct software_node_ref_args) { \

Review

Quoted 10 lines
(quoted diff) +6 -1
-     .node = _ref_,                                          \
+     .swnode = _Generic(_ref_,                               \
+                        const struct software_node *: _ref_, \
+                        default: NULL),                      \
+     .fwnode = _Generic(_ref_,                               \
+                        struct fwnode_handle *: _ref_,       \
+                        default: NULL),                      \
      .nargs = COUNT_ARGS(__VA_ARGS__),                       \
      .args = { __VA_ARGS__ },                                \
 }

This change seems incompatible with my driver txgbe, since the software nodes are registered in " struct software_node * " but not " const struct software_node * ".

So when I pulled the net-next-6.19-rc1 that merged this patch, to probe my driver. The error logs shows:

Quoted 7 lines
[    5.243396] txgbe 0000:10:00.0 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    5.243399] txgbe 0000:10:00.0: failed to init phylink
[    5.576008] txgbe 0000:10:00.0: probe with driver txgbe failed with error -22
[    6.109548] txgbe 0000:10:00.1 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    6.109551] txgbe 0000:10:00.1: failed to init phylink
[    6.442044] txgbe 0000:10:00.1: probe with driver txgbe failed with error -22
Quoted 5 lines

This shouldn't have changed anything for existing software nodes - the pointer in struct software_node_ref_args has always been const. This would have failed at build-time if this was an issue. Have you bisected it to this very commit? What line is the -EINVAL assigned and for what reason?

The -EINVAL is assigned software_node_get_reference_args():

	if (ref->swnode)
		refnode = software_node_fwnode(ref->swnode);
	else if (ref->fwnode)
		refnode = ref->fwnode;
	else
		return -EINVAL;

I think the reason is that _Generic selection is restrictive, it only accept exactly const struct software_node for software node references. So the macro SOFTWARE_NODE_REFERENCE fall back to the default to set .swnode = NULL.

And I temporarily added this line to fix it:

include/linux/property.h +1 -0
index 272bfbdea7bf..e30ef23a9af3 100644
@@ -371,6 +371,7 @@ struct software_node_ref_args {
 (const struct software_node_ref_args) {                                \
        .swnode = _Generic(_ref_,                               \
                           const struct software_node *: _ref_, \
+                          struct software_node *: _ref_,       \
                           default: NULL),                      \
        .fwnode = _Generic(_ref_,                               \
                           struct fwnode_handle *: _ref_,       \
#3 lore raw
Quoted 59 lines · Jiawen Wu
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Jiawen Wu
Quoted 4 lines

#define SOFTWARE_NODE_REFERENCE(_ref_, ...) \
(const struct software_node_ref_args) { \

Review

Quoted 10 lines
(quoted diff) +6 -1
-     .node = _ref_,                                          \
+     .swnode = _Generic(_ref_,                               \
+                        const struct software_node *: _ref_, \
+                        default: NULL),                      \
+     .fwnode = _Generic(_ref_,                               \
+                        struct fwnode_handle *: _ref_,       \
+                        default: NULL),                      \
      .nargs = COUNT_ARGS(__VA_ARGS__),                       \
      .args = { __VA_ARGS__ },                                \
 }

This change seems incompatible with my driver txgbe, since the software nodes are registered in " struct software_node * " but not " const struct software_node * ".

So when I pulled the net-next-6.19-rc1 that merged this patch, to probe my driver. The error logs shows:

Quoted 7 lines
[    5.243396] txgbe 0000:10:00.0 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    5.243399] txgbe 0000:10:00.0: failed to init phylink
[    5.576008] txgbe 0000:10:00.0: probe with driver txgbe failed with error -22
[    6.109548] txgbe 0000:10:00.1 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    6.109551] txgbe 0000:10:00.1: failed to init phylink
[    6.442044] txgbe 0000:10:00.1: probe with driver txgbe failed with error -22
Quoted 5 lines

This shouldn't have changed anything for existing software nodes - the pointer in struct software_node_ref_args has always been const. This would have failed at build-time if this was an issue. Have you bisected it to this very commit? What line is the -EINVAL assigned and for what reason?

The -EINVAL is assigned software_node_get_reference_args():

        if (ref->swnode)
                refnode = software_node_fwnode(ref->swnode);
        else if (ref->fwnode)
                refnode = ref->fwnode;
        else
                return -EINVAL;

I think the reason is that _Generic selection is restrictive, it only accept exactly const struct software_node for software node references. So the macro SOFTWARE_NODE_REFERENCE fall back to the default to set .swnode = NULL.

And I temporarily added this line to fix it:

include/linux/property.h +0 -0
index 272bfbdea7bf..e30ef23a9af3 100644

include/linux/property.h struct software_node_ref_args { · line 377

Quoted 7 lines
include/linux/property.h +1 -0
@@ -371,6 +371,7 @@ struct software_node_ref_args {
 (const struct software_node_ref_args) {                                \
        .swnode = _Generic(_ref_,                               \
                           const struct software_node *: _ref_, \
+                          struct software_node *: _ref_,       \
                           default: NULL),                      \
        .fwnode = _Generic(_ref_,                               \
                           struct fwnode_handle *: _ref_,       \

Ah I see, we'd assign struct software_node * to const struct software_node * and it used to work but with _Generic() we need the exact type. I agree with this approach, do you want to send a proper patch?

Bart

author
#4 lore raw
Quoted 64 lines · Bartosz Golaszewski
Quoted 63 lines · Jiawen Wu
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Jiawen Wu
Quoted 4 lines

#define SOFTWARE_NODE_REFERENCE(_ref_, ...) \
(const struct software_node_ref_args) { \

Review

Quoted 10 lines
(quoted diff) +6 -1
-     .node = _ref_,                                          \
+     .swnode = _Generic(_ref_,                               \
+                        const struct software_node *: _ref_, \
+                        default: NULL),                      \
+     .fwnode = _Generic(_ref_,                               \
+                        struct fwnode_handle *: _ref_,       \
+                        default: NULL),                      \
      .nargs = COUNT_ARGS(__VA_ARGS__),                       \
      .args = { __VA_ARGS__ },                                \
 }

This change seems incompatible with my driver txgbe, since the software nodes are registered in " struct software_node * " but not " const struct software_node * ".

So when I pulled the net-next-6.19-rc1 that merged this patch, to probe my driver. The error logs shows:

Quoted 7 lines
[    5.243396] txgbe 0000:10:00.0 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    5.243399] txgbe 0000:10:00.0: failed to init phylink
[    5.576008] txgbe 0000:10:00.0: probe with driver txgbe failed with error -22
[    6.109548] txgbe 0000:10:00.1 (unnamed net_device) (uninitialized): unable to attach SFP bus: -EINVAL
[    6.109551] txgbe 0000:10:00.1: failed to init phylink
[    6.442044] txgbe 0000:10:00.1: probe with driver txgbe failed with error -22
Quoted 5 lines

This shouldn't have changed anything for existing software nodes - the pointer in struct software_node_ref_args has always been const. This would have failed at build-time if this was an issue. Have you bisected it to this very commit? What line is the -EINVAL assigned and for what reason?

The -EINVAL is assigned software_node_get_reference_args():

        if (ref->swnode)
                refnode = software_node_fwnode(ref->swnode);
        else if (ref->fwnode)
                refnode = ref->fwnode;
        else
                return -EINVAL;

I think the reason is that _Generic selection is restrictive, it only accept exactly const struct software_node for software node references. So the macro SOFTWARE_NODE_REFERENCE fall back to the default to set .swnode = NULL.

And I temporarily added this line to fix it:

include/linux/property.h +1 -0
index 272bfbdea7bf..e30ef23a9af3 100644
@@ -371,6 +371,7 @@ struct software_node_ref_args {
 (const struct software_node_ref_args) {                                \
        .swnode = _Generic(_ref_,                               \
                           const struct software_node *: _ref_, \
+                          struct software_node *: _ref_,       \
                           default: NULL),                      \
Quoted 8 lines

include/linux/property.h struct software_node_ref_args { · line 377

Quoted 3 lines
include/linux/property.h +0 -0
        .fwnode = _Generic(_ref_,                               \
                           struct fwnode_handle *: _ref_,       \

Ah I see, we'd assign struct software_node * to const struct software_node * and it used to work but with _Generic() we need the exact type. I agree with this approach, do you want to send a proper patch?

It might be more appropriate for you to send the patch, and could also check if there are any other missed details, like for fwnode... I'm not very proficient in this field. :)

maintainer
#5 lore raw
Quoted 23 lines · Jiawen Wu
Quoted 13 lines · Bartosz Golaszewski
Quoted 12 lines · Jiawen Wu

And I temporarily added this line to fix it:

include/linux/property.h +1 -0
index 272bfbdea7bf..e30ef23a9af3 100644
@@ -371,6 +371,7 @@ struct software_node_ref_args {
 (const struct software_node_ref_args) {                                \
        .swnode = _Generic(_ref_,                               \
                           const struct software_node *: _ref_, \
+                          struct software_node *: _ref_,       \
                           default: NULL),                      \
Quoted 8 lines

include/linux/property.h struct software_node_ref_args { · line 377

Quoted 3 lines
include/linux/property.h +0 -0
        .fwnode = _Generic(_ref_,                               \
                           struct fwnode_handle *: _ref_,       \

Ah I see, we'd assign struct software_node * to const struct software_node * and it used to work but with _Generic() we need the exact type. I agree with this approach, do you want to send a proper patch?

Quoted 3 lines

It might be more appropriate for you to send the patch, and could also check if there are any other missed details, like for fwnode... I'm not very proficient in this field. :)

There is already [1], which I queued up in the driver-core tree to send as fix for -rc3.

[1] https://lore.kernel.org/lkml/[email protected]/

author
#6 lore raw
Quoted 24 lines · Danilo Krummrich
Quoted 23 lines · Jiawen Wu
Quoted 21 lines · Bartosz Golaszewski
Quoted 8 lines · Jiawen Wu

And I temporarily added this line to fix it:

include/linux/property.h +0 -0
index 272bfbdea7bf..e30ef23a9af3 100644

include/linux/property.h struct software_node_ref_args { · line 377

Quoted 7 lines
include/linux/property.h +1 -0
@@ -371,6 +371,7 @@ struct software_node_ref_args {
 (const struct software_node_ref_args) {                                \
        .swnode = _Generic(_ref_,                               \
                           const struct software_node *: _ref_, \
+                          struct software_node *: _ref_,       \
                           default: NULL),                      \
        .fwnode = _Generic(_ref_,                               \
                           struct fwnode_handle *: _ref_,       \

Ah I see, we'd assign struct software_node * to const struct software_node * and it used to work but with _Generic() we need the exact type. I agree with this approach, do you want to send a proper patch?

Quoted 8 lines
Quoted 3 lines

It might be more appropriate for you to send the patch, and could also check if there are any other missed details, like for fwnode... I'm not very proficient in this field. :)

There is already [1], which I queued up in the driver-core tree to send as fix for -rc3.

[1] https://lore.kernel.org/lkml/[email protected]/

I apologize for not noticing this patch... I did something superfluous.