Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'drm-next-4.12' of git://people.freedesktop.org/~agd5f/linux into drm-next

Just some bug fixes and vega10 updates for 4.12.

* 'drm-next-4.12' of git://people.freedesktop.org/~agd5f/linux:
drm/amdgpu: fix fence memory leak in wait_all_fence V2
drm/amdgpu: fix "fix 64bit division"
drm/amd/powerplay: add fan controller table v11 support.
drm/amd/powerplay: port newest process pptable code for vega10.
drm/amdgpu: set vm size and block size by individual gmc by default (v3)
drm/amdgpu: Avoid overflows/divide-by-zero in latency_watermark calculations.
drm/amdgpu: Make display watermark calculations more accurate
drm/radeon: fix typo in bandwidth calculation
drm/radeon: Refuse to migrate a prime BO to VRAM. (v2)
drm/radeon: Maintain prime import/export refcount for BOs
drm/amdgpu: Refuse to pin or change acceptable domains of prime BOs to VRAM. (v2)
drm/amdgpu: Fail fb creation from imported dma-bufs. (v2)
drm/radeon: Fail fb creation from imported dma-bufs.

+453 -218
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 1242 1242 continue; 1243 1243 1244 1244 r = dma_fence_wait_timeout(fence, true, timeout); 1245 + dma_fence_put(fence); 1245 1246 if (r < 0) 1246 1247 return r; 1247 1248
+13 -18
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 1040 1040 return (arg & (arg - 1)) == 0; 1041 1041 } 1042 1042 1043 - static void amdgpu_get_block_size(struct amdgpu_device *adev) 1043 + static void amdgpu_check_block_size(struct amdgpu_device *adev) 1044 1044 { 1045 1045 /* defines number of bits in page table versus page directory, 1046 1046 * a page is 4KB so we have 12 bits offset, minimum 9 bits in the 1047 1047 * page table and the remaining bits are in the page directory */ 1048 - if (amdgpu_vm_block_size == -1) { 1048 + if (amdgpu_vm_block_size == -1) 1049 + return; 1049 1050 1050 - /* Total bits covered by PD + PTs */ 1051 - unsigned bits = ilog2(amdgpu_vm_size) + 18; 1052 - 1053 - /* Make sure the PD is 4K in size up to 8GB address space. 1054 - Above that split equal between PD and PTs */ 1055 - if (amdgpu_vm_size <= 8) 1056 - amdgpu_vm_block_size = bits - 9; 1057 - else 1058 - amdgpu_vm_block_size = (bits + 3) / 2; 1059 - 1060 - } else if (amdgpu_vm_block_size < 9) { 1051 + if (amdgpu_vm_block_size < 9) { 1061 1052 dev_warn(adev->dev, "VM page table size (%d) too small\n", 1062 1053 amdgpu_vm_block_size); 1063 - amdgpu_vm_block_size = 9; 1054 + goto def_value; 1064 1055 } 1065 1056 1066 1057 if (amdgpu_vm_block_size > 24 || 1067 1058 (amdgpu_vm_size * 1024) < (1ull << amdgpu_vm_block_size)) { 1068 1059 dev_warn(adev->dev, "VM page table size (%d) too large\n", 1069 1060 amdgpu_vm_block_size); 1070 - amdgpu_vm_block_size = 9; 1061 + goto def_value; 1071 1062 } 1063 + 1064 + return; 1065 + 1066 + def_value: 1067 + amdgpu_vm_block_size = -1; 1072 1068 } 1073 1069 1074 1070 static void amdgpu_check_vm_size(struct amdgpu_device *adev) ··· 1093 1097 return; 1094 1098 1095 1099 def_value: 1096 - amdgpu_vm_size = 8; 1097 - dev_info(adev->dev, "set default VM size %dGB\n", amdgpu_vm_size); 1100 + amdgpu_vm_size = -1; 1098 1101 } 1099 1102 1100 1103 /** ··· 1127 1132 1128 1133 amdgpu_check_vm_size(adev); 1129 1134 1130 - amdgpu_get_block_size(adev); 1135 + amdgpu_check_block_size(adev); 1131 1136 1132 1137 if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 || 1133 1138 !amdgpu_check_pot_argument(amdgpu_vram_page_split))) {
+6
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
··· 614 614 return ERR_PTR(-ENOENT); 615 615 } 616 616 617 + /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */ 618 + if (obj->import_attach) { 619 + DRM_DEBUG_KMS("Cannot create framebuffer from imported dma_buf\n"); 620 + return ERR_PTR(-EINVAL); 621 + } 622 + 617 623 amdgpu_fb = kzalloc(sizeof(*amdgpu_fb), GFP_KERNEL); 618 624 if (amdgpu_fb == NULL) { 619 625 drm_gem_object_unreference_unlocked(obj);
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 86 86 unsigned amdgpu_ip_block_mask = 0xffffffff; 87 87 int amdgpu_bapm = -1; 88 88 int amdgpu_deep_color = 0; 89 - int amdgpu_vm_size = 64; 89 + int amdgpu_vm_size = -1; 90 90 int amdgpu_vm_block_size = -1; 91 91 int amdgpu_vm_fault_stop = 0; 92 92 int amdgpu_vm_debug = 0;
+5
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 729 729 break; 730 730 } 731 731 case AMDGPU_GEM_OP_SET_PLACEMENT: 732 + if (robj->prime_shared_count && (args->value & AMDGPU_GEM_DOMAIN_VRAM)) { 733 + r = -EINVAL; 734 + amdgpu_bo_unreserve(robj); 735 + break; 736 + } 732 737 if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { 733 738 r = -EPERM; 734 739 amdgpu_bo_unreserve(robj);
+4
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 650 650 if (WARN_ON_ONCE(min_offset > max_offset)) 651 651 return -EINVAL; 652 652 653 + /* A shared bo cannot be migrated to VRAM */ 654 + if (bo->prime_shared_count && (domain == AMDGPU_GEM_DOMAIN_VRAM)) 655 + return -EINVAL; 656 + 653 657 if (bo->pin_count) { 654 658 uint32_t mem_type = bo->tbo.mem.mem_type; 655 659
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 554 554 uint64_t offset = page_offset; 555 555 556 556 page_offset = do_div(offset, size); 557 + mm += offset; 557 558 return (bo->mem.bus.base >> PAGE_SHIFT) + mm->start + page_offset; 558 559 } 559 560
+38
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 2064 2064 } 2065 2065 } 2066 2066 2067 + static uint32_t amdgpu_vm_get_block_size(uint64_t vm_size) 2068 + { 2069 + /* Total bits covered by PD + PTs */ 2070 + unsigned bits = ilog2(vm_size) + 18; 2071 + 2072 + /* Make sure the PD is 4K in size up to 8GB address space. 2073 + Above that split equal between PD and PTs */ 2074 + if (vm_size <= 8) 2075 + return (bits - 9); 2076 + else 2077 + return ((bits + 3) / 2); 2078 + } 2079 + 2080 + /** 2081 + * amdgpu_vm_adjust_size - adjust vm size and block size 2082 + * 2083 + * @adev: amdgpu_device pointer 2084 + * @vm_size: the default vm size if it's set auto 2085 + */ 2086 + void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size) 2087 + { 2088 + /* adjust vm size firstly */ 2089 + if (amdgpu_vm_size == -1) 2090 + adev->vm_manager.vm_size = vm_size; 2091 + else 2092 + adev->vm_manager.vm_size = amdgpu_vm_size; 2093 + 2094 + /* block size depends on vm size */ 2095 + if (amdgpu_vm_block_size == -1) 2096 + adev->vm_manager.block_size = 2097 + amdgpu_vm_get_block_size(adev->vm_manager.vm_size); 2098 + else 2099 + adev->vm_manager.block_size = amdgpu_vm_block_size; 2100 + 2101 + DRM_INFO("vm size is %llu GB, block size is %u-bit\n", 2102 + adev->vm_manager.vm_size, adev->vm_manager.block_size); 2103 + } 2104 + 2067 2105 /** 2068 2106 * amdgpu_vm_init - initialize a vm instance 2069 2107 *
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
··· 234 234 uint64_t saddr, uint64_t size); 235 235 void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, 236 236 struct amdgpu_bo_va *bo_va); 237 + void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size); 237 238 238 239 #endif
+8 -21
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
··· 1090 1090 a.full = dfixed_const(available_bandwidth); 1091 1091 b.full = dfixed_const(wm->num_heads); 1092 1092 a.full = dfixed_div(a, b); 1093 + tmp = div_u64((u64) dmif_size * (u64) wm->disp_clk, mc_latency + 512); 1094 + tmp = min(dfixed_trunc(a), tmp); 1093 1095 1094 - b.full = dfixed_const(mc_latency + 512); 1095 - c.full = dfixed_const(wm->disp_clk); 1096 - b.full = dfixed_div(b, c); 1097 - 1098 - c.full = dfixed_const(dmif_size); 1099 - b.full = dfixed_div(c, b); 1100 - 1101 - tmp = min(dfixed_trunc(a), dfixed_trunc(b)); 1102 - 1103 - b.full = dfixed_const(1000); 1104 - c.full = dfixed_const(wm->disp_clk); 1105 - b.full = dfixed_div(c, b); 1106 - c.full = dfixed_const(wm->bytes_per_pixel); 1107 - b.full = dfixed_mul(b, c); 1108 - 1109 - lb_fill_bw = min(tmp, dfixed_trunc(b)); 1096 + lb_fill_bw = min(tmp, wm->disp_clk * wm->bytes_per_pixel / 1000); 1110 1097 1111 1098 a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); 1112 1099 b.full = dfixed_const(1000); ··· 1201 1214 { 1202 1215 struct drm_display_mode *mode = &amdgpu_crtc->base.mode; 1203 1216 struct dce10_wm_params wm_low, wm_high; 1204 - u32 pixel_period; 1217 + u32 active_time; 1205 1218 u32 line_time = 0; 1206 1219 u32 latency_watermark_a = 0, latency_watermark_b = 0; 1207 1220 u32 tmp, wm_mask, lb_vblank_lead_lines = 0; 1208 1221 1209 1222 if (amdgpu_crtc->base.enabled && num_heads && mode) { 1210 - pixel_period = 1000000 / (u32)mode->clock; 1211 - line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); 1223 + active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 1224 + line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 1212 1225 1213 1226 /* watermark for high clocks */ 1214 1227 if (adev->pm.dpm_enabled) { ··· 1223 1236 1224 1237 wm_high.disp_clk = mode->clock; 1225 1238 wm_high.src_width = mode->crtc_hdisplay; 1226 - wm_high.active_time = mode->crtc_hdisplay * pixel_period; 1239 + wm_high.active_time = active_time; 1227 1240 wm_high.blank_time = line_time - wm_high.active_time; 1228 1241 wm_high.interlaced = false; 1229 1242 if (mode->flags & DRM_MODE_FLAG_INTERLACE) ··· 1262 1275 1263 1276 wm_low.disp_clk = mode->clock; 1264 1277 wm_low.src_width = mode->crtc_hdisplay; 1265 - wm_low.active_time = mode->crtc_hdisplay * pixel_period; 1278 + wm_low.active_time = active_time; 1266 1279 wm_low.blank_time = line_time - wm_low.active_time; 1267 1280 wm_low.interlaced = false; 1268 1281 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+8 -21
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
··· 1059 1059 a.full = dfixed_const(available_bandwidth); 1060 1060 b.full = dfixed_const(wm->num_heads); 1061 1061 a.full = dfixed_div(a, b); 1062 + tmp = div_u64((u64) dmif_size * (u64) wm->disp_clk, mc_latency + 512); 1063 + tmp = min(dfixed_trunc(a), tmp); 1062 1064 1063 - b.full = dfixed_const(mc_latency + 512); 1064 - c.full = dfixed_const(wm->disp_clk); 1065 - b.full = dfixed_div(b, c); 1066 - 1067 - c.full = dfixed_const(dmif_size); 1068 - b.full = dfixed_div(c, b); 1069 - 1070 - tmp = min(dfixed_trunc(a), dfixed_trunc(b)); 1071 - 1072 - b.full = dfixed_const(1000); 1073 - c.full = dfixed_const(wm->disp_clk); 1074 - b.full = dfixed_div(c, b); 1075 - c.full = dfixed_const(wm->bytes_per_pixel); 1076 - b.full = dfixed_mul(b, c); 1077 - 1078 - lb_fill_bw = min(tmp, dfixed_trunc(b)); 1065 + lb_fill_bw = min(tmp, wm->disp_clk * wm->bytes_per_pixel / 1000); 1079 1066 1080 1067 a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); 1081 1068 b.full = dfixed_const(1000); ··· 1170 1183 { 1171 1184 struct drm_display_mode *mode = &amdgpu_crtc->base.mode; 1172 1185 struct dce10_wm_params wm_low, wm_high; 1173 - u32 pixel_period; 1186 + u32 active_time; 1174 1187 u32 line_time = 0; 1175 1188 u32 latency_watermark_a = 0, latency_watermark_b = 0; 1176 1189 u32 tmp, wm_mask, lb_vblank_lead_lines = 0; 1177 1190 1178 1191 if (amdgpu_crtc->base.enabled && num_heads && mode) { 1179 - pixel_period = 1000000 / (u32)mode->clock; 1180 - line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); 1192 + active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 1193 + line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 1181 1194 1182 1195 /* watermark for high clocks */ 1183 1196 if (adev->pm.dpm_enabled) { ··· 1192 1205 1193 1206 wm_high.disp_clk = mode->clock; 1194 1207 wm_high.src_width = mode->crtc_hdisplay; 1195 - wm_high.active_time = mode->crtc_hdisplay * pixel_period; 1208 + wm_high.active_time = active_time; 1196 1209 wm_high.blank_time = line_time - wm_high.active_time; 1197 1210 wm_high.interlaced = false; 1198 1211 if (mode->flags & DRM_MODE_FLAG_INTERLACE) ··· 1231 1244 1232 1245 wm_low.disp_clk = mode->clock; 1233 1246 wm_low.src_width = mode->crtc_hdisplay; 1234 - wm_low.active_time = mode->crtc_hdisplay * pixel_period; 1247 + wm_low.active_time = active_time; 1235 1248 wm_low.blank_time = line_time - wm_low.active_time; 1236 1249 wm_low.interlaced = false; 1237 1250 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+8 -21
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
··· 861 861 a.full = dfixed_const(available_bandwidth); 862 862 b.full = dfixed_const(wm->num_heads); 863 863 a.full = dfixed_div(a, b); 864 + tmp = div_u64((u64) dmif_size * (u64) wm->disp_clk, mc_latency + 512); 865 + tmp = min(dfixed_trunc(a), tmp); 864 866 865 - b.full = dfixed_const(mc_latency + 512); 866 - c.full = dfixed_const(wm->disp_clk); 867 - b.full = dfixed_div(b, c); 868 - 869 - c.full = dfixed_const(dmif_size); 870 - b.full = dfixed_div(c, b); 871 - 872 - tmp = min(dfixed_trunc(a), dfixed_trunc(b)); 873 - 874 - b.full = dfixed_const(1000); 875 - c.full = dfixed_const(wm->disp_clk); 876 - b.full = dfixed_div(c, b); 877 - c.full = dfixed_const(wm->bytes_per_pixel); 878 - b.full = dfixed_mul(b, c); 879 - 880 - lb_fill_bw = min(tmp, dfixed_trunc(b)); 867 + lb_fill_bw = min(tmp, wm->disp_clk * wm->bytes_per_pixel / 1000); 881 868 882 869 a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); 883 870 b.full = dfixed_const(1000); ··· 973 986 struct drm_display_mode *mode = &amdgpu_crtc->base.mode; 974 987 struct dce6_wm_params wm_low, wm_high; 975 988 u32 dram_channels; 976 - u32 pixel_period; 989 + u32 active_time; 977 990 u32 line_time = 0; 978 991 u32 latency_watermark_a = 0, latency_watermark_b = 0; 979 992 u32 priority_a_mark = 0, priority_b_mark = 0; ··· 983 996 fixed20_12 a, b, c; 984 997 985 998 if (amdgpu_crtc->base.enabled && num_heads && mode) { 986 - pixel_period = 1000000 / (u32)mode->clock; 987 - line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); 999 + active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 1000 + line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 988 1001 priority_a_cnt = 0; 989 1002 priority_b_cnt = 0; 990 1003 ··· 1003 1016 1004 1017 wm_high.disp_clk = mode->clock; 1005 1018 wm_high.src_width = mode->crtc_hdisplay; 1006 - wm_high.active_time = mode->crtc_hdisplay * pixel_period; 1019 + wm_high.active_time = active_time; 1007 1020 wm_high.blank_time = line_time - wm_high.active_time; 1008 1021 wm_high.interlaced = false; 1009 1022 if (mode->flags & DRM_MODE_FLAG_INTERLACE) ··· 1030 1043 1031 1044 wm_low.disp_clk = mode->clock; 1032 1045 wm_low.src_width = mode->crtc_hdisplay; 1033 - wm_low.active_time = mode->crtc_hdisplay * pixel_period; 1046 + wm_low.active_time = active_time; 1034 1047 wm_low.blank_time = line_time - wm_low.active_time; 1035 1048 wm_low.interlaced = false; 1036 1049 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+8 -21
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
··· 974 974 a.full = dfixed_const(available_bandwidth); 975 975 b.full = dfixed_const(wm->num_heads); 976 976 a.full = dfixed_div(a, b); 977 + tmp = div_u64((u64) dmif_size * (u64) wm->disp_clk, mc_latency + 512); 978 + tmp = min(dfixed_trunc(a), tmp); 977 979 978 - b.full = dfixed_const(mc_latency + 512); 979 - c.full = dfixed_const(wm->disp_clk); 980 - b.full = dfixed_div(b, c); 981 - 982 - c.full = dfixed_const(dmif_size); 983 - b.full = dfixed_div(c, b); 984 - 985 - tmp = min(dfixed_trunc(a), dfixed_trunc(b)); 986 - 987 - b.full = dfixed_const(1000); 988 - c.full = dfixed_const(wm->disp_clk); 989 - b.full = dfixed_div(c, b); 990 - c.full = dfixed_const(wm->bytes_per_pixel); 991 - b.full = dfixed_mul(b, c); 992 - 993 - lb_fill_bw = min(tmp, dfixed_trunc(b)); 980 + lb_fill_bw = min(tmp, wm->disp_clk * wm->bytes_per_pixel / 1000); 994 981 995 982 a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); 996 983 b.full = dfixed_const(1000); ··· 1085 1098 { 1086 1099 struct drm_display_mode *mode = &amdgpu_crtc->base.mode; 1087 1100 struct dce8_wm_params wm_low, wm_high; 1088 - u32 pixel_period; 1101 + u32 active_time; 1089 1102 u32 line_time = 0; 1090 1103 u32 latency_watermark_a = 0, latency_watermark_b = 0; 1091 1104 u32 tmp, wm_mask, lb_vblank_lead_lines = 0; 1092 1105 1093 1106 if (amdgpu_crtc->base.enabled && num_heads && mode) { 1094 - pixel_period = 1000000 / (u32)mode->clock; 1095 - line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); 1107 + active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 1108 + line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 1096 1109 1097 1110 /* watermark for high clocks */ 1098 1111 if (adev->pm.dpm_enabled) { ··· 1107 1120 1108 1121 wm_high.disp_clk = mode->clock; 1109 1122 wm_high.src_width = mode->crtc_hdisplay; 1110 - wm_high.active_time = mode->crtc_hdisplay * pixel_period; 1123 + wm_high.active_time = active_time; 1111 1124 wm_high.blank_time = line_time - wm_high.active_time; 1112 1125 wm_high.interlaced = false; 1113 1126 if (mode->flags & DRM_MODE_FLAG_INTERLACE) ··· 1146 1159 1147 1160 wm_low.disp_clk = mode->clock; 1148 1161 wm_low.src_width = mode->crtc_hdisplay; 1149 - wm_low.active_time = mode->crtc_hdisplay * pixel_period; 1162 + wm_low.active_time = active_time; 1150 1163 wm_low.blank_time = line_time - wm_low.active_time; 1151 1164 wm_low.interlaced = false; 1152 1165 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+1 -5
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
··· 849 849 if (r) 850 850 return r; 851 851 852 - adev->vm_manager.vm_size = amdgpu_vm_size; 853 - adev->vm_manager.block_size = amdgpu_vm_block_size; 852 + amdgpu_vm_adjust_size(adev, 64); 854 853 adev->vm_manager.max_pfn = adev->vm_manager.vm_size << 18; 855 - 856 - DRM_INFO("vm size is %llu GB, block size is %d-bit\n", 857 - adev->vm_manager.vm_size, adev->vm_manager.block_size); 858 854 859 855 adev->mc.mc_mask = 0xffffffffffULL; 860 856
+1 -5
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
··· 1003 1003 * Currently set to 4GB ((1 << 20) 4k pages). 1004 1004 * Max GPUVM size for cayman and SI is 40 bits. 1005 1005 */ 1006 - adev->vm_manager.vm_size = amdgpu_vm_size; 1007 - adev->vm_manager.block_size = amdgpu_vm_block_size; 1006 + amdgpu_vm_adjust_size(adev, 64); 1008 1007 adev->vm_manager.max_pfn = adev->vm_manager.vm_size << 18; 1009 - 1010 - DRM_INFO("vm size is %llu GB, block size is %d-bit\n", 1011 - adev->vm_manager.vm_size, adev->vm_manager.block_size); 1012 1008 1013 1009 /* Set the internal MC address mask 1014 1010 * This is the max address of the GPU's
+1 -5
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
··· 1087 1087 * Currently set to 4GB ((1 << 20) 4k pages). 1088 1088 * Max GPUVM size for cayman and SI is 40 bits. 1089 1089 */ 1090 - adev->vm_manager.vm_size = amdgpu_vm_size; 1091 - adev->vm_manager.block_size = amdgpu_vm_block_size; 1090 + amdgpu_vm_adjust_size(adev, 64); 1092 1091 adev->vm_manager.max_pfn = adev->vm_manager.vm_size << 18; 1093 - 1094 - DRM_INFO("vm size is %llu GB, block size is %d-bit\n", 1095 - adev->vm_manager.vm_size, adev->vm_manager.block_size); 1096 1092 1097 1093 /* Set the internal MC address mask 1098 1094 * This is the max address of the GPU's
+10 -6
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 520 520 * amdkfd will use VMIDs 8-15 521 521 */ 522 522 adev->vm_manager.num_ids = AMDGPU_NUM_OF_VMIDS; 523 - adev->vm_manager.num_level = 3; 523 + 524 + /* TODO: fix num_level for APU when updating vm size and block size */ 525 + if (adev->flags & AMD_IS_APU) 526 + adev->vm_manager.num_level = 1; 527 + else 528 + adev->vm_manager.num_level = 3; 524 529 amdgpu_vm_manager_init(adev); 525 530 526 531 /* base offset of vram pages */ ··· 557 552 558 553 if (adev->flags & AMD_IS_APU) { 559 554 adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; 560 - adev->vm_manager.vm_size = amdgpu_vm_size; 561 - adev->vm_manager.block_size = amdgpu_vm_block_size; 555 + amdgpu_vm_adjust_size(adev, 64); 562 556 } else { 563 557 /* XXX Don't know how to get VRAM type yet. */ 564 558 adev->mc.vram_type = AMDGPU_VRAM_TYPE_HBM; ··· 568 564 */ 569 565 adev->vm_manager.vm_size = 1U << 18; 570 566 adev->vm_manager.block_size = 9; 567 + DRM_INFO("vm size is %llu GB, block size is %u-bit\n", 568 + adev->vm_manager.vm_size, 569 + adev->vm_manager.block_size); 571 570 } 572 - 573 - DRM_INFO("vm size is %llu GB, block size is %d-bit\n", 574 - adev->vm_manager.vm_size, adev->vm_manager.block_size); 575 571 576 572 /* This interrupt is VMC page fault.*/ 577 573 r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_VMC, 0,
+50
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_pptable.h
··· 250 250 USHORT usFanStartTemperature; 251 251 } ATOM_Vega10_Fan_Table; 252 252 253 + typedef struct _ATOM_Vega10_Fan_Table_V2 { 254 + UCHAR ucRevId; 255 + USHORT usFanOutputSensitivity; 256 + USHORT usFanAcousticLimitRpm; 257 + USHORT usThrottlingRPM; 258 + USHORT usTargetTemperature; 259 + USHORT usMinimumPWMLimit; 260 + USHORT usTargetGfxClk; 261 + USHORT usFanGainEdge; 262 + USHORT usFanGainHotspot; 263 + USHORT usFanGainLiquid; 264 + USHORT usFanGainVrVddc; 265 + USHORT usFanGainVrMvdd; 266 + USHORT usFanGainPlx; 267 + USHORT usFanGainHbm; 268 + UCHAR ucEnableZeroRPM; 269 + USHORT usFanStopTemperature; 270 + USHORT usFanStartTemperature; 271 + UCHAR ucFanParameters; 272 + UCHAR ucFanMinRPM; 273 + UCHAR ucFanMaxRPM; 274 + } ATOM_Vega10_Fan_Table_V2; 275 + 253 276 typedef struct _ATOM_Vega10_Thermal_Controller { 254 277 UCHAR ucRevId; 255 278 UCHAR ucType; /* one of ATOM_VEGA10_PP_THERMALCONTROLLER_*/ ··· 327 304 UCHAR ucPlx_I2C_LineSDA; 328 305 USHORT usTemperatureLimitTedge; 329 306 } ATOM_Vega10_PowerTune_Table; 307 + 308 + typedef struct _ATOM_Vega10_PowerTune_Table_V2 309 + { 310 + UCHAR ucRevId; 311 + USHORT usSocketPowerLimit; 312 + USHORT usBatteryPowerLimit; 313 + USHORT usSmallPowerLimit; 314 + USHORT usTdcLimit; 315 + USHORT usEdcLimit; 316 + USHORT usSoftwareShutdownTemp; 317 + USHORT usTemperatureLimitHotSpot; 318 + USHORT usTemperatureLimitLiquid1; 319 + USHORT usTemperatureLimitLiquid2; 320 + USHORT usTemperatureLimitHBM; 321 + USHORT usTemperatureLimitVrSoc; 322 + USHORT usTemperatureLimitVrMem; 323 + USHORT usTemperatureLimitPlx; 324 + USHORT usLoadLineResistance; 325 + UCHAR ucLiquid1_I2C_address; 326 + UCHAR ucLiquid2_I2C_address; 327 + UCHAR ucLiquid_I2C_Line; 328 + UCHAR ucVr_I2C_address; 329 + UCHAR ucVr_I2C_Line; 330 + UCHAR ucPlx_I2C_address; 331 + UCHAR ucPlx_I2C_Line; 332 + USHORT usTemperatureLimitTedge; 333 + } ATOM_Vega10_PowerTune_Table_V2; 330 334 331 335 typedef struct _ATOM_Vega10_Hard_Limit_Record { 332 336 ULONG ulSOCCLKLimit;
+227 -93
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
··· 116 116 const ATOM_Vega10_POWERPLAYTABLE *powerplay_table) 117 117 { 118 118 const ATOM_Vega10_Thermal_Controller *thermal_controller; 119 - const ATOM_Vega10_Fan_Table *fan_table; 119 + const Vega10_PPTable_Generic_SubTable_Header *header; 120 + const ATOM_Vega10_Fan_Table *fan_table_v1; 121 + const ATOM_Vega10_Fan_Table_V2 *fan_table_v2; 120 122 121 123 thermal_controller = (ATOM_Vega10_Thermal_Controller *) 122 124 (((unsigned long)powerplay_table) + 123 125 le16_to_cpu(powerplay_table->usThermalControllerOffset)); 124 126 125 127 PP_ASSERT_WITH_CODE((powerplay_table->usThermalControllerOffset != 0), 126 - "Thermal controller table not set!", return -1); 128 + "Thermal controller table not set!", return -EINVAL); 127 129 128 130 hwmgr->thermal_controller.ucType = thermal_controller->ucType; 129 131 hwmgr->thermal_controller.ucI2cLine = thermal_controller->ucI2cLine; ··· 144 142 hwmgr->thermal_controller.fanInfo.ulMaxRPM = 145 143 thermal_controller->ucFanMaxRPM * 100UL; 146 144 145 + hwmgr->thermal_controller.advanceFanControlParameters.ulCycleDelay 146 + = 100000; 147 + 147 148 set_hw_cap( 148 149 hwmgr, 149 150 ATOM_VEGA10_PP_THERMALCONTROLLER_NONE != hwmgr->thermal_controller.ucType, ··· 155 150 if (!powerplay_table->usFanTableOffset) 156 151 return 0; 157 152 158 - fan_table = (const ATOM_Vega10_Fan_Table *) 153 + header = (const Vega10_PPTable_Generic_SubTable_Header *) 159 154 (((unsigned long)powerplay_table) + 160 155 le16_to_cpu(powerplay_table->usFanTableOffset)); 161 156 162 - PP_ASSERT_WITH_CODE((fan_table->ucRevId >= 8), 163 - "Invalid Input Fan Table!", return -1); 157 + if (header->ucRevId == 10) { 158 + fan_table_v1 = (ATOM_Vega10_Fan_Table *)header; 164 159 165 - hwmgr->thermal_controller.advanceFanControlParameters.ulCycleDelay 166 - = 100000; 167 - phm_cap_set(hwmgr->platform_descriptor.platformCaps, 168 - PHM_PlatformCaps_MicrocodeFanControl); 160 + PP_ASSERT_WITH_CODE((fan_table_v1->ucRevId >= 8), 161 + "Invalid Input Fan Table!", return -EINVAL); 169 162 170 - hwmgr->thermal_controller.advanceFanControlParameters.usFanOutputSensitivity = 171 - le16_to_cpu(fan_table->usFanOutputSensitivity); 172 - hwmgr->thermal_controller.advanceFanControlParameters.usMaxFanRPM = 173 - le16_to_cpu(fan_table->usFanRPMMax); 174 - hwmgr->thermal_controller.advanceFanControlParameters.usFanRPMMaxLimit = 175 - le16_to_cpu(fan_table->usThrottlingRPM); 176 - hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit = 177 - le32_to_cpu((uint32_t)(fan_table->usFanAcousticLimit)); 178 - hwmgr->thermal_controller.advanceFanControlParameters.usTMax = 179 - le16_to_cpu(fan_table->usTargetTemperature); 180 - hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin = 181 - le16_to_cpu(fan_table->usMinimumPWMLimit); 182 - hwmgr->thermal_controller.advanceFanControlParameters.ulTargetGfxClk = 183 - le32_to_cpu((uint32_t)(fan_table->usTargetGfxClk)); 184 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainEdge = 185 - le16_to_cpu(fan_table->usFanGainEdge); 186 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHotspot = 187 - le16_to_cpu(fan_table->usFanGainHotspot); 188 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainLiquid = 189 - le16_to_cpu(fan_table->usFanGainLiquid); 190 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrVddc = 191 - le16_to_cpu(fan_table->usFanGainVrVddc); 192 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrMvdd = 193 - le16_to_cpu(fan_table->usFanGainVrMvdd); 194 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainPlx = 195 - le16_to_cpu(fan_table->usFanGainPlx); 196 - hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHbm = 197 - le16_to_cpu(fan_table->usFanGainHbm); 163 + phm_cap_set(hwmgr->platform_descriptor.platformCaps, 164 + PHM_PlatformCaps_MicrocodeFanControl); 198 165 199 - hwmgr->thermal_controller.advanceFanControlParameters.ucEnableZeroRPM = 200 - fan_table->ucEnableZeroRPM; 201 - hwmgr->thermal_controller.advanceFanControlParameters.usZeroRPMStopTemperature = 202 - le16_to_cpu(fan_table->usFanStopTemperature); 203 - hwmgr->thermal_controller.advanceFanControlParameters.usZeroRPMStartTemperature = 204 - le16_to_cpu(fan_table->usFanStartTemperature); 166 + hwmgr->thermal_controller.advanceFanControlParameters.usFanOutputSensitivity = 167 + le16_to_cpu(fan_table_v1->usFanOutputSensitivity); 168 + hwmgr->thermal_controller.advanceFanControlParameters.usMaxFanRPM = 169 + le16_to_cpu(fan_table_v1->usFanRPMMax); 170 + hwmgr->thermal_controller.advanceFanControlParameters.usFanRPMMaxLimit = 171 + le16_to_cpu(fan_table_v1->usThrottlingRPM); 172 + hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit = 173 + le16_to_cpu(fan_table_v1->usFanAcousticLimit); 174 + hwmgr->thermal_controller.advanceFanControlParameters.usTMax = 175 + le16_to_cpu(fan_table_v1->usTargetTemperature); 176 + hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin = 177 + le16_to_cpu(fan_table_v1->usMinimumPWMLimit); 178 + hwmgr->thermal_controller.advanceFanControlParameters.ulTargetGfxClk = 179 + le16_to_cpu(fan_table_v1->usTargetGfxClk); 180 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainEdge = 181 + le16_to_cpu(fan_table_v1->usFanGainEdge); 182 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHotspot = 183 + le16_to_cpu(fan_table_v1->usFanGainHotspot); 184 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainLiquid = 185 + le16_to_cpu(fan_table_v1->usFanGainLiquid); 186 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrVddc = 187 + le16_to_cpu(fan_table_v1->usFanGainVrVddc); 188 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrMvdd = 189 + le16_to_cpu(fan_table_v1->usFanGainVrMvdd); 190 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainPlx = 191 + le16_to_cpu(fan_table_v1->usFanGainPlx); 192 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHbm = 193 + le16_to_cpu(fan_table_v1->usFanGainHbm); 205 194 195 + hwmgr->thermal_controller.advanceFanControlParameters.ucEnableZeroRPM = 196 + fan_table_v1->ucEnableZeroRPM; 197 + hwmgr->thermal_controller.advanceFanControlParameters.usZeroRPMStopTemperature = 198 + le16_to_cpu(fan_table_v1->usFanStopTemperature); 199 + hwmgr->thermal_controller.advanceFanControlParameters.usZeroRPMStartTemperature = 200 + le16_to_cpu(fan_table_v1->usFanStartTemperature); 201 + } else if (header->ucRevId > 10) { 202 + fan_table_v2 = (ATOM_Vega10_Fan_Table_V2 *)header; 203 + 204 + hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution = 205 + fan_table_v2->ucFanParameters & ATOM_VEGA10_PP_FANPARAMETERS_TACHOMETER_PULSES_PER_REVOLUTION_MASK; 206 + hwmgr->thermal_controller.fanInfo.ulMinRPM = fan_table_v2->ucFanMinRPM * 100UL; 207 + hwmgr->thermal_controller.fanInfo.ulMaxRPM = fan_table_v2->ucFanMaxRPM * 100UL; 208 + 209 + phm_cap_set(hwmgr->platform_descriptor.platformCaps, 210 + PHM_PlatformCaps_MicrocodeFanControl); 211 + 212 + hwmgr->thermal_controller.advanceFanControlParameters.usFanOutputSensitivity = 213 + le16_to_cpu(fan_table_v2->usFanOutputSensitivity); 214 + hwmgr->thermal_controller.advanceFanControlParameters.usMaxFanRPM = 215 + fan_table_v2->ucFanMaxRPM * 100UL; 216 + hwmgr->thermal_controller.advanceFanControlParameters.usFanRPMMaxLimit = 217 + le16_to_cpu(fan_table_v2->usThrottlingRPM); 218 + hwmgr->thermal_controller.advanceFanControlParameters.ulMinFanSCLKAcousticLimit = 219 + le16_to_cpu(fan_table_v2->usFanAcousticLimitRpm); 220 + hwmgr->thermal_controller.advanceFanControlParameters.usTMax = 221 + le16_to_cpu(fan_table_v2->usTargetTemperature); 222 + hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin = 223 + le16_to_cpu(fan_table_v2->usMinimumPWMLimit); 224 + hwmgr->thermal_controller.advanceFanControlParameters.ulTargetGfxClk = 225 + le16_to_cpu(fan_table_v2->usTargetGfxClk); 226 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainEdge = 227 + le16_to_cpu(fan_table_v2->usFanGainEdge); 228 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHotspot = 229 + le16_to_cpu(fan_table_v2->usFanGainHotspot); 230 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainLiquid = 231 + le16_to_cpu(fan_table_v2->usFanGainLiquid); 232 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrVddc = 233 + le16_to_cpu(fan_table_v2->usFanGainVrVddc); 234 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainVrMvdd = 235 + le16_to_cpu(fan_table_v2->usFanGainVrMvdd); 236 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainPlx = 237 + le16_to_cpu(fan_table_v2->usFanGainPlx); 238 + hwmgr->thermal_controller.advanceFanControlParameters.usFanGainHbm = 239 + le16_to_cpu(fan_table_v2->usFanGainHbm); 240 + 241 + hwmgr->thermal_controller.advanceFanControlParameters.ucEnableZeroRPM = 242 + fan_table_v2->ucEnableZeroRPM; 243 + hwmgr->thermal_controller.advanceFanControlParameters.usZeroRPMStopTemperature = 244 + le16_to_cpu(fan_table_v2->usFanStopTemperature); 245 + hwmgr->thermal_controller.advanceFanControlParameters.usZeroRPMStartTemperature = 246 + le16_to_cpu(fan_table_v2->usFanStartTemperature); 247 + } 206 248 return 0; 207 249 } 208 250 ··· 313 261 return 0; 314 262 } 315 263 264 + static void get_scl_sda_value(uint8_t line, uint8_t *scl, uint8_t* sda) 265 + { 266 + switch(line){ 267 + case Vega10_I2CLineID_DDC1: 268 + *scl = Vega10_I2C_DDC1CLK; 269 + *sda = Vega10_I2C_DDC1DATA; 270 + break; 271 + case Vega10_I2CLineID_DDC2: 272 + *scl = Vega10_I2C_DDC2CLK; 273 + *sda = Vega10_I2C_DDC2DATA; 274 + break; 275 + case Vega10_I2CLineID_DDC3: 276 + *scl = Vega10_I2C_DDC3CLK; 277 + *sda = Vega10_I2C_DDC3DATA; 278 + break; 279 + case Vega10_I2CLineID_DDC4: 280 + *scl = Vega10_I2C_DDC4CLK; 281 + *sda = Vega10_I2C_DDC4DATA; 282 + break; 283 + case Vega10_I2CLineID_DDC5: 284 + *scl = Vega10_I2C_DDC5CLK; 285 + *sda = Vega10_I2C_DDC5DATA; 286 + break; 287 + case Vega10_I2CLineID_DDC6: 288 + *scl = Vega10_I2C_DDC6CLK; 289 + *sda = Vega10_I2C_DDC6DATA; 290 + break; 291 + case Vega10_I2CLineID_SCLSDA: 292 + *scl = Vega10_I2C_SCL; 293 + *sda = Vega10_I2C_SDA; 294 + break; 295 + case Vega10_I2CLineID_DDCVGA: 296 + *scl = Vega10_I2C_DDCVGACLK; 297 + *sda = Vega10_I2C_DDCVGADATA; 298 + break; 299 + default: 300 + *scl = 0; 301 + *sda = 0; 302 + break; 303 + } 304 + } 305 + 316 306 static int get_tdp_table( 317 307 struct pp_hwmgr *hwmgr, 318 308 struct phm_tdp_table **info_tdp_table, ··· 362 268 { 363 269 uint32_t table_size; 364 270 struct phm_tdp_table *tdp_table; 365 - 366 - const ATOM_Vega10_PowerTune_Table *power_tune_table = 367 - (ATOM_Vega10_PowerTune_Table *)table; 368 - 369 - table_size = sizeof(uint32_t) + sizeof(struct phm_cac_tdp_table); 370 - hwmgr->dyn_state.cac_dtp_table = (struct phm_cac_tdp_table *) 371 - kzalloc(table_size, GFP_KERNEL); 372 - 373 - if (!hwmgr->dyn_state.cac_dtp_table) 374 - return -ENOMEM; 271 + uint8_t scl; 272 + uint8_t sda; 273 + const ATOM_Vega10_PowerTune_Table *power_tune_table; 274 + const ATOM_Vega10_PowerTune_Table_V2 *power_tune_table_v2; 375 275 376 276 table_size = sizeof(uint32_t) + sizeof(struct phm_tdp_table); 277 + 377 278 tdp_table = kzalloc(table_size, GFP_KERNEL); 378 279 379 - if (!tdp_table) { 380 - kfree(hwmgr->dyn_state.cac_dtp_table); 381 - hwmgr->dyn_state.cac_dtp_table = NULL; 280 + if (!tdp_table) 382 281 return -ENOMEM; 282 + 283 + if (table->ucRevId == 5) { 284 + power_tune_table = (ATOM_Vega10_PowerTune_Table *)table; 285 + tdp_table->usMaximumPowerDeliveryLimit = le16_to_cpu(power_tune_table->usSocketPowerLimit); 286 + tdp_table->usTDC = le16_to_cpu(power_tune_table->usTdcLimit); 287 + tdp_table->usEDCLimit = le16_to_cpu(power_tune_table->usEdcLimit); 288 + tdp_table->usSoftwareShutdownTemp = 289 + le16_to_cpu(power_tune_table->usSoftwareShutdownTemp); 290 + tdp_table->usTemperatureLimitTedge = 291 + le16_to_cpu(power_tune_table->usTemperatureLimitTedge); 292 + tdp_table->usTemperatureLimitHotspot = 293 + le16_to_cpu(power_tune_table->usTemperatureLimitHotSpot); 294 + tdp_table->usTemperatureLimitLiquid1 = 295 + le16_to_cpu(power_tune_table->usTemperatureLimitLiquid1); 296 + tdp_table->usTemperatureLimitLiquid2 = 297 + le16_to_cpu(power_tune_table->usTemperatureLimitLiquid2); 298 + tdp_table->usTemperatureLimitHBM = 299 + le16_to_cpu(power_tune_table->usTemperatureLimitHBM); 300 + tdp_table->usTemperatureLimitVrVddc = 301 + le16_to_cpu(power_tune_table->usTemperatureLimitVrSoc); 302 + tdp_table->usTemperatureLimitVrMvdd = 303 + le16_to_cpu(power_tune_table->usTemperatureLimitVrMem); 304 + tdp_table->usTemperatureLimitPlx = 305 + le16_to_cpu(power_tune_table->usTemperatureLimitPlx); 306 + tdp_table->ucLiquid1_I2C_address = power_tune_table->ucLiquid1_I2C_address; 307 + tdp_table->ucLiquid2_I2C_address = power_tune_table->ucLiquid2_I2C_address; 308 + tdp_table->ucLiquid_I2C_Line = power_tune_table->ucLiquid_I2C_LineSCL; 309 + tdp_table->ucLiquid_I2C_LineSDA = power_tune_table->ucLiquid_I2C_LineSDA; 310 + tdp_table->ucVr_I2C_address = power_tune_table->ucVr_I2C_address; 311 + tdp_table->ucVr_I2C_Line = power_tune_table->ucVr_I2C_LineSCL; 312 + tdp_table->ucVr_I2C_LineSDA = power_tune_table->ucVr_I2C_LineSDA; 313 + tdp_table->ucPlx_I2C_address = power_tune_table->ucPlx_I2C_address; 314 + tdp_table->ucPlx_I2C_Line = power_tune_table->ucPlx_I2C_LineSCL; 315 + tdp_table->ucPlx_I2C_LineSDA = power_tune_table->ucPlx_I2C_LineSDA; 316 + hwmgr->platform_descriptor.LoadLineSlope = power_tune_table->usLoadLineResistance; 317 + } else { 318 + power_tune_table_v2 = (ATOM_Vega10_PowerTune_Table_V2 *)table; 319 + tdp_table->usMaximumPowerDeliveryLimit = le16_to_cpu(power_tune_table_v2->usSocketPowerLimit); 320 + tdp_table->usTDC = le16_to_cpu(power_tune_table_v2->usTdcLimit); 321 + tdp_table->usEDCLimit = le16_to_cpu(power_tune_table_v2->usEdcLimit); 322 + tdp_table->usSoftwareShutdownTemp = 323 + le16_to_cpu(power_tune_table_v2->usSoftwareShutdownTemp); 324 + tdp_table->usTemperatureLimitTedge = 325 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitTedge); 326 + tdp_table->usTemperatureLimitHotspot = 327 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitHotSpot); 328 + tdp_table->usTemperatureLimitLiquid1 = 329 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitLiquid1); 330 + tdp_table->usTemperatureLimitLiquid2 = 331 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitLiquid2); 332 + tdp_table->usTemperatureLimitHBM = 333 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitHBM); 334 + tdp_table->usTemperatureLimitVrVddc = 335 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitVrSoc); 336 + tdp_table->usTemperatureLimitVrMvdd = 337 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitVrMem); 338 + tdp_table->usTemperatureLimitPlx = 339 + le16_to_cpu(power_tune_table_v2->usTemperatureLimitPlx); 340 + tdp_table->ucLiquid1_I2C_address = power_tune_table_v2->ucLiquid1_I2C_address; 341 + tdp_table->ucLiquid2_I2C_address = power_tune_table_v2->ucLiquid2_I2C_address; 342 + 343 + get_scl_sda_value(power_tune_table_v2->ucLiquid_I2C_Line, &scl, &sda); 344 + 345 + tdp_table->ucLiquid_I2C_Line = scl; 346 + tdp_table->ucLiquid_I2C_LineSDA = sda; 347 + 348 + tdp_table->ucVr_I2C_address = power_tune_table_v2->ucVr_I2C_address; 349 + 350 + get_scl_sda_value(power_tune_table_v2->ucVr_I2C_Line, &scl, &sda); 351 + 352 + tdp_table->ucVr_I2C_Line = scl; 353 + tdp_table->ucVr_I2C_LineSDA = sda; 354 + tdp_table->ucPlx_I2C_address = power_tune_table_v2->ucPlx_I2C_address; 355 + 356 + get_scl_sda_value(power_tune_table_v2->ucPlx_I2C_Line, &scl, &sda); 357 + 358 + tdp_table->ucPlx_I2C_Line = scl; 359 + tdp_table->ucPlx_I2C_LineSDA = sda; 360 + 361 + hwmgr->platform_descriptor.LoadLineSlope = 362 + power_tune_table_v2->usLoadLineResistance; 383 363 } 384 - 385 - tdp_table->usMaximumPowerDeliveryLimit = le16_to_cpu(power_tune_table->usSocketPowerLimit); 386 - tdp_table->usTDC = le16_to_cpu(power_tune_table->usTdcLimit); 387 - tdp_table->usEDCLimit = le16_to_cpu(power_tune_table->usEdcLimit); 388 - tdp_table->usSoftwareShutdownTemp = 389 - le16_to_cpu(power_tune_table->usSoftwareShutdownTemp); 390 - tdp_table->usTemperatureLimitTedge = 391 - le16_to_cpu(power_tune_table->usTemperatureLimitTedge); 392 - tdp_table->usTemperatureLimitHotspot = 393 - le16_to_cpu(power_tune_table->usTemperatureLimitHotSpot); 394 - tdp_table->usTemperatureLimitLiquid1 = 395 - le16_to_cpu(power_tune_table->usTemperatureLimitLiquid1); 396 - tdp_table->usTemperatureLimitLiquid2 = 397 - le16_to_cpu(power_tune_table->usTemperatureLimitLiquid2); 398 - tdp_table->usTemperatureLimitHBM = 399 - le16_to_cpu(power_tune_table->usTemperatureLimitHBM); 400 - tdp_table->usTemperatureLimitVrVddc = 401 - le16_to_cpu(power_tune_table->usTemperatureLimitVrSoc); 402 - tdp_table->usTemperatureLimitVrMvdd = 403 - le16_to_cpu(power_tune_table->usTemperatureLimitVrMem); 404 - tdp_table->usTemperatureLimitPlx = 405 - le16_to_cpu(power_tune_table->usTemperatureLimitPlx); 406 - tdp_table->ucLiquid1_I2C_address = power_tune_table->ucLiquid1_I2C_address; 407 - tdp_table->ucLiquid2_I2C_address = power_tune_table->ucLiquid2_I2C_address; 408 - tdp_table->ucLiquid_I2C_Line = power_tune_table->ucLiquid_I2C_LineSCL; 409 - tdp_table->ucLiquid_I2C_LineSDA = power_tune_table->ucLiquid_I2C_LineSDA; 410 - tdp_table->ucVr_I2C_address = power_tune_table->ucVr_I2C_address; 411 - tdp_table->ucVr_I2C_Line = power_tune_table->ucVr_I2C_LineSCL; 412 - tdp_table->ucVr_I2C_LineSDA = power_tune_table->ucVr_I2C_LineSDA; 413 - tdp_table->ucPlx_I2C_address = power_tune_table->ucPlx_I2C_address; 414 - tdp_table->ucPlx_I2C_Line = power_tune_table->ucPlx_I2C_LineSCL; 415 - tdp_table->ucPlx_I2C_LineSDA = power_tune_table->ucPlx_I2C_LineSDA; 416 - 417 - hwmgr->platform_descriptor.LoadLineSlope = power_tune_table->usLoadLineResistance; 418 364 419 365 *info_tdp_table = tdp_table; 420 366 ··· 970 836 (((unsigned long)powerplay_table) + 971 837 le16_to_cpu(powerplay_table->usVddcLookupTableOffset)); 972 838 result = get_vddc_lookup_table(hwmgr, 973 - &pp_table_info->vddc_lookup_table, vddc_table, 16); 839 + &pp_table_info->vddc_lookup_table, vddc_table, 8); 974 840 } 975 841 976 842 if (powerplay_table->usVddmemLookupTableOffset) { ··· 979 845 (((unsigned long)powerplay_table) + 980 846 le16_to_cpu(powerplay_table->usVddmemLookupTableOffset)); 981 847 result = get_vddc_lookup_table(hwmgr, 982 - &pp_table_info->vddmem_lookup_table, vdd_mem_table, 16); 848 + &pp_table_info->vddmem_lookup_table, vdd_mem_table, 4); 983 849 } 984 850 985 851 if (powerplay_table->usVddciLookupTableOffset) { ··· 988 854 (((unsigned long)powerplay_table) + 989 855 le16_to_cpu(powerplay_table->usVddciLookupTableOffset)); 990 856 result = get_vddc_lookup_table(hwmgr, 991 - &pp_table_info->vddci_lookup_table, vddci_table, 16); 857 + &pp_table_info->vddci_lookup_table, vddci_table, 4); 992 858 } 993 859 994 860 return result;
+28
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h
··· 26 26 27 27 #include "hwmgr.h" 28 28 29 + enum Vega10_I2CLineID { 30 + Vega10_I2CLineID_DDC1 = 0x90, 31 + Vega10_I2CLineID_DDC2 = 0x91, 32 + Vega10_I2CLineID_DDC3 = 0x92, 33 + Vega10_I2CLineID_DDC4 = 0x93, 34 + Vega10_I2CLineID_DDC5 = 0x94, 35 + Vega10_I2CLineID_DDC6 = 0x95, 36 + Vega10_I2CLineID_SCLSDA = 0x96, 37 + Vega10_I2CLineID_DDCVGA = 0x97 38 + }; 39 + 40 + #define Vega10_I2C_DDC1DATA 0 41 + #define Vega10_I2C_DDC1CLK 1 42 + #define Vega10_I2C_DDC2DATA 2 43 + #define Vega10_I2C_DDC2CLK 3 44 + #define Vega10_I2C_DDC3DATA 4 45 + #define Vega10_I2C_DDC3CLK 5 46 + #define Vega10_I2C_SDA 40 47 + #define Vega10_I2C_SCL 41 48 + #define Vega10_I2C_DDC4DATA 65 49 + #define Vega10_I2C_DDC4CLK 66 50 + #define Vega10_I2C_DDC5DATA 0x48 51 + #define Vega10_I2C_DDC5CLK 0x49 52 + #define Vega10_I2C_DDC6DATA 0x4a 53 + #define Vega10_I2C_DDC6CLK 0x4b 54 + #define Vega10_I2C_DDCVGADATA 0x4c 55 + #define Vega10_I2C_DDCVGACLK 0x4d 56 + 29 57 extern const struct pp_table_func vega10_pptable_funcs; 30 58 extern int vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr); 31 59 extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index,
+1 -1
drivers/gpu/drm/radeon/r100.c
··· 3295 3295 mem_trp = ((temp >> 8) & 0x7) + 1; 3296 3296 mem_tras = ((temp >> 11) & 0xf) + 4; 3297 3297 } else if (rdev->family == CHIP_RV350 || 3298 - rdev->family <= CHIP_RV380) { 3298 + rdev->family == CHIP_RV380) { 3299 3299 /* rv3x0 */ 3300 3300 mem_trcd = (temp & 0x7) + 3; 3301 3301 mem_trp = ((temp >> 8) & 0x7) + 3;
+1
drivers/gpu/drm/radeon/radeon.h
··· 499 499 u32 tiling_flags; 500 500 u32 pitch; 501 501 int surface_reg; 502 + unsigned prime_shared_count; 502 503 /* list of all virtual address to which this bo 503 504 * is associated to 504 505 */
+10
drivers/gpu/drm/radeon/radeon_cs.c
··· 164 164 p->relocs[i].allowed_domains = domain; 165 165 } 166 166 167 + /* Objects shared as dma-bufs cannot be moved to VRAM */ 168 + if (p->relocs[i].robj->prime_shared_count) { 169 + p->relocs[i].allowed_domains &= ~RADEON_GEM_DOMAIN_VRAM; 170 + if (!p->relocs[i].allowed_domains) { 171 + DRM_ERROR("BO associated with dma-buf cannot " 172 + "be moved to VRAM\n"); 173 + return -EINVAL; 174 + } 175 + } 176 + 167 177 p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; 168 178 p->relocs[i].tv.shared = !r->write_domain; 169 179
+6
drivers/gpu/drm/radeon/radeon_display.c
··· 1354 1354 return ERR_PTR(-ENOENT); 1355 1355 } 1356 1356 1357 + /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */ 1358 + if (obj->import_attach) { 1359 + DRM_DEBUG_KMS("Cannot create framebuffer from imported dma_buf\n"); 1360 + return ERR_PTR(-EINVAL); 1361 + } 1362 + 1357 1363 radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL); 1358 1364 if (radeon_fb == NULL) { 1359 1365 drm_gem_object_unreference_unlocked(obj);
+4
drivers/gpu/drm/radeon/radeon_gem.c
··· 120 120 return r; 121 121 } 122 122 } 123 + if (domain == RADEON_GEM_DOMAIN_VRAM && robj->prime_shared_count) { 124 + /* A BO that is associated with a dma-buf cannot be sensibly migrated to VRAM */ 125 + return -EINVAL; 126 + } 123 127 return 0; 124 128 } 125 129
+5
drivers/gpu/drm/radeon/radeon_object.c
··· 352 352 353 353 return 0; 354 354 } 355 + if (bo->prime_shared_count && domain == RADEON_GEM_DOMAIN_VRAM) { 356 + /* A BO shared as a dma-buf cannot be sensibly migrated to VRAM */ 357 + return -EINVAL; 358 + } 359 + 355 360 radeon_ttm_placement_from_domain(bo, domain); 356 361 for (i = 0; i < bo->placement.num_placement; i++) { 357 362 /* force to pin into visible video ram */
+6
drivers/gpu/drm/radeon/radeon_prime.c
··· 77 77 list_add_tail(&bo->list, &rdev->gem.objects); 78 78 mutex_unlock(&rdev->gem.mutex); 79 79 80 + bo->prime_shared_count = 1; 80 81 return &bo->gem_base; 81 82 } 82 83 ··· 92 91 93 92 /* pin buffer into GTT */ 94 93 ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL); 94 + if (likely(ret == 0)) 95 + bo->prime_shared_count++; 96 + 95 97 radeon_bo_unreserve(bo); 96 98 return ret; 97 99 } ··· 109 105 return; 110 106 111 107 radeon_bo_unpin(bo); 108 + if (bo->prime_shared_count) 109 + bo->prime_shared_count--; 112 110 radeon_bo_unreserve(bo); 113 111 } 114 112