Setting rtc wakealarm through sysfs interface fails

Bug #503546 reported by Paul Larson
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux-mvl-dove (Ubuntu)
Invalid
Medium
Unassigned
Lucid
Won't Fix
Undecided
Paolo Pisati
Maverick
Won't Fix
Undecided
Paolo Pisati

Bug Description

SRU Justification:

    Impact: alarm date are always improperly set to 2091.
    Fix: see attached patch.
    Testcase:

     sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm" && cat /proc/driver/rtc

     you will notice that alrm_date is 2091.

===

I'm working with some of the scripts to do suspend/resume testing and noticed that using the /sys/class/rtc/rtc0/wakealarm interface for setting wakealarms does not seem to work correctly. No matter what I echo to that file, it always contains the value of 3787332250 after catting it again after the echo. I can echo 0 to it to reset it, but it still picks up the wrong value no matter what I send to it.

$ uname -a
Linux dove 2.6.31-701-dove #4-Ubuntu Thu Dec 17 09:31:21 UTC 2009 armv7l GNU/Linux

Paul Larson (pwlars)
Changed in linux-mvl-dove (Ubuntu):
assignee: nobody → Eric Miao (eric.y.miao)
Eric Miao (eric.y.miao)
Changed in linux-mvl-dove (Ubuntu):
importance: Undecided → Medium
milestone: none → lucid-alpha-3
status: New → Confirmed
tags: added: kernel-series-unknown
Revision history for this message
Steve Langasek (vorlon) wrote :

lucid-alpha-3 is clearly long past. Is this bug still applicable to lucid?

Changed in linux-mvl-dove (Ubuntu):
status: Confirmed → Invalid
Changed in linux-mvl-dove (Ubuntu Lucid):
assignee: nobody → Eric Miao (eric.y.miao)
Changed in linux-mvl-dove (Ubuntu):
assignee: Eric Miao (eric.y.miao) → nobody
milestone: lucid-alpha-3 → none
Changed in linux-mvl-dove (Ubuntu Lucid):
status: New → Confirmed
Paolo Pisati (p-pisati)
Changed in linux-mvl-dove (Ubuntu Lucid):
assignee: Eric Miao (eric.y.miao) → Paolo Pisati (p-pisati)
Changed in linux-mvl-dove (Ubuntu Maverick):
assignee: nobody → Paolo Pisati (p-pisati)
Paolo Pisati (p-pisati)
Changed in linux-mvl-dove (Ubuntu Maverick):
status: New → Confirmed
Revision history for this message
Paolo Pisati (p-pisati) wrote :

yes, it is still present:

flag@casper:~$ date '+%s'
1300104497
flag@casper:~$ sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
flag@casper:~$ sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm"
flag@casper:~$ cat /sys/class/rtc/rtc0/wakealarm
3824712805
flag@casper:~$ cat /proc/driver/rtc
rtc_time : 12:08:59
rtc_date : 2011-03-14
alrm_time : 12:13:25
alrm_date : 2091-03-14
alarm_IRQ : yes
alrm_pending : no
24hr : yes

and it is due to an erroneous mask operation when reading back the alarm from the RTC register.
This following patch should fix it:

diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index daf7c5e..8446717 100755
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -112,7 +112,7 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)

        day = rtc_date & 0x3f;
        month = (rtc_date >> RTC_MONTH_OFFS) & 0x3f;
- year = (rtc_date >> RTC_YEAR_OFFS) & 0xff;
+ year = (rtc_date >> RTC_YEAR_OFFS) & 0x7f;

        alm->time.tm_sec = bcd2bin(second);
        alm->time.tm_min = bcd2bin(minute);

i already forwarded it to our Marvell contact, waiting for feedback on it.

Unfortunately, even with this patch, i cannot successfully make Casper to resume, so more work is needed in this area.

Revision history for this message
Paolo Pisati (p-pisati) wrote :

After a bit more testing, i confirm i can successfully resume from S3.

Revision history for this message
Paolo Pisati (p-pisati) wrote :
Paolo Pisati (p-pisati)
description: updated
Paolo Pisati (p-pisati)
Changed in linux-mvl-dove (Ubuntu Lucid):
status: Confirmed → In Progress
Changed in linux-mvl-dove (Ubuntu Maverick):
status: Confirmed → In Progress
Tim Gardner (timg-tpi)
Changed in linux-mvl-dove (Ubuntu Lucid):
status: In Progress → Fix Committed
Revision history for this message
Paolo Pisati (p-pisati) wrote :

Saeed sent me the correct fix for this:

the year valid is 8 bits after the start of the year field, the previous
code sets the wrong bit (7 + start of year offset).

Changed in linux-mvl-dove (Ubuntu Lucid):
status: Fix Committed → In Progress
Revision history for this message
Rolf Leggewie (r0lf) wrote :

maverick has seen the end of its life and is no longer receiving any updates. Marking the maverick task for this ticket as "Won't Fix".

Changed in linux-mvl-dove (Ubuntu Maverick):
status: In Progress → Won't Fix
Revision history for this message
Rolf Leggewie (r0lf) wrote :

lucid has seen the end of its life and is no longer receiving any updates. Marking the lucid task for this ticket as "Won't Fix".

Changed in linux-mvl-dove (Ubuntu Lucid):
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.