diff options
author | Simon Glass | 2022-10-29 19:47:08 -0600 |
---|---|---|
committer | Simon Glass | 2022-11-07 16:24:30 -0700 |
commit | 5ea894ac4285be2bebc2e7bdfd6451c699469f37 (patch) | |
tree | 52ab410f3ca011c24657c5498859efac5f93dc4a /include | |
parent | fa1e420ab0259b0e8c975a6572dc3086596b980e (diff) |
dm: test: Clear the block cache after running a test
Some tests access data in block devices and so cause the cache to fill
up. This results in memory being allocated.
Some tests check the malloc usage at the beginning and then again at the
end, to ensure there is no memory leak caused by the test. The block cache
makes this difficult, since the any test may cause entries to be allocated
or even freed, if the cache becomes full.
It is simpler to clear the block cache after each test. This ensures that
it will not introduce noise in tests which check malloc usage.
Add the logic to clear the cache, using the existing blkcache_invalidate()
function. Drop the duplicate code at the same time.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/blk.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/blk.h b/include/blk.h index e854166edb9..c8cbb64c7f8 100644 --- a/include/blk.h +++ b/include/blk.h @@ -147,8 +147,8 @@ void blkcache_fill(int iftype, int dev, * blkcache_invalidate() - discard the cache for a set of blocks * because of a write or device (re)initialization. * - * @param iftype - uclass_id_x for type of device - * @param dev - device index of particular type + * @iftype - UCLASS_ID_ for type of device, or -1 for any + * @dev - device index of particular type, if @iftype is not -1 */ void blkcache_invalidate(int iftype, int dev); @@ -178,6 +178,9 @@ struct block_cache_stats { */ void blkcache_stats(struct block_cache_stats *stats); +/** blkcache_free() - free all memory allocated to the block cache */ +void blkcache_free(void); + #else static inline int blkcache_read(int iftype, int dev, @@ -193,6 +196,8 @@ static inline void blkcache_fill(int iftype, int dev, static inline void blkcache_invalidate(int iftype, int dev) {} +static inline void blkcache_free(void) {} + #endif #if CONFIG_IS_ENABLED(BLK) |