Skip to contentSkip to conversation

dpll: fix clock quality level reporting

PATCH Applied Ivan Vecera 5 participants 6 messages Sep 12, 2025 – Sep 14, 2025

Subsystems (3)
lore
Share & tools
lore

Ivan Vecera

author reviewer
#0 lore raw

PATCH 1/1 dpll: fix clock quality level reporting

The DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC is not reported via netlink due to bug in dpll_msg_add_clock_quality_level(). The usage of DPLL_CLOCK_QUALITY_LEVEL_MAX for both DECLARE_BITMAP() and for_each_set_bit() is not correct because these macros requires bitmap size and not the highest valid bit in the bitmap.

Use correct bitmap size to fix this issue.

Fixes a1afb959add1 ("dpll: add clock quality level attribute and op")
---
 drivers/dpll/dpll_netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dpll/dpll_netlink.c +2 -2
index 036f21cac0a9..0a852011653c 100644
@@ -211,8 +211,8 @@ static int
 dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
 				 struct netlink_ext_ack *extack)
 {
+	DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) = { 0 };
 	const struct dpll_device_ops *ops = dpll_device_ops(dpll);
-	DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 };
 	enum dpll_clock_quality_level ql;
 	int ret;
 
@@ -221,7 +221,7 @@ dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
 	ret = ops->clock_quality_level_get(dpll, dpll_priv(dpll), qls, extack);
 	if (ret)
 		return ret;
-	for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX)
+	for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1)
 		if (nla_put_u32(msg, DPLL_A_CLOCK_QUALITY_LEVEL, ql))
 			return -EMSGSIZE;
 
Signature · 1 line
2.49.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines

From: Ivan Vecera <[email protected]>
Sent: Friday, September 12, 2025 11:34 AM
To: [email protected]
Cc: Vadim Fedorenko <[email protected]>; Kubalewski, Arkadiusz <[email protected]>; Jiri Pirko <[email protected]>; Jakub Kicinski <[email protected]>; open list <[email protected]>
Subject: [PATCH net] dpll: fix clock quality level reporting

The DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC is not reported via netlink due to bug in dpll_msg_add_clock_quality_level(). The usage of DPLL_CLOCK_QUALITY_LEVEL_MAX for both DECLARE_BITMAP() and for_each_set_bit() is not correct because these macros requires bitmap size and not the highest valid bit in the bitmap.

Quoted 4 lines

Use correct bitmap size to fix this issue.

Fixes a1afb959add1 ("dpll: add clock quality level attribute and op")

LGTM,
Thanks!

Quoted 32 lines

---
drivers/dpll/dpll_netlink.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dpll/dpll_netlink.c +0 -0
index 036f21cac0a9..0a852011653c 100644
@@ -211,8 +211,8 @@ static int

dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
struct netlink_ext_ack *extack)
{

drivers/dpll/dpll_netlink.c +1 -0
+	DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) = { 0 };
	const struct dpll_device_ops *ops = dpll_device_ops(dpll);
drivers/dpll/dpll_netlink.c +0 -1
-	DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 };
	enum dpll_clock_quality_level ql;
	int ret;
drivers/dpll/dpll_netlink.c +1 -1
@@ -221,7 +221,7 @@ dpll_msg_add_clock_quality_level(struct sk_buff *msg,
 struct dpll_device *dpll,
 	ret = ops->clock_quality_level_get(dpll, dpll_priv(dpll), qls,
 extack);
 	if (ret)
 		return ret;
-	for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX)
+	for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1)
 		if (nla_put_u32(msg, DPLL_A_CLOCK_QUALITY_LEVEL, ql))
			return -EMSGSIZE;

--
2.49.1

maintainer
#2 lore raw
In reply to Ivan Vecera
Quoted 19 lines · Ivan Vecera

The DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC is not reported via netlink due to bug in dpll_msg_add_clock_quality_level(). The usage of DPLL_CLOCK_QUALITY_LEVEL_MAX for both DECLARE_BITMAP() and for_each_set_bit() is not correct because these macros requires bitmap size and not the highest valid bit in the bitmap.

Use correct bitmap size to fix this issue.

