From patchwork Mon Aug 23 14:38:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 124191 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7NEc9Wn000368 for ; Mon, 23 Aug 2010 14:38:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292Ab0HWOiI (ORCPT ); Mon, 23 Aug 2010 10:38:08 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:36340 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751107Ab0HWOiI (ORCPT ); Mon, 23 Aug 2010 10:38:08 -0400 Received: by bwz11 with SMTP id 11so3927034bwz.19 for ; Mon, 23 Aug 2010 07:38:03 -0700 (PDT) Received: by 10.204.127.65 with SMTP id f1mr3802982bks.55.1282574283087; Mon, 23 Aug 2010 07:38:03 -0700 (PDT) Received: from [10.4.1.29] ([82.166.227.17]) by mx.google.com with ESMTPS id y2sm4771701bkx.20.2010.08.23.07.38.01 (version=SSLv3 cipher=RC4-MD5); Mon, 23 Aug 2010 07:38:02 -0700 (PDT) Message-ID: <4C7287C8.1040106@dev.mellanox.co.il> Date: Mon, 23 Aug 2010 17:38:00 +0300 From: Yevgeny Kliteynik User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: Sasha Khapyorsky CC: Linux RDMA , Tzachi Dar Subject: [PATCH] complib/cl_timer.c: fixing cl_timer calculation Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 23 Aug 2010 14:38:10 +0000 (UTC) diff --git a/opensm/complib/cl_timer.c b/opensm/complib/cl_timer.c index 2acdb51..09a5584 100644 --- a/opensm/complib/cl_timer.c +++ b/opensm/complib/cl_timer.c @@ -299,7 +299,8 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer, { struct timeval curtime; cl_list_item_t *p_list_item; - uint32_t delta_time = time_ms; + uint32_t delta_time_sec = time_ms / 1000; + uint32_t delta_time_usec = (time_ms % 1000) * 1000; CL_ASSERT(p_timer); CL_ASSERT(p_timer->state == CL_INITIALIZED); @@ -324,9 +325,10 @@ cl_status_t cl_timer_start(IN cl_timer_t * const p_timer, /* if (delta_time < 1000.0) {delta_time = 1000;} */ /* Calculate the timeout. */ - p_timer->timeout.tv_sec = curtime.tv_sec + (delta_time / 1000); + p_timer->timeout.tv_sec = curtime.tv_sec + delta_time_sec + + ((curtime.tv_usec + delta_time_usec) / 1000000); p_timer->timeout.tv_nsec = - (curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000; + ((curtime.tv_usec + delta_time_usec) % 1000000) * 1000; /* Add the timer to the queue. */ if (cl_is_qlist_empty(&gp_timer_prov->queue)) {