netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] dpll: fix clock quality level reporting
@ 2025-09-12  9:33 Ivan Vecera
  2025-09-12 10:51 ` Kubalewski, Arkadiusz
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ivan Vecera @ 2025-09-12  9:33 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko, Jakub Kicinski,
	open list

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")
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 036f21cac0a9..0a852011653c 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -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;
 
-- 
2.49.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH net] dpll: fix clock quality level reporting
  2025-09-12  9:33 [PATCH net] dpll: fix clock quality level reporting Ivan Vecera
@ 2025-09-12 10:51 ` Kubalewski, Arkadiusz
  2025-09-12 19:37 ` Vadim Fedorenko
  2025-09-14 20:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Kubalewski, Arkadiusz @ 2025-09-12 10:51 UTC (permalink / raw)
  To: Vecera, Ivan, netdev@vger.kernel.org
  Cc: Vadim Fedorenko, Jiri Pirko, Jakub Kicinski, open list

>From: Ivan Vecera <ivecera@redhat.com>
>Sent: Friday, September 12, 2025 11:34 AM
>To: netdev@vger.kernel.org
>Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>; Kubalewski, Arkadiusz
><arkadiusz.kubalewski@intel.com>; Jiri Pirko <jiri@resnulli.us>; Jakub
>Kicinski <kuba@kernel.org>; open list <linux-kernel@vger.kernel.org>
>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.
>
>Use correct bitmap size to fix this issue.
>
>Fixes: a1afb959add1 ("dpll: add clock quality level attribute and op")
>Signed-off-by: Ivan Vecera <ivecera@redhat.com>

LGTM,
Thanks!

Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>

>---
> drivers/dpll/dpll_netlink.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
>index 036f21cac0a9..0a852011653c 100644
>--- a/drivers/dpll/dpll_netlink.c
>+++ b/drivers/dpll/dpll_netlink.c
>@@ -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;
>
>--
>2.49.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] dpll: fix clock quality level reporting
  2025-09-12  9:33 [PATCH net] dpll: fix clock quality level reporting Ivan Vecera
  2025-09-12 10:51 ` Kubalewski, Arkadiusz
@ 2025-09-12 19:37 ` Vadim Fedorenko
  2025-09-13 11:09   ` Ivan Vecera
  2025-09-14 20:10 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Vadim Fedorenko @ 2025-09-12 19:37 UTC (permalink / raw)
  To: Ivan Vecera, netdev
  Cc: Arkadiusz Kubalewski, Jiri Pirko, Jakub Kicinski, open list

On 12.09.2025 10:33, Ivan Vecera 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.
> 
> Fixes: a1afb959add1 ("dpll: add clock quality level attribute and op")
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
>   drivers/dpll/dpll_netlink.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
> index 036f21cac0a9..0a852011653c 100644
> --- a/drivers/dpll/dpll_netlink.c
> +++ b/drivers/dpll/dpll_netlink.c
> @@ -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

>   	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;
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] dpll: fix clock quality level reporting
  2025-09-12 19:37 ` Vadim Fedorenko
@ 2025-09-13 11:09   ` Ivan Vecera
  2025-09-14 20:03     ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Ivan Vecera @ 2025-09-13 11:09 UTC (permalink / raw)
  To: Vadim Fedorenko, netdev
  Cc: Arkadiusz Kubalewski, Jiri Pirko, Jakub Kicinski, open list



On 12. 09. 25 9:37 odp., Vadim Fedorenko wrote:
> On 12.09.2025 10:33, Ivan Vecera 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.
>>
>> Fixes: a1afb959add1 ("dpll: add clock quality level attribute and op")
>> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
>> ---
>>   drivers/dpll/dpll_netlink.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
>> index 036f21cac0a9..0a852011653c 100644
>> --- a/drivers/dpll/dpll_netlink.c
>> +++ b/drivers/dpll/dpll_netlink.c
>> @@ -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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] dpll: fix clock quality level reporting
  2025-09-13 11:09   ` Ivan Vecera
@ 2025-09-14 20:03     ` Jakub Kicinski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2025-09-14 20:03 UTC (permalink / raw)
  To: Ivan Vecera
  Cc: Vadim Fedorenko, netdev, Arkadiusz Kubalewski, Jiri Pirko,
	open list

On Sat, 13 Sep 2025 13:09:03 +0200 Ivan Vecera wrote:
> >> +    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?

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] dpll: fix clock quality level reporting
  2025-09-12  9:33 [PATCH net] dpll: fix clock quality level reporting Ivan Vecera
  2025-09-12 10:51 ` Kubalewski, Arkadiusz
  2025-09-12 19:37 ` Vadim Fedorenko
@ 2025-09-14 20:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-14 20:10 UTC (permalink / raw)
  To: Ivan Vecera
  Cc: netdev, vadim.fedorenko, arkadiusz.kubalewski, jiri, kuba,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-14 20:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12  9:33 [PATCH net] dpll: fix clock quality level reporting Ivan Vecera
2025-09-12 10:51 ` Kubalewski, Arkadiusz
2025-09-12 19:37 ` Vadim Fedorenko
2025-09-13 11:09   ` Ivan Vecera
2025-09-14 20:03     ` Jakub Kicinski
2025-09-14 20:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).