From owner-freebsd-hackers Sat Nov 30 21:42:24 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id VAA02264 for hackers-outgoing; Sat, 30 Nov 1996 21:42:24 -0800 (PST) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id VAA02257 for ; Sat, 30 Nov 1996 21:42:14 -0800 (PST) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.3/8.6.9) id QAA10354; Sun, 1 Dec 1996 16:36:17 +1100 Date: Sun, 1 Dec 1996 16:36:17 +1100 From: Bruce Evans Message-Id: <199612010536.QAA10354@godzilla.zeta.org.au> To: durian@plutotech.com, freebsd-hackers@FreeBSD.org Subject: Re: LKM driver question / patch Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > First of all I have a patch for kern/kern_conf.c. Without this, you >get a panic when you try to unload a driver module: Thanks. I knew that unloading the joy and qcam modules was broken. > Second, I have a question on writing a lkm driver. What is the proper >way to use ISA an lkm driver with interrupts? The existing drivers in No one knows the details yet :-[. We will know when you've finished :-). >sys/i386/isa don't use interrupt, or only use them in conjuction with >other existing hardware. > I've added the: > INTRMASK > register_intr > INTREN >code sequence as found in isa.c to my driver load routine, but See eisa_reg_intr() in eisaconf.c. The isa code is mouldier and all the current code only good enough at boot time. It's important to call update_intr() masks somewhere (eisa_reg_intr() does this). If you are loading a tty driver and PPP or SLIP is enabled, then it is important to OR tty_imask into net_imask. See ppp_tty.c and isa.c. The initializations there only work at ppp attach time (for PPP) and at boot time (for SLIP). They should probably be done in update_intr_masks(), and update_intr_masks() should probably be called from register_intr(). register_intr() only returns EBUSY when the interrupt is already assigned to something _other than_ isa_strayintr, i.e., when it really is busy. > Also, how should I unregister the interrupt when I unload the driver? >I see code in isa.c that does: > INTRDIS > unregister_intr > INTRUNMASK >but it fails too (probably because it never got registered properly). >In fact it ends up masking my SCSI interrupts and I get aborts and >must reboot. See eisa_release_intr() in eisaconf.c. I think this doesn't actually work. update_intr_masks() needs some changes. Note that it ORs bits into the current masks. Thus it is no use releasing interrupts. It can't simply clear all the masks so that they get rebuilt from scratch since some of the masks are initialized to nonzero (clk_imask, stat_imask, npx0_imask at least). Bruce