aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-07-18 03:17:09 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-10-02 23:12:53 -0400
commit8be21a6402baa502cd6475e137760afdb2b5dba8 (patch)
treef64e53b12cf06a50718f13a614dbd7b477418787
parent017e6e2955a8b290653aa71bd321609d0d4b1486 (diff)
drm/nouveau: pull nouveau_bo definitions into their own header
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.h92
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h87
4 files changed, 97 insertions, 90 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h
new file mode 100644
index 000000000000..a0a889cbf5ca
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
@@ -0,0 +1,92 @@
1#ifndef __NOUVEAU_BO_H__
2#define __NOUVEAU_BO_H__
3
4struct nouveau_channel;
5struct nouveau_vma;
6
7struct nouveau_tile_reg {
8 bool used;
9 struct nouveau_fence *fence;
10};
11
12struct nouveau_bo {
13 struct ttm_buffer_object bo;
14 struct ttm_placement placement;
15 u32 valid_domains;
16 u32 placements[3];
17 u32 busy_placements[3];
18 struct ttm_bo_kmap_obj kmap;
19 struct list_head head;
20
21 /* protected by ttm_bo_reserve() */
22 struct drm_file *reserved_by;
23 struct list_head entry;
24 int pbbo_index;
25 bool validate_mapped;
26
27 struct list_head vma_list;
28 unsigned page_shift;
29
30 u32 tile_mode;
31 u32 tile_flags;
32 struct nouveau_tile_reg *tile;
33
34 struct drm_gem_object *gem;
35 int pin_refcnt;
36
37 struct ttm_bo_kmap_obj dma_buf_vmap;
38 int vmapping_count;
39};
40
41static inline struct nouveau_bo *
42nouveau_bo(struct ttm_buffer_object *bo)
43{
44 return container_of(bo, struct nouveau_bo, bo);
45}
46
47static inline int
48nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
49{
50 struct nouveau_bo *prev;
51
52 if (!pnvbo)
53 return -EINVAL;
54 prev = *pnvbo;
55
56 *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;
57 if (prev) {
58 struct ttm_buffer_object *bo = &prev->bo;
59
60 ttm_bo_unref(&bo);
61 }
62
63 return 0;
64}
65
66extern struct ttm_bo_driver nouveau_bo_driver;
67
68void nouveau_bo_move_init(struct nouveau_channel *);
69int nouveau_bo_new(struct drm_device *, int size, int align, u32 flags,
70 u32 tile_mode, u32 tile_flags, struct sg_table *sg,
71 struct nouveau_bo **);
72int nouveau_bo_pin(struct nouveau_bo *, u32 flags);
73int nouveau_bo_unpin(struct nouveau_bo *);
74int nouveau_bo_map(struct nouveau_bo *);
75void nouveau_bo_unmap(struct nouveau_bo *);
76void nouveau_bo_placement_set(struct nouveau_bo *, u32 type, u32 busy);
77u16 nouveau_bo_rd16(struct nouveau_bo *, unsigned index);
78void nouveau_bo_wr16(struct nouveau_bo *, unsigned index, u16 val);
79u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
80void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
81void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
82int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
83 bool no_wait_reserve, bool no_wait_gpu);
84
85struct nouveau_vma *
86nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
87
88int nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
89 struct nouveau_vma *);
90void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
91
92#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index b7c2423a2536..fd4d9513585e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -32,6 +32,10 @@
32#include "nouveau_fence.h" 32#include "nouveau_fence.h"
33#include "nouveau_software.h" 33#include "nouveau_software.h"
34 34
35MODULE_PARM_DESC(vram_pushbuf, "Force DMA push buffers to be in VRAM");
36int nouveau_vram_pushbuf;
37module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
38
35static int 39static int
36nouveau_channel_pushbuf_init(struct nouveau_channel *chan) 40nouveau_channel_pushbuf_init(struct nouveau_channel *chan)
37{ 41{
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 561bc00c4851..4b90f12575b9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -43,10 +43,6 @@ MODULE_PARM_DESC(modeset, "Enable kernel modesetting");
43int nouveau_modeset = -1; 43int nouveau_modeset = -1;
44module_param_named(modeset, nouveau_modeset, int, 0400); 44module_param_named(modeset, nouveau_modeset, int, 0400);
45 45
46MODULE_PARM_DESC(vram_pushbuf, "Force DMA push buffers to be in VRAM");
47int nouveau_vram_pushbuf;
48module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
49
50MODULE_PARM_DESC(vram_notify, "Force DMA notifiers to be in VRAM"); 46MODULE_PARM_DESC(vram_notify, "Force DMA notifiers to be in VRAM");
51int nouveau_vram_notify = 0; 47int nouveau_vram_notify = 0;
52module_param_named(vram_notify, nouveau_vram_notify, int, 0400); 48module_param_named(vram_notify, nouveau_vram_notify, int, 0400);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 760af9286819..2374bb6f3c91 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -104,50 +104,12 @@ struct nouveau_mem;
104#define NOUVEAU_MAX_CHANNEL_NR 4096 104#define NOUVEAU_MAX_CHANNEL_NR 4096
105#define NOUVEAU_MAX_TILE_NR 15 105#define NOUVEAU_MAX_TILE_NR 15
106 106
107struct nouveau_tile_reg { 107#include "nouveau_bo.h"
108 bool used;
109 struct nouveau_fence *fence;
110};
111
112struct nouveau_bo {
113 struct ttm_buffer_object bo;
114 struct ttm_placement placement;
115 u32 valid_domains;
116 u32 placements[3];
117 u32 busy_placements[3];
118 struct ttm_bo_kmap_obj kmap;
119 struct list_head head;
120
121 /* protected by ttm_bo_reserve() */
122 struct drm_file *reserved_by;
123 struct list_head entry;
124 int pbbo_index;
125 bool validate_mapped;
126
127 struct list_head vma_list;
128 unsigned page_shift;
129
130 uint32_t tile_mode;
131 uint32_t tile_flags;
132 struct nouveau_tile_reg *tile;
133
134 struct drm_gem_object *gem;
135 int pin_refcnt;
136
137 struct ttm_bo_kmap_obj dma_buf_vmap;
138 int vmapping_count;
139};
140 108
141#define nouveau_bo_tile_layout(nvbo) \ 109#define nouveau_bo_tile_layout(nvbo) \
142 ((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) 110 ((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)
143 111
144static inline struct nouveau_bo * 112static inline struct nouveau_bo *
145nouveau_bo(struct ttm_buffer_object *bo)
146{
147 return container_of(bo, struct nouveau_bo, bo);
148}
149
150static inline struct nouveau_bo *
151nouveau_gem_object(struct drm_gem_object *gem) 113nouveau_gem_object(struct drm_gem_object *gem)
152{ 114{
153 return gem ? gem->driver_private : NULL; 115 return gem ? gem->driver_private : NULL;
@@ -591,25 +553,6 @@ nouveau_bdev(struct ttm_bo_device *bd)
591 return container_of(bd, struct drm_nouveau_private, ttm.bdev); 553 return container_of(bd, struct drm_nouveau_private, ttm.bdev);
592} 554}
593 555
594static inline int
595nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
596{
597 struct nouveau_bo *prev;
598
599 if (!pnvbo)
600 return -EINVAL;
601 prev = *pnvbo;
602
603 *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL;
604 if (prev) {
605 struct ttm_buffer_object *bo = &prev->bo;
606
607 ttm_bo_unref(&bo);
608 }
609
610 return 0;
611}
612
613/* nouveau_drv.c */ 556/* nouveau_drv.c */
614extern int nouveau_modeset; 557extern int nouveau_modeset;
615extern int nouveau_duallink; 558extern int nouveau_duallink;
@@ -931,34 +874,6 @@ void nvd0_display_flip_stop(struct drm_crtc *);
931int nvd0_display_flip_next(struct drm_crtc *, struct drm_framebuffer *, 874int nvd0_display_flip_next(struct drm_crtc *, struct drm_framebuffer *,
932 struct nouveau_channel *, u32 swap_interval); 875 struct nouveau_channel *, u32 swap_interval);
933 876
934/* nouveau_bo.c */
935extern struct ttm_bo_driver nouveau_bo_driver;
936extern void nouveau_bo_move_init(struct nouveau_channel *);
937extern int nouveau_bo_new(struct drm_device *, int size, int align,
938 uint32_t flags, uint32_t tile_mode,
939 uint32_t tile_flags,
940 struct sg_table *sg,
941 struct nouveau_bo **);
942extern int nouveau_bo_pin(struct nouveau_bo *, uint32_t flags);
943extern int nouveau_bo_unpin(struct nouveau_bo *);
944extern int nouveau_bo_map(struct nouveau_bo *);
945extern void nouveau_bo_unmap(struct nouveau_bo *);
946extern void nouveau_bo_placement_set(struct nouveau_bo *, uint32_t type,
947 uint32_t busy);
948extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index);
949extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val);
950extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index);
951extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val);
952extern void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
953extern int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
954 bool no_wait_reserve, bool no_wait_gpu);
955
956extern struct nouveau_vma *
957nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
958extern int nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
959 struct nouveau_vma *);
960extern void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
961
962/* nouveau_gem.c */ 877/* nouveau_gem.c */
963extern int nouveau_gem_new(struct drm_device *, int size, int align, 878extern int nouveau_gem_new(struct drm_device *, int size, int align,
964 uint32_t domain, uint32_t tile_mode, 879 uint32_t domain, uint32_t tile_mode,