From hmo@sep.oldach.net  Fri Jan 20 18:20:54 2006
Return-Path: <hmo@sep.oldach.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D70C216A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Jan 2006 18:20:54 +0000 (GMT)
	(envelope-from hmo@sep.oldach.net)
Received: from rigel.oldach.net (rigel.oldach.net [194.8.96.250])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4B05843D45
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Jan 2006 18:20:53 +0000 (GMT)
	(envelope-from hmo@sep.oldach.net)
Received: from sep.oldach.net (p548FAD37.dip0.t-ipconnect.de [84.143.173.55])
	by rigel.oldach.net (8.13.4/8.13.4/hmo30jul04) with ESMTP id k0KIKluL039385
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Jan 2006 19:20:48 +0100 (CET)
	(envelope-from hmo@sep.oldach.net)
Received: from sep.oldach.net (localhost [127.0.0.1])
	by sep.oldach.net (8.13.4/8.13.4/hmo26jun05) with ESMTP id k0KIKkaJ002115
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Fri, 20 Jan 2006 19:20:46 +0100 (CET)
	(envelope-from hmo@sep.oldach.net)
Received: (from hmo@localhost)
	by sep.oldach.net (8.13.4/8.13.4/Submit/hmo26jun05) id k0KIKjno002114;
	Fri, 20 Jan 2006 19:20:45 +0100 (CET)
	(envelope-from hmo)
Message-Id: <200601201820.k0KIKjno002114@sep.oldach.net>
Date: Fri, 20 Jan 2006 19:20:45 +0100 (CET)
From: Helge Oldach <freebsdpcic@oldach.net>
Reply-To: Helge Oldach <freebsdpcic@oldach.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: wi0: No irq?! with LG 11Mbps Wireless LAN PCI Card
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         92070
>Category:       kern
>Synopsis:       [pccard] wi0: No irq?! with LG 11Mbps Wireless LAN PCI Card
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 20 18:30:05 GMT 2006
>Closed-Date:    Mon Apr 13 09:49:02 MDT 2009
>Last-Modified:  Mon Apr 13 09:49:02 MDT 2009
>Originator:     Helge Oldach
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
>Environment:

System: FreeBSD localhost 5.4-STABLE FreeBSD 5.4-STABLE #602: Fri Jan 20 15:43:51 CET 2006 toor@localhost:/usr/obj/usr/src/sys/HMO i386

>Description:

I own an LG Electronics LW1100P wireless LAN PCI board, consisting of
a Texas Instruments TI-1211 PCI-CardBus bridge and a wi(4)-compatible
PCCARD.

This card is recognized with an OLDCARD kernel but not with a(n almost)
GENERIC kernel.

Please see i386/91919 for another issue with this specific card. However
this one is independent. With the patch from this PR the card is being
recognized as follows:

cbb0: <TI1211 PCI-CardBus Bridge> at device 15.0 on pci0
cbb0: Found memory at 80000000
cbb0: Secondary bus is 0
cbb0: Secondary bus set to 2 subbus 3
cardbus0: <CardBus bus> on cbb0
pccard0: <16-bit PCCard bus> on cbb0
Status is 0x30001851
cbb0: card inserted: event=0x00000000, state=30001851
pccard0: chip_socket_enable
cbb_pcic_socket_enable:
cbb0: cbb_power: 3V
pccard0: read_cis
cis mem map 0xd31ad000 (resource: 0x88000000)
pccard0: CIS tuple chain:
CISTPL_DEVICE type=null speed=null
 01 03 00 00 ff
CISTPL_DEVICE_A type=sram speed=ext
 17 04 67 5a 08 ff
unhandled CISTPL 1d
 1d 05 03 67 5a 08 ff
CISTPL_VERS_1
 15 32 05 00 4c 47 00 31 31 4d 62 70 73 20 57 69
 72 65 6c 65 73 73 20 4c 41 4e 20 50 43 49 20 43
 61 72 64 00 56 65 72 73 69 6f 6e 20 30 31 2e 30
 32 00 00 ff
CISTPL_MANFID
 20 04 56 01 02 00
CISTPL_FUNCID
 21 02 06 00
CISTPL_FUNCE
 22 02 01 07
CISTPL_FUNCE
 22 05 02 40 42 0f 00
CISTPL_FUNCE
 22 05 02 80 84 1e 00
CISTPL_FUNCE
 22 05 02 60 ec 53 00
CISTPL_FUNCE
 22 05 02 c0 d8 a7 00
CISTPL_FUNCE
 22 02 03 07
CISTPL_FUNCE
 22 08 04 06 00 04 47 50 15 3a
CISTPL_FUNCE
 22 02 05 01
CISTPL_CONFIG
 1a 07 03 01 e0 03 00 00 01
CISTPL_CFTABLE_ENTRY
 1b 0d c1 01 09 77 b5 1e 35 b5 3c 36 36 05 46
CISTPL_END
 ff
