From patchwork Fri Nov 10 15:37:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118577 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8079899qgn; Fri, 10 Nov 2017 07:38:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMZCPePYECY+LADnBXD2Lrk0O9kBbkpBJZdvqdoMSqICTH1G5uXJdnBbZCbSkmtVtKdp9IxT X-Received: by 10.98.249.5 with SMTP id o5mr803729pfh.54.1510328317535; Fri, 10 Nov 2017 07:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510328317; cv=none; d=google.com; s=arc-20160816; b=fvZOQYCVVR5yhx2NatNz6p4hcxKU1UAVmPpOF9zidRbh5XhX1kPf3a8WCSvUZX/X+E OLzfNYYrxlZ5XIL2OLw7DCF2NJbTaJJ9q9ghUlRuc8cXt+Wn6tSYXBHhQlCSBo6hj+bB IhWgnX1kumsKIyjdcD31uyYdS7mmaZP360egQmjFt6GwbbR0GMDThyboU+Dhe/ExFALG sJ2oWIIxHxl8ntvs7/qwTuPCQWeyqiFn9uONH22j2BvbTPuuJz5xwMhlgNohENF093qj cscABfRxeI7Bv60t/4DTD6PcEKYTcf9TiFM5P4DnkY7uXmGdLJFcVfRHuWDHS0G9fWEK sr0g== 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=V8+bYpjv4DeLkSnW5QUn1ZCU3rdsuPAGJrLZ/DUwmmk=; b=RwU0U+ujn25x3MjrN7B9W83emVrjhN9fxVRQhvWq2tdVdC8iu+uDENnlAiAPTYrlVH S00zzZ1rAHimwdSH88vkcIzxqM+R0EER/yHsexao4ppKrit3uNWonU9IMbmXv9xozqIi yrchgLpCa2opuzESZ+j4a0+581Iz22IBkqeSGTgx13BtWQSGiDU9m8jbnn405xS34U+r N1WED8SpO38+EFPEhhpuvHKhOPvhQeoVAupp3ePiFgExnceD1u1zkUdqAFATa5ydSNey uOjoRKkfNYpVV9xDKT7iERhB/VjvPp2/9cmm197c+mN8tSf7z1x3S+QeMNkl1UkPksVn eBDQ== 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 a91si9181285pld.674.2017.11.10.07.38.37; Fri, 10 Nov 2017 07:38:37 -0800 (PST) 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 S1753262AbdKJPhu (ORCPT + 23 others); Fri, 10 Nov 2017 10:37:50 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:49938 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929AbdKJPhs (ORCPT ); Fri, 10 Nov 2017 10:37:48 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lkxnh-1ekrUs1VbR-00apFp; Fri, 10 Nov 2017 16:37:31 +0100 From: Arnd Bergmann To: Anil Gurumurthy , Sudarsana Kalluru , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, hch@lst.de, hare@suse.com, jthumshirn@suse.de, Arnd Bergmann Subject: [PATCH 1/7] scsi: bfa: use ktime_get_real_ts64 for firmware timestamp Date: Fri, 10 Nov 2017 16:37:09 +0100 Message-Id: <20171110153715.1929456-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110153715.1929456-1-arnd@arndb.de> References: <20171110153715.1929456-1-arnd@arndb.de> X-Provags-ID: V03:K0:KaLg+egeRfhBIhP6+g1ypHG2oA09owQTKOQOIcnN76U/6hroPi3 T6z0iVsaWLyrnsRWp3hgmq/yQGn8e4LjswQ6X96zOSvXNa9JPBCURYqYMewvDXfvWVCQtBi epGKEX8/hpKZSb78n8wI1qDuNq3BTZ9NPn9kTJR3qmLwqwLQmRij1D/GgTHd+ONk4Xtd0Z0 R0qBrdVcONjqrOk9QRBeg== X-UI-Out-Filterresults: notjunk:1; V01:K0:wkTVqXffYcg=:o5At62PTY2h+2lnkS0VC0o qNX1vKMLyz3UUbVIx52ItMyK27w4AXjGp+i0GmnP0Ey4xKuO6+5waGAvKdjYk6e6MpcHl+wba Mxnc0HEwiXBMVdzNWCyImK28Pvg2C2DSuysXwu3I9miQbPOVLNZpWrLhm/8evGRYFFRSFyt0t LF2dVzP9nE8n9wF4vCF1NvVOCDr5k38rdKe/pEAOw6rhCTIt2zWesg60LZfi+1WTobT4tglQ+ paHy5857KvNnv1iNugdtLhiMW0T/d/D+ehYirDdOJTB+jVo0zrxBb935nIUKFLp91DEtB8fxm jadgYDapdG50GicP9lARPdKwDR8EQCUarIDj5bKd5xEGLACsHh3076/zeyh4SAy1E9aw6bjiy IzroeqHJUvb1B00fAtvcCsnY6yKESWWrhWpJSe2ZgS4FeKSWJ+YlZfHoufkCL4x/8G+vJ0K9b n7y5vBqb3JTygQ16yPL3Mq/t9hYnrtUR/Z2PIcgwXFg2wzKd4kzNsa73o8alAAudHy+Xv3mNn YahgZ7QUPv+g3VCCySmdwfFf5nGptetkCI668gzDuqacAQp41fsUL/vfG3GPlzOgd3hdCWxCV sJBFcT8U0Bc+AWdZ7J+9wYd+5obBIgWNH+ZeYFYNZWGzDlh6ALopvcyDlzwebLF4cV2b9WUIN I4IxmQfIHzRKLptO8XNEsRevVXlwAceKSiOZmzM/tBHbl9RcXqBGhiSIuR44DoRoKKmfmBLxp BSuMqj4SYhN/N2bkXT1Z1ws21IVgeCsY8ZxpZQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BFA_TRC_TS() calculates a 32-bit microsecond timestamp using the deprecated do_gettimeofday() function. This overflows roughly every 71 minutes, so it's obviously not used as an absolute time stamp, but it seems wrong to use a time base for it that will jump during settimeofday() calls, leap seconds, or the y2038 overflow. This converts it to ktime_get_ts64(), which has none of those problems but is not synchronized to wall-clock time. Signed-off-by: Arnd Bergmann --- drivers/scsi/bfa/bfa_cs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h index df6760ca0911..9685efc59b16 100644 --- a/drivers/scsi/bfa/bfa_cs.h +++ b/drivers/scsi/bfa/bfa_cs.h @@ -35,10 +35,10 @@ #define BFA_TRC_TS(_trcm) \ ({ \ - struct timeval tv; \ + struct timespec64 ts; \ \ - do_gettimeofday(&tv); \ - (tv.tv_sec*1000000+tv.tv_usec); \ + ktime_get_ts64(&ts); \ + (ts.tv_sec*1000000+ts.tv_nsec / 1000); \ }) #ifndef BFA_TRC_TS From patchwork Fri Nov 10 15:37:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118581 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8080728qgn; Fri, 10 Nov 2017 07:39:26 -0800 (PST) X-Google-Smtp-Source: AGs4zMYurZYZqVnFD5xF2YWIYL0gSSuPtMOy82hk8HE5ehraiPLFRk/S7L+YQpsh9YrPwxh+Dhvi X-Received: by 10.98.80.69 with SMTP id e66mr793774pfb.112.1510328366790; Fri, 10 Nov 2017 07:39:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510328366; cv=none; d=google.com; s=arc-20160816; b=po9d1FRPeVhaa/p+e6mwa+MPv+yHBQ4KqEGZ4pGlw5owtqpV5YxBMbtSMZfrNbJTqT 2ip6LBnjllcSXqeycU4rx02/JgCFOsRT9STY0HbROcCJhQxUqDLzHLIKDg3Wk2d4zxhw e1Kwaby8kCZ2vOzt8pjomYVNe6RQnfAa1pkFmuJmJlXgVwq8JOIE823PlaHDPH6HSeS4 5J6LGBpWyVvwooDspmh+caMvVLLAhuKbOPo19l/lTuVV9RqoP4e9ZsDlzxKY69XV+Ndt 6cPIbIR6XiMDa+SHlbeaQTExfz9aMTgobERXabwvHQdZqGS8Oq6TRIadItxIQUZReVu/ mfdQ== 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=soHvmxijzSiN6/1dOG2V0Jy0T7xrjSdGjqVRkQyvEkU=; b=qTadLuX9vyZOJ5fOvwazyxcy1Qrhx86IQDQ8fGVJKURY3pgf+Iy2Z1tEvfFvwPyuG/ XL1nFFYIIefwfgPn0ecXSDiUv5ZFBr5kFPel3WnoCn6ovVVNrV005piPxXlcXwNvfCzQ mniFTHD6M6ReKgJb0U/qRmDJJ99p3MxsgWvsJISo+Sp0e56qqELgKJ0FOxxZxpSMi0Ko d9HoNZCh5J/z0IgcHWCEbz7VDWm6gyEzJWIMf18IfdGrxTCBovt4WtJaZpBahiHr8UA5 KF59OOfF+aRY5+aDtmCqvMpJpVWLym0V1ZUiN5pKTMCq72v1fQCCtnHhCKhLmhcxxpXA 1L5Q== 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 s2si8640854pgp.169.2017.11.10.07.39.26; Fri, 10 Nov 2017 07:39:26 -0800 (PST) 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 S1753499AbdKJPjZ (ORCPT + 23 others); Fri, 10 Nov 2017 10:39:25 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:51617 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753185AbdKJPjX (ORCPT ); Fri, 10 Nov 2017 10:39:23 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Md4Bm-1eVGDh3Wr4-00IC6o; Fri, 10 Nov 2017 16:37:32 +0100 From: Arnd Bergmann To: Anil Gurumurthy , Sudarsana Kalluru , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, hch@lst.de, hare@suse.com, jthumshirn@suse.de, Arnd Bergmann Subject: [PATCH 2/7] scsi: bfa: use proper time accessor for stats_reset_time Date: Fri, 10 Nov 2017 16:37:10 +0100 Message-Id: <20171110153715.1929456-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110153715.1929456-1-arnd@arndb.de> References: <20171110153715.1929456-1-arnd@arndb.de> X-Provags-ID: V03:K0:56Gcehp3KWQ5z6qO5VO4nlcZdNFwYDM5NgWTXh2oj0wSYa8tXoE M0ToFBzhCteIUZ0mxw2caUL/bfJWPQmqXsMvsYvuVHhhb8Dgc92vDK3ZD6AK070/gzmyeFF YObDrv/pY/uqHDifm3OBT5ZkyNB43o7a+rEORafQwQ+dsVvLXgp1wPU/hJzU6orIOKqsUx6 6Ou2PcrAdnJVUbDGSSW1A== X-UI-Out-Filterresults: notjunk:1; V01:K0:bGQk8vN0uuQ=:hVZdP/eHrWMzLJ33MWENCt Fd8eDxjWb2iiVowbeZh7afo5uLZ5YKJC+bS4Z10AL5aEPbr6oLakCzn2cmxZjtbFwLsAt8BTM +QvCD7WY7hExcU6Y3Fw5DYsSipz/QINMuRDEMzuGmdUgMRx1fexzLRFcjvzvNezF2c3dxtoe4 esCtZdlqekbgLFfFfqxbDtaZr5t30MsdGvXZAIUVR4KfbOnXRmcMV2A3gmQOnBABkGKeuZ5Bm QNm1KP3pNkhWiw1vffu2Qeak7n8VafFlAWgDrLJr7HU/wjnBHmttD+9Y4XKur1bl8nLmxyAZk B3WPahZOJD4LVDuTjT7ZT6KDgY17HjXTNeyMlLXV+gDUup70VlQ34dcg7TbU6hWYkOrKn80ao oyaViQryUmimYvIgz+OSwXKNL+4O/S3CVOFLid4ddHNv292vPsdTIgeY1XlO/kgETWwZ0TaLl t2uBGAf1Z/p4zoo8n3Jil5XUGHJCRtoJPy4Y0kXsFQiDttSBM/hI2OsFES/PRKvI41BVZzal2 7b1+qX0D9IwxzqULsUZy/LD9yRc2HSIZqtTD0AabIoc8k3gI5Bbo3fwzPN6+rYMOMb0FlDgNi xjKM/GSlNrBORAepXaO5qBDkwDLAbX9QJXcJPmywkXYcx9w7XRQfgXn7sownFKVqPS8OPrI/a ErXKdZzgsSRszkoq/HT/avxgy7jvCag9klTTxWe/WwlUdwEhqAvZq+VsoWq67e9ZEyAmkHy0A +TyR97x8GnrT4ZQ51Y45xtX22ct8bCejVni/Lw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We use the deprecated do_gettimeofday() function to read the current time when resetting the statistics in both bfa_port and bfa_svc. This works fine because overflow is handled correctly, but we want to get rid of do_gettimeofday() and using a non-monotonic time suffers from concurrent settimeofday calls and other problems. This uses the ktime_get_seconds() function instead, which does what we need here. Signed-off-by: Arnd Bergmann --- drivers/scsi/bfa/bfa_port.c | 15 +++------------ drivers/scsi/bfa/bfa_port.h | 2 +- drivers/scsi/bfa/bfa_svc.c | 15 ++++----------- drivers/scsi/bfa/bfa_svc.h | 2 +- 4 files changed, 9 insertions(+), 25 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/bfa/bfa_port.c b/drivers/scsi/bfa/bfa_port.c index da1721e0d167..079bc77f4102 100644 --- a/drivers/scsi/bfa/bfa_port.c +++ b/drivers/scsi/bfa/bfa_port.c @@ -96,14 +96,11 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status) port->stats_busy = BFA_FALSE; if (status == BFA_STATUS_OK) { - struct timeval tv; - memcpy(port->stats, port->stats_dma.kva, sizeof(union bfa_port_stats_u)); bfa_port_stats_swap(port, port->stats); - do_gettimeofday(&tv); - port->stats->fc.secs_reset = tv.tv_sec - port->stats_reset_time; + port->stats->fc.secs_reset = ktime_get_seconds() - port->stats_reset_time; } if (port->stats_cbfn) { @@ -124,16 +121,13 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status) static void bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status) { - struct timeval tv; - port->stats_status = status; port->stats_busy = BFA_FALSE; /* * re-initialize time stamp for stats reset */ - do_gettimeofday(&tv); - port->stats_reset_time = tv.tv_sec; + port->stats_reset_time = ktime_get_seconds(); if (port->stats_cbfn) { port->stats_cbfn(port->stats_cbarg, status); @@ -471,8 +465,6 @@ void bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, void *dev, struct bfa_trc_mod_s *trcmod) { - struct timeval tv; - WARN_ON(!port); port->dev = dev; @@ -494,8 +486,7 @@ bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, /* * initialize time stamp for stats reset */ - do_gettimeofday(&tv); - port->stats_reset_time = tv.tv_sec; + port->stats_reset_time = ktime_get_seconds(); bfa_trc(port, 0); } diff --git a/drivers/scsi/bfa/bfa_port.h b/drivers/scsi/bfa/bfa_port.h index 26dc1bf14c85..0c3b200243ca 100644 --- a/drivers/scsi/bfa/bfa_port.h +++ b/drivers/scsi/bfa/bfa_port.h @@ -36,7 +36,7 @@ struct bfa_port_s { bfa_port_stats_cbfn_t stats_cbfn; void *stats_cbarg; bfa_status_t stats_status; - u32 stats_reset_time; + time64_t stats_reset_time; union bfa_port_stats_u *stats; struct bfa_dma_s stats_dma; bfa_boolean_t endis_pending; diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c index e640223bab3c..dd7d1e6bc2d8 100644 --- a/drivers/scsi/bfa/bfa_svc.c +++ b/drivers/scsi/bfa/bfa_svc.c @@ -3047,7 +3047,6 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa); struct bfa_port_cfg_s *port_cfg = &fcport->cfg; struct bfa_fcport_ln_s *ln = &fcport->ln; - struct timeval tv; fcport->bfa = bfa; ln->fcport = fcport; @@ -3060,8 +3059,7 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, /* * initialize time stamp for stats reset */ - do_gettimeofday(&tv); - fcport->stats_reset_time = tv.tv_sec; + fcport->stats_reset_time = ktime_get_seconds(); fcport->stats_dma_ready = BFA_FALSE; /* @@ -3295,9 +3293,7 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete) union bfa_fcport_stats_u *ret; if (complete) { - struct timeval tv; - if (fcport->stats_status == BFA_STATUS_OK) - do_gettimeofday(&tv); + time64_t time = ktime_get_seconds(); list_for_each_safe(qe, qen, &fcport->stats_pending_q) { bfa_q_deq(&fcport->stats_pending_q, &qe); @@ -3312,7 +3308,7 @@ __bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete) bfa_fcport_fcoe_stats_swap(&ret->fcoe, &fcport->stats->fcoe); ret->fcoe.secs_reset = - tv.tv_sec - fcport->stats_reset_time; + time - fcport->stats_reset_time; } } bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe, @@ -3373,13 +3369,10 @@ __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete) struct list_head *qe, *qen; if (complete) { - struct timeval tv; - /* * re-initialize time stamp for stats reset */ - do_gettimeofday(&tv); - fcport->stats_reset_time = tv.tv_sec; + fcport->stats_reset_time = ktime_get_seconds(); list_for_each_safe(qe, qen, &fcport->statsclr_pending_q) { bfa_q_deq(&fcport->statsclr_pending_q, &qe); cb = (struct bfa_cb_pending_q_s *)qe; diff --git a/drivers/scsi/bfa/bfa_svc.h b/drivers/scsi/bfa/bfa_svc.h index ea2278bc78a8..7e8fb6231d49 100644 --- a/drivers/scsi/bfa/bfa_svc.h +++ b/drivers/scsi/bfa/bfa_svc.h @@ -505,7 +505,7 @@ struct bfa_fcport_s { struct list_head stats_pending_q; struct list_head statsclr_pending_q; bfa_boolean_t stats_qfull; - u32 stats_reset_time; /* stats reset time stamp */ + time64_t stats_reset_time; /* stats reset time stamp */ bfa_boolean_t diag_busy; /* diag busy status */ bfa_boolean_t beacon; /* port beacon status */ bfa_boolean_t link_e2e_beacon; /* link beacon status */ From patchwork Fri Nov 10 15:37:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118574 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8079255qgn; Fri, 10 Nov 2017 07:37:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMYX/Nkj6w5J2oyGvpsO2L23yq0Ignh0jZ5iBj+Kj0kKYJW/SICAuUTCEWNetNo/tILsJsAQ X-Received: by 10.99.173.74 with SMTP id y10mr701017pgo.107.1510328274902; Fri, 10 Nov 2017 07:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510328274; cv=none; d=google.com; s=arc-20160816; b=eb53QkDB5yBNsd/zXDUy9QG9eLgguAHozHYG5WkOO7tfMGQEvKM3cRrpCMYwAU3nOz AyapDefVAFL4uA0DKX1mGYNz0MPxdNCfTtHi+K60/GhjexN5+hyqHjy+RCh21tKsdNCc Ema87KXe3BJGi32BgdtKoivZj39mlioSsjq3HNId332CdST71+BJahi0sfTqk8MJF2/C NUV0s69YcdVxs65uFKDnRm3yxqlQLwq1hP3vo38JWq/I94XqrlWRaO8kjNYFMHxaj6Vp czRr9ukwoHqZwXUjGIRToVJJQhrwDKHplfKmXBqO8w3/El5otsJc1TNWX4zvSPK05KKx uUEg== 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=+kwQkwNS+X+gnbJHzwIA8ADhbiglnC+WLS1C48POYvY=; b=jafDXz6qDf9Yw9x5hhKbi9CyA9CbTyzJJ09nVTCYSB8dGpFOmm7kTfl8VlSBu5dlPi mZfNIHzdGBoPC+YpEY3gN8LgbpjrRSLt9gtVQWTKdqXeIke2OdojF/qbUBHXZ0JreBbZ yH/U+UgEC+208Wphe25l6dyuNNxYV6UmMgVN4xMb5rZlqw+WWxxWDej+joOHC1BfhQEX N1L0J6XsMMIiRdaCqWoZyb7K4axc0PY0wtWVThAcoMmoqOCB6PDcfbAcOxhK6UuhdYy/ 7jYyvRl0A5Tawb0btwYxpK1dAet9aP8J45xH+4IWrTQk7x/rN8itD3ZmGGHmeZ81uuIp usCg== 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 33si2203527ply.166.2017.11.10.07.37.54; Fri, 10 Nov 2017 07:37:54 -0800 (PST) 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 S1753348AbdKJPhx (ORCPT + 23 others); Fri, 10 Nov 2017 10:37:53 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:57844 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753211AbdKJPhs (ORCPT ); Fri, 10 Nov 2017 10:37:48 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Md4Bm-1eVGDm194k-00IC6o; Fri, 10 Nov 2017 16:37:32 +0100 From: Arnd Bergmann To: Anil Gurumurthy , Sudarsana Kalluru , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, hch@lst.de, hare@suse.com, jthumshirn@suse.de, Arnd Bergmann Subject: [PATCH 3/7] scsi: bfa: improve bfa_ioc_send_enable/disable data Date: Fri, 10 Nov 2017 16:37:11 +0100 Message-Id: <20171110153715.1929456-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110153715.1929456-1-arnd@arndb.de> References: <20171110153715.1929456-1-arnd@arndb.de> X-Provags-ID: V03:K0:swalmTZADPr80V+qrfarea+osqfK3nMzF4+jTsQlJ75WWB6Butx qUXjFc9vqGfUTBlQWWSOl/2PKDBHh2R100ArGopGw3BXH83Owp7cAYycppbbzJ22r7tIQ17 CwrGfaD0iLgeQkpKr/n3S1aK8uWhypS54l8qtKoGlF6OAm52tp4gwZxXhvctNPiG683slei AqnnENhEsIwXX8A6cTpLw== X-UI-Out-Filterresults: notjunk:1; V01:K0:lQB3U3k6tu8=:AEyMp8zztygPfQiRCrQqSp qmfeGiTtjNbePo1RLdHUe0mgiw8xXiTwP5PJg/EpuXOhir8cBIUcJWrltKy4m33M2gRbnG9Qa cZIdaGdLyflNEuiz1Ab9tzFdtMgaCj1G+f1H+XVaFO7r3esEQ+2RNRqltQCfK2jjlnSH63oBq 4kzrzqnjnw3PZMc7n+pXZQZcFOjpedxx4ZCPLHROzmiqQb4AUSQLX7c64H+BPiXMqFp3f2D7f yoOEw4LEwve2dcVPJoKKWKnGBUSucvfH4GKcdLCZ6Ml9mQnomIXCb+VVU7kJiiUX7/JgCFOEd KMXF7LFK90p3DjutDmTeWNbn5vr4PC1nf4keRrKK0nRjbGowQ/6h8dlPulFX7CtZbf8oPszh/ q8qw0ejXZnTYRVFHOUzsyU5ixY4EiE5jRCtK8po5o5eubwWvM2cyYKk5drT7jDZhPVjd7GA69 5/98lgXOaQ0n4Hz5UjfBxG2oM7w5ctH0hvQv/MRV4zlJxa09QJ6cdeTS+bHbsuE8H7nwyku1j Qmks4i9dQYhEfwc0Nb6mCkrGq7qnsRJgmdybN0BFLxblXdY/yMQVbLGnCXIS7Cv2zVNG8BefB ixxYHBoZW0kK6w8bvKBK6CJfrQpPPIz8Oani9LNtvKTIDW6UXw4C/3uGwdYc5nNi4xE/9fy05 seFhWGk/1XcYOP55qfHtIik7r8i1WISeg79W4Ni7AnKjapFTk1kq4DRzT8kvEM6GkBHImciEo 7OMXMdYTy9GQFmYwIt0DMCVOv5J9+OP/1Ec7IQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In bfa_ioc_send_enable, we use the deprecated do_gettimeofday() function to read the current time. This is not a problem, since the firmware interface is already limited to 32-bit timestamps, but it's better to use ktime_get_seconds() and document what the limitation is. I noticed that I did the same change in commit a5af83925363 ("bna: avoid writing uninitialized data into hw registers") for the ethernet driver. That commit also changed the "disable" funtion to initialize the data we pass to the firmware properly, so I'm doing the same thing here. Signed-off-by: Arnd Bergmann --- drivers/scsi/bfa/bfa_ioc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 256f4afaccf9..117332537763 100644 --- a/drivers/scsi/bfa/bfa_ioc.c +++ b/drivers/scsi/bfa/bfa_ioc.c @@ -1809,13 +1809,12 @@ static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc) { struct bfi_ioc_ctrl_req_s enable_req; - struct timeval tv; bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, bfa_ioc_portid(ioc)); enable_req.clscode = cpu_to_be16(ioc->clscode); - do_gettimeofday(&tv); - enable_req.tv_sec = be32_to_cpu(tv.tv_sec); + /* unsigned 32-bit time_t overflow in y2106 */ + enable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds()); bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s)); } @@ -1826,6 +1825,9 @@ bfa_ioc_send_disable(struct bfa_ioc_s *ioc) bfi_h2i_set(disable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_DISABLE_REQ, bfa_ioc_portid(ioc)); + disable_req.clscode = cpu_to_be16(ioc->clscode); + /* unsigned 32-bit time_t overflow in y2106 */ + disable_req.tv_sec = be32_to_cpu(ktime_get_real_seconds()); bfa_ioc_mbox_send(ioc, &disable_req, sizeof(struct bfi_ioc_ctrl_req_s)); } From patchwork Fri Nov 10 15:37:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118575 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8079413qgn; Fri, 10 Nov 2017 07:38:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMZOeEqYd6rEcDDPA6ecA1xxEWQAZzPGWaY8y3ie6hST+6zQZc0Mk0Iw6ENN6Mqj50cibigg X-Received: by 10.84.128.97 with SMTP id 88mr755926pla.161.1510328285447; Fri, 10 Nov 2017 07:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510328285; cv=none; d=google.com; s=arc-20160816; b=oFEt3gBcnY57zVG9bpzpCWKBNtMHZaWfjZJgzhVbeKGg2WnLudCdaqx/xAme5nSAtU a1PkERCUowP0muUCMQlc0j+/+wXOsqBF3MhwJ4iNpe3vZn+c+6j7m3L+ACu7iAXWwcSa mjSl/mTt+STYGAtSrscFbHbWaf8OwJHc7BJy9UtLjMXr9yITFfA21UNtLSg2gzfebAtR UNMPp/nBAnbyiasRDmVoqPFstF9WTOGoLdysXax5JLNZYg0lXy18YkBkIbqBEiq+X3Hx tn5nVfBDudzT0OWyEHvxJl+DcD8wka9Ovgz4FmwmFBZBQaVdogLEhg0TPOIm3I1LoLQg zJCg== 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=NqjXRsyp2VNGj5QTqjejYewbI0SHGBGPwjahOhqUDS4=; b=ht9dc9RWk4vd/hUojK7tCxprkElt4b0Mz36zd59adF/Ehwm5YhwOKDyHBsu8ge3m92 yIpzwBh7Fbe/+P2G3Ik4IAmrky8tDWkw2WTaVm+phm+XM/DL8VqfKBcn3EKn3p6v0GHe hZq+v9hNlrD1dJsERk0y2XwlyLDaHyqvtEkoZyORKTZK0R1qcd6q2LyZu1FhXLjTWe0J yp+FkwG0SPutk0EhlDxUEMLCMYPg5kO2KRTwonv3ghcPTFjsNx1bqhhxXdLZgTIRRuOl 4BpB9/TOj9A/I/5LWAF/dCdUJT3cMaU5JQob8v3racAtnJSFq+eyLMBeNeSi2sSrtEzG bDLg== 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 a91si9181285pld.674.2017.11.10.07.38.05; Fri, 10 Nov 2017 07:38:05 -0800 (PST) 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 S1753310AbdKJPhw (ORCPT + 23 others); Fri, 10 Nov 2017 10:37:52 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:56196 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753141AbdKJPhs (ORCPT ); Fri, 10 Nov 2017 10:37:48 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0LtWNA-1fBVBR0dka-010qbA; Fri, 10 Nov 2017 16:37:33 +0100 From: Arnd Bergmann To: Anil Gurumurthy , Sudarsana Kalluru , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, hch@lst.de, hare@suse.com, jthumshirn@suse.de, Arnd Bergmann Subject: [PATCH 5/7] scsi: bfa: replace bfa_get_log_time() with ktime_get_real_seconds() Date: Fri, 10 Nov 2017 16:37:13 +0100 Message-Id: <20171110153715.1929456-6-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110153715.1929456-1-arnd@arndb.de> References: <20171110153715.1929456-1-arnd@arndb.de> X-Provags-ID: V03:K0:rJFCtGg7+A3WsdfWGIvbkZngd3UuBd5eUYz+fENZaj4OhVbCjR3 455IJqNNjDStQBJAfhoPvv04lBib9WFLQJyP4YBtIMU7rpypK9+R8m/SN9wDiTD49hrkZFJ roTRhbPrBrFf//f4urpylmq7ET+hhJsjvqfDcYe6gxu0ea1XnAAGpt7EUz9CL+Hzdut8xx9 +EkWv7xBK1OL2QEo+Z3VA== X-UI-Out-Filterresults: notjunk:1; V01:K0:sZrt4+q72VY=:IwK6eTRRE8MUuar7/8WPF8 ukuvrAZeEi1BXUyrUevnclOichaQL8+dYx381aBjGvzEo8DuFS2Yqjvc09jfcCdvdaNB/+nL6 1zC0hCQDT5ulZ+LYWJAyfW2qhFlPZeEyrnPY+C9NM32VX1gqhhGIFU1+K/0OANmxkfwxAmrLa vJDqqsTPQ97ZJEJSQbgtM7lKfvUPoEZVH5u2lQ5n25nAs6dddEGC52ilUUzkgVQNeAYxEAXPW v+pbDAqM1HeV6xCc/X7bp+cFIQgsZMV4kGQPO7wO/RpFzzwpK138Qg2nJeyKvRawHdb9MLcjB tt+m5FPmBE/Qd8QA+w4J3OI6q7AtSxsL7ovLIp+4bihpnDpPCHWffBDru7QcJiAkckn+NYJV6 wPsG2OmzXIrVc3taThRgK1zf5OT9b2EEoZ/rTnuRw5Vszm9mLMQk04FycWNjPS5r5ws/JwZMV GiFajDeqgzJgnJZ6YJ1ILoSlGFq9VqIUKgl7YtKfw+cfyw72gRkSkqe/BvD/3go3XScdjpLzu IWPUkdCVX4dwWUdRKcJ7JMkkYAkGayDMUTBpQTRrDxSUudu3Jb4ZaF0mRPFfLWCBGDAh315kL 5SG/v0gzUyycQ0Jgjz66Tjb2masClxQuF3CN1HyhDlePTxpS7pEWJoyycZEGnNv76iN+d0RXA uwyFaVqzXhgAchCBQWYk0Fnj3os7RHDW4p1/D0pOi9PTvn21XFDNjhz6kE6K0rniIjMdPDUrV HT0dS9g63cro18u8qzF10ZMcmqO4CsqLXNkSIA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bfa_get_log_time() returns a 64-bit timestamp that does not suffer from the y2038 overflow on 64-bit systems. However, on 32-bit architectures the timestamp will jump from 0x000000007fffffff to 0xffffffff80000000 in y2038 and produce wrong results. The ktime_get_real_seconds() function does the same thing as bfa_get_log_time() without that problem, so we can simply remove the former use ktime_get_real_seconds() instead. Signed-off-by: Arnd Bergmann --- drivers/scsi/bfa/bfa_svc.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c index dd7d1e6bc2d8..9d20d2c92e8c 100644 --- a/drivers/scsi/bfa/bfa_svc.c +++ b/drivers/scsi/bfa/bfa_svc.c @@ -288,18 +288,6 @@ plkd_validate_logrec(struct bfa_plog_rec_s *pl_rec) return 0; } -static u64 -bfa_get_log_time(void) -{ - u64 system_time = 0; - struct timeval tv; - do_gettimeofday(&tv); - - /* We are interested in seconds only. */ - system_time = tv.tv_sec; - return system_time; -} - static void bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec) { @@ -320,7 +308,7 @@ bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec) memcpy(pl_recp, pl_rec, sizeof(struct bfa_plog_rec_s)); - pl_recp->tv = bfa_get_log_time(); + pl_recp->tv = ktime_get_real_seconds(); BFA_PL_LOG_REC_INCR(plog->tail); if (plog->head == plog->tail) @@ -6141,13 +6129,13 @@ bfa_fcdiag_lb_is_running(struct bfa_s *bfa) /* * D-port */ -#define bfa_dport_result_start(__dport, __mode) do { \ - (__dport)->result.start_time = bfa_get_log_time(); \ - (__dport)->result.status = DPORT_TEST_ST_INPRG; \ - (__dport)->result.mode = (__mode); \ - (__dport)->result.rp_pwwn = (__dport)->rp_pwwn; \ - (__dport)->result.rp_nwwn = (__dport)->rp_nwwn; \ - (__dport)->result.lpcnt = (__dport)->lpcnt; \ +#define bfa_dport_result_start(__dport, __mode) do { \ + (__dport)->result.start_time = ktime_get_real_seconds(); \ + (__dport)->result.status = DPORT_TEST_ST_INPRG; \ + (__dport)->result.mode = (__mode); \ + (__dport)->result.rp_pwwn = (__dport)->rp_pwwn; \ + (__dport)->result.rp_nwwn = (__dport)->rp_nwwn; \ + (__dport)->result.lpcnt = (__dport)->lpcnt; \ } while (0) static bfa_boolean_t bfa_dport_send_req(struct bfa_dport_s *dport, @@ -6581,7 +6569,7 @@ bfa_dport_scn(struct bfa_dport_s *dport, struct bfi_diag_dport_scn_s *msg) switch (dport->i2hmsg.scn.state) { case BFI_DPORT_SCN_TESTCOMP: - dport->result.end_time = bfa_get_log_time(); + dport->result.end_time = ktime_get_real_seconds(); bfa_trc(dport->bfa, dport->result.end_time); dport->result.status = msg->info.testcomp.status; @@ -6628,7 +6616,7 @@ bfa_dport_scn(struct bfa_dport_s *dport, struct bfi_diag_dport_scn_s *msg) case BFI_DPORT_SCN_SUBTESTSTART: subtesttype = msg->info.teststart.type; dport->result.subtest[subtesttype].start_time = - bfa_get_log_time(); + ktime_get_real_seconds(); dport->result.subtest[subtesttype].status = DPORT_TEST_ST_INPRG; From patchwork Fri Nov 10 15:37:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118578 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8079936qgn; Fri, 10 Nov 2017 07:38:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMbKi4OoFmZrv4Z/7dMJwxe8hO4RrlqCZWi3rV53ifJXX/jlSRqDU55K1IVN3fxzdb05vBX0 X-Received: by 10.99.121.140 with SMTP id u134mr728024pgc.16.1510328319845; Fri, 10 Nov 2017 07:38:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510328319; cv=none; d=google.com; s=arc-20160816; b=PJD74EHNazXfQfaaENIXrfcpUVjZmacirZNJ3tj0lfhui9b3ofO1uAWGwz4xM8MGgf yRE3Ly2sARULmRW9KwrjxCJyVmf0PlxyIKG0EmYjiEOis606gaSJwTnl+9oZ3D6CAEWx gfLKQSpMupHjmN+m7oUott+SlYWfcOFtU0Hxg+8BBiBvZD8wwNc5zeL1r0++ASDHduBb J6Kp71yhO8b1Z9CgkkUwQeSSuI0lZacBCPLLuk5mYa7lnO+VV8HsngscQ7CPSft49U3M Mjc3JzhG5+iC08CsdNN1chuR+wmbBhS6V9RQRw5I+gmt1S3y7jDGaVwl3s4uMm40/F30 lXWA== 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=XRftZJDm3ai0VWDqsu19KPwk20u5uhJ9IOYsAPFplGw=; b=PHdIFqtvPl7d47TnGpXXoZ4jPo/GtVnmSerzEpdKEtx9zQnwyCfwwRnnPkq08n5w91 itR76XGvPFHeA92Sz4kjaEvl1z3UXMHfQjWrLeU7j6ktpWnn5CqJW7y8NbRwWryMtxkG DYFsPtdubjfcAbaj10Idleos2Bc4ep8RQr/2JLiFpyFT1WSWA2MxWe9fm9YnUdJjrZW8 z5v9wpniJDJsfWei9w/2xAX4up5QhKR9c87MnVSbbYn/UXc3r/bPSYJYlDtCfbEdlgDY 5c2grb9zZ7i/jEKmIoSOEQkGhxjw7w+aVC/YsM1nHJav/UHxUhLafJ6akZ029zK0eUD7 E2qQ== 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 a91si9181285pld.674.2017.11.10.07.38.39; Fri, 10 Nov 2017 07:38:39 -0800 (PST) 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 S1753410AbdKJPih (ORCPT + 23 others); Fri, 10 Nov 2017 10:38:37 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:58152 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753146AbdKJPhu (ORCPT ); Fri, 10 Nov 2017 10:37:50 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MWjbX-1ekRYk2TTH-00XqFL; Fri, 10 Nov 2017 16:37:33 +0100 From: Arnd Bergmann To: Anil Gurumurthy , Sudarsana Kalluru , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, hch@lst.de, hare@suse.com, jthumshirn@suse.de, Arnd Bergmann Subject: [PATCH 6/7] scsi: bfa: try to sanitize vendor netlink events Date: Fri, 10 Nov 2017 16:37:14 +0100 Message-Id: <20171110153715.1929456-7-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110153715.1929456-1-arnd@arndb.de> References: <20171110153715.1929456-1-arnd@arndb.de> X-Provags-ID: V03:K0:F+ZmV3vkh9+pIezdX/G6DQPShDK66QHv4SUZGh4JAhigcmX/WCk beupxNC1blBzU5Dz99JFx9RJW3h7N0R4bmPBFYrFFQvdJoOGRCWJMRwFHJwkYkMLtHStHrk PCzikwUDOqCXutfcOTRU6LKamVHazFJP0xmey5Pe4Pm61HWNVWPAQaUjygVDCBUu+JzSyTP Mp0v0ulletjNSNIGSekuQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ETXCMT/dZBI=:Em6yaPe1AOD9d0LIXJH9No CWoWle67bsmaMmwHlCI3h0eUfKZyYXC2tLJndCfXZ5huo00Y7zodJ1L1FZTpFHwl06vEU/uMR zp2YiUW3hqUxQXiYQilzBnew6AHkayCEZauI+T9EavOAHeMAFSbbHGqpIaDB5/SwRF261j1NW ah1OL/lcR9tyB+BZiSAYgoJFmoXd9gu45D5qeskBo70rAgAMibjlBpezlabikLCnAApZ0zv7r odcjPzrkfP8Q7M5/LgqhrjLQKcDKoxRmE6XRZ3SG938/QunORZ6jF5p+2hqEZkk0ncjabJUAN ZjMNa/7XKo24uVNookG3ZqAMMnVzaMtix4SyTiysERSi2D9ko4gQr3tl6riTNip2BlVn2Q4wC 2nMPlqUx/aLXgV3vOEsqgQSypJABnXIUEaZExb16kgg0LJ+fE6Xsg/pXW+7fbsY7LfaGGvvwZ KnhuaIGo6qGvrU4Dpq9XZEo8K7Yu3oGexW8292VJnqr7wvedBwfaLxuDN3fJ9baSsD3XB9viL 7FxUOvaLbXk9DqFAUhvT8PkadVQqy3WioT42kMSn9uW7Qd0wDX0/sS40Uvw3sKATrK0FiVAdr vvM1frrWCiJFQGgNl/ZxQW2DHt8Ryjs7/4SFjIPsI4JXi6HheKr5ZQuqAEkZF5o6kD8SkzCv/ 4V0eniGq6a3w8MAlKKa4v1czsnUqrbykiZ1iyVpkLJYKhfQBoLK6ugrUKJ8wz/ZpJvOhgALTL j6o1nC/7s5c4bVJ1vcAJ/Y3ehXbpLkeuHW+giA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bfa_aen_entry_s is passed to user space in a netlink message, but is defined using a 'struct timeval' and an 'enum' that are not only different between architectures, but also between 32-bit user space and 64-bit kernels they may run on, as well as depending on the particular C library that defines timeval. This changes the in-kernel definition to no longer use the timeval type directly but instead use two open-coded 'unsigned long' members. This keeps the existing ABI, but making the variable unsigned also helps make it work after y2038, until it overflows in 2106. Since the macro becomes overly complex at this point, I'm changing it to an inline function for readability. I'm not changing the 32-bit user-space ABI at this point, to keep the changes separate, I deally this would be defined using the same binary layout for all architectures. Signed-off-by: Arnd Bergmann --- drivers/scsi/bfa/bfa_defs_svc.h | 3 ++- drivers/scsi/bfa/bfad_im.h | 32 ++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h index e81707f938cb..df1e874015c4 100644 --- a/drivers/scsi/bfa/bfa_defs_svc.h +++ b/drivers/scsi/bfa/bfa_defs_svc.h @@ -1455,7 +1455,8 @@ struct bfa_aen_entry_s { enum bfa_aen_category aen_category; u32 aen_type; union bfa_aen_data_u aen_data; - struct timeval aen_tv; + unsigned long aen_tv_sec; + unsigned long aen_tv_usec; u32 seq_num; u32 bfad_num; }; diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h index c81ec2a77ef5..7f7616c52814 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -131,16 +131,28 @@ struct bfad_im_s { } while (0) /* post fc_host vendor event */ -#define bfad_im_post_vendor_event(_entry, _drv, _cnt, _cat, _evt) do { \ - do_gettimeofday(&(_entry)->aen_tv); \ - (_entry)->bfad_num = (_drv)->inst_no; \ - (_entry)->seq_num = (_cnt); \ - (_entry)->aen_category = (_cat); \ - (_entry)->aen_type = (_evt); \ - if ((_drv)->bfad_flags & BFAD_FC4_PROBE_DONE) \ - queue_work((_drv)->im->drv_workq, \ - &(_drv)->im->aen_im_notify_work); \ -} while (0) +static inline void bfad_im_post_vendor_event(struct bfa_aen_entry_s *entry, + struct bfad_s *drv, int cnt, + enum bfa_aen_category cat, + enum bfa_ioc_aen_event evt) +{ + struct timespec64 ts; + + ktime_get_real_ts64(&ts); + /* + * 'unsigned long aen_tv_sec' overflows in y2106 on 32-bit + * architectures, or in 2038 if user space interprets it + * as 'signed'. + */ + entry->aen_tv_sec = ts.tv_sec; + entry->aen_tv_usec = ts.tv_nsec / NSEC_PER_USEC; + entry->bfad_num = drv->inst_no; + entry->seq_num = cnt; + entry->aen_category = cat; + entry->aen_type = evt; + if (drv->bfad_flags & BFAD_FC4_PROBE_DONE) + queue_work(drv->im->drv_workq, &drv->im->aen_im_notify_work); +} struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *);