02 Jun, 2011

1 commit

  • Bryan Henderson noticed that the "RTC: Fix rtc driver ioctl specific
    shortcutting" commit has a small bug: When an ioctl is called with an
    invalid command code and the clock driver does not have an "ioctl"
    method, the ioctl returns rc 0 instead of -ENOTTY.

    This patch fixes the issue.

    CC: Bryan Henderson
    CC: Gabor Z. Papp
    Reported-by: Bryan Henderson
    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
     

04 Feb, 2011

1 commit

  • Some RTC drivers enable functionality directly via their ioctl method
    instead of using the generic ioctl handling code. With the recent
    virtualization of the RTC layer, its now important that the generic
    layer always be used.

    This patch moved the rtc driver ioctl method call to after the generic
    ioctl processing is done. This allows hardware specific features or
    ioctls to still function, while relying on the generic code for handling
    everything else.

    This patch on its own may more obviously break rtc drivers that
    implement the alarm irq enablement via their ioctl method instead of
    implementing the alarm_irq_eanble method. Those drivers will be fixed
    in a following patch. Additionaly, those drivers are already likely to
    not be functioning reliably without this patch.

    CC: Alessandro Zummo
    CC: Marcelo Roberto Jimenez
    CC: Thomas Gleixner
    Reported-by: Marcelo Roberto Jimenez
    Tested-by: Marcelo Roberto Jimenez
    Signed-off-by: John Stultz

    John Stultz
     

11 Dec, 2010

1 commit

  • 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
     

12 Oct, 2009

1 commit


20 Jun, 2009

1 commit

  • The rtc_update_irq() might be called with irqs enabled, if a interrupt
    handler was registered without IRQF_DISABLED. Use
    spin_lock_irqsave/spin_unlock_irqrestore instead of spin_lock/spin_unlock.

    Also update kerneldoc and drivers which do extra work to follow the
    current interface spec, as suggestted by David Brownell.

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

    Atsushi Nemoto
     

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
     

02 Nov, 2008

1 commit

  • As it is, all instances of ->release() for files that have ->fasync()
    need to remember to evict file from fasync lists; forgetting that
    creates a hole and we actually have a bunch that *does* forget.

    So let's keep our lives simple - let __fput() check FASYNC in
    file->f_flags and call ->fasync() there if it's been set. And lose that
    crap in ->release() instances - leaving it there is still valid, but we
    don't have to bother anymore.

    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Al Viro
     

17 Oct, 2008

1 commit

  • Make the rtc framework consistent about disabling 1/second update IRQs
    that may have been activated through the /dev interface, when that /dev
    file is closed. (It may have closed because of coredump, etc.) This was
    previously done only for emulated update IRQs ... now, do it always.

    Also comment the current policy: repeating IRQs (periodic, update) that
    userspace enabled will be cleanly disabled, but alarms are left alone.
    Such repeating IRQs are a constant and pointless system load.

    Update some RTC drivers to remove now-needless release() methods. Most
    such methods just enforce that policy. The others all seem to be buggy,
    and mistreat in-kernel clients of periodic or alarm IRQs.

    Signed-off-by: David Brownell
    Acked-by: Andrew Sharp
    Cc: Angelo Castello
    Acked-by: Atsushi Nemoto
    Acked-by: Paul Mundt
    Cc: Thomas Hommel
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

04 Oct, 2008

