From bel@orel.ru  Thu Jul 15 20:27:37 2004
Return-Path: <bel@orel.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2D69D16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Jul 2004 20:27:37 +0000 (GMT)
Received: from orel.ru (amts3620-114.dialup.orel.ru [213.59.64.114])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6C0C443D45
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Jul 2004 20:27:34 +0000 (GMT)
	(envelope-from bel@orel.ru)
Received: from orel.ru (localhost.localdomain [127.0.0.1])
	by belnb.localdomain (8.12.11/8.12.11) with ESMTP id i6FJp2nV001049
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 15 Jul 2004 23:51:03 +0400 (MSD)
	(envelope-from bel@orel.ru)
Received: (from bel@localhost)
	by orel.ru (8.12.11/8.12.11/Submit) id i6FJp19G001048;
	Thu, 15 Jul 2004 23:51:01 +0400 (MSD)
	(envelope-from bel)
Message-Id: <200407151951.i6FJp19G001048@orel.ru>
Date: Thu, 15 Jul 2004 23:51:01 +0400 (MSD)
From: Andrew Belashov <bel@orel.ru>
Reply-To: Andrew Belashov <bel@orel.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] EtherLink III LAN PC Card 3C589D not detected
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         69127
>Category:       kern
>Synopsis:       [patch] EtherLink III LAN PC Card 3C589D not detected
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 15 20:30:33 GMT 2004
>Closed-Date:    Mon Jan 10 17:34:33 MST 2005
>Last-Modified:  Mon Jan 10 17:34:33 MST 2005
>Originator:     Andrew Belashov
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
ORIS
>Environment:
System: FreeBSD belnb.localdomain 5.2-CURRENT FreeBSD 5.2-CURRENT #12: Thu Jul 15 22:54:29 MSD 2004 bel@belnb.localdomain:/usr/obj/usr/src/sys/BELNBO i386


	Machine: Fujitsu FMV-BIBLIO NU13 Notebook (Pentium I @133MHz),
	TI1131 CardBus controller.
>Description:
	Some PCMCIA (PC Card) does not detected in NEWCARD code.
>How-To-Repeat:
	Insert card. Card does not detected. Messages on console:

----------------------------------------------------
pccard0: read_cis
exca_mem_map window 0 bus 88010000+1000 card addr 0
common memory
exca_do_mem_map window 0: 0010 8010 0000 88 (88010000+00001000.00001000*00000000
)
attribtue memory
exca_do_mem_map window 0: 0010 8010 4000 88 (88010000+00001000.00001000*00000000
)
[...]
pccard0: CIS tuple chain:
unhandled CISTPL 40
 40 00
CISTPL_NONE
 00
CISTPL_NONE
 00
[...]
pccard0: Card has no functions!
cbb0: PC Card card activation failed
----------------------------------------------------

>Fix:

	This patch correct?

