diff options
author | Mike Marciniszyn <mike.marciniszyn@intel.com> | 2017-11-06 17:38:38 +0300 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-11-13 23:53:57 +0300 |
commit | d61ea0751aa097182291c7ceed447bc73e020109 (patch) | |
tree | 8b78c4ea599d5268f4f83db9ff232a36f35b2c0c /drivers/infiniband/hw/hfi1/rc.c | |
parent | 0e31a2e195220da576c32647277f849509588391 (diff) | |
download | linux-d61ea0751aa097182291c7ceed447bc73e020109.tar.xz |
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>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/rc.c')
-rw-r--r-- | drivers/infiniband/hw/hfi1/rc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c index 32d7bbe9738c..3f21b050714f 100644 --- a/drivers/infiniband/hw/hfi1/rc.c +++ b/drivers/infiniband/hw/hfi1/rc.c @@ -1965,7 +1965,7 @@ static void log_cca_event(struct hfi1_pportdata *ppd, u8 sl, u32 rlid, cc_event->svc_type = svc_type; cc_event->rlid = rlid; /* keep timestamp in units of 1.024 usec */ - cc_event->timestamp = ktime_to_ns(ktime_get()) / 1024; + cc_event->timestamp = ktime_get_ns() / 1024; spin_unlock_irqrestore(&ppd->cc_log_lock, flags); } |