summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2015-07-20 15:44:43 +0000
committerkettenis <kettenis@openbsd.org>2015-07-20 15:44:43 +0000
commit4a270c0d2485e269bb703f4e1a5d60bc400131d2 (patch)
tree5fd703d7b6327f9389095102ffadb5150ede5f3f
parentUse V_ASN1_UNDEF instead of -1. (diff)
downloadwireguard-openbsd-4a270c0d2485e269bb703f4e1a5d60bc400131d2.tar.xz
wireguard-openbsd-4a270c0d2485e269bb703f4e1a5d60bc400131d2.zip
Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured. ok miod@, mlarkin@
-rw-r--r--sys/dev/pci/pccbb.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/dev/pci/pccbb.c b/sys/dev/pci/pccbb.c
index d43a6e0f740..1a5bcfecbf1 100644
--- a/sys/dev/pci/pccbb.c
+++ b/sys/dev/pci/pccbb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pccbb.c,v 1.94 2015/07/19 05:37:38 bcook Exp $ */
+/* $OpenBSD: pccbb.c,v 1.95 2015/07/20 15:44:43 kettenis Exp $ */
/* $NetBSD: pccbb.c,v 1.96 2004/03/28 09:49:31 nakayama Exp $ */
/*
@@ -372,6 +372,7 @@ pccbbattach(struct device *parent, struct device *self, void *aux)
pci_chipset_tag_t pc = pa->pa_pc;
pci_intr_handle_t ih;
const char *intrstr = NULL;
+ u_long busnum;
int flags;
pccbb_attach_hook(parent, self, pa);
@@ -447,8 +448,19 @@ pccbbattach(struct device *parent, struct device *self, void *aux)
printf(": %s", intrstr);
/*
- * When bus number isn't set correctly, give up using 32-bit CardBus
- * mode.
+ * When the bus number isn't configured, try to allocate one
+ * ourselves.
+ */
+ if ((sc->sc_busnum & 0x00ffff00) == 0 && pa->pa_busex &&
+ extent_alloc(pa->pa_busex, 1, 1, 0, 0, EX_NOWAIT, &busnum) == 0) {
+ sc->sc_busnum |= (busnum << 8);
+ sc->sc_busnum |= (busnum << 16);
+ pci_conf_write(pc, pa->pa_tag, PCI_BUSNUM, sc->sc_busnum);
+ }
+
+ /*
+ * When the bus number still isn't set correctly, give up
+ * using 32-bit CardBus mode.
*/
if (((sc->sc_busnum >> 8) & 0xff) == 0) {
printf(", CardBus support disabled");