mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Akashdeep Kaur <a-kaur@ti.com>
Cc: praneeth@ti.com, nm@ti.com, vigneshr@ti.com,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	sebin.francis@ti.com, s-tripathi1@ti.com, vishalm@ti.com,
	k-willis@ti.com
Subject: Re: [PATCH 0/2] rtc: Prevent hctosys from using invalid RTC time
Date: Wed, 21 Oct 2026 09:13:51 +0200	[thread overview]
Message-ID: <202610210713515313f800@mail.local> (raw)
In-Reply-To: <20261021042435.3895543-1-a-kaur@ti.com>

Hello,

On 21/10/2026 09:54:33+0530, Akashdeep Kaur wrote:
> The kernel's boot-time RTC synchronization blindly trusts the RTC 
> value when setting system time, but RTCs may have invalid time 
> depending on the boot path:
> 
> - On first cold boot: RTC may have lost power, time is invalid
> - After low-power mode (RTC-only) cold boot: RTC retained power, time 
>   is valid
> 
> On normal cold boot where bootloader or NTP has already established 
> correct time, boot-time sync (triggered when RTC driver loads as 
> module or probes at boot) can overwrite it with invalid RTC data, 
> causing time rollback to 1970. However, on boot from RTC-only power 
> mode, the RTC has valid time and boot-time sync should work to 
> restore system time from RTC.
> 
> This series adds a flag that drivers set dynamically per-boot to 
> indicate whether RTC has valid time. Drivers check at probe if RTC 
> retained power through this specific boot. Boot-time sync checks this 
> flag before setting system time. This enables correct behavior for 
> both boot paths while keeping PM suspend/resume compensation 
> unaffected.

The proper way to do this is to return -EINVAL in read_time until you
know the date is correct. There is no need for an extra flag for the core.

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

      parent reply	other threads:[~2026-10-21  7:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  4:24 Akashdeep Kaur
2026-10-21  4:24 ` [PATCH 1/2] rtc: Add flag for dynamic hctosys control Akashdeep Kaur
2026-10-21  4:24 ` [PATCH 2/2] rtc: ti-k3: Mark RTC time as invalid without battery backup Akashdeep Kaur
2026-10-21  7:13 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202610210713515313f800@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=a-kaur@ti.com \
    --cc=k-willis@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=praneeth@ti.com \
    --cc=s-tripathi1@ti.com \
    --cc=sebin.francis@ti.com \
    --cc=vigneshr@ti.com \
    --cc=vishalm@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®