[PATCH] driver core: avoid repeatedly printing the same 'Fixed dependency' log

Xu Yang posted 1 patch 1 month ago
drivers/base/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH] driver core: avoid repeatedly printing the same 'Fixed dependency' log
Posted by Xu Yang 1 month ago
The "Fixed dependency cycle(s) with ..." log is printed for each cycle
finding process. In particular, the same cycle may be parsed many times
during the proxy link setup. For example, if /soc/bus@4c000000/usb@4c100000
is a devicetree structure and node usb@4c100000 is in a cycle, then for
each device registration (soc, 4c000000.bus and 4c100000.usb),
fw_devlink_create_devlink() will find the same cycle and print a log.
The repeat logs are redundant and may cause confusion for the user. Move
the pr_debug() to __fwnode_link_cycle() and avoid printing the log if it
has already been printed.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
 drivers/base/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index d49420e066de..af0371d4ed83 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -127,7 +127,13 @@ static void __fwnode_link_cycle(struct fwnode_link *link)
 {
 	pr_debug("%pfwf: cycle: depends on %pfwf\n",
 		 link->consumer, link->supplier);
+
+	if (link->flags & FWLINK_FLAG_CYCLE)
+		return;
+
 	link->flags |= FWLINK_FLAG_CYCLE;
+	pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
+		link->consumer, link->supplier);
 }
 
 /**
@@ -2140,8 +2146,6 @@ static int fw_devlink_create_devlink(struct device *con,
 	if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) {
 		__fwnode_link_cycle(link);
 		pr_debug("----- cycle: end -----\n");
-		pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
-			link->consumer, sup_handle);
 	}
 	device_links_write_unlock();
 
-- 
2.34.1
Re: [PATCH] driver core: avoid repeatedly printing the same 'Fixed dependency' log
Posted by Xu Yang 2 weeks, 4 days ago
Hi Saravana,

On Sat, May 09, 2026 at 07:17:28PM +0800, Xu Yang wrote:
> The "Fixed dependency cycle(s) with ..." log is printed for each cycle
> finding process. In particular, the same cycle may be parsed many times
> during the proxy link setup. For example, if /soc/bus@4c000000/usb@4c100000
> is a devicetree structure and node usb@4c100000 is in a cycle, then for
> each device registration (soc, 4c000000.bus and 4c100000.usb),
> fw_devlink_create_devlink() will find the same cycle and print a log.
> The repeat logs are redundant and may cause confusion for the user. Move
> the pr_debug() to __fwnode_link_cycle() and avoid printing the log if it
> has already been printed.

Could the logging be improved here?

Thanks,
Xu Yang

> 
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
>  drivers/base/core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index d49420e066de..af0371d4ed83 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -127,7 +127,13 @@ static void __fwnode_link_cycle(struct fwnode_link *link)
>  {
>  	pr_debug("%pfwf: cycle: depends on %pfwf\n",
>  		 link->consumer, link->supplier);
> +
> +	if (link->flags & FWLINK_FLAG_CYCLE)
> +		return;
> +
>  	link->flags |= FWLINK_FLAG_CYCLE;
> +	pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
> +		link->consumer, link->supplier);
>  }
>  
>  /**
> @@ -2140,8 +2146,6 @@ static int fw_devlink_create_devlink(struct device *con,
>  	if (__fw_devlink_relax_cycles(link->consumer, sup_handle)) {
>  		__fwnode_link_cycle(link);
>  		pr_debug("----- cycle: end -----\n");
> -		pr_info("%pfwf: Fixed dependency cycle(s) with %pfwf\n",
> -			link->consumer, sup_handle);
>  	}
>  	device_links_write_unlock();
>  
> -- 
> 2.34.1
>