From nobody@FreeBSD.ORG  Thu Sep 21 11:52:42 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 672E837B424; Thu, 21 Sep 2000 11:52:42 -0700 (PDT)
Message-Id: <20000921185242.672E837B424@hub.freebsd.org>
Date: Thu, 21 Sep 2000 11:52:42 -0700 (PDT)
From: D.Rock@gmx.de
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: ISA PnP resource allocator problem
X-Send-Pr-Version: www-1.0

>Number:         21461
>Category:       kern
>Synopsis:       ISA PnP resource allocator problem
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 21 12:00:01 PDT 2000
>Closed-Date:    Sat Mar 01 19:41:11 UTC 2008
>Last-Modified:  Sat Mar 01 19:41:11 UTC 2008
>Originator:     Daniel Rock
>Release:        5.0-CURRENT (cvsup'd yesterday)
>Organization:
>Environment:
FreeBSD gate.rock.net 5.0-CURRENT FreeBSD 5.0-CURRENT #465: Thu Sep 21 20:37:32 CEST 2000     root@gate.rock.net:/usr/src/sys/compile/ROCK  i386

>Description:
if a resource is already held by another PnP device, the code in
/sys/kern/subr_rman.c automatically tries to find another region, but
doesn't honour alignment requirements. The code in /sys/isa/isa_common.c
(function isa_find_port()) is therefor pretty useless.

This code is present in the system since FreeBSD switched to the new PnP
code (about a year ago)
>How-To-Repeat:
I have different ISA PnP devices in my system (output from pnpinfo):

   I/O Range 0x100 .. 0x3ff, alignment 0x1, len 0x1
        [16-bit addr]

   I/O Range 0x100 .. 0x3f0, alignment 0x8, len 0x8
        [not 16-bit addr]

For the first device the I/O port 0x100 is allocated. This port isn't
available for the second device, but the code in /sys/kern/subr_rman.c
automatically "finds" an area large enough at 0x101, but doesn't know
the alignment constraint. Instead the second device should be allocated
at 0x108-0x10f

Wrong boot output:
unknown10: <EEPROM> at port 0x100 on isa0
isic0: <Sedlbauer WinSpeed> at port 0x101-0x108 irq 11 on isa0

should be:
unknown10: <EEPROM> at port 0x100 on isa0
isic0: <Sedlbauer WinSpeed> at port 0x108-0x10f irq 11 on isa0

>Fix:
The following code releases the region if it is not exactly the one
requested, which was the original intention of the code but didn't
work because of the additional "intelligence" by the resource allocator.

Quick - but ugly - hack (worked for me since I discovered the bug):

Index: isa_common.c
===================================================================
RCS file: /data/cvs/src/sys/isa/isa_common.c,v
retrieving revision 1.18
diff -u -r1.18 isa_common.c
--- isa_common.c        2000/07/12 00:42:08     1.18
+++ isa_common.c        2000/09/21 18:37:14
@@ -209,6 +209,13 @@
                                                    SYS_RES_IOPORT, &i,
                                                    0, ~0, 1, 0 /* !RF_ACTIVE */);
                        if (res[i]) {
+                               /* HACK */
+                               if(res[i]->r_start != start) {
+                                       bus_release_resource(child,
+                                                       SYS_RES_IOPORT, i,
+                                                       res[i]);
+                                       continue;
+                               }
                                result->ic_port[i].ir_start = start;
                                result->ic_port[i].ir_end = start + size - 1;
                                result->ic_port[i].ir_size = size;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: imp 
Responsible-Changed-When: Wed Jun 6 16:38:40 MDT 2001 
Responsible-Changed-Why:  
I'll look into this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=21461 
State-Changed-From-To: open->feedback 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 04:00:19 UTC 2007 
State-Changed-Why:  

Likely fixed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21461 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Mar 1 19:40:54 UTC 2008 
State-Changed-Why:  
Feedback timeout (> 3 months). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21461 
>Unformatted:
Is this still a problem on RELENG_6?
