Rev 3192 | Rev 5078 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3192 | Rev 3764 | ||
---|---|---|---|
Line 91... | Line 91... | ||
91 | MODULE_FIRMWARE("radeon/SUMO_pfp.bin"); |
91 | MODULE_FIRMWARE("radeon/SUMO_pfp.bin"); |
92 | MODULE_FIRMWARE("radeon/SUMO_me.bin"); |
92 | MODULE_FIRMWARE("radeon/SUMO_me.bin"); |
93 | MODULE_FIRMWARE("radeon/SUMO2_pfp.bin"); |
93 | MODULE_FIRMWARE("radeon/SUMO2_pfp.bin"); |
94 | MODULE_FIRMWARE("radeon/SUMO2_me.bin"); |
94 | MODULE_FIRMWARE("radeon/SUMO2_me.bin"); |
Line -... | Line 95... | ||
- | 95 | ||
- | 96 | static const u32 crtc_offsets[2] = |
|
- | 97 | { |
|
- | 98 | 0, |
|
- | 99 | AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL |
|
- | 100 | }; |
|
95 | 101 | ||
Line 96... | Line 102... | ||
96 | int r600_debugfs_mc_info_init(struct radeon_device *rdev); |
102 | int r600_debugfs_mc_info_init(struct radeon_device *rdev); |
97 | 103 | ||
98 | /* r600,rv610,rv630,rv620,rv635,rv670 */ |
104 | /* r600,rv610,rv630,rv620,rv635,rv670 */ |
99 | int r600_mc_wait_for_idle(struct radeon_device *rdev); |
105 | int r600_mc_wait_for_idle(struct radeon_device *rdev); |
100 | static void r600_gpu_init(struct radeon_device *rdev); |
106 | static void r600_gpu_init(struct radeon_device *rdev); |
101 | void r600_fini(struct radeon_device *rdev); |
107 | void r600_fini(struct radeon_device *rdev); |
Line -... | Line 108... | ||
- | 108 | void r600_irq_disable(struct radeon_device *rdev); |
|
- | 109 | static void r600_pcie_gen2_enable(struct radeon_device *rdev); |
|
- | 110 | ||
- | 111 | /** |
|
- | 112 | * r600_get_xclk - get the xclk |
|
- | 113 | * |
|
- | 114 | * @rdev: radeon_device pointer |
|
- | 115 | * |
|
- | 116 | * Returns the reference clock used by the gfx engine |
|
- | 117 | * (r6xx, IGPs, APUs). |
|
- | 118 | */ |
|
- | 119 | u32 r600_get_xclk(struct radeon_device *rdev) |
|
- | 120 | { |
|
102 | void r600_irq_disable(struct radeon_device *rdev); |
121 | return rdev->clock.spll.reference_freq; |
103 | static void r600_pcie_gen2_enable(struct radeon_device *rdev); |
122 | } |
104 | 123 | ||
105 | /* get temperature in millidegrees */ |
124 | /* get temperature in millidegrees */ |
106 | int rv6xx_get_temp(struct radeon_device *rdev) |
125 | int rv6xx_get_temp(struct radeon_device *rdev) |
Line 596... | Line 615... | ||
596 | udelay(1); |
615 | udelay(1); |
597 | } |
616 | } |
598 | return -1; |
617 | return -1; |
599 | } |
618 | } |
Line -... | Line 619... | ||
- | 619 | ||
- | 620 | uint32_t rs780_mc_rreg(struct radeon_device *rdev, uint32_t reg) |
|
- | 621 | { |
|
- | 622 | uint32_t r; |
|
- | 623 | ||
- | 624 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg)); |
|
- | 625 | r = RREG32(R_0028FC_MC_DATA); |
|
- | 626 | WREG32(R_0028F8_MC_INDEX, ~C_0028F8_MC_IND_ADDR); |
|
- | 627 | return r; |
|
- | 628 | } |
|
- | 629 | ||
- | 630 | void rs780_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
|
- | 631 | { |
|
- | 632 | WREG32(R_0028F8_MC_INDEX, S_0028F8_MC_IND_ADDR(reg) | |
|
- | 633 | S_0028F8_MC_IND_WR_EN(1)); |
|
- | 634 | WREG32(R_0028FC_MC_DATA, v); |
|
- | 635 | WREG32(R_0028F8_MC_INDEX, 0x7F); |
|
- | 636 | } |
|
600 | 637 | ||
601 | static void r600_mc_program(struct radeon_device *rdev) |
638 | static void r600_mc_program(struct radeon_device *rdev) |
602 | { |
639 | { |
603 | struct rv515_mc_save save; |
640 | struct rv515_mc_save save; |
604 | u32 tmp; |
641 | u32 tmp; |
Line 695... | Line 732... | ||
695 | mc->real_vram_size = 0xE0000000; |
732 | mc->real_vram_size = 0xE0000000; |
696 | mc->mc_vram_size = 0xE0000000; |
733 | mc->mc_vram_size = 0xE0000000; |
697 | } |
734 | } |
698 | if (rdev->flags & RADEON_IS_AGP) { |
735 | if (rdev->flags & RADEON_IS_AGP) { |
699 | size_bf = mc->gtt_start; |
736 | size_bf = mc->gtt_start; |
700 | size_af = 0xFFFFFFFF - mc->gtt_end; |
737 | size_af = mc->mc_mask - mc->gtt_end; |
701 | if (size_bf > size_af) { |
738 | if (size_bf > size_af) { |
702 | if (mc->mc_vram_size > size_bf) { |
739 | if (mc->mc_vram_size > size_bf) { |
703 | dev_warn(rdev->dev, "limiting VRAM\n"); |
740 | dev_warn(rdev->dev, "limiting VRAM\n"); |
704 | mc->real_vram_size = size_bf; |
741 | mc->real_vram_size = size_bf; |
705 | mc->mc_vram_size = size_bf; |
742 | mc->mc_vram_size = size_bf; |
Line 731... | Line 768... | ||
731 | 768 | ||
732 | static int r600_mc_init(struct radeon_device *rdev) |
769 | static int r600_mc_init(struct radeon_device *rdev) |
733 | { |
770 | { |
734 | u32 tmp; |
771 | u32 tmp; |
- | 772 | int chansize, numchan; |
|
- | 773 | uint32_t h_addr, l_addr; |
|
Line 735... | Line 774... | ||
735 | int chansize, numchan; |
774 | unsigned long long k8_addr; |
736 | 775 | ||
737 | /* Get VRAM informations */ |
776 | /* Get VRAM informations */ |
738 | rdev->mc.vram_is_ddr = true; |
777 | rdev->mc.vram_is_ddr = true; |
Line 771... | Line 810... | ||
771 | r600_vram_gtt_location(rdev, &rdev->mc); |
810 | r600_vram_gtt_location(rdev, &rdev->mc); |
Line 772... | Line 811... | ||
772 | 811 | ||
773 | if (rdev->flags & RADEON_IS_IGP) { |
812 | if (rdev->flags & RADEON_IS_IGP) { |
774 | rs690_pm_info(rdev); |
813 | rs690_pm_info(rdev); |
- | 814 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
|
- | 815 | ||
- | 816 | if (rdev->family == CHIP_RS780 || rdev->family == CHIP_RS880) { |
|
- | 817 | /* Use K8 direct mapping for fast fb access. */ |
|
- | 818 | rdev->fastfb_working = false; |
|
- | 819 | h_addr = G_000012_K8_ADDR_EXT(RREG32_MC(R_000012_MC_MISC_UMA_CNTL)); |
|
- | 820 | l_addr = RREG32_MC(R_000011_K8_FB_LOCATION); |
|
- | 821 | k8_addr = ((unsigned long long)h_addr) << 32 | l_addr; |
|
- | 822 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) |
|
- | 823 | if (k8_addr + rdev->mc.visible_vram_size < 0x100000000ULL) |
|
- | 824 | #endif |
|
- | 825 | { |
|
- | 826 | /* FastFB shall be used with UMA memory. Here it is simply disabled when sideport |
|
- | 827 | * memory is present. |
|
- | 828 | */ |
|
- | 829 | if (rdev->mc.igp_sideport_enabled == false && radeon_fastfb == 1) { |
|
- | 830 | DRM_INFO("Direct mapping: aper base at 0x%llx, replaced by direct mapping base 0x%llx.\n", |
|
- | 831 | (unsigned long long)rdev->mc.aper_base, k8_addr); |
|
- | 832 | rdev->mc.aper_base = (resource_size_t)k8_addr; |
|
- | 833 | rdev->fastfb_working = true; |
|
775 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
834 | } |
- | 835 | } |
|
- | 836 | } |
|
- | 837 | } |
|
776 | } |
838 | |
777 | radeon_update_bandwidth_info(rdev); |
839 | radeon_update_bandwidth_info(rdev); |
778 | return 0; |
840 | return 0; |
Line 779... | Line 841... | ||
779 | } |
841 | } |
Line 806... | Line 868... | ||
806 | radeon_bo_unpin(rdev->vram_scratch.robj); |
868 | radeon_bo_unpin(rdev->vram_scratch.robj); |
807 | radeon_bo_unreserve(rdev->vram_scratch.robj); |
869 | radeon_bo_unreserve(rdev->vram_scratch.robj); |
Line 808... | Line 870... | ||
808 | 870 | ||
809 | return r; |
871 | return r; |
810 | } |
- | |
811 | /* We doesn't check that the GPU really needs a reset we simply do the |
- | |
812 | * reset, it's up to the caller to determine if the GPU needs one. We |
- | |
813 | * might add an helper function to check that. |
- | |
814 | */ |
- | |
815 | static void r600_gpu_soft_reset_gfx(struct radeon_device *rdev) |
- | |
816 | { |
- | |
817 | u32 grbm_busy_mask = S_008010_VC_BUSY(1) | S_008010_VGT_BUSY_NO_DMA(1) | |
- | |
818 | S_008010_VGT_BUSY(1) | S_008010_TA03_BUSY(1) | |
- | |
819 | S_008010_TC_BUSY(1) | S_008010_SX_BUSY(1) | |
- | |
820 | S_008010_SH_BUSY(1) | S_008010_SPI03_BUSY(1) | |
- | |
821 | S_008010_SMX_BUSY(1) | S_008010_SC_BUSY(1) | |
- | |
822 | S_008010_PA_BUSY(1) | S_008010_DB03_BUSY(1) | |
- | |
823 | S_008010_CR_BUSY(1) | S_008010_CB03_BUSY(1) | |
- | |
824 | S_008010_GUI_ACTIVE(1); |
- | |
825 | u32 grbm2_busy_mask = S_008014_SPI0_BUSY(1) | S_008014_SPI1_BUSY(1) | |
- | |
826 | S_008014_SPI2_BUSY(1) | S_008014_SPI3_BUSY(1) | |
- | |
827 | S_008014_TA0_BUSY(1) | S_008014_TA1_BUSY(1) | |
- | |
828 | S_008014_TA2_BUSY(1) | S_008014_TA3_BUSY(1) | |
- | |
829 | S_008014_DB0_BUSY(1) | S_008014_DB1_BUSY(1) | |
- | |
830 | S_008014_DB2_BUSY(1) | S_008014_DB3_BUSY(1) | |
- | |
831 | S_008014_CB0_BUSY(1) | S_008014_CB1_BUSY(1) | |
- | |
832 | S_008014_CB2_BUSY(1) | S_008014_CB3_BUSY(1); |
- | |
Line -... | Line 872... | ||
- | 872 | } |
|
- | 873 | ||
- | 874 | void r600_vram_scratch_fini(struct radeon_device *rdev) |
|
- | 875 | { |
|
833 | u32 tmp; |
876 | int r; |
834 | 877 | ||
- | 878 | if (rdev->vram_scratch.robj == NULL) { |
|
- | 879 | return; |
|
- | 880 | } |
|
- | 881 | r = radeon_bo_reserve(rdev->vram_scratch.robj, false); |
|
- | 882 | if (likely(r == 0)) { |
|
- | 883 | radeon_bo_kunmap(rdev->vram_scratch.robj); |
|
- | 884 | radeon_bo_unpin(rdev->vram_scratch.robj); |
|
- | 885 | radeon_bo_unreserve(rdev->vram_scratch.robj); |
|
- | 886 | } |
|
- | 887 | radeon_bo_unref(&rdev->vram_scratch.robj); |
|
- | 888 | } |
|
- | 889 | ||
- | 890 | void r600_set_bios_scratch_engine_hung(struct radeon_device *rdev, bool hung) |
|
- | 891 | { |
|
- | 892 | u32 tmp = RREG32(R600_BIOS_3_SCRATCH); |
|
- | 893 | ||
- | 894 | if (hung) |
|
- | 895 | tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
|
- | 896 | else |
|
- | 897 | tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; |
|
- | 898 | ||
Line -... | Line 899... | ||
- | 899 | WREG32(R600_BIOS_3_SCRATCH, tmp); |
|
- | 900 | } |
|
835 | if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE)) |
901 | |
836 | return; |
902 | static void r600_print_gpu_status_regs(struct radeon_device *rdev) |
837 | 903 | { |
|
838 | dev_info(rdev->dev, " R_008010_GRBM_STATUS = 0x%08X\n", |
904 | dev_info(rdev->dev, " R_008010_GRBM_STATUS = 0x%08X\n", |
839 | RREG32(R_008010_GRBM_STATUS)); |
905 | RREG32(R_008010_GRBM_STATUS)); |
Line 847... | Line 913... | ||
847 | RREG32(CP_STALLED_STAT2)); |
913 | RREG32(CP_STALLED_STAT2)); |
848 | dev_info(rdev->dev, " R_00867C_CP_BUSY_STAT = 0x%08X\n", |
914 | dev_info(rdev->dev, " R_00867C_CP_BUSY_STAT = 0x%08X\n", |
849 | RREG32(CP_BUSY_STAT)); |
915 | RREG32(CP_BUSY_STAT)); |
850 | dev_info(rdev->dev, " R_008680_CP_STAT = 0x%08X\n", |
916 | dev_info(rdev->dev, " R_008680_CP_STAT = 0x%08X\n", |
851 | RREG32(CP_STAT)); |
917 | RREG32(CP_STAT)); |
- | 918 | dev_info(rdev->dev, " R_00D034_DMA_STATUS_REG = 0x%08X\n", |
|
- | 919 | RREG32(DMA_STATUS_REG)); |
|
- | 920 | } |
|
- | 921 | ||
- | 922 | static bool r600_is_display_hung(struct radeon_device *rdev) |
|
- | 923 | { |
|
- | 924 | u32 crtc_hung = 0; |
|
- | 925 | u32 crtc_status[2]; |
|
- | 926 | u32 i, j, tmp; |
|
- | 927 | ||
- | 928 | for (i = 0; i < rdev->num_crtc; i++) { |
|
- | 929 | if (RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[i]) & AVIVO_CRTC_EN) { |
|
- | 930 | crtc_status[i] = RREG32(AVIVO_D1CRTC_STATUS_HV_COUNT + crtc_offsets[i]); |
|
- | 931 | crtc_hung |= (1 << i); |
|
- | 932 | } |
|
- | 933 | } |
|
- | 934 | ||
- | 935 | for (j = 0; j < 10; j++) { |
|
- | 936 | for (i = 0; i < rdev->num_crtc; i++) { |
|
- | 937 | if (crtc_hung & (1 << i)) { |
|
- | 938 | tmp = RREG32(AVIVO_D1CRTC_STATUS_HV_COUNT + crtc_offsets[i]); |
|
- | 939 | if (tmp != crtc_status[i]) |
|
- | 940 | crtc_hung &= ~(1 << i); |
|
- | 941 | } |
|
- | 942 | } |
|
- | 943 | if (crtc_hung == 0) |
|
- | 944 | return false; |
|
- | 945 | udelay(100); |
|
- | 946 | } |
|
- | 947 | ||
- | 948 | return true; |
|
- | 949 | } |
|
- | 950 | ||
- | 951 | static u32 r600_gpu_check_soft_reset(struct radeon_device *rdev) |
|
- | 952 | { |
|
- | 953 | u32 reset_mask = 0; |
|
- | 954 | u32 tmp; |
|
- | 955 | ||
- | 956 | /* GRBM_STATUS */ |
|
- | 957 | tmp = RREG32(R_008010_GRBM_STATUS); |
|
- | 958 | if (rdev->family >= CHIP_RV770) { |
|
- | 959 | if (G_008010_PA_BUSY(tmp) | G_008010_SC_BUSY(tmp) | |
|
- | 960 | G_008010_SH_BUSY(tmp) | G_008010_SX_BUSY(tmp) | |
|
- | 961 | G_008010_TA_BUSY(tmp) | G_008010_VGT_BUSY(tmp) | |
|
- | 962 | G_008010_DB03_BUSY(tmp) | G_008010_CB03_BUSY(tmp) | |
|
- | 963 | G_008010_SPI03_BUSY(tmp) | G_008010_VGT_BUSY_NO_DMA(tmp)) |
|
- | 964 | reset_mask |= RADEON_RESET_GFX; |
|
- | 965 | } else { |
|
- | 966 | if (G_008010_PA_BUSY(tmp) | G_008010_SC_BUSY(tmp) | |
|
- | 967 | G_008010_SH_BUSY(tmp) | G_008010_SX_BUSY(tmp) | |
|
- | 968 | G_008010_TA03_BUSY(tmp) | G_008010_VGT_BUSY(tmp) | |
|
- | 969 | G_008010_DB03_BUSY(tmp) | G_008010_CB03_BUSY(tmp) | |
|
- | 970 | G_008010_SPI03_BUSY(tmp) | G_008010_VGT_BUSY_NO_DMA(tmp)) |
|
- | 971 | reset_mask |= RADEON_RESET_GFX; |
|
- | 972 | } |
|
- | 973 | ||
- | 974 | if (G_008010_CF_RQ_PENDING(tmp) | G_008010_PF_RQ_PENDING(tmp) | |
|
- | 975 | G_008010_CP_BUSY(tmp) | G_008010_CP_COHERENCY_BUSY(tmp)) |
|
- | 976 | reset_mask |= RADEON_RESET_CP; |
|
- | 977 | ||
- | 978 | if (G_008010_GRBM_EE_BUSY(tmp)) |
|
- | 979 | reset_mask |= RADEON_RESET_GRBM | RADEON_RESET_GFX | RADEON_RESET_CP; |
|
- | 980 | ||
- | 981 | /* DMA_STATUS_REG */ |
|
- | 982 | tmp = RREG32(DMA_STATUS_REG); |
|
- | 983 | if (!(tmp & DMA_IDLE)) |
|
- | 984 | reset_mask |= RADEON_RESET_DMA; |
|
- | 985 | ||
- | 986 | /* SRBM_STATUS */ |
|
- | 987 | tmp = RREG32(R_000E50_SRBM_STATUS); |
|
- | 988 | if (G_000E50_RLC_RQ_PENDING(tmp) | G_000E50_RLC_BUSY(tmp)) |
|
- | 989 | reset_mask |= RADEON_RESET_RLC; |
|
- | 990 | ||
- | 991 | if (G_000E50_IH_BUSY(tmp)) |
|
- | 992 | reset_mask |= RADEON_RESET_IH; |
|
- | 993 | ||
- | 994 | if (G_000E50_SEM_BUSY(tmp)) |
|
- | 995 | reset_mask |= RADEON_RESET_SEM; |
|
- | 996 | ||
- | 997 | if (G_000E50_GRBM_RQ_PENDING(tmp)) |
|
- | 998 | reset_mask |= RADEON_RESET_GRBM; |
|
- | 999 | ||
- | 1000 | if (G_000E50_VMC_BUSY(tmp)) |
|
- | 1001 | reset_mask |= RADEON_RESET_VMC; |
|
- | 1002 | ||
- | 1003 | if (G_000E50_MCB_BUSY(tmp) | G_000E50_MCDZ_BUSY(tmp) | |
|
- | 1004 | G_000E50_MCDY_BUSY(tmp) | G_000E50_MCDX_BUSY(tmp) | |
|
- | 1005 | G_000E50_MCDW_BUSY(tmp)) |
|
- | 1006 | reset_mask |= RADEON_RESET_MC; |
|
- | 1007 | ||
- | 1008 | if (r600_is_display_hung(rdev)) |
|
- | 1009 | reset_mask |= RADEON_RESET_DISPLAY; |
|
- | 1010 | ||
- | 1011 | /* Skip MC reset as it's mostly likely not hung, just busy */ |
|
- | 1012 | if (reset_mask & RADEON_RESET_MC) { |
|
- | 1013 | DRM_DEBUG("MC busy: 0x%08X, clearing.\n", reset_mask); |
|
- | 1014 | reset_mask &= ~RADEON_RESET_MC; |
|
- | 1015 | } |
|
- | 1016 | ||
- | 1017 | return reset_mask; |
|
- | 1018 | } |
|
- | 1019 | ||
- | 1020 | static void r600_gpu_soft_reset(struct radeon_device *rdev, u32 reset_mask) |
|
- | 1021 | { |
|
- | 1022 | struct rv515_mc_save save; |
|
- | 1023 | u32 grbm_soft_reset = 0, srbm_soft_reset = 0; |
|
- | 1024 | u32 tmp; |
|
- | 1025 | ||
- | 1026 | if (reset_mask == 0) |
|
- | 1027 | return; |
|
- | 1028 | ||
- | 1029 | dev_info(rdev->dev, "GPU softreset: 0x%08X\n", reset_mask); |
|
- | 1030 | ||
- | 1031 | r600_print_gpu_status_regs(rdev); |
|
Line 852... | Line 1032... | ||
852 | 1032 | ||
- | 1033 | /* Disable CP parsing/prefetching */ |
|
- | 1034 | if (rdev->family >= CHIP_RV770) |
|
- | 1035 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1) | S_0086D8_CP_PFP_HALT(1)); |
|
853 | /* Disable CP parsing/prefetching */ |
1036 | else |
Line -... | Line 1037... | ||
- | 1037 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); |
|
- | 1038 | ||
- | 1039 | /* disable the RLC */ |
|
- | 1040 | WREG32(RLC_CNTL, 0); |
|
- | 1041 | ||
- | 1042 | if (reset_mask & RADEON_RESET_DMA) { |
|
- | 1043 | /* Disable DMA */ |
|
- | 1044 | tmp = RREG32(DMA_RB_CNTL); |
|
- | 1045 | tmp &= ~DMA_RB_ENABLE; |
|
- | 1046 | WREG32(DMA_RB_CNTL, tmp); |
|
- | 1047 | } |
|
- | 1048 | ||
- | 1049 | mdelay(50); |
|
- | 1050 | ||
854 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); |
1051 | rv515_mc_stop(rdev, &save); |
- | 1052 | if (r600_mc_wait_for_idle(rdev)) { |
|
- | 1053 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
|
855 | 1054 | } |
|
- | 1055 | ||
856 | /* Check if any of the rendering block is busy and reset it */ |
1056 | if (reset_mask & (RADEON_RESET_GFX | RADEON_RESET_COMPUTE)) { |
857 | if ((RREG32(R_008010_GRBM_STATUS) & grbm_busy_mask) || |
1057 | if (rdev->family >= CHIP_RV770) |
- | 1058 | grbm_soft_reset |= S_008020_SOFT_RESET_DB(1) | |
|
- | 1059 | S_008020_SOFT_RESET_CB(1) | |
|
- | 1060 | S_008020_SOFT_RESET_PA(1) | |
|
- | 1061 | S_008020_SOFT_RESET_SC(1) | |
|
- | 1062 | S_008020_SOFT_RESET_SPI(1) | |
|
- | 1063 | S_008020_SOFT_RESET_SX(1) | |
|
- | 1064 | S_008020_SOFT_RESET_SH(1) | |
|
- | 1065 | S_008020_SOFT_RESET_TC(1) | |
|
- | 1066 | S_008020_SOFT_RESET_TA(1) | |
|
- | 1067 | S_008020_SOFT_RESET_VC(1) | |
|
- | 1068 | S_008020_SOFT_RESET_VGT(1); |
|
858 | (RREG32(R_008014_GRBM_STATUS2) & grbm2_busy_mask)) { |
1069 | else |
859 | tmp = S_008020_SOFT_RESET_CR(1) | |
1070 | grbm_soft_reset |= S_008020_SOFT_RESET_CR(1) | |
860 | S_008020_SOFT_RESET_DB(1) | |
1071 | S_008020_SOFT_RESET_DB(1) | |
861 | S_008020_SOFT_RESET_CB(1) | |
1072 | S_008020_SOFT_RESET_CB(1) | |
862 | S_008020_SOFT_RESET_PA(1) | |
1073 | S_008020_SOFT_RESET_PA(1) | |
Line 867... | Line 1078... | ||
867 | S_008020_SOFT_RESET_SH(1) | |
1078 | S_008020_SOFT_RESET_SH(1) | |
868 | S_008020_SOFT_RESET_TC(1) | |
1079 | S_008020_SOFT_RESET_TC(1) | |
869 | S_008020_SOFT_RESET_TA(1) | |
1080 | S_008020_SOFT_RESET_TA(1) | |
870 | S_008020_SOFT_RESET_VC(1) | |
1081 | S_008020_SOFT_RESET_VC(1) | |
871 | S_008020_SOFT_RESET_VGT(1); |
1082 | S_008020_SOFT_RESET_VGT(1); |
872 | dev_info(rdev->dev, " R_008020_GRBM_SOFT_RESET=0x%08X\n", tmp); |
- | |
873 | WREG32(R_008020_GRBM_SOFT_RESET, tmp); |
- | |
874 | RREG32(R_008020_GRBM_SOFT_RESET); |
- | |
875 | mdelay(15); |
- | |
876 | WREG32(R_008020_GRBM_SOFT_RESET, 0); |
- | |
877 | } |
1083 | } |
878 | /* Reset CP (we always reset CP) */ |
- | |
879 | tmp = S_008020_SOFT_RESET_CP(1); |
- | |
880 | dev_info(rdev->dev, "R_008020_GRBM_SOFT_RESET=0x%08X\n", tmp); |
- | |
881 | WREG32(R_008020_GRBM_SOFT_RESET, tmp); |
- | |
882 | RREG32(R_008020_GRBM_SOFT_RESET); |
- | |
883 | mdelay(15); |
- | |
884 | WREG32(R_008020_GRBM_SOFT_RESET, 0); |
- | |
Line 885... | Line -... | ||
885 | - | ||
886 | dev_info(rdev->dev, " R_008010_GRBM_STATUS = 0x%08X\n", |
- | |
887 | RREG32(R_008010_GRBM_STATUS)); |
- | |
888 | dev_info(rdev->dev, " R_008014_GRBM_STATUS2 = 0x%08X\n", |
1084 | |
889 | RREG32(R_008014_GRBM_STATUS2)); |
- | |
890 | dev_info(rdev->dev, " R_000E50_SRBM_STATUS = 0x%08X\n", |
- | |
891 | RREG32(R_000E50_SRBM_STATUS)); |
- | |
892 | dev_info(rdev->dev, " R_008674_CP_STALLED_STAT1 = 0x%08X\n", |
- | |
893 | RREG32(CP_STALLED_STAT1)); |
1085 | if (reset_mask & RADEON_RESET_CP) { |
894 | dev_info(rdev->dev, " R_008678_CP_STALLED_STAT2 = 0x%08X\n", |
1086 | grbm_soft_reset |= S_008020_SOFT_RESET_CP(1) | |
895 | RREG32(CP_STALLED_STAT2)); |
- | |
896 | dev_info(rdev->dev, " R_00867C_CP_BUSY_STAT = 0x%08X\n", |
- | |
897 | RREG32(CP_BUSY_STAT)); |
- | |
898 | dev_info(rdev->dev, " R_008680_CP_STAT = 0x%08X\n", |
- | |
Line -... | Line 1087... | ||
- | 1087 | S_008020_SOFT_RESET_VGT(1); |
|
899 | RREG32(CP_STAT)); |
1088 | |
Line -... | Line 1089... | ||
- | 1089 | srbm_soft_reset |= S_000E60_SOFT_RESET_GRBM(1); |
|
- | 1090 | } |
|
900 | 1091 | ||
901 | } |
1092 | if (reset_mask & RADEON_RESET_DMA) { |
- | 1093 | if (rdev->family >= CHIP_RV770) |
|
902 | 1094 | srbm_soft_reset |= RV770_SOFT_RESET_DMA; |
|
Line 903... | Line 1095... | ||
903 | static void r600_gpu_soft_reset_dma(struct radeon_device *rdev) |
1095 | else |
904 | { |
1096 | srbm_soft_reset |= SOFT_RESET_DMA; |
Line 905... | Line 1097... | ||
905 | u32 tmp; |
1097 | } |
906 | 1098 | ||
Line 907... | Line -... | ||
907 | if (RREG32(DMA_STATUS_REG) & DMA_IDLE) |
- | |
908 | return; |
- | |
909 | 1099 | if (reset_mask & RADEON_RESET_RLC) |
|
910 | dev_info(rdev->dev, " R_00D034_DMA_STATUS_REG = 0x%08X\n", |
1100 | srbm_soft_reset |= S_000E60_SOFT_RESET_RLC(1); |
Line 911... | Line -... | ||
911 | RREG32(DMA_STATUS_REG)); |
- | |
912 | 1101 | ||
913 | /* Disable DMA */ |
1102 | if (reset_mask & RADEON_RESET_SEM) |
914 | tmp = RREG32(DMA_RB_CNTL); |
- | |
915 | tmp &= ~DMA_RB_ENABLE; |
- | |
916 | WREG32(DMA_RB_CNTL, tmp); |
- | |
917 | - | ||
918 | /* Reset dma */ |
- | |
Line 919... | Line 1103... | ||
919 | if (rdev->family >= CHIP_RV770) |
1103 | srbm_soft_reset |= S_000E60_SOFT_RESET_SEM(1); |
920 | WREG32(SRBM_SOFT_RESET, RV770_SOFT_RESET_DMA); |
1104 | |
- | 1105 | if (reset_mask & RADEON_RESET_IH) |
|
921 | else |
1106 | srbm_soft_reset |= S_000E60_SOFT_RESET_IH(1); |
Line 922... | Line 1107... | ||
922 | WREG32(SRBM_SOFT_RESET, SOFT_RESET_DMA); |
1107 | |
923 | RREG32(SRBM_SOFT_RESET); |
- | |
924 | udelay(50); |
1108 | if (reset_mask & RADEON_RESET_GRBM) |
Line 925... | Line 1109... | ||
925 | WREG32(SRBM_SOFT_RESET, 0); |
1109 | srbm_soft_reset |= S_000E60_SOFT_RESET_GRBM(1); |
- | 1110 | ||
926 | 1111 | if (!(rdev->flags & RADEON_IS_IGP)) { |
|
- | 1112 | if (reset_mask & RADEON_RESET_MC) |
|
- | 1113 | srbm_soft_reset |= S_000E60_SOFT_RESET_MC(1); |
|
- | 1114 | } |
|
Line 927... | Line 1115... | ||
927 | dev_info(rdev->dev, " R_00D034_DMA_STATUS_REG = 0x%08X\n", |
1115 | |
Line 928... | Line 1116... | ||
928 | RREG32(DMA_STATUS_REG)); |
1116 | if (reset_mask & RADEON_RESET_VMC) |
929 | } |
1117 | srbm_soft_reset |= S_000E60_SOFT_RESET_VMC(1); |
930 | 1118 | ||
931 | static int r600_gpu_soft_reset(struct radeon_device *rdev, u32 reset_mask) |
1119 | if (grbm_soft_reset) { |
Line -... | Line 1120... | ||
- | 1120 | tmp = RREG32(R_008020_GRBM_SOFT_RESET); |
|
932 | { |
1121 | tmp |= grbm_soft_reset; |
933 | struct rv515_mc_save save; |
1122 | dev_info(rdev->dev, "R_008020_GRBM_SOFT_RESET=0x%08X\n", tmp); |
- | 1123 | WREG32(R_008020_GRBM_SOFT_RESET, tmp); |
|
- | 1124 | tmp = RREG32(R_008020_GRBM_SOFT_RESET); |
|
- | 1125 | ||
Line -... | Line 1126... | ||
- | 1126 | udelay(50); |
|
- | 1127 | ||
- | 1128 | tmp &= ~grbm_soft_reset; |
|
934 | 1129 | WREG32(R_008020_GRBM_SOFT_RESET, tmp); |
|
935 | if (reset_mask == 0) |
1130 | tmp = RREG32(R_008020_GRBM_SOFT_RESET); |
- | 1131 | } |
|
Line 936... | Line 1132... | ||
936 | return 0; |
1132 | |
937 | 1133 | if (srbm_soft_reset) { |
|
Line 938... | Line 1134... | ||
938 | dev_info(rdev->dev, "GPU softreset: 0x%08X\n", reset_mask); |
1134 | tmp = RREG32(SRBM_SOFT_RESET); |
- | 1135 | tmp |= srbm_soft_reset; |
|
- | 1136 | dev_info(rdev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp); |
|
- | 1137 | WREG32(SRBM_SOFT_RESET, tmp); |
|
- | 1138 | tmp = RREG32(SRBM_SOFT_RESET); |
|
- | 1139 | ||
- | 1140 | udelay(50); |
|
- | 1141 | ||
- | 1142 | tmp &= ~srbm_soft_reset; |
|
- | 1143 | WREG32(SRBM_SOFT_RESET, tmp); |
|
- | 1144 | tmp = RREG32(SRBM_SOFT_RESET); |
|
- | 1145 | } |
|
- | 1146 | ||
- | 1147 | /* Wait a little for things to settle down */ |
|
- | 1148 | mdelay(1); |
|
- | 1149 | ||
- | 1150 | rv515_mc_resume(rdev, &save); |
|
- | 1151 | udelay(50); |
|
- | 1152 | ||
- | 1153 | r600_print_gpu_status_regs(rdev); |
|
- | 1154 | } |
|
- | 1155 | ||
939 | 1156 | int r600_asic_reset(struct radeon_device *rdev) |
|
940 | rv515_mc_stop(rdev, &save); |
1157 | { |
Line -... | Line 1158... | ||
- | 1158 | u32 reset_mask; |
|
- | 1159 | ||
- | 1160 | reset_mask = r600_gpu_check_soft_reset(rdev); |
|
- | 1161 | ||
- | 1162 | if (reset_mask) |
|
- | 1163 | r600_set_bios_scratch_engine_hung(rdev, true); |
|
- | 1164 | ||
- | 1165 | r600_gpu_soft_reset(rdev, reset_mask); |
|
- | 1166 | ||
941 | if (r600_mc_wait_for_idle(rdev)) { |
1167 | reset_mask = r600_gpu_check_soft_reset(rdev); |
942 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
1168 | |
943 | } |
1169 | if (!reset_mask) |
944 | - | ||
945 | if (reset_mask & (RADEON_RESET_GFX | RADEON_RESET_COMPUTE)) |
- | |
946 | r600_gpu_soft_reset_gfx(rdev); |
1170 | r600_set_bios_scratch_engine_hung(rdev, false); |
947 | 1171 | ||
948 | if (reset_mask & RADEON_RESET_DMA) |
1172 | return 0; |
949 | r600_gpu_soft_reset_dma(rdev); |
- | |
950 | 1173 | } |
|
951 | /* Wait a little for things to settle down */ |
1174 | |
952 | mdelay(1); |
1175 | /** |
953 | 1176 | * r600_gfx_is_lockup - Check if the GFX engine is locked up |
|
954 | rv515_mc_resume(rdev, &save); |
1177 | * |
955 | return 0; |
1178 | * @rdev: radeon_device pointer |
Line 977... | Line 1200... | ||
977 | * r600_dma_is_lockup - Check if the DMA engine is locked up |
1200 | * r600_dma_is_lockup - Check if the DMA engine is locked up |
978 | * |
1201 | * |
979 | * @rdev: radeon_device pointer |
1202 | * @rdev: radeon_device pointer |
980 | * @ring: radeon_ring structure holding ring information |
1203 | * @ring: radeon_ring structure holding ring information |
981 | * |
1204 | * |
982 | * Check if the async DMA engine is locked up (r6xx-evergreen). |
1205 | * Check if the async DMA engine is locked up. |
983 | * Returns true if the engine appears to be locked up, false if not. |
1206 | * Returns true if the engine appears to be locked up, false if not. |
984 | */ |
1207 | */ |
985 | bool r600_dma_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring) |
1208 | bool r600_dma_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring) |
986 | { |
1209 | { |
987 | u32 dma_status_reg; |
1210 | u32 reset_mask = r600_gpu_check_soft_reset(rdev); |
Line 988... | Line -... | ||
988 | - | ||
989 | dma_status_reg = RREG32(DMA_STATUS_REG); |
1211 | |
990 | if (dma_status_reg & DMA_IDLE) { |
1212 | if (!(reset_mask & RADEON_RESET_DMA)) { |
991 | radeon_ring_lockup_update(ring); |
1213 | radeon_ring_lockup_update(ring); |
992 | return false; |
1214 | return false; |
993 | } |
1215 | } |
994 | /* force ring activities */ |
1216 | /* force ring activities */ |
995 | radeon_ring_force_activity(rdev, ring); |
1217 | radeon_ring_force_activity(rdev, ring); |
996 | return radeon_ring_test_lockup(rdev, ring); |
1218 | return radeon_ring_test_lockup(rdev, ring); |
Line 997... | Line -... | ||
997 | } |
- | |
998 | - | ||
999 | int r600_asic_reset(struct radeon_device *rdev) |
- | |
1000 | { |
- | |
1001 | return r600_gpu_soft_reset(rdev, (RADEON_RESET_GFX | |
- | |
1002 | RADEON_RESET_COMPUTE | |
- | |
1003 | RADEON_RESET_DMA)); |
- | |
1004 | } |
1219 | } |
1005 | 1220 | ||
1006 | u32 r6xx_remap_render_backend(struct radeon_device *rdev, |
1221 | u32 r6xx_remap_render_backend(struct radeon_device *rdev, |
1007 | u32 tiling_pipe_num, |
1222 | u32 tiling_pipe_num, |
1008 | u32 max_rb_num, |
1223 | u32 max_rb_num, |
1009 | u32 total_max_rb_num, |
1224 | u32 total_max_rb_num, |
1010 | u32 disabled_rb_mask) |
1225 | u32 disabled_rb_mask) |
1011 | { |
1226 | { |
1012 | u32 rendering_pipe_num, rb_num_width, req_rb_num; |
1227 | u32 rendering_pipe_num, rb_num_width, req_rb_num; |
1013 | u32 pipe_rb_ratio, pipe_rb_remain; |
1228 | u32 pipe_rb_ratio, pipe_rb_remain, tmp; |
Line 1014... | Line 1229... | ||
1014 | u32 data = 0, mask = 1 << (max_rb_num - 1); |
1229 | u32 data = 0, mask = 1 << (max_rb_num - 1); |
1015 | unsigned i, j; |
1230 | unsigned i, j; |
- | 1231 | ||
- | 1232 | /* mask out the RBs that don't exist on that asic */ |
|
- | 1233 | tmp = disabled_rb_mask | ((0xff << max_rb_num) & 0xff); |
|
Line 1016... | Line 1234... | ||
1016 | 1234 | /* make sure at least one RB is available */ |
|
1017 | /* mask out the RBs that don't exist on that asic */ |
1235 | if ((tmp & 0xff) != 0xff) |
1018 | disabled_rb_mask |= (0xff << max_rb_num) & 0xff; |
1236 | disabled_rb_mask = tmp; |
Line 1859... | Line 2077... | ||
1859 | * Returns 0 for success, error for failure. |
2077 | * Returns 0 for success, error for failure. |
1860 | */ |
2078 | */ |
1861 | int r600_dma_resume(struct radeon_device *rdev) |
2079 | int r600_dma_resume(struct radeon_device *rdev) |
1862 | { |
2080 | { |
1863 | struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
2081 | struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
1864 | u32 rb_cntl, dma_cntl; |
2082 | u32 rb_cntl, dma_cntl, ib_cntl; |
1865 | u32 rb_bufsz; |
2083 | u32 rb_bufsz; |
1866 | int r; |
2084 | int r; |
Line 1867... | Line 2085... | ||
1867 | 2085 | ||
1868 | /* Reset dma */ |
2086 | /* Reset dma */ |
Line 1899... | Line 2117... | ||
1899 | rb_cntl |= DMA_RPTR_WRITEBACK_ENABLE; |
2117 | rb_cntl |= DMA_RPTR_WRITEBACK_ENABLE; |
Line 1900... | Line 2118... | ||
1900 | 2118 | ||
Line 1901... | Line 2119... | ||
1901 | WREG32(DMA_RB_BASE, ring->gpu_addr >> 8); |
2119 | WREG32(DMA_RB_BASE, ring->gpu_addr >> 8); |
- | 2120 | ||
- | 2121 | /* enable DMA IBs */ |
|
- | 2122 | ib_cntl = DMA_IB_ENABLE; |
|
- | 2123 | #ifdef __BIG_ENDIAN |
|
1902 | 2124 | ib_cntl |= DMA_IB_SWAP_ENABLE; |
|
Line 1903... | Line 2125... | ||
1903 | /* enable DMA IBs */ |
2125 | #endif |
1904 | WREG32(DMA_IB_CNTL, DMA_IB_ENABLE); |
2126 | WREG32(DMA_IB_CNTL, ib_cntl); |
1905 | 2127 | ||
Line 1942... | Line 2164... | ||
1942 | r600_dma_stop(rdev); |
2164 | r600_dma_stop(rdev); |
1943 | radeon_ring_fini(rdev, &rdev->ring[R600_RING_TYPE_DMA_INDEX]); |
2165 | radeon_ring_fini(rdev, &rdev->ring[R600_RING_TYPE_DMA_INDEX]); |
1944 | } |
2166 | } |
Line 1945... | Line 2167... | ||
1945 | 2167 | ||
- | 2168 | /* |
|
- | 2169 | * UVD |
|
- | 2170 | */ |
|
- | 2171 | int r600_uvd_rbc_start(struct radeon_device *rdev) |
|
- | 2172 | { |
|
- | 2173 | struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; |
|
- | 2174 | uint64_t rptr_addr; |
|
- | 2175 | uint32_t rb_bufsz, tmp; |
|
- | 2176 | int r; |
|
- | 2177 | ||
- | 2178 | rptr_addr = rdev->wb.gpu_addr + R600_WB_UVD_RPTR_OFFSET; |
|
- | 2179 | ||
- | 2180 | if (upper_32_bits(rptr_addr) != upper_32_bits(ring->gpu_addr)) { |
|
- | 2181 | DRM_ERROR("UVD ring and rptr not in the same 4GB segment!\n"); |
|
- | 2182 | return -EINVAL; |
|
- | 2183 | } |
|
- | 2184 | ||
- | 2185 | /* force RBC into idle state */ |
|
- | 2186 | WREG32(UVD_RBC_RB_CNTL, 0x11010101); |
|
- | 2187 | ||
- | 2188 | /* Set the write pointer delay */ |
|
- | 2189 | WREG32(UVD_RBC_RB_WPTR_CNTL, 0); |
|
- | 2190 | ||
- | 2191 | /* set the wb address */ |
|
- | 2192 | WREG32(UVD_RBC_RB_RPTR_ADDR, rptr_addr >> 2); |
|
- | 2193 | ||
- | 2194 | /* programm the 4GB memory segment for rptr and ring buffer */ |
|
- | 2195 | WREG32(UVD_LMI_EXT40_ADDR, upper_32_bits(rptr_addr) | |
|
- | 2196 | (0x7 << 16) | (0x1 << 31)); |
|
- | 2197 | ||
- | 2198 | /* Initialize the ring buffer's read and write pointers */ |
|
- | 2199 | WREG32(UVD_RBC_RB_RPTR, 0x0); |
|
- | 2200 | ||
- | 2201 | ring->wptr = ring->rptr = RREG32(UVD_RBC_RB_RPTR); |
|
- | 2202 | WREG32(UVD_RBC_RB_WPTR, ring->wptr); |
|
- | 2203 | ||
- | 2204 | /* set the ring address */ |
|
- | 2205 | WREG32(UVD_RBC_RB_BASE, ring->gpu_addr); |
|
- | 2206 | ||
- | 2207 | /* Set ring buffer size */ |
|
- | 2208 | rb_bufsz = drm_order(ring->ring_size); |
|
- | 2209 | rb_bufsz = (0x1 << 8) | rb_bufsz; |
|
- | 2210 | WREG32(UVD_RBC_RB_CNTL, rb_bufsz); |
|
- | 2211 | ||
- | 2212 | ring->ready = true; |
|
- | 2213 | r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring); |
|
- | 2214 | if (r) { |
|
- | 2215 | ring->ready = false; |
|
- | 2216 | return r; |
|
- | 2217 | } |
|
- | 2218 | ||
- | 2219 | r = radeon_ring_lock(rdev, ring, 10); |
|
- | 2220 | if (r) { |
|
- | 2221 | DRM_ERROR("radeon: ring failed to lock UVD ring (%d).\n", r); |
|
- | 2222 | return r; |
|
- | 2223 | } |
|
- | 2224 | ||
- | 2225 | tmp = PACKET0(UVD_SEMA_WAIT_FAULT_TIMEOUT_CNTL, 0); |
|
- | 2226 | radeon_ring_write(ring, tmp); |
|
- | 2227 | radeon_ring_write(ring, 0xFFFFF); |
|
- | 2228 | ||
- | 2229 | tmp = PACKET0(UVD_SEMA_WAIT_INCOMPLETE_TIMEOUT_CNTL, 0); |
|
- | 2230 | radeon_ring_write(ring, tmp); |
|
- | 2231 | radeon_ring_write(ring, 0xFFFFF); |
|
- | 2232 | ||
- | 2233 | tmp = PACKET0(UVD_SEMA_SIGNAL_INCOMPLETE_TIMEOUT_CNTL, 0); |
|
- | 2234 | radeon_ring_write(ring, tmp); |
|
- | 2235 | radeon_ring_write(ring, 0xFFFFF); |
|
- | 2236 | ||
- | 2237 | /* Clear timeout status bits */ |
|
- | 2238 | radeon_ring_write(ring, PACKET0(UVD_SEMA_TIMEOUT_STATUS, 0)); |
|
- | 2239 | radeon_ring_write(ring, 0x8); |
|
- | 2240 | ||
- | 2241 | radeon_ring_write(ring, PACKET0(UVD_SEMA_CNTL, 0)); |
|
- | 2242 | radeon_ring_write(ring, 3); |
|
- | 2243 | ||
- | 2244 | radeon_ring_unlock_commit(rdev, ring); |
|
- | 2245 | ||
- | 2246 | return 0; |
|
- | 2247 | } |
|
- | 2248 | ||
- | 2249 | void r600_uvd_rbc_stop(struct radeon_device *rdev) |
|
- | 2250 | { |
|
- | 2251 | struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; |
|
- | 2252 | ||
- | 2253 | /* force RBC into idle state */ |
|
- | 2254 | WREG32(UVD_RBC_RB_CNTL, 0x11010101); |
|
- | 2255 | ring->ready = false; |
|
- | 2256 | } |
|
- | 2257 | ||
- | 2258 | int r600_uvd_init(struct radeon_device *rdev) |
|
- | 2259 | { |
|
- | 2260 | int i, j, r; |
|
- | 2261 | /* disable byte swapping */ |
|
- | 2262 | u32 lmi_swap_cntl = 0; |
|
- | 2263 | u32 mp_swap_cntl = 0; |
|
- | 2264 | ||
- | 2265 | /* raise clocks while booting up the VCPU */ |
|
- | 2266 | radeon_set_uvd_clocks(rdev, 53300, 40000); |
|
- | 2267 | ||
- | 2268 | /* disable clock gating */ |
|
- | 2269 | WREG32(UVD_CGC_GATE, 0); |
|
- | 2270 | ||
- | 2271 | /* disable interupt */ |
|
- | 2272 | WREG32_P(UVD_MASTINT_EN, 0, ~(1 << 1)); |
|
- | 2273 | ||
- | 2274 | /* put LMI, VCPU, RBC etc... into reset */ |
|
- | 2275 | WREG32(UVD_SOFT_RESET, LMI_SOFT_RESET | VCPU_SOFT_RESET | |
|
- | 2276 | LBSI_SOFT_RESET | RBC_SOFT_RESET | CSM_SOFT_RESET | |
|
- | 2277 | CXW_SOFT_RESET | TAP_SOFT_RESET | LMI_UMC_SOFT_RESET); |
|
- | 2278 | mdelay(5); |
|
- | 2279 | ||
- | 2280 | /* take UVD block out of reset */ |
|
- | 2281 | WREG32_P(SRBM_SOFT_RESET, 0, ~SOFT_RESET_UVD); |
|
- | 2282 | mdelay(5); |
|
- | 2283 | ||
- | 2284 | /* initialize UVD memory controller */ |
|
- | 2285 | WREG32(UVD_LMI_CTRL, 0x40 | (1 << 8) | (1 << 13) | |
|
- | 2286 | (1 << 21) | (1 << 9) | (1 << 20)); |
|
- | 2287 | ||
- | 2288 | #ifdef __BIG_ENDIAN |
|
- | 2289 | /* swap (8 in 32) RB and IB */ |
|
- | 2290 | lmi_swap_cntl = 0xa; |
|
- | 2291 | mp_swap_cntl = 0; |
|
- | 2292 | #endif |
|
- | 2293 | WREG32(UVD_LMI_SWAP_CNTL, lmi_swap_cntl); |
|
- | 2294 | WREG32(UVD_MP_SWAP_CNTL, mp_swap_cntl); |
|
- | 2295 | ||
- | 2296 | WREG32(UVD_MPC_SET_MUXA0, 0x40c2040); |
|
- | 2297 | WREG32(UVD_MPC_SET_MUXA1, 0x0); |
|
- | 2298 | WREG32(UVD_MPC_SET_MUXB0, 0x40c2040); |
|
- | 2299 | WREG32(UVD_MPC_SET_MUXB1, 0x0); |
|
- | 2300 | WREG32(UVD_MPC_SET_ALU, 0); |
|
- | 2301 | WREG32(UVD_MPC_SET_MUX, 0x88); |
|
- | 2302 | ||
- | 2303 | /* Stall UMC */ |
|
- | 2304 | WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8)); |
|
- | 2305 | WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3)); |
|
- | 2306 | ||
- | 2307 | /* take all subblocks out of reset, except VCPU */ |
|
- | 2308 | WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET); |
|
- | 2309 | mdelay(5); |
|
- | 2310 | ||
- | 2311 | /* enable VCPU clock */ |
|
- | 2312 | WREG32(UVD_VCPU_CNTL, 1 << 9); |
|
- | 2313 | ||
- | 2314 | /* enable UMC */ |
|
- | 2315 | WREG32_P(UVD_LMI_CTRL2, 0, ~(1 << 8)); |
|
- | 2316 | ||
- | 2317 | /* boot up the VCPU */ |
|
- | 2318 | WREG32(UVD_SOFT_RESET, 0); |
|
- | 2319 | mdelay(10); |
|
- | 2320 | ||
- | 2321 | WREG32_P(UVD_RB_ARB_CTRL, 0, ~(1 << 3)); |
|
- | 2322 | ||
- | 2323 | for (i = 0; i < 10; ++i) { |
|
- | 2324 | uint32_t status; |
|
- | 2325 | for (j = 0; j < 100; ++j) { |
|
- | 2326 | status = RREG32(UVD_STATUS); |
|
- | 2327 | if (status & 2) |
|
- | 2328 | break; |
|
- | 2329 | mdelay(10); |
|
- | 2330 | } |
|
- | 2331 | r = 0; |
|
- | 2332 | if (status & 2) |
|
- | 2333 | break; |
|
- | 2334 | ||
- | 2335 | DRM_ERROR("UVD not responding, trying to reset the VCPU!!!\n"); |
|
- | 2336 | WREG32_P(UVD_SOFT_RESET, VCPU_SOFT_RESET, ~VCPU_SOFT_RESET); |
|
- | 2337 | mdelay(10); |
|
- | 2338 | WREG32_P(UVD_SOFT_RESET, 0, ~VCPU_SOFT_RESET); |
|
- | 2339 | mdelay(10); |
|
- | 2340 | r = -1; |
|
- | 2341 | } |
|
- | 2342 | ||
- | 2343 | if (r) { |
|
- | 2344 | DRM_ERROR("UVD not responding, giving up!!!\n"); |
|
- | 2345 | radeon_set_uvd_clocks(rdev, 0, 0); |
|
- | 2346 | return r; |
|
- | 2347 | } |
|
- | 2348 | ||
- | 2349 | /* enable interupt */ |
|
- | 2350 | WREG32_P(UVD_MASTINT_EN, 3<<1, ~(3 << 1)); |
|
- | 2351 | ||
- | 2352 | r = r600_uvd_rbc_start(rdev); |
|
- | 2353 | if (!r) |
|
- | 2354 | DRM_INFO("UVD initialized successfully.\n"); |
|
- | 2355 | ||
- | 2356 | /* lower clocks again */ |
|
- | 2357 | radeon_set_uvd_clocks(rdev, 0, 0); |
|
- | 2358 | ||
- | 2359 | return r; |
|
- | 2360 | } |
|
- | 2361 | ||
1946 | /* |
2362 | /* |
1947 | * GPU scratch registers helpers function. |
2363 | * GPU scratch registers helpers function. |
1948 | */ |
2364 | */ |
1949 | void r600_scratch_init(struct radeon_device *rdev) |
2365 | void r600_scratch_init(struct radeon_device *rdev) |
1950 | { |
2366 | { |
Line 2050... | Line 2466... | ||
2050 | r = -EINVAL; |
2466 | r = -EINVAL; |
2051 | } |
2467 | } |
2052 | return r; |
2468 | return r; |
2053 | } |
2469 | } |
Line -... | Line 2470... | ||
- | 2470 | ||
- | 2471 | int r600_uvd_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) |
|
- | 2472 | { |
|
- | 2473 | uint32_t tmp = 0; |
|
- | 2474 | unsigned i; |
|
- | 2475 | int r; |
|
- | 2476 | ||
- | 2477 | WREG32(UVD_CONTEXT_ID, 0xCAFEDEAD); |
|
- | 2478 | r = radeon_ring_lock(rdev, ring, 3); |
|
- | 2479 | if (r) { |
|
- | 2480 | DRM_ERROR("radeon: cp failed to lock ring %d (%d).\n", |
|
- | 2481 | ring->idx, r); |
|
- | 2482 | return r; |
|
- | 2483 | } |
|
- | 2484 | radeon_ring_write(ring, PACKET0(UVD_CONTEXT_ID, 0)); |
|
- | 2485 | radeon_ring_write(ring, 0xDEADBEEF); |
|
- | 2486 | radeon_ring_unlock_commit(rdev, ring); |
|
- | 2487 | for (i = 0; i < rdev->usec_timeout; i++) { |
|
- | 2488 | tmp = RREG32(UVD_CONTEXT_ID); |
|
- | 2489 | if (tmp == 0xDEADBEEF) |
|
- | 2490 | break; |
|
- | 2491 | DRM_UDELAY(1); |
|
- | 2492 | } |
|
- | 2493 | ||
- | 2494 | if (i < rdev->usec_timeout) { |
|
- | 2495 | DRM_INFO("ring test on %d succeeded in %d usecs\n", |
|
- | 2496 | ring->idx, i); |
|
- | 2497 | } else { |
|
- | 2498 | DRM_ERROR("radeon: ring %d test failed (0x%08X)\n", |
|
- | 2499 | ring->idx, tmp); |
|
- | 2500 | r = -EINVAL; |
|
- | 2501 | } |
|
- | 2502 | return r; |
|
- | 2503 | } |
|
2054 | 2504 | ||
2055 | /* |
2505 | /* |
2056 | * CP fences/semaphores |
2506 | * CP fences/semaphores |
Line 2057... | Line 2507... | ||
2057 | */ |
2507 | */ |
Line 2101... | Line 2551... | ||
2101 | radeon_ring_write(ring, PACKET0(CP_INT_STATUS, 0)); |
2551 | radeon_ring_write(ring, PACKET0(CP_INT_STATUS, 0)); |
2102 | radeon_ring_write(ring, RB_INT_STAT); |
2552 | radeon_ring_write(ring, RB_INT_STAT); |
2103 | } |
2553 | } |
2104 | } |
2554 | } |
Line -... | Line 2555... | ||
- | 2555 | ||
- | 2556 | void r600_uvd_fence_emit(struct radeon_device *rdev, |
|
- | 2557 | struct radeon_fence *fence) |
|
- | 2558 | { |
|
- | 2559 | struct radeon_ring *ring = &rdev->ring[fence->ring]; |
|
- | 2560 | uint32_t addr = rdev->fence_drv[fence->ring].gpu_addr; |
|
- | 2561 | ||
- | 2562 | radeon_ring_write(ring, PACKET0(UVD_CONTEXT_ID, 0)); |
|
- | 2563 | radeon_ring_write(ring, fence->seq); |
|
- | 2564 | radeon_ring_write(ring, PACKET0(UVD_GPCOM_VCPU_DATA0, 0)); |
|
- | 2565 | radeon_ring_write(ring, addr & 0xffffffff); |
|
- | 2566 | radeon_ring_write(ring, PACKET0(UVD_GPCOM_VCPU_DATA1, 0)); |
|
- | 2567 | radeon_ring_write(ring, upper_32_bits(addr) & 0xff); |
|
- | 2568 | radeon_ring_write(ring, PACKET0(UVD_GPCOM_VCPU_CMD, 0)); |
|
- | 2569 | radeon_ring_write(ring, 0); |
|
- | 2570 | ||
- | 2571 | radeon_ring_write(ring, PACKET0(UVD_GPCOM_VCPU_DATA0, 0)); |
|
- | 2572 | radeon_ring_write(ring, 0); |
|
- | 2573 | radeon_ring_write(ring, PACKET0(UVD_GPCOM_VCPU_DATA1, 0)); |
|
- | 2574 | radeon_ring_write(ring, 0); |
|
- | 2575 | radeon_ring_write(ring, PACKET0(UVD_GPCOM_VCPU_CMD, 0)); |
|
- | 2576 | radeon_ring_write(ring, 2); |
|
- | 2577 | return; |
|
- | 2578 | } |
|
2105 | 2579 | ||
2106 | void r600_semaphore_ring_emit(struct radeon_device *rdev, |
2580 | void r600_semaphore_ring_emit(struct radeon_device *rdev, |
2107 | struct radeon_ring *ring, |
2581 | struct radeon_ring *ring, |
2108 | struct radeon_semaphore *semaphore, |
2582 | struct radeon_semaphore *semaphore, |
2109 | bool emit_wait) |
2583 | bool emit_wait) |
Line 2170... | Line 2644... | ||
2170 | radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_SEMAPHORE, 0, s, 0)); |
2644 | radeon_ring_write(ring, DMA_PACKET(DMA_PACKET_SEMAPHORE, 0, s, 0)); |
2171 | radeon_ring_write(ring, addr & 0xfffffffc); |
2645 | radeon_ring_write(ring, addr & 0xfffffffc); |
2172 | radeon_ring_write(ring, upper_32_bits(addr) & 0xff); |
2646 | radeon_ring_write(ring, upper_32_bits(addr) & 0xff); |
2173 | } |
2647 | } |
Line -... | Line 2648... | ||
- | 2648 | ||
- | 2649 | void r600_uvd_semaphore_emit(struct radeon_device *rdev, |
|
- | 2650 | struct radeon_ring *ring, |
|
- | 2651 | struct radeon_semaphore *semaphore, |
|
- | 2652 | bool emit_wait) |
|
- | 2653 | { |
|
- | 2654 | uint64_t addr = semaphore->gpu_addr; |
|
- | 2655 | ||
- | 2656 | radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0)); |
|
- | 2657 | radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF); |
|
- | 2658 | ||
- | 2659 | radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0)); |
|
- | 2660 | radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF); |
|
- | 2661 | ||
- | 2662 | radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0)); |
|
- | 2663 | radeon_ring_write(ring, emit_wait ? 1 : 0); |
|
- | 2664 | } |
|
2174 | 2665 | ||
2175 | int r600_copy_blit(struct radeon_device *rdev, |
2666 | int r600_copy_blit(struct radeon_device *rdev, |
2176 | uint64_t src_offset, |
2667 | uint64_t src_offset, |
2177 | uint64_t dst_offset, |
2668 | uint64_t dst_offset, |
2178 | unsigned num_gpu_pages, |
2669 | unsigned num_gpu_pages, |
Line 2292... | Line 2783... | ||
2292 | DRM_ERROR("Failed to load firmware!\n"); |
2783 | DRM_ERROR("Failed to load firmware!\n"); |
2293 | return r; |
2784 | return r; |
2294 | } |
2785 | } |
2295 | } |
2786 | } |
Line -... | Line 2787... | ||
- | 2787 | ||
- | 2788 | r = r600_vram_scratch_init(rdev); |
|
- | 2789 | if (r) |
|
- | 2790 | return r; |
|
2296 | 2791 | ||
2297 | r600_mc_program(rdev); |
2792 | r600_mc_program(rdev); |
2298 | if (rdev->flags & RADEON_IS_AGP) { |
2793 | if (rdev->flags & RADEON_IS_AGP) { |
2299 | r600_agp_enable(rdev); |
2794 | r600_agp_enable(rdev); |
2300 | } else { |
2795 | } else { |
Line 2326... | Line 2821... | ||
2326 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
2821 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
2327 | return r; |
2822 | return r; |
2328 | } |
2823 | } |
Line 2329... | Line 2824... | ||
2329 | 2824 | ||
- | 2825 | /* Enable IRQ */ |
|
- | 2826 | if (!rdev->irq.installed) { |
|
- | 2827 | r = radeon_irq_kms_init(rdev); |
|
- | 2828 | if (r) |
|
- | 2829 | return r; |
|
- | 2830 | } |
|
2330 | /* Enable IRQ */ |
2831 | |
2331 | r = r600_irq_init(rdev); |
2832 | r = r600_irq_init(rdev); |
2332 | if (r) { |
2833 | if (r) { |
2333 | DRM_ERROR("radeon: IH init failed (%d).\n", r); |
2834 | DRM_ERROR("radeon: IH init failed (%d).\n", r); |
2334 | // radeon_irq_kms_fini(rdev); |
2835 | // radeon_irq_kms_fini(rdev); |
Line 2443... | Line 2944... | ||
2443 | /* Memory manager */ |
2944 | /* Memory manager */ |
2444 | r = radeon_bo_init(rdev); |
2945 | r = radeon_bo_init(rdev); |
2445 | if (r) |
2946 | if (r) |
2446 | return r; |
2947 | return r; |
Line 2447... | Line -... | ||
2447 | - | ||
2448 | r = radeon_irq_kms_init(rdev); |
- | |
2449 | if (r) |
- | |
2450 | return r; |
- | |
2451 | 2948 | ||
2452 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ring_obj = NULL; |
2949 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ring_obj = NULL; |
Line 2453... | Line 2950... | ||
2453 | r600_ring_init(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX], 1024 * 1024); |
2950 | r600_ring_init(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX], 1024 * 1024); |
2454 | 2951 | ||
Line 2504... | Line 3001... | ||
2504 | (ib->gpu_addr & 0xFFFFFFFC)); |
3001 | (ib->gpu_addr & 0xFFFFFFFC)); |
2505 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFF); |
3002 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFF); |
2506 | radeon_ring_write(ring, ib->length_dw); |
3003 | radeon_ring_write(ring, ib->length_dw); |
2507 | } |
3004 | } |
Line -... | Line 3005... | ||
- | 3005 | ||
- | 3006 | void r600_uvd_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) |
|
- | 3007 | { |
|
- | 3008 | struct radeon_ring *ring = &rdev->ring[ib->ring]; |
|
- | 3009 | ||
- | 3010 | radeon_ring_write(ring, PACKET0(UVD_RBC_IB_BASE, 0)); |
|
- | 3011 | radeon_ring_write(ring, ib->gpu_addr); |
|
- | 3012 | radeon_ring_write(ring, PACKET0(UVD_RBC_IB_SIZE, 0)); |
|
- | 3013 | radeon_ring_write(ring, ib->length_dw); |
|
- | 3014 | } |
|
2508 | 3015 | ||
2509 | int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) |
3016 | int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) |
2510 | { |
3017 | { |
2511 | struct radeon_ib ib; |
3018 | struct radeon_ib ib; |
2512 | uint32_t scratch; |
3019 | uint32_t scratch; |
Line 2574... | Line 3081... | ||
2574 | unsigned i; |
3081 | unsigned i; |
2575 | int r; |
3082 | int r; |
2576 | void __iomem *ptr = (void *)rdev->vram_scratch.ptr; |
3083 | void __iomem *ptr = (void *)rdev->vram_scratch.ptr; |
2577 | u32 tmp = 0; |
3084 | u32 tmp = 0; |
Line 2578... | Line -... | ||
2578 | - | ||
2579 | ENTER(); |
- | |
2580 | 3085 | ||
2581 | if (!ptr) { |
3086 | if (!ptr) { |
2582 | DRM_ERROR("invalid vram scratch pointer\n"); |
3087 | DRM_ERROR("invalid vram scratch pointer\n"); |
2583 | return -EINVAL; |
3088 | return -EINVAL; |
Line 2620... | Line 3125... | ||
2620 | } else { |
3125 | } else { |
2621 | DRM_ERROR("radeon: ib test failed (0x%08X)\n", tmp); |
3126 | DRM_ERROR("radeon: ib test failed (0x%08X)\n", tmp); |
2622 | r = -EINVAL; |
3127 | r = -EINVAL; |
2623 | } |
3128 | } |
2624 | radeon_ib_free(rdev, &ib); |
3129 | radeon_ib_free(rdev, &ib); |
- | 3130 | return r; |
|
- | 3131 | } |
|
- | 3132 | ||
- | 3133 | int r600_uvd_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) |
|
- | 3134 | { |
|
- | 3135 | struct radeon_fence *fence = NULL; |
|
- | 3136 | int r; |
|
Line -... | Line 3137... | ||
- | 3137 | ||
- | 3138 | r = radeon_set_uvd_clocks(rdev, 53300, 40000); |
|
- | 3139 | if (r) { |
|
- | 3140 | DRM_ERROR("radeon: failed to raise UVD clocks (%d).\n", r); |
|
- | 3141 | return r; |
|
- | 3142 | } |
|
- | 3143 | ||
2625 | 3144 | // r = radeon_uvd_get_create_msg(rdev, ring->idx, 1, NULL); |
|
- | 3145 | if (r) { |
|
- | 3146 | DRM_ERROR("radeon: failed to get create msg (%d).\n", r); |
|
- | 3147 | goto error; |
|
Line -... | Line 3148... | ||
- | 3148 | } |
|
- | 3149 | ||
- | 3150 | // r = radeon_uvd_get_destroy_msg(rdev, ring->idx, 1, &fence); |
|
- | 3151 | if (r) { |
|
- | 3152 | DRM_ERROR("radeon: failed to get destroy ib (%d).\n", r); |
|
- | 3153 | goto error; |
|
- | 3154 | } |
|
- | 3155 | ||
- | 3156 | r = radeon_fence_wait(fence, false); |
|
- | 3157 | if (r) { |
|
- | 3158 | DRM_ERROR("radeon: fence wait failed (%d).\n", r); |
|
- | 3159 | goto error; |
|
- | 3160 | } |
|
- | 3161 | DRM_INFO("ib test on ring %d succeeded\n", ring->idx); |
|
- | 3162 | error: |
|
2626 | LEAVE(); |
3163 | radeon_fence_unref(&fence); |
2627 | 3164 | radeon_set_uvd_clocks(rdev, 0, 0); |
|
Line 2628... | Line 3165... | ||
2628 | return r; |
3165 | return r; |
2629 | } |
3166 | } |
Line 3281... | Line 3818... | ||
3281 | * 233 - GUI Idle |
3818 | * 233 - GUI Idle |
3282 | * |
3819 | * |
3283 | * Note, these are based on r600 and may need to be |
3820 | * Note, these are based on r600 and may need to be |
3284 | * adjusted or added to on newer asics |
3821 | * adjusted or added to on newer asics |
3285 | */ |
3822 | */ |
3286 | - | ||
- | 3823 | #undef DRM_DEBUG |
|
3287 | #define DRM_DEBUG(...) |
3824 | #define DRM_DEBUG(...) |
Line 3288... | Line 3825... | ||
3288 | 3825 | ||
3289 | int r600_irq_process(struct radeon_device *rdev) |
3826 | int r600_irq_process(struct radeon_device *rdev) |
3290 | { |
3827 | { |
Line 3543... | Line 4080... | ||
3543 | WREG32(R_005480_HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1); |
4080 | WREG32(R_005480_HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1); |
3544 | } |
4081 | } |
Line 3545... | Line 4082... | ||
3545 | 4082 | ||
3546 | void r600_set_pcie_lanes(struct radeon_device *rdev, int lanes) |
4083 | void r600_set_pcie_lanes(struct radeon_device *rdev, int lanes) |
3547 | { |
4084 | { |
Line 3548... | Line 4085... | ||
3548 | u32 link_width_cntl, mask, target_reg; |
4085 | u32 link_width_cntl, mask; |
3549 | 4086 | ||
Line 3550... | Line 4087... | ||
3550 | if (rdev->flags & RADEON_IS_IGP) |
4087 | if (rdev->flags & RADEON_IS_IGP) |
Line 3555... | Line 4092... | ||
3555 | 4092 | ||
3556 | /* x2 cards have a special sequence */ |
4093 | /* x2 cards have a special sequence */ |
3557 | if (ASIC_IS_X2(rdev)) |
4094 | if (ASIC_IS_X2(rdev)) |
Line 3558... | Line 4095... | ||
3558 | return; |
4095 | return; |
Line 3559... | Line 4096... | ||
3559 | 4096 | ||
3560 | /* FIXME wait for idle */ |
4097 | radeon_gui_idle(rdev); |
3561 | 4098 | ||
3562 | switch (lanes) { |
4099 | switch (lanes) { |
Line 3574... | Line 4111... | ||
3574 | break; |
4111 | break; |
3575 | case 8: |
4112 | case 8: |
3576 | mask = RADEON_PCIE_LC_LINK_WIDTH_X8; |
4113 | mask = RADEON_PCIE_LC_LINK_WIDTH_X8; |
3577 | break; |
4114 | break; |
3578 | case 12: |
4115 | case 12: |
- | 4116 | /* not actually supported */ |
|
3579 | mask = RADEON_PCIE_LC_LINK_WIDTH_X12; |
4117 | mask = RADEON_PCIE_LC_LINK_WIDTH_X12; |
3580 | break; |
4118 | break; |
3581 | case 16: |
4119 | case 16: |
3582 | default: |
- | |
3583 | mask = RADEON_PCIE_LC_LINK_WIDTH_X16; |
4120 | mask = RADEON_PCIE_LC_LINK_WIDTH_X16; |
3584 | break; |
4121 | break; |
3585 | } |
- | |
3586 | - | ||
3587 | link_width_cntl = RREG32_PCIE_P(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
- | |
3588 | - | ||
3589 | if ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) == |
- | |
3590 | (mask << RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT)) |
- | |
3591 | return; |
4122 | default: |
3592 | - | ||
3593 | if (link_width_cntl & R600_PCIE_LC_UPCONFIGURE_DIS) |
4123 | DRM_ERROR("invalid pcie lane request: %d\n", lanes); |
3594 | return; |
4124 | return; |
- | 4125 | } |
|
Line -... | Line 4126... | ||
- | 4126 | ||
3595 | 4127 | link_width_cntl = RREG32_PCIE_PORT(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
|
3596 | link_width_cntl &= ~(RADEON_PCIE_LC_LINK_WIDTH_MASK | |
4128 | link_width_cntl &= ~RADEON_PCIE_LC_LINK_WIDTH_MASK; |
3597 | RADEON_PCIE_LC_RECONFIG_NOW | |
4129 | link_width_cntl |= mask << RADEON_PCIE_LC_LINK_WIDTH_SHIFT; |
3598 | R600_PCIE_LC_RENEGOTIATE_EN | |
4130 | link_width_cntl |= (RADEON_PCIE_LC_RECONFIG_NOW | |
3599 | R600_PCIE_LC_RECONFIG_ARC_MISSING_ESCAPE); |
- | |
3600 | link_width_cntl |= mask; |
- | |
3601 | - | ||
3602 | WREG32_PCIE_P(RADEON_PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
- | |
3603 | - | ||
3604 | /* some northbridges can renegotiate the link rather than requiring |
- | |
3605 | * a complete re-config. |
- | |
3606 | * e.g., AMD 780/790 northbridges (pci ids: 0x5956, 0x5957, 0x5958, etc.) |
- | |
3607 | */ |
- | |
3608 | if (link_width_cntl & R600_PCIE_LC_RENEGOTIATION_SUPPORT) |
- | |
3609 | link_width_cntl |= R600_PCIE_LC_RENEGOTIATE_EN | R600_PCIE_LC_UPCONFIGURE_SUPPORT; |
- | |
3610 | else |
- | |
3611 | link_width_cntl |= R600_PCIE_LC_RECONFIG_ARC_MISSING_ESCAPE; |
- | |
3612 | - | ||
3613 | WREG32_PCIE_P(RADEON_PCIE_LC_LINK_WIDTH_CNTL, (link_width_cntl | |
- | |
3614 | RADEON_PCIE_LC_RECONFIG_NOW)); |
- | |
3615 | - | ||
3616 | if (rdev->family >= CHIP_RV770) |
- | |
3617 | target_reg = R700_TARGET_AND_CURRENT_PROFILE_INDEX; |
- | |
3618 | else |
- | |
3619 | target_reg = R600_TARGET_AND_CURRENT_PROFILE_INDEX; |
- | |
3620 | - | ||
3621 | /* wait for lane set to complete */ |
- | |
3622 | link_width_cntl = RREG32(target_reg); |
- | |
3623 | while (link_width_cntl == 0xffffffff) |
- | |
Line -... | Line 4131... | ||
- | 4131 | R600_PCIE_LC_RECONFIG_ARC_MISSING_ESCAPE); |
|
3624 | link_width_cntl = RREG32(target_reg); |
4132 | |
Line 3625... | Line 4133... | ||
3625 | 4133 | WREG32_PCIE_PORT(RADEON_PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
|
3626 | } |
4134 | } |
3627 | 4135 | ||
Line 3637... | Line 4145... | ||
3637 | 4145 | ||
3638 | /* x2 cards have a special sequence */ |
4146 | /* x2 cards have a special sequence */ |
3639 | if (ASIC_IS_X2(rdev)) |
4147 | if (ASIC_IS_X2(rdev)) |
Line 3640... | Line 4148... | ||
3640 | return 0; |
4148 | return 0; |
Line 3641... | Line 4149... | ||
3641 | 4149 | ||
Line 3642... | Line 4150... | ||
3642 | /* FIXME wait for idle */ |
4150 | radeon_gui_idle(rdev); |
3643 | - | ||
3644 | link_width_cntl = RREG32_PCIE_P(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
- | |
3645 | 4151 | ||
3646 | switch ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) >> RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT) { |
4152 | link_width_cntl = RREG32_PCIE_PORT(RADEON_PCIE_LC_LINK_WIDTH_CNTL); |
3647 | case RADEON_PCIE_LC_LINK_WIDTH_X0: |
4153 | |
3648 | return 0; |
4154 | switch ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) >> RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT) { |
3649 | case RADEON_PCIE_LC_LINK_WIDTH_X1: |
4155 | case RADEON_PCIE_LC_LINK_WIDTH_X1: |
3650 | return 1; |
4156 | return 1; |
3651 | case RADEON_PCIE_LC_LINK_WIDTH_X2: |
4157 | case RADEON_PCIE_LC_LINK_WIDTH_X2: |
3652 | return 2; |
4158 | return 2; |
- | 4159 | case RADEON_PCIE_LC_LINK_WIDTH_X4: |
|
- | 4160 | return 4; |
|
- | 4161 | case RADEON_PCIE_LC_LINK_WIDTH_X8: |
|
- | 4162 | return 8; |
|
3653 | case RADEON_PCIE_LC_LINK_WIDTH_X4: |
4163 | case RADEON_PCIE_LC_LINK_WIDTH_X12: |
3654 | return 4; |
4164 | /* not actually supported */ |
3655 | case RADEON_PCIE_LC_LINK_WIDTH_X8: |
4165 | return 12; |
3656 | return 8; |
4166 | case RADEON_PCIE_LC_LINK_WIDTH_X0: |
3657 | case RADEON_PCIE_LC_LINK_WIDTH_X16: |
4167 | case RADEON_PCIE_LC_LINK_WIDTH_X16: |
Line 3658... | Line 4168... | ||
3658 | default: |
4168 | default: |
3659 | return 16; |
4169 | return 16; |
3660 | } |
4170 | } |
3661 | } |
4171 | } |
3662 | - | ||
3663 | static void r600_pcie_gen2_enable(struct radeon_device *rdev) |
- | |
Line 3664... | Line 4172... | ||
3664 | { |
4172 | |
3665 | u32 link_width_cntl, lanes, speed_cntl, training_cntl, tmp; |
4173 | static void r600_pcie_gen2_enable(struct radeon_device *rdev) |
Line 3666... | Line 4174... | ||
3666 | u16 link_cntl2; |
4174 | { |
Line 3682... | Line 4190... | ||
3682 | 4190 | ||
3683 | /* only RV6xx+ chips are supported */ |
4191 | /* only RV6xx+ chips are supported */ |
3684 | if (rdev->family <= CHIP_R600) |
4192 | if (rdev->family <= CHIP_R600) |
Line 3685... | Line 4193... | ||
3685 | return; |
4193 | return; |
3686 | - | ||
3687 | ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask); |
- | |
3688 | if (ret != 0) |
- | |
3689 | return; |
4194 | |
3690 | 4195 | if ((rdev->pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) && |
|
Line 3691... | Line 4196... | ||
3691 | if (!(mask & DRM_PCIE_SPEED_50)) |
4196 | (rdev->pdev->bus->max_bus_speed != PCIE_SPEED_8_0GT)) |
3692 | return; |
4197 | return; |
3693 | 4198 | ||
3694 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
4199 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
3695 | if (speed_cntl & LC_CURRENT_DATA_RATE) { |
4200 | if (speed_cntl & LC_CURRENT_DATA_RATE) { |
Line 3702... | Line 4207... | ||
3702 | /* 55 nm r6xx asics */ |
4207 | /* 55 nm r6xx asics */ |
3703 | if ((rdev->family == CHIP_RV670) || |
4208 | if ((rdev->family == CHIP_RV670) || |
3704 | (rdev->family == CHIP_RV620) || |
4209 | (rdev->family == CHIP_RV620) || |
3705 | (rdev->family == CHIP_RV635)) { |
4210 | (rdev->family == CHIP_RV635)) { |
3706 | /* advertise upconfig capability */ |
4211 | /* advertise upconfig capability */ |
3707 | link_width_cntl = RREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL); |
4212 | link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
3708 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
4213 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
3709 | WREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
4214 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
3710 | link_width_cntl = RREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL); |
4215 | link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
3711 | if (link_width_cntl & LC_RENEGOTIATION_SUPPORT) { |
4216 | if (link_width_cntl & LC_RENEGOTIATION_SUPPORT) { |
3712 | lanes = (link_width_cntl & LC_LINK_WIDTH_RD_MASK) >> LC_LINK_WIDTH_RD_SHIFT; |
4217 | lanes = (link_width_cntl & LC_LINK_WIDTH_RD_MASK) >> LC_LINK_WIDTH_RD_SHIFT; |
3713 | link_width_cntl &= ~(LC_LINK_WIDTH_MASK | |
4218 | link_width_cntl &= ~(LC_LINK_WIDTH_MASK | |
3714 | LC_RECONFIG_ARC_MISSING_ESCAPE); |
4219 | LC_RECONFIG_ARC_MISSING_ESCAPE); |
3715 | link_width_cntl |= lanes | LC_RECONFIG_NOW | LC_RENEGOTIATE_EN; |
4220 | link_width_cntl |= lanes | LC_RECONFIG_NOW | LC_RENEGOTIATE_EN; |
3716 | WREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
4221 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
3717 | } else { |
4222 | } else { |
3718 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
4223 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
3719 | WREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
4224 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
3720 | } |
4225 | } |
3721 | } |
4226 | } |
Line 3722... | Line 4227... | ||
3722 | 4227 | ||
3723 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
4228 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
3724 | if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) && |
4229 | if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) && |
Line 3725... | Line 4230... | ||
3725 | (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) { |
4230 | (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) { |
3726 | 4231 | ||
Line 3739... | Line 4244... | ||
3739 | speed_cntl &= ~LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_MASK; |
4244 | speed_cntl &= ~LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_MASK; |
3740 | speed_cntl |= (0x3 << LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_SHIFT); |
4245 | speed_cntl |= (0x3 << LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_SHIFT); |
3741 | speed_cntl &= ~LC_VOLTAGE_TIMER_SEL_MASK; |
4246 | speed_cntl &= ~LC_VOLTAGE_TIMER_SEL_MASK; |
3742 | speed_cntl &= ~LC_FORCE_DIS_HW_SPEED_CHANGE; |
4247 | speed_cntl &= ~LC_FORCE_DIS_HW_SPEED_CHANGE; |
3743 | speed_cntl |= LC_FORCE_EN_HW_SPEED_CHANGE; |
4248 | speed_cntl |= LC_FORCE_EN_HW_SPEED_CHANGE; |
3744 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
4249 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
Line 3745... | Line 4250... | ||
3745 | 4250 | ||
3746 | tmp = RREG32(0x541c); |
4251 | tmp = RREG32(0x541c); |
3747 | WREG32(0x541c, tmp | 0x8); |
4252 | WREG32(0x541c, tmp | 0x8); |
3748 | WREG32(MM_CFGREGS_CNTL, MM_WR_TO_CFG_EN); |
4253 | WREG32(MM_CFGREGS_CNTL, MM_WR_TO_CFG_EN); |
Line 3753... | Line 4258... | ||
3753 | WREG32(MM_CFGREGS_CNTL, 0); |
4258 | WREG32(MM_CFGREGS_CNTL, 0); |
Line 3754... | Line 4259... | ||
3754 | 4259 | ||
3755 | if ((rdev->family == CHIP_RV670) || |
4260 | if ((rdev->family == CHIP_RV670) || |
3756 | (rdev->family == CHIP_RV620) || |
4261 | (rdev->family == CHIP_RV620) || |
3757 | (rdev->family == CHIP_RV635)) { |
4262 | (rdev->family == CHIP_RV635)) { |
3758 | training_cntl = RREG32_PCIE_P(PCIE_LC_TRAINING_CNTL); |
4263 | training_cntl = RREG32_PCIE_PORT(PCIE_LC_TRAINING_CNTL); |
3759 | training_cntl &= ~LC_POINT_7_PLUS_EN; |
4264 | training_cntl &= ~LC_POINT_7_PLUS_EN; |
3760 | WREG32_PCIE_P(PCIE_LC_TRAINING_CNTL, training_cntl); |
4265 | WREG32_PCIE_PORT(PCIE_LC_TRAINING_CNTL, training_cntl); |
3761 | } else { |
4266 | } else { |
3762 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
4267 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
3763 | speed_cntl &= ~LC_TARGET_LINK_SPEED_OVERRIDE_EN; |
4268 | speed_cntl &= ~LC_TARGET_LINK_SPEED_OVERRIDE_EN; |
3764 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
4269 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
Line 3765... | Line 4270... | ||
3765 | } |
4270 | } |
3766 | 4271 | ||
3767 | speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL); |
4272 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
Line 3768... | Line 4273... | ||
3768 | speed_cntl |= LC_GEN2_EN_STRAP; |
4273 | speed_cntl |= LC_GEN2_EN_STRAP; |
3769 | WREG32_PCIE_P(PCIE_LC_SPEED_CNTL, speed_cntl); |
4274 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
3770 | 4275 | ||
3771 | } else { |
4276 | } else { |
3772 | link_width_cntl = RREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL); |
4277 | link_width_cntl = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
3773 | /* XXX: only disable it if gen1 bridge vendor == 0x111d or 0x1106 */ |
4278 | /* XXX: only disable it if gen1 bridge vendor == 0x111d or 0x1106 */ |
3774 | if (1) |
4279 | if (1) |
3775 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
4280 | link_width_cntl |= LC_UPCONFIGURE_DIS; |
3776 | else |
4281 | else |
3777 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
4282 | link_width_cntl &= ~LC_UPCONFIGURE_DIS; |
Line 3778... | Line 4283... | ||
3778 | WREG32_PCIE_P(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
4283 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl); |
3779 | } |
4284 | } |
3780 | } |
4285 | } |
3781 | 4286 | ||
3782 | /** |
4287 | /** |
3783 | * r600_get_gpu_clock - return GPU clock counter snapshot |
4288 | * r600_get_gpu_clock_counter - return GPU clock counter snapshot |
3784 | * |
4289 | * |
3785 | * @rdev: radeon_device pointer |
4290 | * @rdev: radeon_device pointer |
3786 | * |
4291 | * |
3787 | * Fetches a GPU clock counter snapshot (R6xx-cayman). |
4292 | * Fetches a GPU clock counter snapshot (R6xx-cayman). |
3788 | * Returns the 64 bit clock counter snapshot. |
4293 | * Returns the 64 bit clock counter snapshot. |
Line 3789... | Line 4294... | ||
3789 | */ |
4294 | */ |
3790 | uint64_t r600_get_gpu_clock(struct radeon_device *rdev) |
4295 | uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev) |