Rev 5078 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4075 | Serge | 1 | /************************************************************************** |
2 | * |
||
3 | * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA |
||
4 | * All Rights Reserved. |
||
5 | * |
||
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
7 | * copy of this software and associated documentation files (the |
||
8 | * "Software"), to deal in the Software without restriction, including |
||
9 | * without limitation the rights to use, copy, modify, merge, publish, |
||
10 | * distribute, sub license, and/or sell copies of the Software, and to |
||
11 | * permit persons to whom the Software is furnished to do so, subject to |
||
12 | * the following conditions: |
||
13 | * |
||
14 | * The above copyright notice and this permission notice (including the |
||
15 | * next paragraph) shall be included in all copies or substantial portions |
||
16 | * of the Software. |
||
17 | * |
||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
||
22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
||
23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
||
24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
25 | * |
||
26 | **************************************************************************/ |
||
27 | |||
28 | #define pr_fmt(fmt) "[TTM] " fmt |
||
29 | |||
30 | #include |
||
31 | #include |
||
32 | #include |
||
33 | #include |
||
34 | #include |
||
35 | #include |
||
36 | #include |
||
37 | #include |
||
38 | #include |
||
39 | |||
6296 | serge | 40 | #define TTM_MEMORY_ALLOC_RETRIES 4 |
4075 | Serge | 41 | |
42 | |||
5078 | serge | 43 | int ttm_mem_global_init(struct ttm_mem_global *glob) |
4075 | Serge | 44 | { |
45 | int ret; |
||
5078 | serge | 46 | int i; |
4075 | Serge | 47 | |
5078 | serge | 48 | spin_lock_init(&glob->lock); |
4075 | Serge | 49 | |
50 | |||
51 | |||
5078 | serge | 52 | ttm_page_alloc_init(glob, 4*1024); |
4075 | Serge | 53 | |
54 | return 0; |
||
5078 | serge | 55 | out_no_zone: |
56 | ttm_mem_global_release(glob); |
||
57 | return ret; |
||
4075 | Serge | 58 | } |
5078 | serge | 59 | EXPORT_SYMBOL(ttm_mem_global_init); |
4075 | Serge | 60 | |
61 | void ttm_mem_global_release(struct ttm_mem_global *glob) |
||
62 | { |
||
63 | unsigned int i; |
||
64 | |||
65 | /* let the page allocator first stop the shrink work. */ |
||
5078 | serge | 66 | // ttm_page_alloc_fini(); |
67 | // ttm_dma_page_alloc_fini(); |
||
4075 | Serge | 68 | |
5078 | serge | 69 | |
4075 | Serge | 70 | } |
71 | |||
6296 | serge | 72 | void ttm_mem_global_free(struct ttm_mem_global *glob, |
73 | uint64_t amount) |
||
74 | { |
||
4075 | Serge | 75 | |
6296 | serge | 76 | } |
77 | EXPORT_SYMBOL(ttm_mem_global_free); |
||
4075 | Serge | 78 | |
6296 | serge | 79 | int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, |
80 | bool no_wait, bool interruptible) |
||
81 | { |
||
82 | /** |
||
83 | * Normal allocations of kernel memory are registered in |
||
84 | * all zones. |
||
85 | */ |
||
86 | |||
87 | return 0; |
||
88 | } |
||
89 | EXPORT_SYMBOL(ttm_mem_global_alloc); |
||
90 | |||
4075 | Serge | 91 | size_t ttm_round_pot(size_t size) |
92 | { |
||
93 | if ((size & (size - 1)) == 0) |
||
94 | return size; |
||
95 | else if (size > PAGE_SIZE) |
||
96 | return PAGE_ALIGN(size); |
||
97 | else { |
||
98 | size_t tmp_size = 4; |
||
99 | |||
100 | while (tmp_size < size) |
||
101 | tmp_size <<= 1; |
||
102 | |||
103 | return tmp_size; |
||
104 | } |
||
105 | return 0; |
||
106 | } |
||
107 | EXPORT_SYMBOL(ttm_round_pot);=><=>> |