Subject: is TIOCMGET supposed to reflect reality?
To: None <tech-kern@netbsd.org>
From: Tom Yu <tlyu@mit.edu>
List: tech-kern
Date: 09/26/2004 18:12:59
I filed a bug [port-sparc/24734] earlier about TIOCMGET showing
erroneous modem status line state in the zs driver.  I have done a
little more digging since then.  Various things in z8530tty.c call
zs_maskintr() to set interrupt-enable bits in WR15.  Unfortunately,
zs_maskintr() appears to only enable DCD and CTS interrupts when the
corrresponding masks are set in cs->cs_rr0_cts or
cs->cs_rr0_dcd.

TIOCMGET only queries the cached state of RR0 in cs->cs_rr0, which is
updated by zstty_stint().  If CLOCAL is set, the DCD interrupt won't
be enabled, and the cached state of DCD returned by TIOCMGET won't
reflect the actual line state if there haven't been any status
interrupts generated by that serial port.  Likewise, if a CTS-based
flow control method isn't enabled, the state of CTS returned by
TIOCMGET won't reflect the actual line state.  Some experimentation
with jumper wires, LED indicators, and the serial port on a SS5 seem
to confirm this.

Is there any reason not to always enable DCD and CTS interrupts?  I
gather that there might be performance reasons for disabling DCD and
CTS interrupts, but if the interrupts are disabled, TIOCMGET would
have to explicitly read RR0 to get the correct state of the modem
status lines.

---Tom