3 #include "nouveau_drv.h"
4 #include "nouveau_ramht.h"
6 /* returns the size of fifo context */
8 nouveau_fifo_ctx_size(struct drm_device
*dev
)
10 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
12 if (dev_priv
->chipset
>= 0x40)
15 if (dev_priv
->chipset
>= 0x17)
21 int nv04_instmem_init(struct drm_device
*dev
)
23 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
24 struct nouveau_gpuobj
*ramht
= NULL
;
28 /* RAMIN always available */
29 dev_priv
->ramin_available
= true;
31 /* Setup shared RAMHT */
32 ret
= nouveau_gpuobj_new_fake(dev
, 0x10000, ~0, 4096,
33 NVOBJ_FLAG_ZERO_ALLOC
, &ramht
);
37 ret
= nouveau_ramht_new(dev
, ramht
, &dev_priv
->ramht
);
38 nouveau_gpuobj_ref(NULL
, &ramht
);
43 ret
= nouveau_gpuobj_new_fake(dev
, 0x11200, ~0, 512,
44 NVOBJ_FLAG_ZERO_ALLOC
, &dev_priv
->ramro
);
49 length
= dev_priv
->engine
.fifo
.channels
* nouveau_fifo_ctx_size(dev
);
50 switch (dev_priv
->card_type
) {
59 ret
= nouveau_gpuobj_new_fake(dev
, offset
, ~0, length
,
60 NVOBJ_FLAG_ZERO_ALLOC
, &dev_priv
->ramfc
);
64 /* Only allow space after RAMFC to be used for object allocation */
67 /* It appears RAMRO (or something?) is controlled by 0x2220/0x2230
68 * on certain NV4x chipsets as well as RAMFC. When 0x2230 == 0
69 * ("new style" control) the upper 16-bits of 0x2220 points at this
70 * other mysterious table that's clobbering important things.
72 * We're now pointing this at RAMIN+0x30000 to avoid RAMFC getting
73 * smashed to pieces on us, so reserve 0x30000-0x40000 too..
75 if (dev_priv
->card_type
>= NV_40
) {
80 ret
= drm_mm_init(&dev_priv
->ramin_heap
, offset
,
81 dev_priv
->ramin_rsvd_vram
- offset
);
83 NV_ERROR(dev
, "Failed to init RAMIN heap: %d\n", ret
);
91 nv04_instmem_takedown(struct drm_device
*dev
)
93 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
95 nouveau_ramht_ref(NULL
, &dev_priv
->ramht
, NULL
);
96 nouveau_gpuobj_ref(NULL
, &dev_priv
->ramro
);
97 nouveau_gpuobj_ref(NULL
, &dev_priv
->ramfc
);
101 nv04_instmem_suspend(struct drm_device
*dev
)
107 nv04_instmem_resume(struct drm_device
*dev
)
112 nv04_instmem_get(struct nouveau_gpuobj
*gpuobj
, u32 size
, u32 align
)
114 struct drm_nouveau_private
*dev_priv
= gpuobj
->dev
->dev_private
;
115 struct drm_mm_node
*ramin
= NULL
;
118 if (drm_mm_pre_get(&dev_priv
->ramin_heap
))
121 spin_lock(&dev_priv
->ramin_lock
);
122 ramin
= drm_mm_search_free(&dev_priv
->ramin_heap
, size
, align
, 0);
124 spin_unlock(&dev_priv
->ramin_lock
);
128 ramin
= drm_mm_get_block_atomic(ramin
, size
, align
);
129 spin_unlock(&dev_priv
->ramin_lock
);
130 } while (ramin
== NULL
);
132 gpuobj
->node
= ramin
;
133 gpuobj
->vinst
= ramin
->start
;
138 nv04_instmem_put(struct nouveau_gpuobj
*gpuobj
)
140 struct drm_nouveau_private
*dev_priv
= gpuobj
->dev
->dev_private
;
142 spin_lock(&dev_priv
->ramin_lock
);
143 drm_mm_put_block(gpuobj
->node
);
145 spin_unlock(&dev_priv
->ramin_lock
);
149 nv04_instmem_map(struct nouveau_gpuobj
*gpuobj
)
151 gpuobj
->pinst
= gpuobj
->vinst
;
156 nv04_instmem_unmap(struct nouveau_gpuobj
*gpuobj
)
161 nv04_instmem_flush(struct drm_device
*dev
)