public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "Mario Limonciello" <superm1@kernel.org>,
	"Mateusz Jończyk" <mat.jonczyk@o2.pl>,
	"John Stultz" <jstultz@google.com>
Cc: Stephen Boyd <sboyd@kernel.org>,
	"open list:TIMEKEEPING, CLOCKSOURCE CORE, NTP,
	ALARMTIMER" <linux-kernel@vger.kernel.org>,
	Mario Limonciello <mario.limonciello@amd.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH RESEND] alarmtimer: Use aie_timer from RTC device instead of own timer
Date: Wed, 02 Oct 2024 16:45:18 +0200	[thread overview]
Message-ID: <87wmiqwold.ffs@tglx> (raw)
In-Reply-To: <e35d22f7-4796-43ae-bc73-7e41497094d6@kernel.org>

On Tue, Oct 01 2024 at 08:41, Mario Limonciello wrote:
> On 10/1/2024 03:30, Thomas Gleixner wrote:
>> On Mon, Sep 30 2024 at 13:29, Mario Limonciello wrote:
>>> It was reported that suspend-then-hibernate stopped working with modern
>>> systemd versions on an AMD Cezanne system. The reason for this breakage
>>> was because systemd switched to using alarmtimer instead of the wakealarm
>>> sysfs file.
>>>
>>> The wakealarm sysfs file programs the time to the `rtc->aie_timer` member
>>> of the RTC, whereas the alarmtimer suspend routine programs it to it's
>>> own device.
>>>
>>> On AMD Cezanne systems rtc_read_alarm() is used to program a secondary
>>> timer with the value of the timer. This behavior was introduced by
>>> commit 59348401ebed9 ("platform/x86: amd-pmc: Add special handling
>>> for timer based S0i3 wakeup").
>>>
>>> As rtc_read_alarm() uses the `rtc->aie_timer` to report the cached
>>> timer no alarm is provided as enabled.
>>>
>>> To fix this issue, drop the use of a dedicated timer for the alarmtimer
>>> and instead use `rtc->aie_timer` in the alarmtimer suspend/resume
>>> routines.
>> 
>> I'm not sure that this is correct. There is a reason why alarmtimer uses
>> a dedicated timer 
>
> Do you know what it is?  When I was looking at this problem I wasn't sure.

Because you cannot just blindly overwrite the aie_timer. It might have
been set by something else. Both end up in the timerqueue and the first
expiring timer is armed first.

>> and this worked correctly so far.
>> 
>> I'd rather look at commit 59348401ebed9, which plays games with the RTC.
>
> The workaround in commit 59348401ebed9 exists because of what appears to 
> be a platform bug that is unique to Cezanne systems.  Newer stuff 
> (Mendocino, Rembrandt, Phoenix, Strix etc) doesn't need or use it.

The problem is that this hack looks at the aie_timer and not at the
first expiring timer in the timerqueue which arms the RTC. That's
obviously wrong. There is no interface to get that information, but
that's a solvable problem.

Thanks,

        tglx





      reply	other threads:[~2024-10-02 14:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 18:29 [PATCH RESEND] alarmtimer: Use aie_timer from RTC device instead of own timer Mario Limonciello
2024-10-01  8:30 ` Thomas Gleixner
2024-10-01 13:41   ` Mario Limonciello
2024-10-02 14:45     ` Thomas Gleixner [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=87wmiqwold.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=mat.jonczyk@o2.pl \
    --cc=sboyd@kernel.org \
    --cc=superm1@kernel.org \
    /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