Linux RTC
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Mario Limonciello <mario.limonciello@amd.com>
Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	 Alexandre Belloni <alexandre.belloni@bootlin.com>,
	 Hans de Goede <hansg@kernel.org>,
	platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>,
	linux-rtc@vger.kernel.org,  Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 2/2] platform/x86: amd-pmc: Fix S0i3 wakeup with alarmtimer
Date: Thu, 25 Jun 2026 13:06:01 +0300 (EEST)	[thread overview]
Message-ID: <f023638f-d2fd-5d79-a4be-aefdfd7f645f@linux.intel.com> (raw)
In-Reply-To: <20260521043714.1022930-3-mario.limonciello@amd.com>

[-- Attachment #1: Type: text/plain, Size: 2080 bytes --]

On Wed, 20 May 2026, Mario Limonciello wrote:

> It was reported that suspend-then-hibernate stopped working with modern
> systemd versions on AMD Cezanne systems. The reason for this breakage
> was because systemd switched to using alarmtimer instead of the wakealarm
> sysfs file.
> 
> On AMD Cezanne systems, amd_pmc_verify_czn_rtc() programs a secondary
> timer with the alarm time. This was introduced by
> commit 59348401ebed ("platform/x86: amd-pmc: Add special handling for
> timer based S0i3 wakeup"). However, this function uses rtc_read_alarm(),
> which only reads the aie_timer, not the next expiring timer from the
> timerqueue.
> 
> When both alarmtimer and wakealarm are active, the first expiring timer
> might be the alarmtimer, but amd_pmc_verify_czn_rtc() would only see
> the aie_timer, potentially missing the earlier alarm.
> 
> Switch to rtc_read_next_alarm() to read whichever timer will fire next.
> Also handle -ENOENT (no alarm pending) explicitly as a non-error case.
> 
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3591
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/platform/x86/amd/pmc/pmc.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
> index 50f5784f2aa2e..8cd2db0ccaacd 100644
> --- a/drivers/platform/x86/amd/pmc/pmc.c
> +++ b/drivers/platform/x86/amd/pmc/pmc.c
> @@ -595,9 +595,12 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg)
>  	rtc_device = rtc_class_open("rtc0");
>  	if (!rtc_device)
>  		return 0;
> -	rc = rtc_read_alarm(rtc_device, &alarm);
> -	if (rc)
> -		return rc;
> +	rc = rtc_read_next_alarm(rtc_device, &alarm);
> +	if (rc) {
> +		if (rc == -ENOENT)
> +			dev_dbg(pdev->dev, "no alarm pending\n");
> +		return rc == -ENOENT ? 0 : rc;
> +	}
>  	if (!alarm.enabled) {
>  		dev_dbg(pdev->dev, "alarm not enabled\n");
>  		return 0;

Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

  reply	other threads:[~2026-06-25 10:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21  4:37 [PATCH v2 0/2] Fix S0i3 wakeup with alarmtimer Mario Limonciello
2026-05-21  4:37 ` [PATCH v2 1/2] rtc: Add rtc_read_next_alarm() to read next expiring timer Mario Limonciello
2026-06-24 21:15   ` (subset) " Alexandre Belloni
2026-06-24 23:30     ` Mario Limonciello
2026-06-25 10:08       ` Ilpo Järvinen
2026-05-21  4:37 ` [PATCH v2 2/2] platform/x86: amd-pmc: Fix S0i3 wakeup with alarmtimer Mario Limonciello
2026-06-25 10:06   ` Ilpo Järvinen [this message]
2026-06-25 12:43 ` (subset) [PATCH v2 0/2] " Alexandre Belloni

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=f023638f-d2fd-5d79-a4be-aefdfd7f645f@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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