From nobody@FreeBSD.org  Mon Dec 24 12:52:57 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8640216A417
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 24 Dec 2007 12:52:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 67CA813C455
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 24 Dec 2007 12:52:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id lBOCqQT6032954
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 24 Dec 2007 12:52:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id lBOCqQ49032953;
	Mon, 24 Dec 2007 12:52:26 GMT
	(envelope-from nobody)
Message-Id: <200712241252.lBOCqQ49032953@www.freebsd.org>
Date: Mon, 24 Dec 2007 12:52:26 GMT
From: Igor Mozolevsky <igor@hybrid-lab.co.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: nve + PAE bus_addr_t/void * inconsistencies
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         118990
>Category:       kern
>Synopsis:       [nve] nve + PAE bus_addr_t/void * inconsistencies
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 24 13:00:01 UTC 2007
>Closed-Date:    Mon Dec 05 18:32:20 UTC 2011
>Last-Modified:  Mon Dec 05 18:32:20 UTC 2011
>Originator:     Igor Mozolevsky
>Release:        RELENG_6
>Organization:
>Environment:
>Description:
=== FreeBSD-RELENG_6/src/sys/i386/include/_bus.h defines bus_addr_t as:

l38:
/*
 * Bus address and size types
 */
#ifdef PAE
typedef uint64_t bus_addr_t;
#else
typedef uint32_t bus_addr_t;
#endif

which is clearly 64 bits when PAE is enabled, this causes compile
problems with nve device driver when it copies stuff around:

=== FreeBSD-RELENG_6/src/sys/dev/nve/if_nve.c:

l1450:
nve_osallocrxbuf(PNV_VOID ctx, PMEMORY_BLOCK mem, PNV_VOID *id)

l1453:
struct nve_rx_desc *desc;

l1494: (this is the one that makes the compiler bail out)
mem->pPhysical = (void *)desc->paddr;

=== FreeBSD-RELENG_6/src/sys/contrib/dev/nve/basetype.h
l91:
#define NV_VOID                 void
typedef NV_VOID                 *PNV_VOID;

=== FreeBSD-RELENG_6/src/sys/contrib/dev/nve/os.h
l45:
PNV_VOID   pPhysical;


>How-To-Repeat:
Enable both PAE and nve in the kernel
>Fix:
Don't enable PAE

>Release-Note:
>Audit-Trail:

