dpll: fix clock quality level reporting
Subsystems (3)
Ivan Vecera
reviewerPATCH 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.
--- drivers/dpll/dpll_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dpll/dpll_netlink.c +2 -2
@@ -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
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 reportingThe
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRCis not reported via netlink due to bug indpll_msg_add_clock_quality_level(). The usage ofDPLL_CLOCK_QUALITY_LEVEL_MAXfor bothDECLARE_BITMAP()andfor_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")Signed-off-by Ivan Vecera <[email protected]>
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@@ -211,8 +211,8 @@ static intdpll_msg_add_clock_quality_level(struct
sk_buff*msg, structdpll_device*dpll,
structnetlink_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
Vadim Fedorenko
maintainerQuoted 19 lines · Ivan Vecera
The
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRCis not reported via netlink due to bug indpll_msg_add_clock_quality_level(). The usage ofDPLL_CLOCK_QUALITY_LEVEL_MAXfor bothDECLARE_BITMAP()andfor_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")Signed-off-by Ivan Vecera <[email protected]>--- drivers/dpll/dpll_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dpll/dpll_netlink.c +0
-0
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
-1enum 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 ;
Ivan Vecera
reviewerQuoted 15 lines · Vadim Fedorenko
Quoted 14 lines · Ivan Vecera
The
DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRCis not reported via netlink due to bug indpll_msg_add_clock_quality_level(). The usage ofDPLL_CLOCK_QUALITY_LEVEL_MAXfor bothDECLARE_BITMAP()andfor_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")Signed-off-by Ivan Vecera <[email protected]>---
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@@ -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_MAXshould 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
Jakub Kicinski
maintainerQuoted 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 structdpll_device_ops*ops =dpll_device_ops(dpll); -DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX)= { 0 };I believe
__DPLL_CLOCK_QUALITY_LEVEL_MAXshould be used in both places
Quoted 7 lines
I don't think so. I consider
__DPLL_CLOCK_QUALITY_LEVEL_MAXto be an auxiliary value that should not be used directly.But it would be possible to rename it to
DPLL_CLOCK_QUALITY_LEVEL_COUNTand 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
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_EPRCis not reported via netlink due to bug indpll_msg_add_clock_quality_level(). The usage ofDPLL_CLOCK_QUALITY_LEVEL_MAXfor bothDECLARE_BITMAP()andfor_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