Subject: Re: wi0 hassles on Dell 5000e.
To: None <kenh@cmf.nrl.navy.mil>
From: Hayakawa Koichi <haya@ilink.sony.co.jp>
List: tech-kern
Date: 02/02/2001 18:58:31
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?

-- 
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
--