--- exca.c.diff begins here ---
--- sys/dev/exca/exca.c.orig	Tue Oct  7 08:29:04 2003
+++ sys/dev/exca/exca.c	Thu Jul 15 22:51:02 2004
@@ -180,9 +180,12 @@
 {
 	struct mem_map_index_st *map;
 	struct pccard_mem_handle *mem;
+	uint32_t offset;
 	
 	map = &mem_map_index[win];
 	mem = &sc->mem[win];
+	offset = ((mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) -
+	    (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT)) & 0x3fff;
 	exca_putb(sc, map->sysmem_start_lsb,
 	    (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT) & 0xff);
 	exca_putb(sc, map->sysmem_start_msb,
@@ -201,9 +204,9 @@
 	    (mem->addr >> EXCA_MEMREG_WIN_SHIFT) & 0xff);
 
 	exca_putb(sc, map->cardmem_lsb,
-	    (mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff);
+	    offset & 0xff);
 	exca_putb(sc, map->cardmem_msb,
-	    ((mem->cardaddr >> (EXCA_CARDMEM_ADDRX_SHIFT + 8)) &
+	    ((offset >> 8) &
 	    EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) |
 	    ((mem->kind == PCCARD_A_MEM_ATTR) ?
 	    EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0));
--- exca.c.diff ends here ---

With best regards,
 Andrew Belashov.
>Release-Note:
>Audit-Trail:

From: Andrew Belashov <bel@orel.ru>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/69127: [patch] EtherLink III LAN PC Card 3C589D not detected
Date: Thu, 12 Aug 2004 14:58:17 +0400

 I have following PC Card:
 
 3Com Etherlink III 3C589D
 Ninja-ATA CD-ROM Drive
 Nokia Cellular Data Card DTP-2 ver II
 Cardinal MVP144C2 FAX MODEM
 
 All cards working with this patch.
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: arved 
Responsible-Changed-When: Mon Aug 30 21:02:57 GMT 2004 
Responsible-Changed-Why:  
Over to imp, who wrote exca 


http://www.freebsd.org/cgi/query-pr.cgi?pr=69127 

From: Andrew Belashov <bel@orel.ru>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/69127: [patch] EtherLink III LAN PC Card 3C589D not detected
Date: Wed, 13 Oct 2004 11:32:54 +0400

 This is a multi-part message in MIME format.
 --------------070102040105020102020503
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hello, Warner!
 
 Current source code still have hidden bug in exca driver.
 
 To reproduce problem I use two PCMCIA card or set up "hw.cbb.start_memory"
 sysctl variable. For example:
 
 # sysctl hw.cbb.start_memory=0x88010000
 
 The problem arises, when the mapped start address (for CIS or CCR) in not align
 to full address space of card. This is true for some cards (for example
 3Com 3C589D).
 
 Expanded patch attached. Note: Patch is not tested on memory cards.
 
 --
 Best regards,
 Andrew Belashov.
 
 --------------070102040105020102020503
 Content-Type: text/plain;
  name="exca.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="exca.patch"
 
 --- sys/dev/exca/exca.c.orig	Tue Oct 12 16:09:05 2004
 +++ sys/dev/exca/exca.c	Wed Oct 13 10:48:05 2004
 @@ -180,9 +180,12 @@ exca_do_mem_map(struct exca_softc *sc, i
  {
  	struct mem_map_index_st *map;
  	struct pccard_mem_handle *mem;
 +	uint32_t offset;
  	
  	map = &mem_map_index[win];
  	mem = &sc->mem[win];
 +	offset = ((mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) -
 +	    (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT)) & 0x3fff;
  	exca_putb(sc, map->sysmem_start_lsb,
  	    (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT) & 0xff);
  	exca_putb(sc, map->sysmem_start_msb,
 @@ -202,9 +205,9 @@ exca_do_mem_map(struct exca_softc *sc, i
  	    (mem->addr >> EXCA_MEMREG_WIN_SHIFT) & 0xff);
  
  	exca_putb(sc, map->cardmem_lsb,
 -	    (mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff);
 +	    offset & 0xff);
  	exca_putb(sc, map->cardmem_msb,
 -	    ((mem->cardaddr >> (EXCA_CARDMEM_ADDRX_SHIFT + 8)) &
 +	    ((offset >> 8) &
  	    EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) |
  	    ((mem->kind == PCCARD_A_MEM_ATTR) ?
  	    EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0));
 --- sys/dev/pccard/pccard_cis.c.orig	Thu Aug  5 09:36:48 2004
 +++ sys/dev/pccard/pccard_cis.c	Wed Oct 13 10:49:20 2004
 @@ -127,15 +127,9 @@ pccard_scan_cis(device_t dev, int (*fct)
  
  	/* allocate some memory */
  
 -	/*
 -	 * Some reports from the field suggest that a 64k memory boundary
 -	 * helps card CIS being able to be read.  Try it here and see what
 -	 * the results actually are.  I'm not sure I understand why this
 -	 * would make cards work better, but it is easy enough to test.
 -	 */
  	rid = 0;
  	res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0,
 -	    PCCARD_CIS_SIZE, RF_ACTIVE | rman_make_alignment_flags(64*1024));
 +	    PCCARD_CIS_SIZE, RF_ACTIVE);
  	if (res == NULL) {
  		device_printf(dev, "can't alloc memory to read attributes\n");
  		return -1;
 
 --------------070102040105020102020503--
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Mon Jan 10 17:33:44 MST 2005 
State-Changed-Why:  
Committed the offset patch, but not the pccard_cis patch because it 
doesn't seem to be needed. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=69127 
>Unformatted:
