Skip to contentSkip to conversation

driver core: Don't log intentional skip of device link creation as error

PATCH Superseded Nícolas F. R. A. Prado 4 participants 12 messages Jun 24, 2024 – Dec 17, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: Don't log intentional skip of device link creation as error

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Fixes ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links")
---
 drivers/base/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/base/core.c +7 -2
index 2b4c0624b704..5eaafe3a280c 100644
@@ -2187,8 +2187,13 @@ static int fw_devlink_create_devlink(struct device *con,
 		}
 
 		if (con != sup_dev && !device_link_add(con, sup_dev, flags)) {
-			dev_err(con, "Failed to create device link (0x%x) with %s\n",
-				flags, dev_name(sup_dev));
+			if (flags & DL_FLAG_SYNC_STATE_ONLY &&
+			    con->links.status != DL_DEV_NO_DRIVER &&
+			    con->links.status != DL_DEV_PROBING)
+				dev_dbg(con, "Skipping device link creation for probed device\n");
+			else
+				dev_err(con, "Failed to create device link (0x%x) with %s\n",
+					flags, dev_name(sup_dev));
 			ret = -EINVAL;
 		}
 

---
base-commit: b992b79ca8bc336fa8e2c80990b5af80ed8f36fd
change-id: 20240624-fwdevlink-probed-no-err-45d21feb05fd

Best regards,

Signature · 1 line
Nícolas F. R. A. Prado <[email protected]>
#1 lore raw
Quoted 10 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

There might be a better way to filter things out.

-Saravana

Quoted 36 lines
Fixes ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links")
---
 drivers/base/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/base/core.c +7 -3
index 2b4c0624b704..5eaafe3a280c 100644
@@ -2187,8 +2187,13 @@ static int fw_devlink_create_devlink(struct device *con,
                }
 
                if (con != sup_dev && !device_link_add(con, sup_dev, flags)) {
-                       dev_err(con, "Failed to create device link (0x%x) with %s\n",
-                               flags, dev_name(sup_dev));
+                       if (flags & DL_FLAG_SYNC_STATE_ONLY &&
+                           con->links.status != DL_DEV_NO_DRIVER &&
+                           con->links.status != DL_DEV_PROBING)
+                               dev_dbg(con, "Skipping device link creation for probed device\n");
+                       else
+                               dev_err(con, "Failed to create device link (0x%x) with %s\n",
+                                       flags, dev_name(sup_dev));
                        ret = -EINVAL;
                }
 
 
---

base-commit: b992b79ca8bc336fa8e2c80990b5af80ed8f36fd
change-id: 20240624-fwdevlink-probed-no-err-45d21feb05fd

Best regards,
--
Nícolas F. R. A. Prado <[email protected]>

#2 lore raw
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Full log at https://lava.collabora.dev/scheduler/job/14573149

Thanks,
Nícolas

#3 lore raw
Quoted 30 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

Quoted 8 lines

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Thanks,
Nícolas

#4 lore raw
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

2. If we take this patch, it might be better to make a "useless device links" helper function and use the same on in device_link_add() and in the "if" condition that's used to decide if a device link should be created. The con == sup is another "useless device link" check. But I'm not really sure if we should mask this error as it help with stuff like (1). con == sup is a bit more clear cut example of a "useless device link" in the context of fw_devlink.

-Saravana

#5 lore raw
Quoted 50 lines · Saravana Kannan
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Quoted 7 lines

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

I don't see any cycle there. edp-tx points to backlight, but backlight doesn't point back (from mt8195-cherry.dtsi):

  &edp_tx {
  	...
  	aux-bus {
  		panel {
  			compatible = "edp-panel";
  			power-supply = <&pp3300_disp_x>;
  			backlight = <&backlight_lcd0>;

  
  backlight_lcd0: backlight-lcd0 {
  	compatible = "pwm-backlight";
  	brightness-levels = <0 1023>;
  	default-brightness-level = <576>;
  	enable-gpios = <&pio 82 GPIO_ACTIVE_HIGH>;
  	num-interpolated-steps = <1023>;
  	pwms = <&disp_pwm0 0 500000>;
  	power-supply = <&ppvar_sys>;
  };

And DL_FLAG_CYCLE is not set in the flags in the error log: 0x180. (Let me know if there's something else that I should be looking at to detect a cycle)

Thanks,
Nícolas

Quoted 10 lines

2. If we take this patch, it might be better to make a "useless device links" helper function and use the same on in device_link_add() and in the "if" condition that's used to decide if a device link should be created. The con == sup is another "useless device link" check. But I'm not really sure if we should mask this error as it help with stuff like (1). con == sup is a bit more clear cut example of a "useless device link" in the context of fw_devlink.

-Saravana

#6 lore raw
Quoted 81 lines · Nícolas F. R. A. Prado
Quoted 50 lines · Saravana Kannan
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Quoted 7 lines

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

I don't see any cycle there. edp-tx points to backlight, but backlight doesn't point back (from mt8195-cherry.dtsi):

  &edp_tx {
  	...
  	aux-bus {
  		panel {
  			compatible = "edp-panel";
  			power-supply = <&pp3300_disp_x>;
  			backlight = <&backlight_lcd0>;

  
  backlight_lcd0: backlight-lcd0 {
  	compatible = "pwm-backlight";
  	brightness-levels = <0 1023>;
  	default-brightness-level = <576>;
  	enable-gpios = <&pio 82 GPIO_ACTIVE_HIGH>;
  	num-interpolated-steps = <1023>;
  	pwms = <&disp_pwm0 0 500000>;
  	power-supply = <&ppvar_sys>;
  };
Quoted 2 lines

And DL_FLAG_CYCLE is not set in the flags in the error log: 0x180. (Let me know if there's something else that I should be looking at to detect a cycle)

Hi Saravana,

Here are some debug logs to help contextualize the issue:

  [    0.198518] device: 'backlight-lcd0': device_add
  [    0.198655] platform 1c500000.edp-tx: Linked as a sync state only consumer to backlight-lcd0
  [   34.971653] platform backlight-lcd0: error -EPROBE_DEFER: supplier 1100e000.pwm not ready
  [   35.115480] mediatek-drm-dp 1c500000.edp-tx: driver: 'mediatek-drm-dp': driver_bound: bound to device
  [   35.160115] mediatek-drm-dp 1c500000.edp-tx: Dropping the link to backlight-lcd0
  [   53.910433] pwm-backlight backlight-lcd0: driver: 'pwm-backlight': driver_bound: bound to device
  [   53.919213] mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

So a SYNC_STATE_ONLY device link is created from backlight-lcd0 to edp-tx. When the edp-tx probes, the link is dropped, since it is SYNC_STATE_ONLY. When the backlight-lcd0 probes a new devlink is attempted to the consumer edp-tx and fails, since it is useless, printing the warning.

You mentioned a cycle before. The only cycle I see is between the edp-tx and the panel, but doesn't involve the backlight:

  [    0.198104] ----- cycle: start -----
  [    0.198105] /soc/edp-tx@1c500000/aux-bus/panel: cycle: depends on /soc/edp-tx@1c500000
  [    0.198112] ----- cycle: start -----
  [    0.198113] /soc/edp-tx@1c500000/aux-bus/panel: cycle: child of /soc/edp-tx@1c500000
  [    0.198119] /soc/edp-tx@1c500000: cycle: depends on /soc/edp-tx@1c500000/aux-bus/panel
  [    0.198125] ----- cycle: end -----
  [    0.198126] platform 1c500000.edp-tx: Fixed dependency cycle(s) with /soc/edp-tx@1c500000/aux-bus/panel

Just in case I tried using post-init-providers:

  diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
  index 75d56b2d5a3d..19df138ef043 100644
  --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
  +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
  @@ -322,6 +322,7 @@ &edp_tx {
          pinctrl-names = "default";
          pinctrl-0 = <&edptx_pins_default>;

+ post-init-providers = <&panel>;

          ports {
                  #address-cells = <1>;
  @@ -344,7 +345,7 @@ edp_out: endpoint {
          };
  
          aux-bus {
  -               panel {
  +               panel: panel {
                          compatible = "edp-panel";
                          power-supply = <&pp3300_disp_x>;
                          backlight = <&backlight_lcd0>;

It broke the cycle, as I no longer see it in the logs, but the failed device link warning is still there as expected.

It seems to me that the issue comes form the device link being SYNC_STATE_ONLY in the first place. I see that comes from the 'else' path in

	if (con->fwnode == link->consumer)
		flags = fw_devlink_get_flags(link->flags);
	else
		flags = FW_DEVLINK_FLAGS_PERMISSIVE;

and the value on each side of the comparison is:

con->fwnode: /soc/edp-tx@1c500000 link->consumer: /soc/edp-tx@1c500000/aux-bus/panel

Could you help me understand what (if anything) is wrong here?

(I also noticed that as per the DT the consumer for backlight-lcd0 should be the panel, but the devlink has it instead as the edp-tx, I'm guessing that's another symptom of the same issue)

Thanks,
Nícolas

Quoted 14 lines

Thanks,
Nícolas

Quoted 10 lines

2. If we take this patch, it might be better to make a "useless device links" helper function and use the same on in device_link_add() and in the "if" condition that's used to decide if a device link should be created. The con == sup is another "useless device link" check. But I'm not really sure if we should mask this error as it help with stuff like (1). con == sup is a bit more clear cut example of a "useless device link" in the context of fw_devlink.

-Saravana

#7 lore raw

Hi Nicolas, Saravanna,

Quoted 153 lines · Nícolas F. R. A. Prado
Quoted 81 lines · Nícolas F. R. A. Prado
Quoted 50 lines · Saravana Kannan
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Quoted 7 lines

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

I don't see any cycle there. edp-tx points to backlight, but backlight doesn't point back (from mt8195-cherry.dtsi):

   &edp_tx {
   	...
   	aux-bus {
   		panel {
   			compatible = "edp-panel";
   			power-supply = <&pp3300_disp_x>;
   			backlight = <&backlight_lcd0>;

   
   backlight_lcd0: backlight-lcd0 {
   	compatible = "pwm-backlight";
   	brightness-levels = <0 1023>;
   	default-brightness-level = <576>;
   	enable-gpios = <&pio 82 GPIO_ACTIVE_HIGH>;
   	num-interpolated-steps = <1023>;
   	pwms = <&disp_pwm0 0 500000>;
   	power-supply = <&ppvar_sys>;
   };
Quoted 2 lines

And DL_FLAG_CYCLE is not set in the flags in the error log: 0x180. (Let me know if there's something else that I should be looking at to detect a cycle)

Hi Saravana,

Here are some debug logs to help contextualize the issue:

   [    0.198518] device: 'backlight-lcd0': device_add
   [    0.198655] platform 1c500000.edp-tx: Linked as a sync state only consumer to backlight-lcd0
   [   34.971653] platform backlight-lcd0: error -EPROBE_DEFER: supplier 1100e000.pwm not ready
   [   35.115480] mediatek-drm-dp 1c500000.edp-tx: driver: 'mediatek-drm-dp': driver_bound: bound to device
   [   35.160115] mediatek-drm-dp 1c500000.edp-tx: Dropping the link to backlight-lcd0
   [   53.910433] pwm-backlight backlight-lcd0: driver: 'pwm-backlight': driver_bound: bound to device
   [   53.919213] mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

So a SYNC_STATE_ONLY device link is created from backlight-lcd0 to edp-tx. When the edp-tx probes, the link is dropped, since it is SYNC_STATE_ONLY. When the backlight-lcd0 probes a new devlink is attempted to the consumer edp-tx and fails, since it is useless, printing the warning.

You mentioned a cycle before. The only cycle I see is between the edp-tx and the panel, but doesn't involve the backlight:

   [    0.198104] ----- cycle: start -----
   [    0.198105] /soc/edp-tx@1c500000/aux-bus/panel: cycle: depends on /soc/edp-tx@1c500000
   [    0.198112] ----- cycle: start -----
   [    0.198113] /soc/edp-tx@1c500000/aux-bus/panel: cycle: child of /soc/edp-tx@1c500000
   [    0.198119] /soc/edp-tx@1c500000: cycle: depends on /soc/edp-tx@1c500000/aux-bus/panel
   [    0.198125] ----- cycle: end -----
   [    0.198126] platform 1c500000.edp-tx: Fixed dependency cycle(s) with /soc/edp-tx@1c500000/aux-bus/panel

Just in case I tried using post-init-providers:

   diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   index 75d56b2d5a3d..19df138ef043 100644
   --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   @@ -322,6 +322,7 @@ &edp_tx {
           pinctrl-names = "default";
           pinctrl-0 = <&edptx_pins_default>;
   +       post-init-providers = <&panel>;
   
           ports {
                   #address-cells = <1>;
   @@ -344,7 +345,7 @@ edp_out: endpoint {
           };
   
           aux-bus {
   -               panel {
   +               panel: panel {
                           compatible = "edp-panel";
                           power-supply = <&pp3300_disp_x>;
                           backlight = <&backlight_lcd0>;

It broke the cycle, as I no longer see it in the logs, but the failed device link warning is still there as expected.

It seems to me that the issue comes form the device link being SYNC_STATE_ONLY in the first place. I see that comes from the 'else' path in

	if (con->fwnode == link->consumer)
		flags = fw_devlink_get_flags(link->flags);
	else
		flags = FW_DEVLINK_FLAGS_PERMISSIVE;

and the value on each side of the comparison is:

Quoted 8 lines

con->fwnode: /soc/edp-tx@1c500000 link->consumer: /soc/edp-tx@1c500000/aux-bus/panel

Could you help me understand what (if anything) is wrong here?

(I also noticed that as per the DT the consumer for backlight-lcd0 should be the panel, but the devlink has it instead as the edp-tx, I'm guessing that's another symptom of the same issue)

I did not seen any update on this. It would be great to get this fixed.

Thanks
Jon

Signature · 1 line
nvpublic
#8 lore raw
Quoted 152 lines · Jon Hunter

Hi Nicolas, Saravanna,

Quoted 149 lines · Nícolas F. R. A. Prado
Quoted 80 lines · Nícolas F. R. A. Prado
Quoted 50 lines · Saravana Kannan
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Quoted 7 lines

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

I don't see any cycle there. edp-tx points to backlight, but backlight doesn't point back (from mt8195-cherry.dtsi):

   &edp_tx {
   	...
   	aux-bus {
   		panel {
   			compatible = "edp-panel";
   			power-supply = <&pp3300_disp_x>;
   			backlight = <&backlight_lcd0>;

   backlight_lcd0: backlight-lcd0 {
   	compatible = "pwm-backlight";
   	brightness-levels = <0 1023>;
   	default-brightness-level = <576>;
   	enable-gpios = <&pio 82 GPIO_ACTIVE_HIGH>;
   	num-interpolated-steps = <1023>;
   	pwms = <&disp_pwm0 0 500000>;
   	power-supply = <&ppvar_sys>;
   };
Quoted 2 lines

And DL_FLAG_CYCLE is not set in the flags in the error log: 0x180. (Let me know if there's something else that I should be looking at to detect a cycle)

Hi Saravana,

Here are some debug logs to help contextualize the issue:

   [    0.198518] device: 'backlight-lcd0': device_add
   [    0.198655] platform 1c500000.edp-tx: Linked as a sync state only consumer to backlight-lcd0
   [   34.971653] platform backlight-lcd0: error -EPROBE_DEFER: supplier 1100e000.pwm not ready
   [   35.115480] mediatek-drm-dp 1c500000.edp-tx: driver: 'mediatek-drm-dp': driver_bound: bound to device
   [   35.160115] mediatek-drm-dp 1c500000.edp-tx: Dropping the link to backlight-lcd0
   [   53.910433] pwm-backlight backlight-lcd0: driver: 'pwm-backlight': driver_bound: bound to device
   [   53.919213] mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

So a SYNC_STATE_ONLY device link is created from backlight-lcd0 to edp-tx. When the edp-tx probes, the link is dropped, since it is SYNC_STATE_ONLY. When the backlight-lcd0 probes a new devlink is attempted to the consumer edp-tx and fails, since it is useless, printing the warning.

You mentioned a cycle before. The only cycle I see is between the edp-tx and the panel, but doesn't involve the backlight:

   [    0.198104] ----- cycle: start -----
   [    0.198105] /soc/edp-tx@1c500000/aux-bus/panel: cycle: depends on /soc/edp-tx@1c500000
   [    0.198112] ----- cycle: start -----
   [    0.198113] /soc/edp-tx@1c500000/aux-bus/panel: cycle: child of /soc/edp-tx@1c500000
   [    0.198119] /soc/edp-tx@1c500000: cycle: depends on /soc/edp-tx@1c500000/aux-bus/panel
   [    0.198125] ----- cycle: end -----
   [    0.198126] platform 1c500000.edp-tx: Fixed dependency cycle(s) with /soc/edp-tx@1c500000/aux-bus/panel

Just in case I tried using post-init-providers:

   diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   index 75d56b2d5a3d..19df138ef043 100644
   --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   @@ -322,6 +322,7 @@ &edp_tx {
           pinctrl-names = "default";
           pinctrl-0 = <&edptx_pins_default>;
   +       post-init-providers = <&panel>;
           ports {
                   #address-cells = <1>;
   @@ -344,7 +345,7 @@ edp_out: endpoint {
           };
           aux-bus {
   -               panel {
   +               panel: panel {
                           compatible = "edp-panel";
                           power-supply = <&pp3300_disp_x>;
                           backlight = <&backlight_lcd0>;

It broke the cycle, as I no longer see it in the logs, but the failed device link warning is still there as expected.

It seems to me that the issue comes form the device link being SYNC_STATE_ONLY in the first place. I see that comes from the 'else' path in

	if (con->fwnode == link->consumer)
		flags = fw_devlink_get_flags(link->flags);
	else
		flags = FW_DEVLINK_FLAGS_PERMISSIVE;

and the value on each side of the comparison is:

con->fwnode: /soc/edp-tx@1c500000 link->consumer: /soc/edp-tx@1c500000/aux-bus/panel

Quoted 8 lines
Quoted 5 lines

Could you help me understand what (if anything) is wrong here?

(I also noticed that as per the DT the consumer for backlight-lcd0 should be the panel, but the devlink has it instead as the edp-tx, I'm guessing that's another symptom of the same issue)

I did not seen any update on this. It would be great to get this fixed.

Since there hasn't been a reply on this, let's postpone this investigation and move forward in fixing the error log. I've sent v2 of the patch:
https://lore.kernel.org/all/[email protected]

Thanks,
Nícolas

#9 lore raw
Quoted 161 lines · Nícolas F. R. A. Prado
Quoted 159 lines · Jon Hunter

Hi Nicolas, Saravanna,

Quoted 154 lines · Nícolas F. R. A. Prado
Quoted 80 lines · Nícolas F. R. A. Prado
Quoted 50 lines · Saravana Kannan
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Quoted 7 lines

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

I don't see any cycle there. edp-tx points to backlight, but backlight doesn't point back (from mt8195-cherry.dtsi):

   &edp_tx {
          ...
          aux-bus {
                  panel {
                          compatible = "edp-panel";
                          power-supply = <&pp3300_disp_x>;
                          backlight = <&backlight_lcd0>;

   backlight_lcd0: backlight-lcd0 {
          compatible = "pwm-backlight";
          brightness-levels = <0 1023>;
          default-brightness-level = <576>;
          enable-gpios = <&pio 82 GPIO_ACTIVE_HIGH>;
          num-interpolated-steps = <1023>;
          pwms = <&disp_pwm0 0 500000>;
          power-supply = <&ppvar_sys>;
   };
Quoted 2 lines

And DL_FLAG_CYCLE is not set in the flags in the error log: 0x180. (Let me know if there's something else that I should be looking at to detect a cycle)

Hi Saravana,

Here are some debug logs to help contextualize the issue:

   [    0.198518] device: 'backlight-lcd0': device_add
   [    0.198655] platform 1c500000.edp-tx: Linked as a sync state only consumer to backlight-lcd0
   [   34.971653] platform backlight-lcd0: error -EPROBE_DEFER: supplier 1100e000.pwm not ready
   [   35.115480] mediatek-drm-dp 1c500000.edp-tx: driver: 'mediatek-drm-dp': driver_bound: bound to device
   [   35.160115] mediatek-drm-dp 1c500000.edp-tx: Dropping the link to backlight-lcd0
   [   53.910433] pwm-backlight backlight-lcd0: driver: 'pwm-backlight': driver_bound: bound to device
   [   53.919213] mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

So a SYNC_STATE_ONLY device link is created from backlight-lcd0 to edp-tx. When the edp-tx probes, the link is dropped, since it is SYNC_STATE_ONLY. When the backlight-lcd0 probes a new devlink is attempted to the consumer edp-tx and fails, since it is useless, printing the warning.

You mentioned a cycle before. The only cycle I see is between the edp-tx and the panel, but doesn't involve the backlight:

   [    0.198104] ----- cycle: start -----
   [    0.198105] /soc/edp-tx@1c500000/aux-bus/panel: cycle: depends on /soc/edp-tx@1c500000
   [    0.198112] ----- cycle: start -----
   [    0.198113] /soc/edp-tx@1c500000/aux-bus/panel: cycle: child of /soc/edp-tx@1c500000
   [    0.198119] /soc/edp-tx@1c500000: cycle: depends on /soc/edp-tx@1c500000/aux-bus/panel
   [    0.198125] ----- cycle: end -----
   [    0.198126] platform 1c500000.edp-tx: Fixed dependency cycle(s) with /soc/edp-tx@1c500000/aux-bus/panel

Just in case I tried using post-init-providers:

   diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   index 75d56b2d5a3d..19df138ef043 100644
   --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   @@ -322,6 +322,7 @@ &edp_tx {
           pinctrl-names = "default";
           pinctrl-0 = <&edptx_pins_default>;
   +       post-init-providers = <&panel>;
           ports {
                   #address-cells = <1>;
   @@ -344,7 +345,7 @@ edp_out: endpoint {
           };
           aux-bus {
   -               panel {
   +               panel: panel {
                           compatible = "edp-panel";
                           power-supply = <&pp3300_disp_x>;
                           backlight = <&backlight_lcd0>;

It broke the cycle, as I no longer see it in the logs, but the failed device link warning is still there as expected.

It seems to me that the issue comes form the device link being SYNC_STATE_ONLY in the first place. I see that comes from the 'else' path in

    if (con->fwnode == link->consumer)
            flags = fw_devlink_get_flags(link->flags);
    else
            flags = FW_DEVLINK_FLAGS_PERMISSIVE;

and the value on each side of the comparison is:

con->fwnode: /soc/edp-tx@1c500000 link->consumer: /soc/edp-tx@1c500000/aux-bus/panel

Could you help me understand what (if anything) is wrong here?

(I also noticed that as per the DT the consumer for backlight-lcd0 should be the panel, but the devlink has it instead as the edp-tx, I'm guessing that's another symptom of the same issue)

Quoted 6 lines
Quoted 1 line

I did not seen any update on this. It would be great to get this fixed.

Since there hasn't been a reply on this, let's postpone this investigation and move forward in fixing the error log. I've sent v2 of the patch:
https://lore.kernel.org/all/[email protected]

Sorry for the really long delay Nicolas. All the logs you provides and all the analysis you did so far definitely helped me narrow this down.

Your instinct about devm_of_dp_aux_populate_bus() was right.

Can you try this fix please? I'm 99% sure this will fix the issue. This has been a theme... the log message you saw mostly indicates that the device didn't have its fwnode set.

-Saravana

(quoted diff) +0 -0

b/drivers/gpu/drm/display/drm_dp_aux_bus.c
index d810529ebfb6..ec7eac6b595f 100644

drivers/gpu/drm/display/drm_dp_aux_bus.c +1 -1
@@ -292,7 +292,7 @@ int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
        aux_ep->dev.parent = aux->dev;
        aux_ep->dev.bus = &dp_aux_bus_type;
        aux_ep->dev.type = &dp_aux_device_type_type;
-       aux_ep->dev.of_node = of_node_get(np);
+       device_set_node(&aux_ep->dev, of_fwnode_handle(of_node_get(np)));
        dev_set_name(&aux_ep->dev, "aux-%s", dev_name(aux->dev));
 
        ret = device_register(&aux_ep->dev);

Thanks,
Saravana

author Tested-by
#10 lore raw
Quoted 196 lines · Saravana Kannan
Quoted 161 lines · Nícolas F. R. A. Prado
Quoted 159 lines · Jon Hunter

Hi Nicolas, Saravanna,

Quoted 154 lines · Nícolas F. R. A. Prado
Quoted 80 lines · Nícolas F. R. A. Prado
Quoted 50 lines · Saravana Kannan
Quoted 39 lines · Nícolas F. R. A. Prado
Quoted 37 lines · Nícolas F. R. A. Prado
Quoted 10 lines · Saravana Kannan
Quoted 8 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Quoted 6 lines
Quoted 2 lines

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

Your point is somewhat valid, and I might Ack this. But this really shouldn't be happening a lot. Can you give more context on how you are hitting this?

Of course. I'm seeing this on the mt8195-cherry-tomato-r2 platform.

The following error is printed during boot:

mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

It doesn't happen with the upstream defconfig, but with the following config change it does:

-CONFIG_PWM_MTK_DISP=m
+CONFIG_PWM_MTK_DISP=y

That probably changes the order in which the MTK DP and the backlight drivers probe, resulting in the error.

One peculiarity that comes to mind is that the DP driver calls devm_of_dp_aux_populate_bus() to run a callback once the panel has finished probing. I'm not sure if this could have something to do with the error.

Quoted 6 lines
Quoted 1 line

Full log at https://lava.collabora.dev/scheduler/job/14573149

Hi Saravana,

With the given context for where this issue is happening, what do you think about this patch?

Ah sorry, missed your earlier email.

Quoted 7 lines

Couple of points:
1. It looks like the link in question is "SYNC_STATE_ONLY" because it's part of a cycle. Correct me if I'm wrong. You might want to use the new "post-init-providers" property to help fw_devlink break the cycle and enforce the right dependency between the edp-tx and your backlight. And then this error should go away and your device ordering is enforced a bit better.

I don't see any cycle there. edp-tx points to backlight, but backlight doesn't point back (from mt8195-cherry.dtsi):

   &edp_tx {
          ...
          aux-bus {
                  panel {
                          compatible = "edp-panel";
                          power-supply = <&pp3300_disp_x>;
                          backlight = <&backlight_lcd0>;

   backlight_lcd0: backlight-lcd0 {
          compatible = "pwm-backlight";
          brightness-levels = <0 1023>;
          default-brightness-level = <576>;
          enable-gpios = <&pio 82 GPIO_ACTIVE_HIGH>;
          num-interpolated-steps = <1023>;
          pwms = <&disp_pwm0 0 500000>;
          power-supply = <&ppvar_sys>;
   };
Quoted 2 lines

And DL_FLAG_CYCLE is not set in the flags in the error log: 0x180. (Let me know if there's something else that I should be looking at to detect a cycle)

Hi Saravana,

Here are some debug logs to help contextualize the issue:

   [    0.198518] device: 'backlight-lcd0': device_add
   [    0.198655] platform 1c500000.edp-tx: Linked as a sync state only consumer to backlight-lcd0
   [   34.971653] platform backlight-lcd0: error -EPROBE_DEFER: supplier 1100e000.pwm not ready
   [   35.115480] mediatek-drm-dp 1c500000.edp-tx: driver: 'mediatek-drm-dp': driver_bound: bound to device
   [   35.160115] mediatek-drm-dp 1c500000.edp-tx: Dropping the link to backlight-lcd0
   [   53.910433] pwm-backlight backlight-lcd0: driver: 'pwm-backlight': driver_bound: bound to device
   [   53.919213] mediatek-drm-dp 1c500000.edp-tx: Failed to create device link (0x180) with backlight-lcd0

So a SYNC_STATE_ONLY device link is created from backlight-lcd0 to edp-tx. When the edp-tx probes, the link is dropped, since it is SYNC_STATE_ONLY. When the backlight-lcd0 probes a new devlink is attempted to the consumer edp-tx and fails, since it is useless, printing the warning.

You mentioned a cycle before. The only cycle I see is between the edp-tx and the panel, but doesn't involve the backlight:

   [    0.198104] ----- cycle: start -----
   [    0.198105] /soc/edp-tx@1c500000/aux-bus/panel: cycle: depends on /soc/edp-tx@1c500000
   [    0.198112] ----- cycle: start -----
   [    0.198113] /soc/edp-tx@1c500000/aux-bus/panel: cycle: child of /soc/edp-tx@1c500000
   [    0.198119] /soc/edp-tx@1c500000: cycle: depends on /soc/edp-tx@1c500000/aux-bus/panel
   [    0.198125] ----- cycle: end -----
   [    0.198126] platform 1c500000.edp-tx: Fixed dependency cycle(s) with /soc/edp-tx@1c500000/aux-bus/panel

Just in case I tried using post-init-providers:

   diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   index 75d56b2d5a3d..19df138ef043 100644
   --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
   @@ -322,6 +322,7 @@ &edp_tx {
           pinctrl-names = "default";
           pinctrl-0 = <&edptx_pins_default>;
   +       post-init-providers = <&panel>;
           ports {
                   #address-cells = <1>;
   @@ -344,7 +345,7 @@ edp_out: endpoint {
           };
           aux-bus {
   -               panel {
   +               panel: panel {
                           compatible = "edp-panel";
                           power-supply = <&pp3300_disp_x>;
                           backlight = <&backlight_lcd0>;

It broke the cycle, as I no longer see it in the logs, but the failed device link warning is still there as expected.

It seems to me that the issue comes form the device link being SYNC_STATE_ONLY in the first place. I see that comes from the 'else' path in

    if (con->fwnode == link->consumer)
            flags = fw_devlink_get_flags(link->flags);
    else
            flags = FW_DEVLINK_FLAGS_PERMISSIVE;

and the value on each side of the comparison is:

con->fwnode: /soc/edp-tx@1c500000 link->consumer: /soc/edp-tx@1c500000/aux-bus/panel

Could you help me understand what (if anything) is wrong here?

(I also noticed that as per the DT the consumer for backlight-lcd0 should be the panel, but the devlink has it instead as the edp-tx, I'm guessing that's another symptom of the same issue)

Quoted 6 lines
Quoted 1 line

I did not seen any update on this. It would be great to get this fixed.

Since there hasn't been a reply on this, let's postpone this investigation and move forward in fixing the error log. I've sent v2 of the patch:
https://lore.kernel.org/all/[email protected]

Sorry for the really long delay Nicolas. All the logs you provides and all the analysis you did so far definitely helped me narrow this down.

Your instinct about devm_of_dp_aux_populate_bus() was right.

Can you try this fix please? I'm 99% sure this will fix the issue. This has been a theme... the log message you saw mostly indicates that the device didn't have its fwnode set.

(quoted diff) +0 -1
-Saravana
drivers/gpu/drm/display/drm_dp_aux_bus.c +1 -1
index d810529ebfb6..ec7eac6b595f 100644
@@ -292,7 +292,7 @@ int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
        aux_ep->dev.parent = aux->dev;
        aux_ep->dev.bus = &dp_aux_bus_type;
        aux_ep->dev.type = &dp_aux_device_type_type;
-       aux_ep->dev.of_node = of_node_get(np);
+       device_set_node(&aux_ep->dev, of_fwnode_handle(of_node_get(np)));
        dev_set_name(&aux_ep->dev, "aux-%s", dev_name(aux->dev));
 
        ret = device_register(&aux_ep->dev);
Quoted 2 lines

Thanks,
Saravana

Hi Saravana,

Indeed this fixed the issue! Thank you for tracking this down. Feel free to add when you send the patch

Thanks,
Nícolas

#11 lore raw
In reply to Nícolas F. R. A. Prado
Quoted 9 lines · Nícolas F. R. A. Prado

Commit ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links") introduced an early return in device_link_add() to prevent useless links from being created. However the calling function fw_devlink_create_devlink() unconditionally prints an error if device_link_add() didn't create a link, even in this case where it is intentionally skipping the link creation.

Add a check to detect if the link wasn't created intentionally and in that case don't log an error.

While it was concluded that this patch was not needed to fix the author's issue, I have come across a similar problem that I have not been able to solve:

I'm currently working on a TI AM335x, and after updating to a recent kernel (currently 6.12.4) and fixing the ti-sysc driver to probe in a few cases where it was broken before, I'm now seeing the following messages:

ti-sysc 44e31000.target-module: Failed to create device link (0x180) with ocp ti-sysc 48040000.target-module: Failed to create device link (0x180) with ocp

The direct cause of the failure is the same as noted in this patch: The 44e31000.target-module and 48040000.target-module devices have already been probed at this point, so applying it would hide the error message.

The attempt to create these device links results from a call to __fw_devlink_pickup_dangling_consumers() moving consumers from /ocp/interrupt-controller@48200000 to /ocp. This happens because the interrupt controller driver (irq-omap-intc) is declared using IRQCHIP_DECLARE(), so its fwnode doesn't have an associated device.

As the existence of fwnodes without device is the whole point of __fw_devlink_pickup_dangling_consumers(), I imagine that this is a valid case that should be supported properly. Would it make sense to reconsider this patch, or is there a better solution? The condition for hiding the error message could also be made stricter by introducing a new fwnode_link flag to mark links that have been moved by __fw_devlink_pickup_dangling_consumers().

Best regards,
Matthias

Quoted 34 lines
Fixes ac66c5bbb437 ("driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links")
---
 drivers/base/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/base/core.c +7 -3
index 2b4c0624b704..5eaafe3a280c 100644
@@ -2187,8 +2187,13 @@ static int fw_devlink_create_devlink(struct device *con,
 		}
 
 		if (con != sup_dev && !device_link_add(con, sup_dev, flags)) {
-			dev_err(con, "Failed to create device link (0x%x) with %s\n",
-				flags, dev_name(sup_dev));
+			if (flags & DL_FLAG_SYNC_STATE_ONLY &&
+			    con->links.status != DL_DEV_NO_DRIVER &&
+			    con->links.status != DL_DEV_PROBING)
+				dev_dbg(con, "Skipping device link creation for probed device\n");
+			else
+				dev_err(con, "Failed to create device link (0x%x) with %s\n",
+					flags, dev_name(sup_dev));
 			ret = -EINVAL;
 		}
 
 
---

base-commit: b992b79ca8bc336fa8e2c80990b5af80ed8f36fd
change-id: 20240624-fwdevlink-probed-no-err-45d21feb05fd

Best regards,

Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/