Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Aug 1998 17:56:39 -0600
From:      chanders@timing.com (Craig Anderson)
To:        Mike Smith <mike@smith.net.au>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Device driver synchronization with spl? 
Message-ID:  <199808032356.RAA02513@count.timing.com>
In-Reply-To: Your message of "Mon, 03 Aug 1998 16:22:06 PDT." <199808032322.QAA01662@dingo.cdrom.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks, I did not see man spl(9) yet.  Another question.  The driver is not
configured it installed as an LKM.  Is spltty() still appropriate?
Help again!

> > 
> > I would like an explanation of how the spl functions are used to
> > sychronize a driver that uses interrupts.  Code fragments from a
> > driver I'm working on are at the end of the messages.  The interrupt
> > handler is installed on irq 11.
> 
> 'man 9 spl' on a -current system contains a fairly succinct answer.
> 
> > Here are my assumptions (guesses) so far.
> > 
> > 1) gt401read() calls splgt401() to add a mask for irq 11.
> 
> No.  I don't believe that creating new spl's is trivial anymore.  In 
> the first instance, I would simply add the 'tty' keyword to your 
> device's ISA configuration entry (see eg. the 'sio' entries for 
> examples).
> 
> > 2) After splgt401() the interrupt function gt401intr will not run.
> >    This prevents a wakeup being lost between checking the data count
> >    and sleeping for data to show up.
> 
> Not exactly.  After spltty(), should an interrupt masked by the 'tty' 
> mask occur, it will be remembered, and when the mask is cleared the 
> interrupt handler will be run.
> 
> > 3) The tsleep() causes another process to run with an interrupt
> >    mask that will allow gt401intr() to run.
> 
> A call to tsleep() will put the current process to sleep, preserving 
> the current interrupt mask.  When a new process is selected to run, the 
> mask is set to that for the new process.
> 
> > 4) irq 11 happens and the handler gt401intr() is run.
> 
> Yes, although the interrupt may have happened during the peroid when 
> the interrupt was masked.
> 
> > 5) gt401intr() updates the data count and issues the wakeup.
> 
> ... and returns.  The woken process won't actually run until the 
> interrupt handler has returned.
> 
> > 6) gt401read() returns from the tsleep() and sees that there is now data.
> 
> It should check to see if there is data; it may have been woken for
> other reasons (timeout, signal delivery, etc.).
> 
> > 
> > Some questions.
> > 1) Is my understanding of the spl usage good enough?
> 
> Geting there. 8)
> 
> > 2) If this is correct, what should splgt401() look like?
> 
> Don't complicate things yet; stick with spltty().
> 
> >    My guess here, after looking at /usr/src/sys/i386/include/spl.h is
> >      GENSPL(splbio, cpl |= some_mask)
> >    where some_mask is appropriate for irq11.  If this is right what should
> >    some_mask be?
> 
> spl.h has been obsoleted in -current, you can find it in i386/isa/
> ipl_funcs.c.  Implementing a private interrupt mask is probably not a
> useful thing to do, as it's more work that necessary.
> 
> -- 
> \\  Sometimes you're ahead,       \\  Mike Smith
> \\  sometimes you're behind.      \\  mike@smith.net.au
> \\  The race is long, and in the  \\  msmith@freebsd.org
> \\  end it's only with yourself.  \\  msmith@cdrom.com
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



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