From patchwork Tue May 12 14:11:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 48385 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3E40A2121F for ; Tue, 12 May 2015 14:12:54 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf2216676lbb.0 for ; Tue, 12 May 2015 07:12:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=1FKGXFS9xXNcqFzddwS2gFpJFEpL+Y7EMSAoS/vW/vM=; b=ODvQUJsrKM5eP8QN4xZ9m0ArfoYxmF0DXsoNS6Ct0yQp7g6WTfWww2wkLo32OgMDgJ LDj2ctB1/u42fDwbAO/El+ERubwkhfPhmcC4Y/ctkAH68YN3jOC8tiYdJSM5SsnoStZG 4EemwDVfrLOAleNV7yfDsh9igOU5nL+ku2ddLGwuRR9QYmkETMMNjkCfg2LppQMqxnhn L5jfM6pCdg1Cuoi64jvoXMDralcKRtVDnkKE9fgUVxJRb4rTg1AOvu6En+R6aLfzAdB4 nxTBrOg0fX6VvLyu7PlHUPO//adJy76KuiF6W4FOIytXrTPZUJ36d2UwHFe7L4qIX0Wq HmTg== X-Gm-Message-State: ALoCoQlYTaZp4OF/YmRmkkzhqtOsQJlsKRYpr6jZWXAaCqvTtSCcl4bONnBKmQrFXOulLnOaglT4 X-Received: by 10.180.97.9 with SMTP id dw9mr1948714wib.2.1431439973131; Tue, 12 May 2015 07:12:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.7 with SMTP id js7ls37202lab.34.gmail; Tue, 12 May 2015 07:12:52 -0700 (PDT) X-Received: by 10.152.6.1 with SMTP id w1mr11967065law.91.1431439972942; Tue, 12 May 2015 07:12:52 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id wm10si10433600lbb.149.2015.05.12.07.12.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 07:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by layy10 with SMTP id y10so6951126lay.0 for ; Tue, 12 May 2015 07:12:52 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr12207531laa.36.1431439972820; Tue, 12 May 2015 07:12:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2117262lbb; Tue, 12 May 2015 07:12:51 -0700 (PDT) X-Received: by 10.66.255.10 with SMTP id am10mr5505104pad.60.1431439970981; Tue, 12 May 2015 07:12:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fe6si22750859pdb.84.2015.05.12.07.12.30; Tue, 12 May 2015 07:12:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933114AbbELOMB (ORCPT + 28 others); Tue, 12 May 2015 10:12:01 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:35820 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932944AbbELOL6 (ORCPT ); Tue, 12 May 2015 10:11:58 -0400 Received: by pdbqd1 with SMTP id qd1so13892182pdb.2 for ; Tue, 12 May 2015 07:11:58 -0700 (PDT) X-Received: by 10.70.138.38 with SMTP id qn6mr28208077pdb.119.1431439918470; Tue, 12 May 2015 07:11:58 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id ca2sm16426448pdb.25.2015.05.12.07.11.56 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 07:11:58 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v3 12/23] posix-timers:Convert to the 64bit methods for the clock_gettime syscall function Date: Tue, 12 May 2015 22:11:51 +0800 Message-Id: <1431439911-4583-1-git-send-email-baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch introduces the clock_get64 method with timespec64 type for k_clock structure, that makes it ready for the 2038 year. Convert to the 64bit method with timespec64 type for the clock_gettime syscall function, and change the clock_gettime syscall implementation according to the CONFIG_64BIT macro. Also add a default 64bit method for the clock_get64 pointer of k_clock structure, and it will be removed after all the drivers are converted to 64bit methods. Signed-off-by: Baolin Wang --- include/linux/posix-timers.h | 1 + kernel/time/posix-timers.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 2b19ec8..be2123d 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -103,6 +103,7 @@ struct k_clock { int (*clock_set64) (const clockid_t which_clock, const struct timespec64 *tp); int (*clock_get) (const clockid_t which_clock, struct timespec * tp); + int (*clock_get64) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_adj) (const clockid_t which_clock, struct timex *tx); int (*timer_create) (struct k_itimer *timer); int (*nsleep) (const clockid_t which_clock, int flags, diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index ca85793..ddd681c 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -553,6 +553,20 @@ static int default_clock_set64(const clockid_t which_clock, return ret; } +static int default_clock_get64(const clockid_t which_clock, + struct timespec64 *tp64) +{ + struct k_clock *kc = clockid_to_kclock(which_clock); + struct timespec tp; + int ret; + + ret = kc->clock_get(which_clock, &tp); + if (!ret) + *tp64 = timespec_to_timespec64(tp); + + return ret; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -562,8 +576,8 @@ void posix_timers_register_clock(const clockid_t clock_id, return; } - if (!new_clock->clock_get) { - printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n", + if (!new_clock->clock_get && !new_clock->clock_get64) { + printk(KERN_WARNING "POSIX clock id %d lacks clock_get() and clock_get64()\n", clock_id); return; } @@ -579,6 +593,8 @@ void posix_timers_register_clock(const clockid_t clock_id, new_clock->timer_set64 = default_timer_set64; if (new_clock->clock_set && !new_clock->clock_set64) new_clock->clock_set64 = default_clock_set64; + if (new_clock->clock_get && !new_clock->clock_get64) + new_clock->clock_get64 = default_clock_get64; posix_clocks[clock_id] = *new_clock; } @@ -1123,23 +1139,32 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, #endif } -static int __clock_gettime(clockid_t which_clock, struct timespec *ts) +static int __clock_gettime(clockid_t which_clock, struct timespec64 *ts) { struct k_clock *kc = clockid_to_kclock(which_clock); if (!kc) return -EINVAL; - return kc->clock_get(which_clock, ts); + return kc->clock_get64(which_clock, ts); } SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, struct timespec __user *,tp) { - struct timespec kernel_tp; int error; +#ifdef CONFIG_64BIT + struct timespec64 kernel_tp; error = __clock_gettime(which_clock, &kernel_tp); +#else + struct timespec64 kernel_tp64; + struct timespec kernel_tp; + + error = __clock_gettime(which_clock, &kernel_tp64); + if (!error) + kernel_tp = timespec64_to_timespec(kernel_tp64); +#endif if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp))) error = -EFAULT;