drivers/rtc/rtc-loongson.c | 8 ++++++++ 1 file changed, 8 insertions(+)
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
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
在 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
>
>
>
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
>>
>>
>>
© 2016 - 2026 Red Hat, Inc.