Subject: Re: wi0 hassles on Dell 5000e.
To: Hayakawa Koichi <haya@ilink.sony.co.jp>
From: Luke Mewburn <lukem@wasabisystems.com>
List: tech-kern
Date: 02/03/2001 06:33:43
On Fri, Feb 02, 2001 at 06:58:31PM +0900, Hayakawa Koichi wrote:
> Hello,
> 
> From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
> Subject: Re: wi0 hassles on Dell 5000e. 
> Date: Wed, 17 Jan 2001 11:04:40 -0500
> Message-ID: <200101171604.f0HG4f923197@ginger.cmf.nrl.navy.mil>
> 
>  > The code that allocates I/O and memory address spaces for CardBus seems
>  > rather ... strange.  I noticed two problems when I was debugging a similar
>  > problem:
>  > 
>  > - A extremely large alignment is specified when allocating stuff for
>  >   Cardbus.
>  >
>  > I think it's the second thing that makes my CD-ROM drive not work (since
>  > that driver needs to allocate two chunks of space).
>  > 
> 
> Is this patch makes sense for your problem?

I've applied the patch below and disabled Simon's temporary
workaround, and now things seem to work well!

Good Work!

(Can you commit this soon, without your debug printf? :)

For example, I previously had problems with using my CompactFlash
cards (in a PCMCIA adaptor) and my Wavelan cards, unless I plugged in
a cardbus card into slot0 first. Now I can just plug my CF or Wavelan
card in to slot 0 and things `work'. Here's an extract from my dmesg
where I'm plugging in various devices and removing them:


pcmcia0: CIS version PCMCIA 2.0 or 2.1
pcmcia0: CIS info: HITACHI, FLASH, 4.0
pcmcia0: Manufacturer code 0x7, product 0x0
pcmcia0: function 0: fixed disk(ata), ccr addr 200 mask f
pcmcia0: function 0, config table entry 0: memory card; irq mask 0; memspace 0-7ff; rdybsy_active powerdown
pcmcia0: function 0, config table entry 1: I/O card; irq mask ffff; iomask 4, iospace 0-f; memspace 0-7ff; rdybsy_active io8 io16 irqshare irqpulse irqlevel powerdown
pcmcia0: function 0, config table entry 2: I/O card; irq mask 4000; iomask a, iospace 1f0-1f7 3f6-3f7; memspace 0-7ff; rdybsy_active io8 io16 irqshare irqpulse irqlevel powerdown
pcmcia0: function 0, config table entry 3: I/O card; irq mask 4000; iomask a, iospace 170-177 376-377; memspace 0-7ff; rdybsy_active io8 io16 irqshare irqpulse irqlevel powerdown
wdc2 at pcmcia0 function 0-- pccbb_pcmcia_io_alloc cbb0: mask 0x1f

wd1 at wdc2 channel 0 drive 0: <Hitachi CV 7.2.2>
wd1: drive supports 1-sector PIO transfers, LBA addressing
wd1: 7872 KB, 246 cyl, 2 head, 32 sec, 512 bytes/sect x 15744 sectors
wd1 detached
wdc2 detached
pcmcia0: CIS version PC Card Standard 5.0
pcmcia0: CIS info: Lucent Technologies, WaveLAN/IEEE, Version 01.01, 
pcmcia0: Manufacturer code 0x156, product 0x2
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 irqpulse irqlevel
wi0 at pcmcia0 function 0: Lucent Technologies, WaveLAN/IEEE, Version 01.01, 
-- pccbb_pcmcia_io_alloc cbb0: mask 0x7f
wi0: 802.11 address 00:02:2d:0c:11:29
wi0 detached
tlp0 at cardbus0 dev 0 function 0: DECchip 21143 Ethernet, pass 4.1
tlp0: Ethernet address 00:10:7a:15:e5:76
ukphy0 at tlp0 phy 1: Generic IEEE 802.3u media interface
ukphy0: OUI 0x0010dd, model 0x0002, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
pcmcia1: CIS version PC Card Standard 5.0
pcmcia1: CIS info: Lucent Technologies, WaveLAN/IEEE, Version 01.01, 
pcmcia1: Manufacturer code 0x156, product 0x2
pcmcia1: function 0: network adapter, ccr addr 3e0 mask 1
pcmcia1: function 0, config table entry 1: I/O card; irq mask ffff; iomask 6, iospace 0-3f; io16 irqpulse irqlevel
wi0 at pcmcia1 function 0: Lucent Technologies, WaveLAN/IEEE, Version 01.01, 
-- pccbb_pcmcia_io_alloc cbb1: mask 0x7f
wi0: 802.11 address 00:02:2d:0c:11:29
ukphy0 detached
tlp0 detached
wi0 detached
pcmcia1: CIS version PC Card Standard 5.0
pcmcia1: CIS info: Lucent Technologies, WaveLAN/IEEE, Version 01.01, 
pcmcia1: Manufacturer code 0x156, product 0x2
pcmcia1: function 0: network adapter, ccr addr 3e0 mask 1
pcmcia1: function 0, config table entry 1: I/O card; irq mask ffff; iomask 6, iospace 0-3f; io16 irqpulse irqlevel
wi0 at pcmcia1 function 0: Lucent Technologies, WaveLAN/IEEE, Version 01.01, 
-- pccbb_pcmcia_io_alloc cbb1: mask 0x7f
wi0: 802.11 address 00:02:2d:0c:11:29
wi0 detached
tlp0 at cardbus0 dev 0 function 0: DECchip 21143 Ethernet, pass 4.1
tlp0: Ethernet address 00:10:7a:15:e5:76
ukphy0 at tlp0 phy 1: Generic IEEE 802.3u media interface
ukphy0: OUI 0x0010dd, model 0x0002, rev. 1
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
pcmcia1: CIS version PCMCIA 2.0 or 2.1
pcmcia1: CIS info: HITACHI, FLASH, 4.0
pcmcia1: Manufacturer code 0x7, product 0x0
pcmcia1: function 0: fixed disk(ata), ccr addr 200 mask f
pcmcia1: function 0, config table entry 0: memory card; irq mask 0; memspace 0-7ff; rdybsy_active powerdown
pcmcia1: function 0, config table entry 1: I/O card; irq mask ffff; iomask 4, iospace 0-f; memspace 0-7ff; rdybsy_active io8 io16 irqshare irqpulse irqlevel powerdown
pcmcia1: function 0, config table entry 2: I/O card; irq mask 4000; iomask a, iospace 1f0-1f7 3f6-3f7; memspace 0-7ff; rdybsy_active io8 io16 irqshare irqpulse irqlevel powerdown
pcmcia1: function 0, config table entry 3: I/O card; irq mask 4000; iomask a, iospace 170-177 376-377; memspace 0-7ff; rdybsy_active io8 io16 irqshare irqpulse irqlevel powerdown
wdc2 at pcmcia1 function 0-- pccbb_pcmcia_io_alloc cbb1: mask 0x1f

wd1 at wdc2 channel 0 drive 0: <Hitachi CV 7.2.2>
wd1: drive supports 1-sector PIO transfers, LBA addressing
wd1: 7872 KB, 246 cyl, 2 head, 32 sec, 512 bytes/sect x 15744 sectors
wd1 detached
wdc2 detached
tlp0: interrupting at 11


> 
> -- 
> Index: pccbb.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/dev/pci/pccbb.c,v
> retrieving revision 1.56
> diff -c -r1.56 pccbb.c
> *** pccbb.c	2001/01/30 07:23:14	1.56
> --- pccbb.c	2001/02/02 09:50:47
> ***************
> *** 1927,1932 ****
> --- 1927,1933 ----
>   	int flags = 0;
>   	bus_space_tag_t iot;
>   	bus_space_handle_t ioh;
> + 	bus_addr_t mask;
>   #if rbus
>   	rbus_tag_t rb;
>   #endif
> ***************
> *** 1934,1939 ****
> --- 1935,1968 ----
>   		align = size;	       /* XXX: funny??? */
>   	}
>   
> + 	if (start != 0) {
> + 		/* XXX: assume all card decode lower 10 bits by its hardware */
> + 		mask = 0x3ff;
> + 	} else {
> + 		/*
> + 		 * calculate mask:
> + 		 *  1. get the most significant bit of size (call it msb).
> + 		 *  2. compare msb with the value of size.
> + 		 *  3. if size is larger, shift msb left once.
> + 		 *  4. obtain mask value to decrement msb.
> + 		 */
> + 		bus_size_t size_tmp = size;
> + 		int shifts = 0;
> + 
> + 		mask = 1;
> + 		while (size_tmp) {
> + 			++shifts;
> + 			size_tmp >>= 1;
> + 		}
> + 		mask = (1 << shifts);
> + 		if (mask < size) {
> + 			mask <<= 1;
> + 		}
> + 		--mask;
> + 	}
> + 	printf("-- pccbb_pcmcia_io_alloc %s: mask 0x%lx\n",
> + 	    ((struct pccbb_softc *)(ph->ph_parent))->sc_dev.dv_xname, mask);
> + 
>   	/* 
>   	 * Allocate some arbitrary I/O space.
>   	 */
> ***************
> *** 1942,1949 ****
>   
>   #if rbus
>   	rb = ((struct pccbb_softc *)(ph->ph_parent))->sc_rbus_iot;
> ! 	/* XXX: I assume all card decode lower 10 bits by its hardware */
> ! 	if (rbus_space_alloc(rb, start, size, 0x3ff, align, 0, &ioaddr, &ioh)) {
>   		return 1;
>   	}
>   #else
> --- 1971,1977 ----
>   
>   #if rbus
>   	rb = ((struct pccbb_softc *)(ph->ph_parent))->sc_rbus_iot;
> ! 	if (rbus_space_alloc(rb, start, size, mask, align, 0, &ioaddr, &ioh)) {
>   		return 1;
>   	}
>   #else
> -- 

-- 
Luke Mewburn  <lukem@wasabisystems.com>  http://www.wasabisystems.com
Luke Mewburn     <lukem@netbsd.org>      http://www.netbsd.org
Wasabi Systems - providing NetBSD sales, support and service.