From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CFD5C433E8 for ; Sat, 25 Jul 2020 08:16:45 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id E1736206C1 for ; Sat, 25 Jul 2020 08:16:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1736206C1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7BE581C0B3; Sat, 25 Jul 2020 10:16:22 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id BAD251C0B0; Sat, 25 Jul 2020 10:16:20 +0200 (CEST) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 07CEB77BBDE849ED8A83; Sat, 25 Jul 2020 16:16:18 +0800 (CST) Received: from tester.localdomain (10.175.119.39) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Sat, 25 Jul 2020 16:16:07 +0800 From: Xiaoyun wang To: CC: , , , , , , , , , Xiaoyun wang , Date: Sat, 25 Jul 2020 16:15:36 +0800 Message-ID: <1833dd4a5af04cf69c9191a5329397772e5f1ae6.1595663173.git.cloud.wangxiaoyun@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.119.39] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2 4/4] net/hinic/base: make timeout not affected by system time jump X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Replace gettimeofday() with clock_gettime(CLOCK_MONOTONIC_RAW, &now), the reason is same with this patch "make alarm not affected by system time jump". Fixes: 81d53291a466 ("net/hinic/base: add various headers") Cc: stable@dpdk.org Signed-off-by: Xiaoyun wang --- drivers/net/hinic/base/hinic_compat.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index 2d21b7b..7036b03 100644 --- a/drivers/net/hinic/base/hinic_compat.h +++ b/drivers/net/hinic/base/hinic_compat.h @@ -166,16 +166,17 @@ static inline u32 readl(const volatile void *addr) #define spin_lock(spinlock_prt) rte_spinlock_lock(spinlock_prt) #define spin_unlock(spinlock_prt) rte_spinlock_unlock(spinlock_prt) -static inline unsigned long get_timeofday_ms(void) +static inline unsigned long clock_gettime_ms(void) { - struct timeval tv; + struct timespec tv; - (void)gettimeofday(&tv, NULL); + (void)clock_gettime(CLOCK_MONOTONIC, &tv); - return (unsigned long)tv.tv_sec * 1000 + tv.tv_usec / 1000; + return (unsigned long)tv.tv_sec * 1000 + + (unsigned long)tv.tv_nsec / 1000000; } -#define jiffies get_timeofday_ms() +#define jiffies clock_gettime_ms() #define msecs_to_jiffies(ms) (ms) #define time_before(now, end) ((now) < (end)) -- 1.8.3.1