From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbeBSGlD (ORCPT ); Mon, 19 Feb 2018 01:41:03 -0500 Received: from mail-lf0-f53.google.com ([209.85.215.53]:36607 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbeBSGlC (ORCPT ); Mon, 19 Feb 2018 01:41:02 -0500 X-Google-Smtp-Source: AH8x224Q8hoTbKV14wOYCXiIBZ9k1Hsg5t1TvbcyQpbH/BEo8BoVIsDkZiojqy5Ng7DNUIFveqDUzA== From: Igor Plyatov Subject: 500 ms delay in time saved into RTC To: linux-kernel@vger.kernel.org, Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com Message-ID: <30ae185f-28c9-54f1-2884-4ee7801b130e@gmail.com> Date: Mon, 19 Feb 2018 09:40:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! I have board based on AT91SAM9G20 (ARM926EJ-S CPU), Linux-4.9.36 kernel and RTC chip DS1340 (rtc-ds1307.c driver). RTC chip connected by means of I2C-bus, without HW IRQ line connected. Kernel configured to not use embedded functions for time getting at startup and saving at shutdown: CONFIG_RTC_CLASS=y # CONFIG_RTC_HCTOSYS is not set # CONFIG_RTC_SYSTOHC is not set CONFIG_RTC_INTF_DEV_UIE_EMUL=y CONFIG_RTC_DRV_DS1307=y CONFIG_RTC_DRV_DS1307_CENTURY=y The hwclock utility is from util-linux-2.29.1. The OS does not have external time synchronization sources like NTP, PTP or else. Generally I need to achieve error within +-20 ms when RTC's time copied into OS or back from OS into RTC. I have made measurements during startup and shutdown of OS and have found 500 ms delay introduced into RTC's time, when "hwclock --utc --systohc" executed. Logical analyzer show to me I2C-bus transactions and PPS signal generated by Linux. And I see 500 ms delay is between of rising edge of PPS signal (start of OS second) and moment when time saved into RTC. Please explain, why this happens? Is this due to absence of IRQ line for RTC or due to a bug in the hwclock, or kernel bug or I have missed something else? Best wishes. -- Igor Plyatov