mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
Merge branch 'net-stmmac-cleanup-rx-coalescing-computation-when-using-riwt'
Maxime Chevallier says: ==================== net: stmmac: Cleanup rx coalescing computation when using RIWT Currently when configuring interrupt coalescing on devices that relies on the Receive Interrupt Watchdog Timer feature of dwmac, the computation of the RIWT timings leads to off-by-one values when reporting the timings back to userspace. RIWT works by arming a watchdog timer upon receiving frames with the RI bit not set in the descriptor. The timer duration is expressed in units of 256 stmmac clock ticks, and therefore requires a bit of computation to derive it : riwt = (rx_usecs * n_clk_ticks_per_usec) / 256 and conversely rx_usecs = (riwt * 256) / n_clk_ticks_per_usec This computation as-is leads to a consistent off-by-one when setting then getting back the rx-usecs value due to rounding errors (by truncation): ethtool -C eth1 rx-usecs 42 ethtool -c eth1 -> reports rx-usecs: 41 Let's use DIV_ROUND_CLOSEST instead for the computations. It does have one side effect, the accepted boundaries for rx-usecs also shifts by one now, going from [16us, 246us] to [15us, 245us]. For that reason, I'm not targeting the net tree here, and it's overall a very small issue. ==================== Link: https://patch.msgid.link/20260802114015.214212-1-maxime.chevallier@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
63638bc3e2
|
|
@ -759,7 +759,10 @@ static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (usec * (clk / 1000000)) / 256;
|
||||
/* Receive Interrupt Watchdog Timer (riwt) has a resolution of 256
|
||||
* ticks.
|
||||
*/
|
||||
return DIV_ROUND_CLOSEST(usec * (clk / USEC_PER_SEC), 256);
|
||||
}
|
||||
|
||||
static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv)
|
||||
|
|
@ -772,7 +775,7 @@ static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (riwt * 256) / (clk / 1000000);
|
||||
return DIV_ROUND_CLOSEST(riwt * 256, clk / USEC_PER_SEC);
|
||||
}
|
||||
|
||||
static int __stmmac_get_coalesce(struct net_device *dev,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user