summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/pci.c11
-rw-r--r--sys/dev/pci/pci_pci.c7
2 files changed, 15 insertions, 3 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 22046c1..9cd5a1c 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -2576,6 +2576,17 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl,
uint16_t cmd;
struct resource *res;
+ /*
+ * The BAR may already exist if the device is a CardBus card
+ * whose CIS is stored in this BAR.
+ */
+ pm = pci_find_bar(dev, reg);
+ if (pm != NULL) {
+ maprange = pci_maprange(pm->pm_value);
+ barlen = maprange == 64 ? 2 : 1;
+ return (barlen);
+ }
+
pci_read_bar(dev, reg, &map, &testval);
if (PCI_BAR_MEM(map)) {
type = SYS_RES_MEMORY;
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index f68973b..da8465c 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -916,7 +916,8 @@ pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type,
/* Move end_free down until it is properly aligned. */
end_free &= ~(align - 1);
- front = end_free - count;
+ end_free--;
+ front = end_free - (count - 1);
/*
* The resource would now be allocated at (front,
@@ -944,7 +945,7 @@ pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type,
/* Move start_free up until it is properly aligned. */
start_free = roundup2(start_free, align);
- back = start_free + count;
+ back = start_free + count - 1;
/*
* The resource would now be allocated at (start_free,
@@ -957,7 +958,7 @@ pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type,
if (bootverbose)
printf("\tback candidate range: %#lx-%#lx\n",
start_free, back);
- back = roundup2(back, w->step) - 1;
+ back = roundup2(back + 1, w->step) - 1;
back -= rman_get_end(w->res);
} else
back = 0;
OpenPOWER on IntegriCloud