Subject: Re: kern/31245: Adaptec 1460 pcmcia support (aic) broken
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <djb_netbsd@charter.net>
List: netbsd-bugs
Date: 08/21/2007 03:35:02
The following reply was made to PR kern/31245; it has been noted by GNATS.

From: <djb_netbsd@charter.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/31245: Adaptec 1460 pcmcia support (aic) broken
Date: Mon, 20 Aug 2007 21:51:42 -0400

 Possible work around!
 
 around line 771 of dev/pcmcia/pcmcia.c function pcmcia_config_alloc
 
 If align is equal to or greater than 0x400 then the io allocation is busted.
 
 For the case with the 1460 scsi card:
 pcmcia_config_alloc: io 0 start=340 length=20 align=400 skew=340
 -- and  --
 pccbb_pcmcia_do_io_map win 0 addr 0x4400 size 20 width 0
 
 The card only decodes 10 bits and starts at 0x140 or 0x340 not 0.  Access to io address 0x4400 above do not hit the card since the card is really at 0x4340 or 0x4740.
 
 Since pccbb.c masks the address to 10 bits, any alignment of 10 bits or more are meaningless on the PC architecture.
 
 ------
 
 pcmcia.c, line 781:
    bus_size_t align = cfe->iomask ? (1 << cfe->iomask) : length;
 my hack:
    bus_size_t align = (cfe->iomask ? (1 << cfe->iomask) : length) & 0x3ff;
 
 Also, line 785 - 789 are commented out.
 
 dmesg fragments - bad:
 pcmcia0: CIS version PCMCIA 2.0 or 2.1
 pcmcia0: CIS info: Adaptec, Inc., APA-1460 SCSI Host Adapter, Version 0.01
 pcmcia0: Manufacturer code 0x12f, product 0x2
 pcmcia0: function 0: unspecified, ccr addr 2000 mask 1
 pcmcia0: function 0, config table entry 9: I/O card; irq mask 1e00; iomask a, iospace 340-35f; io16 irqlevel
 pcmcia0: function 0, config table entry 8: I/O card; irq mask 1e00; iomask a, iospace 140-15f; io16 irqlevel
 aic0 at pcmcia0 function 0: <Adaptec, Inc., APA-1460 SCSI Host Adapter, Version 0.01>
 pcmcia_config_alloc: io 0 start=340 length=20 align=400 skew=340
 pccbb_pcmcia_io_alloc alloc port 0x4400+0x20
 pccbb_pcmcia_io_map window 0 dynamic port 4400+20
 pccbb_pcmcia_do_io_map win 0 addr 0x4400 size 0x20 width 0
 pccbb_pcmcia_do_io_map start 00 44, stop 1f 44, ioctl 02 enable 40
 window iobase 4400 iomax 441f
 function iobase 4400 iomax 441f
 pccbb_intr_establish start. 0x0
 pccbb_intr_establish add pil. 0xc07996c0
 pcmcia0: ++enabled_count = 2
 cbb0: pccbb_pcmcia_socket_settype 00 type io 70
 pccbb_pcmcia_alloc_mem: addr 0x20001000 size 0x14, realsize 0x1000
 pccbb_pcmcia_mem_map window 0 bus 20001000+0+14 at card addr 2000
 pccbb_pcmcia_do_mem_map: start 0x20001000 end 0x20001013 off 0xe0001000
 pccbb_pcmcia_do_mem_map window 0: 0100 0180 0140 20
 pcmcia0: function 0 CCR at 0 offset 0: 49 0 49 0, 0 49 0 49, 0
 aic0: unable to detect chip!
 
 
 dmesg with hacks above:
 pcmcia0: CIS version PCMCIA 2.0 or 2.1
 pcmcia0: CIS info: Adaptec, Inc., APA-1460 SCSI Host Adapter, Version 0.01
 pcmcia0: Manufacturer code 0x12f, product 0x2
 pcmcia0: function 0: unspecified, ccr addr 2000 mask 1
 pcmcia0: function 0, config table entry 9: I/O card; irq mask 1e00; iomask a, iospace 340-35f; io16 irqlevel
 pcmcia0: function 0, config table entry 8: I/O card; irq mask 1e00; iomask a, iospace 140-15f; io16 irqlevel
 aic0 at pcmcia0 function 0: <Adaptec, Inc., APA-1460 SCSI Host Adapter, Version 0.01>
 pcmcia_config_alloc: io 0 start=340 length=20 align=0 skew=340
 pccbb_pcmcia_io_alloc alloc port 0x4340+0x20
 pccbb_pcmcia_io_map window 0 dynamic port 4340+20
 pccbb_pcmcia_do_io_map win 0 addr 0x4340 size 0x20 width 0
 pccbb_pcmcia_do_io_map start 40 43, stop 5f 43, ioctl 02 enable 40
 window iobase 4340 iomax 435f
 function iobase 4340 iomax 435f
 pccbb_intr_establish start. 0x0
 pccbb_intr_establish add pil. 0xc06e6a80
 pcmcia0: ++enabled_count = 2
 cbb0: pccbb_pcmcia_socket_settype 00 type io 70
 pccbb_pcmcia_alloc_mem: addr 0x20000000 size 0x14, realsize 0x1000
 pccbb_pcmcia_mem_map window 0 bus 20000000+0+14 at card addr 2000
 pccbb_pcmcia_do_mem_map: start 0x20000000 end 0x20000013 off 0xe0002000
 pccbb_pcmcia_do_mem_map window 0: 0000 0080 0240 20
 pcmcia0: function 0 CCR at 0 offset 0: 49 0 49 0, 0 49 0 49, 0
 scsibus0 at aic0: 8 targets, 8 luns per target
 pcmcia0: --enabled_count = 1
 scsibus0: waiting 2 seconds for devices to settle...
 sd0 at scsibus0 target 4 lun 0: <MATSHITA, PD-1 LF-1000, A105> optical removable
 sd0: drive offline
 cd0 at scsibus0 target 4 lun 1: <MATSHITA, PD-1 LF-1000, A105> cdrom removable
 sd0: async, 8-bit transfers
 cd0: async, 8-bit transfers
 
 
 This hack may apply to many other cards too.  I don't know what might break.  I also don't have a clue how the align/skew stuff is supposed to work.
 
 Dave Barnes