When running the kernel from gentoo-sources-2.6.17-r7, the applications using the Specialix SX Multiport serial card work as expected. After updating the system to kernel 2.6.19-r5 the applications do not work. The messages log shows lines like "Mar 12 10:08:06 dev1 sx: unsupported baud rate: 1200342922." and the application does not see incoming characters. If I boot using kernel 2.6.17-r7, everything works. If I boot from 2.6.19-r5 I get the above, and if (as an experiment) I try the unstable 2.6.0-gentoo kernel, it does not even detect the card. I have tried configuring the driver as built into the kernel and as a module. I have tried installing the unstable linux-headers-2.6.19.2-r2 and rebuilding glibc and the applications. But the effect is the same - it all works if I boot 2.6.17-r7 but not 2.6.19-r5. Portage 2.1.2-r9 (default-linux/x86/2006.1/server, gcc-4.1.1, glibc-2.5-r0, 2.6.19-gentoo-r5 i686) ================================================================= System uname: 2.6.19-gentoo-r5 i686 Intel(R) Xeon(TM) CPU 3.20GHz Gentoo Base System release 1.12.9 Timestamp of tree: Tue, 06 Mar 2007 13:00:01 +0000 distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] ccache version 2.3 [disabled] dev-lang/python: 2.4.3-r4 dev-python/pycrypto: 2.0.1-r5 dev-util/ccache: 2.3 sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.61 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10 sys-devel/binutils: 2.16.1-r3 sys-devel/gcc-config: 1.3.14 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.19.2-r2 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-O2 -pipe -march=pentium4 -ggdb" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config" CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo" CXXFLAGS="-O2 -pipe -march=pentium4 -ggdb" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig distlocks getbinpkg metadata-transfer sandbox sfperms splitdebug strict" GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo" LANG="en_GB.UTF-8" LC_ALL="en_GB.UTF-8" PKGDIR="/usr/portage/packages" PORTAGE_RSYNC_EXTRA_OPTS="--exclude-from=/etc/portage/rsync_excludes" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" SYNC="rsync://rsync.webwayone.co.uk/gentoo-portage" USE="apache2 berkdb bitmap-fonts bzip2 cli cracklib crypt doc examples fortran gdbm gpm iconv ipv6 isdnlog libg++ logrotate mailwrapper midi mmx ncurses nls nptl nptlonly pam pcre perl postgres ppds pppd python readline reflection session snmp spl sse sse2 ssl symlink tcpd threads truetype truetype-fonts type1-fonts unicode x86 xml xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="radeon fbdev" Unset: CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LDFLAGS, LINGUAS, MAKEOPTS, PORTDIR_OVERLAY
Created attachment 113057 [details] Kernel config for working 2.6.17-r7
Created attachment 113058 [details] Kernel config for failing 2.6.19-r5
Further investigation has shown 1) The same problem occurs with vanilla-sources-2.6.19-r5 2) The ports are actually working but at 9600bps instead of the configured 115200bps. Strace of one of the applications shows that the IOCTL is called with a B115200 value and that the syscall returns a 0 result code and stty shows them as configured for 115200.
If you're really keen and have some time on your hands you can track down the exact commit which introduced the bug with: http://www.reactivated.net/weblog/archives/2006/01/using-git-bisect-to-find-buggy-kernel-patches/ It's actually fairly obvious that one commit from a certain small group of patches would have added this bug (SX had a series of cleanups merged for this release), but I don't have time to start formatting the patches right now.
With a bit of looking around and judicious use of printk, I think I have found the problem in gentoo-sources-2.6.19-r5. In drivers/char/generic_serial.c in routine gs_set_termios(), it calls tty_get_baud_rate() and then uses the return value to index into the gs_baudrates array. The problem being that tty_get_baud_rate() returns the actual baud rate but gs_set_termios() is treating the result as an index to the baud rate table. Commenting out the line baudrate = gs_baudrates[baudrate]; and just using the result of tty_get_baud_rate() seems to have fixed the problem and all is working properly now.
Thanks for digging into this, that is indeed the correct fix.
patch accepted upstream
fixed in Linux 2.6.20.5 / genpatches-2.6.20-6 / gentoo-sources-2.6.20-r5