Subject: port-i386/9683: No doc on pcmcia IO space conflicts
To: None <gnats-bugs@gnats.netbsd.org>
From: John Hawkinson <jhawk@mit.edu>
List: netbsd-bugs
Date: 03/27/2000 16:31:04
>Number:         9683
>Category:       port-i386
>Synopsis:       No doc on pcmcia IO space conflicts
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer (NetBSD/i386 Portmaster)
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 26 22:39:00 2000
>Last-Modified:
>Originator:     John Hawkinson
>Organization:
	MIT
>Release:        NetBSD 1.4.2
>Environment:
	
System: NetBSD zorkmid.mit.edu 1.4.2 NetBSD 1.4.2 (ZORKMID) #10: Mon Mar 27 12:33:31 CST 2000 jhawk@zorkmid.mit.edu:/usr/src/sys/arch/i386/compile/ZORKMID i386


>Description:
On the SONY VAIO PCG-Z505HE, pcmcia maps device IO space in a location
that conflicts with existing hardware, causing some PCMCIA (but not
all--my modem worked fine) to fail mysteriously.

There are sorts of ways to fix this, but I think it's unconscionable
that it's undocumented. Perhaps everyone knows how to debug PCMCIA
problems, or perhaps it's as easy as walking across the room to find
someone who is and getting them to figure it out for you, but I don't
think this is at all clear from the code.

I'd like this problem to be fixed in the code, of course, but I think
that port-i386/5177 ("PCMCIA port allocations may conflict with
display") addresses that problem. Discussion with Bill Sommerfeld
suggests that someone is working on a PNP mechanism to detect such IO
space conflicts.

In the absence of that, the choice between using 0x300 space versus
0x400 space seems to be a choice between which hardware you'd like to
work around. Jason changed the default back to 0x300 in revision 1.7
of sys/dev/isa/i82365_isa.c (which is now in i82365_isasubr.c):
 
| Revision 1.7 / (download) - annotate - [select for diffs] , Wed Nov
| 5 21:41:36 1997 UTC (2 years, 4 months ago) by thorpej
| Branch: MAIN 
| Changes since 1.6: +15 -1 lines
| Diff to previous 1.6 
| 
| The bus width probe doesn't always work properly, producing a false positive
| for 12-bit addresses.  This causes PCMCIA cards mapped at 0x400 and higher
| to not function properly.  However, the range 0x300-0x3ff causes some
| laptops (e.g. the NEC Versa 6030X) to hang if cards are mapped there.
| 
| So, after some experimentation, we compromise.  If the probe discovers
| a 12-bit address bus, don't trust it.  Instead, use the range 0x330-0x3ff.
| This has been shown to work on the laptops that the 0x300-0x3ff range is
| known to fail on.

On my laptop, NetBSD ended up mapping my new Wavelan card:

Mar 27 10:02:41 zorkmid /netbsd: wi0 at pcmcia0 function 0 port 0x380-0x3bf

which of course conflicts some NeoMagic frob; According to Win98:

         0376h-0376h - Secondary IDE controller (dual fifo)
         0376h-0376h - Intel 82371AB/EB PCI Bus Master IDE Controller
         0378h-037Fh - ECP Printer Port (LPT1)
         0398h-0399h - Motherboard resources
         03B0h-03BBh - NeoMagic MagicMedia256AV
         03C0h-03DFh - NeoMagic MagicMedia256AV
         03E8h-03EFh - Sony Fast Infrared Port
         03F6h-03F6h - Intel 82371AB/EB PCI Bus Master IDE Controller
         03F6h-03F6h - Primary IDE controller (dual fifo)
         03F8h-03FFh - Communications Port (COM1)

I'm tempted to request a kernel printf() for the cases
where NetBSD would default to using 0x400 but isn't (i.e. 12-bit
addresses), saying "WARNING: pcmcia may not work, check for bus space
conflicts," though I am of mixed minds on that.

I don't know if my laptop broken is more important than Jason's;
in the absence of any knowlege on the topic, I'll assume not.