1 commit

  • When userspace uses SIGIO notification and forgets to disable it before
    closing file descriptor, rtc->async_queue contains stale pointer to struct
    file. When user space enables again SIGIO notification in different
    process, kernel dereferences this (poisoned) pointer and crashes.

    So disable SIGIO notification on close.

    Kernel panic:
    (second run of qemu (requires echo 1024 > /sys/class/rtc/rtc0/max_user_freq))

    general protection fault: 0000 [1] PREEMPT
    CPU 0
    Modules linked in: af_packet snd_pcm_oss snd_mixer_oss snd_seq_oss snd_seq_midi_event snd_seq usbhid tuner tea5767 tda8290 tuner_xc2028 xc5000 tda9887 tuner_simple tuner_types mt20xx tea5761 tda9875 uhci_hcd ehci_hcd usbcore bttv snd_via82xx snd_ac97_codec ac97_bus snd_pcm snd_timer ir_common compat_ioctl32 snd_page_alloc videodev v4l1_compat snd_mpu401_uart snd_rawmidi v4l2_common videobuf_dma_sg videobuf_core snd_seq_device snd btcx_risc soundcore tveeprom i2c_viapro
    Pid: 5781, comm: qemu-system-x86 Not tainted 2.6.27-rc6 #363
    RIP: 0010:[] [] __lock_acquire+0x3db/0x73f
    RSP: 0000:ffffffff80674cb8 EFLAGS: 00010002
    RAX: ffff8800224c62f0 RBX: 0000000000000046 RCX: 0000000000000002
    RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8800224c62f0
    RBP: ffffffff80674d08 R08: 0000000000000002 R09: 0000000000000001
    R10: ffffffff80238941 R11: 0000000000000001 R12: 0000000000000000
    R13: 6b6b6b6b6b6b6b6b R14: ffff88003a450080 R15: 0000000000000000
    FS: 00007f98b69516f0(0000) GS:ffffffff80623200(0000) knlGS:00000000f7cc86d0
    CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: 0000000000a87000 CR3: 0000000022598000 CR4: 00000000000006e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Process qemu-system-x86 (pid: 5781, threadinfo ffff880028812000, task ffff88003a450080)
    Stack: ffffffff80674cf8 0000000180238440 0000000200000002 0000000000000000
    ffff8800224c62f0 0000000000000046 0000000000000000 0000000000000002
    0000000000000002 0000000000000000 ffffffff80674d68 ffffffff8024fc7a
    Call Trace:
    [] lock_acquire+0x85/0xa9
    [] ? send_sigio+0x2a/0x184
    [] _read_lock+0x3e/0x4a
    [] ? send_sigio+0x2a/0x184
    [] send_sigio+0x2a/0x184
    [] ? __lock_acquire+0x6e1/0x73f
    [] ? kill_fasync+0x2c/0x4e
    [] __kill_fasync+0x54/0x65
    [] kill_fasync+0x3a/0x4e
    [] rtc_update_irq+0x9c/0xa5
    [] cmos_interrupt+0xae/0xc0
    [] handle_IRQ_event+0x25/0x5a
    [] handle_edge_irq+0xdd/0x123
    [] do_IRQ+0xe4/0x144
    [] ret_from_intr+0x0/0xf
    [] ? __alloc_pages_internal+0xe7/0x3ad
    [] ? clear_page_c+0x7/0x10
    [] ? get_page_from_freelist+0x385/0x450
    [] ? __alloc_pages_internal+0xe7/0x3ad
    [] ? anon_vma_prepare+0x2e/0xf6
    [] ? handle_mm_fault+0x227/0x6a5
    [] ? do_page_fault+0x494/0x83f
    [] ? error_exit+0x0/0xa9

    Code: cc 41 39 45 28 74 24 e8 5e 1d 0f 00 85 c0 0f 84 6a 03 00 00 83 3d 8f a9 aa 00 00 be 47 03 00 00 0f 84 6a 02 00 00 e9 53 03 00 00 ff 85 38 01 00 00 45 8b be 90 06 00 00 41 83 ff 2f 76 24 e8
    RIP [] __lock_acquire+0x3db/0x73f
    RSP
    ---[ end trace 431877d860448760 ]---
    Kernel panic - not syncing: Aiee, killing interrupt handler!

    Signed-off-by: Marcin Slusarz
    Acked-by: Alessandro Zummo
    Acked-by: David Brownell
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Marcin Slusarz
     

21 Aug, 2008

