Rev 2175 | Rev 3031 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2175 | Rev 2997 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * Authors: Dave Airlie |
24 | * Authors: Dave Airlie |
25 | * Alex Deucher |
25 | * Alex Deucher |
26 | * Jerome Glisse |
26 | * Jerome Glisse |
27 | */ |
27 | */ |
28 | //#include |
28 | //#include |
29 | - | ||
- | 29 | #include |
|
30 | #include |
30 | #include |
31 | #include |
31 | #include |
32 | #include |
32 | #include |
33 | #include "radeon_reg.h" |
33 | #include "radeon_reg.h" |
34 | #include "radeon.h" |
34 | #include "radeon.h" |
Line 53... | Line 53... | ||
53 | int radeon_dynpm = -1; |
53 | int radeon_dynpm = -1; |
54 | int radeon_audio = 1; |
54 | int radeon_audio = 1; |
55 | int radeon_hw_i2c = 0; |
55 | int radeon_hw_i2c = 0; |
56 | int radeon_pcie_gen2 = 0; |
56 | int radeon_pcie_gen2 = 0; |
57 | int radeon_disp_priority = 0; |
57 | int radeon_disp_priority = 0; |
- | 58 | int radeon_lockup_timeout = 10000; |
|
- | 59 | ||
Line 58... | Line 60... | ||
58 | 60 | ||
Line 59... | Line 61... | ||
59 | int irq_override = 0; |
61 | int irq_override = 0; |
Line 60... | Line 62... | ||
60 | 62 | ||
61 | 63 | ||
62 | extern display_t *rdisplay; |
64 | extern display_t *rdisplay; |
Line 63... | Line 65... | ||
63 | 65 | ||
64 | void parse_cmdline(char *cmdline, videomode_t *mode, char *log, int *kms); |
66 | void parse_cmdline(char *cmdline, videomode_t *mode, char *log, int *kms); |
65 | int init_display(struct radeon_device *rdev, videomode_t *mode); |
67 | int init_display(struct radeon_device *rdev, videomode_t *mode); |
Line 66... | Line 68... | ||
66 | int init_display_kms(struct radeon_device *rdev, videomode_t *mode); |
68 | int init_display_kms(struct radeon_device *rdev, videomode_t *mode); |
Line 130... | Line 132... | ||
130 | "SUMO2", |
132 | "SUMO2", |
131 | "BARTS", |
133 | "BARTS", |
132 | "TURKS", |
134 | "TURKS", |
133 | "CAICOS", |
135 | "CAICOS", |
134 | "CAYMAN", |
136 | "CAYMAN", |
- | 137 | "ARUBA", |
|
- | 138 | "TAHITI", |
|
- | 139 | "PITCAIRN", |
|
- | 140 | "VERDE", |
|
135 | "LAST", |
141 | "LAST", |
136 | }; |
142 | }; |
Line 137... | Line 143... | ||
137 | 143 | ||
- | 144 | /** |
|
- | 145 | * radeon_surface_init - Clear GPU surface registers. |
|
- | 146 | * |
|
- | 147 | * @rdev: radeon_device pointer |
|
138 | /* |
148 | * |
139 | * Clear GPU surface registers. |
149 | * Clear GPU surface registers (r1xx-r5xx). |
140 | */ |
150 | */ |
141 | void radeon_surface_init(struct radeon_device *rdev) |
151 | void radeon_surface_init(struct radeon_device *rdev) |
142 | { |
152 | { |
143 | /* FIXME: check this out */ |
153 | /* FIXME: check this out */ |
Line 153... | Line 163... | ||
153 | } |
163 | } |
Line 154... | Line 164... | ||
154 | 164 | ||
155 | /* |
165 | /* |
156 | * GPU scratch registers helpers function. |
166 | * GPU scratch registers helpers function. |
- | 167 | */ |
|
- | 168 | /** |
|
- | 169 | * radeon_scratch_init - Init scratch register driver information. |
|
- | 170 | * |
|
- | 171 | * @rdev: radeon_device pointer |
|
- | 172 | * |
|
- | 173 | * Init CP scratch register driver information (r1xx-r5xx) |
|
157 | */ |
174 | */ |
158 | void radeon_scratch_init(struct radeon_device *rdev) |
175 | void radeon_scratch_init(struct radeon_device *rdev) |
159 | { |
176 | { |
Line 160... | Line 177... | ||
160 | int i; |
177 | int i; |
Line 170... | Line 187... | ||
170 | rdev->scratch.free[i] = true; |
187 | rdev->scratch.free[i] = true; |
171 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); |
188 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); |
172 | } |
189 | } |
173 | } |
190 | } |
Line -... | Line 191... | ||
- | 191 | ||
- | 192 | /** |
|
- | 193 | * radeon_scratch_get - Allocate a scratch register |
|
- | 194 | * |
|
- | 195 | * @rdev: radeon_device pointer |
|
- | 196 | * @reg: scratch register mmio offset |
|
- | 197 | * |
|
- | 198 | * Allocate a CP scratch register for use by the driver (all asics). |
|
- | 199 | * Returns 0 on success or -EINVAL on failure. |
|
174 | 200 | */ |
|
175 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg) |
201 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg) |
176 | { |
202 | { |
Line 177... | Line 203... | ||
177 | int i; |
203 | int i; |
Line 184... | Line 210... | ||
184 | } |
210 | } |
185 | } |
211 | } |
186 | return -EINVAL; |
212 | return -EINVAL; |
187 | } |
213 | } |
Line -... | Line 214... | ||
- | 214 | ||
- | 215 | /** |
|
- | 216 | * radeon_scratch_free - Free a scratch register |
|
- | 217 | * |
|
- | 218 | * @rdev: radeon_device pointer |
|
- | 219 | * @reg: scratch register mmio offset |
|
- | 220 | * |
|
- | 221 | * Free a CP scratch register allocated for use by the driver (all asics) |
|
188 | 222 | */ |
|
189 | void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg) |
223 | void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg) |
190 | { |
224 | { |
Line 191... | Line 225... | ||
191 | int i; |
225 | int i; |
Line 196... | Line 230... | ||
196 | return; |
230 | return; |
197 | } |
231 | } |
198 | } |
232 | } |
199 | } |
233 | } |
Line -... | Line 234... | ||
- | 234 | ||
- | 235 | /* |
|
- | 236 | * radeon_wb_*() |
|
- | 237 | * Writeback is the the method by which the the GPU updates special pages |
|
- | 238 | * in memory with the status of certain GPU events (fences, ring pointers, |
|
- | 239 | * etc.). |
|
- | 240 | */ |
|
- | 241 | ||
- | 242 | /** |
|
- | 243 | * radeon_wb_disable - Disable Writeback |
|
- | 244 | * |
|
- | 245 | * @rdev: radeon_device pointer |
|
- | 246 | * |
|
- | 247 | * Disables Writeback (all asics). Used for suspend. |
|
200 | 248 | */ |
|
201 | void radeon_wb_disable(struct radeon_device *rdev) |
249 | void radeon_wb_disable(struct radeon_device *rdev) |
202 | { |
250 | { |
Line 203... | Line 251... | ||
203 | int r; |
251 | int r; |
Line 211... | Line 259... | ||
211 | radeon_bo_unreserve(rdev->wb.wb_obj); |
259 | radeon_bo_unreserve(rdev->wb.wb_obj); |
212 | } |
260 | } |
213 | rdev->wb.enabled = false; |
261 | rdev->wb.enabled = false; |
214 | } |
262 | } |
Line -... | Line 263... | ||
- | 263 | ||
- | 264 | /** |
|
- | 265 | * radeon_wb_fini - Disable Writeback and free memory |
|
- | 266 | * |
|
- | 267 | * @rdev: radeon_device pointer |
|
- | 268 | * |
|
- | 269 | * Disables Writeback and frees the Writeback memory (all asics). |
|
- | 270 | * Used at driver shutdown. |
|
215 | 271 | */ |
|
216 | void radeon_wb_fini(struct radeon_device *rdev) |
272 | void radeon_wb_fini(struct radeon_device *rdev) |
217 | { |
273 | { |
218 | radeon_wb_disable(rdev); |
274 | radeon_wb_disable(rdev); |
219 | if (rdev->wb.wb_obj) { |
275 | if (rdev->wb.wb_obj) { |
220 | radeon_bo_unref(&rdev->wb.wb_obj); |
276 | radeon_bo_unref(&rdev->wb.wb_obj); |
221 | rdev->wb.wb = NULL; |
277 | rdev->wb.wb = NULL; |
222 | rdev->wb.wb_obj = NULL; |
278 | rdev->wb.wb_obj = NULL; |
223 | } |
279 | } |
Line -... | Line 280... | ||
- | 280 | } |
|
- | 281 | ||
- | 282 | /** |
|
- | 283 | * radeon_wb_init- Init Writeback driver info and allocate memory |
|
- | 284 | * |
|
- | 285 | * @rdev: radeon_device pointer |
|
- | 286 | * |
|
- | 287 | * Disables Writeback and frees the Writeback memory (all asics). |
|
- | 288 | * Used at driver startup. |
|
224 | } |
289 | * Returns 0 on success or an -error on failure. |
225 | 290 | */ |
|
226 | int radeon_wb_init(struct radeon_device *rdev) |
291 | int radeon_wb_init(struct radeon_device *rdev) |
Line 227... | Line 292... | ||
227 | { |
292 | { |
228 | int r; |
293 | int r; |
229 | 294 | ||
230 | if (rdev->wb.wb_obj == NULL) { |
295 | if (rdev->wb.wb_obj == NULL) { |
231 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, |
296 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, |
232 | RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj); |
297 | RADEON_GEM_DOMAIN_GTT, NULL, &rdev->wb.wb_obj); |
233 | if (r) { |
298 | if (r) { |
234 | dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); |
299 | dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); |
Line 259... | Line 324... | ||
259 | /* clear wb memory */ |
324 | /* clear wb memory */ |
260 | memset((char *)rdev->wb.wb, 0, RADEON_GPU_PAGE_SIZE); |
325 | memset((char *)rdev->wb.wb, 0, RADEON_GPU_PAGE_SIZE); |
261 | /* disable event_write fences */ |
326 | /* disable event_write fences */ |
262 | rdev->wb.use_event = false; |
327 | rdev->wb.use_event = false; |
263 | /* disabled via module param */ |
328 | /* disabled via module param */ |
264 | if (radeon_no_wb == 1) |
329 | if (radeon_no_wb == 1) { |
265 | rdev->wb.enabled = false; |
330 | rdev->wb.enabled = false; |
266 | else { |
331 | } else { |
- | 332 | if (rdev->flags & RADEON_IS_AGP) { |
|
267 | /* often unreliable on AGP */ |
333 | /* often unreliable on AGP */ |
- | 334 | rdev->wb.enabled = false; |
|
268 | // if (rdev->flags & RADEON_IS_AGP) { |
335 | } else if (rdev->family < CHIP_R300) { |
- | 336 | /* often unreliable on pre-r300 */ |
|
269 | // rdev->wb.enabled = false; |
337 | rdev->wb.enabled = false; |
270 | // } else { |
338 | } else { |
271 | rdev->wb.enabled = true; |
339 | rdev->wb.enabled = true; |
272 | /* event_write fences are only available on r600+ */ |
340 | /* event_write fences are only available on r600+ */ |
273 | if (rdev->family >= CHIP_R600) |
341 | if (rdev->family >= CHIP_R600) { |
274 | rdev->wb.use_event = true; |
342 | rdev->wb.use_event = true; |
275 | // } |
- | |
276 | } |
343 | } |
- | 344 | } |
|
- | 345 | } |
|
277 | /* always use writeback/events on NI */ |
346 | /* always use writeback/events on NI, APUs */ |
278 | if (ASIC_IS_DCE5(rdev)) { |
347 | if (rdev->family >= CHIP_PALM) { |
279 | rdev->wb.enabled = true; |
348 | rdev->wb.enabled = true; |
280 | rdev->wb.use_event = true; |
349 | rdev->wb.use_event = true; |
281 | } |
350 | } |
Line 282... | Line 351... | ||
282 | 351 | ||
Line 326... | Line 395... | ||
326 | * |
395 | * |
327 | * FIXME: when reducing VRAM size align new size on power of 2. |
396 | * FIXME: when reducing VRAM size align new size on power of 2. |
328 | */ |
397 | */ |
329 | void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base) |
398 | void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base) |
330 | { |
399 | { |
- | 400 | uint64_t limit = (uint64_t)radeon_vram_limit << 20; |
|
- | 401 | ||
331 | mc->vram_start = base; |
402 | mc->vram_start = base; |
332 | if (mc->mc_vram_size > (0xFFFFFFFF - base + 1)) { |
403 | if (mc->mc_vram_size > (0xFFFFFFFF - base + 1)) { |
333 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
404 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
334 | mc->real_vram_size = mc->aper_size; |
405 | mc->real_vram_size = mc->aper_size; |
335 | mc->mc_vram_size = mc->aper_size; |
406 | mc->mc_vram_size = mc->aper_size; |
Line 339... | Line 410... | ||
339 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
410 | dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); |
340 | mc->real_vram_size = mc->aper_size; |
411 | mc->real_vram_size = mc->aper_size; |
341 | mc->mc_vram_size = mc->aper_size; |
412 | mc->mc_vram_size = mc->aper_size; |
342 | } |
413 | } |
343 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
414 | mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; |
- | 415 | if (limit && limit < mc->real_vram_size) |
|
- | 416 | mc->real_vram_size = limit; |
|
344 | dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n", |
417 | dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n", |
345 | mc->mc_vram_size >> 20, mc->vram_start, |
418 | mc->mc_vram_size >> 20, mc->vram_start, |
346 | mc->vram_end, mc->real_vram_size >> 20); |
419 | mc->vram_end, mc->real_vram_size >> 20); |
347 | } |
420 | } |
Line 383... | Line 456... | ||
383 | } |
456 | } |
Line 384... | Line 457... | ||
384 | 457 | ||
385 | /* |
458 | /* |
386 | * GPU helpers function. |
459 | * GPU helpers function. |
- | 460 | */ |
|
- | 461 | /** |
|
- | 462 | * radeon_card_posted - check if the hw has already been initialized |
|
- | 463 | * |
|
- | 464 | * @rdev: radeon_device pointer |
|
- | 465 | * |
|
- | 466 | * Check if the asic has been initialized (all asics). |
|
- | 467 | * Used at driver startup. |
|
- | 468 | * Returns true if initialized or false if not. |
|
387 | */ |
469 | */ |
388 | bool radeon_card_posted(struct radeon_device *rdev) |
470 | bool radeon_card_posted(struct radeon_device *rdev) |
389 | { |
471 | { |
Line 390... | Line 472... | ||
390 | uint32_t reg; |
472 | uint32_t reg; |
Line 429... | Line 511... | ||
429 | 511 | ||
Line 430... | Line 512... | ||
430 | return false; |
512 | return false; |
Line -... | Line 513... | ||
- | 513 | ||
- | 514 | } |
|
- | 515 | ||
- | 516 | /** |
|
- | 517 | * radeon_update_bandwidth_info - update display bandwidth params |
|
- | 518 | * |
|
- | 519 | * @rdev: radeon_device pointer |
|
- | 520 | * |
|
431 | 521 | * Used when sclk/mclk are switched or display modes are set. |
|
432 | } |
522 | * params are used to calculate display watermarks (all asics) |
433 | 523 | */ |
|
434 | void radeon_update_bandwidth_info(struct radeon_device *rdev) |
524 | void radeon_update_bandwidth_info(struct radeon_device *rdev) |
435 | { |
525 | { |
Line 449... | Line 539... | ||
449 | /* core_bandwidth = sclk(Mhz) * 16 */ |
539 | /* core_bandwidth = sclk(Mhz) * 16 */ |
450 | rdev->pm.core_bandwidth.full = dfixed_div(rdev->pm.sclk, a); |
540 | rdev->pm.core_bandwidth.full = dfixed_div(rdev->pm.sclk, a); |
451 | } |
541 | } |
452 | } |
542 | } |
Line -... | Line 543... | ||
- | 543 | ||
- | 544 | /** |
|
- | 545 | * radeon_boot_test_post_card - check and possibly initialize the hw |
|
- | 546 | * |
|
- | 547 | * @rdev: radeon_device pointer |
|
- | 548 | * |
|
- | 549 | * Check if the asic is initialized and if not, attempt to initialize |
|
- | 550 | * it (all asics). |
|
- | 551 | * Returns true if initialized or false if not. |
|
453 | 552 | */ |
|
454 | bool radeon_boot_test_post_card(struct radeon_device *rdev) |
553 | bool radeon_boot_test_post_card(struct radeon_device *rdev) |
455 | { |
554 | { |
456 | if (radeon_card_posted(rdev)) |
555 | if (radeon_card_posted(rdev)) |
Line 467... | Line 566... | ||
467 | dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); |
566 | dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); |
468 | return false; |
567 | return false; |
469 | } |
568 | } |
470 | } |
569 | } |
Line -... | Line 570... | ||
- | 570 | ||
- | 571 | /** |
|
- | 572 | * radeon_dummy_page_init - init dummy page used by the driver |
|
- | 573 | * |
|
- | 574 | * @rdev: radeon_device pointer |
|
- | 575 | * |
|
- | 576 | * Allocate the dummy page used by the driver (all asics). |
|
- | 577 | * This dummy page is used by the driver as a filler for gart entries |
|
- | 578 | * when pages are taken out of the GART |
|
- | 579 | * Returns 0 on sucess, -ENOMEM on failure. |
|
471 | 580 | */ |
|
472 | int radeon_dummy_page_init(struct radeon_device *rdev) |
581 | int radeon_dummy_page_init(struct radeon_device *rdev) |
473 | { |
582 | { |
474 | if (rdev->dummy_page.page) |
583 | if (rdev->dummy_page.page) |
475 | return 0; |
584 | return 0; |
476 | rdev->dummy_page.page = AllocPage(); |
585 | rdev->dummy_page.page = (void*)AllocPage(); |
477 | if (rdev->dummy_page.page == NULL) |
586 | if (rdev->dummy_page.page == NULL) |
478 | return -ENOMEM; |
587 | return -ENOMEM; |
479 | rdev->dummy_page.addr = MapIoMem(rdev->dummy_page.page, 4096, 5); |
588 | rdev->dummy_page.addr = MapIoMem((addr_t)rdev->dummy_page.page, 4096, 3); |
480 | if (!rdev->dummy_page.addr) { |
589 | if (!rdev->dummy_page.addr) { |
481 | // __free_page(rdev->dummy_page.page); |
590 | // __free_page(rdev->dummy_page.page); |
482 | rdev->dummy_page.page = NULL; |
591 | rdev->dummy_page.page = NULL; |
483 | return -ENOMEM; |
592 | return -ENOMEM; |
484 | } |
593 | } |
485 | return 0; |
594 | return 0; |
Line -... | Line 595... | ||
- | 595 | } |
|
- | 596 | ||
- | 597 | /** |
|
- | 598 | * radeon_dummy_page_fini - free dummy page used by the driver |
|
- | 599 | * |
|
- | 600 | * @rdev: radeon_device pointer |
|
- | 601 | * |
|
486 | } |
602 | * Frees the dummy page used by the driver (all asics). |
487 | 603 | */ |
|
488 | void radeon_dummy_page_fini(struct radeon_device *rdev) |
604 | void radeon_dummy_page_fini(struct radeon_device *rdev) |
489 | { |
605 | { |
490 | if (rdev->dummy_page.page == NULL) |
606 | if (rdev->dummy_page.page == NULL) |
491 | return; |
607 | return; |
492 | KernelFree(rdev->dummy_page.addr); |
608 | KernelFree((void*)rdev->dummy_page.addr); |
Line 493... | Line 609... | ||
493 | rdev->dummy_page.page = NULL; |
609 | rdev->dummy_page.page = NULL; |
- | 610 | } |
|
- | 611 | ||
- | 612 | ||
- | 613 | /* ATOM accessor methods */ |
|
- | 614 | /* |
|
- | 615 | * ATOM is an interpreted byte code stored in tables in the vbios. The |
|
- | 616 | * driver registers callbacks to access registers and the interpreter |
|
- | 617 | * in the driver parses the tables and executes then to program specific |
|
- | 618 | * actions (set display modes, asic init, etc.). See radeon_atombios.c, |
|
- | 619 | * atombios.h, and atom.c |
|
- | 620 | */ |
|
- | 621 | ||
- | 622 | /** |
|
- | 623 | * cail_pll_read - read PLL register |
|
- | 624 | * |
|
- | 625 | * @info: atom card_info pointer |
|
- | 626 | * @reg: PLL register offset |
|
494 | } |
627 | * |
495 | 628 | * Provides a PLL register accessor for the atom interpreter (r4xx+). |
|
496 | 629 | * Returns the value of the PLL register. |
|
497 | /* ATOM accessor methods */ |
630 | */ |
Line 498... | Line 631... | ||
498 | static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) |
631 | static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) |
499 | { |
632 | { |
500 | struct radeon_device *rdev = info->dev->dev_private; |
633 | struct radeon_device *rdev = info->dev->dev_private; |
Line -... | Line 634... | ||
- | 634 | uint32_t r; |
|
- | 635 | ||
- | 636 | r = rdev->pll_rreg(rdev, reg); |
|
- | 637 | return r; |
|
- | 638 | } |
|
- | 639 | ||
- | 640 | /** |
|
- | 641 | * cail_pll_write - write PLL register |
|
- | 642 | * |
|
501 | uint32_t r; |
643 | * @info: atom card_info pointer |
502 | 644 | * @reg: PLL register offset |
|
503 | r = rdev->pll_rreg(rdev, reg); |
645 | * @val: value to write to the pll register |
Line 504... | Line 646... | ||
504 | return r; |
646 | * |
505 | } |
647 | * Provides a PLL register accessor for the atom interpreter (r4xx+). |
Line -... | Line 648... | ||
- | 648 | */ |
|
- | 649 | static void cail_pll_write(struct card_info *info, uint32_t reg, uint32_t val) |
|
- | 650 | { |
|
- | 651 | struct radeon_device *rdev = info->dev->dev_private; |
|
- | 652 | ||
- | 653 | rdev->pll_wreg(rdev, reg, val); |
|
- | 654 | } |
|
- | 655 | ||
- | 656 | /** |
|
506 | 657 | * cail_mc_read - read MC (Memory Controller) register |
|
507 | static void cail_pll_write(struct card_info *info, uint32_t reg, uint32_t val) |
658 | * |
508 | { |
659 | * @info: atom card_info pointer |
509 | struct radeon_device *rdev = info->dev->dev_private; |
660 | * @reg: MC register offset |
Line 510... | Line 661... | ||
510 | 661 | * |
|
511 | rdev->pll_wreg(rdev, reg, val); |
662 | * Provides an MC register accessor for the atom interpreter (r4xx+). |
512 | } |
663 | * Returns the value of the MC register. |
Line -... | Line 664... | ||
- | 664 | */ |
|
- | 665 | static uint32_t cail_mc_read(struct card_info *info, uint32_t reg) |
|
- | 666 | { |
|
- | 667 | struct radeon_device *rdev = info->dev->dev_private; |
|
- | 668 | uint32_t r; |
|
- | 669 | ||
- | 670 | r = rdev->mc_rreg(rdev, reg); |
|
- | 671 | return r; |
|
- | 672 | } |
|
513 | 673 | ||
514 | static uint32_t cail_mc_read(struct card_info *info, uint32_t reg) |
674 | /** |
515 | { |
675 | * cail_mc_write - write MC (Memory Controller) register |
Line 516... | Line 676... | ||
516 | struct radeon_device *rdev = info->dev->dev_private; |
676 | * |
517 | uint32_t r; |
677 | * @info: atom card_info pointer |
Line -... | Line 678... | ||
- | 678 | * @reg: MC register offset |
|
- | 679 | * @val: value to write to the pll register |
|
- | 680 | * |
|
- | 681 | * Provides a MC register accessor for the atom interpreter (r4xx+). |
|
- | 682 | */ |
|
- | 683 | static void cail_mc_write(struct card_info *info, uint32_t reg, uint32_t val) |
|
- | 684 | { |
|
- | 685 | struct radeon_device *rdev = info->dev->dev_private; |
|
- | 686 | ||
518 | 687 | rdev->mc_wreg(rdev, reg, val); |
|
519 | r = rdev->mc_rreg(rdev, reg); |
688 | } |
520 | return r; |
689 | |
Line 521... | Line 690... | ||
521 | } |
690 | /** |
522 | 691 | * cail_reg_write - write MMIO register |
|
Line -... | Line 692... | ||
- | 692 | * |
|
- | 693 | * @info: atom card_info pointer |
|
- | 694 | * @reg: MMIO register offset |
|
- | 695 | * @val: value to write to the pll register |
|
- | 696 | * |
|
- | 697 | * Provides a MMIO register accessor for the atom interpreter (r4xx+). |
|
- | 698 | */ |
|
- | 699 | static void cail_reg_write(struct card_info *info, uint32_t reg, uint32_t val) |
|
- | 700 | { |
|
523 | static void cail_mc_write(struct card_info *info, uint32_t reg, uint32_t val) |
701 | struct radeon_device *rdev = info->dev->dev_private; |
524 | { |
702 | |
525 | struct radeon_device *rdev = info->dev->dev_private; |
703 | WREG32(reg*4, val); |
526 | 704 | } |
|
Line 527... | Line 705... | ||
527 | rdev->mc_wreg(rdev, reg, val); |
705 | |
528 | } |
706 | /** |
529 | 707 | * cail_reg_read - read MMIO register |
|
Line -... | Line 708... | ||
- | 708 | * |
|
- | 709 | * @info: atom card_info pointer |
|
- | 710 | * @reg: MMIO register offset |
|
- | 711 | * |
|
- | 712 | * Provides an MMIO register accessor for the atom interpreter (r4xx+). |
|
- | 713 | * Returns the value of the MMIO register. |
|
- | 714 | */ |
|
- | 715 | static uint32_t cail_reg_read(struct card_info *info, uint32_t reg) |
|
- | 716 | { |
|
530 | static void cail_reg_write(struct card_info *info, uint32_t reg, uint32_t val) |
717 | struct radeon_device *rdev = info->dev->dev_private; |
531 | { |
718 | uint32_t r; |
532 | struct radeon_device *rdev = info->dev->dev_private; |
719 | |
Line 533... | Line 720... | ||
533 | 720 | r = RREG32(reg*4); |
|
534 | WREG32(reg*4, val); |
721 | return r; |
Line -... | Line 722... | ||
- | 722 | } |
|
- | 723 | ||
- | 724 | /** |
|
- | 725 | * cail_ioreg_write - write IO register |
|
- | 726 | * |
|
- | 727 | * @info: atom card_info pointer |
|
- | 728 | * @reg: IO register offset |
|
- | 729 | * @val: value to write to the pll register |
|
- | 730 | * |
|
535 | } |
731 | * Provides a IO register accessor for the atom interpreter (r4xx+). |
536 | 732 | */ |
|
537 | static uint32_t cail_reg_read(struct card_info *info, uint32_t reg) |
733 | static void cail_ioreg_write(struct card_info *info, uint32_t reg, uint32_t val) |
538 | { |
734 | { |
Line 539... | Line 735... | ||
539 | struct radeon_device *rdev = info->dev->dev_private; |
735 | struct radeon_device *rdev = info->dev->dev_private; |
540 | uint32_t r; |
736 | |
541 | 737 | WREG32_IO(reg*4, val); |
|
Line -... | Line 738... | ||
- | 738 | } |
|
- | 739 | ||
- | 740 | /** |
|
- | 741 | * cail_ioreg_read - read IO register |
|
- | 742 | * |
|
- | 743 | * @info: atom card_info pointer |
|
- | 744 | * @reg: IO register offset |
|
- | 745 | * |
|
- | 746 | * Provides an IO register accessor for the atom interpreter (r4xx+). |
|
- | 747 | * Returns the value of the IO register. |
|
542 | r = RREG32(reg*4); |
748 | */ |
543 | return r; |
749 | static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg) |
544 | } |
750 | { |
545 | 751 | struct radeon_device *rdev = info->dev->dev_private; |
|
Line 590... | Line 796... | ||
590 | radeon_atom_initialize_bios_scratch_regs(rdev->ddev); |
796 | radeon_atom_initialize_bios_scratch_regs(rdev->ddev); |
591 | atom_allocate_fb_scratch(rdev->mode_info.atom_context); |
797 | atom_allocate_fb_scratch(rdev->mode_info.atom_context); |
592 | return 0; |
798 | return 0; |
593 | } |
799 | } |
Line -... | Line 800... | ||
- | 800 | ||
- | 801 | /** |
|
- | 802 | * radeon_atombios_fini - free the driver info and callbacks for atombios |
|
- | 803 | * |
|
- | 804 | * @rdev: radeon_device pointer |
|
- | 805 | * |
|
- | 806 | * Frees the driver info and register access callbacks for the ATOM |
|
- | 807 | * interpreter (r4xx+). |
|
- | 808 | * Called at driver shutdown. |
|
594 | 809 | */ |
|
595 | void radeon_atombios_fini(struct radeon_device *rdev) |
810 | void radeon_atombios_fini(struct radeon_device *rdev) |
596 | { |
811 | { |
597 | if (rdev->mode_info.atom_context) { |
812 | if (rdev->mode_info.atom_context) { |
598 | kfree(rdev->mode_info.atom_context->scratch); |
813 | kfree(rdev->mode_info.atom_context->scratch); |
599 | kfree(rdev->mode_info.atom_context); |
814 | kfree(rdev->mode_info.atom_context); |
600 | } |
815 | } |
601 | kfree(rdev->mode_info.atom_card_info); |
816 | kfree(rdev->mode_info.atom_card_info); |
Line -... | Line 817... | ||
- | 817 | } |
|
- | 818 | ||
- | 819 | /* COMBIOS */ |
|
- | 820 | /* |
|
- | 821 | * COMBIOS is the bios format prior to ATOM. It provides |
|
- | 822 | * command tables similar to ATOM, but doesn't have a unified |
|
- | 823 | * parser. See radeon_combios.c |
|
- | 824 | */ |
|
- | 825 | ||
- | 826 | /** |
|
- | 827 | * radeon_combios_init - init the driver info for combios |
|
- | 828 | * |
|
- | 829 | * @rdev: radeon_device pointer |
|
- | 830 | * |
|
- | 831 | * Initializes the driver info for combios (r1xx-r3xx). |
|
- | 832 | * Returns 0 on sucess. |
|
602 | } |
833 | * Called at driver startup. |
603 | 834 | */ |
|
604 | int radeon_combios_init(struct radeon_device *rdev) |
835 | int radeon_combios_init(struct radeon_device *rdev) |
605 | { |
836 | { |
606 | radeon_combios_initialize_bios_scratch_regs(rdev->ddev); |
837 | radeon_combios_initialize_bios_scratch_regs(rdev->ddev); |
Line -... | Line 838... | ||
- | 838 | return 0; |
|
- | 839 | } |
|
- | 840 | ||
- | 841 | /** |
|
- | 842 | * radeon_combios_fini - free the driver info for combios |
|
- | 843 | * |
|
- | 844 | * @rdev: radeon_device pointer |
|
- | 845 | * |
|
607 | return 0; |
846 | * Frees the driver info for combios (r1xx-r3xx). |
608 | } |
847 | * Called at driver shutdown. |
609 | 848 | */ |
|
Line 610... | Line 849... | ||
610 | void radeon_combios_fini(struct radeon_device *rdev) |
849 | void radeon_combios_fini(struct radeon_device *rdev) |
- | 850 | { |
|
- | 851 | } |
|
- | 852 | ||
- | 853 | /* if we get transitioned to only one device, take VGA back */ |
|
- | 854 | /** |
|
- | 855 | * radeon_vga_set_decode - enable/disable vga decode |
|
- | 856 | * |
|
- | 857 | * @cookie: radeon_device pointer |
|
- | 858 | * @state: enable/disable vga decode |
|
611 | { |
859 | * |
612 | } |
860 | * Enable/disable vga decode (all asics). |
613 | 861 | * Returns VGA resource flags. |
|
614 | /* if we get transitioned to only one device, tak VGA back */ |
862 | */ |
615 | static unsigned int radeon_vga_set_decode(void *cookie, bool state) |
863 | static unsigned int radeon_vga_set_decode(void *cookie, bool state) |
Line 621... | Line 869... | ||
621 | VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
869 | VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
622 | else |
870 | else |
623 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
871 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
624 | } |
872 | } |
Line -... | Line 873... | ||
- | 873 | ||
- | 874 | /** |
|
- | 875 | * radeon_check_pot_argument - check that argument is a power of two |
|
- | 876 | * |
|
- | 877 | * @arg: value to check |
|
- | 878 | * |
|
- | 879 | * Validates that a certain argument is a power of two (all asics). |
|
- | 880 | * Returns true if argument is valid. |
|
- | 881 | */ |
|
- | 882 | static bool radeon_check_pot_argument(int arg) |
|
- | 883 | { |
|
- | 884 | return (arg & (arg - 1)) == 0; |
|
- | 885 | } |
|
- | 886 | ||
- | 887 | /** |
|
- | 888 | * radeon_check_arguments - validate module params |
|
- | 889 | * |
|
- | 890 | * @rdev: radeon_device pointer |
|
- | 891 | * |
|
- | 892 | * Validates certain module parameters and updates |
|
- | 893 | * the associated values used by the driver (all asics). |
|
625 | 894 | */ |
|
626 | void radeon_check_arguments(struct radeon_device *rdev) |
895 | static void radeon_check_arguments(struct radeon_device *rdev) |
627 | { |
896 | { |
628 | /* vramlimit must be a power of two */ |
897 | /* vramlimit must be a power of two */ |
629 | switch (radeon_vram_limit) { |
- | |
630 | case 0: |
- | |
631 | case 4: |
- | |
632 | case 8: |
- | |
633 | case 16: |
- | |
634 | case 32: |
- | |
635 | case 64: |
- | |
636 | case 128: |
- | |
637 | case 256: |
- | |
638 | case 512: |
- | |
639 | case 1024: |
- | |
640 | case 2048: |
- | |
641 | case 4096: |
- | |
642 | break; |
- | |
643 | default: |
898 | if (!radeon_check_pot_argument(radeon_vram_limit)) { |
644 | dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n", |
899 | dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n", |
645 | radeon_vram_limit); |
900 | radeon_vram_limit); |
646 | radeon_vram_limit = 0; |
- | |
647 | break; |
901 | radeon_vram_limit = 0; |
648 | } |
- | |
- | 902 | } |
|
649 | radeon_vram_limit = radeon_vram_limit << 20; |
903 | |
650 | /* gtt size must be power of two and greater or equal to 32M */ |
904 | /* gtt size must be power of two and greater or equal to 32M */ |
651 | switch (radeon_gart_size) { |
- | |
652 | case 4: |
- | |
653 | case 8: |
- | |
654 | case 16: |
905 | if (radeon_gart_size < 32) { |
655 | dev_warn(rdev->dev, "gart size (%d) too small forcing to 512M\n", |
906 | dev_warn(rdev->dev, "gart size (%d) too small forcing to 512M\n", |
656 | radeon_gart_size); |
907 | radeon_gart_size); |
657 | radeon_gart_size = 512; |
- | |
658 | break; |
- | |
659 | case 32: |
- | |
660 | case 64: |
- | |
661 | case 128: |
- | |
662 | case 256: |
- | |
663 | case 512: |
- | |
664 | case 1024: |
- | |
665 | case 2048: |
- | |
666 | case 4096: |
908 | radeon_gart_size = 512; |
667 | break; |
909 | |
668 | default: |
910 | } else if (!radeon_check_pot_argument(radeon_gart_size)) { |
669 | dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n", |
911 | dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n", |
670 | radeon_gart_size); |
912 | radeon_gart_size); |
671 | radeon_gart_size = 512; |
- | |
672 | break; |
913 | radeon_gart_size = 512; |
673 | } |
914 | } |
- | 915 | rdev->mc.gtt_size = (uint64_t)radeon_gart_size << 20; |
|
674 | rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; |
916 | |
675 | /* AGP mode can only be -1, 1, 2, 4, 8 */ |
917 | /* AGP mode can only be -1, 1, 2, 4, 8 */ |
676 | switch (radeon_agpmode) { |
918 | switch (radeon_agpmode) { |
677 | case -1: |
919 | case -1: |
678 | case 0: |
920 | case 0: |
Line 703... | Line 945... | ||
703 | rdev->flags = flags; |
945 | rdev->flags = flags; |
704 | rdev->family = flags & RADEON_FAMILY_MASK; |
946 | rdev->family = flags & RADEON_FAMILY_MASK; |
705 | rdev->is_atom_bios = false; |
947 | rdev->is_atom_bios = false; |
706 | rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT; |
948 | rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT; |
707 | rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; |
949 | rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; |
708 | rdev->gpu_lockup = false; |
- | |
709 | rdev->accel_working = false; |
950 | rdev->accel_working = false; |
- | 951 | /* set up ring ids */ |
|
- | 952 | for (i = 0; i < RADEON_NUM_RINGS; i++) { |
|
- | 953 | rdev->ring[i].idx = i; |
|
- | 954 | } |
|
Line 710... | Line 955... | ||
710 | 955 | ||
711 | DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X).\n", |
956 | DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X).\n", |
- | 957 | radeon_family_name[rdev->family], pdev->vendor, pdev->device, |
|
Line 712... | Line 958... | ||
712 | radeon_family_name[rdev->family], pdev->vendor, pdev->device); |
958 | pdev->subsystem_vendor, pdev->subsystem_device); |
713 | 959 | ||
714 | /* mutex initialization are all done here so we |
- | |
715 | * can recall function without having locking issues */ |
- | |
716 | mutex_init(&rdev->cs_mutex); |
960 | /* mutex initialization are all done here so we |
717 | mutex_init(&rdev->ib_pool.mutex); |
961 | * can recall function without having locking issues */ |
718 | mutex_init(&rdev->cp.mutex); |
- | |
719 | mutex_init(&rdev->dc_hw_i2c_mutex); |
962 | mutex_init(&rdev->ring_lock); |
720 | if (rdev->family >= CHIP_R600) |
963 | mutex_init(&rdev->dc_hw_i2c_mutex); |
721 | spin_lock_init(&rdev->ih.lock); |
964 | atomic_set(&rdev->ih.lock, 0); |
722 | mutex_init(&rdev->gem.mutex); |
965 | mutex_init(&rdev->gem.mutex); |
- | 966 | mutex_init(&rdev->pm.mutex); |
|
- | 967 | mutex_init(&rdev->gpu_clock_mutex); |
|
- | 968 | init_rwsem(&rdev->pm.mclk_lock); |
|
- | 969 | init_rwsem(&rdev->exclusive_lock); |
|
- | 970 | init_waitqueue_head(&rdev->irq.vblank_queue); |
|
- | 971 | r = radeon_gem_init(rdev); |
|
- | 972 | if (r) |
|
723 | mutex_init(&rdev->pm.mutex); |
973 | return r; |
- | 974 | /* initialize vm here */ |
|
- | 975 | mutex_init(&rdev->vm_manager.lock); |
|
- | 976 | /* Adjust VM size here. |
|
- | 977 | * Currently set to 4GB ((1 << 20) 4k pages). |
|
- | 978 | * Max GPUVM size for cayman and SI is 40 bits. |
|
724 | mutex_init(&rdev->vram_mutex); |
979 | */ |
Line 725... | Line 980... | ||
725 | rwlock_init(&rdev->fence_drv.lock); |
980 | rdev->vm_manager.max_pfn = 1 << 20; |
726 | INIT_LIST_HEAD(&rdev->gem.objects); |
981 | INIT_LIST_HEAD(&rdev->vm_manager.lru_vm); |
727 | 982 | ||
728 | /* Set asic functions */ |
983 | /* Set asic functions */ |
Line 743... | Line 998... | ||
743 | radeon_agp_disable(rdev); |
998 | radeon_agp_disable(rdev); |
744 | } |
999 | } |
Line 745... | Line 1000... | ||
745 | 1000 | ||
746 | /* set DMA mask + need_dma32 flags. |
1001 | /* set DMA mask + need_dma32 flags. |
747 | * PCIE - can handle 40-bits. |
1002 | * PCIE - can handle 40-bits. |
748 | * IGP - can handle 40-bits (in theory) |
1003 | * IGP - can handle 40-bits |
749 | * AGP - generally dma32 is safest |
1004 | * AGP - generally dma32 is safest |
750 | * PCI - only dma32 |
1005 | * PCI - dma32 for legacy pci gart, 40 bits on newer asics |
751 | */ |
1006 | */ |
752 | rdev->need_dma32 = false; |
1007 | rdev->need_dma32 = false; |
753 | if (rdev->flags & RADEON_IS_AGP) |
1008 | if (rdev->flags & RADEON_IS_AGP) |
754 | rdev->need_dma32 = true; |
1009 | rdev->need_dma32 = true; |
- | 1010 | if ((rdev->flags & RADEON_IS_PCI) && |
|
755 | if (rdev->flags & RADEON_IS_PCI) |
1011 | (rdev->family <= CHIP_RS740)) |
Line 756... | Line 1012... | ||
756 | rdev->need_dma32 = true; |
1012 | rdev->need_dma32 = true; |
757 | 1013 | ||
758 | dma_bits = rdev->need_dma32 ? 32 : 40; |
1014 | dma_bits = rdev->need_dma32 ? 32 : 40; |
759 | r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits)); |
1015 | r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits)); |
- | 1016 | if (r) { |
|
760 | if (r) { |
1017 | rdev->need_dma32 = true; |
761 | rdev->need_dma32 = true; |
1018 | dma_bits = 32; |
Line 762... | Line 1019... | ||
762 | printk(KERN_WARNING "radeon: No suitable DMA available.\n"); |
1019 | printk(KERN_WARNING "radeon: No suitable DMA available.\n"); |
763 | } |
1020 | } |
764 | 1021 | ||
765 | /* Registers mapping */ |
1022 | /* Registers mapping */ |
766 | /* TODO: block userspace mapping of io register */ |
- | |
767 | rdev->rmmio_base = pci_resource_start(rdev->pdev, 2); |
1023 | /* TODO: block userspace mapping of io register */ |
768 | rdev->rmmio_size = pci_resource_len(rdev->pdev, 2); |
- | |
769 | - | ||
770 | rdev->rmmio = (void*)MapIoMem(rdev->rmmio_base, rdev->rmmio_size, |
1024 | rdev->rmmio_base = pci_resource_start(rdev->pdev, 2); |
771 | PG_SW+PG_NOCACHE); |
1025 | rdev->rmmio_size = pci_resource_len(rdev->pdev, 2); |
772 | 1026 | rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size); |
|
773 | if (rdev->rmmio == NULL) { |
1027 | if (rdev->rmmio == NULL) { |
774 | return -ENOMEM; |
1028 | return -ENOMEM; |
Line -... | Line 1029... | ||
- | 1029 | } |
|
- | 1030 | DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)rdev->rmmio_base); |
|
- | 1031 | DRM_INFO("register mmio size: %u\n", (unsigned)rdev->rmmio_size); |
|
- | 1032 | ||
- | 1033 | /* io port mapping */ |
|
- | 1034 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
|
- | 1035 | if (pci_resource_flags(rdev->pdev, i) & IORESOURCE_IO) { |
|
- | 1036 | rdev->rio_mem_size = pci_resource_len(rdev->pdev, i); |
|
- | 1037 | rdev->rio_mem = pci_iomap(rdev->pdev, i, rdev->rio_mem_size); |
|
- | 1038 | break; |
|
- | 1039 | } |
|
- | 1040 | } |
|
775 | } |
1041 | if (rdev->rio_mem == NULL) |
776 | DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)rdev->rmmio_base); |
1042 | DRM_ERROR("Unable to find PCI I/O BAR\n"); |
777 | DRM_INFO("register mmio size: %u\n", (unsigned)rdev->rmmio_size); |
1043 | |
Line 778... | Line 1044... | ||
778 | 1044 | ||
Line 792... | Line 1058... | ||
792 | return r; |
1058 | return r; |
793 | } |
1059 | } |
794 | // if (radeon_testing) { |
1060 | // if (radeon_testing) { |
795 | // radeon_test_moves(rdev); |
1061 | // radeon_test_moves(rdev); |
796 | // } |
1062 | // } |
- | 1063 | // if ((radeon_testing & 2)) { |
|
- | 1064 | // radeon_test_syncing(rdev); |
|
- | 1065 | // } |
|
797 | if (radeon_benchmarking) { |
1066 | if (radeon_benchmarking) { |
798 | radeon_benchmark(rdev); |
1067 | radeon_benchmark(rdev, radeon_benchmarking); |
799 | } |
1068 | } |
800 | return 0; |
1069 | return 0; |
801 | } |
1070 | } |
Line -... | Line 1071... | ||
- | 1071 | ||
- | 1072 | /** |
|
- | 1073 | * radeon_gpu_reset - reset the asic |
|
- | 1074 | * |
|
- | 1075 | * @rdev: radeon device pointer |
|
- | 1076 | * |
|
- | 1077 | * Attempt the reset the GPU if it has hung (all asics). |
|
- | 1078 | * Returns 0 for success or an error on failure. |
|
- | 1079 | */ |
|
- | 1080 | int radeon_gpu_reset(struct radeon_device *rdev) |
|
- | 1081 | { |
|
- | 1082 | unsigned ring_sizes[RADEON_NUM_RINGS]; |
|
- | 1083 | uint32_t *ring_data[RADEON_NUM_RINGS]; |
|
- | 1084 | ||
- | 1085 | bool saved = false; |
|
- | 1086 | ||
- | 1087 | int i, r; |
|
- | 1088 | int resched; |
|
- | 1089 | ||
- | 1090 | // down_write(&rdev->exclusive_lock); |
|
- | 1091 | radeon_save_bios_scratch_regs(rdev); |
|
- | 1092 | /* block TTM */ |
|
- | 1093 | // resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev); |
|
- | 1094 | radeon_suspend(rdev); |
|
- | 1095 | ||
- | 1096 | for (i = 0; i < RADEON_NUM_RINGS; ++i) { |
|
- | 1097 | ring_sizes[i] = radeon_ring_backup(rdev, &rdev->ring[i], |
|
- | 1098 | &ring_data[i]); |
|
- | 1099 | if (ring_sizes[i]) { |
|
- | 1100 | saved = true; |
|
- | 1101 | dev_info(rdev->dev, "Saved %d dwords of commands " |
|
- | 1102 | "on ring %d.\n", ring_sizes[i], i); |
|
- | 1103 | } |
|
- | 1104 | } |
|
- | 1105 | ||
- | 1106 | retry: |
|
- | 1107 | r = radeon_asic_reset(rdev); |
|
- | 1108 | if (!r) { |
|
- | 1109 | dev_info(rdev->dev, "GPU reset succeeded, trying to resume\n"); |
|
- | 1110 | radeon_resume(rdev); |
|
- | 1111 | } |
|
- | 1112 | ||
- | 1113 | radeon_restore_bios_scratch_regs(rdev); |
|
- | 1114 | drm_helper_resume_force_mode(rdev->ddev); |
|
- | 1115 | ||
- | 1116 | if (!r) { |
|
- | 1117 | for (i = 0; i < RADEON_NUM_RINGS; ++i) { |
|
- | 1118 | radeon_ring_restore(rdev, &rdev->ring[i], |
|
- | 1119 | ring_sizes[i], ring_data[i]); |
|
- | 1120 | ring_sizes[i] = 0; |
|
- | 1121 | ring_data[i] = NULL; |
|
- | 1122 | } |
|
- | 1123 | ||
- | 1124 | r = radeon_ib_ring_tests(rdev); |
|
- | 1125 | if (r) { |
|
- | 1126 | dev_err(rdev->dev, "ib ring test failed (%d).\n", r); |
|
- | 1127 | if (saved) { |
|
- | 1128 | saved = false; |
|
- | 1129 | radeon_suspend(rdev); |
|
- | 1130 | goto retry; |
|
- | 1131 | } |
|
- | 1132 | } |
|
- | 1133 | } else { |
|
- | 1134 | for (i = 0; i < RADEON_NUM_RINGS; ++i) { |
|
- | 1135 | kfree(ring_data[i]); |
|
- | 1136 | } |
|
- | 1137 | } |
|
- | 1138 | ||
- | 1139 | // ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched); |
|
- | 1140 | if (r) { |
|
- | 1141 | /* bad news, how to tell it to userspace ? */ |
|
- | 1142 | dev_info(rdev->dev, "GPU reset failed\n"); |
|
- | 1143 | } |
|
- | 1144 | ||
- | 1145 | // up_write(&rdev->exclusive_lock); |
|
- | 1146 | return r; |
|
- | 1147 | } |
|
- | 1148 | ||
Line 802... | Line 1149... | ||
802 | 1149 | ||
803 | 1150 | ||
804 | /* |
1151 | /* |
805 | * Driver load/unload |
1152 | * Driver load/unload |
Line 899... | Line 1246... | ||
899 | init_display_kms(dev->dev_private, &usermode); |
1246 | init_display_kms(dev->dev_private, &usermode); |
900 | else |
1247 | else |
901 | init_display(dev->dev_private, &usermode); |
1248 | init_display(dev->dev_private, &usermode); |
Line 902... | Line -... | ||
902 | - | ||
903 | - | ||
904 | uint32_t route0 = PciRead32(0, 31<<3, 0x60); |
- | |
905 | - | ||
906 | uint32_t route1 = PciRead32(0, 31<<3, 0x68); |
- | |
907 | - | ||
908 | uint8_t elcr0 = in8(0x4D0); |
- | |
909 | uint8_t elcr1 = in8(0x4D1); |
- | |
910 | - | ||
911 | dbgprintf("pci route: %x %x elcr: %x %x\n", route0, route1, elcr0, elcr1); |
1249 | |
Line 912... | Line 1250... | ||
912 | 1250 | ||
Line 913... | Line 1251... | ||
913 | LEAVE(); |
1251 | LEAVE(); |
Line 1020... | Line 1358... | ||
1020 | 1358 | ||
1021 | case SRV_ENUM_MODES: |
1359 | case SRV_ENUM_MODES: |
1022 | dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
1360 | dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
1023 | inp, io->inp_size, io->out_size ); |
1361 | inp, io->inp_size, io->out_size ); |
1024 | check_output(4); |
- | |
1025 | check_input(*outp * sizeof(videomode_t)); |
1362 | check_output(4); |
1026 | if( radeon_modeset) |
1363 | if( radeon_modeset) |
1027 | retval = get_modes((videomode_t*)inp, outp); |
1364 | retval = get_modes((videomode_t*)inp, outp); |
Line 1028... | Line 1365... | ||
1028 | break; |
1365 | break; |
Line 1034... | Line 1371... | ||
1034 | if( radeon_modeset ) |
1371 | if( radeon_modeset ) |
1035 | retval = set_user_mode((videomode_t*)inp); |
1372 | retval = set_user_mode((videomode_t*)inp); |
1036 | break; |
1373 | break; |
Line 1037... | Line 1374... | ||
1037 | 1374 | ||
1038 | case SRV_CREATE_VIDEO: |
1375 | case SRV_CREATE_VIDEO: |
1039 | retval = r600_create_video(inp[0], inp[1], outp); |
1376 | // retval = r600_create_video(inp[0], inp[1], outp); |
Line 1040... | Line 1377... | ||
1040 | break; |
1377 | break; |
1041 | 1378 | ||
1042 | case SRV_BLIT_VIDEO: |
1379 | case SRV_BLIT_VIDEO: |
Line 1043... | Line 1380... | ||
1043 | r600_video_blit( ((uint64_t*)inp)[0], inp[2], inp[3], |
1380 | // r600_video_blit( ((uint64_t*)inp)[0], inp[2], inp[3], |
1044 | inp[4], inp[5], inp[6]); |
1381 | // inp[4], inp[5], inp[6]); |
Line 1045... | Line 1382... | ||
1045 | 1382 | ||
1046 | retval = 0; |
1383 | retval = 0; |
1047 | break; |
1384 | break; |
1048 | 1385 | ||
1049 | case SRV_CREATE_BITMAP: |
1386 | case SRV_CREATE_BITMAP: |
Line 1050... | Line 1387... | ||
1050 | check_input(8); |
1387 | check_input(8); |
Line 1051... | Line 1388... | ||
1051 | check_output(4); |
1388 | check_output(4); |
Line 1062... | Line 1399... | ||
1062 | 1399 | ||
1063 | u32_t drvEntry(int action, char *cmdline) |
1400 | u32_t drvEntry(int action, char *cmdline) |
1064 | { |
1401 | { |
Line 1065... | Line 1402... | ||
1065 | struct radeon_device *rdev = NULL; |
1402 | struct radeon_device *rdev = NULL; |
Line 1066... | Line 1403... | ||
1066 | 1403 | ||
1067 | struct pci_device_id *ent; |
1404 | const struct pci_device_id *ent; |
Line 1068... | Line 1405... | ||
1068 | 1405 | ||
Line 1086... | Line 1423... | ||
1086 | { |
1423 | { |
1087 | printf("Can't open %s\nExit\n", log); |
1424 | printf("Can't open %s\nExit\n", log); |
1088 | return 0; |
1425 | return 0; |
1089 | }; |
1426 | }; |
1090 | } |
1427 | } |
1091 | dbgprintf("Radeon RC11 cmdline %s\n", cmdline); |
1428 | dbgprintf("Radeon RC12 preview 1 cmdline %s\n", cmdline); |
Line 1092... | Line 1429... | ||
1092 | 1429 | ||
Line 1093... | Line 1430... | ||
1093 | enum_pci_devices(); |
1430 | enum_pci_devices(); |
Line 1119... | Line 1456... | ||
1119 | {}; |
1456 | {}; |
Line 1120... | Line 1457... | ||
1120 | 1457 | ||
1121 | void drm_vblank_pre_modeset(struct drm_device *dev, int crtc) |
1458 | void drm_vblank_pre_modeset(struct drm_device *dev, int crtc) |
Line -... | Line 1459... | ||
- | 1459 | {}; |
|
- | 1460 | ||
- | 1461 | ||
- | 1462 | #define PCI_CLASS_REVISION 0x08 |
|
- | 1463 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
|
- | 1464 | ||
- | 1465 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
|
- | 1466 | { |
|
- | 1467 | u16_t vendor, device; |
|
- | 1468 | u32_t class; |
|
- | 1469 | int ret = 0; |
|
- | 1470 | ||
- | 1471 | vendor = id & 0xffff; |
|
- | 1472 | device = (id >> 16) & 0xffff; |
|
- | 1473 | ||
- | 1474 | if(vendor == 0x1002) |
|
- | 1475 | { |
|
- | 1476 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
|
- | 1477 | class >>= 16; |
|
- | 1478 | ||
- | 1479 | if( class == PCI_CLASS_DISPLAY_VGA) |
|
- | 1480 | ret = 1; |
|
- | 1481 | } |