Re: Re: [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events

From: liudalin@xxxxxxxxxxxxxx
Date: Thu May 08 2025 - 02:44:18 EST


Hi Binbin:
The described issue does not happened with or without the patch by test, as the interrupt is managed by acpi.

The device info and test result are as follows.

1. Device info
[系统未激活][root@mail test]# dmidecode -q
BIOS Information
Vendor: ZD-TECH
Version: V09
Release Date: 06/15/2022
ROM Size: 8 MB
Characteristics:
PCI is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
BIOS ROM is socketed
Serial services are supported (int 14h)
USB legacy is supported
Function key-initiated network boot is supported
UEFI is supported
BIOS Revision: 4.0
Firmware Revision: 0.4

System Information
Manufacturer: GEIT
Product Name: UT6000-LB5
Version: 1.0
Serial Number: TBD by OEM
UUID: 00112233-4455-6677-8899-aabbccddeeff
Wake-up Type: Power Switch
SKU Number: Loongson_SKU
Family: Type1Family

Base Board Information
Manufacturer: GEIT
Product Name: GG-3A5000-02
Version: 1.0
Serial Number: Chassis Board Serial#To Be Filled By O.E.M
Asset Tag: Type2 - Board Asset Tag
Features:
Board is a hosting board
Board is replaceable
Location In Chassis: Type2 - Board Chassis Location
Type: Motherboard
...

2. The system exhibits a timeout error when waiting for alarm signal response without the patch.
[系统未激活][root@mail test]# cat /proc/interrupts |grep acpi
21: 3 0 0 0 PCH PIC 1 acpi
[系统未激活][root@mail test]#
[系统未激活][root@mail test]# ./rtc01
RTC READ TEST:
RTC READ TEST Passed
Current RTC date/time is 8-5-2025, 05:50:05.
RTC ALARM TEST :Alarm time set to 05:50:10.
Waiting 5 seconds for the alarm...
Timed out waiting for the alarm
RTC UPDATE INTERRUPTS TEST :
RTC_UIE_ON not supported
RTC Tests Done!
[系统未激活][root@mail test]#
[系统未激活][root@mail test]# cat /proc/interrupts |grep acpi
21: 4 0 0 0 PCH PIC 1 acpi
[系统未激活][root@mail test]#

3. There is no error with the patch applied and the interrupts are triggered ok
[系统未激活][root@mail test]# cat /proc/interrupts |grep acpi
21: 0 0 0 0 PCH PIC 1 acpi
[系统未激活][root@mail test]#
[系统未激活][root@mail test]# ./rtc01
RTC READ TEST:
RTC READ TEST Passed
Current RTC date/time is 8-5-2025, 06:09:03.
RTC ALARM TEST :Alarm time set to 06:09:08.
Waiting 5 seconds for the alarm...
Alarm rang.
RTC ALARM TEST Passed
RTC UPDATE INTERRUPTS TEST :
RTC_UIE_ON not supported
RTC Tests Done!
[系统未激活][root@mail test]#
[系统未激活][root@mail test]# cat /proc/interrupts |grep acpi
21: 1 0 0 0 PCH PIC 1 acpi
[系统未激活][root@mail test]#





From: Binbin Zhou



Date: 2025-05-08 11:12



To: Liu Dalin; alexandre.belloni; wangming01



CC: chenhuacai; gaojuxin; git; jiaxun.yang; keguang.zhang; lixuefeng; linux-rtc; linux-kernel; zhoubb.aaron



Subject: Re: [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events



Hi Dalin:



 



Thanks for your patch.



 



On 2025/4/29 14:27, Liu Dalin wrote:



> When an application sets and enables an alarm on Loongson RTC devices,



> the alarm notification fails to propagate to userspace because the



> ACPI event handler omits calling rtc_update_irq().



>



> As a result, processes waiting via select() or poll() on RTC device



> files fail to receive alarm notifications.



>



> Fixes: 1b733a9ebc3d ("rtc: Add rtc driver for the Loongson family chips")



> Signed-off-by: Liu Dalin <liudalin@xxxxxxxxxxxxxxx>



> ---



>   drivers/rtc/rtc-loongson.c | 2 ++



>   1 file changed, 2 insertions(+)



>



> diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c



> index 97e5625c064c..0c573f198f63 100644



> --- a/drivers/rtc/rtc-loongson.c



> +++ b/drivers/rtc/rtc-loongson.c



> @@ -129,6 +129,8 @@ static u32 loongson_rtc_handler(void *id)



>   {



>   struct loongson_rtc_priv *priv = (struct loongson_rtc_priv *)id;



>  



> + rtc_update_irq(priv->rtcdev, 1, RTC_AF | RTC_IRQF);



> +



While testing the patch, I noticed that interrupts are triggered



multiple times (/proc/interrupt), not sure if you have the same issue.



 



I think we need a similar operation to loongson_rtc_isr() to clear the



interrupt:



regmap_write(priv->regmap, TOY_MATCH0_REG, 0);



>   spin_lock(&priv->lock);



>   /* Disable RTC alarm wakeup and interrupt */



>   writel(readl(priv->pm_base + PM1_EN_REG) & ~RTC_EN,



Thanks.



Binbin