Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Jun 2004 13:58:17 -0400
From:      John Baldwin <jhb@FreeBSD.org>
To:        freebsd-acpi@FreeBSD.org
Subject:   Re: Patch: Defer bus_config_intr() until bus_alloc_resource()..
Message-ID:  <200406021358.17521.jhb@FreeBSD.org>
In-Reply-To: <200406021104.59860.jhb@FreeBSD.org>
References:  <20040601141424.I29932@root.org> <20040601.163316.88476133.imp@bsdimp.com> <200406021104.59860.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 02 June 2004 11:04 am, John Baldwin wrote:
> > 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*

Ok, summary of PITAs after an hour or so of looking into it:

- For the PIC mode on i386, we use bus_config_intr() after bus_setup_intr() to
  set the interrupt to level/low.  This can be worked around by deferring
  handler setup until after acpica_machdep_init() and calling
  AcpiEnableSubsystem() twice.
- There is no way (currently) to get a pointer to the resource structure
  associated with rid X w/o calling bus_alloc_resource().  In fact, there is
  no resource structure in which to place the IRQ configuration flags until
  bus_alloc_resource(), thus for the bus_config_intr() that sets the mode for
  the SCI for PIC mode above there is no resource (once you defer the
  interrupt setup) and for all of the resources set via bus_set_resource() in
  acpi_parse_resources() there is no resource to set the flags in, so that
  info is lost unless we also hack on the resource list items to add flag
  members and change that API to allow for flags to be passed around.
- sys/rman.h now depends on sys/bus.h being included before it
- The above mentioned PITA regarding having to rework the route_interrupt()
  interface since we don't have a resource to stick the flags in yet.

I really don't want to spend a lot of time implementing all this. Does 
somebody else want to do this?  The change I posted earlier is a _lot_ 
simpler and smaller.

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406021358.17521.jhb>