linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
@ 2022-02-09  8:39 Qing Wang
  2022-02-09 13:30 ` patchwork-bot+netdevbpf
  2022-02-09 19:11 ` Christophe JAILLET
  0 siblings, 2 replies; 6+ messages in thread
From: Qing Wang @ 2022-02-09  8:39 UTC (permalink / raw)
  To: Derek Chickles, Satanand Burla, Felix Manlunas, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel
  Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

do_div() does a 64-by-32 division.
When the divisor is u64, do_div() truncates it to 32 bits, this means it
can test non-zero and be truncated to zero for division.

fix do_div.cocci warning:
do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index ba28aa4..8e07192
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1539,7 +1539,7 @@ static int liquidio_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 	 * compute the delta in terms of coprocessor clocks.
 	 */
 	delta = (u64)ppb << 32;
-	do_div(delta, oct->coproc_clock_rate);
+	div64_u64(delta, oct->coproc_clock_rate);
 
 	spin_lock_irqsave(&lio->ptp_lock, flags);
 	comp = lio_pci_readq(oct, CN6XXX_MIO_PTP_CLOCK_COMP);
@@ -1672,7 +1672,7 @@ static void liquidio_ptp_init(struct octeon_device *oct)
 	u64 clock_comp, cfg;
 
 	clock_comp = (u64)NSEC_PER_SEC << 32;
-	do_div(clock_comp, oct->coproc_clock_rate);
+	div64_u64(clock_comp, oct->coproc_clock_rate);
 	lio_pci_writeq(oct, clock_comp, CN6XXX_MIO_PTP_CLOCK_COMP);
 
 	/* Enable */
-- 
2.7.4


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

* Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
  2022-02-09  8:39 [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div() Qing Wang
@ 2022-02-09 13:30 ` patchwork-bot+netdevbpf
  2022-02-09 20:01   ` Christophe JAILLET
  2022-02-09 19:11 ` Christophe JAILLET
  1 sibling, 1 reply; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-09 13:30 UTC (permalink / raw)
  To: Qing Wang; +Cc: dchickles, sburla, fmanlunas, davem, kuba, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed,  9 Feb 2022 00:39:19 -0800 you wrote:
> From: Wang Qing <wangqing@vivo.com>
> 
> do_div() does a 64-by-32 division.
> When the divisor is u64, do_div() truncates it to 32 bits, this means it
> can test non-zero and be truncated to zero for division.
> 
> fix do_div.cocci warning:
> do_div() does a 64-by-32 division, please consider using div64_u64 instead.
> 
> [...]

Here is the summary with links:
  - net: ethernet: cavium: use div64_u64() instead of do_div()
    https://git.kernel.org/netdev/net-next/c/038fcdaf0470

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

* Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
  2022-02-09  8:39 [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div() Qing Wang
  2022-02-09 13:30 ` patchwork-bot+netdevbpf
@ 2022-02-09 19:11 ` Christophe JAILLET
  1 sibling, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2022-02-09 19:11 UTC (permalink / raw)
  To: Qing Wang, Derek Chickles, Satanand Burla, Felix Manlunas,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel

Le 09/02/2022 à 09:39, Qing Wang a écrit :
> From: Wang Qing <wangqing@vivo.com>
> 
> do_div() does a 64-by-32 division.
> When the divisor is u64, do_div() truncates it to 32 bits, this means it
> can test non-zero and be truncated to zero for division.
> 
> fix do_div.cocci warning:
> do_div() does a 64-by-32 division, please consider using div64_u64 instead.
> 
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
>   drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> index ba28aa4..8e07192
> --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> @@ -1539,7 +1539,7 @@ static int liquidio_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
>   	 * compute the delta in terms of coprocessor clocks.
>   	 */
>   	delta = (u64)ppb << 32;
> -	do_div(delta, oct->coproc_clock_rate);
> +	div64_u64(delta, oct->coproc_clock_rate);
>   
>   	spin_lock_irqsave(&lio->ptp_lock, flags);
>   	comp = lio_pci_readq(oct, CN6XXX_MIO_PTP_CLOCK_COMP);
> @@ -1672,7 +1672,7 @@ static void liquidio_ptp_init(struct octeon_device *oct)
>   	u64 clock_comp, cfg;
>   
>   	clock_comp = (u64)NSEC_PER_SEC << 32;
> -	do_div(clock_comp, oct->coproc_clock_rate);
> +	div64_u64(clock_comp, oct->coproc_clock_rate);
>   	lio_pci_writeq(oct, clock_comp, CN6XXX_MIO_PTP_CLOCK_COMP);
>   
>   	/* Enable */

I think that all your recent patches about such conversions are broken.

See [1] were it was already reported that do_div() and div64_u64() don't 
have the same calling convention.

Looks that div64_u64() and div64_ul() works the same way.


CJ

[1]: 
https://lore.kernel.org/linux-kernel/20211117112559.jix3hmx7uwqmuryg@pengutronix.de/

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

* Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
  2022-02-09 13:30 ` patchwork-bot+netdevbpf
@ 2022-02-09 20:01   ` Christophe JAILLET
  2022-02-10  2:01     ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe JAILLET @ 2022-02-09 20:01 UTC (permalink / raw)
  To: patchwork-bot+netdevbpf, Qing Wang
  Cc: dchickles, sburla, fmanlunas, davem, kuba, netdev, linux-kernel

Le 09/02/2022 à 14:30, patchwork-bot+netdevbpf@kernel.org a écrit :
> Hello:
> 
> This patch was applied to netdev/net-next.git (master)
> by David S. Miller <davem@davemloft.net>:
> 
> On Wed,  9 Feb 2022 00:39:19 -0800 you wrote:
>> From: Wang Qing <wangqing@vivo.com>
>>
>> do_div() does a 64-by-32 division.
>> When the divisor is u64, do_div() truncates it to 32 bits, this means it
>> can test non-zero and be truncated to zero for division.
>>
>> fix do_div.cocci warning:
>> do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>>
>> [...]
> 
> Here is the summary with links:
>    - net: ethernet: cavium: use div64_u64() instead of do_div()
>      https://git.kernel.org/netdev/net-next/c/038fcdaf0470
> 
> You are awesome, thank you!

Hi,

I think that this patch should be reverted because do_div() and 
div64_u64() don't have the same calling convention.

See [1]

[1]: 
https://lore.kernel.org/linux-kernel/20211117112559.jix3hmx7uwqmuryg@pengutronix.de/

CJ

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

* Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
  2022-02-09 20:01   ` Christophe JAILLET
@ 2022-02-10  2:01     ` Jakub Kicinski
  2022-02-10 18:33       ` Christophe JAILLET
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2022-02-10  2:01 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: patchwork-bot+netdevbpf, Qing Wang, dchickles, sburla, fmanlunas,
	davem, netdev, linux-kernel

On Wed, 9 Feb 2022 21:01:35 +0100 Christophe JAILLET wrote:
> Le 09/02/2022 à 14:30, patchwork-bot+netdevbpf@kernel.org a écrit :
> > Here is the summary with links:
> >    - net: ethernet: cavium: use div64_u64() instead of do_div()
> >      https://git.kernel.org/netdev/net-next/c/038fcdaf0470
> > 
> > You are awesome, thank you!  
> 
> Hi,
> 
> I think that this patch should be reverted because do_div() and 
> div64_u64() don't have the same calling convention.
> 
> See [1]
> 
> [1]: 
> https://lore.kernel.org/linux-kernel/20211117112559.jix3hmx7uwqmuryg@pengutronix.de/

Would you mind sending a revert?

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

* Re: [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div()
  2022-02-10  2:01     ` Jakub Kicinski
@ 2022-02-10 18:33       ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2022-02-10 18:33 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: patchwork-bot+netdevbpf, Qing Wang, dchickles, sburla, fmanlunas,
	davem, netdev, linux-kernel

Le 10/02/2022 à 03:01, Jakub Kicinski a écrit :
> On Wed, 9 Feb 2022 21:01:35 +0100 Christophe JAILLET wrote:
>> Le 09/02/2022 à 14:30, patchwork-bot+netdevbpf@kernel.org a écrit :
>>> Here is the summary with links:
>>>     - net: ethernet: cavium: use div64_u64() instead of do_div()
>>>       https://git.kernel.org/netdev/net-next/c/038fcdaf0470
>>>
>>> You are awesome, thank you!
>>
>> Hi,
>>
>> I think that this patch should be reverted because do_div() and
>> div64_u64() don't have the same calling convention.
>>
>> See [1]
>>
>> [1]:
>> https://lore.kernel.org/linux-kernel/20211117112559.jix3hmx7uwqmuryg@pengutronix.de/
> 
> Would you mind sending a revert?
> 

I don't work on net-next, only linux-next.

I can send a revert once it reaches linux-next but I would be better if 
it is fixed before that.

CJ

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

end of thread, other threads:[~2022-02-10 18:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09  8:39 [PATCH] net: ethernet: cavium: use div64_u64() instead of do_div() Qing Wang
2022-02-09 13:30 ` patchwork-bot+netdevbpf
2022-02-09 20:01   ` Christophe JAILLET
2022-02-10  2:01     ` Jakub Kicinski
2022-02-10 18:33       ` Christophe JAILLET
2022-02-09 19:11 ` Christophe JAILLET

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).