Lines Matching refs:rdev

160 	struct radeon_device *rdev = dev->dev_private;  in radeon_is_px()  local
162 if (rdev->flags & RADEON_IS_PX) in radeon_is_px()
167 static void radeon_device_handle_px_quirks(struct radeon_device *rdev) in radeon_device_handle_px_quirks() argument
173 if (rdev->pdev->vendor == p->chip_vendor && in radeon_device_handle_px_quirks()
174 rdev->pdev->device == p->chip_device && in radeon_device_handle_px_quirks()
175 rdev->pdev->subsystem_vendor == p->subsys_vendor && in radeon_device_handle_px_quirks()
176 rdev->pdev->subsystem_device == p->subsys_device) { in radeon_device_handle_px_quirks()
177 rdev->px_quirk_flags = p->px_quirk_flags; in radeon_device_handle_px_quirks()
183 if (rdev->px_quirk_flags & RADEON_PX_QUIRK_DISABLE_PX) in radeon_device_handle_px_quirks()
184 rdev->flags &= ~RADEON_IS_PX; in radeon_device_handle_px_quirks()
189 rdev->flags &= ~RADEON_IS_PX; in radeon_device_handle_px_quirks()
202 void radeon_program_register_sequence(struct radeon_device *rdev, in radeon_program_register_sequence() argument
228 void radeon_pci_config_reset(struct radeon_device *rdev) in radeon_pci_config_reset() argument
230 pci_write_config_dword(rdev->pdev, 0x7c, RADEON_ASIC_RESET_DATA); in radeon_pci_config_reset()
240 void radeon_surface_init(struct radeon_device *rdev) in radeon_surface_init() argument
243 if (rdev->family < CHIP_R600) { in radeon_surface_init()
247 if (rdev->surface_regs[i].bo) in radeon_surface_init()
248 radeon_bo_get_surface_reg(rdev->surface_regs[i].bo); in radeon_surface_init()
250 radeon_clear_surface_reg(rdev, i); in radeon_surface_init()
267 void radeon_scratch_init(struct radeon_device *rdev) in radeon_scratch_init() argument
272 if (rdev->family < CHIP_R300) { in radeon_scratch_init()
273 rdev->scratch.num_reg = 5; in radeon_scratch_init()
275 rdev->scratch.num_reg = 7; in radeon_scratch_init()
277 rdev->scratch.reg_base = RADEON_SCRATCH_REG0; in radeon_scratch_init()
278 for (i = 0; i < rdev->scratch.num_reg; i++) { in radeon_scratch_init()
279 rdev->scratch.free[i] = true; in radeon_scratch_init()
280 rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); in radeon_scratch_init()
293 int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg) in radeon_scratch_get() argument
297 for (i = 0; i < rdev->scratch.num_reg; i++) { in radeon_scratch_get()
298 if (rdev->scratch.free[i]) { in radeon_scratch_get()
299 rdev->scratch.free[i] = false; in radeon_scratch_get()
300 *reg = rdev->scratch.reg[i]; in radeon_scratch_get()
315 void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg) in radeon_scratch_free() argument
319 for (i = 0; i < rdev->scratch.num_reg; i++) { in radeon_scratch_free()
320 if (rdev->scratch.reg[i] == reg) { in radeon_scratch_free()
321 rdev->scratch.free[i] = true; in radeon_scratch_free()
338 static int radeon_doorbell_init(struct radeon_device *rdev) in radeon_doorbell_init() argument
341 rdev->doorbell.base = pci_resource_start(rdev->pdev, 2); in radeon_doorbell_init()
342 rdev->doorbell.size = pci_resource_len(rdev->pdev, 2); in radeon_doorbell_init()
344 rdev->doorbell.num_doorbells = min_t(u32, rdev->doorbell.size / sizeof(u32), RADEON_MAX_DOORBELLS); in radeon_doorbell_init()
345 if (rdev->doorbell.num_doorbells == 0) in radeon_doorbell_init()
348 rdev->doorbell.ptr = ioremap(rdev->doorbell.base, rdev->doorbell.num_doorbells * sizeof(u32)); in radeon_doorbell_init()
349 if (rdev->doorbell.ptr == NULL) { in radeon_doorbell_init()
352 DRM_INFO("doorbell mmio base: 0x%08X\n", (uint32_t)rdev->doorbell.base); in radeon_doorbell_init()
353 DRM_INFO("doorbell mmio size: %u\n", (unsigned)rdev->doorbell.size); in radeon_doorbell_init()
355 memset(&rdev->doorbell.used, 0, sizeof(rdev->doorbell.used)); in radeon_doorbell_init()
367 static void radeon_doorbell_fini(struct radeon_device *rdev) in radeon_doorbell_fini() argument
369 iounmap(rdev->doorbell.ptr); in radeon_doorbell_fini()
370 rdev->doorbell.ptr = NULL; in radeon_doorbell_fini()
382 int radeon_doorbell_get(struct radeon_device *rdev, u32 *doorbell) in radeon_doorbell_get() argument
384 unsigned long offset = find_first_zero_bit(rdev->doorbell.used, rdev->doorbell.num_doorbells); in radeon_doorbell_get()
385 if (offset < rdev->doorbell.num_doorbells) { in radeon_doorbell_get()
386 __set_bit(offset, rdev->doorbell.used); in radeon_doorbell_get()
402 void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell) in radeon_doorbell_free() argument
404 if (doorbell < rdev->doorbell.num_doorbells) in radeon_doorbell_free()
405 __clear_bit(doorbell, rdev->doorbell.used); in radeon_doorbell_free()
422 void radeon_wb_disable(struct radeon_device *rdev) in radeon_wb_disable() argument
424 rdev->wb.enabled = false; in radeon_wb_disable()
435 void radeon_wb_fini(struct radeon_device *rdev) in radeon_wb_fini() argument
437 radeon_wb_disable(rdev); in radeon_wb_fini()
438 if (rdev->wb.wb_obj) { in radeon_wb_fini()
439 if (!radeon_bo_reserve(rdev->wb.wb_obj, false)) { in radeon_wb_fini()
440 radeon_bo_kunmap(rdev->wb.wb_obj); in radeon_wb_fini()
441 radeon_bo_unpin(rdev->wb.wb_obj); in radeon_wb_fini()
442 radeon_bo_unreserve(rdev->wb.wb_obj); in radeon_wb_fini()
444 radeon_bo_unref(&rdev->wb.wb_obj); in radeon_wb_fini()
445 rdev->wb.wb = NULL; in radeon_wb_fini()
446 rdev->wb.wb_obj = NULL; in radeon_wb_fini()
459 int radeon_wb_init(struct radeon_device *rdev) in radeon_wb_init() argument
463 if (rdev->wb.wb_obj == NULL) { in radeon_wb_init()
464 r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, in radeon_wb_init()
466 &rdev->wb.wb_obj); in radeon_wb_init()
468 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); in radeon_wb_init()
471 r = radeon_bo_reserve(rdev->wb.wb_obj, false); in radeon_wb_init()
473 radeon_wb_fini(rdev); in radeon_wb_init()
476 r = radeon_bo_pin(rdev->wb.wb_obj, RADEON_GEM_DOMAIN_GTT, in radeon_wb_init()
477 &rdev->wb.gpu_addr); in radeon_wb_init()
479 radeon_bo_unreserve(rdev->wb.wb_obj); in radeon_wb_init()
480 dev_warn(rdev->dev, "(%d) pin WB bo failed\n", r); in radeon_wb_init()
481 radeon_wb_fini(rdev); in radeon_wb_init()
484 r = radeon_bo_kmap(rdev->wb.wb_obj, (void **)&rdev->wb.wb); in radeon_wb_init()
485 radeon_bo_unreserve(rdev->wb.wb_obj); in radeon_wb_init()
487 dev_warn(rdev->dev, "(%d) map WB bo failed\n", r); in radeon_wb_init()
488 radeon_wb_fini(rdev); in radeon_wb_init()
494 memset((char *)rdev->wb.wb, 0, RADEON_GPU_PAGE_SIZE); in radeon_wb_init()
496 rdev->wb.use_event = false; in radeon_wb_init()
499 rdev->wb.enabled = false; in radeon_wb_init()
501 if (rdev->flags & RADEON_IS_AGP) { in radeon_wb_init()
503 rdev->wb.enabled = false; in radeon_wb_init()
504 } else if (rdev->family < CHIP_R300) { in radeon_wb_init()
506 rdev->wb.enabled = false; in radeon_wb_init()
508 rdev->wb.enabled = true; in radeon_wb_init()
510 if (rdev->family >= CHIP_R600) { in radeon_wb_init()
511 rdev->wb.use_event = true; in radeon_wb_init()
516 if (rdev->family >= CHIP_PALM) { in radeon_wb_init()
517 rdev->wb.enabled = true; in radeon_wb_init()
518 rdev->wb.use_event = true; in radeon_wb_init()
521 dev_info(rdev->dev, "WB %sabled\n", rdev->wb.enabled ? "en" : "dis"); in radeon_wb_init()
567 void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base) in radeon_vram_location() argument
572 if (mc->mc_vram_size > (rdev->mc.mc_mask - base + 1)) { in radeon_vram_location()
573 dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); in radeon_vram_location()
578 if (rdev->flags & RADEON_IS_AGP && mc->vram_end > mc->gtt_start && mc->vram_start <= mc->gtt_end) { in radeon_vram_location()
579 dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); in radeon_vram_location()
586 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n", in radeon_vram_location()
603 void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc) in radeon_gtt_location() argument
607 size_af = ((rdev->mc.mc_mask - mc->vram_end) + mc->gtt_base_align) & ~mc->gtt_base_align; in radeon_gtt_location()
611 dev_warn(rdev->dev, "limiting GTT\n"); in radeon_gtt_location()
617 dev_warn(rdev->dev, "limiting GTT\n"); in radeon_gtt_location()
623 dev_info(rdev->dev, "GTT: %lluM 0x%016llX - 0x%016llX\n", in radeon_gtt_location()
656 bool radeon_card_posted(struct radeon_device *rdev) in radeon_card_posted() argument
661 if (rdev->family >= CHIP_BONAIRE && in radeon_card_posted()
667 (rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) && in radeon_card_posted()
668 (rdev->family < CHIP_R600)) in radeon_card_posted()
671 if (ASIC_IS_NODCE(rdev)) in radeon_card_posted()
675 if (ASIC_IS_DCE4(rdev)) { in radeon_card_posted()
678 if (rdev->num_crtc >= 4) { in radeon_card_posted()
682 if (rdev->num_crtc >= 6) { in radeon_card_posted()
688 } else if (ASIC_IS_AVIVO(rdev)) { in radeon_card_posted()
704 if (rdev->family >= CHIP_R600) in radeon_card_posted()
724 void radeon_update_bandwidth_info(struct radeon_device *rdev) in radeon_update_bandwidth_info() argument
727 u32 sclk = rdev->pm.current_sclk; in radeon_update_bandwidth_info()
728 u32 mclk = rdev->pm.current_mclk; in radeon_update_bandwidth_info()
732 rdev->pm.sclk.full = dfixed_const(sclk); in radeon_update_bandwidth_info()
733 rdev->pm.sclk.full = dfixed_div(rdev->pm.sclk, a); in radeon_update_bandwidth_info()
734 rdev->pm.mclk.full = dfixed_const(mclk); in radeon_update_bandwidth_info()
735 rdev->pm.mclk.full = dfixed_div(rdev->pm.mclk, a); in radeon_update_bandwidth_info()
737 if (rdev->flags & RADEON_IS_IGP) { in radeon_update_bandwidth_info()
740 rdev->pm.core_bandwidth.full = dfixed_div(rdev->pm.sclk, a); in radeon_update_bandwidth_info()
753 bool radeon_boot_test_post_card(struct radeon_device *rdev) in radeon_boot_test_post_card() argument
755 if (radeon_card_posted(rdev)) in radeon_boot_test_post_card()
758 if (rdev->bios) { in radeon_boot_test_post_card()
760 if (rdev->is_atom_bios) in radeon_boot_test_post_card()
761 atom_asic_init(rdev->mode_info.atom_context); in radeon_boot_test_post_card()
763 radeon_combios_asic_init(rdev_to_drm(rdev)); in radeon_boot_test_post_card()
766 dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); in radeon_boot_test_post_card()
781 int radeon_dummy_page_init(struct radeon_device *rdev) in radeon_dummy_page_init() argument
783 if (rdev->dummy_page.page) in radeon_dummy_page_init()
785 rdev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO); in radeon_dummy_page_init()
786 if (rdev->dummy_page.page == NULL) in radeon_dummy_page_init()
788 rdev->dummy_page.addr = dma_map_page(&rdev->pdev->dev, rdev->dummy_page.page, in radeon_dummy_page_init()
790 if (dma_mapping_error(&rdev->pdev->dev, rdev->dummy_page.addr)) { in radeon_dummy_page_init()
791 dev_err(&rdev->pdev->dev, "Failed to DMA MAP the dummy page\n"); in radeon_dummy_page_init()
792 __free_page(rdev->dummy_page.page); in radeon_dummy_page_init()
793 rdev->dummy_page.page = NULL; in radeon_dummy_page_init()
796 rdev->dummy_page.entry = radeon_gart_get_page_entry(rdev->dummy_page.addr, in radeon_dummy_page_init()
808 void radeon_dummy_page_fini(struct radeon_device *rdev) in radeon_dummy_page_fini() argument
810 if (rdev->dummy_page.page == NULL) in radeon_dummy_page_fini()
812 dma_unmap_page(&rdev->pdev->dev, rdev->dummy_page.addr, PAGE_SIZE, in radeon_dummy_page_fini()
814 __free_page(rdev->dummy_page.page); in radeon_dummy_page_fini()
815 rdev->dummy_page.page = NULL; in radeon_dummy_page_fini()
839 struct radeon_device *rdev = info->dev->dev_private; in cail_pll_read() local
842 r = rdev->pll_rreg(rdev, reg); in cail_pll_read()
857 struct radeon_device *rdev = info->dev->dev_private; in cail_pll_write() local
859 rdev->pll_wreg(rdev, reg, val); in cail_pll_write()
873 struct radeon_device *rdev = info->dev->dev_private; in cail_mc_read() local
876 r = rdev->mc_rreg(rdev, reg); in cail_mc_read()
891 struct radeon_device *rdev = info->dev->dev_private; in cail_mc_write() local
893 rdev->mc_wreg(rdev, reg, val); in cail_mc_write()
907 struct radeon_device *rdev = info->dev->dev_private; in cail_reg_write() local
923 struct radeon_device *rdev = info->dev->dev_private; in cail_reg_read() local
941 struct radeon_device *rdev = info->dev->dev_private; in cail_ioreg_write() local
957 struct radeon_device *rdev = info->dev->dev_private; in cail_ioreg_read() local
974 int radeon_atombios_init(struct radeon_device *rdev) in radeon_atombios_init() argument
982 rdev->mode_info.atom_card_info = atom_card_info; in radeon_atombios_init()
983 atom_card_info->dev = rdev_to_drm(rdev); in radeon_atombios_init()
987 if (rdev->rio_mem) { in radeon_atombios_init()
1000 rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios); in radeon_atombios_init()
1001 if (!rdev->mode_info.atom_context) { in radeon_atombios_init()
1002 radeon_atombios_fini(rdev); in radeon_atombios_init()
1006 mutex_init(&rdev->mode_info.atom_context->mutex); in radeon_atombios_init()
1007 mutex_init(&rdev->mode_info.atom_context->scratch_mutex); in radeon_atombios_init()
1008 radeon_atom_initialize_bios_scratch_regs(rdev_to_drm(rdev)); in radeon_atombios_init()
1009 atom_allocate_fb_scratch(rdev->mode_info.atom_context); in radeon_atombios_init()
1022 void radeon_atombios_fini(struct radeon_device *rdev) in radeon_atombios_fini() argument
1024 if (rdev->mode_info.atom_context) { in radeon_atombios_fini()
1025 kfree(rdev->mode_info.atom_context->scratch); in radeon_atombios_fini()
1026 kfree(rdev->mode_info.atom_context->iio); in radeon_atombios_fini()
1028 kfree(rdev->mode_info.atom_context); in radeon_atombios_fini()
1029 rdev->mode_info.atom_context = NULL; in radeon_atombios_fini()
1030 kfree(rdev->mode_info.atom_card_info); in radeon_atombios_fini()
1031 rdev->mode_info.atom_card_info = NULL; in radeon_atombios_fini()
1050 int radeon_combios_init(struct radeon_device *rdev) in radeon_combios_init() argument
1052 radeon_combios_initialize_bios_scratch_regs(rdev_to_drm(rdev)); in radeon_combios_init()
1064 void radeon_combios_fini(struct radeon_device *rdev) in radeon_combios_fini() argument
1081 struct radeon_device *rdev = dev->dev_private; in radeon_vga_set_decode() local
1082 radeon_vga_set_state(rdev, state); in radeon_vga_set_decode()
1115 static void radeon_check_arguments(struct radeon_device *rdev) in radeon_check_arguments() argument
1119 dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n", in radeon_check_arguments()
1125 radeon_gart_size = radeon_gart_size_auto(rdev->family); in radeon_check_arguments()
1129 dev_warn(rdev->dev, "gart size (%d) too small\n", in radeon_check_arguments()
1131 radeon_gart_size = radeon_gart_size_auto(rdev->family); in radeon_check_arguments()
1133 dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n", in radeon_check_arguments()
1135 radeon_gart_size = radeon_gart_size_auto(rdev->family); in radeon_check_arguments()
1137 rdev->mc.gtt_size = (uint64_t)radeon_gart_size << 20; in radeon_check_arguments()
1149 dev_warn(rdev->dev, "invalid AGP mode %d (valid mode: " in radeon_check_arguments()
1156 dev_warn(rdev->dev, "VM size (%d) must be a power of 2\n", in radeon_check_arguments()
1162 dev_warn(rdev->dev, "VM size (%d) too small, min is 1GB\n", in radeon_check_arguments()
1171 dev_warn(rdev->dev, "VM size (%d) too large, max is 1TB\n", in radeon_check_arguments()
1192 dev_warn(rdev->dev, "VM page table size (%d) too small\n", in radeon_check_arguments()
1199 dev_warn(rdev->dev, "VM page table size (%d) too large\n", in radeon_check_arguments()
1278 int radeon_device_init(struct radeon_device *rdev, in radeon_device_init() argument
1287 rdev->shutdown = false; in radeon_device_init()
1288 rdev->flags = flags; in radeon_device_init()
1289 rdev->family = flags & RADEON_FAMILY_MASK; in radeon_device_init()
1290 rdev->is_atom_bios = false; in radeon_device_init()
1291 rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT; in radeon_device_init()
1292 rdev->mc.gtt_size = 512 * 1024 * 1024; in radeon_device_init()
1293 rdev->accel_working = false; in radeon_device_init()
1296 rdev->ring[i].idx = i; in radeon_device_init()
1298 rdev->fence_context = dma_fence_context_alloc(RADEON_NUM_RINGS); in radeon_device_init()
1301 radeon_family_name[rdev->family], pdev->vendor, pdev->device, in radeon_device_init()
1306 mutex_init(&rdev->ring_lock); in radeon_device_init()
1307 mutex_init(&rdev->dc_hw_i2c_mutex); in radeon_device_init()
1308 atomic_set(&rdev->ih.lock, 0); in radeon_device_init()
1309 mutex_init(&rdev->gem.mutex); in radeon_device_init()
1310 mutex_init(&rdev->pm.mutex); in radeon_device_init()
1311 mutex_init(&rdev->gpu_clock_mutex); in radeon_device_init()
1312 mutex_init(&rdev->srbm_mutex); in radeon_device_init()
1313 mutex_init(&rdev->audio.component_mutex); in radeon_device_init()
1314 init_rwsem(&rdev->pm.mclk_lock); in radeon_device_init()
1315 init_rwsem(&rdev->exclusive_lock); in radeon_device_init()
1316 init_waitqueue_head(&rdev->irq.vblank_queue); in radeon_device_init()
1317 r = radeon_gem_init(rdev); in radeon_device_init()
1321 radeon_check_arguments(rdev); in radeon_device_init()
1325 rdev->vm_manager.max_pfn = radeon_vm_size << 18; in radeon_device_init()
1328 r = radeon_asic_init(rdev); in radeon_device_init()
1335 if ((rdev->family >= CHIP_RS400) && in radeon_device_init()
1336 (rdev->flags & RADEON_IS_IGP)) { in radeon_device_init()
1337 rdev->flags &= ~RADEON_IS_AGP; in radeon_device_init()
1340 if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) { in radeon_device_init()
1341 radeon_agp_disable(rdev); in radeon_device_init()
1348 if (rdev->family >= CHIP_CAYMAN) in radeon_device_init()
1349 rdev->mc.mc_mask = 0xffffffffffULL; /* 40 bit MC */ in radeon_device_init()
1350 else if (rdev->family >= CHIP_CEDAR) in radeon_device_init()
1351 rdev->mc.mc_mask = 0xfffffffffULL; /* 36 bit MC */ in radeon_device_init()
1353 rdev->mc.mc_mask = 0xffffffffULL; /* 32 bit MC */ in radeon_device_init()
1362 if (rdev->flags & RADEON_IS_AGP) in radeon_device_init()
1364 if ((rdev->flags & RADEON_IS_PCI) && in radeon_device_init()
1365 (rdev->family <= CHIP_RS740)) in radeon_device_init()
1368 if (rdev->family == CHIP_CEDAR) in radeon_device_init()
1372 r = dma_set_mask_and_coherent(&rdev->pdev->dev, DMA_BIT_MASK(dma_bits)); in radeon_device_init()
1377 rdev->need_swiotlb = drm_need_swiotlb(dma_bits); in radeon_device_init()
1381 spin_lock_init(&rdev->mmio_idx_lock); in radeon_device_init()
1382 spin_lock_init(&rdev->smc_idx_lock); in radeon_device_init()
1383 spin_lock_init(&rdev->pll_idx_lock); in radeon_device_init()
1384 spin_lock_init(&rdev->mc_idx_lock); in radeon_device_init()
1385 spin_lock_init(&rdev->pcie_idx_lock); in radeon_device_init()
1386 spin_lock_init(&rdev->pciep_idx_lock); in radeon_device_init()
1387 spin_lock_init(&rdev->pif_idx_lock); in radeon_device_init()
1388 spin_lock_init(&rdev->cg_idx_lock); in radeon_device_init()
1389 spin_lock_init(&rdev->uvd_idx_lock); in radeon_device_init()
1390 spin_lock_init(&rdev->rcu_idx_lock); in radeon_device_init()
1391 spin_lock_init(&rdev->didt_idx_lock); in radeon_device_init()
1392 spin_lock_init(&rdev->end_idx_lock); in radeon_device_init()
1393 if (rdev->family >= CHIP_BONAIRE) { in radeon_device_init()
1394 rdev->rmmio_base = pci_resource_start(rdev->pdev, 5); in radeon_device_init()
1395 rdev->rmmio_size = pci_resource_len(rdev->pdev, 5); in radeon_device_init()
1397 rdev->rmmio_base = pci_resource_start(rdev->pdev, 2); in radeon_device_init()
1398 rdev->rmmio_size = pci_resource_len(rdev->pdev, 2); in radeon_device_init()
1400 rdev->rmmio = ioremap(rdev->rmmio_base, rdev->rmmio_size); in radeon_device_init()
1401 if (rdev->rmmio == NULL) in radeon_device_init()
1405 if (rdev->family >= CHIP_BONAIRE) in radeon_device_init()
1406 radeon_doorbell_init(rdev); in radeon_device_init()
1410 if (pci_resource_flags(rdev->pdev, i) & IORESOURCE_IO) { in radeon_device_init()
1411 rdev->rio_mem_size = pci_resource_len(rdev->pdev, i); in radeon_device_init()
1412 rdev->rio_mem = pci_iomap(rdev->pdev, i, rdev->rio_mem_size); in radeon_device_init()
1416 if (rdev->rio_mem == NULL) in radeon_device_init()
1419 if (rdev->flags & RADEON_IS_PX) in radeon_device_init()
1420 radeon_device_handle_px_quirks(rdev); in radeon_device_init()
1425 vga_client_register(rdev->pdev, radeon_vga_set_decode); in radeon_device_init()
1427 if (rdev->flags & RADEON_IS_PX) in radeon_device_init()
1429 if (!pci_is_thunderbolt_attached(rdev->pdev)) in radeon_device_init()
1430 vga_switcheroo_register_client(rdev->pdev, in radeon_device_init()
1433 vga_switcheroo_init_domain_pm_ops(rdev->dev, &rdev->vga_pm_domain); in radeon_device_init()
1435 r = radeon_init(rdev); in radeon_device_init()
1439 radeon_gem_debugfs_init(rdev); in radeon_device_init()
1441 if (rdev->flags & RADEON_IS_AGP && !rdev->accel_working) { in radeon_device_init()
1445 radeon_asic_reset(rdev); in radeon_device_init()
1446 radeon_fini(rdev); in radeon_device_init()
1447 radeon_agp_disable(rdev); in radeon_device_init()
1448 r = radeon_init(rdev); in radeon_device_init()
1453 radeon_audio_component_init(rdev); in radeon_device_init()
1455 r = radeon_ib_ring_tests(rdev); in radeon_device_init()
1464 if (rdev->pm.dpm_enabled && in radeon_device_init()
1465 (rdev->pm.pm_method == PM_METHOD_DPM) && in radeon_device_init()
1466 (rdev->family == CHIP_TURKS) && in radeon_device_init()
1467 (rdev->flags & RADEON_IS_MOBILITY)) { in radeon_device_init()
1468 mutex_lock(&rdev->pm.mutex); in radeon_device_init()
1469 radeon_dpm_disable(rdev); in radeon_device_init()
1470 radeon_dpm_enable(rdev); in radeon_device_init()
1471 mutex_unlock(&rdev->pm.mutex); in radeon_device_init()
1475 if (rdev->accel_working) in radeon_device_init()
1476 radeon_test_moves(rdev); in radeon_device_init()
1481 if (rdev->accel_working) in radeon_device_init()
1482 radeon_test_syncing(rdev); in radeon_device_init()
1487 if (rdev->accel_working) in radeon_device_init()
1488 radeon_benchmark(rdev, radeon_benchmarking); in radeon_device_init()
1499 vga_switcheroo_fini_domain_pm_ops(rdev->dev); in radeon_device_init()
1511 void radeon_device_fini(struct radeon_device *rdev) in radeon_device_fini() argument
1514 rdev->shutdown = true; in radeon_device_fini()
1516 radeon_bo_evict_vram(rdev); in radeon_device_fini()
1517 radeon_audio_component_fini(rdev); in radeon_device_fini()
1518 radeon_fini(rdev); in radeon_device_fini()
1519 if (!pci_is_thunderbolt_attached(rdev->pdev)) in radeon_device_fini()
1520 vga_switcheroo_unregister_client(rdev->pdev); in radeon_device_fini()
1521 if (rdev->flags & RADEON_IS_PX) in radeon_device_fini()
1522 vga_switcheroo_fini_domain_pm_ops(rdev->dev); in radeon_device_fini()
1523 vga_client_unregister(rdev->pdev); in radeon_device_fini()
1524 if (rdev->rio_mem) in radeon_device_fini()
1525 pci_iounmap(rdev->pdev, rdev->rio_mem); in radeon_device_fini()
1526 rdev->rio_mem = NULL; in radeon_device_fini()
1527 iounmap(rdev->rmmio); in radeon_device_fini()
1528 rdev->rmmio = NULL; in radeon_device_fini()
1529 if (rdev->family >= CHIP_BONAIRE) in radeon_device_fini()
1530 radeon_doorbell_fini(rdev); in radeon_device_fini()
1547 struct radeon_device *rdev; in radeon_suspend_kms() local
1557 rdev = dev->dev_private; in radeon_suspend_kms()
1592 if (!radeon_fbdev_robj_is_fb(rdev, robj)) { in radeon_suspend_kms()
1601 radeon_bo_evict_vram(rdev); in radeon_suspend_kms()
1605 r = radeon_fence_wait_empty(rdev, i); in radeon_suspend_kms()
1608 radeon_fence_driver_force_completion(rdev, i); in radeon_suspend_kms()
1611 flush_delayed_work(&rdev->fence_drv[i].lockup_work); in radeon_suspend_kms()
1615 radeon_save_bios_scratch_regs(rdev); in radeon_suspend_kms()
1617 radeon_suspend(rdev); in radeon_suspend_kms()
1618 radeon_hpd_fini(rdev); in radeon_suspend_kms()
1623 radeon_bo_evict_vram(rdev); in radeon_suspend_kms()
1625 radeon_agp_suspend(rdev); in radeon_suspend_kms()
1628 if (freeze && rdev->family >= CHIP_CEDAR && !(rdev->flags & RADEON_IS_IGP)) { in radeon_suspend_kms()
1629 rdev->asic->asic_reset(rdev, true); in radeon_suspend_kms()
1639 radeon_fbdev_set_suspend(rdev, 1); in radeon_suspend_kms()
1655 struct radeon_device *rdev = dev->dev_private; in radeon_resume_kms() local
1676 radeon_agp_resume(rdev); in radeon_resume_kms()
1677 radeon_resume(rdev); in radeon_resume_kms()
1679 r = radeon_ib_ring_tests(rdev); in radeon_resume_kms()
1683 if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) { in radeon_resume_kms()
1685 r = radeon_pm_late_init(rdev); in radeon_resume_kms()
1687 rdev->pm.dpm_enabled = false; in radeon_resume_kms()
1692 radeon_pm_resume(rdev); in radeon_resume_kms()
1695 radeon_restore_bios_scratch_regs(rdev); in radeon_resume_kms()
1708 ASIC_IS_AVIVO(rdev) ? in radeon_resume_kms()
1719 if (rdev->is_atom_bios) { in radeon_resume_kms()
1720 radeon_atom_encoder_init(rdev); in radeon_resume_kms()
1721 radeon_atom_disp_eng_pll_init(rdev); in radeon_resume_kms()
1723 if (rdev->mode_info.bl_encoder) { in radeon_resume_kms()
1724 u8 bl_level = radeon_get_backlight_level(rdev, in radeon_resume_kms()
1725 rdev->mode_info.bl_encoder); in radeon_resume_kms()
1726 radeon_set_backlight_level(rdev, rdev->mode_info.bl_encoder, in radeon_resume_kms()
1731 radeon_hpd_init(rdev); in radeon_resume_kms()
1746 if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) in radeon_resume_kms()
1747 radeon_pm_compute_clocks(rdev); in radeon_resume_kms()
1750 radeon_fbdev_set_suspend(rdev, 0); in radeon_resume_kms()
1765 int radeon_gpu_reset(struct radeon_device *rdev) in radeon_gpu_reset() argument
1774 down_write(&rdev->exclusive_lock); in radeon_gpu_reset()
1776 if (!rdev->needs_reset) { in radeon_gpu_reset()
1777 up_write(&rdev->exclusive_lock); in radeon_gpu_reset()
1781 atomic_inc(&rdev->gpu_reset_counter); in radeon_gpu_reset()
1783 radeon_save_bios_scratch_regs(rdev); in radeon_gpu_reset()
1784 radeon_suspend(rdev); in radeon_gpu_reset()
1785 radeon_hpd_fini(rdev); in radeon_gpu_reset()
1788 ring_sizes[i] = radeon_ring_backup(rdev, &rdev->ring[i], in radeon_gpu_reset()
1792 dev_info(rdev->dev, "Saved %d dwords of commands " in radeon_gpu_reset()
1797 r = radeon_asic_reset(rdev); in radeon_gpu_reset()
1799 dev_info(rdev->dev, "GPU reset succeeded, trying to resume\n"); in radeon_gpu_reset()
1800 radeon_resume(rdev); in radeon_gpu_reset()
1803 radeon_restore_bios_scratch_regs(rdev); in radeon_gpu_reset()
1807 radeon_ring_restore(rdev, &rdev->ring[i], in radeon_gpu_reset()
1810 radeon_fence_driver_force_completion(rdev, i); in radeon_gpu_reset()
1815 if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) { in radeon_gpu_reset()
1817 r = radeon_pm_late_init(rdev); in radeon_gpu_reset()
1819 rdev->pm.dpm_enabled = false; in radeon_gpu_reset()
1824 radeon_pm_resume(rdev); in radeon_gpu_reset()
1828 if (rdev->is_atom_bios) { in radeon_gpu_reset()
1829 radeon_atom_encoder_init(rdev); in radeon_gpu_reset()
1830 radeon_atom_disp_eng_pll_init(rdev); in radeon_gpu_reset()
1832 if (rdev->mode_info.bl_encoder) { in radeon_gpu_reset()
1833 u8 bl_level = radeon_get_backlight_level(rdev, in radeon_gpu_reset()
1834 rdev->mode_info.bl_encoder); in radeon_gpu_reset()
1835 radeon_set_backlight_level(rdev, rdev->mode_info.bl_encoder, in radeon_gpu_reset()
1840 radeon_hpd_init(rdev); in radeon_gpu_reset()
1842 rdev->in_reset = true; in radeon_gpu_reset()
1843 rdev->needs_reset = false; in radeon_gpu_reset()
1845 downgrade_write(&rdev->exclusive_lock); in radeon_gpu_reset()
1847 drm_helper_resume_force_mode(rdev_to_drm(rdev)); in radeon_gpu_reset()
1850 if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled) in radeon_gpu_reset()
1851 radeon_pm_compute_clocks(rdev); in radeon_gpu_reset()
1854 r = radeon_ib_ring_tests(rdev); in radeon_gpu_reset()
1859 dev_info(rdev->dev, "GPU reset failed\n"); in radeon_gpu_reset()
1862 rdev->needs_reset = r == -EAGAIN; in radeon_gpu_reset()
1863 rdev->in_reset = false; in radeon_gpu_reset()
1865 up_read(&rdev->exclusive_lock); in radeon_gpu_reset()