# real time clock runtime errors

## harryr

I thought interrupt '8' was for clock?

Mine seems to be interrupt '0' and 'LOC'.

Why does rtc module complain about inappropriate

ioctl when genrtc doesn't?

I had HPET stuff in kernel and recompiled without

any HPET since web resources said that could be

the problem, but this didn't help.

How can I fix?

Code snippit says it all (I think).

```
eagle ~ # ./rtctest

                        RTC Driver Test Example.

ioctl: Inappropriate ioctl for device

eagle ~ # rmmod rtc

eagle ~ # modprobe genrtc

eagle ~ # ./rtctest

                        RTC Driver Test Example.

Counting 5 update (1/sec) interrupts from reading /dev/rtc: 1 2 3 4 5

Again, from using select(2) on /dev/rtc: 1 2 3 4 5

Current RTC date/time is 24-10-2005, 20:42:24.

ioctl ALM_SET: Invalid argument

eagle ~ # cat /proc/interrupts 

           CPU0       

  0:    1350015    IO-APIC-edge  timer

  1:       1048    IO-APIC-edge  i8042

  7:          0    IO-APIC-edge  parport0

  9:         82   IO-APIC-level  acpi

 12:        428    IO-APIC-edge  i8042

 14:       4490    IO-APIC-edge  ide0

 15:      11919    IO-APIC-edge  ide1

 17:          0   IO-APIC-level  SiS SI7012

 18:       6396   IO-APIC-level  eth0

NMI:          0 

LOC:    1349925 

ERR:          0

MIS:          0

eagle ~ # uname -a

Linux eagle.ssd.fsi.com 2.6.13-gentoo-r3 #4 Mon Oct 24 15:16:59 CDT 2005 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux
```

----------

## harryr

Maybe I didn't provide enough information?

Here is more:

emerge --info

Portage 2.0.51.22-r3 (default-linux/x86/2005.0, gcc-3.3.6, glibc-2.3.5-r2, 2.6.13-gentoo-r3 i686)

=================================================================

System uname: 2.6.13-gentoo-r3 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz

Gentoo Base System version 1.6.13

ccache version 2.3 [disabled]

dev-lang/python:     2.3.5-r2, 2.4.2

sys-apps/sandbox:    1.2.12

sys-devel/autoconf:  2.13, 2.59-r6

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1

sys-devel/binutils:  2.15.92.0.2-r10

sys-devel/libtool:   1.5.20

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=pentium4 -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/shar\

e/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"

CXXFLAGS="-O2 -march=pentium4 -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks sandbox sfperms strict"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="x86 X a52 aac acpi alsa apm arts avi berkdb bitmap-fonts bmp calendar cdr cpdflib crpyt crypt cscope cups curl dga divx4linux dv dvd dvdr dvdread eds emacs emacs-w3 emboss encode esd ex\

if fam flac foomaticdb fortran ftp gb gdbm gif gnome gphoto2 gpm gps gstreamer gtk gtk2 gtkhtml hal howl imagemagick imlib ipv6 jpeg kerberos krb4 lesstif libg++ libwww lm_sensors mad mikmod\

 mime motif mozilla mp3 mpeg mysql mysqli ncurses nls ogg oggvorbis openal opengl oss pam pcmcia pcre pdflib perl plotutils png pnp posix ppds python quicktime readline samba sdl shared shar\

edmem simplexml sndfile sockets sox spell ssl svga tcpd tiff truetype truetype-fonts type1-fonts udev usb v4l vcd vorbis wifi xine xml xml2 xmms xv xvid zlib userland_GNU kernel_linux elibc_\

glibc"

Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTDIR_OVERLAY

----------

## harryr

I'm doing more investigating.

The rtctest.c example code was snipped from rtc.txt in kernel

documentation tree.  It has this line:

```
#include <linux/rtc.h>
```

Inside this header file I see this definition:

```
#define RTC_UIE_ON      _IO('p', 0x03)  /* Update int. enable on        */
```

I modified the section of rtctest.c with this to totally confirm the

spot of the error:

```
/* Turn on update interrupts (one per second) */

retval = ioctl(fd, RTC_UIE_ON, 0);

if (retval == -1) {

  fprintf(stderr, "RTC_UIE_ON ioctl broken\n");

        perror("ioctl");

        exit(errno);

        }
```

Since rtctest.c compiles and links with no errors I presume RTC_UIE_ON is well

defined according to the rtc.h header file.

But, with rtc module loaded in I get

                        RTC Driver Test Example.

RTC_UIE_ON ioctl broken

ioctl: Inappropriate ioctl for device

This tells me that the rtc module (driver) is broken.

Is this a gentoo problem or is it an issue with the 2.6.13 kernel?

----------

## harryr

Another piece of the puzzle.

Over the weekend, I pulled down the 2.6.14 kernel from 

www.kernel.org compiled it and booted it up.

The rtctest program runs without error.

Things that make me go Hmmmmmm.

----------

## harryr

Newer kernel and different kernel configuration.  One or the other or maybe

even both? solved my rtc problem.  Here is other relevant info:

# cat /proc/interrupts 

           CPU0       

  0:    9139638    IO-APIC-edge  timer

  1:         15    IO-APIC-edge  i8042

  7:          0    IO-APIC-edge  parport0

  8:      10141    IO-APIC-edge  rtc

  9:      10518   IO-APIC-level  acpi

 12:        116    IO-APIC-edge  i8042

 14:       8672    IO-APIC-edge  ide0

 15:      80045    IO-APIC-edge  ide1

 16:      48679   IO-APIC-level  yenta, pcnet_cs

 17:     182720   IO-APIC-level  SiS SI7012, SiS SI7013 Modem

 18:      21296   IO-APIC-level  ohci_hcd:usb1

 19:          0   IO-APIC-level  ohci_hcd:usb2

 20:          0   IO-APIC-level  ohci_hcd:usb3

 21:          2   IO-APIC-level  ehci_hcd:usb4

 23:     756615   IO-APIC-level  nvidia

NMI:          0 

LOC:    9140720 

ERR:          0

MIS:          0

# uname -a

Linux eagle.ssd.fsi.com 2.6.14-gentoo-r4 #5 PREEMPT Mon Dec 19 12:39:13 CST 2005 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux

----------

## VeneficusAcerbus

I was having pretty much the same problem [except for me aireplay-ng would keep saying "ioctl(RTC_IRQP_SET) failed: Inappropriate ioctl for device"]. Thanks mostly to your posts, I've determined that, at least for me, the problem is with SMP being enabled in the kernel - I also have a 2.8GHz P4 - with hyperthreading.

----------

## julot

I had the same problem on a Intel 915 motherboard.

Disappeared when update the Bios to the ultimate version,

I think that it was a buggy acpi implementation or a ancient microcode,

Intel 915GAV.

Pentium 4 600 with HT. 3.0 Ghz.

----------

