From imp@bsdimp.com  Sat Nov 23 00:40:59 2002
Return-Path: <imp@bsdimp.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id C10D837B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 23 Nov 2002 00:40:59 -0800 (PST)
Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0746F43E6E
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 23 Nov 2002 00:40:59 -0800 (PST)
	(envelope-from imp@bsdimp.com)
Received: from localhost (warner@rover2.village.org [10.0.0.1])
	by harmony.village.org (8.12.3/8.12.3) with ESMTP id gAN8evpk022372;
	Sat, 23 Nov 2002 01:40:58 -0700 (MST)
	(envelope-from imp@bsdimp.com)
Message-Id: <20021123.013939.109040651.imp@bsdimp.com>
Date: Sat, 23 Nov 2002 01:39:39 -0700 (MST)
From: "M. Warner Losh" <imp@bsdimp.com>
To: matt@gsicomp.on.ca
Cc: FreeBSD-gnats-submit@freebsd.org, chris@unixpages.org
In-Reply-To: <200211230800.gAN80Wig000699@dhcp2.gsicomp.on.ca>
Subject: Re: wi0 device_probe_and_attach returns 6
References: <200211230800.gAN80Wig000699@dhcp2.gsicomp.on.ca>

>Number:         45640
>Category:       kern
>Synopsis:       Re: wi0 device_probe_and_attach returns 6
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 23 00:50:00 PST 2002
>Closed-Date:    Sun Nov 24 08:07:31 PST 2002
>Last-Modified:  Sun Nov 24 08:11:42 PST 2002
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 Actually, I think this patch has all the comparisons going the right
 way.
 
 Warner
 
 --- //depot/user/imp/freebsd-imp/sys/dev/pci/pci_pci.c	2002/11/14 23:02:51
 +++ //depot/user/imp/newcard/dev/pci/pci_pci.c	2002/11/23 00:35:32
 @@ -282,6 +282,7 @@
  		    u_long start, u_long end, u_long count, u_int flags)
  {
      struct pcib_softc	*sc = device_get_softc(dev);
 +    int ok;
  
      /*
       * If this is a "default" allocation against this rid, we can't work
 @@ -299,14 +300,18 @@
  	 */
  	switch (type) {
  	case SYS_RES_IOPORT:
 +	    ok = 1;
  	    if (!pcib_is_isa_io(start)) {
  		if (!pci_allow_unsupported_io_range) {
  		    if (start < sc->iobase)
  			start = sc->iobase;
  		    if (end > sc->iolimit)
  			end = sc->iolimit;
 -		    if (end < start)
 +		    if (end < start) {
  			start = 0;
 +			end = 0;
 +			ok = 0;
 +		    }
  		} else {
  		    if (start < sc->iobase)
  			printf("start (%lx) < sc->iobase (%x)\n", start,
 @@ -318,12 +323,11 @@
  			printf("end (%lx) < start (%lx)\n", end, start);
  		}
  	    }
 -	    if (!pcib_is_isa_io(start) &&
 -	      ((start < sc->iobase) || (end > sc->iolimit))) {
 -		device_printf(dev, "device %s%d requested unsupported I/O range 0x%lx-0x%lx"
 -			      " (decoding 0x%x-0x%x)\n",
 -			      device_get_name(child), device_get_unit(child), start, end,
 -			      sc->iobase, sc->iolimit);
 +	    if (!ok) {
 +		device_printf(dev, "device %s%d requested unsupported I/O "
 +		  "range 0x%lx-0x%lx (decoding 0x%x-0x%x)\n",
 +		  device_get_name(child), device_get_unit(child), start, end,
 +		  sc->iobase, sc->iolimit);
  		return (NULL);
  	    }
  	    if (bootverbose)
 @@ -332,44 +336,64 @@
  	    break;
  
  	    /*
 -	     * XXX will have to decide whether the device making the request is asking
 -	     *     for prefetchable memory or not.  If it's coming from another bridge
 -	     *     down the line, do we assume not, or ask the bridge to pass in another
 -	     *     flag as the request bubbles up?
 +	     * XXX will have to decide whether the device making the request
 +	     * is asking for prefetchable memory or not.  If it's coming
 +	     * from another bridge down the line, do we assume not, or ask
 +	     * the bridge to pass in another flag as the request bubbles up?
  	     */
  	case SYS_RES_MEMORY:
 +	    ok = 1;
  	    if (!pcib_is_isa_mem(start)) {
 +		ok = 0;
 +		if (sc->membase > 0 && sc->membase < sc->memlimit)
 +		    ok = ok || (start >= sc->membase && end <= sc->memlimit);
 +		if (sc->membase > 0 && sc->pmembase < sc->pmemlimit)
 +		    ok = ok || (start >= sc->pmembase && end <= sc->pmemlimit);
  		if (!pci_allow_unsupported_io_range) {
 -		    if (start < sc->membase && end >= sc->membase)
 -			start = sc->membase;
 -		    if (end > sc->memlimit)
 -			end = sc->memlimit;
 +		    if (!ok) {
 +			/* XXX Assume non-prefetchable */
 +			if (start < sc->membase)
 +			    start = sc->membase;
 +			if (end > sc->memlimit)
 +			    end = sc->memlimit;
 +			ok = 1;
 +			if (end < start) {
 +			    start = 0;
 +			    end = 0;
 +			    ok = 0;
 +			}
 +		    }
 +		} else if (!ok) {
 +		    ok = 1;	/* pci_allow_unsupported_ranges -> always ok */
 +		    if (sc->membase > 0 && sc->membase < sc->memlimit) {
 +			if (start < sc->membase)
 +			    printf("start (%lx) < sc->membase (%x)\n",
 +			      start, sc->membase);
 +			if (end > sc->memlimit)
 +			    printf("end (%lx) > sc->memlimit (%x)\n",
 +			      end, sc->memlimit);
 +		    }
 +		    if (sc->pmembase > 0 && sc->pmembase < sc->pmemlimit) {
 +			if (start < sc->pmembase)
 +			    printf("start (%lx) < sc->pmembase (%x)\n",
 +			      start, sc->pmembase);
 +			if (end > sc->pmemlimit)
 +			    printf("end (%lx) > sc->pmemlimit (%x)\n",
 +			      end, sc->memlimit);
 +		    }
  		    if (end < start)
 -			start = 0;
 -		} else {
 -		    if (start < sc->membase && end > sc->membase)
 -			printf("start (%lx) < sc->membase (%x)\n",
 -				start, sc->membase);
 -		    if (end > sc->memlimit)
 -			printf("end (%lx) > sc->memlimit (%x)\n",
 -				end, sc->memlimit);
 -		    if (end < start)
  			printf("end (%lx) < start (%lx)\n", end, start);
  		}
  	    }
 -	    if (!pcib_is_isa_mem(start) &&
 -	        (((start < sc->membase) || (end > sc->memlimit)) &&
 -		((start < sc->pmembase) || (end > sc->pmemlimit)))) {
 -		if (bootverbose)
 -		    device_printf(dev,
 -			"device %s%d requested unsupported memory range "
 -			"0x%lx-0x%lx (decoding 0x%x-0x%x, 0x%x-0x%x)\n",
 -			device_get_name(child), device_get_unit(child), start,
 -			end, sc->membase, sc->memlimit, sc->pmembase,
 -			sc->pmemlimit);
 -		if (!pci_allow_unsupported_io_range)
 -		    return (NULL);
 -	    }
 +	    if (!ok && bootverbose)
 +		device_printf(dev,
 +		  "device %s%d requested unsupported memory range "
 +		  "0x%lx-0x%lx (decoding 0x%x-0x%x, 0x%x-0x%x)\n",
 +		  device_get_name(child), device_get_unit(child), start,
 +		  end, sc->membase, sc->memlimit, sc->pmembase,
 +		  sc->pmemlimit);
 +	    if (!ok)
 +		return (NULL);
  	    if (bootverbose)
  		device_printf(sc->dev, "device %s%d requested decoded memory range 0x%lx-0x%lx\n",
  			      device_get_name(child), device_get_unit(child), start, end);
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Sun Nov 24 08:05:49 PST 2002 
State-Changed-Why:  
Followup to kern/45637 misfiled as a new PR. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Sun Nov 24 08:05:49 PST 2002 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=45638 
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Sun Nov 24 08:05:49 PST 2002 
State-Changed-Why:  
Followup to kern/45637 misfiled as a new PR. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Sun Nov 24 08:05:49 PST 2002 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=45639 
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Sun Nov 24 08:05:49 PST 2002 
State-Changed-Why:  
Followup to kern/45637 misfiled as a new PR. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Sun Nov 24 08:05:49 PST 2002 
Responsible-Changed-Why:  

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