Commit ba7a0f44 authored by Jakub Kicinski's avatar Jakub Kicinski

Revert "net: mvpp2: Improve data types and use min()"

This reverts commit f7023b3d.

Russell indicates that assuming 32bits are sufficient isn't
necessarily safe.

Link: https://lore.kernel.org/20240711154741.174745-1-thorsten.blum@toblux.com/Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0970bf67
...@@ -2766,29 +2766,29 @@ static void mvpp2_tx_pkts_coal_set(struct mvpp2_port *port, ...@@ -2766,29 +2766,29 @@ static void mvpp2_tx_pkts_coal_set(struct mvpp2_port *port,
} }
} }
static u32 mvpp2_usec_to_cycles(u32 usec, u32 clk_hz) static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz)
{ {
u64 tmp = (u64)clk_hz * usec; u64 tmp = (u64)clk_hz * usec;
do_div(tmp, USEC_PER_SEC); do_div(tmp, USEC_PER_SEC);
return min(tmp, U32_MAX); return tmp > U32_MAX ? U32_MAX : tmp;
} }
static u32 mvpp2_cycles_to_usec(u32 cycles, u32 clk_hz) static u32 mvpp2_cycles_to_usec(u32 cycles, unsigned long clk_hz)
{ {
u64 tmp = (u64)cycles * USEC_PER_SEC; u64 tmp = (u64)cycles * USEC_PER_SEC;
do_div(tmp, clk_hz); do_div(tmp, clk_hz);
return min(tmp, U32_MAX); return tmp > U32_MAX ? U32_MAX : tmp;
} }
/* Set the time delay in usec before Rx interrupt */ /* Set the time delay in usec before Rx interrupt */
static void mvpp2_rx_time_coal_set(struct mvpp2_port *port, static void mvpp2_rx_time_coal_set(struct mvpp2_port *port,
struct mvpp2_rx_queue *rxq) struct mvpp2_rx_queue *rxq)
{ {
u32 freq = port->priv->tclk; unsigned long freq = port->priv->tclk;
u32 val = mvpp2_usec_to_cycles(rxq->time_coal, freq); u32 val = mvpp2_usec_to_cycles(rxq->time_coal, freq);
if (val > MVPP2_MAX_ISR_RX_THRESHOLD) { if (val > MVPP2_MAX_ISR_RX_THRESHOLD) {
...@@ -2804,7 +2804,7 @@ static void mvpp2_rx_time_coal_set(struct mvpp2_port *port, ...@@ -2804,7 +2804,7 @@ static void mvpp2_rx_time_coal_set(struct mvpp2_port *port,
static void mvpp2_tx_time_coal_set(struct mvpp2_port *port) static void mvpp2_tx_time_coal_set(struct mvpp2_port *port)
{ {
u32 freq = port->priv->tclk; unsigned long freq = port->priv->tclk;
u32 val = mvpp2_usec_to_cycles(port->tx_time_coal, freq); u32 val = mvpp2_usec_to_cycles(port->tx_time_coal, freq);
if (val > MVPP2_MAX_ISR_TX_THRESHOLD) { if (val > MVPP2_MAX_ISR_TX_THRESHOLD) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment