From patchwork Mon Jun 18 15:20:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138996 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4079281lji; Mon, 18 Jun 2018 08:21:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3B/rXi5zmlYuGnMwJKXHoVTLBr4OpYbb/0cU4kiCzl/ftaG5SEZRyHKNi8WkrXDKBUtFd X-Received: by 2002:a62:cd82:: with SMTP id o124-v6mr14043739pfg.250.1529335265359; Mon, 18 Jun 2018 08:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335265; cv=none; d=google.com; s=arc-20160816; b=DLI4hbnDZvEmQOxNfEMWrOZQVQgZyRZQDnwenFtMb5WKgWs3IZHoo2itufF8E5/DhL LRp42lA/SzrI+WzFyD1eMOpQ9ZkoeW04d1JyVFVqf0cBaiKXcQTl4kvnt8bIY9Mui5w/ W3gJXyRPqJQaWu0X+EZlbHFQXQVI2Dz4gawe1M+WDmkBrFz8Wkj9R4woCxUYdkpkPWkz U/zWqd2MleaeViolZb7hHPu06cqO595f+bB0M0wfJY4nQ2dmqqp6+F5GAik9PcoxHvYo lPll8mV8qMJSnuakKzjGSiP5LimJ7E8jkg9jn1BcbyEMeubRx89VMn7weXCrLWtYvSHz HTMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BvTQiAulCc4A1BXeqSDhfaLVqtA/L5oTP8vX00ecMns=; b=e4W4jCEOkEvLcoG4jcdIrXSlxV2zb+a9VecxTh9aWb2haSO+IYmzst5MOmJzE4F+XW RInlisFicaQQIrJW58leKFABzVwz7pzTotMOJpdGzwZPpUCvPDahZz+iuv6hwuZuMvI8 +HCu8FW3iPf7rnGIt0bsNTFbnlk9tVi4V9OotIG9+aT40rmprtyD+mAy3wJYHVJV7q96 TLxLqwhSv+BIVPDWHlx6qq2dukqTXNR7WOCUPKrXFIhrpQdRs6CIkwCMniYcDQc4CViW jm+Q6qWW3Fd83V8RLLPgld92mWQEDgaNK30f1JBRcKB0dGdT/z81CaEA/oWfMvs2mMTP 8alQ== 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 u17-v6si15280610plq.405.2018.06.18.08.21.05; Mon, 18 Jun 2018 08:21:05 -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 S933496AbeFRPVD (ORCPT + 30 others); Mon, 18 Jun 2018 11:21:03 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:55187 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910AbeFRPVB (ORCPT ); Mon, 18 Jun 2018 11:21:01 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lup4D-1gCTyO1tjd-0104PC; Mon, 18 Jun 2018 17:20:53 +0200 From: Arnd Bergmann To: Jakub Kicinski , "David S. Miller" Cc: y2038@lists.linaro.org, Arnd Bergmann , Simon Horman , John Hurley , Pieter Jansen van Vuuren , Jiri Pirko , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] nfp: avoid using getnstimeofday64() Date: Mon, 18 Jun 2018 17:20:17 +0200 Message-Id: <20180618152051.1510142-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:UiQT+MNRfCF33W85M08QghYMG35BP+29OnqhlH3qLGGwjGUSxE+ 8UNfoZBin7m1dLHNBstbYBUPD8+FxsnPnn5CmdHhPuVS24mHSoqo3QBiSIMYYNWFxK1xz7y Nb8Y4tWJM8350q73ULtpR0HpguUczXAqC2EPsicg3owzhgiqGAvH8lcDlLnsHEcqOahGQa3 YA4x3zClSEwIwQw2KjszA== X-UI-Out-Filterresults: notjunk:1; V01:K0:5u4lt1EdB/o=:ZD2XYXjEMxXcpQnByPCIkC 41KwWj78hmrRiI8CEVLaAxa5oJF8mIjMPWjf7Wj7M6UlcbKZ1gcLKTPV/jOEF553pGs3+g+SV sLd3M59f2rFMLpDHJ8ByfBFiPU9MoZYqnv9/wMhG+5FzR4tuQb9QvuQ7t76Gq63BJg/ZmlUpd j31Hwzu/1sLoD7dmNiEfemBF0MkYowRS9CZ8ssq2IC1o5Q91Jw4HXZaGB0Xye2elHL1wsA/Lk Ry4vwxAfIqJsuE1NfJLYzWFySHf3MDml9iE7ScE82n7sILaNO1STMpZC0pQi+G5qhPDSbk05q /r61q+3/XkTbSp9MpauslFP6gRj4UPwl90Lnk7H+pzoIAIKf0iWiYjgzNxQb6BOio77v9Pn9W RalG5xebMurP+/HHoe4TzVp8NLmZESbEJ6e3FBWQSEcdk8f8VPyRur8Jz+5o5lqlCVFeKPIrf NSiGdbDaTQ/tM/x2gETvZzoGWYmHIC1UXbV2qpGbgu/4ZKyXRRk/STwIjbtrZ73iPWM37Icss NwWFSUqTAkPDYcD1uyTnvpEj7EN6rwekvyGCqV/9qnUfPq8a+FalcGvhTrn6SQI/cxfdl+tJs It84oJDYc19Db3ZZKpg2GUzpwpfcaUXJT2rp1EUiSEFyMDcQPuNQSGj6DAk/seVRpGX3C7VbA Qt7jZd+Z5nRcAFUQKXAacT8264uT0/3SrtFoxUuqbbHr/vA5YkFkSq7tws4SZcXLLfDY= 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. 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(-) -- 2.9.0 Acked-by: Jakub Kicinski 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);