From patchwork Fri Jun 12 03:10:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 483352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qg0-x23c.google.com (mail-qg0-x23c.google.com [IPv6:2607:f8b0:400d:c04::23c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 98BD9140348 for ; Fri, 12 Jun 2015 13:13:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b=AUwv707s; dkim-atps=neutral Received: by qgdq107 with SMTP id q107sf6403010qgd.0 for ; Thu, 11 Jun 2015 20:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:from:to:cc:subject:date:message-id:x-original-sender :x-original-authentication-results:reply-to:content-type:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:sender:list-subscribe:list-unsubscribe; bh=T++nRkJCMKid0TDQdBNsrMh4ZKsi2lrmQfc2WROZpx0=; b=AUwv707sMlXxZtA10lYWRh6no4Bt29KhrkJmJvsvKALnOL2lIP3xFQ6AKqYTOtFVLX u7vSTwITtsE7v811WNilPCeGgZO9a/z51zXTAsxaQVTL4PQ6YJ0fM/DgUy4SYcxGB757 wj+wpF7Lk2BfuJJxovQmlfbasqUt7rzEDyYjUJ4Pjgs7s3pO2+Lco03LpC9IbTiu42lk aXQ7THW6SeL7Bfb2erF0mTjZ2D3Q6UtCqbRNmLCsDfEUQvbVMDnbr31vrMeATlvfiCh/ 4JdcBfpyEoRE9TkwXsQ/46YGnOpA1uL3jrM75AKSNjv6awCBKleMcGcyF3HqcVloxPtF TDLw== X-Received: by 10.50.109.137 with SMTP id hs9mr28243igb.1.1434078784815; Thu, 11 Jun 2015 20:13:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.114.73 with SMTP id je9ls92438igb.38.gmail; Thu, 11 Jun 2015 20:13:04 -0700 (PDT) X-Received: by 10.42.139.138 with SMTP id g10mr17630674icu.21.1434078784549; Thu, 11 Jun 2015 20:13:04 -0700 (PDT) Received: from m50-111.126.com (m50-111.126.com. [123.125.50.111]) by gmr-mx.google.com with ESMTP id ax9si53632igc.1.2015.06.11.20.13.03 for ; Thu, 11 Jun 2015 20:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of xlpang@126.com designates 123.125.50.111 as permitted sender) client-ip=123.125.50.111; Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowAAnbaa5TXpVUaYwAQ--.1090S2; Fri, 12 Jun 2015 11:11:07 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , Alexandre Belloni , John Stultz , Arnd Bergmann , "David S. Miller" , sparclinux@vger.kernel.org, Xunlei Pang , Paul Bolle Subject: [rtc-linux] [PATCH v3 1/3] NTP: rtc: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization Date: Fri, 12 Jun 2015 11:10:16 +0800 Message-Id: <1434078618-16373-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jtKowAAnbaa5TXpVUaYwAQ--.1090S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4DCr1xXw4fur17Xr17trb_yoW5Cryxpr WfA34IgrsFgF45XrsrC3ykuFy5Kas7J3yUGF13G3WF9FyUArykCr1ayrW7XrWUJFs3t39a qFy0gFnxuw1UCrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jzmhrUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi6AsXv1UJQdk27wAAsW X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of xlpang@126.com designates 123.125.50.111 as permitted sender) smtp.mail=xlpang@126.com; dkim=pass header.i=@126.com; dmarc=pass (p=NONE dis=NONE) header.from=126.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: rtc-linux@googlegroups.com X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: Xunlei Pang Currently, CONFIG_RTC_SYSTOHC uses CONFIG_RTC_HCTOSYS_DEVICE which is originally used by CONFIG_RTC_HCTOSYS, but this rtc device has some limiations, for example, it must be battery-backed, be able to work with irq off and through system suspension, etc. So add CONFIG_RTC_SYSTOHC_DEVICE used exclusively for CONFIG_RTC_SYSTOHC, it is more lenient compared to CONFIG_RTC_HCTOSYS_DEVICE, and could be assigned any available RTC in the system. Default value is CONFIG_RTC_HCTOSYS_DEVICE which is "rtc0" by default. After this patch, NTP will sync up "rtc0" by default. Cc: Paul Bolle Signed-off-by: Xunlei Pang --- drivers/rtc/Kconfig | 28 +++++++++++++++++++--------- drivers/rtc/systohc.c | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 0fe4ad8..1dcfab4 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -25,17 +25,9 @@ config RTC_HCTOSYS the value read from a specified RTC device. This is useful to avoid unnecessary fsck runs at boot time, and to network better. -config RTC_SYSTOHC - bool "Set the RTC time based on NTP synchronization" - default y - help - If you say yes here, the system time (wall clock) will be stored - in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 - minutes if userspace reports synchronized NTP status. - config RTC_HCTOSYS_DEVICE string "RTC used to set the system time" - depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y + depends on RTC_HCTOSYS default "rtc0" help The RTC device that will be used to (re)initialize the system @@ -56,6 +48,24 @@ config RTC_HCTOSYS_DEVICE sleep states. Do not specify an RTC here unless it stays powered during all this system's supported sleep states. +config RTC_SYSTOHC + bool "Set the RTC time based on NTP synchronization" + default y + help + If you say yes here, the system time (wall clock) will be stored + in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 + minutes if userspace reports synchronized NTP status. + +config RTC_SYSTOHC_DEVICE + string "RTC used to synchronize NTP adjustment" + depends on RTC_SYSTOHC + default RTC_HCTOSYS_DEVICE + help + The RTC device used for NTP synchronization. The main difference + between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this + one can sleep when setting time, because it runs in the workqueue + context. + config RTC_DEBUG bool "RTC debug support" help diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index 7728d5e..b4a68ff 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -31,7 +31,7 @@ int rtc_set_ntp_time(struct timespec64 now) else rtc_time64_to_tm(now.tv_sec + 1, &tm); - rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); + rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); if (rtc) { /* rtc_hctosys exclusively uses UTC, so we call set_time here, * not set_mmss. */