aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2009-09-14 12:29:49 -0400
committerDave Airlie <airlied@redhat.com>2009-09-14 18:53:14 -0400
commit4aac047323e3082d0866b8ad3784236632105af4 (patch)
treeaf4c118e42b9ea55c961c4f5bbb02998dc2cc4fe
parent21f9a437222e92adb3abc68584a5f04801b92739 (diff)
drm/radeon/kms: clear confusion in GART init/deinit path
GART static one time initialization was mixed up with GART enabling/disabling which could happen several time for instance during suspend/resume cycles. This patch splits all GART handling into 4 differents function. gart_init is for one time initialization, gart_deinit is called upon module unload to free resources allocated by gart_init, gart_enable enable the GART and is intented to be call after first initialization and at each resume cycle or reset cycle. Finaly gart_disable stop the GART and is intended to be call at suspend time or when unloading the module. Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/radeon/r100.c40
-rw-r--r--drivers/gpu/drm/radeon/r300.c108
-rw-r--r--drivers/gpu/drm/radeon/r420.c57
-rw-r--r--drivers/gpu/drm/radeon/r520.c5
-rw-r--r--drivers/gpu/drm/radeon/r600.c53
-rw-r--r--drivers/gpu/drm/radeon/radeon.h11
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h38
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c36
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c9
-rw-r--r--drivers/gpu/drm/radeon/rs400.c53
-rw-r--r--drivers/gpu/drm/radeon/rs600.c41
-rw-r--r--drivers/gpu/drm/radeon/rs690.c3
-rw-r--r--drivers/gpu/drm/radeon/rv515.c5
-rw-r--r--drivers/gpu/drm/radeon/rv770.c37
14 files changed, 306 insertions, 190 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 47263d3ede98..fa0fdc1e3457 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -84,23 +84,28 @@ void r100_pci_gart_tlb_flush(struct radeon_device *rdev)
84 * could end up in wrong address. */ 84 * could end up in wrong address. */
85} 85}
86 86
87int r100_pci_gart_enable(struct radeon_device *rdev) 87int r100_pci_gart_init(struct radeon_device *rdev)
88{ 88{
89 uint32_t tmp;
90 int r; 89 int r;
91 90
91 if (rdev->gart.table.ram.ptr) {
92 WARN(1, "R100 PCI GART already initialized.\n");
93 return 0;
94 }
92 /* Initialize common gart structure */ 95 /* Initialize common gart structure */
93 r = radeon_gart_init(rdev); 96 r = radeon_gart_init(rdev);
94 if (r) { 97 if (r)
95 return r; 98 return r;
96 } 99 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
97 if (rdev->gart.table.ram.ptr == NULL) { 100 rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
98 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; 101 rdev->asic->gart_set_page = &r100_pci_gart_set_page;
99 r = radeon_gart_table_ram_alloc(rdev); 102 return radeon_gart_table_ram_alloc(rdev);
100 if (r) { 103}
101 return r; 104
102 } 105int r100_pci_gart_enable(struct radeon_device *rdev)
103 } 106{
107 uint32_t tmp;
108
104 /* discard memory request outside of configured range */ 109 /* discard memory request outside of configured range */
105 tmp = RREG32(RADEON_AIC_CNTL) | RADEON_DIS_OUT_OF_PCI_GART_ACCESS; 110 tmp = RREG32(RADEON_AIC_CNTL) | RADEON_DIS_OUT_OF_PCI_GART_ACCESS;
106 WREG32(RADEON_AIC_CNTL, tmp); 111 WREG32(RADEON_AIC_CNTL, tmp);
@@ -140,13 +145,11 @@ int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
140 return 0; 145 return 0;
141} 146}
142 147
143int r100_gart_enable(struct radeon_device *rdev) 148void r100_pci_gart_fini(struct radeon_device *rdev)
144{ 149{
145 if (rdev->flags & RADEON_IS_AGP) { 150 r100_pci_gart_disable(rdev);
146 r100_pci_gart_disable(rdev); 151 radeon_gart_table_ram_free(rdev);
147 return 0; 152 radeon_gart_fini(rdev);
148 }
149 return r100_pci_gart_enable(rdev);
150} 153}
151 154
152 155
@@ -273,9 +276,6 @@ int r100_mc_init(struct radeon_device *rdev)
273 276
274void r100_mc_fini(struct radeon_device *rdev) 277void r100_mc_fini(struct radeon_device *rdev)
275{ 278{
276 r100_pci_gart_disable(rdev);
277 radeon_gart_table_ram_free(rdev);
278 radeon_gart_fini(rdev);
279} 279}
280 280
281 281
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index ced3322bd5fb..bb151ecdf8fc 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -42,7 +42,6 @@ int r100_cp_reset(struct radeon_device *rdev);
42int r100_rb2d_reset(struct radeon_device *rdev); 42int r100_rb2d_reset(struct radeon_device *rdev);
43int r100_cp_init(struct radeon_device *rdev, unsigned ring_size); 43int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
44int r100_pci_gart_enable(struct radeon_device *rdev); 44int r100_pci_gart_enable(struct radeon_device *rdev);
45void r100_pci_gart_disable(struct radeon_device *rdev);
46void r100_mc_setup(struct radeon_device *rdev); 45void r100_mc_setup(struct radeon_device *rdev);
47void r100_mc_disable_clients(struct radeon_device *rdev); 46void r100_mc_disable_clients(struct radeon_device *rdev);
48int r100_gui_wait_for_idle(struct radeon_device *rdev); 47int r100_gui_wait_for_idle(struct radeon_device *rdev);
@@ -86,26 +85,57 @@ void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev)
86 mb(); 85 mb();
87} 86}
88 87
89int rv370_pcie_gart_enable(struct radeon_device *rdev) 88int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
89{
90 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
91
92 if (i < 0 || i > rdev->gart.num_gpu_pages) {
93 return -EINVAL;
94 }
95 addr = (lower_32_bits(addr) >> 8) |
96 ((upper_32_bits(addr) & 0xff) << 24) |
97 0xc;
98 /* on x86 we want this to be CPU endian, on powerpc
99 * on powerpc without HW swappers, it'll get swapped on way
100 * into VRAM - so no need for cpu_to_le32 on VRAM tables */
101 writel(addr, ((void __iomem *)ptr) + (i * 4));
102 return 0;
103}
104
105int rv370_pcie_gart_init(struct radeon_device *rdev)
90{ 106{
91 uint32_t table_addr;
92 uint32_t tmp;
93 int r; 107 int r;
94 108
109 if (rdev->gart.table.vram.robj) {
110 WARN(1, "RV370 PCIE GART already initialized.\n");
111 return 0;
112 }
95 /* Initialize common gart structure */ 113 /* Initialize common gart structure */
96 r = radeon_gart_init(rdev); 114 r = radeon_gart_init(rdev);
97 if (r) { 115 if (r)
98 return r; 116 return r;
99 }
100 r = rv370_debugfs_pcie_gart_info_init(rdev); 117 r = rv370_debugfs_pcie_gart_info_init(rdev);
101 if (r) { 118 if (r)
102 DRM_ERROR("Failed to register debugfs file for PCIE gart !\n"); 119 DRM_ERROR("Failed to register debugfs file for PCIE gart !\n");
103 }
104 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; 120 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
105 r = radeon_gart_table_vram_alloc(rdev); 121 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
106 if (r) { 122 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
107 return r; 123 return radeon_gart_table_vram_alloc(rdev);
124}
125
126int rv370_pcie_gart_enable(struct radeon_device *rdev)
127{
128 uint32_t table_addr;
129 uint32_t tmp;
130 int r;
131
132 if (rdev->gart.table.vram.robj == NULL) {
133 dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
134 return -EINVAL;
108 } 135 }
136 r = radeon_gart_table_vram_pin(rdev);
137 if (r)
138 return r;
109 /* discard memory request outside of configured range */ 139 /* discard memory request outside of configured range */
110 tmp = RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD; 140 tmp = RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
111 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp); 141 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
@@ -145,51 +175,13 @@ void rv370_pcie_gart_disable(struct radeon_device *rdev)
145 } 175 }
146} 176}
147 177
148int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) 178void rv370_pcie_gart_fini(struct radeon_device *rdev)
149{
150 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
151
152 if (i < 0 || i > rdev->gart.num_gpu_pages) {
153 return -EINVAL;
154 }
155 addr = (lower_32_bits(addr) >> 8) |
156 ((upper_32_bits(addr) & 0xff) << 24) |
157 0xc;
158 /* on x86 we want this to be CPU endian, on powerpc
159 * on powerpc without HW swappers, it'll get swapped on way
160 * into VRAM - so no need for cpu_to_le32 on VRAM tables */
161 writel(addr, ((void __iomem *)ptr) + (i * 4));
162 return 0;
163}
164
165int r300_gart_enable(struct radeon_device *rdev)
166{ 179{
167#if __OS_HAS_AGP 180 rv370_pcie_gart_disable(rdev);
168 if (rdev->flags & RADEON_IS_AGP) { 181 radeon_gart_table_vram_free(rdev);
169 if (rdev->family > CHIP_RV350) { 182 radeon_gart_fini(rdev);
170 rv370_pcie_gart_disable(rdev);
171 } else {
172 r100_pci_gart_disable(rdev);
173 }
174 return 0;
175 }
176#endif
177 if (rdev->flags & RADEON_IS_PCIE) {
178 rdev->asic->gart_disable = &rv370_pcie_gart_disable;
179 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
180 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
181 return rv370_pcie_gart_enable(rdev);
182 }
183 if (rdev->flags & RADEON_IS_PCI) {
184 rdev->asic->gart_disable = &r100_pci_gart_disable;
185 rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
186 rdev->asic->gart_set_page = &r100_pci_gart_set_page;
187 return r100_pci_gart_enable(rdev);
188 }
189 return r100_pci_gart_enable(rdev);
190} 183}
191 184
192
193/* 185/*
194 * MC 186 * MC
195 */ 187 */
@@ -237,14 +229,6 @@ int r300_mc_init(struct radeon_device *rdev)
237 229
238void r300_mc_fini(struct radeon_device *rdev) 230void r300_mc_fini(struct radeon_device *rdev)
239{ 231{
240 if (rdev->flags & RADEON_IS_PCIE) {
241 rv370_pcie_gart_disable(rdev);
242 radeon_gart_table_vram_free(rdev);
243 } else {
244 r100_pci_gart_disable(rdev);
245 radeon_gart_table_ram_free(rdev);
246 }
247 radeon_gart_fini(rdev);
248} 232}
249 233
250 234
@@ -1299,8 +1283,6 @@ void r300_mc_program(struct radeon_device *rdev)
1299 1283
1300 /* Stops all mc clients */ 1284 /* Stops all mc clients */
1301 r100_mc_stop(rdev, &save); 1285 r100_mc_stop(rdev, &save);
1302 /* Shutdown PCI/PCIE GART */
1303 radeon_gart_disable(rdev);
1304 if (rdev->flags & RADEON_IS_AGP) { 1286 if (rdev->flags & RADEON_IS_AGP) {
1305 WREG32(R_00014C_MC_AGP_LOCATION, 1287 WREG32(R_00014C_MC_AGP_LOCATION,
1306 S_00014C_MC_AGP_START(rdev->mc.gtt_start >> 16) | 1288 S_00014C_MC_AGP_START(rdev->mc.gtt_start >> 16) |
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index e57b9ba4aaf3..33a25a4377b8 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -161,6 +161,11 @@ int r420_resume(struct radeon_device *rdev)
161{ 161{
162 int r; 162 int r;
163 163
164 /* Make sur GART are not working */
165 if (rdev->flags & RADEON_IS_PCIE)
166 rv370_pcie_gart_disable(rdev);
167 if (rdev->flags & RADEON_IS_PCI)
168 r100_pci_gart_disable(rdev);
164 /* Resume clock before doing reset */ 169 /* Resume clock before doing reset */
165 r420_clock_resume(rdev); 170 r420_clock_resume(rdev);
166 /* Reset gpu before posting otherwise ATOM will enter infinite loop */ 171 /* Reset gpu before posting otherwise ATOM will enter infinite loop */
@@ -180,10 +185,15 @@ int r420_resume(struct radeon_device *rdev)
180 r300_mc_program(rdev); 185 r300_mc_program(rdev);
181 /* Initialize GART (initialize after TTM so we can allocate 186 /* Initialize GART (initialize after TTM so we can allocate
182 * memory through TTM but finalize after TTM) */ 187 * memory through TTM but finalize after TTM) */
183 r = radeon_gart_enable(rdev); 188 if (rdev->flags & RADEON_IS_PCIE) {
184 if (r) { 189 r = rv370_pcie_gart_enable(rdev);
185 dev_err(rdev->dev, "failled initializing GART (%d).\n", r); 190 if (r)
186 return r; 191 return r;
192 }
193 if (rdev->flags & RADEON_IS_PCI) {
194 r = r100_pci_gart_enable(rdev);
195 if (r)
196 return r;
187 } 197 }
188 r420_pipes_init(rdev); 198 r420_pipes_init(rdev);
189 /* Enable IRQ */ 199 /* Enable IRQ */
@@ -212,7 +222,10 @@ int r420_suspend(struct radeon_device *rdev)
212 r100_cp_disable(rdev); 222 r100_cp_disable(rdev);
213 r100_wb_disable(rdev); 223 r100_wb_disable(rdev);
214 r100_irq_disable(rdev); 224 r100_irq_disable(rdev);
215 radeon_gart_disable(rdev); 225 if (rdev->flags & RADEON_IS_PCIE)
226 rv370_pcie_gart_disable(rdev);
227 if (rdev->flags & RADEON_IS_PCI)
228 r100_pci_gart_disable(rdev);
216 return 0; 229 return 0;
217} 230}
218 231
@@ -222,14 +235,10 @@ void r420_fini(struct radeon_device *rdev)
222 r100_wb_fini(rdev); 235 r100_wb_fini(rdev);
223 r100_ib_fini(rdev); 236 r100_ib_fini(rdev);
224 radeon_gem_fini(rdev); 237 radeon_gem_fini(rdev);
225 if (rdev->flags & RADEON_IS_PCIE) { 238 if (rdev->flags & RADEON_IS_PCIE)
226 rv370_pcie_gart_disable(rdev); 239 rv370_pcie_gart_fini(rdev);
227 radeon_gart_table_vram_free(rdev); 240 if (rdev->flags & RADEON_IS_PCI)
228 } else { 241 r100_pci_gart_fini(rdev);
229 r100_pci_gart_disable(rdev);
230 radeon_gart_table_ram_free(rdev);
231 }
232 radeon_gart_fini(rdev);
233 radeon_agp_fini(rdev); 242 radeon_agp_fini(rdev);
234 radeon_irq_kms_fini(rdev); 243 radeon_irq_kms_fini(rdev);
235 radeon_fence_driver_fini(rdev); 244 radeon_fence_driver_fini(rdev);
@@ -309,6 +318,16 @@ int r420_init(struct radeon_device *rdev)
309 if (r) { 318 if (r) {
310 return r; 319 return r;
311 } 320 }
321 if (rdev->flags & RADEON_IS_PCIE) {
322 r = rv370_pcie_gart_init(rdev);
323 if (r)
324 return r;
325 }
326 if (rdev->flags & RADEON_IS_PCI) {
327 r = r100_pci_gart_init(rdev);
328 if (r)
329 return r;
330 }
312 r300_set_reg_safe(rdev); 331 r300_set_reg_safe(rdev);
313 r = r420_resume(rdev); 332 r = r420_resume(rdev);
314 if (r) { 333 if (r) {
@@ -318,14 +337,10 @@ int r420_init(struct radeon_device *rdev)
318 r100_cp_fini(rdev); 337 r100_cp_fini(rdev);
319 r100_wb_fini(rdev); 338 r100_wb_fini(rdev);
320 r100_ib_fini(rdev); 339 r100_ib_fini(rdev);
321 if (rdev->flags & RADEON_IS_PCIE) { 340 if (rdev->flags & RADEON_IS_PCIE)
322 rv370_pcie_gart_disable(rdev); 341 rv370_pcie_gart_fini(rdev);
323 radeon_gart_table_vram_free(rdev); 342 if (rdev->flags & RADEON_IS_PCI)
324 } else { 343 r100_pci_gart_fini(rdev);
325 r100_pci_gart_disable(rdev);
326 radeon_gart_table_ram_free(rdev);
327 }
328 radeon_gart_fini(rdev);
329 radeon_agp_fini(rdev); 344 radeon_agp_fini(rdev);
330 radeon_irq_kms_fini(rdev); 345 radeon_irq_kms_fini(rdev);
331 } 346 }
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 0e1686d1c873..d4b0b9d2e39b 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -31,8 +31,6 @@
31 31
32/* r520,rv530,rv560,rv570,r580 depends on : */ 32/* r520,rv530,rv560,rv570,r580 depends on : */
33void r100_hdp_reset(struct radeon_device *rdev); 33void r100_hdp_reset(struct radeon_device *rdev);
34int rv370_pcie_gart_enable(struct radeon_device *rdev);
35void rv370_pcie_gart_disable(struct radeon_device *rdev);
36void r420_pipes_init(struct radeon_device *rdev); 34void r420_pipes_init(struct radeon_device *rdev);
37void rs600_mc_disable_clients(struct radeon_device *rdev); 35void rs600_mc_disable_clients(struct radeon_device *rdev);
38void rs600_disable_vga(struct radeon_device *rdev); 36void rs600_disable_vga(struct radeon_device *rdev);
@@ -118,9 +116,6 @@ int r520_mc_init(struct radeon_device *rdev)
118 116
119void r520_mc_fini(struct radeon_device *rdev) 117void r520_mc_fini(struct radeon_device *rdev)
120{ 118{
121 rv370_pcie_gart_disable(rdev);
122 radeon_gart_table_vram_free(rdev);
123 radeon_gart_fini(rdev);
124} 119}
125 120
126 121
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 1bc25678986b..65699e9f2025 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -113,21 +113,34 @@ void r600_pcie_gart_tlb_flush(struct radeon_device *rdev)
113 } 113 }
114} 114}
115 115
116int r600_pcie_gart_enable(struct radeon_device *rdev) 116int r600_pcie_gart_init(struct radeon_device *rdev)
117{ 117{
118 u32 tmp; 118 int r;
119 int r, i;
120 119
120 if (rdev->gart.table.vram.robj) {
121 WARN(1, "R600 PCIE GART already initialized.\n");
122 return 0;
123 }
121 /* Initialize common gart structure */ 124 /* Initialize common gart structure */
122 r = radeon_gart_init(rdev); 125 r = radeon_gart_init(rdev);
123 if (r) { 126 if (r)
124 return r; 127 return r;
125 }
126 rdev->gart.table_size = rdev->gart.num_gpu_pages * 8; 128 rdev->gart.table_size = rdev->gart.num_gpu_pages * 8;
127 r = radeon_gart_table_vram_alloc(rdev); 129 return radeon_gart_table_vram_alloc(rdev);
128 if (r) { 130}
129 return r; 131
132int r600_pcie_gart_enable(struct radeon_device *rdev)
133{
134 u32 tmp;
135 int r, i;
136
137 if (rdev->gart.table.vram.robj == NULL) {
138 dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
139 return -EINVAL;
130 } 140 }
141 r = radeon_gart_table_vram_pin(rdev);
142 if (r)
143 return r;
131 for (i = 0; i < rdev->gart.num_gpu_pages; i++) 144 for (i = 0; i < rdev->gart.num_gpu_pages; i++)
132 r600_gart_clear_page(rdev, i); 145 r600_gart_clear_page(rdev, i);
133 /* Setup L2 cache */ 146 /* Setup L2 cache */
@@ -175,10 +188,6 @@ void r600_pcie_gart_disable(struct radeon_device *rdev)
175 u32 tmp; 188 u32 tmp;
176 int i; 189 int i;
177 190
178 /* Clear ptes*/
179 for (i = 0; i < rdev->gart.num_gpu_pages; i++)
180 r600_gart_clear_page(rdev, i);
181 r600_pcie_gart_tlb_flush(rdev);
182 /* Disable all tables */ 191 /* Disable all tables */
183 for (i = 0; i < 7; i++) 192 for (i = 0; i < 7; i++)
184 WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); 193 WREG32(VM_CONTEXT0_CNTL + (i * 4), 0);
@@ -204,6 +213,17 @@ void r600_pcie_gart_disable(struct radeon_device *rdev)
204 WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL, tmp); 213 WREG32(MC_VM_L1_TLB_MCB_WR_SYS_CNTL, tmp);
205 WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL, tmp); 214 WREG32(MC_VM_L1_TLB_MCB_RD_HDP_CNTL, tmp);
206 WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL, tmp); 215 WREG32(MC_VM_L1_TLB_MCB_WR_HDP_CNTL, tmp);
216 if (rdev->gart.table.vram.robj) {
217 radeon_object_kunmap(rdev->gart.table.vram.robj);
218 radeon_object_unpin(rdev->gart.table.vram.robj);
219 }
220}
221
222void r600_pcie_gart_fini(struct radeon_device *rdev)
223{
224 r600_pcie_gart_disable(rdev);
225 radeon_gart_table_vram_free(rdev);
226 radeon_gart_fini(rdev);
207} 227}
208 228
209int r600_mc_wait_for_idle(struct radeon_device *rdev) 229int r600_mc_wait_for_idle(struct radeon_device *rdev)
@@ -1472,6 +1492,7 @@ int r600_suspend(struct radeon_device *rdev)
1472{ 1492{
1473 /* FIXME: we should wait for ring to be empty */ 1493 /* FIXME: we should wait for ring to be empty */
1474 r600_cp_stop(rdev); 1494 r600_cp_stop(rdev);
1495 r600_pcie_gart_disable(rdev);
1475 return 0; 1496 return 0;
1476} 1497}
1477 1498
@@ -1548,6 +1569,10 @@ int r600_init(struct radeon_device *rdev)
1548 } 1569 }
1549 } 1570 }
1550 1571
1572 r = r600_pcie_gart_init(rdev);
1573 if (r)
1574 return r;
1575
1551 r = r600_resume(rdev); 1576 r = r600_resume(rdev);
1552 if (r) { 1577 if (r) {
1553 if (rdev->flags & RADEON_IS_AGP) { 1578 if (rdev->flags & RADEON_IS_AGP) {
@@ -1583,9 +1608,7 @@ void r600_fini(struct radeon_device *rdev)
1583 1608
1584 r600_blit_fini(rdev); 1609 r600_blit_fini(rdev);
1585 radeon_ring_fini(rdev); 1610 radeon_ring_fini(rdev);
1586 r600_pcie_gart_disable(rdev); 1611 r600_pcie_gart_fini(rdev);
1587 radeon_gart_table_vram_free(rdev);
1588 radeon_gart_fini(rdev);
1589 radeon_gem_fini(rdev); 1612 radeon_gem_fini(rdev);
1590 radeon_fence_driver_fini(rdev); 1613 radeon_fence_driver_fini(rdev);
1591 radeon_clocks_fini(rdev); 1614 radeon_clocks_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 8cec5bf2922b..99292be8bc99 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -596,6 +596,8 @@ struct radeon_asic {
596 void (*mc_fini)(struct radeon_device *rdev); 596 void (*mc_fini)(struct radeon_device *rdev);
597 int (*wb_init)(struct radeon_device *rdev); 597 int (*wb_init)(struct radeon_device *rdev);
598 void (*wb_fini)(struct radeon_device *rdev); 598 void (*wb_fini)(struct radeon_device *rdev);
599 int (*gart_init)(struct radeon_device *rdev);
600 void (*gart_fini)(struct radeon_device *rdev);
599 int (*gart_enable)(struct radeon_device *rdev); 601 int (*gart_enable)(struct radeon_device *rdev);
600 void (*gart_disable)(struct radeon_device *rdev); 602 void (*gart_disable)(struct radeon_device *rdev);
601 void (*gart_tlb_flush)(struct radeon_device *rdev); 603 void (*gart_tlb_flush)(struct radeon_device *rdev);
@@ -950,6 +952,8 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
950#define radeon_mc_fini(rdev) (rdev)->asic->mc_fini((rdev)) 952#define radeon_mc_fini(rdev) (rdev)->asic->mc_fini((rdev))
951#define radeon_wb_init(rdev) (rdev)->asic->wb_init((rdev)) 953#define radeon_wb_init(rdev) (rdev)->asic->wb_init((rdev))
952#define radeon_wb_fini(rdev) (rdev)->asic->wb_fini((rdev)) 954#define radeon_wb_fini(rdev) (rdev)->asic->wb_fini((rdev))
955#define radeon_gpu_gart_init(rdev) (rdev)->asic->gart_init((rdev))
956#define radeon_gpu_gart_fini(rdev) (rdev)->asic->gart_fini((rdev))
953#define radeon_gart_enable(rdev) (rdev)->asic->gart_enable((rdev)) 957#define radeon_gart_enable(rdev) (rdev)->asic->gart_enable((rdev))
954#define radeon_gart_disable(rdev) (rdev)->asic->gart_disable((rdev)) 958#define radeon_gart_disable(rdev) (rdev)->asic->gart_disable((rdev))
955#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev)) 959#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
@@ -978,6 +982,7 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
978#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev)) 982#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
979 983
980/* Common functions */ 984/* Common functions */
985extern int radeon_gart_table_vram_pin(struct radeon_device *rdev);
981extern int radeon_modeset_init(struct radeon_device *rdev); 986extern int radeon_modeset_init(struct radeon_device *rdev);
982extern void radeon_modeset_fini(struct radeon_device *rdev); 987extern void radeon_modeset_fini(struct radeon_device *rdev);
983extern bool radeon_card_posted(struct radeon_device *rdev); 988extern bool radeon_card_posted(struct radeon_device *rdev);
@@ -1000,6 +1005,8 @@ extern void r100_cp_disable(struct radeon_device *rdev);
1000extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size); 1005extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
1001extern void r100_cp_fini(struct radeon_device *rdev); 1006extern void r100_cp_fini(struct radeon_device *rdev);
1002extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev); 1007extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
1008extern int r100_pci_gart_init(struct radeon_device *rdev);
1009extern void r100_pci_gart_fini(struct radeon_device *rdev);
1003extern int r100_pci_gart_enable(struct radeon_device *rdev); 1010extern int r100_pci_gart_enable(struct radeon_device *rdev);
1004extern void r100_pci_gart_disable(struct radeon_device *rdev); 1011extern void r100_pci_gart_disable(struct radeon_device *rdev);
1005extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr); 1012extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
@@ -1020,6 +1027,9 @@ extern int r100_wb_init(struct radeon_device *rdev);
1020extern void r300_set_reg_safe(struct radeon_device *rdev); 1027extern void r300_set_reg_safe(struct radeon_device *rdev);
1021extern void r300_mc_program(struct radeon_device *rdev); 1028extern void r300_mc_program(struct radeon_device *rdev);
1022extern void r300_vram_info(struct radeon_device *rdev); 1029extern void r300_vram_info(struct radeon_device *rdev);
1030extern int rv370_pcie_gart_init(struct radeon_device *rdev);
1031extern void rv370_pcie_gart_fini(struct radeon_device *rdev);
1032extern int rv370_pcie_gart_enable(struct radeon_device *rdev);
1023extern void rv370_pcie_gart_disable(struct radeon_device *rdev); 1033extern void rv370_pcie_gart_disable(struct radeon_device *rdev);
1024 1034
1025/* r420,r423,rv410 */ 1035/* r420,r423,rv410 */
@@ -1043,6 +1053,7 @@ extern int r600_cp_resume(struct radeon_device *rdev);
1043extern int r600_count_pipe_bits(uint32_t val); 1053extern int r600_count_pipe_bits(uint32_t val);
1044extern int r600_gart_clear_page(struct radeon_device *rdev, int i); 1054extern int r600_gart_clear_page(struct radeon_device *rdev, int i);
1045extern int r600_mc_wait_for_idle(struct radeon_device *rdev); 1055extern int r600_mc_wait_for_idle(struct radeon_device *rdev);
1056extern int r600_pcie_gart_init(struct radeon_device *rdev);
1046extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev); 1057extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev);
1047extern int r600_ib_test(struct radeon_device *rdev); 1058extern int r600_ib_test(struct radeon_device *rdev);
1048extern int r600_ring_test(struct radeon_device *rdev); 1059extern int r600_ring_test(struct radeon_device *rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 8f27be31e094..5f2a9e6f12c5 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -53,7 +53,9 @@ void r100_mc_fini(struct radeon_device *rdev);
53u32 r100_get_vblank_counter(struct radeon_device *rdev, int crtc); 53u32 r100_get_vblank_counter(struct radeon_device *rdev, int crtc);
54int r100_wb_init(struct radeon_device *rdev); 54int r100_wb_init(struct radeon_device *rdev);
55void r100_wb_fini(struct radeon_device *rdev); 55void r100_wb_fini(struct radeon_device *rdev);
56int r100_gart_enable(struct radeon_device *rdev); 56int r100_pci_gart_init(struct radeon_device *rdev);
57void r100_pci_gart_fini(struct radeon_device *rdev);
58int r100_pci_gart_enable(struct radeon_device *rdev);
57void r100_pci_gart_disable(struct radeon_device *rdev); 59void r100_pci_gart_disable(struct radeon_device *rdev);
58void r100_pci_gart_tlb_flush(struct radeon_device *rdev); 60void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
59int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr); 61int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
@@ -92,7 +94,9 @@ static struct radeon_asic r100_asic = {
92 .mc_fini = &r100_mc_fini, 94 .mc_fini = &r100_mc_fini,
93 .wb_init = &r100_wb_init, 95 .wb_init = &r100_wb_init,
94 .wb_fini = &r100_wb_fini, 96 .wb_fini = &r100_wb_fini,
95 .gart_enable = &r100_gart_enable, 97 .gart_init = &r100_pci_gart_init,
98 .gart_fini = &r100_pci_gart_fini,
99 .gart_enable = &r100_pci_gart_enable,
96 .gart_disable = &r100_pci_gart_disable, 100 .gart_disable = &r100_pci_gart_disable,
97 .gart_tlb_flush = &r100_pci_gart_tlb_flush, 101 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
98 .gart_set_page = &r100_pci_gart_set_page, 102 .gart_set_page = &r100_pci_gart_set_page,
@@ -135,7 +139,9 @@ void r300_ring_start(struct radeon_device *rdev);
135void r300_fence_ring_emit(struct radeon_device *rdev, 139void r300_fence_ring_emit(struct radeon_device *rdev,
136 struct radeon_fence *fence); 140 struct radeon_fence *fence);
137int r300_cs_parse(struct radeon_cs_parser *p); 141int r300_cs_parse(struct radeon_cs_parser *p);
138int r300_gart_enable(struct radeon_device *rdev); 142int rv370_pcie_gart_init(struct radeon_device *rdev);
143void rv370_pcie_gart_fini(struct radeon_device *rdev);
144int rv370_pcie_gart_enable(struct radeon_device *rdev);
139void rv370_pcie_gart_disable(struct radeon_device *rdev); 145void rv370_pcie_gart_disable(struct radeon_device *rdev);
140void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev); 146void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev);
141int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr); 147int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
@@ -157,7 +163,9 @@ static struct radeon_asic r300_asic = {
157 .mc_fini = &r300_mc_fini, 163 .mc_fini = &r300_mc_fini,
158 .wb_init = &r100_wb_init, 164 .wb_init = &r100_wb_init,
159 .wb_fini = &r100_wb_fini, 165 .wb_fini = &r100_wb_fini,
160 .gart_enable = &r300_gart_enable, 166 .gart_init = &r100_pci_gart_init,
167 .gart_fini = &r100_pci_gart_fini,
168 .gart_enable = &r100_pci_gart_enable,
161 .gart_disable = &r100_pci_gart_disable, 169 .gart_disable = &r100_pci_gart_disable,
162 .gart_tlb_flush = &r100_pci_gart_tlb_flush, 170 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
163 .gart_set_page = &r100_pci_gart_set_page, 171 .gart_set_page = &r100_pci_gart_set_page,
@@ -205,8 +213,8 @@ static struct radeon_asic r420_asic = {
205 .mc_fini = NULL, 213 .mc_fini = NULL,
206 .wb_init = NULL, 214 .wb_init = NULL,
207 .wb_fini = NULL, 215 .wb_fini = NULL,
208 .gart_enable = &r300_gart_enable, 216 .gart_enable = NULL,
209 .gart_disable = &rv370_pcie_gart_disable, 217 .gart_disable = NULL,
210 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, 218 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
211 .gart_set_page = &rv370_pcie_gart_set_page, 219 .gart_set_page = &rv370_pcie_gart_set_page,
212 .cp_init = NULL, 220 .cp_init = NULL,
@@ -242,6 +250,8 @@ void rs400_errata(struct radeon_device *rdev);
242void rs400_vram_info(struct radeon_device *rdev); 250void rs400_vram_info(struct radeon_device *rdev);
243int rs400_mc_init(struct radeon_device *rdev); 251int rs400_mc_init(struct radeon_device *rdev);
244void rs400_mc_fini(struct radeon_device *rdev); 252void rs400_mc_fini(struct radeon_device *rdev);
253int rs400_gart_init(struct radeon_device *rdev);
254void rs400_gart_fini(struct radeon_device *rdev);
245int rs400_gart_enable(struct radeon_device *rdev); 255int rs400_gart_enable(struct radeon_device *rdev);
246void rs400_gart_disable(struct radeon_device *rdev); 256void rs400_gart_disable(struct radeon_device *rdev);
247void rs400_gart_tlb_flush(struct radeon_device *rdev); 257void rs400_gart_tlb_flush(struct radeon_device *rdev);
@@ -257,6 +267,8 @@ static struct radeon_asic rs400_asic = {
257 .mc_fini = &rs400_mc_fini, 267 .mc_fini = &rs400_mc_fini,
258 .wb_init = &r100_wb_init, 268 .wb_init = &r100_wb_init,
259 .wb_fini = &r100_wb_fini, 269 .wb_fini = &r100_wb_fini,
270 .gart_init = &rs400_gart_init,
271 .gart_fini = &rs400_gart_fini,
260 .gart_enable = &rs400_gart_enable, 272 .gart_enable = &rs400_gart_enable,
261 .gart_disable = &rs400_gart_disable, 273 .gart_disable = &rs400_gart_disable,
262 .gart_tlb_flush = &rs400_gart_tlb_flush, 274 .gart_tlb_flush = &rs400_gart_tlb_flush,
@@ -298,6 +310,8 @@ void rs600_mc_fini(struct radeon_device *rdev);
298int rs600_irq_set(struct radeon_device *rdev); 310int rs600_irq_set(struct radeon_device *rdev);
299int rs600_irq_process(struct radeon_device *rdev); 311int rs600_irq_process(struct radeon_device *rdev);
300u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc); 312u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc);
313int rs600_gart_init(struct radeon_device *rdev);
314void rs600_gart_fini(struct radeon_device *rdev);
301int rs600_gart_enable(struct radeon_device *rdev); 315int rs600_gart_enable(struct radeon_device *rdev);
302void rs600_gart_disable(struct radeon_device *rdev); 316void rs600_gart_disable(struct radeon_device *rdev);
303void rs600_gart_tlb_flush(struct radeon_device *rdev); 317void rs600_gart_tlb_flush(struct radeon_device *rdev);
@@ -314,6 +328,8 @@ static struct radeon_asic rs600_asic = {
314 .mc_fini = &rs600_mc_fini, 328 .mc_fini = &rs600_mc_fini,
315 .wb_init = &r100_wb_init, 329 .wb_init = &r100_wb_init,
316 .wb_fini = &r100_wb_fini, 330 .wb_fini = &r100_wb_fini,
331 .gart_init = &rs600_gart_init,
332 .gart_fini = &rs600_gart_fini,
317 .gart_enable = &rs600_gart_enable, 333 .gart_enable = &rs600_gart_enable,
318 .gart_disable = &rs600_gart_disable, 334 .gart_disable = &rs600_gart_disable,
319 .gart_tlb_flush = &rs600_gart_tlb_flush, 335 .gart_tlb_flush = &rs600_gart_tlb_flush,
@@ -361,6 +377,8 @@ static struct radeon_asic rs690_asic = {
361 .mc_fini = &rs690_mc_fini, 377 .mc_fini = &rs690_mc_fini,
362 .wb_init = &r100_wb_init, 378 .wb_init = &r100_wb_init,
363 .wb_fini = &r100_wb_fini, 379 .wb_fini = &r100_wb_fini,
380 .gart_init = &rs400_gart_init,
381 .gart_fini = &rs400_gart_fini,
364 .gart_enable = &rs400_gart_enable, 382 .gart_enable = &rs400_gart_enable,
365 .gart_disable = &rs400_gart_disable, 383 .gart_disable = &rs400_gart_disable,
366 .gart_tlb_flush = &rs400_gart_tlb_flush, 384 .gart_tlb_flush = &rs400_gart_tlb_flush,
@@ -415,7 +433,9 @@ static struct radeon_asic rv515_asic = {
415 .mc_fini = &rv515_mc_fini, 433 .mc_fini = &rv515_mc_fini,
416 .wb_init = &r100_wb_init, 434 .wb_init = &r100_wb_init,
417 .wb_fini = &r100_wb_fini, 435 .wb_fini = &r100_wb_fini,
418 .gart_enable = &r300_gart_enable, 436 .gart_init = &rv370_pcie_gart_init,
437 .gart_fini = &rv370_pcie_gart_fini,
438 .gart_enable = &rv370_pcie_gart_enable,
419 .gart_disable = &rv370_pcie_gart_disable, 439 .gart_disable = &rv370_pcie_gart_disable,
420 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, 440 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
421 .gart_set_page = &rv370_pcie_gart_set_page, 441 .gart_set_page = &rv370_pcie_gart_set_page,
@@ -462,7 +482,9 @@ static struct radeon_asic r520_asic = {
462 .mc_fini = &r520_mc_fini, 482 .mc_fini = &r520_mc_fini,
463 .wb_init = &r100_wb_init, 483 .wb_init = &r100_wb_init,
464 .wb_fini = &r100_wb_fini, 484 .wb_fini = &r100_wb_fini,
465 .gart_enable = &r300_gart_enable, 485 .gart_init = &rv370_pcie_gart_init,
486 .gart_fini = &rv370_pcie_gart_fini,
487 .gart_enable = &rv370_pcie_gart_enable,
466 .gart_disable = &rv370_pcie_gart_disable, 488 .gart_disable = &rv370_pcie_gart_disable,
467 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, 489 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
468 .gart_set_page = &rv370_pcie_gart_set_page, 490 .gart_set_page = &rv370_pcie_gart_set_page,
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index ece097c3e079..7b6d0b1a5962 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -320,6 +320,14 @@ int radeon_asic_init(struct radeon_device *rdev)
320 case CHIP_RV350: 320 case CHIP_RV350:
321 case CHIP_RV380: 321 case CHIP_RV380:
322 rdev->asic = &r300_asic; 322 rdev->asic = &r300_asic;
323 if (rdev->flags & RADEON_IS_PCIE) {
324 rdev->asic->gart_init = &rv370_pcie_gart_init;
325 rdev->asic->gart_fini = &rv370_pcie_gart_fini;
326 rdev->asic->gart_enable = &rv370_pcie_gart_enable;
327 rdev->asic->gart_disable = &rv370_pcie_gart_disable;
328 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
329 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
330 }
323 break; 331 break;
324 case CHIP_R420: 332 case CHIP_R420:
325 case CHIP_R423: 333 case CHIP_R423:
@@ -504,6 +512,12 @@ int radeon_device_init(struct radeon_device *rdev,
504 rwlock_init(&rdev->fence_drv.lock); 512 rwlock_init(&rdev->fence_drv.lock);
505 INIT_LIST_HEAD(&rdev->gem.objects); 513 INIT_LIST_HEAD(&rdev->gem.objects);
506 514
515 /* Set asic functions */
516 r = radeon_asic_init(rdev);
517 if (r) {
518 return r;
519 }
520
507 if (radeon_agpmode == -1) { 521 if (radeon_agpmode == -1) {
508 rdev->flags &= ~RADEON_IS_AGP; 522 rdev->flags &= ~RADEON_IS_AGP;
509 if (rdev->family >= CHIP_RV515 || 523 if (rdev->family >= CHIP_RV515 ||
@@ -512,18 +526,24 @@ int radeon_device_init(struct radeon_device *rdev,
512 rdev->family == CHIP_R423) { 526 rdev->family == CHIP_R423) {
513 DRM_INFO("Forcing AGP to PCIE mode\n"); 527 DRM_INFO("Forcing AGP to PCIE mode\n");
514 rdev->flags |= RADEON_IS_PCIE; 528 rdev->flags |= RADEON_IS_PCIE;
529 rdev->asic->gart_init = &rv370_pcie_gart_init;
530 rdev->asic->gart_fini = &rv370_pcie_gart_fini;
531 rdev->asic->gart_enable = &rv370_pcie_gart_enable;
532 rdev->asic->gart_disable = &rv370_pcie_gart_disable;
533 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
534 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
515 } else { 535 } else {
516 DRM_INFO("Forcing AGP to PCI mode\n"); 536 DRM_INFO("Forcing AGP to PCI mode\n");
517 rdev->flags |= RADEON_IS_PCI; 537 rdev->flags |= RADEON_IS_PCI;
538 rdev->asic->gart_init = &r100_pci_gart_init;
539 rdev->asic->gart_fini = &r100_pci_gart_fini;
540 rdev->asic->gart_enable = &r100_pci_gart_enable;
541 rdev->asic->gart_disable = &r100_pci_gart_disable;
542 rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
543 rdev->asic->gart_set_page = &r100_pci_gart_set_page;
518 } 544 }
519 } 545 }
520 546
521 /* Set asic functions */
522 r = radeon_asic_init(rdev);
523 if (r) {
524 return r;
525 }
526
527 /* set DMA mask + need_dma32 flags. 547 /* set DMA mask + need_dma32 flags.
528 * PCIE - can handle 40-bits. 548 * PCIE - can handle 40-bits.
529 * IGP - can handle 40-bits (in theory) 549 * IGP - can handle 40-bits (in theory)
@@ -623,6 +643,9 @@ int radeon_device_init(struct radeon_device *rdev,
623 if (r) { 643 if (r) {
624 return r; 644 return r;
625 } 645 }
646 r = radeon_gpu_gart_init(rdev);
647 if (r)
648 return r;
626 /* Initialize GART (initialize after TTM so we can allocate 649 /* Initialize GART (initialize after TTM so we can allocate
627 * memory through TTM but finalize after TTM) */ 650 * memory through TTM but finalize after TTM) */
628 r = radeon_gart_enable(rdev); 651 r = radeon_gart_enable(rdev);
@@ -675,6 +698,7 @@ void radeon_device_fini(struct radeon_device *rdev)
675 radeon_ib_pool_fini(rdev); 698 radeon_ib_pool_fini(rdev);
676 radeon_cp_fini(rdev); 699 radeon_cp_fini(rdev);
677 radeon_wb_fini(rdev); 700 radeon_wb_fini(rdev);
701 radeon_gpu_gart_fini(rdev);
678 radeon_gem_fini(rdev); 702 radeon_gem_fini(rdev);
679 radeon_mc_fini(rdev); 703 radeon_mc_fini(rdev);
680#if __OS_HAS_AGP 704#if __OS_HAS_AGP
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 2977539880fb..a931af065dd4 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -75,7 +75,6 @@ void radeon_gart_table_ram_free(struct radeon_device *rdev)
75 75
76int radeon_gart_table_vram_alloc(struct radeon_device *rdev) 76int radeon_gart_table_vram_alloc(struct radeon_device *rdev)
77{ 77{
78 uint64_t gpu_addr;
79 int r; 78 int r;
80 79
81 if (rdev->gart.table.vram.robj == NULL) { 80 if (rdev->gart.table.vram.robj == NULL) {
@@ -88,6 +87,14 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev)
88 return r; 87 return r;
89 } 88 }
90 } 89 }
90 return 0;
91}
92
93int radeon_gart_table_vram_pin(struct radeon_device *rdev)
94{
95 uint64_t gpu_addr;
96 int r;
97
91 r = radeon_object_pin(rdev->gart.table.vram.robj, 98 r = radeon_object_pin(rdev->gart.table.vram.robj,
92 RADEON_GEM_DOMAIN_VRAM, &gpu_addr); 99 RADEON_GEM_DOMAIN_VRAM, &gpu_addr);
93 if (r) { 100 if (r) {
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index e1e4ce427828..a3fbdad938c7 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -92,20 +92,41 @@ void rs400_gart_tlb_flush(struct radeon_device *rdev)
92 WREG32_MC(RS480_GART_CACHE_CNTRL, 0); 92 WREG32_MC(RS480_GART_CACHE_CNTRL, 0);
93} 93}
94 94
95int rs400_gart_enable(struct radeon_device *rdev) 95int rs400_gart_init(struct radeon_device *rdev)
96{ 96{
97 uint32_t size_reg;
98 uint32_t tmp;
99 int r; 97 int r;
100 98
99 if (rdev->gart.table.ram.ptr) {
100 WARN(1, "RS400 GART already initialized.\n");
101 return 0;
102 }
103 /* Check gart size */
104 switch(rdev->mc.gtt_size / (1024 * 1024)) {
105 case 32:
106 case 64:
107 case 128:
108 case 256:
109 case 512:
110 case 1024:
111 case 2048:
112 break;
113 default:
114 return -EINVAL;
115 }
101 /* Initialize common gart structure */ 116 /* Initialize common gart structure */
102 r = radeon_gart_init(rdev); 117 r = radeon_gart_init(rdev);
103 if (r) { 118 if (r)
104 return r; 119 return r;
105 } 120 if (rs400_debugfs_pcie_gart_info_init(rdev))
106 if (rs400_debugfs_pcie_gart_info_init(rdev)) {
107 DRM_ERROR("Failed to register debugfs file for RS400 GART !\n"); 121 DRM_ERROR("Failed to register debugfs file for RS400 GART !\n");
108 } 122 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
123 return radeon_gart_table_ram_alloc(rdev);
124}
125
126int rs400_gart_enable(struct radeon_device *rdev)
127{
128 uint32_t size_reg;
129 uint32_t tmp;
109 130
110 tmp = RREG32_MC(RS690_AIC_CTRL_SCRATCH); 131 tmp = RREG32_MC(RS690_AIC_CTRL_SCRATCH);
111 tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; 132 tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS;
@@ -136,13 +157,6 @@ int rs400_gart_enable(struct radeon_device *rdev)
136 default: 157 default:
137 return -EINVAL; 158 return -EINVAL;
138 } 159 }
139 if (rdev->gart.table.ram.ptr == NULL) {
140 rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
141 r = radeon_gart_table_ram_alloc(rdev);
142 if (r) {
143 return r;
144 }
145 }
146 /* It should be fine to program it to max value */ 160 /* It should be fine to program it to max value */
147 if (rdev->family == CHIP_RS690 || (rdev->family == CHIP_RS740)) { 161 if (rdev->family == CHIP_RS690 || (rdev->family == CHIP_RS740)) {
148 WREG32_MC(RS690_MCCFG_AGP_BASE, 0xFFFFFFFF); 162 WREG32_MC(RS690_MCCFG_AGP_BASE, 0xFFFFFFFF);
@@ -201,6 +215,13 @@ void rs400_gart_disable(struct radeon_device *rdev)
201 WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0); 215 WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0);
202} 216}
203 217
218void rs400_gart_fini(struct radeon_device *rdev)
219{
220 rs400_gart_disable(rdev);
221 radeon_gart_table_ram_free(rdev);
222 radeon_gart_fini(rdev);
223}
224
204int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) 225int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
205{ 226{
206 uint32_t entry; 227 uint32_t entry;
@@ -255,14 +276,12 @@ int rs400_mc_init(struct radeon_device *rdev)
255 (void)RREG32(RADEON_HOST_PATH_CNTL); 276 (void)RREG32(RADEON_HOST_PATH_CNTL);
256 WREG32(RADEON_HOST_PATH_CNTL, tmp); 277 WREG32(RADEON_HOST_PATH_CNTL, tmp);
257 (void)RREG32(RADEON_HOST_PATH_CNTL); 278 (void)RREG32(RADEON_HOST_PATH_CNTL);
279
258 return 0; 280 return 0;
259} 281}
260 282
261void rs400_mc_fini(struct radeon_device *rdev) 283void rs400_mc_fini(struct radeon_device *rdev)
262{ 284{
263 rs400_gart_disable(rdev);
264 radeon_gart_table_ram_free(rdev);
265 radeon_gart_fini(rdev);
266} 285}
267 286
268 287
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 1b8d62f5e73c..c31bd8439259 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -68,22 +68,35 @@ void rs600_gart_tlb_flush(struct radeon_device *rdev)
68 tmp = RREG32_MC(RS600_MC_PT0_CNTL); 68 tmp = RREG32_MC(RS600_MC_PT0_CNTL);
69} 69}
70 70
71int rs600_gart_enable(struct radeon_device *rdev) 71int rs600_gart_init(struct radeon_device *rdev)
72{ 72{
73 uint32_t tmp;
74 int i;
75 int r; 73 int r;
76 74
75 if (rdev->gart.table.vram.robj) {
76 WARN(1, "RS600 GART already initialized.\n");
77 return 0;
78 }
77 /* Initialize common gart structure */ 79 /* Initialize common gart structure */
78 r = radeon_gart_init(rdev); 80 r = radeon_gart_init(rdev);
79 if (r) { 81 if (r) {
80 return r; 82 return r;
81 } 83 }
82 rdev->gart.table_size = rdev->gart.num_gpu_pages * 8; 84 rdev->gart.table_size = rdev->gart.num_gpu_pages * 8;
83 r = radeon_gart_table_vram_alloc(rdev); 85 return radeon_gart_table_vram_alloc(rdev);
84 if (r) { 86}
85 return r; 87
88int rs600_gart_enable(struct radeon_device *rdev)
89{
90 uint32_t tmp;
91 int r, i;
92
93 if (rdev->gart.table.vram.robj == NULL) {
94 dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
95 return -EINVAL;
86 } 96 }
97 r = radeon_gart_table_vram_pin(rdev);
98 if (r)
99 return r;
87 /* FIXME: setup default page */ 100 /* FIXME: setup default page */
88 WREG32_MC(RS600_MC_PT0_CNTL, 101 WREG32_MC(RS600_MC_PT0_CNTL,
89 (RS600_EFFECTIVE_L2_CACHE_SIZE(6) | 102 (RS600_EFFECTIVE_L2_CACHE_SIZE(6) |
@@ -138,8 +151,17 @@ void rs600_gart_disable(struct radeon_device *rdev)
138 tmp = RREG32_MC(RS600_MC_CNTL1); 151 tmp = RREG32_MC(RS600_MC_CNTL1);
139 tmp &= ~RS600_ENABLE_PAGE_TABLES; 152 tmp &= ~RS600_ENABLE_PAGE_TABLES;
140 WREG32_MC(RS600_MC_CNTL1, tmp); 153 WREG32_MC(RS600_MC_CNTL1, tmp);
141 radeon_object_kunmap(rdev->gart.table.vram.robj); 154 if (rdev->gart.table.vram.robj) {
142 radeon_object_unpin(rdev->gart.table.vram.robj); 155 radeon_object_kunmap(rdev->gart.table.vram.robj);
156 radeon_object_unpin(rdev->gart.table.vram.robj);
157 }
158}
159
160void rs600_gart_fini(struct radeon_device *rdev)
161{
162 rs600_gart_disable(rdev);
163 radeon_gart_table_vram_free(rdev);
164 radeon_gart_fini(rdev);
143} 165}
144 166
145#define R600_PTE_VALID (1 << 0) 167#define R600_PTE_VALID (1 << 0)
@@ -235,9 +257,6 @@ int rs600_mc_init(struct radeon_device *rdev)
235 257
236void rs600_mc_fini(struct radeon_device *rdev) 258void rs600_mc_fini(struct radeon_device *rdev)
237{ 259{
238 rs600_gart_disable(rdev);
239 radeon_gart_table_vram_free(rdev);
240 radeon_gart_fini(rdev);
241} 260}
242 261
243 262
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 839595b00728..0f585ca8276d 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -94,9 +94,6 @@ int rs690_mc_init(struct radeon_device *rdev)
94 94
95void rs690_mc_fini(struct radeon_device *rdev) 95void rs690_mc_fini(struct radeon_device *rdev)
96{ 96{
97 rs400_gart_disable(rdev);
98 radeon_gart_table_ram_free(rdev);
99 radeon_gart_fini(rdev);
100} 97}
101 98
102 99
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 03d490269ed0..fd799748e7d8 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -37,8 +37,6 @@ int r100_cp_reset(struct radeon_device *rdev);
37int r100_rb2d_reset(struct radeon_device *rdev); 37int r100_rb2d_reset(struct radeon_device *rdev);
38int r100_gui_wait_for_idle(struct radeon_device *rdev); 38int r100_gui_wait_for_idle(struct radeon_device *rdev);
39int r100_cp_init(struct radeon_device *rdev, unsigned ring_size); 39int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
40int rv370_pcie_gart_enable(struct radeon_device *rdev);
41void rv370_pcie_gart_disable(struct radeon_device *rdev);
42void r420_pipes_init(struct radeon_device *rdev); 40void r420_pipes_init(struct radeon_device *rdev);
43void rs600_mc_disable_clients(struct radeon_device *rdev); 41void rs600_mc_disable_clients(struct radeon_device *rdev);
44void rs600_disable_vga(struct radeon_device *rdev); 42void rs600_disable_vga(struct radeon_device *rdev);
@@ -126,9 +124,6 @@ int rv515_mc_init(struct radeon_device *rdev)
126 124
127void rv515_mc_fini(struct radeon_device *rdev) 125void rv515_mc_fini(struct radeon_device *rdev)
128{ 126{
129 rv370_pcie_gart_disable(rdev);
130 radeon_gart_table_vram_free(rdev);
131 radeon_gart_fini(rdev);
132} 127}
133 128
134 129
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 5ba5204091ec..4f2098bc7974 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -48,16 +48,13 @@ int rv770_pcie_gart_enable(struct radeon_device *rdev)
48 u32 tmp; 48 u32 tmp;
49 int r, i; 49 int r, i;
50 50
51 /* Initialize common gart structure */ 51 if (rdev->gart.table.vram.robj == NULL) {
52 r = radeon_gart_init(rdev); 52 dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
53 if (r) { 53 return -EINVAL;
54 return r;
55 } 54 }
56 rdev->gart.table_size = rdev->gart.num_gpu_pages * 8; 55 r = radeon_gart_table_vram_pin(rdev);
57 r = radeon_gart_table_vram_alloc(rdev); 56 if (r)
58 if (r) {
59 return r; 57 return r;
60 }
61 for (i = 0; i < rdev->gart.num_gpu_pages; i++) 58 for (i = 0; i < rdev->gart.num_gpu_pages; i++)
62 r600_gart_clear_page(rdev, i); 59 r600_gart_clear_page(rdev, i);
63 /* Setup L2 cache */ 60 /* Setup L2 cache */
@@ -98,10 +95,6 @@ void rv770_pcie_gart_disable(struct radeon_device *rdev)
98 u32 tmp; 95 u32 tmp;
99 int i; 96 int i;
100 97
101 /* Clear ptes*/
102 for (i = 0; i < rdev->gart.num_gpu_pages; i++)
103 r600_gart_clear_page(rdev, i);
104 r600_pcie_gart_tlb_flush(rdev);
105 /* Disable all tables */ 98 /* Disable all tables */
106 for (i = 0; i < 7; i++) 99 for (i = 0; i < 7; i++)
107 WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); 100 WREG32(VM_CONTEXT0_CNTL + (i * 4), 0);
@@ -120,6 +113,17 @@ void rv770_pcie_gart_disable(struct radeon_device *rdev)
120 WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); 113 WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp);
121 WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); 114 WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp);
122 WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); 115 WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp);
116 if (rdev->gart.table.vram.robj) {
117 radeon_object_kunmap(rdev->gart.table.vram.robj);
118 radeon_object_unpin(rdev->gart.table.vram.robj);
119 }
120}
121
122void rv770_pcie_gart_fini(struct radeon_device *rdev)
123{
124 rv770_pcie_gart_disable(rdev);
125 radeon_gart_table_vram_free(rdev);
126 radeon_gart_fini(rdev);
123} 127}
124 128
125 129
@@ -871,6 +875,7 @@ int rv770_suspend(struct radeon_device *rdev)
871{ 875{
872 /* FIXME: we should wait for ring to be empty */ 876 /* FIXME: we should wait for ring to be empty */
873 r700_cp_stop(rdev); 877 r700_cp_stop(rdev);
878 rv770_pcie_gart_disable(rdev);
874 return 0; 879 return 0;
875} 880}
876 881
@@ -944,6 +949,10 @@ int rv770_init(struct radeon_device *rdev)
944 } 949 }
945 } 950 }
946 951
952 r = r600_pcie_gart_init(rdev);
953 if (r)
954 return r;
955
947 r = rv770_resume(rdev); 956 r = rv770_resume(rdev);
948 if (r) { 957 if (r) {
949 if (rdev->flags & RADEON_IS_AGP) { 958 if (rdev->flags & RADEON_IS_AGP) {
@@ -976,9 +985,7 @@ void rv770_fini(struct radeon_device *rdev)
976{ 985{
977 r600_blit_fini(rdev); 986 r600_blit_fini(rdev);
978 radeon_ring_fini(rdev); 987 radeon_ring_fini(rdev);
979 rv770_pcie_gart_disable(rdev); 988 rv770_pcie_gart_fini(rdev);
980 radeon_gart_table_vram_free(rdev);
981 radeon_gart_fini(rdev);
982 radeon_gem_fini(rdev); 989 radeon_gem_fini(rdev);
983 radeon_fence_driver_fini(rdev); 990 radeon_fence_driver_fini(rdev);
984 radeon_clocks_fini(rdev); 991 radeon_clocks_fini(rdev);