From owner-freebsd-hackers Thu Jan 4 23:21:52 2001 From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 23:21:49 2001 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mass.osd.bsdi.com (dhcp244.osd.bsdi.com [204.216.28.244]) by hub.freebsd.org (Postfix) with ESMTP id 9F03137B400 for ; Thu, 4 Jan 2001 23:21:49 -0800 (PST) Received: from mass.osd.bsdi.com (localhost [127.0.0.1]) by mass.osd.bsdi.com (8.11.1/8.11.1) with ESMTP id f057YSt03677; Thu, 4 Jan 2001 23:34:29 -0800 (PST) (envelope-from msmith@mass.osd.bsdi.com) Message-Id: <200101050734.f057YSt03677@mass.osd.bsdi.com> X-Mailer: exmh version 2.1.1 10/15/1999 To: "Matthew C. Forman" Cc: freebsd-hackers@freebsd.org Subject: Re: Allocating an IRQ on PCI In-reply-to: Your message of "Thu, 04 Jan 2001 15:59:57 GMT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 04 Jan 2001 23:34:28 -0800 From: Mike Smith Sender: msmith@mass.osd.bsdi.com Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > I want to allocate an IRQ for a PCI device driver. Normally this is easy > enough, since the BIOS would reserve it for me, then I would just have to > bus_alloc_resource and not even care which IRQ line it's using. This is how it works in -current. > Thing is, here the BIOS hasn't allocated an IRQ, so I'll need to > bus_set_resource in my probe to get one. To complicate matters, the > device's interrupt generator is pretty flexible, and can generate an > interrupt on (almost) any IRQ line. I have to tell it which IRQ to use > when I know which one has been allocated. Er, no, PCI interrupts don't work like that. A PCI device has four interrupt pins (A-D) which are routed in an opaque fashion to up to four different interrupt lines. You can (sometimes) tell the device which pin to generate an interrupt on, but it will normally tell *you*. > 1. Hardwire it, by using bus_set_resource with a specific IRQ. This isn't > nice, as it'll fail if someone else's setup is already using the one I > pick (or some other device attach will fail later on). This is guarateed to fail most of the time. > 2. Find out what IRQs are free and set and allocate one of those. This is > nicer than 1), but then if some poor device attach later on in boot was > expecting to use that IRQ, it'll break. This is also guaranteed to fail most of the time, as it doesn't matter which interrupts are "free" (you may actually be routed to an interrupt that's already in use somewhere else). > Does anyone know of a sensible & portable way around this? Perhaps IRQ > sharing could save me in some way... Look at the PCI interrupt routing code I committed to -current. Backporting it to -stable should be pretty simple (it will get harder as the code diverges more). -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] V I C T O R Y N O T V E N G E A N C E To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message