kern/155752: tcdrain(3) does not work with uart(4) driver

Poul-Henning Kamp phk at critter.freebsd.dk
Mon Mar 21 15:40:02 UTC 2011


>Number:         155752
>Category:       kern
>Synopsis:       tcdrain(3) does not work with uart(4) driver
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 21 15:40:01 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Poul-Henning Kamp
>Release:        FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
System: FreeBSD critter.freebsd.dk 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r218760M: Thu Feb 17 06:36:02 UTC 2011 root at critter.freebsd.dk:/usr/obj/freebsd/head/sys/CRITTER amd64

	Also affected: FreeBSD 8.1-RELEASE

>Description:

	With the change from sio(4) to uart(4), tcdrain(3) broke.

	Now tcdrain(3) only tests if the characters have been
	delivered to the uart(4) subdriver, it does not wait for
	them to have actually been sent on the wire.

	This prevents half-duplex communications with CTS/RTS from
	working.

	This contradicts both our own manpage and The Open Group
	Standards.

>How-To-Repeat:

	#define AZ(x) assert ((x) == 0)
	int j, fd;

	fd = open(),
 	makeraw() etc.
	set speed 300BPS

	j = TIOCM_RTS;
        AZ(ioctl(fd, TIOCMBIS, &j));
        assert(3 == write(fd, "FOO", 3))
        AZ(tcdrain(fd));
        AZ(ioctl(fd, TIOCMBIC, &j));

	Observe that RTS flips high + low, long before the three
	characters make it out through the TXD pin.

>Fix:

	There don't seem to be a newbus uart(4) method to ask or
	wait until all transmitted characters have been sent.

	One is obviously necessary.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list