Hey TI!
I have the following situation:
A72
running Linux 5.4 from the SDK with dma_buf enabled and the following in devicetree:
&reserved_memory {
#address-cells = <2>;
#size-cells = <2>;
shared_mem_test {
compatible = "dma-heap-carveout";
reg = <0x00 0xaf000000 0x00 0x2d000000>;
};
...
And the following code adapted from the SDK (only important lines listed):
#define DMA_HEAP_NAME "/dev/dma_heap/shared_mem_test" #define DMA_HEAP_ALLOC_FLAGS (0u) m_dma_heap_fd = open(DMA_HEAP_NAME, O_RDONLY | O_CLOEXEC); struct dma_heap_allocation_data data; data.len = size; data.fd_flags = O_CLOEXEC | O_RDWR; data.heap_flags = DMA_HEAP_ALLOC_FLAGS; m_dma_buf_fd = -1; int ret = ioctl(m_dma_heap_fd, DMA_HEAP_IOCTL_ALLOC, &data); m_dma_buf_fd = data.fd; m_virtAddr = mmap(nullptr, size, PROT_WRITE | PROT_READ, MAP_SHARED, m_dma_buf_fd, 0u);
C71 DSP
Bare metal software like this:
volatile uint64_t* val = reinterpret_cast<volatile uint64_t*>(0xaf000000);
*val = 10;
Cache_wb(reinterpret_cast<void*>(0xaf000000), 8, Cache_Type_ALL, TRUE);
while (run)
{
// sleep 1 sec
(*val)++;
Cache_wb(reinterpret_cast<void*>(0xaf000000), 8, Cache_Type_ALL, TRUE);
}
Oberservation
Reading the values on the A72 works with polling, but something with the synchronization is wrong.
So sometimes I instantly see it incremented by the DSP, sometimes the A72 test program lags for seconds and misses values.
I also tried syncing the cache/mem on the A72 via:
struct dma_buf_sync sync_flags; sync_flags.flags = DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END; int status = ioctl(m_dma_buf_fd, DMA_BUF_IOCTL_SYNC, &sync_flags);
Which also did not help. Since the same thing worked good when accessing the memory via /dev/mem and mmap(), it must have something to do with dma_buf.
Can you give me any advice on this?
PS: I know that polling is not good and I will use interrupts/mailbox later. This is only about accessing shared memory from multiple CPUs.