All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Probst" <markus.probst@posteo.de>
Cc: robh@kernel.org, conor+dt@kernel.org, linux-rtc@vger.kernel.org,
	devicetree@vger.kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v8 3/6] rtc: s35390a: Fix alarm not disabling
Date: Mon, 31 Aug 2026 20:14:32 +0000	[thread overview]
Message-ID: <20260831201432.6506C1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260831-rtc_s35390a_int1-v8-3-dac1dc86ce1f@posteo.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Adding `alarm_irq_enable` exposes a preexisting flaw where `set_alarm(enabled=0)` drops the alarm time, causing subsequent `RTC_AIE_ON` ioctls to enable the alarm with an incorrect/stale time.
--

commit 9902d89ba2e478f9c2ca532d42600946943b66e7
Author: Markus Probst <markus.probst@posteo.de>

rtc: s35390a: Fix alarm not disabling

This commit implements the alarm_irq_enable callback to fix an issue where
the alarm was not disabling.

> diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> index 4cfe7034c5165..575bb256eb258 100644
> --- a/drivers/rtc/rtc-s35390a.c
> +++ b/drivers/rtc/rtc-s35390a.c
[ ... ]
> @@ -270,6 +270,24 @@ static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  	return 0;
>  }
>  
> +static int s35390a_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
> +{
> +	struct s35390a *s35390a = dev_get_drvdata(dev);
> +	u8 sts;
> +	int err;
> +
> +	if (enabled)
> +		sts = S35390A_INT2_MODE_ALARM;
> +	else
> +		sts = S35390A_INT2_MODE_NOINTR;
> +
> +	err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));

[Severity: High]
This is a pre-existing issue, but does enabling the alarm here (e.g., via
the RTC_AIE_ON ioctl) expose a flaw where s35390a_rtc_set_alarm() drops the
alarm time?

When a user issues the RTC_ALM_SET ioctl, it inherently calls
s35390a_rtc_set_alarm() with enabled = 0. The driver sets STATUS2 to NOINTR
mode:

drivers/rtc/rtc-s35390a.c:s35390a_rtc_set_alarm() {
    ...
    if (alm->enabled)
        sts = S35390A_INT2_MODE_ALARM;
    else
        sts = S35390A_INT2_MODE_NOINTR;

    /* set interrupt mode*/
    err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
    ...
}

The driver then attempts to write the time to INT2_REG1:

drivers/rtc/rtc-s35390a.c:s35390a_rtc_set_alarm() {
    ...
    err = s35390a_set_reg(s35390a, S35390A_CMD_INT2_REG1, buf,
                          sizeof(buf));
    ...
}

However, as documented by the driver's own comment in s35390a_rtc_read_alarm(),
the alarm time register is completely inaccessible when the alarm is not
enabled. Thus, the time update is silently dropped by the hardware.

When the user subsequently calls RTC_AIE_ON, this newly added
alarm_irq_enable callback enables the alarm interrupt using the incorrect or
stale time previously residing in the registers.

Note: This issue is not resolved by follow-up patches in this series. In the
final patch (commit "rtc: s35390a: Add synology quirk"),
s35390a_rtc_set_alarm() still leaves the interrupt mode disabled when
alm->enabled == 0 before performing the time register writes, preserving the
issue.

> +	if (err < 0)
> +		return err;
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-rtc_s35390a_int1-v8-0-dac1dc86ce1f@posteo.de?part=3

  reply	other threads:[~2026-08-31 20:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 17:42 [PATCH v8 0/6] rtc: s35390a: Allow use of output pin for interrupt signal 1 for wakealarm Markus Probst
2026-08-31 17:42 ` [PATCH v8 1/6] dt-bindings: rtc: Add pinctrl for S35390A Markus Probst
2026-08-31 19:52   ` sashiko-bot
2026-08-31 19:54     ` Markus Probst
2026-09-01 10:05   ` Krzysztof Kozlowski
2026-09-01 13:28     ` Markus Probst
2026-09-03  9:35       ` Krzysztof Kozlowski
2026-08-31 17:42 ` [PATCH v8 2/6] rtc: s35390a: Add missing newline to dev_err Markus Probst
2026-08-31 19:57   ` sashiko-bot
2026-08-31 17:42 ` [PATCH v8 3/6] rtc: s35390a: Fix alarm not disabling Markus Probst
2026-08-31 20:14   ` sashiko-bot [this message]
2026-08-31 17:42 ` [PATCH v8 4/6] rtc: s35390a: Read 24-hour mode on access Markus Probst
2026-08-31 20:24   ` sashiko-bot
2026-08-31 17:42 ` [PATCH v8 5/6] rtc: s35390a: Add pinctrl Markus Probst
2026-08-31 21:00   ` sashiko-bot
2026-08-31 17:42 ` [PATCH v8 6/6] rtc: s35390a: Add synology quirk Markus Probst
2026-08-31 21:06   ` sashiko-bot

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=20260831201432.6506C1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=markus.probst@posteo.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.