1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
/* Copyright (c) 2012,2014, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _ARCH_ARM_MACH_MSM_OCMEM_H
#define _ARCH_ARM_MACH_MSM_OCMEM_H
#include <asm/page.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/err.h>
#define OCMEM_MIN_ALLOC SZ_64K
#define OCMEM_MIN_ALIGN SZ_64K
/* Maximum number of slots in DM */
#define OCMEM_MAX_CHUNKS 32
#define MIN_CHUNK_SIZE SZ_4K
struct ocmem_notifier;
struct ocmem_buf {
unsigned long addr;
unsigned long len;
};
struct ocmem_buf_attr {
unsigned long paddr;
unsigned long len;
};
struct ocmem_chunk {
bool ro;
unsigned long ddr_paddr;
unsigned long size;
};
struct ocmem_map_list {
unsigned num_chunks;
struct ocmem_chunk chunks[OCMEM_MAX_CHUNKS];
};
enum ocmem_power_state {
OCMEM_OFF = 0x0,
OCMEM_RETENTION,
OCMEM_ON,
OCMEM_MAX = OCMEM_ON,
};
struct ocmem_resource {
unsigned resource_id;
unsigned num_keys;
unsigned int *keys;
};
struct ocmem_vectors {
unsigned num_resources;
struct ocmem_resource *r;
};
/* List of clients that allocate/interact with OCMEM */
/* Must be in sync with client_names */
enum ocmem_client {
/* GMEM clients */
OCMEM_GRAPHICS = 0x0,
/* TCMEM clients */
OCMEM_VIDEO,
OCMEM_CAMERA,
/* Dummy Clients */
OCMEM_HP_AUDIO,
OCMEM_VOICE,
/* IMEM Clients */
OCMEM_LP_AUDIO,
OCMEM_SENSORS,
OCMEM_OTHER_OS,
OCMEM_CLIENT_MAX,
};
/**
* List of OCMEM notification events which will be broadcasted
* to clients that optionally register for these notifications
* on a per allocation basis.
**/
enum ocmem_notif_type {
OCMEM_MAP_DONE = 1,
OCMEM_MAP_FAIL,
OCMEM_UNMAP_DONE,
OCMEM_UNMAP_FAIL,
OCMEM_ALLOC_GROW,
OCMEM_ALLOC_SHRINK,
OCMEM_NOTIF_TYPE_COUNT,
};
/* APIS */
#ifdef CONFIG_MSM_OCMEM
/* Notification APIs */
struct ocmem_notifier *ocmem_notifier_register(int client_id,
struct notifier_block *nb);
int ocmem_notifier_unregister(struct ocmem_notifier *notif_hndl,
struct notifier_block *nb);
/* Obtain the maximum quota for the client */
unsigned long get_max_quota(int client_id);
/* Allocation APIs */
struct ocmem_buf *ocmem_allocate(int client_id, unsigned long size);
struct ocmem_buf *ocmem_allocate_nowait(int client_id, unsigned long size);
struct ocmem_buf *ocmem_allocate_nb(int client_id, unsigned long size);
struct ocmem_buf *ocmem_allocate_range(int client_id, unsigned long min,
unsigned long goal, unsigned long step);
/* Free APIs */
int ocmem_free(int client_id, struct ocmem_buf *buf);
/* Dynamic Resize APIs */
int ocmem_shrink(int client_id, struct ocmem_buf *buf,
unsigned long new_size);
/* Transfer APIs */
int ocmem_map(int client_id, struct ocmem_buf *buffer,
struct ocmem_map_list *list);
int ocmem_unmap(int client_id, struct ocmem_buf *buffer,
struct ocmem_map_list *list);
int ocmem_drop(int client_id, struct ocmem_buf *buffer,
struct ocmem_map_list *list);
int ocmem_dump(int client_id, struct ocmem_buf *buffer,
unsigned long dst_phys_addr);
/* Priority Enforcement APIs */
int ocmem_evict(int client_id);
int ocmem_restore(int client_id);
/* Power Control APIs */
int ocmem_set_power_state(int client_id, struct ocmem_buf *buf,
enum ocmem_power_state new_state);
enum ocmem_power_state ocmem_get_power_state(int client_id,
struct ocmem_buf *buf);
struct ocmem_vectors *ocmem_get_vectors(int client_id,
struct ocmem_buf *buf);
#else
/* Notification APIs */
static inline struct ocmem_notifier *ocmem_notifier_register
(int client_id, struct notifier_block *nb)
{
return ERR_PTR(-ENODEV);
}
static inline int ocmem_notifier_unregister(struct ocmem_notifier *notif_hndl,
struct notifier_block *nb)
{
return -ENODEV;
}
/* Obtain the maximum quota for the client */
static inline unsigned long get_max_quota(int client_id)
{
return 0;
}
/* Allocation APIs */
static inline struct ocmem_buf *ocmem_allocate(int client_id,
unsigned long size)
{
return ERR_PTR(-ENODEV);
}
static inline struct ocmem_buf *ocmem_allocate_nowait(int client_id,
unsigned long size)
{
return ERR_PTR(-ENODEV);
}
static inline struct ocmem_buf *ocmem_allocate_nb(int client_id,
unsigned long size)
{
return ERR_PTR(-ENODEV);
}
static inline struct ocmem_buf *ocmem_allocate_range(int client_id,
unsigned long min, unsigned long goal, unsigned long step)
{
return ERR_PTR(-ENODEV);
}
/* Free APIs */
static inline int ocmem_free(int client_id, struct ocmem_buf *buf)
{
return -ENODEV;
}
/* Dynamic Resize APIs */
static inline int ocmem_shrink(int client_id, struct ocmem_buf *buf,
unsigned long new_size)
{
return -ENODEV;
}
/* Transfer APIs */
static inline int ocmem_map(int client_id, struct ocmem_buf *buffer,
struct ocmem_map_list *list)
{
return -ENODEV;
}
static inline int ocmem_unmap(int client_id, struct ocmem_buf *buffer,
struct ocmem_map_list *list)
{
return -ENODEV;
}
static inline int ocmem_dump(int client_id, struct ocmem_buf *buffer,
unsigned long dst_phys_addr)
{
return -ENODEV;
}
/* Priority Enforcement APIs */
static inline int ocmem_evict(int client_id)
{
return -ENODEV;
}
static inline int ocmem_restore(int client_id)
{
return -ENODEV;
}
/* Power Control APIs */
static inline int ocmem_set_power_state(int client_id,
struct ocmem_buf *buf, enum ocmem_power_state new_state)
{
return -ENODEV;
}
static inline enum ocmem_power_state ocmem_get_power_state(int client_id,
struct ocmem_buf *buf)
{
return -ENODEV;
}
static inline struct ocmem_vectors *ocmem_get_vectors(int client_id,
struct ocmem_buf *buf)
{
return ERR_PTR(-ENODEV);
}
#endif
#endif
|