Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2011 15:15:08 GMT
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/155752: tcdrain(3) does not work with uart(4) driver
Message-ID:  <201103211515.p2LFF8Ca027067@critter.freebsd.dk>
Resent-Message-ID: <201103211540.p2LFe2wW036731@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103211515.p2LFF8Ca027067>