From owner-freebsd-acpi@FreeBSD.ORG Wed Jun 2 08:04:27 2004 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADF4D16A4CE for ; Wed, 2 Jun 2004 08:04:27 -0700 (PDT) Received: from mail2.speakeasy.net (mail2.speakeasy.net [216.254.0.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7AB9C43D2F for ; Wed, 2 Jun 2004 08:04:27 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 28988 invoked from network); 2 Jun 2004 15:04:26 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 2 Jun 2004 15:04:26 -0000 Received: from 10.50.41.233 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i52F4E7i064970; Wed, 2 Jun 2004 11:04:17 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-acpi@FreeBSD.org Date: Wed, 2 Jun 2004 11:04:59 -0400 User-Agent: KMail/1.6 References: <20040601141424.I29932@root.org> <20040601221109.GA21063@ns1.xcllnt.net> <20040601.163316.88476133.imp@bsdimp.com> In-Reply-To: <20040601.163316.88476133.imp@bsdimp.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200406021104.59860.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx Subject: Re: Patch: Defer bus_config_intr() until bus_alloc_resource().. X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2004 15:04:27 -0000 On Tuesday 01 June 2004 06:33 pm, M. Warner Losh wrote: > In message: <20040601221109.GA21063@ns1.xcllnt.net> > > Marcel Moolenaar writes: > : On Tue, Jun 01, 2004 at 05:42:57PM -0400, John Baldwin wrote: > : > > > > > I need the patch below in order to turn on bus_config_intr() > : > > > > > when using the I/O APICs. > : > : *snip* > : > : > > > > I appreciate what you're trying to do but I don't like this > : > > > > approach. > : > : *snip* > : > : > > > Well, arguably it exposes an improper layering violation when > : > > > bus_config_intr() was added. > : > : *snip* > : > : > > I still don't like this. > : > : *snip* > : > : > FreeBSD has no format for this and I don't really have time to add > : > multiple resource types (which is what ACPI does, and probably what we > : > will need to do eventually) to struct resource. > : > : Ok, let's relax for a minute. Clearly, the addition of bus_config_intr() > : was done in a biggest-bang-for-the-buck approach and I think we can > : assume for now that it's there in a way that isn't easily extensible. > : > : So, the root problem now is that we need to consume the ACPI info in > : a way that makes it available for later use, i.e., when we actually > : allocate the IRQ resource. The solution needs to be simple so that > : jhb@ can close the immediate problem and it should also be a step in > : the right direction, or at least not a step in the opposite direction, > : so that njl@ doesn't get cornered by it at some later time. > : > : Let me give the numbers: > : o We need 2 bits for the polarity, > : o We need 2 bits for the trigger mode, > : o r_flags is 32 bits of which only 16 are in use. > : > : Can we not stick the IRQ properties in r_flags, just like we > : stick the alignment properties there, remove bus_config_intr() > : and make sure the MD backend queries the flags for polarity and > : trigger (0 values will mean "default" and thus preserve backward > : compatibility)? > : > : This change should only affect 2 places: the place where we set > : the resource and the place where we actually install the interrupt > : and its handler. It's roughly in line with what jhb@ wants to achieve > : and I think it removes the code that njl@ is objecting to the most, > : right? > : > : Oh, and it's not intended to be pretty. > > I like it. Or should I say "Given that we're looking for an > evolutionary change to shoe horn this in, I think it is better than > any of the other ugly kludges." The only PITA is that when we route PCI interrupts we have to push the trigger/polarity back to the alloc_resource() that called route_interrupt(). I guess we could just ignore ACPIs settings and hardcode level/low for PCI interrupts. What I was thinking about on the way home, btw, was to have struct resource be a base class sort of for resoures, and to have an irq_resource, mem_resource, dma_resource, etc. Each class would have an alloc() function that returns a template that is handed to resource_list_alloc() so that you would do something like: struct resource *res; res = irq_resource_alloc(TRIGGER_LEVEL, POLARITY_LOW); bus_alloc_resource(..., res); And bus_alloc_resource() just fills out the common struct resource fields. But really alloc_resource() should be overridden per type as well so that you could make 'prefetchable' and 'alignment' properties of just memory resources, but both of those factor into the alloc() algorithm. I guess we just need a much better resource abstraction. *sigh* -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org