From: Denys Vlasenko Date: Wed, 20 Apr 2016 15:45:55 +0000 (+0200) Subject: e1000e: e1000e_cyclecounter_read(): fix er32(SYSTIML) overflow check X-Git-Tag: v4.1.12-105.0.20170622_2100~127 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=aa5391b028476227d68ba47f915d57403b08d914;p=users%2Fjedix%2Flinux-maple.git e1000e: e1000e_cyclecounter_read(): fix er32(SYSTIML) overflow check If two consecutive reads of the counter are the same, it is also not an overflow. "systimel_1 < systimel_2" should be "systimel_1 <= systimel_2". Before the patch, we could perform an *erroneous* correction: Let's say that systimel_1 == systimel_2 == 0xffffffff. "systimel_1 < systimel_2" is false, we think it's an overflow, we read "systimeh = er32(SYSTIMH)" which meanwhile had incremented, and use "(systimeh << 32) + systimel_2" value which is 2^32 too large. Signed-off-by: Denys Vlasenko CC: intel-wired-lan@lists.osuosl.org Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher Orabug: 26243014 (cherry picked from commit a07fd74d5ea9c45a5c6e41f7cb4b997cf40d50f3) Signed-off-by: Jack Vogel Reviewed-by: Ethan Zhao --- diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 6c2cce474454..1a548c5c3298 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -4287,7 +4287,7 @@ static cycle_t e1000e_cyclecounter_read(const struct cyclecounter *cc) systimeh = er32(SYSTIMH); systimel_2 = er32(SYSTIML); /* Check for overflow. If there was no overflow, use the values */ - if (systimel_1 < systimel_2) { + if (systimel_1 <= systimel_2) { systim = (cycle_t)systimel_1; systim |= (cycle_t)systimeh << 32; } else {