[meta-xilinx] Linux/FreeRTOS AMP vrings

Magnus Olsson Mago at hms.se
Tue Jul 14 01:59:09 PDT 2015


Hey, 

That's the thing -- there is no automatic way of syncing the AMP application and Linux at the moment. You would expect that the remoteproc subsystem of Linux would honor the da (device address) to the VRINGs specified in the resource table, but it doesn't. This is actually a TODO in the remoteproc code at the moment, see the comment on 
http://lxr.free-electrons.com/source/drivers/remoteproc/remoteproc_core.c#L300

So what happens is, your AMP app declares a VRING, passes its address back to Linux through the resource table, and then Linux ignores it and allocates the VRING using the DMA API.

The only way to make it work (at the moment) is to make sure your AMP application keeps the VRINGs in the same place as Linux DMA API will allocate it. And yes, it is a pain because it can move around. What I've done is to put the VRINGs at a low adress, then my AMP app goes ontop of that and finally Linux runs at offset 16 MB (or something). This makes it more or less static, unless I need to adjust the size of my VRINGs.

If you look at the remoteproc output (some DEBUG might need to be enabled) during a bootup, you'll see it print both the da passed by your AMP app and later on, the da which was the result of the DMA allocation. Unless these match, your rings will be broken.


________________________________________
From: meta-xilinx-bounces at yoctoproject.org <meta-xilinx-bounces at yoctoproject.org> on behalf of Edward Wingate <edwingate8 at gmail.com>
Sent: Monday, July 13, 2015 19:14
To: meta-xilinx at yoctoproject.org
Subject: Re: [meta-xilinx] Linux/FreeRTOS AMP vrings

On Thu, Jul 2, 2015 at 10:49 AM, Edward Wingate <edwingate8 at gmail.com> wrote:
> How does this get reconciled with the only addresses that FreeRTOS
> knows about (1e400000/1e404000)?  It seems I need to somehow get Linux
> to allocate the vrings at 1e400000/1e404000 instead of where it is
> currently allocating at.

There's a comment in the FreeRTOS application linker script for vring
memory placement that says "Linker script has to match Linux dma
allocation".  So I think I need to modify my linker script somehow,
but not sure how to go about getting FreeRTOS vring memory allocation
to match Linux DMA allocation.

The vring memory allocation in the FreeRTOS app linker script puts
them after the trace buffer and after the end of the ELF:

   /* Trace buffer should be inside carveout */
   __trace_buffer_start = .;
   . = . + 0x8000; /* It should be TRACE_BUFFER_SIZE */
   __trace_buffer_end = .;
   __elf_end = .; /* This is size of carveout */

/* Linker script has to match Linux dma allocation
* TX buffer has to start at align address but alignment
* is done by dma_alloc_from_coherent and get_order and
bitmap_find_free_region functions
* Algorithm is easy 1 << (count position the most significant bit from
((__elf_end - 1) >> (PAGE_SHIFT -1))
*/
   . = ALIGN(0x400000);

   __ring_tx_addr = .;
   . = . + (256 * 16) + (2 *(3+256)); /* vring size macro without
vring_used_elements */

   . = ALIGN(0x1000); /* Used buffer must be aligned */
   __ring_tx_addr_used = .;
   . = . + 4 + (8 * 256); /* vring_used structure */
   __ring_tx_addr_used_end = .;
   . = ALIGN(0x2000);

   __ring_rx_addr = .;
  . = . + (256 * 16) + (2 *(3+256)); /* vring size macro without
vring_used_elements */
  . = ALIGN(0x1000);
  __ring_rx_addr_used = .; /* Used buffer must be aligned */
  . = . + 4 + (8 * 256); /* vring_used structure */
  __ring_rx_addr_used_end = .;
  . = ALIGN(0x2000);

In this case, RING_TX is at 0x1E400000 and RING_RX at 0x1E404000.  I
tried relocating the vrings to around the memory location Linux wants
to be allocate them (0x1D000000) and adding another corresponding
carveout entry in the resource table, but Linux will then allocate the
vrings at yet another memory location. (And FreeRTOS has problems
accessing that memory location, probably because MMU settings hasn't
been set up correctly.)

How do I get FreeRTOS vring memory location (defined in the linker
script) and the Linux dma allocation for vrings (defined in the
resource table) to sync up to the same memory location?  The memory
location for the vrings in the resource table does sync with the
linker script, but when Linux processes the resource table, it will
allocate vring at another memory location.  Thanks for your help.
--
_______________________________________________
meta-xilinx mailing list
meta-xilinx at yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx



More information about the meta-xilinx mailing list