1 commit

  • With commit 5ad31a575157147b43fa84ef1e21471661653878 ("rtc: remove BKL
    for ioctl()"), RTC_UIE_ON ioctl cause double lock on rtc->ops_lock.
    The ops_lock must not be held while set_uie() calls rtc_read_time()
    which takes the lock. Also clear_uie() does not need ops_lock. This
    patch fixes return value of RTC_UIE_OFF ioctl too.

    Signed-off-by: Atsushi Nemoto
    Cc: David Brownell
    Cc: Russell King
    Cc: Alessandro Zummo
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Atsushi Nemoto
     

13 Aug, 2008

1 commit

  • Revert commit 51a776fa7a7997e726d4a478eda0854c6f9143bd ("rtc: cdev
    lock_kernel() pushdown"). The RTC framework does not need BKL
    protection.

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

    David Brownell
     

31 Jul, 2008

2 commits

  • Solves http://bugzilla.kernel.org/show_bug.cgi?id=11127

    The old rtc.c driver did it and some drivers (like rtc-sh) do it in their
    release function, though they should not -- because they should provide
    the irq_set_state op and the rtc framework itself should care about it.
    This patch makes it do so.

    I am aware that some drivers, like rtc-sh, handle userspace PIE sets in
    their ioctl op (instead of having the framework call the op), exporting
    the irq_set_state op at the same time. The logic in rtc_irq_set_state
    should make sure it doesn't matter and the driver should not need to care
    stopping periodic interrupts in its release routine any more.

    The correct way, in my opinion, should be this:
    1) The driver provides the irq_set_state op and does not care closing the
    interrupts in its release op.
    2) If the driver does not provide the op and handles PIE in the ioctl op, it's
    reponsible for closing them in its release op.
    3) Something similar for other IRQs, like UIE -- if there's no in-kernel API
    like irq_set_state, handle it in ioctl and release ops. The framework will
    be responsible either for everything or for nothing. (This will probably
    change later.)

    Signed-off-by: Tomas Janousek
    Acked-by: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomas Janousek
     
  • It was pointed out that the RTC framework handles its mutex locks oddly
    ... returning -EBUSY when interrupted. This fixes that by returning the
    value of mutex_lock_interruptible() (i.e. -EINTR).

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

    David Brownell
     

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
     

21 Jun, 2008

1 commit


07 Feb, 2008

1 commit

  • Start making the rtc-cmos alarm act more like a oneshot alarm by disabling
    that alarm after its IRQ fires. (ACPI hooks are also needed.)

    The Linux RTC framework has previously been a bit vague in this area, but
    any other behavior is problematic and not very portable. RTCs with full
    YYYY-MM-DD HH:MM[:SS] alarms won't have a problem here. Only ones with
    partial match criteria, with the most visible example being the PC RTC, get
    confused. (Because the criteria will match repeatedly.)

    Update comments relating to that oneshot behavior and timezone handling.
    (Timezones are another issue that's mostly visible with rtc-cmos. That's
    because PCs often dual-boot MS-Windows, which likes its RTC to match local
    wall-clock time instead of UTC.)

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

    David Brownell
     

06 Dec, 2007

1 commit

  • We must make sure that the RTC_DEV_BUSY flag has proper lock semantics,
    i.e. that the RTC_DEV_BUSY stores clearing the flag don't get reordered
    before the preceeding stores and loads and vice versa.

    Spotted by Nick Piggin.

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

    Jiri Kosina
     

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
     

17 Oct, 2007

3 commits

  • drivers/char/rtc.c allowed RTC_PIE_ON ioctls for non-root users, as long as
    the current interval (set via RTC_IRQP_SET) is
    Acked-by: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bryan Kadzban
     
  • In rtc-dev.c, when a rtc device is opened, file->private_data is already
    attached with the rtc device pointer, so there is no need to call
    to_rtc_device() to convert file->private_data to a rtc device pointer.

    Acked-by: Alessandro Zummo
    Signed-off-by: Mark Zhan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Zhan
     
  • Add kernel/kernel and kernel/user locking for the periodic irq feature of
    the rtc class.

    PIE ioctls are also supported.

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

    Alessandro Zummo
     

