Subject: kern/14741: pcmcia_io_alloc and bad start io address PCMCIA devices
To: None <>
From: None <>
List: netbsd-bugs
Date: 11/27/2001 02:40:41
>Number:         14741
>Category:       kern
>Synopsis:       pcmcia_io_alloc and bad start io address PCMCIA devices
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 26 09:42:00 PST 2001
>Release:        NetBSD 1.5Y (2001/11/21)
	CardBus bridge PCI card (RICOH R5C475II) on i386
	My wi device attach failed on i386. It succeeded on hpcmips.
	Also, wd at wdc at pcmcia device (SmartMedia Card Adapter) couldn't
	Other PCMCIA device (ne, com) has no problem on same machine.

	wi fail message is "wi0: could not get mac address, attach failed".
	Some people report same message on some mailing-list and PR.
	(e.g. port-i386, or PR kern/11108)

	I found
	dmesg of BAD device:
	    pcmcia0: (snip) iospace 0-3f; io16 irqshare irqpulse irqlevel
	    pccbb_pcmcia_do_io_map win 0 addr 0x4000 size 0x40 width 0
	iopace start from 0 (zero) and io_map to addr 0x4000.

	ne and com device start from 3xx and io_map addr is 0x43xx.

	I do quick hack attached this mail. Patched kernel works fine.

	dmesg is:
	pcmcia0: CIS version PC Card Standard 5.0
	pcmcia0: CIS info: BUFFALO, WLI-CF-S11G, , 
	pcmcia0: Manufacturer code 0x26f, product 0x30b
	pcmcia0: function 0: network adapter, ccr addr 3e0 mask 1
	pcmcia0: function 0, config table entry 1: I/O card; irq mask ffff; iomask 6, iospace 0-3f; io16 irqshare irqpulse irqlevel
	wi0 at pcmcia0 function 0: BUFFALO, WLI-CF-S11G, 
	wi0:pccbb_pcmcia_io_map window 0 dynamic port 4500+40
	cbb0: pccbb_pcmcia_socket_enable 00 cardtype io 70
	pccbb_pcmcia_do_io_map win 0 addr 0x4500 size 0x40 width 0
	 start 00 45, stop 3f 45, ioctl 02 enable 40
	wi0: using RF:PRISM2.5 MAC:ISL3873, Firmware: 1.3 variant 4

	and wi device attached.

	attach wi device to CardBus slot.
	This is VERY ADHOC patch...

	I think pcic on isa machine has NO problem. (not tested)
	See sys/dev/isa/i82365_isasubr.c, line 367-373.
	(and kernel options PCIC_ISA_ALLOC_IOBASE)

	Should fix sys/dev/pci/pccbb.c::pccbb_pcmcia_io_alloc ?

Index: if_wi_pcmcia.c
RCS file: /cvsroot/syssrc/sys/dev/pcmcia/if_wi_pcmcia.c,v
retrieving revision 1.13
diff -u -r1.13 if_wi_pcmcia.c
--- if_wi_pcmcia.c	2001/11/18 04:27:49	1.13
+++ if_wi_pcmcia.c	2001/11/26 17:15:05
@@ -303,7 +308,7 @@
 	struct wi_softc *sc = &psc->sc_wi;
 	/* Allocate/map I/O space. */
-	if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
+	if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start + 0x500,
 	    cfe->iospace[0].length, WI_IOSIZE,
 	    &psc->sc_pcioh) != 0) {
 		printf("%s: can't allocate i/o space\n",