summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2015-03-16 17:31:18 +0900
committerAtsushi Kumagai <kumagai-atsushi@mxc.nes.nec.co.jp>2015-03-16 17:51:57 +0900
commite068ea2e424c659bd2ce1492e41cf9a73c8595a3 (patch)
tree4e9d82ce2ccf8b23780d443442ec6f9134e8222c /cache.h
parentfebff059d4dfd86959e1d520940498affa4e124f (diff)
[PATCH v3 1/7] cache: get rid of search loop in cache_add().
The intention was that cache code is re-entrant, so all cache entries should go through these states: 1. free 2. pending read 3. used The cache_add() function is used to move an entry from state 2 to 3, but since the caller did not know cache entry pointer, it had to search the pending list for a pending read for the given physical address. This is not needed if cache_alloc() returns this pointer. Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/cache.h b/cache.h
index 4730e12..dab8eb9 100644
--- a/cache.h
+++ b/cache.h
@@ -19,9 +19,15 @@
#ifndef _CACHE_H
#define _CACHE_H
+struct cache_entry {
+ unsigned long long paddr;
+ void *bufptr;
+ struct cache_entry *next, *prev;
+};
+
int cache_init(void);
void *cache_search(unsigned long long paddr);
-void *cache_alloc(unsigned long long paddr);
-void cache_add(unsigned long long paddr);
+struct cache_entry *cache_alloc(unsigned long long paddr);
+void cache_add(struct cache_entry *entry);
#endif /* _CACHE_H */