ikwzm / udmabuf

User space mappable dma buffer device driver for Linux.
BSD 2-Clause "Simplified" License
539 stars 165 forks source link

Regarding Manual cache management with the CPU cache still being enabled #76

Open balaji-ch opened 3 years ago

balaji-ch commented 3 years ago

Do we need to call fd = open("/sys/class/u-dma-buf/udmabuf0/sync_for_device", O_WRONLY)) != -1) once before mmap ? or any special care need to be taken for manual cache management ?

ikwzm commented 3 years ago

Thank you for the issue.

Do we need to call fd = open("/sys/class/u-dma-buf/udmabuf0/sync_for_device", O_WRONLY)) != -1) once before mmap ?

there is no need. It's the same whether you open the file before mmap() or after mmap().

or any special care need to be taken for manual cache management ?

Knowledge of general CPU Cache and Linux Kernel is required.

balaji-ch commented 3 years ago

But here in this example https://github.com/ikwzm/ZynqMP-FPGA-Linux-Example-2-UltraZed/blob/master/negative.py udmabuf4.sync_for_device() udmabuf5.sync_for_device() is called in the for loop ?

ikwzm commented 3 years ago

In this example, sync_for_device()/sync_for_cpu() is inside the loop because it runs multiple times to calculate the average time it takes to process it.