Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp650434imm; Wed, 11 Jul 2018 08:40:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpemTnQqRrr4VRcvtxQmRkxFRfolKxMitgIb1MYrCUvQmYkMXMdlVMvCsCp3UvFJw1u/LVix X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr28892458plk.172.1531323628724; Wed, 11 Jul 2018 08:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531323628; cv=none; d=google.com; s=arc-20160816; b=TqclJUuSW5mAjB03X5SaUay9EpqgdL0I1nznH5bnZ5RaBwOC35cN5UlCwuDjzO6Hoo aBbckHdATbBGk7ZmiiEECJMkV2JG6rUHCkb6gEzc0swhxW/VwNWilgAG1yAwIeE0eW8b 6bQuN0N4ey8kVGpyEHdy/Mja07tKquIlADVZNfHTRLbIr0a4b6ZhS1rxWiy7qDG+NPUA BwTk6EuCdXWyUPhETX7x7gFquRBxozqcKAU+6grpGnoSdD6bWv/QWw0uP5HitY1LE7df ozU6dPyNZeYt5GBbn6bioOS9Ejv3Xbqr+/IZM+eyub1OejmqQm9n1CwDTAAl7bMmhVDd cmfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8sbwhjT6gMy3E4e2S36+Dt4DPBHkSe8l4A4PyxwOCA0=; b=Wk5LrXBQcQjAJCAuyo2gOMsTxQ6ZFjzIvYrIIc+1c+Rl2J7+jnJc98Py8tkJn3EyUM 6SpzZit9PPpJcpTuOm9/7d6CVeWhelW2KbPN3rNq+mQKb+k/0yuObJC/Uc3nPz90mDPr JhKuFMXg96X2ViG0NHJG1elqi5+Xirk7sJk9wXPniZ8kuQ3sJlHNpvFvKZI3apk/2k9/ FbXR1/+3FvmqA20s/wmoO4EmZGE1G2tNNXwS7nUViHltBTAyIuz4FIDwqVSHcIFEoFF3 uI4s9BJMiz0Vd1q8lyaJl/1iekyyNootYkFWI1JIZBhmCNHXPGIkTo7P4YmIc5Dlr/MD pNxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14-v6si4322334pgg.76.2018.07.11.08.40.10; Wed, 11 Jul 2018 08:40:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387408AbeGKMet (ORCPT + 99 others); Wed, 11 Jul 2018 08:34:49 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:56370 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732995AbeGKMet (ORCPT ); Wed, 11 Jul 2018 08:34:49 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0M9j7n-1fnMrk1oIJ-00Cymj; Wed, 11 Jul 2018 14:30:35 +0200 From: Arnd Bergmann To: Jakub Kicinski , "David S. Miller" Cc: Arnd Bergmann , John Hurley , Simon Horman , Pieter Jansen van Vuuren , Jiri Pirko , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] [RESEND] nfp: avoid using getnstimeofday64() Date: Wed, 11 Jul 2018 14:29:53 +0200 Message-Id: <20180711123003.453442-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180711123003.453442-1-arnd@arndb.de> References: <20180711123003.453442-1-arnd@arndb.de> X-Provags-ID: V03:K1:gF3CG1bMAMzEzNZP4a+fJhMwv4Xn5C33s+MzBiNGTKSmj4BEhBs +rQWiF4o6N8JcYdZ8TwqljIMEdEdN/alKQo+GhwM/YWfFawA0NfiYBAgW24YAJq0Pp97Xi1 coi4OtO35JgFmMXUn2J8FuKUm4PIrw1C6IW7CqkKeNO/l4D6O60xH1K4TMUa1kcZwNJQYLC t2g62qJxMsb9svXqhk2LA== X-UI-Out-Filterresults: notjunk:1;V01:K0:J3C33a3p81Q=:CUIEsHvDd9YQ44EG9GmFOb FqnXDLLoSQl2z/K4bsnLtRlJ93J8gRZQGR10668n7lnlc77vSl7M44rNTXpVdZQ8LZXkaf5Rk 0efmjK2mKQYkKbMgJ5xgK9WnAF88/ct09YNIrVYo/5gM0RVka8FWz7RJI4tRRiq21qcl5yInh gcq88EhghFeapBRWRCHEsTyQN3uLVUcgWoEKxMkuRK5I4bjSMdYrbo0wahpcCfwR9LV4LPdfD /T1+BhEAECMv5LYxxrBw4kmi/zUExjcvf3MUAQ/mHp7wCOkwPboqjJouaQBhECgKcsIMGGS3i z/7M1TxaBYoeVIPD7S/T+18khgay/mg7XzgiKonujcYJq66dmR5v+Mkbrbx/luKwkoa+sqHxk ew2q9PKFUVX7QAztmUaLlFlg80eT3vRYqYnKVgmOSQ4HrKay44AemGzz6JtFwrGv/N44KFmTh eetH3fF3Ro5eXxjs1ZiysDDhx2Gz24ceAoyaqzdd5U2YaD1jh00nRfdknsxlBc+8wEwWIrNU7 eFT6n5ML9luaZHbBgko9uKOsyvopYEoR8kWJW/7Jvyjwn0B6vbvi3dczT/glwrff3vM0Ystz2 Wk81xdyy52gdpFklrcGShN2BzzM+EHsG/p/QeL7vc+5QRW4GQsp0IiUCDq+wpx0Pek61p4IQN sipCopIWz2Dcu3qjPGDebaJBiXKWji72ucpz5cSdA5oisfcPbdq8VoGW34iBI7auHyVo= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org getnstimeofday64 is deprecated in favor of the ktime_get() family of functions. The direct replacement would be ktime_get_real_ts64(), but I'm picking the basic ktime_get() instead: - using a ktime_t simplifies the code compared to timespec64 - using monotonic time instead of real time avoids issues caused by a concurrent settimeofday() or during a leap second adjustment. Acked-by: Jakub Kicinski Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/netronome/nfp/flower/main.h | 2 +- drivers/net/ethernet/netronome/nfp/flower/metadata.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index bbe5764d26cb..ef2114d13387 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -73,7 +73,7 @@ struct nfp_app; struct nfp_fl_mask_id { struct circ_buf mask_id_free_list; - struct timespec64 *last_used; + ktime_t *last_used; u8 init_unallocated; }; diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 93fb809f50d1..c098730544b7 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -158,7 +158,6 @@ static int nfp_release_mask_id(struct nfp_app *app, u8 mask_id) { struct nfp_flower_priv *priv = app->priv; struct circ_buf *ring; - struct timespec64 now; ring = &priv->mask_ids.mask_id_free_list; /* Checking if buffer is full. */ @@ -169,8 +168,7 @@ static int nfp_release_mask_id(struct nfp_app *app, u8 mask_id) ring->head = (ring->head + NFP_FLOWER_MASK_ELEMENT_RS) % (NFP_FLOWER_MASK_ENTRY_RS * NFP_FLOWER_MASK_ELEMENT_RS); - getnstimeofday64(&now); - priv->mask_ids.last_used[mask_id] = now; + priv->mask_ids.last_used[mask_id] = ktime_get(); return 0; } @@ -178,7 +176,7 @@ static int nfp_release_mask_id(struct nfp_app *app, u8 mask_id) static int nfp_mask_alloc(struct nfp_app *app, u8 *mask_id) { struct nfp_flower_priv *priv = app->priv; - struct timespec64 delta, now; + ktime_t reuse_timeout; struct circ_buf *ring; u8 temp_id, freed_id; @@ -198,10 +196,10 @@ static int nfp_mask_alloc(struct nfp_app *app, u8 *mask_id) memcpy(&temp_id, &ring->buf[ring->tail], NFP_FLOWER_MASK_ELEMENT_RS); *mask_id = temp_id; - getnstimeofday64(&now); - delta = timespec64_sub(now, priv->mask_ids.last_used[*mask_id]); + reuse_timeout = ktime_add_ns(priv->mask_ids.last_used[*mask_id], + NFP_FL_MASK_REUSE_TIME_NS); - if (timespec64_to_ns(&delta) < NFP_FL_MASK_REUSE_TIME_NS) + if (ktime_before(ktime_get(), reuse_timeout)) goto err_not_found; memcpy(&ring->buf[ring->tail], &freed_id, NFP_FLOWER_MASK_ELEMENT_RS); -- 2.9.0