cis mem map d31ad000
CISTPL_LINKTARGET expected, code 00 observed
pccard0: check_cis_quirks
pccard0: CIS version PC Card Standard 5.0
pccard0: CIS info: LG, 11Mbps Wireless LAN PCI Card, Version 01.02, 
pccard0: Manufacturer code 0x156, product 0x2
pccard0: function 0: network adapter, ccr addr 3e0 mask 1
pccard0: function 0, config table entry 1: I/O card; irq mask 0; iomask 6, iospace 0-3f; io16
pccard0: functions scanning
pccard0: Card has 1 functions. pccard_mfc is 0
pccard0: I/O rid 0 start 0 end ffffffff
cbb_pcic_socket_enable:
cbb0: cbb_power: 0V
cbb0: cbb_power: 3V
pccard0: ccr_res == 88000000-880003ff, base=3e0
pccard0: function 0 CCR at 0 offset 3e0: 41 80 22 ff, ff ff ff ff, ff
wi0: <LG 11Mbps Wireless LAN PCI Card> at port 0x100-0x13f function 0 config 1 on pccard0
wi0: No irq?!
device_attach: wi0 attach returned 6

What is odd is the lack of an IRQ for the card. (With OLDCARD it is
correctly assigned irq 11.)

There is only a single function in the CIS, with a single configuration
table entry that we need to analyze:

CISTPL_CFTABLE_ENTRY
 1b 0d c1 01 09 77 b5 1e 35 b5 3c 36 36 05 46

1b	is the CISTPL_CFTABLE_ENTRY tag
0d	is the length of this entry
c1	says that the default interface is interface 1
01	says that we are interface 1
09	says there follows a power (0x01) and an iospace (0x08) subfunction, but there is no timing, irq, memspace, or misc subfunction

This is reflected by the debug output:

pccard0: function 0, config table entry 1: I/O card; irq mask 0; iomask 6, iospace 0-3f; io16

The issue is the lack of an irq mask. I don't understand the PCMCIA
specs to well, but it appears that the card is going to tell us "I don't
care about the actual IRQ" which is not too unreasonable for a card that
is attached to a PCI-PCCARD bridge. However, since this is an I/O card,
it clearly needs an IRQ.

But the IRQ mask remains initialized to zero, which effectively disables
all IRQs for this card. Hence the "No irq?!" output from device_attach.

I think the best approach would be to initialize the IRQ mask not
to zero, but to 0xffff. This would permit all IRQs, unless the CIS
specifies an IRQ mask explicitely. For I/O cards this should be the
normal behaviour. For memory cards a pre-assigned IRQ mask doesn't harm
- they don't need an IRQ anyway.

The trivial patch below implements this default 0xffff IRQ mask.

There are certainly other approaches to this problem, e.g. interpreting
a zero cfe->irqmask as "don't care about the IRQ" upon device
attachment.

Note again that OLDCARD does it the Right Way; so the correct solution
should probably be stolen from OLDCARD (from pccardd?).

Note also that this issue is likely also present in 6-STABLE and
CURRENT.

>How-To-Repeat:

>Fix:

--- src/sys/dev/pccard/pccard_cis.c.ctm	Thu Feb  3 07:44:38 2005
+++ src/sys/dev/pccard/pccard_cis.c	Fri Jan 20 15:32:17 2006
@@ -1135,6 +1144,8 @@
 					cfe->irqmask =
 					    (1 << (reg & PCCARD_TPCE_IR_IRQ));
 				}
+			} else {
+				cfe->irqmask = 0xffff;
 			}
 			if (memspace) {
 				if (tuple->length <= idx) {

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->imp 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Sat Jan 21 11:46:33 UTC 2006 
Responsible-Changed-Why:  
To maintainers review. 

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

From: freebsdpcic@oldach.net (Helge Oldach)
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-i386@FreeBSD.org
Cc:  
Subject: Re: i386/92070: wi0: No irq?! with LG 11Mbps Wireless LAN PCI Card
Date: Fri, 18 Aug 2006 09:32:30 +0200 (CEST)

 Just like to confirm that 6-STABLE has the same issue, and the same
 fix solves it.
 
 Helge
State-Changed-From-To: open->patched 
State-Changed-By: imp 
State-Changed-When: Tue Aug 26 22:37:06 MDT 2008 
State-Changed-Why:  
Fixed in current.  Need to merge still. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/92070: commit references a PR
Date: Wed, 27 Aug 2008 04:36:45 +0000 (UTC)

 imp         2008-08-27 04:36:27 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/dev/pccard       pccard_cis.c 
   Log:
   SVN rev 182229 on 2008-08-27 04:36:27Z by imp
   
   Some PC Cards don't have the proper IRQ mask in them.  The standard
   says that in such cases we can pick any interrupt.  One of these cards
   is the LG11 Wireless LAN card.  I don't have one of these, but I do
   know that this doesn't hurt any cards I've tried it with.
   
   PR:             92070
   Submitted by:   Helge Oldach
   MFC after:      3 days
   
   Revision  Changes    Path
   1.42      +2 -0      src/sys/dev/pccard/pccard_cis.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: freebsdpcic@oldach.net
To: imp@FreeBSD.org, FreeBSD-gnats-submit@FreeBSD.org,
        freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: kern/92070: [pccard] wi0: No irq?! with LG 11Mbps Wireless LAN PCI Card
Date: Sat, 6 Sep 2008 07:45:15 +0200 (CEST)

 How about the MFC?
 
 Helge
State-Changed-From-To: patched->closed 
State-Changed-By: imp 
State-Changed-When: Mon Apr 13 09:48:58 MDT 2009 
State-Changed-Why:  
These have been in a release... 


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