27 Jul, 2011

1 commit

  • The RTC pie hrtimer is self rearming. We really need to limit the
    frequency to something sensible. Thus limit it to the 8192Hz max
    value from the rtc man documentation

    Cc: Willy Tarreau
    Cc: stable@kernel.org
    Signed-off-by: Thomas Gleixner
    [jstultz: slightly reworked to use RTC_MAX_FREQ value]
    Signed-off-by: John Stultz

    Thomas Gleixner
     

27 May, 2011

1 commit


30 Mar, 2011

1 commit

  • When we register an rtc device at boot, we read the alarm value
    in hardware and set the rtc device's aie_timer to that value.

    The initial method to do this was to simply call rtc_set_alarm()
    with the value read from hardware. However, this may cause problems
    as rtc_set_alarm may enable interupts, and the RTC alarm might fire,
    which can cause invalid pointer dereferencing since the RTC registration
    is not complete.

    This patch solves the issue by initializing the rtc_device.aie_timer
    y hand via rtc_initialize_alarm(). This avoids any calls to the RTC
    hardware which might enable interrupts too early.

    CC: Thomas Gleixner
    CC: Alessandro Zummo
    Reported-by: Konrad Rzeszutek Wilk
    Tested-by: Konrad Rzeszutek Wilk
    Signed-off-by: John Stultz

    John Stultz
     

10 Mar, 2011

4 commits

  • Now that the generic code handles UIE mode irqs via periodic
    alarm interrupts, no one calls the
    rtc_class_ops->update_irq_enable() method anymore.

    This patch removes the driver hooks and implementations of
    update_irq_enable if no one else is calling it.

    CC: Thomas Gleixner
    CC: Alessandro Zummo
    CC: Marcelo Roberto Jimenez
    CC: rtc-linux@googlegroups.com
    Signed-off-by: John Stultz

    John Stultz
     
  • With the generic rtc code now emulating PIE mode irqs via an
    hrtimer, no one calls the rtc_class_ops->irq_set_freq call.

    This patch removes the hook and deletes the driver functions
    if no one else calls them.

    CC: Thomas Gleixner
    CC: Alessandro Zummo
    CC: Marcelo Roberto Jimenez
    CC: rtc-linux@googlegroups.com
    Signed-off-by: John Stultz

    John Stultz
     
  • With PIE mode interrupts now emulated in generic code via an hrtimer,
    no one calls rtc_class_ops->irq_set_state(), so this patch removes it
    along with driver implementations.

    CC: Thomas Gleixner
    CC: Alessandro Zummo
    CC: Marcelo Roberto Jimenez
    CC: rtc-linux@googlegroups.com
    Signed-off-by: John Stultz

    John Stultz
     
  • Mark Brown pointed out a corner case: that RTC alarms should
    be allowed to be persistent across reboots if the hardware
    supported it.

    The rework of the generic layer to virtualize the RTC alarm
    virtualized much of the alarm handling, and removed the
    code used to read the alarm time from the hardware.

    Mark noted if we want the alarm to be persistent across
    reboots, we need to re-read the alarm value into the
    virtualized generic layer at boot up, so that the generic
    layer properly exposes that value.

    This patch restores much of the earlier removed
    rtc_read_alarm code and wires it in so that we
    set the kernel's alarm value to what we find in the
    hardware at boot time.

    NOTE: Not all hardware supports persistent RTC alarm state across
    system reset. rtc-cmos for example will keep the alarm time, but
    disables the AIE mode irq. Applications should not expect the RTC
    alarm to be valid after a system reset. We will preserve what
    we can, to represent the hardware state at boot, but its not
    guarenteed.

    Further, in the future, with multiplexed RTC alarms, the
    soonest alarm to fire may not be the one set via the /dev/rt
    ioctls. So an application may set the alarm with RTC_ALM_SET,
    but after a reset find that RTC_ALM_READ returns an earlier
    time. Again, we preserve what we can, but applications should
    not expect the RTC alarm state to persist across a system reset.

    Big thanks to Mark for pointing out the issue!
    Thanks also to Marcelo for helping think through the solution.

    CC: Mark Brown
    CC: Marcelo Roberto Jimenez
    CC: Thomas Gleixner
    CC: Alessandro Zummo
    CC: rtc-linux@googlegroups.com
    Reported-by: Mark Brown
    Signed-off-by: John Stultz

    John Stultz
     

18 Feb, 2011

