diff options
author | Robert Tivy <rtivy@ti.com> | 2014-05-08 17:24:11 -0700 |
---|---|---|
committer | Robert Tivy <rtivy@ti.com> | 2014-05-08 17:24:11 -0700 |
commit | b47334c21389b2fe90665d8fb01db640ca6af00f (patch) | |
tree | 67427cd9a85ec13e0d589f6b8c5eda3b73e2d6a9 | |
parent | 4f62732ae9159695b27de4b48a00e25e20d6c3fe (diff) | |
download | linuxutils-b47334c21389b2fe90665d8fb01db640ca6af00f.tar.gz |
Add CMEM_cacheWbInvAll() API
For buffer sizes above a certain threshold, a writeback/invalidate-all
operation is quicker than a range-based writeback/invalidate.
-rw-r--r-- | include/ti/cmem.h | 17 | ||||
-rw-r--r-- | src/cmem/api/cmem.c | 19 | ||||
-rw-r--r-- | src/cmem/module/cmemk.c | 6 |
3 files changed, 42 insertions, 0 deletions
diff --git a/include/ti/cmem.h b/include/ti/cmem.h index ae00753..f840813 100644 --- a/include/ti/cmem.h +++ b/include/ti/cmem.h @@ -263,6 +263,7 @@ extern "C" { #define CMEM_IOCGETBLOCK 9 #define CMEM_IOCREGUSER 10 #define CMEM_IOCGETNUMBLOCKS 11 +#define CMEM_IOCCACHEWBINVALL 12 /* * New ioctl cmds should use integers greater than the largest current cmd * in order to not break backward compatibility. @@ -698,6 +699,19 @@ int CMEM_unregister(void *ptr, CMEM_AllocParams *params); off_t CMEM_getPhys(void *ptr); /** + * @brief Do a cache writeback/invalidate of the whole cache + * + * @return Success/failure boolean value + * + * @pre Must have called CMEM_init() + * + * @sa CMEM_cacheWb() + * @sa CMEM_cacheInv() + * @sa CMEM_cacheWbInv() + */ +int CMEM_cacheWbInvAll(void); + +/** * @brief Do a cache writeback of the block pointed to by @c ptr/@c size * * @param ptr Pointer to block to writeback @@ -709,6 +723,7 @@ off_t CMEM_getPhys(void *ptr); * * @sa CMEM_cacheInv() * @sa CMEM_cacheWbInv() + * @sa CMEM_cacheWbInvAll() */ int CMEM_cacheWb(void *ptr, size_t size); @@ -755,6 +770,7 @@ int CMEM_unmap(void *userp, size_t size); * * @sa CMEM_cacheWb() * @sa CMEM_cacheWbInv() + * @sa CMEM_cacheWbInvAll() */ int CMEM_cacheInv(void *ptr, size_t size); @@ -771,6 +787,7 @@ int CMEM_cacheInv(void *ptr, size_t size); * * @sa CMEM_cacheInv() * @sa CMEM_cacheWb() + * @sa CMEM_cacheWbInvAll() */ int CMEM_cacheWbInv(void *ptr, size_t size); diff --git a/src/cmem/api/cmem.c b/src/cmem/api/cmem.c index c4140ec..6da582e 100644 --- a/src/cmem/api/cmem.c +++ b/src/cmem/api/cmem.c @@ -622,6 +622,25 @@ off_t CMEM_getPhys(void *ptr) return (off_t)getDesc.physp; } +int CMEM_cacheWbInvAll(void) +{ + __D("cacheWbInvAll: entered\n"); + + if (!validate_init()) { + return -1; + } + + if (ioctl(cmem_fd, CMEM_IOCCACHEWBINVALL | CMEM_IOCMAGIC, NULL) == -1) { + __E("cacheWbInvAll: Failed to writeback/invalidate all\n"); + + return -1; + } + + __D("cacheWbInvAll: exiting, ioctl CMEM_IOCCACHEWBINVALL succeeded, returning 0\n"); + + return 0; +} + int CMEM_cacheWb(void *ptr, size_t size) { struct block_struct block; diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c index 3db8e13..e757345 100644 --- a/src/cmem/module/cmemk.c +++ b/src/cmem/module/cmemk.c @@ -1689,6 +1689,12 @@ alloc: __D("GETPOOL: returning %d\n", pool); break; + case CMEM_IOCCACHEWBINVALL: + flush_cache_all(); + __D("CACHEWBINVALL: flush all cache\n"); + + break; + case CMEM_IOCCACHE: __D("CACHE%s%s ioctl received.\n", cmd & CMEM_WB ? "WB" : "", cmd & CMEM_INV ? "INV" : ""); |