01 Aug, 2007

1 commit


18 Jul, 2007

1 commit


09 May, 2007

5 commits

  • This fixes a common glitch in how RTC drivers handle two "set alarm" modes,
    by getting rid of the surprising/hidden one that was rarely implemented
    correctly (and which could expose nonportable hardware-specific behavior).

    The glitch comes from the /dev/rtcX logic implementing the legacy
    RTC_ALM_SET (limited to 24 hours, needing RTC_AIE_ON) ioctl on top of the
    RTC driver call providing access to the newer RTC_WKALM_SET (without those
    limitations) by initializing the day/month/year fields to be invalid ...
    that second mode.

    Now, since few RTC drivers check those fields, and most hardware misbehaves
    when faced with invalid date fields, many RTC drivers will set bogus alarm
    times on those RTC_ALM_SET code paths. (Several in-tree drivers have that
    issue, and I also noticed it with code reviews on several new RTC drivers.)

    This patch ensures that RTC drivers never see such invalid alarm fields, by
    moving some logic out of rtc-omap into the RTC_ALM_SET code and adding an
    explicit check (which will prevent the issue on other code paths).

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

    David Brownell
     
  • Fix a goof in the revised classdev support for RTCs: make sure the /dev
    node info is ready before the device is registered, not after. Otherwise
    the /sys/class/rtc/rtcN/dev attribute won't be created and then udev won't
    have the information it needs to create the /dev/rtcN node.

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

    David Brownell
     
  • 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
     

13 Feb, 2007

1 commit

  • Many struct file_operations in the kernel can be "const". Marking them const
    moves these to the .rodata section, which avoids false sharing with potential
    dirty data. In addition it'll catch accidental writes at compile time to
    these shared resources.

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

10 Feb, 2007

1 commit


14 Dec, 2006

1 commit


05 Dec, 2006

1 commit


26 Nov, 2006

2 commits

  • I got a lockdep warning when running "rtctest" so I though it'd be good
    to see what was up.

    - The warning was for rtc->irq_task_lock, gotten from rtc_update_irq()
    by irq handlerss ... but in a handful of other cases, grabbed without
    blocking IRQs.

    - Some callers to rtc_update_irq() were not ensuring IRQs were blocked,
    yet the routine expects that; make sure all callers block IRQs.

    It would appear that RTC API tests haven't been part of anyone's kernel
    regression test suite recently, at least not with lockdep running.

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

    David Brownell
     
  • The RTC framework has an irq_set_freq() method that should be used to manage
    the periodic IRQ frequency, but the current ioctl logic doesn't know how to do
    that. This patch teaches it how.

    This means that drivers implementing irq_set_freq() will automatically support
    RTC_IRQP_{READ,SET} ioctls; that logic doesn't need duplication within the
    driver.

    [akpm@osdl.org: export rtc_irq_set_freq]
    Signed-off-by: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

22 Nov, 2006

1 commit


01 Oct, 2006

3 commits

  • Update RTC framework so that drivers can constify their method tables, moving
    them from ".data" to ".rodata". Then update the drivers.

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

    David Brownell
     
  • This makes RTC core components use "subsys_init" instead of "module_init", as
    appropriate for subsystem infrastructure. This is mostly useful for
    statically linking drivers in other parts of the tree that may provide an RTC
    interface as a secondary functionality (e.g. part of a multifunction chip);
    they won't need to worry so much about drivers/Makefile link order.

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Acked-by: Oleg Verych
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • If cdev_add() fails there is no good reason to call cdev_del().

    Signed-off-by: Rolf Eike Beer
    Cc: Alessandro Zummo
    Cc: Dmitry Torokhov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rolf Eike Beer