Write drivers always run into things that are related to the cache.
Log the interfaces used:
The memory address used in the drive is usually the kernel address, when the user calls the driver interface, sometimes the address of the application is assigned to the driver, when the user Kmalloc get the kernel address.
Then use MMAP to obtain the mapped user address, at this time users use the user address, will use the cache, in order to ensure the real-time data, sometimes the driver should be some operation of the cache
1. __sync_cache_range_r ((void*) start, size);
When the user reads the buffer data, it is read from the cache, and this interface invalidates the cache of the kernel address, which is used to read the data directly from the actual physical address.
Thus guaranteeing the correctness of the data
2. __sync_cache_range_w ((void*) start, size);
When the user writes the data, it is written to the cache, the driver in order to ensure that the data is written to the actual physical address, with this interface, the cache failure data to write to the physical address
Linux kernel Cache