2 commits

  • This patch re-enables UIE timer/polling emulation for rtc devices
    that do not support alarm irqs.

    CC: Uwe Kleine-König
    CC: Thomas Gleixner
    Reported-by: Uwe Kleine-König
    Tested-by: Uwe Kleine-König
    Signed-off-by: John Stultz

    John Stultz
     
  • Uwe pointed out that my alarm based UIE emulation is not sufficient
    to replace the older timer/polling based UIE emulation on devices
    where there is no alarm irq. This causes rtc devices without alarms
    to return -EINVAL to UIE ioctls. The fix is to re-instate the old
    timer/polling method for devices without alarm irqs.

    This patch reverts the following commits:
    042620a018afcfba1d678062b62e46 - Remove UIE emulation
    1daeddd5962acad1bea55e524fc0fa - Cleanup removed UIE emulation declaration
    b5cc8ca1c9c3a37eaddf709b2fd3e1 - Remove Kconfig symbol for UIE emulation

    The emulation mode will still need to be wired-in with a following
    patch before it will work.

    CC: Uwe Kleine-König
    CC: Thomas Gleixner
    Reported-by: Uwe Kleine-König
    Signed-off-by: John Stultz

    John Stultz
     

22 Jan, 2011

2 commits

  • In cases where RTC hardware does not support alarms, the virtualized
    RTC interfaces did not have a way to propagate the error up to userland.

    This patch extends rtc_timer_enqueue so it catches errors from the hardware
    and returns them upwards to the virtualized interfaces. To simplify error
    handling, it also internalizes the management of the timer->enabled bit
    into rtc_timer_enqueue and rtc_timer_remove.

    Also makes rtc_timer_enqueue and rtc_timer_remove static.

    Reported-by: David Daney
    Reported-by: Andreas Schwab
    Reported-by: Geert Uytterhoeven
    Diagnosed-by: David Daney
    Tested-by: David Daney
    Signed-off-by: John Stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    John Stultz
     
  • rtc_dev_update_irq_enable_emul was removed in commit
    042620a018afcfba1d678062b62e463b9e43a68d (UIE emulation is
    now handled via hrtimer), but the declaration was missed.
    This patch cleans it up.

    Signed-off-by: John Stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    John Stultz
     

14 Dec, 2010

1 commit

  • rtctimer_* is already occupied by sound/core/rtctimer.c. Instead of
    fiddling with that, rename the new functions to rtc_timer_* which
    reads nicer anyway.

    Signed-off-by: Thomas Gleixner
    Cc: John Stultz

    Thomas Gleixner
     

11 Dec, 2010

2 commits

  • Since we provide UIE interrupts via a rtc_timer, the old
    emulation code can be removed.

    Signed-off-by: John Stultz
    LKML Reference:
    Acked-by: Alessandro Zummo
    Reviewed-by: Thomas Gleixner
    CC: Alessandro Zummo
    CC: Thomas Gleixner
    CC: Richard Cochran

    John Stultz
     
  • This patch reworks a large portion of the generic RTC code
    to in-effect virtualize the rtc interrupt code.

    The current RTC interface is very much a raw hardware interface.
    Via the proc, /dev/, or sysfs interfaces, applciations can set
    the hardware to trigger interrupts in one of three modes:

    AIE: Alarm interrupt
    UIE: Update interrupt (ie: once per second)
    PIE: Periodic interrupt (sub-second irqs)

    The problem with this interface is that it limits the RTC hardware
    so it can only be used by one application at a time.

    The purpose of this patch is to extend the RTC code so that we can
    multiplex multiple applications event needs onto a single RTC device.
    This is done by utilizing the timerqueue infrastructure to manage
    a list of events, which cause the RTC hardware to be programmed
    to fire an interrupt for the next event in the list.

    In order to preserve the functionality of the exsting proc,/dev/ and
    sysfs interfaces, we emulate the different interrupt modes as follows:

    AIE: We create a rtc_timer dedicated to AIE mode interrupts. There is
    only one per device, so we don't change existing interface semantics.

    UIE: Again, a dedicated rtc_timer, set for periodic mode, is used
    to emulate UIE interrupts. Again, only one per device.

    PIE: Since PIE mode interrupts fire faster then the RTC's clock read
    granularity, we emulate PIE mode interrupts using a hrtimer. Again,
    one per device.

    With this patch, the rtctest.c application in Documentation/rtc.txt
    passes fine on x86 hardware. However, there may very well still be
    bugs, so greatly I'd appreciate any feedback or testing!

    Signed-off-by: John Stultz
    LKML Reference:
    Acked-by: Alessandro Zummo
    Reviewed-by: Thomas Gleixner
    CC: Alessandro Zummo
    CC: Thomas Gleixner
    CC: Richard Cochran

    John Stultz
     

13 Mar, 2010

1 commit

  • Without this patch /sys/class/rtc/$CONFIG_RTC_HCTOSYS_DEVICE/hctosys
    contains a 1 (meaning "This rtc was used to initialize the system clock")
    even if reading the time at bootup failed.

    Moreover change error handling in rtc_hctosys() to use goto and so reduce
    the indention level.

    Signed-off-by: Uwe Kleine-König
    Cc: Paul Gortmaker
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Uwe Kleine-König
     

01 Apr, 2009

1 commit

  • - the LEAP_YEAR macro is buggy - it references its arg multiple times.
    Fix this by turning it into a C function.

    - give it a more approriate name

    - Move it to rtc.h so that other .c files can use it, instead of copying it.

    Cc: dann frazier
    Acked-by: Alessandro Zummo
    Cc: stephane eranian
    Cc: "Luck, Tony"
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

05 Jan, 2009

1 commit

  • Add standard interfaces for alarm/update irqs enabling. Drivers are no
    more required to implement equivalent ioctl code as rtc-dev will provide
    it.

    UIE emulation should now be handled correctly and will work even for those
    RTC drivers who cannot be configured to do both UIE and AIE.

    Signed-off-by: Alessandro Zummo
    Cc: David Brownell
    Cc: Atsushi Nemoto
    Cc: Ralf Baechle
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     

27 Jul, 2008

1 commit


25 Jul, 2008

1 commit

  • Remove implicit use of BKL in ioctl() from the RTC framework.

    Instead, the rtc->ops_lock is used. That's the same lock that already
    protects the RTC operations when they're issued through the exported
    rtc_*() calls in drivers/rtc/interface.c ... making this a bugfix, not
    just a cleanup, since both ioctl calls and set_alarm() need to update IRQ
    enable flags and that implies a common lock (which RTC drivers as a rule
    do not provide on their own).

    A new comment at the declaration of "struct rtc_class_ops" summarizes
    current locking rules. It's not clear to me that the exceptions listed
    there should exist ... if not, those are pre-existing problems which can
    be fixed in a patch that doesn't relate to BKL removal.

    Signed-off-by: David Brownell
    Cc: Alan Cox
    Cc: Jonathan Corbet
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

30 Nov, 2007

1 commit

  • RTC code is using mutex to assure exclusive access to /dev/rtc. This is
    however wrong usage, as it leaves the mutex locked when returning into
    userspace, which is unacceptable.

    Convert rtc->char_lock into bit operation.

    Signed-off-by: Jiri Kosina
    Acked-by: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jiri Kosina
     

09 May, 2007