In part, this addresses port-i386/7703 ("Need to document the PCMCIA
(PCIC) kernel options in the options man page"), however I don't
document all of the options, and am not completely certain what to say
for all of them. Perhaps this is a cop-out?

Ideally I would like to see this information somewhere
more prominent than pcmcia(4) and options(4), and perhaps
have something figured out at installation time. I do not
have a proposal for such a location at this time. I have to
admit I'm relatively peeved that I was bitten by a known
problem and I wasn't told about it. But perhaps my expectations
are too high. On the other hand, high expectations lead to PRs,
and that's good ;-)

In addition to documenting the above, I also reorder the references
section of options(4) into {section,alpha} order because I could see
rhyme or reason to it (and I add pcmcia(4)).

>How-To-Repeat:
	
>Fix:
===================================================================
RCS file: share/man/man4/RCS/options.4,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** share/man/man4/options.4	2000/03/27 05:16:20	1.1
--- share/man/man4/options.4	2000/03/27 06:25:12	1.2
***************
*** 30,36 ****
  .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  .\"
  .\"
! .Dd June 26, 1998
  .Os
  .Dt OPTIONS 4
  .Sh NAME
--- 30,36 ----
  .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  .\"
  .\"
! .Dd March 27, 2000
  .Os
  .Dt OPTIONS 4
  .Sh NAME
***************
*** 1288,1293 ****
--- 1288,1305 ----
  .Em pccons
  console driver.
  .El
+ .Ss isa-specific Options
+ Options specific to
+ .Xr isa 4
+ busses.
+ .Bl -ohang
+ .It Cd options PCIC_ISA_ALLOC_IOBASE=address, PCIC_ISA_ALLOC_IOSIZE=size
+ Control the section of IO bus space used for PCMCIA bus space mapping.
+ Ideally the probed defaults are satisfactory, however in practice
+ that is not always the case. See
+ .Xr pcmcia 4
+ for details.
+ .El
  .Ss m68k-specific Options
  .Bl -ohang
  .It Cd options FPU_EMULATE
***************
*** 1391,1409 ****
  .\" .Sh FILES
  .\" .Sh EXAMPLES
  .Sh SEE ALSO
! .Xr config 8 ,
! .Xr init 8 ,
  .Xr gettimeofday 2 ,
- .Xr sysctl 8 ,
- .Xr sysctl 3 ,
- .Xr xntpd 8 ,
- .Xr ntp_adjtime 2 ,
- .Xr ntp_gettime 2 ,
  .Xr i386_iopl 2 ,
  .Xr msgctl 2 ,
  .Xr msgget 2 ,
  .Xr msgrcv 2 ,
  .Xr msgsnd 2 ,
  .Xr semctl 2 ,
  .Xr semget 2 ,
  .Xr semop 2 ,
--- 1403,1419 ----
  .\" .Sh FILES
  .\" .Sh EXAMPLES
  .Sh SEE ALSO
! .Xr gdb 1 ,
! .Xr ktrace 1 ,
! .Xr quota 1 ,
  .Xr gettimeofday 2 ,
  .Xr i386_iopl 2 ,
  .Xr msgctl 2 ,
  .Xr msgget 2 ,
  .Xr msgrcv 2 ,
  .Xr msgsnd 2 ,
+ .Xr ntp_adjtime 2 ,
+ .Xr ntp_gettime 2 ,
  .Xr semctl 2 ,
  .Xr semget 2 ,
  .Xr semop 2 ,
***************
*** 1411,1442 ****
  .Xr shmctl 2 ,
  .Xr shmdt 2 ,
  .Xr shmget 2 ,
  .Xr apm 4 ,
  .Xr ddb 4 ,
- .Xr lkm 4 ,
  .Xr inet 4 ,
- .Xr ns 4 ,
  .Xr iso 4 ,
! .Xr mrouted 8 ,
! .Xr mount_lfs 8 ,
! .Xr newlfs 8 ,
! .Xr mount_mfs 8 ,
! .Xr mount_nfs 8 ,
  .Xr mount_cd9660 8 ,
- .Xr mount_msdos 8 ,
  .Xr mount_fdesc 8 ,
  .Xr mount_kernfs 8 ,
  .Xr mount_null 8 ,
  .Xr mount_portal 8 ,
  .Xr mount_procfs 8 ,
  .Xr mount_umap 8 ,
  .Xr mount_union 8 ,
! .Xr edquota 8 ,
  .Xr quotaon 8 ,
- .Xr quota 1 ,
  .Xr rpc.rquotad 8 ,
! .Xr ktrace 1 ,
! .Xr gdb 1
  .Sh HISTORY
  The
  .Nm
--- 1421,1455 ----
  .Xr shmctl 2 ,
  .Xr shmdt 2 ,
  .Xr shmget 2 ,
+ .Xr sysctl 3 ,
  .Xr apm 4 ,
  .Xr ddb 4 ,
  .Xr inet 4 ,
  .Xr iso 4 ,
! .Xr lkm 4 ,
! .Xr ns 4 ,
! .Xr pcmcia 4 ,
! .Xr xntpd 8 ,
! .Xr config 8 ,
! .Xr edquota 8 ,
! .Xr init 8 ,
  .Xr mount_cd9660 8 ,
  .Xr mount_fdesc 8 ,
  .Xr mount_kernfs 8 ,
+ .Xr mount_lfs 8 ,
+ .Xr mount_mfs 8 ,
+ .Xr mount_msdos 8 ,
+ .Xr mount_nfs 8 ,
  .Xr mount_null 8 ,
  .Xr mount_portal 8 ,
  .Xr mount_procfs 8 ,
  .Xr mount_umap 8 ,
  .Xr mount_union 8 ,
! .Xr mrouted 8 ,
! .Xr newlfs 8 ,
  .Xr quotaon 8 ,
  .Xr rpc.rquotad 8 ,
! .Xr sysctl 8
  .Sh HISTORY
  The
  .Nm
===================================================================
RCS file: share/man/man4/RCS/pcmcia.4,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** share/man/man4/pcmcia.4	2000/03/27 04:55:41	1.1
--- share/man/man4/pcmcia.4	2000/03/27 06:25:12	1.2
***************
*** 34,40 ****
  .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  .\" POSSIBILITY OF SUCH DAMAGE.
  .\"
! .Dd November 11, 1997
  .Dt PCMCIA 4
  .Os
  .Sh NAME
--- 34,40 ----
  .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  .\" POSSIBILITY OF SUCH DAMAGE.
  .\"
! .Dd March 27, 2000
  .Dt PCMCIA 4
  .Os
  .Sh NAME
***************
*** 91,96 ****
--- 91,97 ----
  The supported PCMCIA controllers are those that are i82365 compatible.
  .Sh SEE ALSO
  .Xr intro 4 ,
+ .Xr options 4 ,
  .Xr aic 4 ,
  .Xr com 4 ,
  .Xr ep 4 ,
***************
*** 103,105 ****
--- 104,133 ----
  driver
  appeared in
  .Nx 1.3 .
+ .Sh BUGS
+ .Ss IO space conflicts
+ .Nx 
+ probes the pcmcia IO bus width and uses that information to decide
+ where to map PCMCIA IO space. For 10-bit wide cards, 0x300-0x3ff is
+ used, and this is satisfactory. For 12-bit wide cards, however,
+ it would nice to use 0x400-0xfff, however this causes some problems
+ for some specific PCMCIA devices, as well as some specific laptops;
+ consequently, 0x300-0x3ff is used.
+ .Pp
+ Unfortunately, the choice of 0x300-0x3ff causes problems as well.
+ In particular, a number of video devices are mapped in that range,
+ and may conflict. In the event that pcmcia devices are mapped
+ in 0x300 and appear to be nonfunctional, remapping to 0x400-0xfff
+ may be appropriate; consult 
+ .Cd options PCIC_ISA_ALLOC_IOBASE
+ and
+ .Cd options PCIC_ISA_ALLOC_IOSIZE
+ in
+ .Xr options 4 .
+ Example:
+ .Bd -literal -offset indent
+ # Avoid pcmcia bus space conflicts with the default io space
+ # allocation on 12-bit wide busses (base 0x300 size 0xff).
+ options PCIC_ISA_ALLOC_IOBASE=0x400
+ options PCIC_ISA_ALLOC_IOSIZE=0xbff
+ .Ed


>Audit-Trail:
>Unformatted: