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: 10053401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B95F260365 for ; Fri, 10 Nov 2017 15:59:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC45A2B2B0 for ; Fri, 10 Nov 2017 15:59:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F8EE2B2B3; Fri, 10 Nov 2017 15:59:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 523DB287F3 for ; Fri, 10 Nov 2017 15:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753309AbdKJP7f (ORCPT ); Fri, 10 Nov 2017 10:59:35 -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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Adam Radford --- drivers/scsi/3w-9xxx.c | 8 +++----- drivers/scsi/3w-sas.c | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) 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));