msync with MS_SYNC option failure

Does Linux on TX1 not support MS_SYNC option for msync?

I mmaped hardware buffer to memory and modified the contents of the memory.
I had to use sleep for about two seconds before the change is written back.
To avoid using sleep, I thought using msync with MS_SYNC is the desired effect I was looking for

But when I try to do so, msync returns EINVAL.

I’d appreciate any comments or advices.
Thanks.

Hi devnglee, I’ll take a look and then get back to you.

Hi devnglee, Could you share your sample code?

Hi vickyy,

I’m trying to capture an image via libargus and process the captured data.

int dmabuf_fd = iImageNativeBuffer->createNvBuffer(
        Size {WIDTH, HEIGHT}, NvBufferColorFormat_YUV420, NvBufferLayout_Pitch);
NvBufferParams params;
NvBufferGetParams(dmabuf_fd, &params);

size_t fsize = params.pitch[0] * params.height[0];

uint8_t* data_mem = (uint8_t*)mmap(
        0, fsize, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd, params.offset[0]);

/*               ...                */
/* Read and modify data at data_mem */
/*               ...                */

msync(data_mem, fsize, MS_SYNC);            /* EINVAL */

The next BSP release will have below functions in nvbuf_utils.h for this.

NvBufferMemMap
NvBufferMemSyncForCpu
NvBufferMemSyncForDevice
NvBufferMemUnMap

If still have any question, please let me know.

Are there any samples demonstrating use of these functions?

Looks like you have found it :p https://devtalk.nvidia.com/default/topic/1026106/jetson-tx1/usage-of-nvbuffer-apis/post/5224382/#5224382