Linux-RTC Archive mirror
 help / color / mirror / Atom feed
From: jianbin zhang <quic_jianbinz@quicinc.com>
To: Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: <linux-arm-msm@vger.kernel.org>, <linux-rtc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	jianbin zhang <quic_jianbinz@quicinc.com>
Subject: [PATCH V4 1/2] rtc-pm8xxx: clear the triggered alarm interrupt during driver probe
Date: Mon, 1 Apr 2024 09:56:29 +0800	[thread overview]
Message-ID: <20240401-fix-rtc-alarm-which-fired-before-driver-probe-not-be-cleard-v1-1-aab2cd6ddab8@quicinc.com> (raw)
In-Reply-To: <20240401-fix-rtc-alarm-which-fired-before-driver-probe-not-be-cleard-v1-0-aab2cd6ddab8@quicinc.com>

If the alarm is triggered before the driver gets probed, the alarm interrupt
will be missed and it won't be detected, and the stale alarm settings will
be still retained because of not being cleared.

Issue reproduce step:
(1) set the alarm and poweroff the device
(2) alarm happens and the device boots
(3) poweroff the device again
(4) alarm irq not be cleard, device boots again

the fixing here is clear the interrupt during the step(3) unconditionally.

Signed-off-by: jianbin zhang <quic_jianbinz@quicinc.com>
---
Changes in v4:
- add the cover letter
- modify the patch to conform to the specification

Changes in v3:
- clear the interrupt in driver probe unconditionally
- link: https://lore.kernel.org/linux-rtc/20240319191037.GA3796206@hu-bjorande-lv.qualcomm.com/T/#t

Changes in v2:
- Adapt the V1 patch according to the newest rtc-pm8xxx
- link: https://lore.kernel.org/linux-rtc/20240124024023df15ef6e@mail.local/

Changes in v1:
- fixing is as below logic, During driver probe: read ALARM_EN, read ALARM_DATA, read RTC_RDATA,
  if (ALARM_DATA < RTC_DATA), Trigger the alarm event and clear the alarm settins
- link: https://lore.kernel.org/linux-rtc/20220321090514.4523-1-quic_jianbinz@quicinc.com/

Changes in original:
- link to original: https://lore.kernel.org/linux-rtc/YTusgJlMUdXOKQaL@piout.net/
---
 drivers/rtc/rtc-pm8xxx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index f6b779c12ca7..e4e2307445cf 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -527,6 +527,11 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
 	if (rc)
 		return rc;
 
+	rc = regmap_update_bits(rtc_dd->regmap, rtc_dd->regs->alarm_ctrl2,
+					  PM8xxx_RTC_ALARM_CLEAR, 1);
+	if (rc)
+		return rc;
+
 	return 0;
 }
 

-- 
2.43.2


  reply	other threads:[~2024-04-01  1:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01  1:56 [PATCH v4 0/2] rtc-pm8xxx: fix rtc alarm which fired before driver probe not be cleard jianbin zhang
2024-04-01  1:56 ` jianbin zhang [this message]
2024-04-05  2:45   ` [PATCH V4 1/2] rtc-pm8xxx: clear the triggered alarm interrupt during driver probe Bjorn Andersson
2024-04-08  9:01     ` jianbin zhang
2024-04-01  1:56 ` [PATCH V4 2/2] rtc-pm8xxx: Correct the value written into the PM8xxx_RTC_ALARM_CLEAR jianbin zhang
2024-04-05  2:47   ` Bjorn Andersson
2024-04-08  9:19     ` jianbin zhang

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=20240401-fix-rtc-alarm-which-fired-before-driver-probe-not-be-cleard-v1-1-aab2cd6ddab8@quicinc.com \
    --to=quic_jianbinz@quicinc.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andersson@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).