From patchwork Mon Jun 18 15:11:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138990 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4070085lji; Mon, 18 Jun 2018 08:12:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIe6jT6u534gNwLkOTVVQfVbTZ7ROVAOWS7nBUIA5sPvgjaPTljIyajxaXP5uDDyQj0piU+ X-Received: by 2002:a63:ad08:: with SMTP id g8-v6mr11106305pgf.74.1529334769042; Mon, 18 Jun 2018 08:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529334769; cv=none; d=google.com; s=arc-20160816; b=YtCa3RoLxLGq1jz9vklEf3uhVy1NrAS+Cx5Eb7oZOAWKxCe/QhuKRU7GsnrBO3gxlY mkzSnFwD4JVTs8rj0Pi00XalTiwbA4cjTBHx9uvEj8ULWuJGoN1zvR66QNFUw0zAkagY vXwfWsR317Q3IGryTZSP+4dnstmuyK/b+hMLZK9SdSSsOa2aAUr1+KzrJ5tlr/AIzC01 d6iE1YdWmdALvoIudRLmQyCbGwvK67u7zAQWamblHT79GpqHiIjIwOIlFBa0BVklQSnf ls7naioqD3hkRGkPVbxVDXgAut/+H5M1a632vFnLfSjBgls5LLcMY5mYL7q4vEF6PLRy fnTA== 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=84JbXJ3LYSC/ji+0Gl7GNdObppBwMLKZh1KJWdS7rqw=; b=w9pmP5DtlkcIcxYXzi0zhwS4TkngibaZHKCYUpqILtny/ovTiSbbbboE8HVy/aN+RM BYmnGXxH/ociTaTf/RMHAXEM4+ildfnRv4ERWLGENYE8dMgruilnd78x0UBB3CN/Bmwn G1Up2K5qdb/ShBej+LRub34akuVGHElDZErX5TzRwWg7k59Oq8x58Mbkj0vE839KDDuF sRmHG3seR9X4XHePLL9cyHeaXlYLYZvq7koolL5xzjutMvnFDsHyM8W/ofOo5AB9dO+I Q5nKkCMHqMiayXFcghwp0Q2HTbz5PgfkuWqbnaxgp5Y4BaLP9vBQlPv6QN4Z6j+oIVrg 8mSQ== 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 g28-v6si17162950plj.307.2018.06.18.08.12.48; Mon, 18 Jun 2018 08:12:49 -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 S1754761AbeFRPMr (ORCPT + 30 others); Mon, 18 Jun 2018 11:12:47 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:39073 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754601AbeFRPMo (ORCPT ); Mon, 18 Jun 2018 11:12:44 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LzJvV-1gGtgA44zx-014WRN; Mon, 18 Jun 2018 17:12:36 +0200 From: Arnd Bergmann To: Stanislav Yakovlev , Kalle Valo , "David S. Miller" Cc: y2038@lists.linaro.org, Arnd Bergmann , Arvind Yadav , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] ipw2x00: track time using boottime Date: Mon, 18 Jun 2018 17:11:16 +0200 Message-Id: <20180618151142.1214422-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180618151142.1214422-1-arnd@arndb.de> References: <20180618151142.1214422-1-arnd@arndb.de> X-Provags-ID: V03:K1:ymvPGCSA4ZZqQOW44nXwPLPxVeLmDDCTwIW6gSVc3DXykze/2LT QTybKlr0hM6zDHPqjwA6UpJmXFokF3AGayFQW5cpqGEgcp04tIUw56s3R5eqOyOiTxgoq7D /IpviYB70OFapR1wPMuE+qqU93drJ6+FCMGNBePkC+2EQP5HEFuRkTb0LzVNSj4Mx/75l6X k9cwSTmhzy26RJj+Nk5Eg== X-UI-Out-Filterresults: notjunk:1; V01:K0:4+k4d7ac9vE=:pMrEyq2Ky7Ig2rZt3o5GKI VYLq75q6SKWwm/Su05OBhg+Mtacun8M59ZNF+FtRj29HLJbK1Au33mS9aY9eciSYqAQ5wmD5A IysP6fOGqboEXnfMr0T0j60DDWmPK5GCvQRXeRQMpPP1jb+/AS/86XsFbBQCJgZ0oGxMgvU2T +suMCMyLYB2r8h+NvyWokXRtnNf2NOj67QwsbuUA3FHk0A1H7QGhd79/NpscyB5s5rGW4aX0a dG16jHVLJN8AkzlsIXGOBPrIhxyzajSlXA7MQ/Vg8Q1LV9B44WKgzCVrLGQTWIT2YbLMXMU/L 29PwaORX4CjJ93vs7LK+T7nyAhDxw5qcq+gBGlWAQwAJlfSOgOjBv2ThY3+cN9EXk0/RoirS8 pNgTMdbpkdHoMDxKHc/nDzBPLIwa0oHzBljfu7BwheLllvXUe1iMQ9LwJQvibiROzSmPWZHZA byzq2p3n/RQEDLoiPJVGyAMI16VykonMjmcr58WOsunr+M1utVbfXz7ITeJQLcK7YyHSY4pMw aosQBEC0YGGSwhm7j5k2Q8NDXk/2FkkLvg1DpWwhCg4zYSMRqALbc/e/hOiu6jN1Edz2Awoul DuYKJLa/y+RnrIR9Tj26wpuSqPIZhx4/9I1PJ2p1/Re5IPJcyjaYmbwJ/ZTDbosT8/bK95vUJ LQiXYmnNDC9Ww0ke9LM1xUHtCnsd0oRmlDKYDR99Y0+vawRHXtnzyBLiB7nLylpYF4fI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ipw2x00 driver family uses get_seconds() to read the current time for various purposes. This function is deprecated because of the 32-bit time_t overflow, and it can cause unexpected behavior when the time changes due to settimeofday() calls or leap second updates. In many cases, we want to use monotonic time instead, however ipw2x00 explicitly tracks the time spent in suspend, so this changes the driver over to use ktime_get_boottime_seconds(), which is slightly slower, but not used in a fastpath here. Signed-off-by: Arnd Bergmann --- drivers/net/wireless/intel/ipw2x00/ipw2100.c | 18 +++++++++--------- drivers/net/wireless/intel/ipw2x00/ipw2100.h | 12 ++++++------ drivers/net/wireless/intel/ipw2x00/ipw2200.c | 4 ++-- drivers/net/wireless/intel/ipw2x00/ipw2200.h | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) -- 2.9.0 Acked-by: Stanislav Yakovlev diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c index b8fd3cc90634..1ad83ef5f202 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c @@ -692,7 +692,7 @@ static void printk_buf(int level, const u8 * data, u32 len) static void schedule_reset(struct ipw2100_priv *priv) { - unsigned long now = get_seconds(); + time64_t now = ktime_get_boottime_seconds(); /* If we haven't received a reset request within the backoff period, * then we can reset the backoff interval so this reset occurs @@ -701,10 +701,10 @@ static void schedule_reset(struct ipw2100_priv *priv) (now - priv->last_reset > priv->reset_backoff)) priv->reset_backoff = 0; - priv->last_reset = get_seconds(); + priv->last_reset = now; if (!(priv->status & STATUS_RESET_PENDING)) { - IPW_DEBUG_INFO("%s: Scheduling firmware restart (%ds).\n", + IPW_DEBUG_INFO("%s: Scheduling firmware restart (%llds).\n", priv->net_dev->name, priv->reset_backoff); netif_carrier_off(priv->net_dev); netif_stop_queue(priv->net_dev); @@ -2079,7 +2079,7 @@ static void isr_indicate_associated(struct ipw2100_priv *priv, u32 status) memcpy(priv->bssid, bssid, ETH_ALEN); priv->status |= STATUS_ASSOCIATING; - priv->connect_start = get_seconds(); + priv->connect_start = ktime_get_boottime_seconds(); schedule_delayed_work(&priv->wx_event_work, HZ / 10); } @@ -4070,8 +4070,8 @@ static ssize_t show_internals(struct device *d, struct device_attribute *attr, #define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" y "\n", priv-> x) if (priv->status & STATUS_ASSOCIATED) - len += sprintf(buf + len, "connected: %lu\n", - get_seconds() - priv->connect_start); + len += sprintf(buf + len, "connected: %llu\n", + ktime_get_boottime_seconds() - priv->connect_start); else len += sprintf(buf + len, "not connected\n"); @@ -4108,7 +4108,7 @@ static ssize_t show_internals(struct device *d, struct device_attribute *attr, DUMP_VAR(txq_stat.lo, "d"); DUMP_VAR(ieee->scans, "d"); - DUMP_VAR(reset_backoff, "d"); + DUMP_VAR(reset_backoff, "lld"); return len; } @@ -6437,7 +6437,7 @@ static int ipw2100_suspend(struct pci_dev *pci_dev, pm_message_t state) pci_disable_device(pci_dev); pci_set_power_state(pci_dev, PCI_D3hot); - priv->suspend_at = get_seconds(); + priv->suspend_at = ktime_get_boottime_seconds(); mutex_unlock(&priv->action_mutex); @@ -6482,7 +6482,7 @@ static int ipw2100_resume(struct pci_dev *pci_dev) * the queue of needed */ netif_device_attach(dev); - priv->suspend_time = get_seconds() - priv->suspend_at; + priv->suspend_time = ktime_get_boottime_seconds() - priv->suspend_at; /* Bring the device back up */ if (!(priv->status & STATUS_RF_KILL_SW)) diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.h b/drivers/net/wireless/intel/ipw2x00/ipw2100.h index ce3e35f6b60f..8c11c7fa2eef 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2100.h +++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.h @@ -491,7 +491,7 @@ struct ipw2100_priv { /* Statistics */ int resets; - int reset_backoff; + time64_t reset_backoff; /* Context */ u8 essid[IW_ESSID_MAX_SIZE]; @@ -500,8 +500,8 @@ struct ipw2100_priv { u8 channel; int last_mode; - unsigned long connect_start; - unsigned long last_reset; + time64_t connect_start; + time64_t last_reset; u32 channel_mask; u32 fatal_error; @@ -581,9 +581,9 @@ struct ipw2100_priv { int user_requested_scan; - /* Track time in suspend */ - unsigned long suspend_at; - unsigned long suspend_time; + /* Track time in suspend, using CLOCK_BOOTTIME */ + time64_t suspend_at; + time64_t suspend_time; u32 interrupts; int tx_interrupts; diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c index 8a858f7e36f4..33186a6b28c0 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c @@ -11888,7 +11888,7 @@ static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state) pci_disable_device(pdev); pci_set_power_state(pdev, pci_choose_state(pdev, state)); - priv->suspend_at = get_seconds(); + priv->suspend_at = ktime_get_boottime_seconds(); return 0; } @@ -11925,7 +11925,7 @@ static int ipw_pci_resume(struct pci_dev *pdev) * the queue of needed */ netif_device_attach(dev); - priv->suspend_time = get_seconds() - priv->suspend_at; + priv->suspend_time = ktime_get_boottime_seconds() - priv->suspend_at; /* Bring the device back up */ schedule_work(&priv->up); diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.h b/drivers/net/wireless/intel/ipw2x00/ipw2200.h index aa301d1eee3c..f98ab1f71edd 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.h +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.h @@ -1343,9 +1343,9 @@ struct ipw_priv { s8 tx_power; - /* Track time in suspend */ - unsigned long suspend_at; - unsigned long suspend_time; + /* Track time in suspend using CLOCK_BOOTIME */ + time64_t suspend_at; + time64_t suspend_time; #ifdef CONFIG_PM u32 pm_state[16];