3 #include "nouveau_drv.h"
5 /* returns the size of fifo context */
7 nouveau_fifo_ctx_size(struct drm_device
*dev
)
9 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
11 if (dev_priv
->chipset
>= 0x40)
14 if (dev_priv
->chipset
>= 0x17)
21 nv04_instmem_determine_amount(struct drm_device
*dev
)
23 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
26 /* Figure out how much instance memory we need */
27 if (dev_priv
->card_type
>= NV_40
) {
28 /* We'll want more instance memory than this on some NV4x cards.
29 * There's a 16MB aperture to play with that maps onto the end
30 * of vram. For now, only reserve a small piece until we know
31 * more about what each chipset requires.
33 switch (dev_priv
->chipset
) {
38 dev_priv
->ramin_rsvd_vram
= (2 * 1024 * 1024);
41 dev_priv
->ramin_rsvd_vram
= (1 * 1024 * 1024);
45 /*XXX: what *are* the limits on <NV40 cards?
47 dev_priv
->ramin_rsvd_vram
= (512 * 1024);
49 NV_DEBUG(dev
, "RAMIN size: %dKiB\n", dev_priv
->ramin_rsvd_vram
>> 10);
51 /* Clear all of it, except the BIOS image that's in the first 64KiB */
52 for (i
= 64 * 1024; i
< dev_priv
->ramin_rsvd_vram
; i
+= 4)
53 nv_wi32(dev
, i
, 0x00000000);
57 nv04_instmem_configure_fixed_tables(struct drm_device
*dev
)
59 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
60 struct nouveau_engine
*engine
= &dev_priv
->engine
;
62 /* FIFO hash table (RAMHT)
63 * use 4k hash table at RAMIN+0x10000
64 * TODO: extend the hash table
66 dev_priv
->ramht_offset
= 0x10000;
67 dev_priv
->ramht_bits
= 9;
68 dev_priv
->ramht_size
= (1 << dev_priv
->ramht_bits
); /* nr entries */
69 dev_priv
->ramht_size
*= 8; /* 2 32-bit values per entry in RAMHT */
70 NV_DEBUG(dev
, "RAMHT offset=0x%x, size=%d\n", dev_priv
->ramht_offset
,
71 dev_priv
->ramht_size
);
73 /* FIFO runout table (RAMRO) - 512k at 0x11200 */
74 dev_priv
->ramro_offset
= 0x11200;
75 dev_priv
->ramro_size
= 512;
76 NV_DEBUG(dev
, "RAMRO offset=0x%x, size=%d\n", dev_priv
->ramro_offset
,
77 dev_priv
->ramro_size
);
79 /* FIFO context table (RAMFC)
80 * NV40 : Not sure exactly how to position RAMFC on some cards,
81 * 0x30002 seems to position it at RAMIN+0x20000 on these
82 * cards. RAMFC is 4kb (32 fifos, 128byte entries).
83 * Others: Position RAMFC at RAMIN+0x11400
85 dev_priv
->ramfc_size
= engine
->fifo
.channels
*
86 nouveau_fifo_ctx_size(dev
);
87 switch (dev_priv
->card_type
) {
89 dev_priv
->ramfc_offset
= 0x20000;
96 dev_priv
->ramfc_offset
= 0x11400;
99 NV_DEBUG(dev
, "RAMFC offset=0x%x, size=%d\n", dev_priv
->ramfc_offset
,
100 dev_priv
->ramfc_size
);
103 int nv04_instmem_init(struct drm_device
*dev
)
105 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
109 nv04_instmem_determine_amount(dev
);
110 nv04_instmem_configure_fixed_tables(dev
);
112 /* Create a heap to manage RAMIN allocations, we don't allocate
113 * the space that was reserved for RAMHT/FC/RO.
115 offset
= dev_priv
->ramfc_offset
+ dev_priv
->ramfc_size
;
117 /* It appears RAMRO (or something?) is controlled by 0x2220/0x2230
118 * on certain NV4x chipsets as well as RAMFC. When 0x2230 == 0
119 * ("new style" control) the upper 16-bits of 0x2220 points at this
120 * other mysterious table that's clobbering important things.
122 * We're now pointing this at RAMIN+0x30000 to avoid RAMFC getting
123 * smashed to pieces on us, so reserve 0x30000-0x40000 too..
125 if (dev_priv
->card_type
>= NV_40
) {
126 if (offset
< 0x40000)
130 ret
= drm_mm_init(&dev_priv
->ramin_heap
, offset
,
131 dev_priv
->ramin_rsvd_vram
- offset
);
133 NV_ERROR(dev
, "Failed to init RAMIN heap: %d\n", ret
);
141 nv04_instmem_takedown(struct drm_device
*dev
)
146 nv04_instmem_populate(struct drm_device
*dev
, struct nouveau_gpuobj
*gpuobj
, uint32_t *sz
)
148 if (gpuobj
->im_backing
)
155 nv04_instmem_clear(struct drm_device
*dev
, struct nouveau_gpuobj
*gpuobj
)
157 struct drm_nouveau_private
*dev_priv
= dev
->dev_private
;
159 if (gpuobj
&& gpuobj
->im_backing
) {
160 if (gpuobj
->im_bound
)
161 dev_priv
->engine
.instmem
.unbind(dev
, gpuobj
);
162 gpuobj
->im_backing
= NULL
;
167 nv04_instmem_bind(struct drm_device
*dev
, struct nouveau_gpuobj
*gpuobj
)
169 if (!gpuobj
->im_pramin
|| gpuobj
->im_bound
)
172 gpuobj
->im_bound
= 1;
177 nv04_instmem_unbind(struct drm_device
*dev
, struct nouveau_gpuobj
*gpuobj
)
179 if (gpuobj
->im_bound
== 0)
182 gpuobj
->im_bound
= 0;
187 nv04_instmem_flush(struct drm_device
*dev
)
192 nv04_instmem_suspend(struct drm_device
*dev
)
198 nv04_instmem_resume(struct drm_device
*dev
)
This page took 0.04579 seconds and 5 git commands to generate.