Make sure that all resource allocation is handled in the pcib device, not

the chipset. This is already how the multi-hose systems handle resource
allocation and it fixes a bug where dense and bwx memory allocations were
not handled properly.

Reviewed by: gallatin
This commit is contained in:
Doug Rabson 2001-05-23 19:44:17 +00:00
parent b516d2f5e1
commit a0e512b219
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77060
12 changed files with 90 additions and 119 deletions

View file

@ -69,7 +69,6 @@
#include <alpha/pci/apecsreg.h>
#include <alpha/pci/apecsvar.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include <machine/intr.h>
#include <machine/resource.h>
@ -151,12 +150,6 @@ apecs_write_hae(u_int64_t hae)
static int apecs_probe(device_t dev);
static int apecs_attach(device_t dev);
static struct resource *apecs_alloc_resource(device_t bus, device_t child,
int type, int *rid, u_long start,
u_long end, u_long count,
u_int flags);
static int apecs_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r);
static int apecs_setup_intr(device_t dev, device_t child,
struct resource *irq, int flags,
driver_intr_t *intr, void *arg, void **cookiep);
@ -169,10 +162,6 @@ static device_method_t apecs_methods[] = {
DEVMETHOD(device_attach, apecs_attach),
/* Bus interface */
DEVMETHOD(bus_alloc_resource, apecs_alloc_resource),
DEVMETHOD(bus_release_resource, apecs_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, apecs_setup_intr),
DEVMETHOD(bus_teardown_intr, apecs_teardown_intr),
@ -280,7 +269,6 @@ apecs_probe(device_t dev)
}
apecs_hae_mem = REGVAL(EPIC_HAXR1);
pci_init_resources();
isa_init_intr();
apecs_init_sgmap();
@ -314,29 +302,6 @@ apecs_attach(device_t dev)
return 0;
}
static struct resource *
apecs_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
if ((hwrpb->rpb_type == ST_DEC_2100_A50) &&
(type == SYS_RES_IRQ))
return isa_alloc_intr(bus, child, start);
else
return pci_alloc_resource(bus, child, type, rid,
start, end, count, flags);
}
static int
apecs_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if ((hwrpb->rpb_type == ST_DEC_2100_A50) &&
(type == SYS_RES_IRQ))
return isa_release_intr(bus, child, r);
else
return pci_release_resource(bus, child, type, rid, r);
}
static void
apecs_disable_intr(int vector)
{

View file

@ -36,9 +36,13 @@
#include <pci/pcivar.h>
#include <machine/swiz.h>
#include <machine/md_var.h>
#include <machine/rpb.h>
#include <machine/resource.h>
#include <alpha/pci/apecsreg.h>
#include <alpha/pci/apecsvar.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include "alphapci_if.h"
#include "pcib_if.h"
@ -52,6 +56,7 @@ apecs_pcib_probe(device_t dev)
{
device_set_desc(dev, "2107x PCI host bus adapter");
pci_init_resources();
device_add_child(dev, "pci", 0);
return 0;
@ -67,6 +72,29 @@ apecs_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
return ENOENT;
}
static struct resource *
apecs_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
if ((hwrpb->rpb_type == ST_DEC_2100_A50) &&
(type == SYS_RES_IRQ))
return isa_alloc_intr(bus, child, start);
else
return pci_alloc_resource(bus, child, type, rid,
start, end, count, flags);
}
static int
apecs_pcib_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if ((hwrpb->rpb_type == ST_DEC_2100_A50) &&
(type == SYS_RES_IRQ))
return isa_release_intr(bus, child, r);
else
return pci_release_resource(bus, child, type, rid, r);
}
static void *
apecs_pcib_cvt_dense(device_t dev, vm_offset_t addr)
{
@ -175,10 +203,10 @@ static device_method_t apecs_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, apecs_pcib_read_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_alloc_resource, apecs_pcib_alloc_resource),
DEVMETHOD(bus_release_resource, apecs_pcib_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),

View file

@ -105,7 +105,6 @@
#include <alpha/pci/ciareg.h>
#include <alpha/pci/ciavar.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include <machine/bwx.h>
#include <machine/swiz.h>
@ -196,10 +195,6 @@ static device_method_t cia_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, cia_setup_intr),
DEVMETHOD(bus_teardown_intr, cia_teardown_intr),
@ -393,7 +388,6 @@ cia_probe(device_t dev)
cia0 = dev;
device_set_desc(dev, "2117x Core Logic chipset"); /* XXX */
pci_init_resources();
isa_init_intr();
cia_rev = REGVAL(CIA_CSR_REV) & REV_MASK;

View file

@ -103,6 +103,8 @@
#include <alpha/pci/ciareg.h>
#include <alpha/pci/ciavar.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include "alphapci_if.h"
#include "pcib_if.h"
@ -116,6 +118,7 @@ cia_pcib_probe(device_t dev)
{
device_set_desc(dev, "2117x PCI host bus adapter");
pci_init_resources();
device_add_child(dev, "pci", 0);
return 0;
@ -395,10 +398,10 @@ static device_method_t cia_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, cia_pcib_read_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, alpha_platform_pci_setup_intr),
DEVMETHOD(bus_teardown_intr, alpha_platform_pci_teardown_intr),

View file

@ -43,7 +43,6 @@
#include <alpha/isa/isavar.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#include <alpha/pci/pcibus.h>
#include <machine/bwx.h>
#include <machine/intr.h>
#include <machine/intrcnt.h>
@ -100,10 +99,6 @@ static device_method_t irongate_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, isa_setup_intr),
DEVMETHOD(bus_teardown_intr, isa_teardown_intr),
@ -131,8 +126,8 @@ irongate_init()
bwx_init_space(&io_space, KV(IRONGATE_IO));
bwx_init_space(&mem_space, KV(IRONGATE_MEM));
busspace_isa_io = (kobj_t) &io_space;
busspace_isa_mem = (kobj_t) &mem_space;
busspace_isa_io = (struct alpha_busspace *) &io_space;
busspace_isa_mem = (struct alpha_busspace *) &mem_space;
if (platform.pci_intr_init)
platform.pci_intr_init();
@ -146,7 +141,6 @@ irongate_probe(device_t dev)
return ENXIO;
irongate0 = dev;
device_set_desc(dev, "AMD 751 Core Logic chipset");
pci_init_resources();
isa_init_intr();
device_add_child(dev, "pcib", 0);
return 0;

View file

@ -40,6 +40,7 @@
#include <pci/pcireg.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#include <alpha/pci/pcibus.h>
#include "alphapci_if.h"
#include "pcib_if.h"
@ -54,6 +55,7 @@ irongate_pcib_probe(device_t dev)
device_set_desc(dev, "AMD 751 PCI host bus adapter");
pci_init_resources();
device_add_child(dev, "pci", 0);
/*
@ -187,10 +189,10 @@ static device_method_t irongate_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, irongate_pcib_read_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),

View file

@ -38,10 +38,8 @@
#include <alpha/pci/lcareg.h>
#include <alpha/pci/lcavar.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include <machine/intr.h>
#include <machine/resource.h>
#include <machine/cpuconf.h>
#include <machine/swiz.h>
#include <machine/sgmap.h>
@ -114,23 +112,12 @@ lca_write_hae(u_int64_t hae)
static int lca_probe(device_t dev);
static int lca_attach(device_t dev);
static struct resource *lca_alloc_resource(device_t bus, device_t child,
int type, int *rid, u_long start,
u_long end, u_long count,
u_int flags);
static int lca_release_resource(device_t bus, device_t child,
int type, int rid, struct resource *r);
static device_method_t lca_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, lca_probe),
DEVMETHOD(device_attach, lca_attach),
/* Bus interface */
DEVMETHOD(bus_alloc_resource, lca_alloc_resource),
DEVMETHOD(bus_release_resource, lca_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, isa_setup_intr),
DEVMETHOD(bus_teardown_intr, isa_teardown_intr),
@ -237,7 +224,6 @@ lca_probe(device_t dev)
lca0 = dev;
device_set_desc(dev, "21066 Core Logic chipset"); /* XXX */
pci_init_resources();
isa_init_intr();
lca_init_sgmap();
@ -264,26 +250,5 @@ lca_attach(device_t dev)
return 0;
}
static struct resource *
lca_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
if (type == SYS_RES_IRQ)
return isa_alloc_intr(bus, child, start);
else
return pci_alloc_resource(bus, child, type, rid,
start, end, count, flags);
}
static int
lca_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (type == SYS_RES_IRQ)
return isa_release_intr(bus, child, r);
else
return pci_release_resource(bus, child, type, rid, r);
}
DRIVER_MODULE(lca, root, lca_driver, lca_devclass, 0, 0);

View file

@ -32,6 +32,7 @@
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <pci/pcivar.h>
#include <machine/swiz.h>
@ -39,6 +40,8 @@
#include <alpha/pci/lcareg.h>
#include <alpha/pci/lcavar.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include "alphapci_if.h"
#include "pcib_if.h"
@ -52,6 +55,7 @@ lca_pcib_probe(device_t dev)
{
device_set_desc(dev, "21066 PCI host bus adapter");
pci_init_resources();
device_add_child(dev, "pci", 0);
return 0;
@ -67,6 +71,27 @@ lca_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
return ENOENT;
}
static struct resource *
lca_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
if (type == SYS_RES_IRQ)
return isa_alloc_intr(bus, child, start);
else
return pci_alloc_resource(bus, child, type, rid,
start, end, count, flags);
}
static int
lca_pcib_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (type == SYS_RES_IRQ)
return isa_release_intr(bus, child, r);
else
return pci_release_resource(bus, child, type, rid, r);
}
static void *
lca_pcib_cvt_dense(device_t dev, vm_offset_t addr)
{
@ -171,10 +196,10 @@ static device_method_t lca_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, lca_pcib_read_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_alloc_resource, lca_pcib_alloc_resource),
DEVMETHOD(bus_release_resource, lca_pcib_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),

View file

@ -66,7 +66,6 @@
#include <alpha/pci/t2reg.h>
#include <alpha/pci/t2var.h>
#include <alpha/pci/pcibus.h>
#include <alpha/isa/isavar.h>
#include <machine/intr.h>
#include <machine/resource.h>
@ -165,10 +164,6 @@ static device_method_t t2_methods[] = {
DEVMETHOD(device_attach, t2_attach),
/* Bus interface */
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, t2_setup_intr),
DEVMETHOD(bus_teardown_intr, t2_teardown_intr),
@ -303,8 +298,8 @@ t2_init()
swiz_init_space_hae(&mem_space, KV(T2_PCI_SPARSE),
t2_set_hae_mem, 0);
busspace_isa_io = (kobj_t) &io_space;
busspace_isa_mem = (kobj_t) &mem_space;
busspace_isa_io = (struct alpha_busspace *) &io_space;
busspace_isa_mem = (struct alpha_busspace *) &mem_space;
chipset = t2_chipset;
@ -350,8 +345,6 @@ t2_probe(device_t dev)
/* t2_num_hoses = 2; XXX not ready for this yet */
}
pci_init_resources();
for (h = 0; h < t2_num_hoses; h++)
t2_csr_init(h);

View file

@ -39,6 +39,7 @@
#include <alpha/pci/t2reg.h>
#include <alpha/pci/t2var.h>
#include <alpha/pci/pcibus.h>
#include "alphapci_if.h"
#include "pcib_if.h"
@ -54,6 +55,8 @@ t2_pcib_probe(device_t dev)
device_set_desc(dev, "T2 PCI host bus adapter");
pci_init_resources();
child = device_add_child(dev, "pci", 0);
device_set_ivars(child, 0);
@ -177,10 +180,10 @@ static device_method_t t2_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, t2_pcib_read_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),

View file

@ -44,7 +44,6 @@
#include <alpha/isa/isavar.h>
#include <alpha/pci/tsunamireg.h>
#include <alpha/pci/tsunamivar.h>
#include <alpha/pci/pcibus.h>
#include <machine/bwx.h>
#include <machine/intr.h>
#include <machine/intrcnt.h>
@ -248,8 +247,8 @@ tsunami_init()
bwx_init_space(&io_space, KV(TSUNAMI_IO(0)));
bwx_init_space(&mem_space, KV(TSUNAMI_MEM(0)));
busspace_isa_io = (kobj_t) &io_space;
busspace_isa_mem = (kobj_t) &mem_space;
busspace_isa_io = (struct alpha_busspace *) &io_space;
busspace_isa_mem = (struct alpha_busspace *) &mem_space;
chipset = tsunami_chipset;
platform.pci_intr_enable = tsunami_intr_enable;
@ -274,7 +273,6 @@ tsunami_probe(device_t dev)
else
tsunami_num_pchips = 1;
pci_init_resources();
isa_init_intr();
for(i = 0; i < tsunami_num_pchips; i++) {

View file

@ -63,6 +63,7 @@ tsunami_pcib_probe(device_t dev)
device_set_desc(dev, "21271 PCI host bus adapter");
pci_init_resources(); /* XXX probably don't need */
child = device_add_child(dev, "pci", -1);
bwx_init_space(&sc->io, KV(TSUNAMI_IO(device_get_unit(dev))));
@ -89,8 +90,8 @@ tsunami_pcib_probe(device_t dev)
* isn't stictly necessary but it keeps things tidy.
*/
if (device_get_unit(dev) == 0) {
busspace_isa_io = (kobj_t) &sc->io;
busspace_isa_mem = (kobj_t) &sc->mem;
busspace_isa_io = (struct alpha_busspace *) &sc->io;
busspace_isa_mem = (struct alpha_busspace *) &sc->mem;
}
return 0;