rtc: cmos: ignore bogus century byte
diff mbox series

Message ID 20190106082103.evfgarznrskd4oxh@dcvr
State Accepted
Commit 2a4daadd4d3e507138f8937926e6a4df49c6bfdc
Headers show
Series
  • rtc: cmos: ignore bogus century byte
Related show

Commit Message

Eric Wong Jan. 6, 2019, 8:21 a.m. UTC
Older versions of Libreboot and Coreboot had an invalid value
(`3' in my case) in the century byte affecting the GM45 in
the Thinkpad X200.  Not everybody's updated their firmwares,
and Linux <= 4.2 was able to read the RTC without problems,
so workaround this by ignoring invalid values.

Fixes: 3c217e51d8a272b9 ("rtc: cmos: century support")

Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Sylvain Chouleur <sylvain.chouleur@intel.com>
Cc: Patrick McDermott <patrick.mcdermott@libiquity.com>
Cc: linux-rtc@vger.kernel.org
Signed-off-by: Eric Wong <e@80x24.org>
---
 drivers/rtc/rtc-mc146818-lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexandre Belloni Jan. 10, 2019, 9:33 p.m. UTC | #1
On 06/01/2019 08:21:03+0000, Eric Wong wrote:
> Older versions of Libreboot and Coreboot had an invalid value
> (`3' in my case) in the century byte affecting the GM45 in
> the Thinkpad X200.  Not everybody's updated their firmwares,
> and Linux <= 4.2 was able to read the RTC without problems,
> so workaround this by ignoring invalid values.
> 

Does this mean that it is set to an invalid value and that in is not
getting updated properly in mc146818_set_time?

> Fixes: 3c217e51d8a272b9 ("rtc: cmos: century support")
> 
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Sylvain Chouleur <sylvain.chouleur@intel.com>
> Cc: Patrick McDermott <patrick.mcdermott@libiquity.com>
> Cc: linux-rtc@vger.kernel.org
> Signed-off-by: Eric Wong <e@80x24.org>
> ---
>  drivers/rtc/rtc-mc146818-lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
> index 2f1772a358ca..18a6f15e313d 100644
> --- a/drivers/rtc/rtc-mc146818-lib.c
> +++ b/drivers/rtc/rtc-mc146818-lib.c
> @@ -82,7 +82,7 @@ unsigned int mc146818_get_time(struct rtc_time *time)
>  	time->tm_year += real_year - 72;
>  #endif
>  
> -	if (century)
> +	if (century > 20)
>  		time->tm_year += (century - 19) * 100;
>  
>  	/*
> -- 
> EW
Eric Wong Jan. 10, 2019, 9:56 p.m. UTC | #2
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> Does this mean that it is set to an invalid value and that in is not
> getting updated properly in mc146818_set_time?

It seems to be set/updated without trouble while the machine is
on.  It's only on a cold boot (from poweroff or hibernate) that
the value is invalid.

Patrick may be able to fill you in on more details.
Alexandre Belloni Jan. 22, 2019, 6:06 p.m. UTC | #3
On 06/01/2019 08:21:03+0000, Eric Wong wrote:
> Older versions of Libreboot and Coreboot had an invalid value
> (`3' in my case) in the century byte affecting the GM45 in
> the Thinkpad X200.  Not everybody's updated their firmwares,
> and Linux <= 4.2 was able to read the RTC without problems,
> so workaround this by ignoring invalid values.
> 
> Fixes: 3c217e51d8a272b9 ("rtc: cmos: century support")
> 
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Alessandro Zummo <a.zummo@towertech.it>
> Cc: Sylvain Chouleur <sylvain.chouleur@intel.com>
> Cc: Patrick McDermott <patrick.mcdermott@libiquity.com>
> Cc: linux-rtc@vger.kernel.org
> Signed-off-by: Eric Wong <e@80x24.org>
> ---
>  drivers/rtc/rtc-mc146818-lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Applied, thanks.

Patch
diff mbox series

diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
index 2f1772a358ca..18a6f15e313d 100644
--- a/drivers/rtc/rtc-mc146818-lib.c
+++ b/drivers/rtc/rtc-mc146818-lib.c
@@ -82,7 +82,7 @@  unsigned int mc146818_get_time(struct rtc_time *time)
 	time->tm_year += real_year - 72;
 #endif
 
-	if (century)
+	if (century > 20)
 		time->tm_year += (century - 19) * 100;
 
 	/*