Query to find out how many compute units on a GPU. Useful for OpenCL usermode drivers.
Unified · Split
| @@ -80,6 +80,7 @@ extern int sumo_rlc_init(struct radeon_device *rdev); · 79 unmodified lines | |||
| 80 | extern void si_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); | 80 | extern void si_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
| 81 | extern void si_rlc_reset(struct radeon_device *rdev); | 81 | extern void si_rlc_reset(struct radeon_device *rdev); |
| 82 | extern void si_init_uvd_internal_cg(struct radeon_device *rdev); | 82 | extern void si_init_uvd_internal_cg(struct radeon_device *rdev); |
| 83 | static u32 cik_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh); | ||
| 83 | extern int cik_sdma_resume(struct radeon_device *rdev); | 84 | extern int cik_sdma_resume(struct radeon_device *rdev); |
| 84 | extern void cik_sdma_enable(struct radeon_device *rdev, bool enable); | 85 | extern void cik_sdma_enable(struct radeon_device *rdev, bool enable); |
| 85 | extern void cik_sdma_fini(struct radeon_device *rdev); | 86 | extern void cik_sdma_fini(struct radeon_device *rdev); |
| @@ -3257,7 +3258,7 @@ static void cik_gpu_init(struct radeon_device *rdev) · 3171 unmodified lines | |||
| 3257 | u32 mc_shared_chmap, mc_arb_ramcfg; | 3258 | u32 mc_shared_chmap, mc_arb_ramcfg; |
| 3258 | u32 hdp_host_path_cntl; | 3259 | u32 hdp_host_path_cntl; |
| 3259 | u32 tmp; | 3260 | u32 tmp; |
| 3260 | int i, j; | 3261 | int i, j, k; |
| 3261 | 3262 | ||
| 3262 | switch (rdev->family) { | 3263 | switch (rdev->family) { |
| 3263 | case CHIP_BONAIRE: | 3264 | case CHIP_BONAIRE: |
| @@ -3446,6 +3447,15 @@ static void cik_gpu_init(struct radeon_device *rdev) · 182 unmodified lines | |||
| 3446 | rdev->config.cik.max_sh_per_se, | 3447 | rdev->config.cik.max_sh_per_se, |
| 3447 | rdev->config.cik.max_backends_per_se); | 3448 | rdev->config.cik.max_backends_per_se); |
| 3448 | 3449 | ||
| 3450 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { | ||
| 3451 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { | ||
| 3452 | for (k = 0; k < rdev->config.cik.max_cu_per_sh; k++) { | ||
| 3453 | rdev->config.cik.active_cus += | ||
| 3454 | hweight32(cik_get_cu_active_bitmap(rdev, i, j)); | ||
| 3455 | } | ||
| 3456 | } | ||
| 3457 | } | ||
| 3458 | |||
| 3449 | /* set HW defaults for 3D engine */ | 3459 | /* set HW defaults for 3D engine */ |
| 3450 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); | 3460 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); |
| 3451 | 3461 | ||
| @@ -3337,6 +3337,18 @@ static void evergreen_gpu_init(struct radeon_device *rdev) · 3336 unmodified lines | |||
| 3337 | disabled_rb_mask &= ~(1 << i); | 3337 | disabled_rb_mask &= ~(1 << i); |
| 3338 | } | 3338 | } |
| 3339 | 3339 | ||
| 3340 | for (i = 0; i < rdev->config.evergreen.num_ses; i++) { | ||
| 3341 | u32 simd_disable_bitmap; | ||
| 3342 | |||
| 3343 | WREG32(GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_INDEX(i)); | ||
| 3344 | WREG32(RLC_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_INDEX(i)); | ||
| 3345 | simd_disable_bitmap = (RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0xffff0000) >> 16; | ||
| 3346 | simd_disable_bitmap |= 0xffffffff << rdev->config.evergreen.max_simds; | ||
| 3347 | tmp <<= 16; | ||
| 3348 | tmp |= simd_disable_bitmap; | ||
| 3349 | } | ||
| 3350 | rdev->config.evergreen.active_simds = hweight32(~tmp); | ||
| 3351 | |||
| 3340 | WREG32(GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); | 3352 | WREG32(GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); |
| 3341 | WREG32(RLC_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); | 3353 | WREG32(RLC_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); |
| 3342 | 3354 | ||
| @@ -1057,6 +1057,18 @@ static void cayman_gpu_init(struct radeon_device *rdev) · 1056 unmodified lines | |||
| 1057 | disabled_rb_mask &= ~(1 << i); | 1057 | disabled_rb_mask &= ~(1 << i); |
| 1058 | } | 1058 | } |
| 1059 | 1059 | ||
| 1060 | for (i = 0; i < rdev->config.cayman.max_shader_engines; i++) { | ||
| 1061 | u32 simd_disable_bitmap; | ||
| 1062 | |||
| 1063 | WREG32(GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_INDEX(i)); | ||
| 1064 | WREG32(RLC_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_INDEX(i)); | ||
| 1065 | simd_disable_bitmap = (RREG32(CC_GC_SHADER_PIPE_CONFIG) & 0xffff0000) >> 16; | ||
| 1066 | simd_disable_bitmap |= 0xffffffff << rdev->config.cayman.max_simds_per_se; | ||
| 1067 | tmp <<= 16; | ||
| 1068 | tmp |= simd_disable_bitmap; | ||
| 1069 | } | ||
| 1070 | rdev->config.cayman.active_simds = hweight32(~tmp); | ||
| 1071 | |||
| 1060 | WREG32(GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); | 1072 | WREG32(GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); |
| 1061 | WREG32(RLC_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); | 1073 | WREG32(RLC_GFX_INDEX, INSTANCE_BROADCAST_WRITES | SE_BROADCAST_WRITES); |
| 1062 | 1074 | ||
| @@ -1958,6 +1958,9 @@ static void r600_gpu_init(struct radeon_device *rdev) · 1957 unmodified lines | |||
| 1958 | if (tmp < rdev->config.r600.max_simds) { | 1958 | if (tmp < rdev->config.r600.max_simds) { |
| 1959 | rdev->config.r600.max_simds = tmp; | 1959 | rdev->config.r600.max_simds = tmp; |
| 1960 | } | 1960 | } |
| 1961 | tmp = rdev->config.r600.max_simds - | ||
| 1962 | r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R6XX_MAX_SIMDS_MASK); | ||
| 1963 | rdev->config.r600.active_simds = tmp; | ||
| 1961 | 1964 | ||
| 1962 | disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R6XX_MAX_BACKENDS_MASK; | 1965 | disabled_rb_mask = (RREG32(CC_RB_BACKEND_DISABLE) >> 16) & R6XX_MAX_BACKENDS_MASK; |
| 1963 | tmp = (tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT; | 1966 | tmp = (tiling_config & PIPE_TILING__MASK) >> PIPE_TILING__SHIFT; |
| @@ -1932,6 +1932,7 @@ struct r600_asic { · 1931 unmodified lines | |||
| 1932 | unsigned tiling_group_size; | 1932 | unsigned tiling_group_size; |
| 1933 | unsigned tile_config; | 1933 | unsigned tile_config; |
| 1934 | unsigned backend_map; | 1934 | unsigned backend_map; |
| 1935 | unsigned active_simds; | ||
| 1935 | }; | 1936 | }; |
| 1936 | 1937 | ||
| 1937 | struct rv770_asic { | 1938 | struct rv770_asic { |
| @@ -1957,6 +1958,7 @@ struct rv770_asic { · 19 unmodified lines | |||
| 1957 | unsigned tiling_group_size; | 1958 | unsigned tiling_group_size; |
| 1958 | unsigned tile_config; | 1959 | unsigned tile_config; |
| 1959 | unsigned backend_map; | 1960 | unsigned backend_map; |
| 1961 | unsigned active_simds; | ||
| 1960 | }; | 1962 | }; |
| 1961 | 1963 | ||
| 1962 | struct evergreen_asic { | 1964 | struct evergreen_asic { |
| @@ -1983,6 +1985,7 @@ struct evergreen_asic { · 20 unmodified lines | |||
| 1983 | unsigned tiling_group_size; | 1985 | unsigned tiling_group_size; |
| 1984 | unsigned tile_config; | 1986 | unsigned tile_config; |
| 1985 | unsigned backend_map; | 1987 | unsigned backend_map; |
| 1988 | unsigned active_simds; | ||
| 1986 | }; | 1989 | }; |
| 1987 | 1990 | ||
| 1988 | struct cayman_asic { | 1991 | struct cayman_asic { |
| @@ -2021,6 +2024,7 @@ struct cayman_asic { · 32 unmodified lines | |||
| 2021 | unsigned multi_gpu_tile_size; | 2024 | unsigned multi_gpu_tile_size; |
| 2022 | 2025 | ||
| 2023 | unsigned tile_config; | 2026 | unsigned tile_config; |
| 2027 | unsigned active_simds; | ||
| 2024 | }; | 2028 | }; |
| 2025 | 2029 | ||
| 2026 | struct si_asic { | 2030 | struct si_asic { |
| @@ -2051,6 +2055,7 @@ struct si_asic { · 24 unmodified lines | |||
| 2051 | 2055 | ||
| 2052 | unsigned tile_config; | 2056 | unsigned tile_config; |
| 2053 | uint32_t tile_mode_array[32]; | 2057 | uint32_t tile_mode_array[32]; |
| 2058 | uint32_t active_cus; | ||
| 2054 | }; | 2059 | }; |
| 2055 | 2060 | ||
| 2056 | struct cik_asic { | 2061 | struct cik_asic { |
| @@ -2082,6 +2087,7 @@ struct cik_asic { · 25 unmodified lines | |||
| 2082 | unsigned tile_config; | 2087 | unsigned tile_config; |
| 2083 | uint32_t tile_mode_array[32]; | 2088 | uint32_t tile_mode_array[32]; |
| 2084 | uint32_t macrotile_mode_array[16]; | 2089 | uint32_t macrotile_mode_array[16]; |
| 2090 | uint32_t active_cus; | ||
| 2085 | }; | 2091 | }; |
| 2086 | 2092 | ||
| 2087 | union radeon_asic_config { | 2093 | union radeon_asic_config { |
| @@ -81,9 +81,10 @@ · 80 unmodified lines | |||
| 81 | * 2.37.0 - allow GS ring setup on r6xx/r7xx | 81 | * 2.37.0 - allow GS ring setup on r6xx/r7xx |
| 82 | * 2.38.0 - RADEON_GEM_OP (GET_INITIAL_DOMAIN, SET_INITIAL_DOMAIN), | 82 | * 2.38.0 - RADEON_GEM_OP (GET_INITIAL_DOMAIN, SET_INITIAL_DOMAIN), |
| 83 | * CIK: 1D and linear tiling modes contain valid PIPE_CONFIG | 83 | * CIK: 1D and linear tiling modes contain valid PIPE_CONFIG |
| 84 | * 2.39.0 - Add INFO query for number of active CUs | ||
| 84 | */ | 85 | */ |
| 85 | #define KMS_DRIVER_MAJOR 2 | 86 | #define KMS_DRIVER_MAJOR 2 |
| 86 | #define KMS_DRIVER_MINOR 38 | 87 | #define KMS_DRIVER_MINOR 39 |
| 87 | #define KMS_DRIVER_PATCHLEVEL 0 | 88 | #define KMS_DRIVER_PATCHLEVEL 0 |
| 88 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags); | 89 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags); |
| 89 | int radeon_driver_unload_kms(struct drm_device *dev); | 90 | int radeon_driver_unload_kms(struct drm_device *dev); |
| @@ -513,6 +513,22 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 512 unmodified lines | |||
| 513 | value_size = sizeof(uint64_t); | 513 | value_size = sizeof(uint64_t); |
| 514 | value64 = atomic64_read(&rdev->gtt_usage); | 514 | value64 = atomic64_read(&rdev->gtt_usage); |
| 515 | break; | 515 | break; |
| 516 | case RADEON_INFO_ACTIVE_CU_COUNT: | ||
| 517 | if (rdev->family >= CHIP_BONAIRE) | ||
| 518 | *value = rdev->config.cik.active_cus; | ||
| 519 | else if (rdev->family >= CHIP_TAHITI) | ||
| 520 | *value = rdev->config.si.active_cus; | ||
| 521 | else if (rdev->family >= CHIP_CAYMAN) | ||
| 522 | *value = rdev->config.cayman.active_simds; | ||
| 523 | else if (rdev->family >= CHIP_CEDAR) | ||
| 524 | *value = rdev->config.evergreen.active_simds; | ||
| 525 | else if (rdev->family >= CHIP_RV770) | ||
| 526 | *value = rdev->config.rv770.active_simds; | ||
| 527 | else if (rdev->family >= CHIP_R600) | ||
| 528 | *value = rdev->config.r600.active_simds; | ||
| 529 | else | ||
| 530 | *value = 1; | ||
| 531 | break; | ||
| 516 | default: | 532 | default: |
| 517 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); | 533 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
| 518 | return -EINVAL; | 534 | return -EINVAL; |
| @@ -1327,6 +1327,9 @@ static void rv770_gpu_init(struct radeon_device *rdev) · 1326 unmodified lines | |||
| 1327 | if (tmp < rdev->config.rv770.max_simds) { | 1327 | if (tmp < rdev->config.rv770.max_simds) { |
| 1328 | rdev->config.rv770.max_simds = tmp; | 1328 | rdev->config.rv770.max_simds = tmp; |
| 1329 | } | 1329 | } |
| 1330 | tmp = rdev->config.rv770.max_simds - | ||
| 1331 | r600_count_pipe_bits((cc_gc_shader_pipe_config >> 16) & R7XX_MAX_SIMDS_MASK); | ||
| 1332 | rdev->config.rv770.active_simds = tmp; | ||
| 1330 | 1333 | ||
| 1331 | switch (rdev->config.rv770.max_tile_pipes) { | 1334 | switch (rdev->config.rv770.max_tile_pipes) { |
| 1332 | case 1: | 1335 | case 1: |
| @@ -71,6 +71,7 @@ MODULE_FIRMWARE("radeon/HAINAN_mc2.bin"); · 70 unmodified lines | |||
| 71 | MODULE_FIRMWARE("radeon/HAINAN_rlc.bin"); | 71 | MODULE_FIRMWARE("radeon/HAINAN_rlc.bin"); |
| 72 | MODULE_FIRMWARE("radeon/HAINAN_smc.bin"); | 72 | MODULE_FIRMWARE("radeon/HAINAN_smc.bin"); |
| 73 | 73 | ||
| 74 | static u32 si_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh); | ||
| 74 | static void si_pcie_gen3_enable(struct radeon_device *rdev); | 75 | static void si_pcie_gen3_enable(struct radeon_device *rdev); |
| 75 | static void si_program_aspm(struct radeon_device *rdev); | 76 | static void si_program_aspm(struct radeon_device *rdev); |
| 76 | extern void sumo_rlc_fini(struct radeon_device *rdev); | 77 | extern void sumo_rlc_fini(struct radeon_device *rdev); |
| @@ -2900,7 +2901,7 @@ static void si_gpu_init(struct radeon_device *rdev) · 2823 unmodified lines | |||
| 2900 | u32 sx_debug_1; | 2901 | u32 sx_debug_1; |
| 2901 | u32 hdp_host_path_cntl; | 2902 | u32 hdp_host_path_cntl; |
| 2902 | u32 tmp; | 2903 | u32 tmp; |
| 2903 | int i, j; | 2904 | int i, j, k; |
| 2904 | 2905 | ||
| 2905 | switch (rdev->family) { | 2906 | switch (rdev->family) { |
| 2906 | case CHIP_TAHITI: | 2907 | case CHIP_TAHITI: |
| @@ -3098,6 +3099,14 @@ static void si_gpu_init(struct radeon_device *rdev) · 191 unmodified lines | |||
| 3098 | rdev->config.si.max_sh_per_se, | 3099 | rdev->config.si.max_sh_per_se, |
| 3099 | rdev->config.si.max_cu_per_sh); | 3100 | rdev->config.si.max_cu_per_sh); |
| 3100 | 3101 | ||
| 3102 | for (i = 0; i < rdev->config.si.max_shader_engines; i++) { | ||
| 3103 | for (j = 0; j < rdev->config.si.max_sh_per_se; j++) { | ||
| 3104 | for (k = 0; k < rdev->config.si.max_cu_per_sh; k++) { | ||
| 3105 | rdev->config.si.active_cus += | ||
| 3106 | hweight32(si_get_cu_active_bitmap(rdev, i, j)); | ||
| 3107 | } | ||
| 3108 | } | ||
| 3109 | } | ||
| 3101 | 3110 | ||
| 3102 | /* set HW defaults for 3D engine */ | 3111 | /* set HW defaults for 3D engine */ |
| 3103 | WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | | 3112 | WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | |
| @@ -1007,7 +1007,7 @@ struct drm_radeon_cs { · 1006 unmodified lines | |||
| 1007 | #define RADEON_INFO_NUM_BYTES_MOVED 0x1d | 1007 | #define RADEON_INFO_NUM_BYTES_MOVED 0x1d |
| 1008 | #define RADEON_INFO_VRAM_USAGE 0x1e | 1008 | #define RADEON_INFO_VRAM_USAGE 0x1e |
| 1009 | #define RADEON_INFO_GTT_USAGE 0x1f | 1009 | #define RADEON_INFO_GTT_USAGE 0x1f |
| 1010 | 1010 | #define RADEON_INFO_ACTIVE_CU_COUNT 0x20 | |
| 1011 | 1011 | ||
| 1012 | struct drm_radeon_info { | 1012 | struct drm_radeon_info { |
| 1013 | uint32_t request; | 1013 | uint32_t request; |