Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Oct 2008 10:36:09 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Ed Schouten <ed@80386.nl>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r184208 - head/sys/dev/uart
Message-ID:  <200810241036.10595.jhb@freebsd.org>
In-Reply-To: <20081024045012.GD6808@hoeg.nl>
References:  <200810231911.m9NJBisd064280@svn.freebsd.org> <200810231555.06892.jhb@freebsd.org> <20081024045012.GD6808@hoeg.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 24 October 2008 12:50:12 am Ed Schouten wrote:
> * John Baldwin <jhb@freebsd.org> wrote:
> > Perhaps have tty drivers sleep in detach until the tty is completely gone?  
> > Either that or free the unit number in the tty layer when the tty is 
> > abandoned.
> 
> Well, I could add a routine to the TTY layer that does that. The reason
> why the TTY layer is a little `lazy' with deallocating TTY unit numbers,
> is because I want to be absolutely sure processes agree they do not use
> the TTY (device name) anymore.
> 
> I'll see if I can add a sleepable tty_gone() routine one of these days.

I think what you want then is for the detach() routines to block until the tty 
is fully drained.  This is similar to what we do for other places 
(ether_ifdetach() is supposed to sleep until the ifnet is completely 
unreferenced from userland for example (it may not fully ensure this yet, but 
that is the way the driver should use the API, the driver can't possibly 
close that sort of race in its own code).

Actually, detach() _needs_ to block because when you kldunload a driver, once 
detach() returns the code segment for that module can be unmapped.  If there 
are threads in that driver's tty routines still then you can get kernel page 
faults.

-- 
John Baldwin



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