Subject: port-sparc/24734: zstty: TIOCMGET always shows DCD if CLOCAL set
To: None <gnats-bugs@gnats.netbsd.org>
From: Tom Yu <tlyu@mit.edu>
List: netbsd-bugs
Date: 03/10/2004 12:46:29
>Number:         24734
>Category:       port-sparc
>Synopsis:       zstty: TIOCMGET always shows DCD if CLOCAL set
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 10 17:47:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Tom Yu
>Release:        NetBSD 1.6.2_STABLE (built from cvs ~ 20040305)
>Organization:
>Environment:
System: NetBSD supernova.triskelion.com 1.6.2_STABLE NetBSD 1.6.2_STABLE (GENERIC) #0: Sun Mar 7 18:37:26 EST 2004 root@supernova.triskelion.com:/u1/NetBSD-release-1-6/obj/sys/arch/sparc/compile/GENERIC sparc
Architecture: sparc
Machine: sparc

excerpt from dmesg.boot:
NetBSD 1.6.2_STABLE (GENERIC) #0: Sun Mar  7 18:37:26 EST 2004
    root@supernova.triskelion.com:/u1/NetBSD-release-1-6/obj/sys/arch/sparc/compile/GENERIC
total memory = 97832 KB
avail memory = 87008 KB
using 896 buffers containing 4992 KB of memory
bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@3,0
mainbus0 (root): SUNW,SPARCstation-5
cpu0 at mainbus0DVMA coherent : MB86907 @ 170 MHz, on-chip FPU
cpu0: 16K instruction (32 b/l), 16K data (32 b/l), 512K external (32 b/l): cache enabled
obio0 at mainbus0
clock0 at obio0 slot 0 offset 0x200000: mk48t08: hostid 808a73e3
timer0 at obio0 slot 0 offset 0xd00000: delay constant 82
zs0 at obio0 slot 0 offset 0x100000 level 12 softpri 6
zstty0 at zs0 channel 0 (console i/o)
zstty1 at zs0 channel 1
zs1 at obio0 slot 0 offset 0x0 level 12 softpri 6
kbd0 at zs1 channel 0: baud rate 1200
ms0 at zs1 channel 1: baud rate 1200
>Description:

In the zstty driver, if CLOCAL is set on a tty, the TIOCMGET ioctl
erroneously shows DCD high when the hardware DCD line is not high.

>How-To-Repeat:

Install the ups-nut package (pkgsrc from cvs ~ 20040305) on a
SPARCstation 5.  Attach an APC Back-UPS Pro 1100 with 940-0020C
"simple signaling" cable (and 9-to-25-pin adaptor) to ttyb and
configure ups-nut appropriately (genericups driver, upstype=2).  Start
upsdriver and upsd from the rc.d scripts.  Observe that upsd always
reports low-battery condition (which is signaled by DCD) when queried,
despite lack of DCD on the hardware line (verified by LEDs on a RS-232
line tester/sniffer in series).  This behavior does not occur on i386.

Note: the ups-nut drivers set CLOCAL on a tty when opening it.
Erroneous reporting of DCD status confirmed by calling the ioctl from
perl.

>Fix:

Workaround, probably only useful for ups-nut: clearing CLOCAL on the
ups tty using stty -clocal causes upsd to correctly report lack of
low-battery condition.  (I have not confirmed whether TIOCMGET
correctly reports a DCD high on the hardware line when CLOCAL is
clear.)
>Release-Note:
>Audit-Trail:
>Unformatted: