IB/hfi1: Fix a wrapping test to insure the correct timeout
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Mon, 6 Nov 2017 14:38:38 +0000 (06:38 -0800)
committerDoug Ledford <dledford@redhat.com>
Mon, 13 Nov 2017 20:53:57 +0000 (15:53 -0500)
commitd61ea0751aa097182291c7ceed447bc73e020109
tree8b78c4ea599d5268f4f83db9ff232a36f35b2c0c
parent0e31a2e195220da576c32647277f849509588391
IB/hfi1: Fix a wrapping test to insure the correct timeout

The "2 * UINT_MAX"  statement:
if ((u64)(ts - cce->timestamp) > 2 * UINT_MAX) {

is equivalent to:
if ((u64)(ts - cce->timestamp) > UINT_MAX - 1) {

This results in a premature timeout of the cong log entry.

Fix by using unsigned 64 bit integers, removing casts, and using
an algebraic equivalent test to avoid the "2 * UINT_MAX" issue.

Also make use of kernel API to get nanoseconds instead of
open coding.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/mad.c
drivers/infiniband/hw/hfi1/mad.h
drivers/infiniband/hw/hfi1/rc.c