* [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events
@ 2025-04-29 6:27 Liu Dalin
2025-05-08 3:12 ` Binbin Zhou
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Liu Dalin @ 2025-04-29 6:27 UTC (permalink / raw)
To: alexandre.belloni, zhoubinbin, wangming01
Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng,
linux-rtc, linux-kernel
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@kylinsec.com.cn>
---
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);
+
spin_lock(&priv->lock);
/* Disable RTC alarm wakeup and interrupt */
writel(readl(priv->pm_base + PM1_EN_REG) & ~RTC_EN,
--
2.33.0
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-04-29 6:27 [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events Liu Dalin @ 2025-05-08 3:12 ` Binbin Zhou 2025-05-08 6:43 ` liudalin [not found] ` <58BBF92742F0D0E1+2025050814202393211321@kylinos.com.cn> 2025-05-09 1:40 ` [PATCH V1] " Liu Dalin 2025-05-09 8:44 ` [PATCH V2] " Liu Dalin 2 siblings, 2 replies; 11+ messages in thread From: Binbin Zhou @ 2025-05-08 3:12 UTC (permalink / raw) To: Liu Dalin, alexandre.belloni, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel, zhoubb.aaron 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@kylinsec.com.cn> > --- > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Re: [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-05-08 3:12 ` Binbin Zhou @ 2025-05-08 6:43 ` liudalin [not found] ` <58BBF92742F0D0E1+2025050814202393211321@kylinos.com.cn> 1 sibling, 0 replies; 11+ messages in thread From: liudalin @ 2025-05-08 6:43 UTC (permalink / raw) To: zhoubinbin, 刘达林, alexandre.belloni, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel, zhoubb.aaron 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@kylinsec.com.cn> > --- > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <58BBF92742F0D0E1+2025050814202393211321@kylinos.com.cn>]
* Re: Re: [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events [not found] ` <58BBF92742F0D0E1+2025050814202393211321@kylinos.com.cn> @ 2025-05-08 6:48 ` Binbin Zhou 0 siblings, 0 replies; 11+ messages in thread From: Binbin Zhou @ 2025-05-08 6:48 UTC (permalink / raw) To: liudalin Cc: zhoubinbin, 刘达林, alexandre.belloni, wangming01, chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel Hi: On Thu, May 8, 2025 at 2:20 PM liudalin@kylinos.com.cn <liudalin@kylinos.com.cn> wrote: > > Hi Binbin: > The described issue does not happened with or without the patch by test, as the interrupt is managed by acpi. I see it. > > The device info and test result are as follows. > > 1. Device info > [系统未激活][root@mail test]# dmidecode > # dmidecode 3.5 > Getting SMBIOS data from sysfs. > SMBIOS 3.2.0 present. > Table at 0x90000000FD620000. > > Handle 0x0000, DMI type 0, 24 bytes > 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 > > Handle 0x0001, DMI type 1, 27 bytes > 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 > > Handle 0x0002, DMI type 2, 15 bytes > Base Board Information > Manufacturer: GEIT > Product Name: GG-3A5000-02 My machine is also Loongosn-3A5000 + 7A2000, I think this should not affect. > 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 > Chassis Handle: 0xFFFF > Type: Motherboard > Contained Object Handles: 0 > > 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]# > Please try continuous testing to see if you get different results. Here is my test code, it behaves fine on Loongson-2K1000, you can compare it with yours. https://gist.github.com/AaronDot/affafc0b861783aee128a76b34d45f55 Also, your test code can be provided to me for testing. > 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]# > > > ________________________________ > liudalin@kylinos.com.cn > > > 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@kylinsec.com.cn> > > --- > > 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 > > > -- Thanks. Binbin ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH V1] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-04-29 6:27 [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events Liu Dalin 2025-05-08 3:12 ` Binbin Zhou @ 2025-05-09 1:40 ` Liu Dalin 2025-05-09 7:12 ` Binbin Zhou 2025-05-09 8:44 ` [PATCH V2] " Liu Dalin 2 siblings, 1 reply; 11+ messages in thread From: Liu Dalin @ 2025-05-09 1:40 UTC (permalink / raw) To: alexandre.belloni, zhoubinbin, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel 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@kylinsec.com.cn> --- drivers/rtc/rtc-loongson.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c index 97e5625c064c..2ca7ffd5d7a9 100644 --- a/drivers/rtc/rtc-loongson.c +++ b/drivers/rtc/rtc-loongson.c @@ -129,6 +129,14 @@ 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); + + /* + * The TOY_MATCH0_REG should be cleared 0 here, + * otherwise the interrupt cannot be cleared. + */ + 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, -- 2.33.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V1] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-05-09 1:40 ` [PATCH V1] " Liu Dalin @ 2025-05-09 7:12 ` Binbin Zhou 2025-05-09 8:06 ` Liu Dalin 0 siblings, 1 reply; 11+ messages in thread From: Binbin Zhou @ 2025-05-09 7:12 UTC (permalink / raw) To: Liu Dalin, alexandre.belloni, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel Hi: On 2025/5/9 09:40, 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@kylinsec.com.cn> Technically I don't think this is a compliant patch, firstly this patch should be V2 and also you should add "Changlog" for describing the differences from the previous patch. Anyway, it's good to me. Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn> > --- > drivers/rtc/rtc-loongson.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c > index 97e5625c064c..2ca7ffd5d7a9 100644 > --- a/drivers/rtc/rtc-loongson.c > +++ b/drivers/rtc/rtc-loongson.c > @@ -129,6 +129,14 @@ 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); > + > + /* > + * The TOY_MATCH0_REG should be cleared 0 here, > + * otherwise the interrupt cannot be cleared. > + */ > + 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V1] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-05-09 7:12 ` Binbin Zhou @ 2025-05-09 8:06 ` Liu Dalin 2025-05-09 8:27 ` Binbin Zhou 0 siblings, 1 reply; 11+ messages in thread From: Liu Dalin @ 2025-05-09 8:06 UTC (permalink / raw) To: Binbin Zhou, alexandre.belloni, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel 在 2025/5/9 15:12, Binbin Zhou 写道: > Hi: > > On 2025/5/9 09:40, 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@kylinsec.com.cn> > Technically I don't think this is a compliant patch, firstly this patch > should be V2 and also you should add "Changlog" for describing the > differences from the previous patch. > Anyway, it's good to me. Ok! There is another problem, if regmap_write(priv->regmap, TOY_MATCH0_REG, 0) move to the end of loongson_rtc_handler as 09471d8f5b39("rtc: loongson: clear TOY_MATCH0_REG in loongson_rtc_isr()"), the interrupt also can be triggered multiple times. So the regmap_write(priv->regmap,TOY_MATCH0_REG, 0) is move behind of rtc_update_irq by me, then the interrupt was triggered OK. Is there any problem ? > > Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn> > >> --- >> drivers/rtc/rtc-loongson.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c >> index 97e5625c064c..2ca7ffd5d7a9 100644 >> --- a/drivers/rtc/rtc-loongson.c >> +++ b/drivers/rtc/rtc-loongson.c >> @@ -129,6 +129,14 @@ 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); >> + >> + /* >> + * The TOY_MATCH0_REG should be cleared 0 here, >> + * otherwise the interrupt cannot be cleared. >> + */ >> + 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 > > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V1] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-05-09 8:06 ` Liu Dalin @ 2025-05-09 8:27 ` Binbin Zhou 0 siblings, 0 replies; 11+ messages in thread From: Binbin Zhou @ 2025-05-09 8:27 UTC (permalink / raw) To: Liu Dalin, alexandre.belloni, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel On 2025/5/9 16:06, Liu Dalin wrote: > > > 在 2025/5/9 15:12, Binbin Zhou 写道: >> Hi: >> >> On 2025/5/9 09:40, 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@kylinsec.com.cn> >> Technically I don't think this is a compliant patch, firstly this >> patch should be V2 and also you should add "Changlog" for describing >> the differences from the previous patch. >> Anyway, it's good to me. > > Ok! There is another problem, if regmap_write(priv->regmap, > TOY_MATCH0_REG, 0) move to the end of loongson_rtc_handler as > 09471d8f5b39("rtc: loongson: clear TOY_MATCH0_REG in > loongson_rtc_isr()"), the interrupt also can be triggered multiple times. > > So the regmap_write(priv->regmap,TOY_MATCH0_REG, 0) is move behind of > rtc_update_irq by me, then the interrupt was triggered OK. > > Is there any problem ? It is ok. That's where I added it when I suggested it before. Thanks. Binbin > >> >> Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn> >> >>> --- >>> drivers/rtc/rtc-loongson.c | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c >>> index 97e5625c064c..2ca7ffd5d7a9 100644 >>> --- a/drivers/rtc/rtc-loongson.c >>> +++ b/drivers/rtc/rtc-loongson.c >>> @@ -129,6 +129,14 @@ 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); >>> + >>> + /* >>> + * The TOY_MATCH0_REG should be cleared 0 here, >>> + * otherwise the interrupt cannot be cleared. >>> + */ >>> + 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 >> >> >> ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH V2] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-04-29 6:27 [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events Liu Dalin 2025-05-08 3:12 ` Binbin Zhou 2025-05-09 1:40 ` [PATCH V1] " Liu Dalin @ 2025-05-09 8:44 ` Liu Dalin 2025-05-13 7:32 ` Binbin Zhou 2025-05-24 22:28 ` Alexandre Belloni 2 siblings, 2 replies; 11+ messages in thread From: Liu Dalin @ 2025-05-09 8:44 UTC (permalink / raw) To: alexandre.belloni, zhoubinbin, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel 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. The ACPI interrupt is also triggered multiple times. In loongson_rtc_handler, we need to clear TOY_MATCH0_REG to resolve this issue. Fixes: 09471d8f5b39 ("rtc: loongson: clear TOY_MATCH0_REG in loongson_rtc_isr()") Fixes: 1b733a9ebc3d ("rtc: Add rtc driver for the Loongson family chips") Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn> --- drivers/rtc/rtc-loongson.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c index 97e5625c064c..2ca7ffd5d7a9 100644 --- a/drivers/rtc/rtc-loongson.c +++ b/drivers/rtc/rtc-loongson.c @@ -129,6 +129,14 @@ 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); + + /* + * The TOY_MATCH0_REG should be cleared 0 here, + * otherwise the interrupt cannot be cleared. + */ + 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, -- 2.33.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-05-09 8:44 ` [PATCH V2] " Liu Dalin @ 2025-05-13 7:32 ` Binbin Zhou 2025-05-24 22:28 ` Alexandre Belloni 1 sibling, 0 replies; 11+ messages in thread From: Binbin Zhou @ 2025-05-13 7:32 UTC (permalink / raw) To: Liu Dalin, alexandre.belloni, wangming01 Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel On 2025/5/9 16:44, 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. > > The ACPI interrupt is also triggered multiple times. In loongson_rtc_handler, > we need to clear TOY_MATCH0_REG to resolve this issue. > > Fixes: 09471d8f5b39 ("rtc: loongson: clear TOY_MATCH0_REG in loongson_rtc_isr()") > Fixes: 1b733a9ebc3d ("rtc: Add rtc driver for the Loongson family chips") > Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn> Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn> > --- > drivers/rtc/rtc-loongson.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/rtc/rtc-loongson.c b/drivers/rtc/rtc-loongson.c > index 97e5625c064c..2ca7ffd5d7a9 100644 > --- a/drivers/rtc/rtc-loongson.c > +++ b/drivers/rtc/rtc-loongson.c > @@ -129,6 +129,14 @@ 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); > + > + /* > + * The TOY_MATCH0_REG should be cleared 0 here, > + * otherwise the interrupt cannot be cleared. > + */ > + 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH V2] rtc: loongson: Add missing alarm notifications for ACPI RTC events 2025-05-09 8:44 ` [PATCH V2] " Liu Dalin 2025-05-13 7:32 ` Binbin Zhou @ 2025-05-24 22:28 ` Alexandre Belloni 1 sibling, 0 replies; 11+ messages in thread From: Alexandre Belloni @ 2025-05-24 22:28 UTC (permalink / raw) To: zhoubinbin, wangming01, Liu Dalin Cc: chenhuacai, gaojuxin, git, jiaxun.yang, keguang.zhang, lixuefeng, linux-rtc, linux-kernel On Fri, 09 May 2025 16:44:16 +0800, 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. > > [...] Applied, thanks! [1/1] rtc: loongson: Add missing alarm notifications for ACPI RTC events https://git.kernel.org/abelloni/c/5af9f1fa5768 Best regards, -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-05-24 22:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-29 6:27 [PATCH] rtc: loongson: Add missing alarm notifications for ACPI RTC events Liu Dalin
2025-05-08 3:12 ` Binbin Zhou
2025-05-08 6:43 ` liudalin
[not found] ` <58BBF92742F0D0E1+2025050814202393211321@kylinos.com.cn>
2025-05-08 6:48 ` Binbin Zhou
2025-05-09 1:40 ` [PATCH V1] " Liu Dalin
2025-05-09 7:12 ` Binbin Zhou
2025-05-09 8:06 ` Liu Dalin
2025-05-09 8:27 ` Binbin Zhou
2025-05-09 8:44 ` [PATCH V2] " Liu Dalin
2025-05-13 7:32 ` Binbin Zhou
2025-05-24 22:28 ` Alexandre Belloni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®