aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nvkm/subdev
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-01-14 00:05:26 -0500
committerBen Skeggs <bskeggs@redhat.com>2015-01-21 21:17:55 -0500
commit78b2b4e76be2100637a92b9721aaa2ce73d0fa22 (patch)
tree8d30155a84a7a57e055b9a0cb34833c42cfc4e23 /drivers/gpu/drm/nouveau/nvkm/subdev
parent5ecfadeb89a63b414bfd26ad469b39037930485e (diff)
drm/nouveau/instmem: namespace + nvidia gpu names (no binary change)
The namespace of NVKM is being changed to nvkm_ instead of nouveau_, which will be used for the DRM part of the driver. This is being done in order to make it very clear as to what part of the driver a given symbol belongs to, and as a minor step towards splitting the DRM driver out to be able to stand on its own (for virt). Because there's already a large amount of churn here anyway, this is as good a time as any to also switch to NVIDIA's device and chipset naming to ease collaboration with them. A comparison of objdump disassemblies proves no code changes. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvkm/subdev')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bit.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c74
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c95
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.h32
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv40.c45
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c66
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h76
8 files changed, 187 insertions, 205 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
index bfb0388f8d5b..9200f122c02c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c
@@ -34,7 +34,7 @@
34 * interface to linux i2c bit-banging algorithm 34 * interface to linux i2c bit-banging algorithm
35 *****************************************************************************/ 35 *****************************************************************************/
36 36
37#ifdef CONFIG_NVKM_I2C_INTERNAL_DEFAULT 37#ifdef CONFIG_NOUVEAU_I2C_INTERNAL_DEFAULT
38#define CSTMSEL true 38#define CSTMSEL true
39#else 39#else
40#define CSTMSEL false 40#define CSTMSEL false
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bit.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bit.c
index 35132badaa8f..861a453d2a67 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bit.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/bit.c
@@ -23,7 +23,7 @@
23 */ 23 */
24#include "priv.h" 24#include "priv.h"
25 25
26#ifdef CONFIG_NVKM_I2C_INTERNAL 26#ifdef CONFIG_NOUVEAU_I2C_INTERNAL
27#define T_TIMEOUT 2200000 27#define T_TIMEOUT 2200000
28#define T_RISEFALL 1000 28#define T_RISEFALL 1000
29#define T_HOLD 5000 29#define T_HOLD 5000
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
index 767fcf70f98f..d16358cc6cbb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
@@ -21,38 +21,37 @@
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24
25#include "priv.h" 24#include "priv.h"
26 25
26#include <core/engine.h>
27
27/****************************************************************************** 28/******************************************************************************
28 * instmem object base implementation 29 * instmem object base implementation
29 *****************************************************************************/ 30 *****************************************************************************/
30 31
31void 32void
32_nouveau_instobj_dtor(struct nouveau_object *object) 33_nvkm_instobj_dtor(struct nvkm_object *object)
33{ 34{
34 struct nouveau_instmem *imem = nouveau_instmem(object); 35 struct nvkm_instmem *imem = nvkm_instmem(object);
35 struct nouveau_instobj *iobj = (void *)object; 36 struct nvkm_instobj *iobj = (void *)object;
36 37
37 mutex_lock(&nv_subdev(imem)->mutex); 38 mutex_lock(&nv_subdev(imem)->mutex);
38 list_del(&iobj->head); 39 list_del(&iobj->head);
39 mutex_unlock(&nv_subdev(imem)->mutex); 40 mutex_unlock(&nv_subdev(imem)->mutex);
40 41
41 return nouveau_object_destroy(&iobj->base); 42 return nvkm_object_destroy(&iobj->base);
42} 43}
43 44
44int 45int
45nouveau_instobj_create_(struct nouveau_object *parent, 46nvkm_instobj_create_(struct nvkm_object *parent, struct nvkm_object *engine,
46 struct nouveau_object *engine, 47 struct nvkm_oclass *oclass, int length, void **pobject)
47 struct nouveau_oclass *oclass,
48 int length, void **pobject)
49{ 48{
50 struct nouveau_instmem *imem = nouveau_instmem(parent); 49 struct nvkm_instmem *imem = nvkm_instmem(parent);
51 struct nouveau_instobj *iobj; 50 struct nvkm_instobj *iobj;
52 int ret; 51 int ret;
53 52
54 ret = nouveau_object_create_(parent, engine, oclass, NV_MEMOBJ_CLASS, 53 ret = nvkm_object_create_(parent, engine, oclass, NV_MEMOBJ_CLASS,
55 length, pobject); 54 length, pobject);
56 iobj = *pobject; 55 iobj = *pobject;
57 if (ret) 56 if (ret)
58 return ret; 57 return ret;
@@ -68,26 +67,24 @@ nouveau_instobj_create_(struct nouveau_object *parent,
68 *****************************************************************************/ 67 *****************************************************************************/
69 68
70static int 69static int
71nouveau_instmem_alloc(struct nouveau_instmem *imem, 70nvkm_instmem_alloc(struct nvkm_instmem *imem, struct nvkm_object *parent,
72 struct nouveau_object *parent, u32 size, u32 align, 71 u32 size, u32 align, struct nvkm_object **pobject)
73 struct nouveau_object **pobject)
74{ 72{
75 struct nouveau_instmem_impl *impl = (void *)imem->base.object.oclass; 73 struct nvkm_instmem_impl *impl = (void *)imem->base.object.oclass;
76 struct nouveau_instobj_args args = { .size = size, .align = align }; 74 struct nvkm_instobj_args args = { .size = size, .align = align };
77 return nouveau_object_ctor(parent, &parent->engine->subdev.object, 75 return nvkm_object_ctor(parent, &parent->engine->subdev.object,
78 impl->instobj, &args, sizeof(args), pobject); 76 impl->instobj, &args, sizeof(args), pobject);
79} 77}
80 78
81int 79int
82_nouveau_instmem_fini(struct nouveau_object *object, bool suspend) 80_nvkm_instmem_fini(struct nvkm_object *object, bool suspend)
83{ 81{
84 struct nouveau_instmem *imem = (void *)object; 82 struct nvkm_instmem *imem = (void *)object;
85 struct nouveau_instobj *iobj; 83 struct nvkm_instobj *iobj;
86 int i, ret = 0; 84 int i, ret = 0;
87 85
88 if (suspend) { 86 if (suspend) {
89 mutex_lock(&imem->base.mutex); 87 mutex_lock(&imem->base.mutex);
90
91 list_for_each_entry(iobj, &imem->list, head) { 88 list_for_each_entry(iobj, &imem->list, head) {
92 iobj->suspend = vmalloc(iobj->size); 89 iobj->suspend = vmalloc(iobj->size);
93 if (!iobj->suspend) { 90 if (!iobj->suspend) {
@@ -98,29 +95,26 @@ _nouveau_instmem_fini(struct nouveau_object *object, bool suspend)
98 for (i = 0; i < iobj->size; i += 4) 95 for (i = 0; i < iobj->size; i += 4)
99 iobj->suspend[i / 4] = nv_ro32(iobj, i); 96 iobj->suspend[i / 4] = nv_ro32(iobj, i);
100 } 97 }
101
102 mutex_unlock(&imem->base.mutex); 98 mutex_unlock(&imem->base.mutex);
103
104 if (ret) 99 if (ret)
105 return ret; 100 return ret;
106 } 101 }
107 102
108 return nouveau_subdev_fini(&imem->base, suspend); 103 return nvkm_subdev_fini(&imem->base, suspend);
109} 104}
110 105
111int 106int
112_nouveau_instmem_init(struct nouveau_object *object) 107_nvkm_instmem_init(struct nvkm_object *object)
113{ 108{
114 struct nouveau_instmem *imem = (void *)object; 109 struct nvkm_instmem *imem = (void *)object;
115 struct nouveau_instobj *iobj; 110 struct nvkm_instobj *iobj;
116 int ret, i; 111 int ret, i;
117 112
118 ret = nouveau_subdev_init(&imem->base); 113 ret = nvkm_subdev_init(&imem->base);
119 if (ret) 114 if (ret)
120 return ret; 115 return ret;
121 116
122 mutex_lock(&imem->base.mutex); 117 mutex_lock(&imem->base.mutex);
123
124 list_for_each_entry(iobj, &imem->list, head) { 118 list_for_each_entry(iobj, &imem->list, head) {
125 if (iobj->suspend) { 119 if (iobj->suspend) {
126 for (i = 0; i < iobj->size; i += 4) 120 for (i = 0; i < iobj->size; i += 4)
@@ -129,28 +123,24 @@ _nouveau_instmem_init(struct nouveau_object *object)
129 iobj->suspend = NULL; 123 iobj->suspend = NULL;
130 } 124 }
131 } 125 }
132
133 mutex_unlock(&imem->base.mutex); 126 mutex_unlock(&imem->base.mutex);
134
135 return 0; 127 return 0;
136} 128}
137 129
138int 130int
139nouveau_instmem_create_(struct nouveau_object *parent, 131nvkm_instmem_create_(struct nvkm_object *parent, struct nvkm_object *engine,
140 struct nouveau_object *engine, 132 struct nvkm_oclass *oclass, int length, void **pobject)
141 struct nouveau_oclass *oclass,
142 int length, void **pobject)
143{ 133{
144 struct nouveau_instmem *imem; 134 struct nvkm_instmem *imem;
145 int ret; 135 int ret;
146 136
147 ret = nouveau_subdev_create_(parent, engine, oclass, 0, 137 ret = nvkm_subdev_create_(parent, engine, oclass, 0, "INSTMEM",
148 "INSTMEM", "instmem", length, pobject); 138 "instmem", length, pobject);
149 imem = *pobject; 139 imem = *pobject;
150 if (ret) 140 if (ret)
151 return ret; 141 return ret;
152 142
153 INIT_LIST_HEAD(&imem->list); 143 INIT_LIST_HEAD(&imem->list);
154 imem->alloc = nouveau_instmem_alloc; 144 imem->alloc = nvkm_instmem_alloc;
155 return 0; 145 return 0;
156} 146}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c
index 9ffd2d8d73c4..80614f1b2074 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.c
@@ -21,58 +21,59 @@
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24
25#include "nv04.h" 24#include "nv04.h"
26 25
26#include <core/ramht.h>
27
27/****************************************************************************** 28/******************************************************************************
28 * instmem object implementation 29 * instmem object implementation
29 *****************************************************************************/ 30 *****************************************************************************/
30 31
31static u32 32static u32
32nv04_instobj_rd32(struct nouveau_object *object, u64 addr) 33nv04_instobj_rd32(struct nvkm_object *object, u64 addr)
33{ 34{
34 struct nv04_instmem_priv *priv = (void *)nouveau_instmem(object); 35 struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
35 struct nv04_instobj_priv *node = (void *)object; 36 struct nv04_instobj_priv *node = (void *)object;
36 return nv_ro32(priv, node->mem->offset + addr); 37 return nv_ro32(priv, node->mem->offset + addr);
37} 38}
38 39
39static void 40static void
40nv04_instobj_wr32(struct nouveau_object *object, u64 addr, u32 data) 41nv04_instobj_wr32(struct nvkm_object *object, u64 addr, u32 data)
41{ 42{
42 struct nv04_instmem_priv *priv = (void *)nouveau_instmem(object); 43 struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
43 struct nv04_instobj_priv *node = (void *)object; 44 struct nv04_instobj_priv *node = (void *)object;
44 nv_wo32(priv, node->mem->offset + addr, data); 45 nv_wo32(priv, node->mem->offset + addr, data);
45} 46}
46 47
47static void 48static void
48nv04_instobj_dtor(struct nouveau_object *object) 49nv04_instobj_dtor(struct nvkm_object *object)
49{ 50{
50 struct nv04_instmem_priv *priv = (void *)nouveau_instmem(object); 51 struct nv04_instmem_priv *priv = (void *)nvkm_instmem(object);
51 struct nv04_instobj_priv *node = (void *)object; 52 struct nv04_instobj_priv *node = (void *)object;
52 nouveau_mm_free(&priv->heap, &node->mem); 53 nvkm_mm_free(&priv->heap, &node->mem);
53 nouveau_instobj_destroy(&node->base); 54 nvkm_instobj_destroy(&node->base);
54} 55}
55 56
56static int 57static int
57nv04_instobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 58nv04_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
58 struct nouveau_oclass *oclass, void *data, u32 size, 59 struct nvkm_oclass *oclass, void *data, u32 size,
59 struct nouveau_object **pobject) 60 struct nvkm_object **pobject)
60{ 61{
61 struct nv04_instmem_priv *priv = (void *)nouveau_instmem(parent); 62 struct nv04_instmem_priv *priv = (void *)nvkm_instmem(parent);
62 struct nv04_instobj_priv *node; 63 struct nv04_instobj_priv *node;
63 struct nouveau_instobj_args *args = data; 64 struct nvkm_instobj_args *args = data;
64 int ret; 65 int ret;
65 66
66 if (!args->align) 67 if (!args->align)
67 args->align = 1; 68 args->align = 1;
68 69
69 ret = nouveau_instobj_create(parent, engine, oclass, &node); 70 ret = nvkm_instobj_create(parent, engine, oclass, &node);
70 *pobject = nv_object(node); 71 *pobject = nv_object(node);
71 if (ret) 72 if (ret)
72 return ret; 73 return ret;
73 74
74 ret = nouveau_mm_head(&priv->heap, 0, 1, args->size, args->size, 75 ret = nvkm_mm_head(&priv->heap, 0, 1, args->size, args->size,
75 args->align, &node->mem); 76 args->align, &node->mem);
76 if (ret) 77 if (ret)
77 return ret; 78 return ret;
78 79
@@ -81,13 +82,13 @@ nv04_instobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
81 return 0; 82 return 0;
82} 83}
83 84
84struct nouveau_instobj_impl 85struct nvkm_instobj_impl
85nv04_instobj_oclass = { 86nv04_instobj_oclass = {
86 .base.ofuncs = &(struct nouveau_ofuncs) { 87 .base.ofuncs = &(struct nvkm_ofuncs) {
87 .ctor = nv04_instobj_ctor, 88 .ctor = nv04_instobj_ctor,
88 .dtor = nv04_instobj_dtor, 89 .dtor = nv04_instobj_dtor,
89 .init = _nouveau_instobj_init, 90 .init = _nvkm_instobj_init,
90 .fini = _nouveau_instobj_fini, 91 .fini = _nvkm_instobj_fini,
91 .rd32 = nv04_instobj_rd32, 92 .rd32 = nv04_instobj_rd32,
92 .wr32 = nv04_instobj_wr32, 93 .wr32 = nv04_instobj_wr32,
93 }, 94 },
@@ -98,40 +99,40 @@ nv04_instobj_oclass = {
98 *****************************************************************************/ 99 *****************************************************************************/
99 100
100static u32 101static u32
101nv04_instmem_rd32(struct nouveau_object *object, u64 addr) 102nv04_instmem_rd32(struct nvkm_object *object, u64 addr)
102{ 103{
103 return nv_rd32(object, 0x700000 + addr); 104 return nv_rd32(object, 0x700000 + addr);
104} 105}
105 106
106static void 107static void
107nv04_instmem_wr32(struct nouveau_object *object, u64 addr, u32 data) 108nv04_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
108{ 109{
109 return nv_wr32(object, 0x700000 + addr, data); 110 return nv_wr32(object, 0x700000 + addr, data);
110} 111}
111 112
112void 113void
113nv04_instmem_dtor(struct nouveau_object *object) 114nv04_instmem_dtor(struct nvkm_object *object)
114{ 115{
115 struct nv04_instmem_priv *priv = (void *)object; 116 struct nv04_instmem_priv *priv = (void *)object;
116 nouveau_gpuobj_ref(NULL, &priv->ramfc); 117 nvkm_gpuobj_ref(NULL, &priv->ramfc);
117 nouveau_gpuobj_ref(NULL, &priv->ramro); 118 nvkm_gpuobj_ref(NULL, &priv->ramro);
118 nouveau_ramht_ref(NULL, &priv->ramht); 119 nvkm_ramht_ref(NULL, &priv->ramht);
119 nouveau_gpuobj_ref(NULL, &priv->vbios); 120 nvkm_gpuobj_ref(NULL, &priv->vbios);
120 nouveau_mm_fini(&priv->heap); 121 nvkm_mm_fini(&priv->heap);
121 if (priv->iomem) 122 if (priv->iomem)
122 iounmap(priv->iomem); 123 iounmap(priv->iomem);
123 nouveau_instmem_destroy(&priv->base); 124 nvkm_instmem_destroy(&priv->base);
124} 125}
125 126
126static int 127static int
127nv04_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 128nv04_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
128 struct nouveau_oclass *oclass, void *data, u32 size, 129 struct nvkm_oclass *oclass, void *data, u32 size,
129 struct nouveau_object **pobject) 130 struct nvkm_object **pobject)
130{ 131{
131 struct nv04_instmem_priv *priv; 132 struct nv04_instmem_priv *priv;
132 int ret; 133 int ret;
133 134
134 ret = nouveau_instmem_create(parent, engine, oclass, &priv); 135 ret = nvkm_instmem_create(parent, engine, oclass, &priv);
135 *pobject = nv_object(priv); 136 *pobject = nv_object(priv);
136 if (ret) 137 if (ret)
137 return ret; 138 return ret;
@@ -139,44 +140,44 @@ nv04_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
139 /* PRAMIN aperture maps over the end of VRAM, reserve it */ 140 /* PRAMIN aperture maps over the end of VRAM, reserve it */
140 priv->base.reserved = 512 * 1024; 141 priv->base.reserved = 512 * 1024;
141 142
142 ret = nouveau_mm_init(&priv->heap, 0, priv->base.reserved, 1); 143 ret = nvkm_mm_init(&priv->heap, 0, priv->base.reserved, 1);
143 if (ret) 144 if (ret)
144 return ret; 145 return ret;
145 146
146 /* 0x00000-0x10000: reserve for probable vbios image */ 147 /* 0x00000-0x10000: reserve for probable vbios image */
147 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x10000, 0, 0, 148 ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x10000, 0, 0,
148 &priv->vbios); 149 &priv->vbios);
149 if (ret) 150 if (ret)
150 return ret; 151 return ret;
151 152
152 /* 0x10000-0x18000: reserve for RAMHT */ 153 /* 0x10000-0x18000: reserve for RAMHT */
153 ret = nouveau_ramht_new(nv_object(priv), NULL, 0x08000, 0, &priv->ramht); 154 ret = nvkm_ramht_new(nv_object(priv), NULL, 0x08000, 0, &priv->ramht);
154 if (ret) 155 if (ret)
155 return ret; 156 return ret;
156 157
157 /* 0x18000-0x18800: reserve for RAMFC (enough for 32 nv30 channels) */ 158 /* 0x18000-0x18800: reserve for RAMFC (enough for 32 nv30 channels) */
158 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x00800, 0, 159 ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x00800, 0,
159 NVOBJ_FLAG_ZERO_ALLOC, &priv->ramfc); 160 NVOBJ_FLAG_ZERO_ALLOC, &priv->ramfc);
160 if (ret) 161 if (ret)
161 return ret; 162 return ret;
162 163
163 /* 0x18800-0x18a00: reserve for RAMRO */ 164 /* 0x18800-0x18a00: reserve for RAMRO */
164 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x00200, 0, 0, 165 ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x00200, 0, 0,
165 &priv->ramro); 166 &priv->ramro);
166 if (ret) 167 if (ret)
167 return ret; 168 return ret;
168 169
169 return 0; 170 return 0;
170} 171}
171 172
172struct nouveau_oclass * 173struct nvkm_oclass *
173nv04_instmem_oclass = &(struct nouveau_instmem_impl) { 174nv04_instmem_oclass = &(struct nvkm_instmem_impl) {
174 .base.handle = NV_SUBDEV(INSTMEM, 0x04), 175 .base.handle = NV_SUBDEV(INSTMEM, 0x04),
175 .base.ofuncs = &(struct nouveau_ofuncs) { 176 .base.ofuncs = &(struct nvkm_ofuncs) {
176 .ctor = nv04_instmem_ctor, 177 .ctor = nv04_instmem_ctor,
177 .dtor = nv04_instmem_dtor, 178 .dtor = nv04_instmem_dtor,
178 .init = _nouveau_instmem_init, 179 .init = _nvkm_instmem_init,
179 .fini = _nouveau_instmem_fini, 180 .fini = _nvkm_instmem_fini,
180 .rd32 = nv04_instmem_rd32, 181 .rd32 = nv04_instmem_rd32,
181 .wr32 = nv04_instmem_wr32, 182 .wr32 = nv04_instmem_wr32,
182 }, 183 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.h b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.h
index 095fbc6fc099..42b6c928047c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv04.h
@@ -1,40 +1,36 @@
1#ifndef __NV04_INSTMEM_H__ 1#ifndef __NV04_INSTMEM_H__
2#define __NV04_INSTMEM_H__ 2#define __NV04_INSTMEM_H__
3#include "priv.h"
3 4
4#include <core/gpuobj.h>
5#include <core/ramht.h>
6#include <core/mm.h> 5#include <core/mm.h>
7 6
8#include "priv.h" 7extern struct nvkm_instobj_impl nv04_instobj_oclass;
9
10extern struct nouveau_instobj_impl nv04_instobj_oclass;
11 8
12struct nv04_instmem_priv { 9struct nv04_instmem_priv {
13 struct nouveau_instmem base; 10 struct nvkm_instmem base;
14 11
15 void __iomem *iomem; 12 void __iomem *iomem;
16 struct nouveau_mm heap; 13 struct nvkm_mm heap;
17 14
18 struct nouveau_gpuobj *vbios; 15 struct nvkm_gpuobj *vbios;
19 struct nouveau_ramht *ramht; 16 struct nvkm_ramht *ramht;
20 struct nouveau_gpuobj *ramro; 17 struct nvkm_gpuobj *ramro;
21 struct nouveau_gpuobj *ramfc; 18 struct nvkm_gpuobj *ramfc;
22}; 19};
23 20
24static inline struct nv04_instmem_priv * 21static inline struct nv04_instmem_priv *
25nv04_instmem(void *obj) 22nv04_instmem(void *obj)
26{ 23{
27 return (void *)nouveau_instmem(obj); 24 return (void *)nvkm_instmem(obj);
28} 25}
29 26
30struct nv04_instobj_priv { 27struct nv04_instobj_priv {
31 struct nouveau_instobj base; 28 struct nvkm_instobj base;
32 struct nouveau_mm_node *mem; 29 struct nvkm_mm_node *mem;
33}; 30};
34 31
35void nv04_instmem_dtor(struct nouveau_object *); 32void nv04_instmem_dtor(struct nvkm_object *);
36
37int nv04_instmem_alloc(struct nouveau_instmem *, struct nouveau_object *,
38 u32 size, u32 align, struct nouveau_object **pobject);
39 33
34int nv04_instmem_alloc(struct nvkm_instmem *, struct nvkm_object *,
35 u32 size, u32 align, struct nvkm_object **pobject);
40#endif 36#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv40.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv40.c
index f65bc796bcde..b42b8588fc0e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv40.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv40.c
@@ -21,39 +21,39 @@
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24#include "nv04.h"
24 25
26#include <core/ramht.h>
25#include <engine/gr/nv40.h> 27#include <engine/gr/nv40.h>
26 28
27#include "nv04.h"
28
29/****************************************************************************** 29/******************************************************************************
30 * instmem subdev implementation 30 * instmem subdev implementation
31 *****************************************************************************/ 31 *****************************************************************************/
32 32
33static u32 33static u32
34nv40_instmem_rd32(struct nouveau_object *object, u64 addr) 34nv40_instmem_rd32(struct nvkm_object *object, u64 addr)
35{ 35{
36 struct nv04_instmem_priv *priv = (void *)object; 36 struct nv04_instmem_priv *priv = (void *)object;
37 return ioread32_native(priv->iomem + addr); 37 return ioread32_native(priv->iomem + addr);
38} 38}
39 39
40static void 40static void
41nv40_instmem_wr32(struct nouveau_object *object, u64 addr, u32 data) 41nv40_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
42{ 42{
43 struct nv04_instmem_priv *priv = (void *)object; 43 struct nv04_instmem_priv *priv = (void *)object;
44 iowrite32_native(data, priv->iomem + addr); 44 iowrite32_native(data, priv->iomem + addr);
45} 45}
46 46
47static int 47static int
48nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 48nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
49 struct nouveau_oclass *oclass, void *data, u32 size, 49 struct nvkm_oclass *oclass, void *data, u32 size,
50 struct nouveau_object **pobject) 50 struct nvkm_object **pobject)
51{ 51{
52 struct nouveau_device *device = nv_device(parent); 52 struct nvkm_device *device = nv_device(parent);
53 struct nv04_instmem_priv *priv; 53 struct nv04_instmem_priv *priv;
54 int ret, bar, vs; 54 int ret, bar, vs;
55 55
56 ret = nouveau_instmem_create(parent, engine, oclass, &priv); 56 ret = nvkm_instmem_create(parent, engine, oclass, &priv);
57 *pobject = nv_object(priv); 57 *pobject = nv_object(priv);
58 if (ret) 58 if (ret)
59 return ret; 59 return ret;
@@ -87,49 +87,48 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
87 87
88 priv->base.reserved = round_up(priv->base.reserved, 4096); 88 priv->base.reserved = round_up(priv->base.reserved, 4096);
89 89
90 ret = nouveau_mm_init(&priv->heap, 0, priv->base.reserved, 1); 90 ret = nvkm_mm_init(&priv->heap, 0, priv->base.reserved, 1);
91 if (ret) 91 if (ret)
92 return ret; 92 return ret;
93 93
94 /* 0x00000-0x10000: reserve for probable vbios image */ 94 /* 0x00000-0x10000: reserve for probable vbios image */
95 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x10000, 0, 0, 95 ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x10000, 0, 0,
96 &priv->vbios); 96 &priv->vbios);
97 if (ret) 97 if (ret)
98 return ret; 98 return ret;
99 99
100 /* 0x10000-0x18000: reserve for RAMHT */ 100 /* 0x10000-0x18000: reserve for RAMHT */
101 ret = nouveau_ramht_new(nv_object(priv), NULL, 0x08000, 0, 101 ret = nvkm_ramht_new(nv_object(priv), NULL, 0x08000, 0, &priv->ramht);
102 &priv->ramht);
103 if (ret) 102 if (ret)
104 return ret; 103 return ret;
105 104
106 /* 0x18000-0x18200: reserve for RAMRO 105 /* 0x18000-0x18200: reserve for RAMRO
107 * 0x18200-0x20000: padding 106 * 0x18200-0x20000: padding
108 */ 107 */
109 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x08000, 0, 0, 108 ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x08000, 0, 0,
110 &priv->ramro); 109 &priv->ramro);
111 if (ret) 110 if (ret)
112 return ret; 111 return ret;
113 112
114 /* 0x20000-0x21000: reserve for RAMFC 113 /* 0x20000-0x21000: reserve for RAMFC
115 * 0x21000-0x40000: padding and some unknown crap 114 * 0x21000-0x40000: padding and some unknown crap
116 */ 115 */
117 ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x20000, 0, 116 ret = nvkm_gpuobj_new(nv_object(priv), NULL, 0x20000, 0,
118 NVOBJ_FLAG_ZERO_ALLOC, &priv->ramfc); 117 NVOBJ_FLAG_ZERO_ALLOC, &priv->ramfc);
119 if (ret) 118 if (ret)
120 return ret; 119 return ret;
121 120
122 return 0; 121 return 0;
123} 122}
124 123
125struct nouveau_oclass * 124struct nvkm_oclass *
126nv40_instmem_oclass = &(struct nouveau_instmem_impl) { 125nv40_instmem_oclass = &(struct nvkm_instmem_impl) {
127 .base.handle = NV_SUBDEV(INSTMEM, 0x40), 126 .base.handle = NV_SUBDEV(INSTMEM, 0x40),
128 .base.ofuncs = &(struct nouveau_ofuncs) { 127 .base.ofuncs = &(struct nvkm_ofuncs) {
129 .ctor = nv40_instmem_ctor, 128 .ctor = nv40_instmem_ctor,
130 .dtor = nv04_instmem_dtor, 129 .dtor = nv04_instmem_dtor,
131 .init = _nouveau_instmem_init, 130 .init = _nvkm_instmem_init,
132 .fini = _nouveau_instmem_fini, 131 .fini = _nvkm_instmem_fini,
133 .rd32 = nv40_instmem_rd32, 132 .rd32 = nv40_instmem_rd32,
134 .wr32 = nv40_instmem_wr32, 133 .wr32 = nv40_instmem_wr32,
135 }, 134 },
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
index 64ee680232e2..8404143f93ee 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -21,21 +21,19 @@
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24#include "priv.h"
24 25
25#include <subdev/fb.h> 26#include <subdev/fb.h>
26#include <core/mm.h>
27
28#include "priv.h"
29 27
30struct nv50_instmem_priv { 28struct nv50_instmem_priv {
31 struct nouveau_instmem base; 29 struct nvkm_instmem base;
32 spinlock_t lock; 30 spinlock_t lock;
33 u64 addr; 31 u64 addr;
34}; 32};
35 33
36struct nv50_instobj_priv { 34struct nv50_instobj_priv {
37 struct nouveau_instobj base; 35 struct nvkm_instobj base;
38 struct nouveau_mem *mem; 36 struct nvkm_mem *mem;
39}; 37};
40 38
41/****************************************************************************** 39/******************************************************************************
@@ -43,9 +41,9 @@ struct nv50_instobj_priv {
43 *****************************************************************************/ 41 *****************************************************************************/
44 42
45static u32 43static u32
46nv50_instobj_rd32(struct nouveau_object *object, u64 offset) 44nv50_instobj_rd32(struct nvkm_object *object, u64 offset)
47{ 45{
48 struct nv50_instmem_priv *priv = (void *)nouveau_instmem(object); 46 struct nv50_instmem_priv *priv = (void *)nvkm_instmem(object);
49 struct nv50_instobj_priv *node = (void *)object; 47 struct nv50_instobj_priv *node = (void *)object;
50 unsigned long flags; 48 unsigned long flags;
51 u64 base = (node->mem->offset + offset) & 0xffffff00000ULL; 49 u64 base = (node->mem->offset + offset) & 0xffffff00000ULL;
@@ -63,9 +61,9 @@ nv50_instobj_rd32(struct nouveau_object *object, u64 offset)
63} 61}
64 62
65static void 63static void
66nv50_instobj_wr32(struct nouveau_object *object, u64 offset, u32 data) 64nv50_instobj_wr32(struct nvkm_object *object, u64 offset, u32 data)
67{ 65{
68 struct nv50_instmem_priv *priv = (void *)nouveau_instmem(object); 66 struct nv50_instmem_priv *priv = (void *)nvkm_instmem(object);
69 struct nv50_instobj_priv *node = (void *)object; 67 struct nv50_instobj_priv *node = (void *)object;
70 unsigned long flags; 68 unsigned long flags;
71 u64 base = (node->mem->offset + offset) & 0xffffff00000ULL; 69 u64 base = (node->mem->offset + offset) & 0xffffff00000ULL;
@@ -81,28 +79,28 @@ nv50_instobj_wr32(struct nouveau_object *object, u64 offset, u32 data)
81} 79}
82 80
83static void 81static void
84nv50_instobj_dtor(struct nouveau_object *object) 82nv50_instobj_dtor(struct nvkm_object *object)
85{ 83{
86 struct nv50_instobj_priv *node = (void *)object; 84 struct nv50_instobj_priv *node = (void *)object;
87 struct nouveau_fb *pfb = nouveau_fb(object); 85 struct nvkm_fb *pfb = nvkm_fb(object);
88 pfb->ram->put(pfb, &node->mem); 86 pfb->ram->put(pfb, &node->mem);
89 nouveau_instobj_destroy(&node->base); 87 nvkm_instobj_destroy(&node->base);
90} 88}
91 89
92static int 90static int
93nv50_instobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 91nv50_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
94 struct nouveau_oclass *oclass, void *data, u32 size, 92 struct nvkm_oclass *oclass, void *data, u32 size,
95 struct nouveau_object **pobject) 93 struct nvkm_object **pobject)
96{ 94{
97 struct nouveau_fb *pfb = nouveau_fb(parent); 95 struct nvkm_fb *pfb = nvkm_fb(parent);
98 struct nouveau_instobj_args *args = data; 96 struct nvkm_instobj_args *args = data;
99 struct nv50_instobj_priv *node; 97 struct nv50_instobj_priv *node;
100 int ret; 98 int ret;
101 99
102 args->size = max((args->size + 4095) & ~4095, (u32)4096); 100 args->size = max((args->size + 4095) & ~4095, (u32)4096);
103 args->align = max((args->align + 4095) & ~4095, (u32)4096); 101 args->align = max((args->align + 4095) & ~4095, (u32)4096);
104 102
105 ret = nouveau_instobj_create(parent, engine, oclass, &node); 103 ret = nvkm_instobj_create(parent, engine, oclass, &node);
106 *pobject = nv_object(node); 104 *pobject = nv_object(node);
107 if (ret) 105 if (ret)
108 return ret; 106 return ret;
@@ -117,13 +115,13 @@ nv50_instobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
117 return 0; 115 return 0;
118} 116}
119 117
120static struct nouveau_instobj_impl 118static struct nvkm_instobj_impl
121nv50_instobj_oclass = { 119nv50_instobj_oclass = {
122 .base.ofuncs = &(struct nouveau_ofuncs) { 120 .base.ofuncs = &(struct nvkm_ofuncs) {
123 .ctor = nv50_instobj_ctor, 121 .ctor = nv50_instobj_ctor,
124 .dtor = nv50_instobj_dtor, 122 .dtor = nv50_instobj_dtor,
125 .init = _nouveau_instobj_init, 123 .init = _nvkm_instobj_init,
126 .fini = _nouveau_instobj_fini, 124 .fini = _nvkm_instobj_fini,
127 .rd32 = nv50_instobj_rd32, 125 .rd32 = nv50_instobj_rd32,
128 .wr32 = nv50_instobj_wr32, 126 .wr32 = nv50_instobj_wr32,
129 }, 127 },
@@ -134,22 +132,22 @@ nv50_instobj_oclass = {
134 *****************************************************************************/ 132 *****************************************************************************/
135 133
136static int 134static int
137nv50_instmem_fini(struct nouveau_object *object, bool suspend) 135nv50_instmem_fini(struct nvkm_object *object, bool suspend)
138{ 136{
139 struct nv50_instmem_priv *priv = (void *)object; 137 struct nv50_instmem_priv *priv = (void *)object;
140 priv->addr = ~0ULL; 138 priv->addr = ~0ULL;
141 return nouveau_instmem_fini(&priv->base, suspend); 139 return nvkm_instmem_fini(&priv->base, suspend);
142} 140}
143 141
144static int 142static int
145nv50_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 143nv50_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
146 struct nouveau_oclass *oclass, void *data, u32 size, 144 struct nvkm_oclass *oclass, void *data, u32 size,
147 struct nouveau_object **pobject) 145 struct nvkm_object **pobject)
148{ 146{
149 struct nv50_instmem_priv *priv; 147 struct nv50_instmem_priv *priv;
150 int ret; 148 int ret;
151 149
152 ret = nouveau_instmem_create(parent, engine, oclass, &priv); 150 ret = nvkm_instmem_create(parent, engine, oclass, &priv);
153 *pobject = nv_object(priv); 151 *pobject = nv_object(priv);
154 if (ret) 152 if (ret)
155 return ret; 153 return ret;
@@ -158,13 +156,13 @@ nv50_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
158 return 0; 156 return 0;
159} 157}
160 158
161struct nouveau_oclass * 159struct nvkm_oclass *
162nv50_instmem_oclass = &(struct nouveau_instmem_impl) { 160nv50_instmem_oclass = &(struct nvkm_instmem_impl) {
163 .base.handle = NV_SUBDEV(INSTMEM, 0x50), 161 .base.handle = NV_SUBDEV(INSTMEM, 0x50),
164 .base.ofuncs = &(struct nouveau_ofuncs) { 162 .base.ofuncs = &(struct nvkm_ofuncs) {
165 .ctor = nv50_instmem_ctor, 163 .ctor = nv50_instmem_ctor,
166 .dtor = _nouveau_instmem_dtor, 164 .dtor = _nvkm_instmem_dtor,
167 .init = _nouveau_instmem_init, 165 .init = _nvkm_instmem_init,
168 .fini = nv50_instmem_fini, 166 .fini = nv50_instmem_fini,
169 }, 167 },
170 .instobj = &nv50_instobj_oclass.base, 168 .instobj = &nv50_instobj_oclass.base,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
index 8d67dedc5bb2..b10e292e5607 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
@@ -1,56 +1,54 @@
1#ifndef __NVKM_INSTMEM_PRIV_H__ 1#ifndef __NVKM_INSTMEM_PRIV_H__
2#define __NVKM_INSTMEM_PRIV_H__ 2#define __NVKM_INSTMEM_PRIV_H__
3
4#include <subdev/instmem.h> 3#include <subdev/instmem.h>
5 4
6struct nouveau_instobj_impl { 5struct nvkm_instobj_impl {
7 struct nouveau_oclass base; 6 struct nvkm_oclass base;
8}; 7};
9 8
10struct nouveau_instobj_args { 9struct nvkm_instobj_args {
11 u32 size; 10 u32 size;
12 u32 align; 11 u32 align;
13}; 12};
14 13
15#define nouveau_instobj_create(p,e,o,d) \ 14#define nvkm_instobj_create(p,e,o,d) \
16 nouveau_instobj_create_((p), (e), (o), sizeof(**d), (void **)d) 15 nvkm_instobj_create_((p), (e), (o), sizeof(**d), (void **)d)
17#define nouveau_instobj_destroy(p) ({ \ 16#define nvkm_instobj_destroy(p) ({ \
18 struct nouveau_instobj *iobj = (p); \ 17 struct nvkm_instobj *iobj = (p); \
19 _nouveau_instobj_dtor(nv_object(iobj)); \ 18 _nvkm_instobj_dtor(nv_object(iobj)); \
20}) 19})
21#define nouveau_instobj_init(p) \ 20#define nvkm_instobj_init(p) \
22 nouveau_object_init(&(p)->base) 21 nvkm_object_init(&(p)->base)
23#define nouveau_instobj_fini(p,s) \ 22#define nvkm_instobj_fini(p,s) \
24 nouveau_object_fini(&(p)->base, (s)) 23 nvkm_object_fini(&(p)->base, (s))
25 24
26int nouveau_instobj_create_(struct nouveau_object *, struct nouveau_object *, 25int nvkm_instobj_create_(struct nvkm_object *, struct nvkm_object *,
27 struct nouveau_oclass *, int, void **); 26 struct nvkm_oclass *, int, void **);
28void _nouveau_instobj_dtor(struct nouveau_object *); 27void _nvkm_instobj_dtor(struct nvkm_object *);
29#define _nouveau_instobj_init nouveau_object_init 28#define _nvkm_instobj_init nvkm_object_init
30#define _nouveau_instobj_fini nouveau_object_fini 29#define _nvkm_instobj_fini nvkm_object_fini
31 30
32struct nouveau_instmem_impl { 31struct nvkm_instmem_impl {
33 struct nouveau_oclass base; 32 struct nvkm_oclass base;
34 struct nouveau_oclass *instobj; 33 struct nvkm_oclass *instobj;
35}; 34};
36 35
37#define nouveau_instmem_create(p,e,o,d) \ 36#define nvkm_instmem_create(p,e,o,d) \
38 nouveau_instmem_create_((p), (e), (o), sizeof(**d), (void **)d) 37 nvkm_instmem_create_((p), (e), (o), sizeof(**d), (void **)d)
39#define nouveau_instmem_destroy(p) \ 38#define nvkm_instmem_destroy(p) \
40 nouveau_subdev_destroy(&(p)->base) 39 nvkm_subdev_destroy(&(p)->base)
41#define nouveau_instmem_init(p) ({ \ 40#define nvkm_instmem_init(p) ({ \
42 struct nouveau_instmem *imem = (p); \ 41 struct nvkm_instmem *imem = (p); \
43 _nouveau_instmem_init(nv_object(imem)); \ 42 _nvkm_instmem_init(nv_object(imem)); \
44}) 43})
45#define nouveau_instmem_fini(p,s) ({ \ 44#define nvkm_instmem_fini(p,s) ({ \
46 struct nouveau_instmem *imem = (p); \ 45 struct nvkm_instmem *imem = (p); \
47 _nouveau_instmem_fini(nv_object(imem), (s)); \ 46 _nvkm_instmem_fini(nv_object(imem), (s)); \
48}) 47})
49 48
50int nouveau_instmem_create_(struct nouveau_object *, struct nouveau_object *, 49int nvkm_instmem_create_(struct nvkm_object *, struct nvkm_object *,
51 struct nouveau_oclass *, int, void **); 50 struct nvkm_oclass *, int, void **);
52#define _nouveau_instmem_dtor _nouveau_subdev_dtor 51#define _nvkm_instmem_dtor _nvkm_subdev_dtor
53int _nouveau_instmem_init(struct nouveau_object *); 52int _nvkm_instmem_init(struct nvkm_object *);
54int _nouveau_instmem_fini(struct nouveau_object *, bool); 53int _nvkm_instmem_fini(struct nvkm_object *, bool);
55
56#endif 54#endif