From patchwork Fri Nov 10 15:58:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118589 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp8099835qgn; Fri, 10 Nov 2017 07:59:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMYOYgkyeXxq+u+EJU7O4J/MPjzVZr6QueFtjY784v0PEbg5ETy2uardxWcVzlRKCyaIoWv6 X-Received: by 10.99.37.69 with SMTP id l66mr820730pgl.14.1510329577444; Fri, 10 Nov 2017 07:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510329577; cv=none; d=google.com; s=arc-20160816; b=qj+oBafdRsXS6II+CCfPoxIAPk+ccwwKDfVdRKNPJV8zaWWhjdNetaHf7deSG6vAuH VlpyvSKwy1IdjBJtKZYVePmHe3yiubcll55ZSIJGRLD9hk4kiManGv7wp6U2eDYY9cQA KWPJTJw0OrKcjq2Ekk9IAm8/DB4G591KtaJWfEFQWT47V9BQbJRDqbjaXoRkbqv/q4zC VBRxCefilUpxWluUnYIF1CLN1hCu/rJcmrBTOsOkQ14LHZCQ1Dk7vDDXFudgvfBPt646 5TogDqebV/CoxJcVWtcI2Z1JjkKO9tRu2a7K8j9XRn2gqBMeEqg5gnWlRTQiRqsMIuZU go/A== 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=EBl8b30pM5jvIDc/1ORtsCPg6ZH22Jpteb8sha2aWbY=; b=cxAxZh7o41mHTp1c6hUUfsE+sZndy3scMjwNelqMaOy6GvUuUB2ALKf9yVFXfhN4Dj pQ13/WK1z2A62akczGKm2dEUTvSP54IaRXc6z0m55JDobOf82dKr6NohrrRyb2wCu/Ty 7W0Wc/D8PqgKB0iBzy/4HNYux2VehMfryoprFt2wXK1osr5nQNPvo1WqCd2WRQVl33/c zyW2cmG5Bax0ceij2fWIGmCeItimCPs17LyW4Ehsf3iO6n1+Cg/cYc1fImNHYJBtyGbD NyhuADcYQaRNKyOfqxa3NpfTy0pjy8PQ22msuntiXrTm3p3JVtePM1XTEm6BalWRzogY kejA== 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 p3si9109878pld.115.2017.11.10.07.59.37; Fri, 10 Nov 2017 07:59: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 S1753356AbdKJP7g (ORCPT + 24 others); Fri, 10 Nov 2017 10:59:36 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:56087 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753141AbdKJP7e (ORCPT ); Fri, 10 Nov 2017 10:59:34 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0ME41n-1eRnsX2rhH-00HKrn; Fri, 10 Nov 2017 16:58:54 +0100 From: Arnd Bergmann To: Adam Radford , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Sumit Saxena , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] scsi: 3ware: use 64-bit times for FW time sync Date: Fri, 10 Nov 2017 16:58:26 +0100 Message-Id: <20171110155840.1941250-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171110155840.1941250-1-arnd@arndb.de> References: <20171110155840.1941250-1-arnd@arndb.de> X-Provags-ID: V03:K0:3HkdWgCDUqF6zuswdgQ9OrdODd01++61VcKPiqCi0JLV4DvmcGW wAqpSeefvDdf/gTa1CWPSJAkRQP3J6tbgI25lE5AhQiCi9q4npuGWUbnxUUboPDk9dPheWh AZeAHDsb1RiqhOviKTCR7aDh27n8FEvxQnZ8kr+0K9FLG2xeMs3fS8r0Xl5m07ffRX7zxaB DmZGAu/WfmsSAbMdZQl3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:1xHMfYwRDoQ=:LvLZrNiambG5GV0/oVkQ1J FZB7ZM9iojX6hD2pcTnWew57ohzclg3aV8C3GJrT6QdoE4ai6wt3aYHWUNr2cAJEyl4kWt2/N sOmvTHfoy4nc33iKFIY91GTMIn2aZxba4Lhq6A5OGk3z1418oOjLhxU+Q5YJogBXAfC9Fu0ED CS50HP2EeSHVcfnXzZDG+Gv8RHNLdE91D4SYFad2687KdH/C6KOBhlEilxsanOiPAzQZsVwFt RU2/rRvUUAdOnK4e3sq+UIV8Mct/Chd32zU/0c9LMR6fK/6FV8wn1uHUszrgsO6M84fdWvNNr 07OrM6FdVX0wgeIcdaZhO4ztVtFUXSHnJ7r7C8qot1hYbNlEytppmdrImZYnO4IQgraJ8LlDU /HSFiK39Ex5mAU0mDf46Go/8yf0Wl2qFfNSkd6VtqnOHLBhnl0N51HJjfLDPYup9kd7+24sej 9GFToSPpF/I1X3HYilifuVjRl8g5if0YMFJEjYGt7NfOYywg4DFAeAtC98CFj4jp/znGp2dev +F5Kwmk2u8PW3yMx3rhiIgtvx0m0XvpetvQlBPQoKDWnrkZdcWk3Uuulyv965BKP5eaYcGHBJ NNDWOAhYrpYjslazZPT7hUYPRF1w7u07kpBV322Lu5fUA1mGPOi1reCaZxyxqXKWFFmQ7TQMy RdnXCUXjNhd/YQ2a81E8nOroR3v/iCFUgKsaDcC3XGQKUZcGi3m4ucy2xHWrGwPS+BXsiRmPj 8SxngHrM/PzVsw9cxTgiMF1QXBXoOiaogdInRQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The calculation of the number of seconds since Sunday 00:00:00 overflows in 2106, meaning that we instead will return the seconds since Wednesday 06:28:16 afterwards. Using 64-bit time stamps avoids this slight inconsistency, and the deprecated do_gettimeofday(), replacing it with the simpler ktime_get_real_seconds(). Signed-off-by: Arnd Bergmann --- drivers/scsi/3w-9xxx.c | 8 +++----- drivers/scsi/3w-sas.c | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) -- 2.9.0 Acked-by: Adam Radford diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index cb9af3f7b653..b1c9bd9c1bfd 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -472,11 +472,10 @@ static char *twa_aen_severity_lookup(unsigned char severity_code) static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) { u32 schedulertime; - struct timeval utc; TW_Command_Full *full_command_packet; TW_Command *command_packet; TW_Param_Apache *param; - u32 local_time; + time64_t local_time; /* Fill out the command packet */ full_command_packet = tw_dev->command_packet_virt[request_id]; @@ -498,9 +497,8 @@ static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) /* Convert system time in UTC to local time seconds since last Sunday 12:00AM */ - do_gettimeofday(&utc); - local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60)); - schedulertime = local_time - (3 * 86400); + local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60)); + div_u64_rem(local_time - (3 * 86400), 604800, &schedulertime); schedulertime = cpu_to_le32(schedulertime % 604800); memcpy(param->data, &schedulertime, sizeof(u32)); diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index c283fdb3cb24..cf9f2a09b47d 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -407,11 +407,10 @@ static int twl_aen_read_queue(TW_Device_Extension *tw_dev, int request_id) static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) { u32 schedulertime; - struct timeval utc; TW_Command_Full *full_command_packet; TW_Command *command_packet; TW_Param_Apache *param; - u32 local_time; + time64_t local_time; /* Fill out the command packet */ full_command_packet = tw_dev->command_packet_virt[request_id]; @@ -433,10 +432,9 @@ static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id) /* Convert system time in UTC to local time seconds since last Sunday 12:00AM */ - do_gettimeofday(&utc); - local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60)); - schedulertime = local_time - (3 * 86400); - schedulertime = cpu_to_le32(schedulertime % 604800); + local_time = (ktime_get_real_seconds() - (sys_tz.tz_minuteswest * 60)); + div_u64_rem(local_time - (3 * 86400), 604800, &schedulertime); + schedulertime = cpu_to_le32(schedulertime); memcpy(param->data, &schedulertime, sizeof(u32));