summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2018-05-23 08:36:16 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2018-05-23 08:36:16 +0000
commitd88153b3d81553f61feb93be97849e002f64f104 (patch)
tree3a43a88006b395fa69487521b5397f823c8222c2
parentba50231bab01e91be3dbb36908fe1b7363dbe57c (diff)
Map the second bwfm(4) BAR first. The bwfm(4) PCIe devices have two
BARs, where the second one is much larger than the first. Both need to be properly aligned in the given extent. Since the first one is smaller, it will "unalign" the next free space and thus create a gap so that the second BAR cannot be properly aligned in the given space. By mapping the second BAR first, it will automatically have proper alignment. The first BAR, which has fewer alignment requirements, fits well after the initial allocation. Fixes bwfm(4) on APU 1. Debugged and solved by kettenis@
-rw-r--r--sys/dev/pci/if_bwfm_pci.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/pci/if_bwfm_pci.c b/sys/dev/pci/if_bwfm_pci.c
index 1481ce8f59e..96ef2c2e2df 100644
--- a/sys/dev/pci/if_bwfm_pci.c
+++ b/sys/dev/pci/if_bwfm_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bwfm_pci.c,v 1.19 2018/05/16 08:20:00 patrick Exp $ */
+/* $OpenBSD: if_bwfm_pci.c,v 1.20 2018/05/23 08:36:15 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2017 Patrick Wildt <patrick@blueri.se>
@@ -321,18 +321,18 @@ bwfm_pci_attach(struct device *parent, struct device *self, void *aux)
const char *intrstr;
pci_intr_handle_t ih;
- if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x00,
- PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->sc_reg_iot, &sc->sc_reg_ioh,
- NULL, &sc->sc_reg_ios, 0)) {
- printf(": can't map bar0\n");
- return;
- }
-
if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x08,
PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->sc_tcm_iot, &sc->sc_tcm_ioh,
NULL, &sc->sc_tcm_ios, 0)) {
printf(": can't map bar1\n");
- goto bar0;
+ return;
+ }
+
+ if (pci_mapreg_map(pa, PCI_MAPREG_START + 0x00,
+ PCI_MAPREG_MEM_TYPE_64BIT, 0, &sc->sc_reg_iot, &sc->sc_reg_ioh,
+ NULL, &sc->sc_reg_ios, 0)) {
+ printf(": can't map bar0\n");
+ goto bar1;
}
sc->sc_pc = pa->pa_pc;
@@ -343,7 +343,7 @@ bwfm_pci_attach(struct device *parent, struct device *self, void *aux)
/* Map and establish the interrupt. */
if (pci_intr_map_msi(pa, &ih) != 0 && pci_intr_map(pa, &ih) != 0) {
printf(": couldn't map interrupt\n");
- goto bar1;
+ goto bar0;
}
intrstr = pci_intr_string(pa->pa_pc, ih);
@@ -361,10 +361,10 @@ bwfm_pci_attach(struct device *parent, struct device *self, void *aux)
config_mountroot(self, bwfm_pci_attachhook);
return;
-bar1:
- bus_space_unmap(sc->sc_tcm_iot, sc->sc_tcm_ioh, sc->sc_tcm_ios);
bar0:
bus_space_unmap(sc->sc_reg_iot, sc->sc_reg_ioh, sc->sc_reg_ios);
+bar1:
+ bus_space_unmap(sc->sc_tcm_iot, sc->sc_tcm_ioh, sc->sc_tcm_ios);
}
void