Fixes a1afb959add1 ("dpll: add clock quality level attribute and op")
---
  drivers/dpll/dpll_netlink.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dpll/dpll_netlink.c +0 -0
index 036f21cac0a9..0a852011653c 100644

drivers/dpll/dpll_netlink.c static int · line 215

Quoted 6 lines
drivers/dpll/dpll_netlink.c +1 -1
@@ -211,8 +211,8 @@ static int
  dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
  				 struct netlink_ext_ack *extack)
  {
+	DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) = { 0 };
  	const struct dpll_device_ops *ops = dpll_device_ops(dpll);
-	DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 };

I believe __DPLL_CLOCK_QUALITY_LEVEL_MAX should be used in both places

Quoted 12 lines
drivers/dpll/dpll_netlink.c +1 -1
  	enum dpll_clock_quality_level ql;
  	int ret;
 
@@ -221,7 +221,7 @@ dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
  	ret = ops->clock_quality_level_get(dpll, dpll_priv(dpll), qls, extack);
  	if (ret)
  		return ret;
-	for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX)
+	for_each_set_bit(ql, qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1)
  		if (nla_put_u32(msg, DPLL_A_CLOCK_QUALITY_LEVEL, ql))
  			return -EMSGSIZE;
 
author reviewer
#3 lore raw
Quoted 15 lines · Vadim Fedorenko
Quoted 14 lines · Ivan Vecera

The DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC is not reported via netlink due to bug in dpll_msg_add_clock_quality_level(). The usage of DPLL_CLOCK_QUALITY_LEVEL_MAX for both DECLARE_BITMAP() and for_each_set_bit() is not correct because these macros requires bitmap size and not the highest valid bit in the bitmap.

Use correct bitmap size to fix this issue.

Fixes a1afb959add1 ("dpll: add clock quality level attribute and op")

---
  drivers/dpll/dpll_netlink.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines

drivers/dpll/dpll_netlink.c static int · line 215

Quoted 11 lines
drivers/dpll/dpll_netlink.c +1 -1
index 036f21cac0a9..0a852011653c 100644
@@ -211,8 +211,8 @@ static int
   dpll_msg_add_clock_quality_level(struct sk_buff *msg, struct dpll_device *dpll,
                    struct netlink_ext_ack *extack)
   {
+    DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) = { 0 };
       const struct dpll_device_ops *ops = dpll_device_ops(dpll);
-    DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 };

I believe __DPLL_CLOCK_QUALITY_LEVEL_MAX should be used in both places

I don't think so. I consider __DPLL_CLOCK_QUALITY_LEVEL_MAX to be an auxiliary value that should not be used directly.

But it would be possible to rename it to DPLL_CLOCK_QUALITY_LEVEL_COUNT and use this.

Thoughts?

Ivan

maintainer
#4 lore raw
Quoted 6 lines · On Sat, 13 Sep 2025 13:09:03 +0200 Ivan Vecera wrote:
Quoted 5 lines
Quoted 3 lines

+    DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX + 1) = { 0 }; const struct dpll_device_ops *ops = dpll_device_ops(dpll); -    DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 };

I believe __DPLL_CLOCK_QUALITY_LEVEL_MAX should be used in both places

Quoted 7 lines

I don't think so. I consider __DPLL_CLOCK_QUALITY_LEVEL_MAX to be an auxiliary value that should not be used directly.

But it would be possible to rename it to DPLL_CLOCK_QUALITY_LEVEL_COUNT and use this.

Thoughts?

I think we should leave it as is. The naming convention is a bit weird but it's what has been done for Netlink historically

#5 lore raw
In reply to Ivan Vecera
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Fri, 12 Sep 2025 11:33:31 +0200 you wrote:

The DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC is not reported via netlink due to bug in dpll_msg_add_clock_quality_level(). The usage of DPLL_CLOCK_QUALITY_LEVEL_MAX for both DECLARE_BITMAP() and for_each_set_bit() is not correct because these macros requires bitmap size and not the highest valid bit in the bitmap.

Use correct bitmap size to fix this issue.

[...]

Here is the summary with links:
- [net] dpll: fix clock quality level reporting

    https://git.kernel.org/netdev/net/c/70d99623d5c1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html