4 commits

  • David says "884b4aaaa242a2db8c8252796f0118164a680ab5 should be reverted. It
    added an rtc_merge_alarm() call to the 2.6.20 kernel, which hasn't yet been
    used by any in-tree driver; this patch obviates the need for that call, and
    uses a more robust approach."

    Cc: Scott Wood
    Cc: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Finish converting the RTC framework so it no longer uses class_device.

    Signed-off-by: David Brownell
    Acked-by: Greg Kroah-Hartman
    Acked-By: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • This patch removes class_device from the programming interface that the RTC
    framework exposes to the rest of the kernel. Now an rtc_device is passed,
    which is more type-safe and streamlines all the relevant code.

    Signed-off-by: David Brownell
    Acked-by: Greg Kroah-Hartman
    Acked-By: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • This simplifies the /dev support by removing a superfluous class_device (the
    /sys/class/rtc-dev stuff) and the class_interface that hooks it into the rtc
    core. Accordingly, if it's configured then /dev support is now part of the
    RTC core, and is never a separate module.

    It's another step towards being able to remove "struct class_device".

    [bunk@stusta.de: drivers/rtc/rtc-dev.c should #include "rtc-core.h"]
    Signed-off-by: David Brownell
    Acked-by: Greg Kroah-Hartman
    Acked-By: Alessandro Zummo
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

11 Dec, 2006

1 commit

  • Add rtc_merge_alarm(), which can be used by rtc drivers to turn a partially
    specified alarm expiry (i.e. most significant fields set to -1, as with the
    RTC_ALM_SET ioctl()) into a fully specified expiry.

    If the most significant specified field is earlier than the current time, the
    least significant unspecified field is incremented.

    Signed-off-by: Scott Wood
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Scott Wood
     

05 Oct, 2006

1 commit

  • Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
    of passing regs around manually through all ~1800 interrupt handlers in the
    Linux kernel.

    The regs pointer is used in few places, but it potentially costs both stack
    space and code to pass it around. On the FRV arch, removing the regs parameter
    from all the genirq function results in a 20% speed up of the IRQ exit path
    (ie: from leaving timer_interrupt() to leaving do_IRQ()).

    Where appropriate, an arch may override the generic storage facility and do
    something different with the variable. On FRV, for instance, the address is
    maintained in GR28 at all times inside the kernel as part of general exception
    handling.

    Having looked over the code, it appears that the parameter may be handed down
    through up to twenty or so layers of functions. Consider a USB character
    device attached to a USB hub, attached to a USB controller that posts its
    interrupts through a cascaded auxiliary interrupt controller. A character
    device driver may want to pass regs to the sysrq handler through the input
    layer which adds another few layers of parameter passing.

    I've build this code with allyesconfig for x86_64 and i386. I've runtested the
    main part of the code on FRV and i386, though I can't test most of the drivers.
    I've also done partial conversion for powerpc and MIPS - these at least compile
    with minimal configurations.

    This will affect all archs. Mostly the changes should be relatively easy.
    Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

    struct pt_regs *old_regs = set_irq_regs(regs);

    And put the old one back at the end:

    set_irq_regs(old_regs);

    Don't pass regs through to generic_handle_irq() or __do_IRQ().

    In timer_interrupt(), this sort of change will be necessary:

    - update_process_times(user_mode(regs));
    - profile_tick(CPU_PROFILING, regs);
    + update_process_times(user_mode(get_irq_regs()));
    + profile_tick(CPU_PROFILING);

    I'd like to move update_process_times()'s use of get_irq_regs() into itself,
    except that i386, alone of the archs, uses something other than user_mode().

    Some notes on the interrupt handling in the drivers:

    (*) input_dev() is now gone entirely. The regs pointer is no longer stored in
    the input_dev struct.

    (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
    something different depending on whether it's been supplied with a regs
    pointer or not.

    (*) Various IRQ handler function pointers have been moved to type
    irq_handler_t.

    Signed-Off-By: David Howells
    (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)

    David Howells
     

01 Oct, 2006

1 commit


01 Jul, 2006

1 commit


26 Jun, 2006

3 commits

  • RTC: Add exported function rtc_year_days() to calculate the tm_yday value.

    Signed-off-by: Andrew Victor
    Signed-off-by: Alessandro Zummo
    Cc: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Victor
     
  • Centralize CAP_SYS_XXX checks to avoid duplicate code and missing checks in
    the drivers.

    Signed-off-by: Alessandro Zummo
    Cc: Richard Purdie
    Cc: Yoichi Yuasa
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     
  • Import genrtc's RTC UIE emulation (CONFIG_GEN_RTC_X) to rtc-dev driver with
    slight adjustments/refinements. This makes UIE-less rtc drivers work
    better with programs doing read/poll on /dev/rtc, such as hwclock. This
    emulation should not harm rtc drivers with UIE support, since
    rtc_dev_ioctl() calls underlaying rtc driver's ioctl() first.

    Signed-off-by: Atsushi Nemoto
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Atsushi Nemoto
     

28 Mar, 2006

2 commits

  • Add the basic RTC subsystem infrastructure to the kernel.

    rtc/class.c - registration facilities for RTC drivers
    rtc/interface.c - kernel/rtc interface functions
    rtc/hctosys.c - snippet of code that copies hw clock to sw clock
    at bootup, if configured to do so.

    Signed-off-by: Alessandro Zummo
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     
  • RTC and date/time related functions.

    Signed-off-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alessandro Zummo
     

22 Mar, 2006

1 commit

  • Git patch 52dfa9a64cfb3dd01fa1ee1150d589481e54e28e

    [PATCH] move rtc_interrupt() prototype to rtc.h

    broke strace(1) builds. The below moves the kernel-only additions lower,
    under the already provided #ifdef __KERNEL__ statement.

    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Korty
     

09 Jan, 2006

1 commit

  • This patch moves the rtc_interrupt() prototype to rtc.h and removes the
    prototypes from C files.

    It also renames static rtc_interrupt() functions in
    arch/arm/mach-integrator/time.c and arch/sh64/kernel/time.c to avoid compile
    problems.

    Signed-off-by: Adrian Bunk
    Signed-off-by: Paul Gortmaker
    Acked-by: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds