summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/page_allocator_priv.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/page_allocator_priv.h69
1 files changed, 66 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h b/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h
index 3d4e3c43..7d7f43c2 100644
--- a/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h
+++ b/drivers/gpu/nvgpu/gk20a/page_allocator_priv.h
@@ -19,12 +19,63 @@
19 19
20#include <linux/list.h> 20#include <linux/list.h>
21#include <linux/rbtree.h> 21#include <linux/rbtree.h>
22#include <gk20a/gk20a_allocator.h>
23 22
24#include "gk20a_allocator.h" 23#include "gk20a_allocator.h"
25 24
26struct gk20a_allocator; 25struct gk20a_allocator;
27 26
27/*
28 * This allocator implements the ability to do SLAB style allocation since the
29 * GPU has two page sizes available - 4k and 64k/128k. When the default
30 * granularity is the large page size (64k/128k) small allocations become very
31 * space inefficient. This is most notable in PDE and PTE blocks which are 4k
32 * in size.
33 *
34 * Thus we need the ability to suballocate in 64k pages. The way we do this for
35 * the GPU is as follows. We have several buckets for sub-64K allocations:
36 *
37 * B0 - 4k
38 * B1 - 8k
39 * B3 - 16k
40 * B4 - 32k
41 * B5 - 64k (for when large pages are 128k)
42 *
43 * When an allocation comes in for less than the large page size (from now on
44 * assumed to be 64k) the allocation is satisfied by one of the buckets.
45 */
46struct page_alloc_slab {
47 struct list_head empty;
48 struct list_head partial;
49 struct list_head full;
50
51 int nr_empty;
52 int nr_partial;
53 int nr_full;
54
55 u32 slab_size;
56};
57
58enum slab_page_state {
59 SP_EMPTY,
60 SP_PARTIAL,
61 SP_FULL,
62 SP_NONE
63};
64
65struct page_alloc_slab_page {
66 unsigned long bitmap;
67 u64 page_addr;
68 u32 slab_size;
69
70 u32 nr_objects;
71 u32 nr_objects_alloced;
72
73 enum slab_page_state state;
74
75 struct page_alloc_slab *owner;
76 struct list_head list_entry;
77};
78
28struct page_alloc_chunk { 79struct page_alloc_chunk {
29 struct list_head list_entry; 80 struct list_head list_entry;
30 81
@@ -34,7 +85,7 @@ struct page_alloc_chunk {
34 85
35/* 86/*
36 * Struct to handle internal management of page allocation. It holds a list 87 * Struct to handle internal management of page allocation. It holds a list
37 * of the chunks of page that make up the overall allocation - much like a 88 * of the chunks of pages that make up the overall allocation - much like a
38 * scatter gather table. 89 * scatter gather table.
39 */ 90 */
40struct gk20a_page_alloc { 91struct gk20a_page_alloc {
@@ -44,13 +95,20 @@ struct gk20a_page_alloc {
44 u64 length; 95 u64 length;
45 96
46 /* 97 /*
47 * Only useful for the RB tree - since the alloc will have discontiguous 98 * Only useful for the RB tree - since the alloc may have discontiguous
48 * pages the base is essentially irrelevant except for the fact that it 99 * pages the base is essentially irrelevant except for the fact that it
49 * is guarenteed to be unique. 100 * is guarenteed to be unique.
50 */ 101 */
51 u64 base; 102 u64 base;
52 103
53 struct rb_node tree_entry; 104 struct rb_node tree_entry;
105
106 /*
107 * Set if this is a slab alloc. Points back to the slab page that owns
108 * this particular allocation. nr_chunks will always be 1 if this is
109 * set.
110 */
111 struct page_alloc_slab_page *slab_page;
54}; 112};
55 113
56struct gk20a_page_allocator { 114struct gk20a_page_allocator {
@@ -73,6 +131,9 @@ struct gk20a_page_allocator {
73 131
74 struct rb_root allocs; /* Outstanding allocations. */ 132 struct rb_root allocs; /* Outstanding allocations. */
75 133
134 struct page_alloc_slab *slabs;
135 int nr_slabs;
136
76 u64 flags; 137 u64 flags;
77 138
78 /* 139 /*
@@ -82,6 +143,8 @@ struct gk20a_page_allocator {
82 u64 nr_frees; 143 u64 nr_frees;
83 u64 nr_fixed_allocs; 144 u64 nr_fixed_allocs;
84 u64 nr_fixed_frees; 145 u64 nr_fixed_frees;
146 u64 nr_slab_allocs;
147 u64 nr_slab_frees;
85 u64 pages_alloced; 148 u64 pages_alloced;
86 u64 pages_freed; 149 u64 pages_freed;
87}; 150};