Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Aug 2001 11:04:15 -0400
From:      Jonathan Chen <jon@spock.org>
To:        "Viren R. Shah" <viren@cigital.com>
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/28203: NEWCARD won't recognize my cardbus controllers or my Xircom Realport 10/100+56k card
Message-ID:  <20010808110415.A37018@enterprise.spock.org>
In-Reply-To: <15216.22809.812694.468954@aop.cigital.com>; from viren@cigital.com on Tue, Aug 07, 2001 at 05:09:45PM -0400
References:  <15210.56924.536714.812107@aop.cigital.com> <20010804032632.A25279@enterprise.spock.org> <15216.9560.513790.149857@aop.cigital.com> <20010807142823.A70032@enterprise.spock.org> <15216.22809.812694.468954@aop.cigital.com>

next in thread | previous in thread | raw e-mail | index | archive | help

I think I may have found the problem which causes panic on reinsert -- it 
was a stupid error on my part.  The following patch fixes this problem.  It 
also includes some printf's which may help debugging.  This patch does not 
address the issue where booting up with the card already insertde doesn't 
work -- it may be caused by having device pcic and card in your kernel 
config.  Please try it out and tell me if it works.  I'd also appreciate 
new dmesg from a boot -v.  Thanks.

-Jon


diff -ur /home/jon/src/sys/dev/cardbus/cardbus.c ./sys/dev/cardbus/cardbus.c
--- /home/jon/src/sys/dev/cardbus/cardbus.c	Wed Aug  8 08:23:15 2001
+++ ./sys/dev/cardbus/cardbus.c	Wed Aug  8 08:45:46 2001
@@ -369,7 +369,8 @@
 	pcicfgregs *cfg = NULL;
 	struct cardbus_devinfo *devlist_entry = NULL;
 
