From owner-freebsd-hackers Mon Aug 3 15:15:03 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA20738 for freebsd-hackers-outgoing; Mon, 3 Aug 1998 15:15:03 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from timingpdc.timing.com (timingpdc.timing.com [208.203.137.194]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA20729 for ; Mon, 3 Aug 1998 15:15:01 -0700 (PDT) (envelope-from chanders@timing.com) Received: from count.timing.com ([208.203.137.222]) by timingpdc.timing.com (Post.Office MTA v3.1.2 release (PO205-101c) ID# 103-49575U100L2S100) with ESMTP id AAA93 for ; Mon, 3 Aug 1998 16:15:52 -0600 Received: (from chanders@localhost) by count.timing.com (8.8.7/8.8.7) id QAA02199 for freebsd-hackers@FreeBSD.ORG; Mon, 3 Aug 1998 16:14:41 -0600 (MDT) (envelope-from chanders) Date: Mon, 3 Aug 1998 16:14:41 -0600 (MDT) From: chanders@timing.com (Craig Anderson) Message-Id: <199808032214.QAA02199@count.timing.com> To: freebsd-hackers@FreeBSD.ORG Subject: Device driver synchronization with spl? Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. Here are my assumptions (guesses) so far. 1) gt401read() calls splgt401() to add a mask for irq 11. 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. 3) The tsleep() causes another process to run with an interrupt mask that will allow gt401intr() to run. 4) irq 11 happens and the handler gt401intr() is run. 5) gt401intr() updates the data count and issues the wakeup. 6) gt401read() returns from the tsleep() and sees that there is now data. Some questions. 1) Is my understanding of the spl usage good enough? 2) If this is correct, what should splgt401() look like? 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? driver code fragments --------------------- static int gt401read (dev_t dev, struct uio* uio, int flag) { ... s = splgt401(); while (gt401Unit[0].rbuf_count == 0) { status = tsleep(gt401Unit[0].sleep_address, PRIBIO | PCATCH, "gt401", i_timeout); if (!((status == 0) || (status == EWOULDBLOCK))) { splx(s); return(status); } } splx(s); void gt401intr(int unit) { ... ++gt401Unit[0].rbuf_count; ... wakeup (gt401Unit[0].sleep_address); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message