2 * Support for Medifield PNW Camera Imaging ISP subsystem.
4 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #ifndef __HMM_POOL_H__
24 #define __HMM_POOL_H__
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/list.h>
29 #include <linux/spinlock.h>
30 #include <linux/mutex.h>
31 #include <linux/kref.h>
32 #include "hmm_common.h"
33 #include "hmm/hmm_bo.h"
35 #define ALLOC_PAGE_FAIL_NUM 5
38 HMM_POOL_TYPE_RESERVED,
39 HMM_POOL_TYPE_DYNAMIC,
43 * struct hmm_pool_ops - memory pool callbacks.
45 * @pool_init: initialize the memory pool.
46 * @pool_exit: uninitialize the memory pool.
47 * @pool_alloc_pages: allocate pages from memory pool.
48 * @pool_free_pages: free pages to memory pool.
49 * @pool_inited: check whether memory pool is initialized.
52 int (*pool_init)(void **pool, unsigned int pool_size);
53 void (*pool_exit)(void **pool);
54 unsigned int (*pool_alloc_pages)(void *pool,
55 struct hmm_page_object *page_obj,
56 unsigned int size, bool cached);
57 void (*pool_free_pages)(void *pool,
58 struct hmm_page_object *page_obj);
59 int (*pool_inited)(void *pool);
63 struct hmm_pool_ops *pops;
69 * struct hmm_reserved_pool_info - represents reserved pool private data.
70 * @pages: a array that store physical pages.
71 * The array is as reserved memory pool.
72 * @index: to indicate the first blank page number
73 * in reserved memory pool(pages array).
74 * @pgnr: the valid page amount in reserved memory
76 * @list_lock: list lock is used to protect the operation
77 * to reserved memory pool.
78 * @flag: reserved memory pool state flag.
80 struct hmm_reserved_pool_info {
90 * struct hmm_dynamic_pool_info - represents dynamic pool private data.
91 * @pages_list: a list that store physical pages.
92 * The pages list is as dynamic memory pool.
93 * @list_lock: list lock is used to protect the operation
94 * to dynamic memory pool.
95 * @flag: dynamic memory pool state flag.
96 * @pgptr_cache: struct kmem_cache, manages a cache.
98 struct hmm_dynamic_pool_info {
99 struct list_head pages_list;
101 /* list lock is used to protect the free pages block lists */
102 spinlock_t list_lock;
104 struct kmem_cache *pgptr_cache;
107 unsigned int pool_size;
113 struct list_head list;
116 extern struct hmm_pool_ops reserved_pops;
117 extern struct hmm_pool_ops dynamic_pops;