[rtc-linux] Re: [PATCH V3 2/2] rtc/rtc-cmos: Initialize software counters before irq is registered

2016-09-06 Thread Pratyush Anand
Hi Thomas,

On 06/09/2016:11:58:08 AM, Thomas Gleixner wrote:
> On Tue, 16 Aug 2016, Pratyush Anand wrote:
> 
> That's a lot of churn to fix that simple problem. The two liner below
> should fix that as well, right?

Thanks a lot for your reply.

Yes, that should fix. I was n't sure if "setting HPET_TN_ENABLE before IRQ is
registered" would be a right step.
I can give it a try, however it is pretty obvious that these two liners should
be able to solve the issue. So, if this solution will not have any side effect
then, it is fine for me as well.

~Pratyush

> 
> Thanks,
> 
>   tglx
> 
> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index 43745cac0141..cb8dfc3ee012 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -707,6 +707,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, 
> int rtc_irq)
>   goto cleanup1;
>   }
>  
> + hpet_rtc_timer_init();
>   if (is_valid_irq(rtc_irq)) {
>   irq_handler_t rtc_cmos_int_handler;
>  
> @@ -714,6 +715,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, 
> int rtc_irq)
>   rtc_cmos_int_handler = hpet_rtc_interrupt;
>   retval = hpet_register_irq_handler(cmos_interrupt);
>   if (retval) {
> + hpet_mask_rtc_irq_bit(RTC_IRQMASK);
>   dev_warn(dev, "hpet_register_irq_handler "
>   " failed in rtc_init().");
>   goto cleanup1;
> @@ -729,7 +731,6 @@ cmos_do_probe(struct device *dev, struct resource *ports, 
> int rtc_irq)
>   goto cleanup1;
>   }
>   }
> - hpet_rtc_timer_init();
>  
>   /* export at least the first block of NVRAM */
>   nvram.size = address_space - NVRAM_OFFSET;
> 

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups 
"rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rtc-linux+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[rtc-linux] Re: [PATCH V3 2/2] rtc/rtc-cmos: Initialize software counters before irq is registered

2016-09-06 Thread Thomas Gleixner
On Tue, 16 Aug 2016, Pratyush Anand wrote:

That's a lot of churn to fix that simple problem. The two liner below
should fix that as well, right?

Thanks,

tglx

diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 43745cac0141..cb8dfc3ee012 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -707,6 +707,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, 
int rtc_irq)
goto cleanup1;
}
 
+   hpet_rtc_timer_init();
if (is_valid_irq(rtc_irq)) {
irq_handler_t rtc_cmos_int_handler;
 
@@ -714,6 +715,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, 
int rtc_irq)
rtc_cmos_int_handler = hpet_rtc_interrupt;
retval = hpet_register_irq_handler(cmos_interrupt);
if (retval) {
+   hpet_mask_rtc_irq_bit(RTC_IRQMASK);
dev_warn(dev, "hpet_register_irq_handler "
" failed in rtc_init().");
goto cleanup1;
@@ -729,7 +731,6 @@ cmos_do_probe(struct device *dev, struct resource *ports, 
int rtc_irq)
goto cleanup1;
}
}
-   hpet_rtc_timer_init();
 
/* export at least the first block of NVRAM */
nvram.size = address_space - NVRAM_OFFSET;


-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups 
"rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rtc-linux+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[rtc-linux] Re: [PATCH v2 1/2] rtc-cmos: Ensure no expired alarm is left enabled after resume

2016-09-06 Thread Gabriele Mazzotta
2016-09-06 0:26 GMT+02:00 Alexandre Belloni
:
> Hi
>
> On 01/09/2016 at 00:58:59 +0200, Gabriele Mazzotta wrote :
>>  static int cmos_resume(struct device *dev)
>>  {
>>   struct cmos_rtc *cmos = dev_get_drvdata(dev);
>>   unsigned char tmp;
>> + bool is_wkalrm_expired;
>>
>>   if (cmos->enabled_wake) {
>>   if (cmos->wake_off)
>> @@ -913,6 +935,8 @@ static int cmos_resume(struct device *dev)
>>   cmos->enabled_wake = 0;
>>   }
>>
>> + is_wkalrm_expired = cmos_is_wkalrm_expired(dev);
>> +
>>   spin_lock_irq(_lock);
>>   tmp = cmos->suspend_ctrl;
>>   cmos->suspend_ctrl = 0;
>> @@ -939,6 +963,17 @@ static int cmos_resume(struct device *dev)
>>   tmp &= ~RTC_AIE;
>>   hpet_mask_rtc_irq_bit(RTC_AIE);
>>   } while (mask & RTC_AIE);
>> +
>> + /*
>> +  * If RTC_AIE is set and we have an alarm set to go off in the
>> +  * past, then the BIOS woke the system when the alarm went off
>> +  * and we now have to clear it.
>> +  */
>> + if ((tmp & RTC_AIE) && is_wkalrm_expired) {
>
> Is there any issue dropping is_wkalrm_expired and calling
> cmos_is_wkalrm_expired() here? That would avoid calling
> cmos_is_wkalrm_expired on each wakeup.

Yes, get_rtc_time() (cmos_read_time()) tries to aquire rtc_lock.

> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups 
"rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rtc-linux+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.