[SRU][PATCH 1/1][jammy:intel-iotg/intel-iot-realtime] UBUNTU: SAUCE: igc: Fix divide error

Thibault Ferrante thibault.ferrante at canonical.com
Fri Apr 19 14:09:49 UTC 2024


BugLink: https://bugs.launchpad.net/bugs/2062129

When resetting/enabling in a fast manner, we can end up in a situation
with a zero divider, avoid this situation by explicitely checking for it.

Signed-off-by: Thibault Ferrante <thibault.ferrante at canonical.com>
---
 drivers/net/ethernet/intel/igc/igc_tsn.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c
index 96f3b8b7fec7..9e7412b465b0 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -243,7 +243,7 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 	nsec = rd32(IGC_SYSTIML);
 	sec = rd32(IGC_SYSTIMH);
 	systim = ktime_set(sec, nsec);
-	if (ktime_compare(systim, base_time) > 0) {
+	if (ktime_compare(systim, base_time) > 0 && cycle != 0) {
 		s64 n = div64_s64(ktime_sub_ns(systim, base_time), cycle);
 
 		base_time = ktime_add_ns(base_time, (n + 1) * cycle);
-- 
2.43.0




More information about the kernel-team mailing list