From owner-freebsd-arch Mon Jul 17 0: 0:53 2000 Delivered-To: freebsd-arch@freebsd.org Received: from wantadilla.lemis.com (wantadilla.lemis.com [192.109.197.80]) by hub.freebsd.org (Postfix) with ESMTP id 65F7337B7B4; Mon, 17 Jul 2000 00:00:43 -0700 (PDT) (envelope-from grog@wantadilla.lemis.com) Received: (from grog@localhost) by wantadilla.lemis.com (8.9.3/8.9.3) id QAA22205; Mon, 17 Jul 2000 16:30:38 +0930 (CST) (envelope-from grog) Date: Mon, 17 Jul 2000 16:30:38 +0930 From: Greg Lehey To: arch@FreeBSD.org, smp@FreeBSD.org Subject: Tidying up the interrupt registration process Message-ID: <20000717163038.J26231@wantadilla.lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.lemis.com/~grog X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I think I now understand how drivers register interrupts with newbus, and it seems that some tidying up is in order. Currently the handlers call BUS_SETUP_INTR with flags intr_type (defined in sys/bus.h): enum intr_type { INTR_TYPE_TTY = 1, INTR_TYPE_BIO = 2, INTR_TYPE_NET = 4, INTR_TYPE_CAM = 8, INTR_TYPE_MISC = 16, INTR_TYPE_FAST = 128 }; At least in nexus_setup_intr (sys/i386/i386/nexus.c), and possibly elsewhere as well, these flags get converted into an interrupt mask and flags for struct intrec, defined in sys/i386/isa/intr_machdep.h: #define INTR_FAST 0x00000001 /* fast interrupt handler */ #define INTR_EXCL 0x00010000 /* exclusive interrupt */ INTR_EXCL comes from the r_flags field in struct resource (sys/rman.h), where it is the complement of RF_SHAREABLE: #define RF_ALLOCATED 0x0001 /* resource has been reserved */ #define RF_ACTIVE 0x0002 /* resource allocation has been activated */ #define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ #define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */ #define RF_WANTED 0x0010 /* somebody is waiting for this resource */ #define RF_FIRSTSHARE 0x0020 /* first in sharing list */ These flag bits are all lightly used, and there's confusing duplication of functionality. For example, in nexus_setup_intr we have: case (INTR_TYPE_TTY | INTR_TYPE_FAST): mask = &tty_imask; icflags |= INTR_FAST; In sys/pci/pci_compat.c we have if (intflags & INTR_FAST) flags |= INTR_TYPE_FAST; It seems to me that we should define the flags to the *setup_intr functions to match those in struct intrec. Probably the RF_* flags are different enough in purpose that we shouldn't do the same thing there. In addition, these flags will have to change a lot in the change to threaded interrupts. First, I intend to add two additional flags to struct intrec: #define INTR_HEAVY 0x00000002 /* heavyweight interrupt process */ #define INTR_LIGHT 0x00000004 /* light weight interrupt thread */ #define INTR_THREADED (INTR_LIGHT | INTR_HEAVY) /* any kind of interrupt thread */ This will allow us to let traditional interrupts, lightweight threads and heavyweight processes to coexist; when the change is complete, we may be able to let them go away. The INTR_TYPE_TTY and friends are a different issue; at the moment I don't know if they're enough, but probably we should replace them with a process priority. I'd be grateful for any thoughts on these subjects. About fast interrupts, which currently seem to be used only by the sio driver: they perform their entire work before reenabling interrupts, and it's possible that we can keep them like that, though I haven't looked at the code yet. Does anybody know any reason why we should convert them to threaded interrupts? Greg -- Finger grog@lemis.com for PGP public key See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message