From imp@bsdimp.com  Sat Nov 23 00:29:42 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 67B9537B401; Sat, 23 Nov 2002 00:29:42 -0800 (PST)
Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 6ED4A43E9C; Sat, 23 Nov 2002 00:29:41 -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 gAN8TVpk022273;
	Sat, 23 Nov 2002 01:29:34 -0700 (MST)
	(envelope-from imp@bsdimp.com)
Message-Id: <20021123.012811.85895040.imp@bsdimp.com>
Date: Sat, 23 Nov 2002 01:28:11 -0700 (MST)
From: "M. Warner Losh" <imp@bsdimp.com>
To: matt@gsicomp.on.ca
Cc: FreeBSD-gnats-submit@freebsd.org, chris@unixpages.org,
	mdodd@freebsd.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:         45638
>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:30:01 PST 2002
>Closed-Date:    Sun Nov 24 08:06:38 PST 2002
>Last-Modified:  Sun Nov 24 08:11:29 PST 2002
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 This patch isn't quite right, but I can see it might work for you.
 However, it does show that I've been ignoring the pmem* part of the
 bridge and need to correct that.  Looks like the following patch will
 do the trick.  This might let us get rid of unsupported ranges, or at
 least reduce its need.  This should also make the nvida people happier
 too, I hope, since they need this since their card is mapped in
 non-prefetchable region.
 
 # still need fix it so drivers can request prefetch or non-prefetch
 # memory on their own.  Cardbus needs this, for example.
 
 ==== //depot/user/imp/newcard/dev/pci/pci_pci.c#8 - /dell/imp/p4/newcard/src/sys/dev/pci/pci_pci.c ====
 @@ -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,20 +336,35 @@
  	    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)) {
  		if (!pci_allow_unsupported_io_range) {
 -		    if (start < sc->membase && end >= sc->membase)
 -			start = sc->membase;
 -		    if (end > sc->memlimit)
 -			end = sc->memlimit;
 -		    if (end < start)
 -			start = 0;
 +		    ok = 0;
 +		    if (sc->membase > sc->memlimit)
 +			ok = ok || 
 +			  (start >= sc->membase && end <= sc->memlimit);
 +		    if (sc->pmembase > sc->pmemlimit)
 +			ok = ok ||
 +			  (start >= sc->pmembase && end <= sc->pmemlimit);
 +		    if (!ok) {
 +			/* XXX Assume non-prefetchable */
 +			if (start < sc->membase)
 +			    start = sc->membase;
 +			if (end > sc->memlimit)
 +			    end = sc->memlimit;
 +			ok = true;
 +			if (end < start) {
 +			    start = 0;
 +			    end = 0;
 +			    ok = false;
 +			}
 +		    }
  		} else {
  		    if (start < sc->membase && end > sc->membase)
  			printf("start (%lx) < sc->membase (%x)\n",
 @@ -357,19 +376,15 @@
  			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);
 
 
 Warner
>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 
>Unformatted:
