Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Alloc Mem error with Intel i350 (e1000 device): (6 Items)
   
Alloc Mem error with Intel i350 (e1000 device)  
Hello!

We are trying to run an e1000 (Intel i350) PCI-e device on an embedded PowerPC board (AMCC PPC460EX) running QNX 6.5.0 
with the following issues:

- with a 2-port card, only the first port is enumerated and working

- with a 4-port card, only the first two ports are enumerated, but only the first ist working correctly

Both cards are working correctly on x86 BIOS (QNX 6.5.0), so this seems to be an issue with the PPC implementation.

sloginfo shows an allocation error during pci_device_attach:

Jan 01 00:02:26    2    17     0 addup_resources: Alloc mem failed
Jan 01 00:02:26    2    10     0 pci_attach_device failed

The pci server executable is pci-ppc460ex. Regarding to a previous thread by Ray Mack (http://community.qnx.com/sf/go/
projects.networking/discussion.drivers.topc25206),
I already started the pci server in verbose mode for further investigation.

Please find attached the syslog for the verbose pci server and the output of "pci -vvv".

I would be grateful for any help solving this issue!

Thanks.
Attachment: Text pci.txt 14.73 KB
Re: Alloc Mem error with Intel i350 (e1000 device)  
> Please find attached the syslog for the verbose pci server and the output of "
> pci -vvv".

...and here the sloginfo output

Attachment: Text slog.txt 17.54 KB
Re: Alloc Mem error with Intel i350 (e1000 device)  
I have replied to your TAM about this problem.



On 2014/9/23, 2:09 AM, "Marvin Hohlfeld" <community-noreply@qnx.com> wrote:

>Hello!
>
>We are trying to run an e1000 (Intel i350) PCI-e device on an embedded
>PowerPC board (AMCC PPC460EX) running QNX 6.5.0 with the following issues:
>
>- with a 2-port card, only the first port is enumerated and working
>
>- with a 4-port card, only the first two ports are enumerated, but only
>the first ist working correctly
>
>Both cards are working correctly on x86 BIOS (QNX 6.5.0), so this seems
>to be an issue with the PPC implementation.
>
>sloginfo shows an allocation error during pci_device_attach:
>
>Jan 01 00:02:26    2    17     0 addup_resources: Alloc mem failed
>Jan 01 00:02:26    2    10     0 pci_attach_device failed
>
>The pci server executable is pci-ppc460ex. Regarding to a previous thread
>by Ray Mack 
>(http://community.qnx.com/sf/go/projects.networking/discussion.drivers.top
>c25206),
>I already started the pci server in verbose mode for further
>investigation.
>
>Please find attached the syslog for the verbose pci server and the output
>of "pci -vvv".
>
>I would be grateful for any help solving this issue!
>
>Thanks.
>
>
>
>
>_______________________________________________
>
>Networking Drivers
>http://community.qnx.com/sf/go/post111833
>To cancel your subscription to this discussion, please e-mail
>drivers-networking-unsubscribe@community.qnx.com

Re: Alloc Mem error with Intel i350 (e1000 device)  
Marvin:

I finally fixed one of my two problems.  We are using an ADI version of the BIOS, so our files are adi.c (for the dll 
entry points) and server.c.  My guess is that the file server.c is entirely QNX, but there could be ADI footprints there
 as well.

So, I believe the root cause of the problem is that the E1000 driver calls pci_allocate with just one PCI memory request
 that is the big buffer plus the little buffer as one memory size.  In the case of the 82580 we are using, this means 
each NIC needs 512kB for the big buffer and the little buffer is 16 kB.  The allocation from rsrcdbmgr is told to 
allocate this 528 kB as one buffer on a 1 MB boundary.

I went in to scan_windows() in server.c and changed the map->mem_reqd which occurs right after the "if" statement where 
size = window_size() is called.  If size comes back with some value that is not exactly a multiple of 1 MB, I force the 
size to be rounded up to the next 1 MB boundary.  This lets my code see all 5 ethernet ports where it used to fail after
 the third one. 

It looks like your code fails on the second ethernet port.  My guess is that you really have issues with that first one,
 too, and it isn't really doing the right thing (but I could be wrong).

There are two other problems that occur:
1) the stock version of server.c allocates from top down and it really should be allocating bottom up (at least for our 
system)
2) I just found that somehow, server.c is allocating INT A to both our 82574 and the first unit of the 82580.

Once I figure out the issue with the INT line and clean all the debug garbage out of my file, I'll try to post the exact
 lines of code you need to fix all of these issues.

Ray
Re: Alloc Mem error with Intel i350 (e1000 device)  
OK, so I am a newbie at PCI interrupts.  The INT Line A was a red herring. 

I was not able to see exactly where we changed from top down to bottom up allocation.  Somewhere in our code we removed 
a RSRCDBMGR_FLAG_TOPDOWN flag from a rsrcdbmgr request.  The need may no longer be necessary since the code below fixes 
the real problem.  We have another issue in our hardware that forces me to grab extra memory and allocate bottom up in 
order to create a hole in the PCI memory.

In the file src/hardware/pci/"your bsp"/server.c you want to find the function scan_windows() function.  In my case "
your bsp" is "adi" since we are using their Cinnamon Bay board.  Here is the new code to force the bus map to reserve 
the right amount of memory for later when the allocation of resources happens when the E1000 driver attempts to allocate
 the ethernet controller from the PCI server:

			if (verbose)
				pci_slogf (_SLOGC_PCI, _SLOG_INFO, "MEM 0x%llx 0x%llx %s", PCI_MEM_ADDR (addr64), size, addr64 & 0x08 ? "pref" : "")
;
			BaseReg->Address = device_enabled ? addr64 : (addr64 &= 0x0f);
			if (! device_enabled) {
				PCI_write_config32 (bus, devfn, Offset, 1, (char *)&addr64);
				if (reg_64) {
					addr64 >>= 32;
					PCI_write_config32 (bus, devfn, Offset + 4, 1, (char *)&addr64);
					}
				}
			else {
				uint64_t Address;

				(*pci_drivers->entry->map_addr) (ll_handle, addr64, &Address, (uint32_t) BaseReg->Flags | PCI_MAP_ADDR_CPU);
                original_size = size;
                if ((size % 0x100000) > 0)
                {
                  size += 0x100000;
                  size &= 0xfff00000;
                }
				if (alloc_resource (PCI_MEM_ADDR (Address), (uint32_t) size, RSRCDBMGR_PCI_MEMORY, bus,
					(BaseReg->Flags & PCI_MEM_PREFETCH) ? 1 : 0)) {
					pci_slogf (_SLOGC_PCI, _SLOG_ERROR, "%s: Alloc failed 0x%llx - Size 0x%llx",
						__FUNCTION__, Address, size);
//					BaseReg->Address = 0;
//					BaseReg->Flags &= ~PCI_DEVICE_ENABLED;
//					dword = 0;
//					PCI_write_config32 (bus, devfn, Offset, 1, (char *)&dword);
					}
//				else {
					BaseReg->Address = Address;
					BaseReg->Flags |= PCI_DEVICE_ENABLED;
					}
				}
			}


The new code you want adjusts the variable size to be on the first 1MB boundary above what you really need.  ("
original_size" is a debug variable used to compare what the chip says vs. what we end up using).
Re: Alloc Mem error with Intel i350 (e1000 device)  
Marvin:

We desperately need the QNX folks to *FIX* the E1000 driver if they have not done so since April. It is (was?) severely 
broken!!!

We have similar issues.  We are using an Atom processor with Poulsbo support chip and using two network chips: 82574 and
 82580 for a total of 5 ports.  The problem is an interaction between the driver and the memory manager.

Run the command "pci" on your console and you will see that each port consumes 1MB !!!!!! This is a serious design bug 
in the driver.  While the 82580 needs 512 kB for one of its buffers, the other one only needs 16 kB.  Unfortunately the 
driver glues the two unrelated buffers together and asks for one buffer of 528 kB that *must* be on a 512 kB boundary.  
This forces it to grab 1 MB of PCI space and waste 99% of the upper 512 kB.

What is even more broken is that the 82574 only needs 128 kB for its main buffer and about 4 kB for the second, but it 
still grabs 1MB because of the way the memory allocation call is made.

I have not been able to find anywhere in the Intel documentation that indicates that the smaller 16 kB area cannot be 
just about anyplace in memory.

I am searching the forum today to see if QNX has done anything to fix this since I found the problem back in April and 
reported it to them.

Ray