-	if (PCIB_READ_CONFIG(brdev, b, s, f, PCIR_DEVVENDOR, 4) != -1) {
+DEVPRINTF((brdev, "read_device: %d %d %d = %d\n", b, s, f, REG(PCIR_DEVVENDOR, 4)));
+	if (REG(PCIR_DEVVENDOR, 4) != -1) {
 		devlist_entry = malloc(sizeof(struct cardbus_devinfo),
 		    M_DEVBUF, M_WAITOK | M_ZERO);
 		if (devlist_entry == NULL)
@@ -393,37 +394,6 @@
 		cfg->lattimer		= REG(PCIR_LATTIMER, 1);
 		cfg->intpin		= REG(PCIR_INTPIN, 1);
 		cfg->intline		= REG(PCIR_INTLINE, 1);
-#ifdef __alpha__
-		alpha_platform_assign_pciintr(cfg);
-#endif
-
-#ifdef APIC_IO
-		if (cfg->intpin != 0) {
-			int airq;
-
-			airq = pci_apic_irq(cfg->bus, cfg->slot, cfg->intpin);
-			if (airq >= 0) {
-				/* PCI specific entry found in MP table */
-				if (airq != cfg->intline) {
-					undirect_pci_irq(cfg->intline);
-					cfg->intline = airq;
-				}
-			} else {
-				/*
-				 * PCI interrupts might be redirected to the
-				 * ISA bus according to some MP tables. Use the
-				 * same methods as used by the ISA devices
-				 * devices to find the proper IOAPIC int pin.
-				 */
-				airq = isa_apic_irq(cfg->intline);
-				if ((airq >= 0) && (airq != cfg->intline)) {
-					/* XXX: undirect_pci_irq() ? */
-					undirect_isa_irq(cfg->intline);
-					cfg->intline = airq;
-				}
-			}
-		}
-#endif /* APIC_IO */
 
 		cfg->mingnt		= REG(PCIR_MINGNT, 1);
 		cfg->maxlat		= REG(PCIR_MAXLAT, 1);
diff -ur /home/jon/src/sys/dev/cardbus/cardbus_cis.c ./sys/dev/cardbus/cardbus_cis.c
--- /home/jon/src/sys/dev/cardbus/cardbus_cis.c	Wed Aug  8 08:23:15 2001
+++ ./sys/dev/cardbus/cardbus_cis.c	Wed Aug  8 08:21:55 2001
@@ -418,6 +418,7 @@
 	u_int32_t size;
 	struct resource *res;
 
+DEVPRINTF((dev, "start = %x\n", *start));
 	switch(CARDBUS_CIS_SPACE(*start)) {
 	case CARDBUS_CIS_ASI_TUPLE:
 		/* CIS in tuple space need no initialization */
@@ -433,7 +434,7 @@
 		break;
 	case CARDBUS_CIS_ASI_ROM:
 		*rid = CARDBUS_ROM_REG;
-		pci_read_config(child, *rid, CARDBUS_ROM_ADDRMASK);
+		pci_write_config(child, *rid, CARDBUS_ROM_ADDRMASK, 4);
 		break;
 	default:
 		device_printf(dev, "Unable to read CIS: Unknown space: %d\n",
@@ -441,22 +442,29 @@
 		return NULL;
 	}
 
+DEVPRINTF((dev, "rid = %x\n", *rid));
 	/* figure out how much space we need */
 	testval = pci_read_config(child, *rid, 4);
 	if (testval&1) {
 		device_printf(dev, "CIS Space is IO, expecting memory.\n");
 		return NULL;
 	}
+DEVPRINTF((dev, "testval = %x\n", *rid));
 	size = CARDBUS_MAPREG_MEM_SIZE(testval);
 	if (size < 4096) size = 4096;
 	/* allocate the memory space to read CIS */
 	res = bus_alloc_resource(child, SYS_RES_MEMORY, rid, 0, ~0, size,
 	    rman_make_alignment_flags(size)|RF_ACTIVE);
+	if (res == NULL) {
+		device_printf(dev, "Unable to allocate resource to read CIS.\n");
+		return NULL;
+	}
 	pci_write_config(child, *rid,
 	    rman_get_start(res) | ((*rid == CARDBUS_ROM_REG)?
 		CARDBUS_ROM_ENABLE:0),
 	    4);
 
+DEVPRINTF((dev, "res = %lx\n", rman_get_start(res)));
 	/* Flip to the right ROM image if CIS is in ROM */
 	if (CARDBUS_CIS_SPACE(*start) == CARDBUS_CIS_ASI_ROM) {
 		bus_space_tag_t bt;
diff -ur /home/jon/src/sys/dev/pccbb/pccbb.c ./sys/dev/pccbb/pccbb.c
--- /home/jon/src/sys/dev/pccbb/pccbb.c	Wed Aug  8 08:23:15 2001
+++ ./sys/dev/pccbb/pccbb.c	Wed Aug  8 10:45:20 2001
@@ -1166,7 +1166,16 @@
 		start = end = tmp;
 		break;
 	    case SYS_RES_IOPORT:
+		if (start <= 0x1000)
+			start = 0x1000;
+		if (end < start)
+			end = start;
+		break;
 	    case SYS_RES_MEMORY:
+		if (start <= 0x10000000)
+			start = 0x10000000;
+		if (end < start)
+			end = start;
 		break;
 	}
 
@@ -1176,7 +1185,7 @@
 		printf("pccbb alloc res fail\n");
 		return NULL;
 	}
-
+DEVPRINTF((brdev, "** ALLOC TO %s: %lx-%lx, %lx-%lx\n", device_get_nameunit(child), start, end, rman_get_start(res), rman_get_end(res)));
 	/*
 	 * Need to record allocated resource so we can iterate through
 	 * it later.
@@ -1685,6 +1694,10 @@
 
 	switch (type) {
 	case SYS_RES_MEMORY:
+		if (start < 0x10000000)
+			start = 0x10000000;		/* XXX tweakable? */
+		if (end < start)
+			end = start;
 		flags = (flags & ~RF_ALIGNMENT_MASK)
 			| rman_make_alignment_flags(PCCBB_MEMALIGN);
 		break;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010808110415.A37018>