[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-tech
Subject:    make sk(4) use pci_mapreg_type()
From:       Brad <brad () comstyle ! com>
Date:       2005-08-28 3:33:11
Message-ID: 20050828033311.GC13796 () blar ! home ! comstyle ! com
[Download RAW message or body]

Some systems will fail to attach sk(4) with pci_mapreg_map() failing
with "can't map mem space". This should resolve that. Also adds a
missing newline when pci_intr_establish() fails.

Index: if_sk.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_sk.c,v
retrieving revision 1.77
diff -u -p -r1.77 if_sk.c
--- if_sk.c	25 Jul 2005 00:49:43 -0000	1.77
+++ if_sk.c	28 Aug 2005 02:54:32 -0000
@@ -1431,11 +1431,11 @@ skc_attach(struct device *parent, struct
 	struct pci_attach_args *pa = aux;
 	struct skc_attach_args skca;
 	pci_chipset_tag_t pc = pa->pa_pc;
+	pcireg_t command, memtype;
 	pci_intr_handle_t ih;
 	const char *intrstr = NULL;
 	bus_size_t size;
 	u_int8_t skrs;
-	u_int32_t command;
 	char *revstr = NULL;
 
 	DPRINTFN(2, ("begin skc_attach\n"));
@@ -1481,11 +1481,18 @@ skc_attach(struct device *parent, struct
 		return;
  	}
 #else
-	if (pci_mapreg_map(pa, SK_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
-	    &sc->sk_btag, &sc->sk_bhandle, NULL, &size, 0)) {
- 		printf(": can't map mem space\n");
+	memtype = pci_mapreg_type(pc, pa->pa_tag, SK_PCI_LOMEM);
+	switch (memtype) {
+	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
+	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
+		if (pci_mapreg_map(pa, SK_PCI_LOMEM,
+				   memtype, 0, &sc->sk_btag, &sc->sk_bhandle,
+				   NULL, &size, 0) == 0)
+			break;
+	default:
+		printf(": can't map mem space\n");
 		return;
- 	}
+	}
 #endif
 	sc->sc_dmatag = pa->pa_dmat;
 
@@ -1512,6 +1519,7 @@ skc_attach(struct device *parent, struct
 		printf(": couldn't establish interrupt");
 		if (intrstr != NULL)
 			printf(" at %s", intrstr);
+		printf("\n");
 		goto fail_1;
 	}
 	printf(": %s\n", intrstr);

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic