Subject: Re: IPL_LOCK oddity
To: Thor Lancelot Simon <tls@rek.tjls.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 08/24/2006 16:40:53
--nVMJ2NtxeReIH9PS
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Aug 24, 2006 at 02:04:23PM -0400, Thor Lancelot Simon wrote:
> On Thu, Aug 24, 2006 at 10:55:42AM -0700, Bill Studenmund wrote:
> > On Thu, Aug 24, 2006 at 09:38:11AM +0200, Manuel Bouyer wrote:
> >=20
> > That would probably be the best solution. I'd rather not have spllock()=
=20
> > block serial interrupts.
> >=20
> > The one problem is that the lock that the com driver takes for interrup=
ts=20
> > is also the one it takes for normal uses. The latter uses may want to s=
tay=20
> > with normal spin locks. If so, that'd be an arguement against changing=
=20
> > serial drivers to use __cpu_simple_lock.
>=20
> I think it makes more sense to think of the code that shuffles bytes out
> of the hardware FIFO and into the driver proper as, well... a separate
> entity, like the old "pseudo-DMA" routines in VAX drivers.  I don't see
> why _these_ routines using __cpu_simple_lock should imply that serial
> drivers in general (or other code in the same serial driver) should do
> so.

The only reasons I can see are:

1) The code only uses one lock, so this lock has to be safe for >=20
IPL_LOCK, which has some tradeoffs (i.e. we lose everything we gain by=20
having locks that work at IPL_LOCK).

The simple fix is to have two different locks, but that leads to...

2) Some of the times when we grab the lock on the softc, we want to lock
access to the softc. i.e. we want to do things like process characters
from the silo, check for modem status, etc. It's ok for the pseudo-DMA
routines to run durring this. Other times, though, we want to touch the
hardware. For the latter times, we want to touch the chip, and for that we=
=20
need to block the pseudo-DMA routines.

This too isn't hard to work out, we just have to audit to make sure we do=
=20
it right. Having one spinlock for most of the softc, which say runs at=20
either splsofttty or spltty, and another spinlock that runs at splserial=20
is probably the best way to go.

Take care,

Bill

--nVMJ2NtxeReIH9PS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFE7jkFWz+3JHUci9cRAhpfAJwOD16jG6ifJ4pEjq7RIm8pf0dvrgCfRkpa
6f3LLn4HXw/OI4IG3Qza8MU=
=Wyf8
-----END PGP SIGNATURE-----

--nVMJ2NtxeReIH9PS--