From: "Mikhail T." <mi+thun@aldan.algebra.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/118990: [nve] nve + PAE bus_addr_t/void * inconsistencies
Date: Mon, 22 Aug 2011 11:57:52 -0400

 This is a multi-part message in MIME format.
 --------------030109040001030106020202
 Content-Type: multipart/alternative;
  boundary="------------090808020409070103020705"
 
 
 --------------090808020409070103020705
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Ping... Any hope for this one to be fixed? I have a perfectly fine machine with 
 8Gb of RAM, which can't run in PAE, because the on-board nve-interface is 
 unusable :(
 
 I made a simple patch, which makes things compile cleanly, but, of course, 
 panics at boot, when the interface is detected... Maybe, if I post this, 
 somebody will fix it out of sheer annoyance :-)
 
 Or, perhaps, it is not correctable, because NVidia's "hardware API" (under 
 sys/contrib/dev/nve/{i386,amd64}/) is only available in binary blobs and thus no 
 changes of the structures is possible?
 
     -mi
 
 --------------090808020409070103020705--
 
 --------------030109040001030106020202
 Content-Type: text/plain;
  name="nve-pae.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="nve-pae.diff"
 
 Index: contrib/dev/nve/adapter.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/contrib/dev/nve/adapter.h,v
 retrieving revision 1.1.1.2
 diff -U 2 -r1.1.1.2 adapter.h
 --- contrib/dev/nve/adapter.h	7 Dec 2005 17:32:12 -0000	1.1.1.2
 +++ contrib/dev/nve/adapter.h	22 Aug 2011 15:45:23 -0000
 @@ -94,5 +94,5 @@
  typedef struct  _ADAPTER_WRITE_ELEMENT
  {
 -    PNV_VOID   pPhysical;
 +    bus_addr_t  pPhysical;
      NV_UINT32   ulLength;
  }   ADAPTER_WRITE_ELEMENT, *PADAPTER_WRITE_ELEMENT;
 Index: contrib/dev/nve/os.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/contrib/dev/nve/os.h,v
 retrieving revision 1.1.1.1
 diff -U 2 -r1.1.1.1 os.h
 --- contrib/dev/nve/os.h	12 Mar 2005 00:17:37 -0000	1.1.1.1
 +++ contrib/dev/nve/os.h	22 Aug 2011 15:45:23 -0000
 @@ -43,6 +43,6 @@
  {
      PNV_VOID   pLogical;
 -    PNV_VOID   pPhysical;
 -    NV_UINT32    uiLength;
 +    bus_addr_t pPhysical;
 +    NV_UINT32  uiLength;
  }   MEMORY_BLOCK, *PMEMORY_BLOCK;
  
 @@ -53,6 +53,6 @@
  {
      PNV_VOID   pLogical;
 -    PNV_VOID   pPhysical;
 -    NV_UINT32    uiLength;
 +    bus_addr_t pPhysical;
 +    NV_UINT32  uiLength;
      /* Parameter to OS layer to indicate what type of memory is needed */
      NV_UINT16    AllocFlags;
 Index: dev/nve/if_nve.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/nve/if_nve.c,v
 retrieving revision 1.33.2.3
 diff -U 2 -r1.33.2.3 if_nve.c
 --- dev/nve/if_nve.c	7 Nov 2010 16:56:29 -0000	1.33.2.3
 +++ dev/nve/if_nve.c	22 Aug 2011 15:45:25 -0000
 @@ -952,5 +952,5 @@
  			    (ulong)desc->frags[i].ds_len;
  			txdata.sElement[i].pPhysical =
 -			    (PVOID)desc->frags[i].ds_addr;
 +			    desc->frags[i].ds_addr;
  		}
  
 @@ -1372,5 +1372,5 @@
  	memset(mem->pLogical, 0, (ulong)mem->uiLength);
  	mem_physical = vtophys(mem->pLogical);
 -	mem->pPhysical = (PVOID)mem_physical;
 +	mem->pPhysical = mem_physical;
  
  	DEBUGOUT(NVE_DEBUG_API, "nve: nve_osalloc 0x%x/0x%x - %d\n",
 @@ -1427,5 +1427,5 @@
  		if (offset) {
  			mem_block_ex->pPhysical =
 -			    (PVOID)((ulong)mem_block_ex->pPhysical +
 +			    ((ulong)mem_block_ex->pPhysical +
  			    mem_block_ex->AlignmentSize - offset);
  			mem_block_ex->pLogical =
 @@ -1446,5 +1446,5 @@
  
  	mem_block.pLogical = mem_block_ex->pLogicalOrig;
 -	mem_block.pPhysical = (PVOID)((ulong)mem_block_ex->pPhysicalOrigLow);
 +	mem_block.pPhysical = ((ulong)mem_block_ex->pPhysicalOrigLow);
  	mem_block.uiLength = mem_block_ex->uiLengthOrig;
  
 @@ -1515,5 +1515,5 @@
  
  	mem->pLogical = (void *)desc->vaddr;
 -	mem->pPhysical = (void *)desc->paddr;
 +	mem->pPhysical = desc->paddr;
  	mem->uiLength = desc->buflength;
  	*id = (void *)desc;
 
 --------------030109040001030106020202--
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Tue Aug 23 19:26:55 UTC 2011 
State-Changed-Why:  
As you know it's not trivial to make patch for binary blob and it 
would take a lot time and efforts to make nve(4) work on PAE 
environments. 
However, I also don't see any reason why you still have to use 
nve(4) given that nfe(4) works on your box. I believe nfe(4) should 
work with PAE. 
If nfe(4) does not work on your box, please let me know with full 
dmesg output. 


Responsible-Changed-From-To: freebsd-bugs->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Tue Aug 23 19:26:55 UTC 2011 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118990 
State-Changed-From-To: feedback->closed 
State-Changed-By: yongari 
State-Changed-When: Mon Dec 5 18:31:33 UTC 2011 
State-Changed-Why:  
Feedback timed out(> 3 months). 
Because nve(4) uses a binary blob it's not easy to make it work 
with PAE.  Given that nfe(4) works with PAE I don't see reasonable 
reason to use nve(4) with PAE. 
If there is a controller that nfe(4) does not work while nve(4) 
works, nfe(4) should be fixed instead. 

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