When allocating pages from GCMA, they should have the refcount at 1 so that they can be used later for mapping them. Fix refcount initialization. Note that when pages are returned to GCMA they should be in the same state, with the caller as the only refcount holder and no other possible (even temporary) users, which means the page should not be on any LRU or otherwise accessible by the rest of the kernel. Bug: 437025819 Bug: 436722327 Change-Id: Ib61e0bce6537ec7d5483d7175e7ba8376c9c7d68 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __GCMA_H__
|
|
#define __GCMA_H__
|
|
|
|
#include <linux/types.h>
|
|
|
|
#ifdef CONFIG_GCMA
|
|
enum gcma_stat_type {
|
|
ALLOCATED_PAGE,
|
|
STORED_PAGE,
|
|
LOADED_PAGE,
|
|
EVICTED_PAGE,
|
|
CACHED_PAGE,
|
|
DISCARDED_PAGE,
|
|
TOTAL_PAGE,
|
|
NUM_OF_GCMA_STAT,
|
|
};
|
|
|
|
#ifdef CONFIG_GCMA_SYSFS
|
|
u64 gcma_stat_get(enum gcma_stat_type type);
|
|
#else
|
|
static inline u64 gcma_stat_get(enum gcma_stat_type type) { return 0; }
|
|
#endif
|
|
|
|
/*
|
|
* NOTE: allocated pages are still marked reserved and when freeing them
|
|
* the caller should ensure they are isolated and not referenced by anyone
|
|
* other than the caller.
|
|
*/
|
|
extern void gcma_alloc_range(unsigned long start_pfn, unsigned long end_pfn);
|
|
extern void gcma_free_range(unsigned long start_pfn, unsigned long end_pfn);
|
|
extern int register_gcma_area(const char *name, phys_addr_t base,
|
|
phys_addr_t size);
|
|
#else
|
|
static inline void gcma_alloc_range(unsigned long start_pfn,
|
|
unsigned long end_pfn) {}
|
|
static inline void gcma_free_range(unsigned long start_pfn,
|
|
unsigned long end_pfn) {}
|
|
static inline int register_gcma_area(const char *name, phys_addr_t base,
|
|
phys_addr_t size) { return -EINVAL; }
|
|
#endif
|
|
|
|
#endif
|