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

Merge tag 'amd-drm-fixes-5.8-2020-06-17' of git://people.freedesktop.org/~agd5f/linux into drm-fixes

amd-drm-fixes-5.8-2020-06-17:

amdgpu:
- Fix kvfree/kfree mixup
- Fix hawaii device id in powertune configuration
- Display FP fixes
- Documentation fixes

amdkfd:
- devcgroup check fix

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Alex Deucher <alexdeucher@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200617220733.3773183-1-alexander.deucher@amd.com

+166 -59
+6 -3
Documentation/gpu/amdgpu.rst
··· 197 197 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 198 198 :doc: pp_power_profile_mode 199 199 200 - busy_percent 201 - ~~~~~~~~~~~~ 200 + *_busy_percent 201 + ~~~~~~~~~~~~~~ 202 202 203 203 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 204 - :doc: busy_percent 204 + :doc: gpu_busy_percent 205 + 206 + .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c 207 + :doc: mem_busy_percent 205 208 206 209 GPU Product Information 207 210 =======================
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
··· 696 696 * default power levels, write "r" (reset) to the file to reset them. 697 697 * 698 698 * 699 - * < For Vega20 > 699 + * < For Vega20 and newer ASICs > 700 700 * 701 701 * Reading the file will display: 702 702 * ··· 1668 1668 } 1669 1669 1670 1670 /** 1671 - * DOC: busy_percent 1671 + * DOC: gpu_busy_percent 1672 1672 * 1673 1673 * The amdgpu driver provides a sysfs API for reading how busy the GPU 1674 1674 * is as a percentage. The file gpu_busy_percent is used for this.
+2 -1
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 40 40 #include <drm/drm_file.h> 41 41 #include <drm/drm_drv.h> 42 42 #include <drm/drm_device.h> 43 + #include <drm/drm_ioctl.h> 43 44 #include <kgd_kfd_interface.h> 44 45 #include <linux/swap.h> 45 46 ··· 1077 1076 #if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF) 1078 1077 struct drm_device *ddev = kfd->ddev; 1079 1078 1080 - return devcgroup_check_permission(DEVCG_DEV_CHAR, ddev->driver->major, 1079 + return devcgroup_check_permission(DEVCG_DEV_CHAR, DRM_MAJOR, 1081 1080 ddev->render->index, 1082 1081 DEVCG_ACC_WRITE | DEVCG_ACC_READ); 1083 1082 #else
-2
drivers/gpu/drm/amd/display/dc/dsc/Makefile
··· 28 28 endif 29 29 30 30 CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc.o := $(dsc_ccflags) 31 - CFLAGS_$(AMDDALPATH)/dc/dsc/rc_calc_dpi.o := $(dsc_ccflags) 32 - CFLAGS_$(AMDDALPATH)/dc/dsc/dc_dsc.o := $(dsc_ccflags) 33 31 34 32 DSC = dc_dsc.o rc_calc.o rc_calc_dpi.o 35 33
+2 -16
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c
··· 22 22 * Author: AMD 23 23 */ 24 24 25 + #include <drm/drm_dsc.h> 25 26 #include "dc_hw_types.h" 26 27 #include "dsc.h" 27 28 #include <drm/drm_dp_helper.h> 28 29 #include "dc.h" 30 + #include "rc_calc.h" 29 31 30 32 /* This module's internal functions */ 31 33 ··· 304 302 static inline uint32_t dsc_div_by_10_round_up(uint32_t value) 305 303 { 306 304 return (value + 9) / 10; 307 - } 308 - 309 - static inline uint32_t calc_dsc_bpp_x16(uint32_t stream_bandwidth_kbps, uint32_t pix_clk_100hz, uint32_t bpp_increment_div) 310 - { 311 - uint32_t dsc_target_bpp_x16; 312 - float f_dsc_target_bpp; 313 - float f_stream_bandwidth_100bps = stream_bandwidth_kbps * 10.0f; 314 - uint32_t precision = bpp_increment_div; // bpp_increment_div is actually precision 315 - 316 - f_dsc_target_bpp = f_stream_bandwidth_100bps / pix_clk_100hz; 317 - 318 - // Round down to the nearest precision stop to bring it into DSC spec range 319 - dsc_target_bpp_x16 = (uint32_t)(f_dsc_target_bpp * precision); 320 - dsc_target_bpp_x16 = (dsc_target_bpp_x16 * 16) / precision; 321 - 322 - return dsc_target_bpp_x16; 323 305 } 324 306 325 307 /* Get DSC bandwidth range based on [min_bpp, max_bpp] target bitrate range, and timing's pixel clock
+145 -6
drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c
··· 23 23 * Authors: AMD 24 24 * 25 25 */ 26 + #include <drm/drm_dsc.h> 26 27 27 28 #include "os_types.h" 28 29 #include "rc_calc.h" ··· 41 40 break 42 41 43 42 44 - void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc, enum max_min max_min, float bpp) 43 + static void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc, 44 + enum max_min max_min, float bpp) 45 45 { 46 46 int mode = MODE_SELECT(444, 422, 420); 47 47 int sel = table_hash(mode, bpc, max_min); ··· 87 85 memcpy(qps, table[index].qps, sizeof(qp_set)); 88 86 } 89 87 90 - double dsc_roundf(double num) 88 + static double dsc_roundf(double num) 91 89 { 92 90 if (num < 0.0) 93 91 num = num - 0.5; ··· 97 95 return (int)(num); 98 96 } 99 97 100 - double dsc_ceil(double num) 98 + static double dsc_ceil(double num) 101 99 { 102 100 double retval = (int)num; 103 101 ··· 107 105 return (int)retval; 108 106 } 109 107 110 - void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp) 108 + static void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp) 111 109 { 112 110 int *p = ofs; 113 111 ··· 162 160 } 163 161 } 164 162 165 - int median3(int a, int b, int c) 163 + static int median3(int a, int b, int c) 166 164 { 167 165 if (a > b) 168 166 swap(a, b); ··· 174 172 return b; 175 173 } 176 174 177 - void calc_rc_params(struct rc_params *rc, enum colour_mode cm, enum bits_per_comp bpc, float bpp, int slice_width, int slice_height, int minor_version) 175 + static void _do_calc_rc_params(struct rc_params *rc, enum colour_mode cm, 176 + enum bits_per_comp bpc, u8 drm_bpp, 177 + bool is_navite_422_or_420, 178 + int slice_width, int slice_height, 179 + int minor_version) 178 180 { 181 + float bpp; 179 182 float bpp_group; 180 183 float initial_xmit_delay_factor; 181 184 int padding_pixels; 182 185 int i; 186 + 187 + bpp = ((float)drm_bpp / 16.0); 188 + /* in native_422 or native_420 modes, the bits_per_pixel is double the 189 + * target bpp (the latter is what calc_rc_params expects) 190 + */ 191 + if (is_navite_422_or_420) 192 + bpp /= 2.0; 183 193 184 194 rc->rc_quant_incr_limit0 = ((bpc == BPC_8) ? 11 : (bpc == BPC_10 ? 15 : 19)) - ((minor_version == 1 && cm == CM_444) ? 1 : 0); 185 195 rc->rc_quant_incr_limit1 = ((bpc == BPC_8) ? 11 : (bpc == BPC_10 ? 15 : 19)) - ((minor_version == 1 && cm == CM_444) ? 1 : 0); ··· 265 251 rc->rc_buf_thresh[13] = 8064; 266 252 } 267 253 254 + static u32 _do_bytes_per_pixel_calc(int slice_width, u8 drm_bpp, 255 + bool is_navite_422_or_420) 256 + { 257 + float bpp; 258 + u32 bytes_per_pixel; 259 + double d_bytes_per_pixel; 260 + 261 + bpp = ((float)drm_bpp / 16.0); 262 + d_bytes_per_pixel = dsc_ceil(bpp * slice_width / 8.0) / slice_width; 263 + // TODO: Make sure the formula for calculating this is precise (ceiling 264 + // vs. floor, and at what point they should be applied) 265 + if (is_navite_422_or_420) 266 + d_bytes_per_pixel /= 2; 267 + 268 + bytes_per_pixel = (u32)dsc_ceil(d_bytes_per_pixel * 0x10000000); 269 + 270 + return bytes_per_pixel; 271 + } 272 + 273 + static u32 _do_calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz, 274 + u32 bpp_increment_div) 275 + { 276 + u32 dsc_target_bpp_x16; 277 + float f_dsc_target_bpp; 278 + float f_stream_bandwidth_100bps; 279 + // bpp_increment_div is actually precision 280 + u32 precision = bpp_increment_div; 281 + 282 + f_stream_bandwidth_100bps = stream_bandwidth_kbps * 10.0f; 283 + f_dsc_target_bpp = f_stream_bandwidth_100bps / pix_clk_100hz; 284 + 285 + // Round down to the nearest precision stop to bring it into DSC spec 286 + // range 287 + dsc_target_bpp_x16 = (u32)(f_dsc_target_bpp * precision); 288 + dsc_target_bpp_x16 = (dsc_target_bpp_x16 * 16) / precision; 289 + 290 + return dsc_target_bpp_x16; 291 + } 292 + 293 + /** 294 + * calc_rc_params - reads the user's cmdline mode 295 + * @rc: DC internal DSC parameters 296 + * @pps: DRM struct with all required DSC values 297 + * 298 + * This function expects a drm_dsc_config data struct with all the required DSC 299 + * values previously filled out by our driver and based on this information it 300 + * computes some of the DSC values. 301 + * 302 + * @note This calculation requires float point operation, most of it executes 303 + * under kernel_fpu_{begin,end}. 304 + */ 305 + void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps) 306 + { 307 + enum colour_mode mode; 308 + enum bits_per_comp bpc; 309 + bool is_navite_422_or_420; 310 + u8 drm_bpp = pps->bits_per_pixel; 311 + int slice_width = pps->slice_width; 312 + int slice_height = pps->slice_height; 313 + 314 + mode = pps->convert_rgb ? CM_RGB : (pps->simple_422 ? CM_444 : 315 + (pps->native_422 ? CM_422 : 316 + pps->native_420 ? CM_420 : CM_444)); 317 + bpc = (pps->bits_per_component == 8) ? BPC_8 : (pps->bits_per_component == 10) 318 + ? BPC_10 : BPC_12; 319 + 320 + is_navite_422_or_420 = pps->native_422 || pps->native_420; 321 + 322 + DC_FP_START(); 323 + _do_calc_rc_params(rc, mode, bpc, drm_bpp, is_navite_422_or_420, 324 + slice_width, slice_height, 325 + pps->dsc_version_minor); 326 + DC_FP_END(); 327 + } 328 + 329 + /** 330 + * calc_dsc_bytes_per_pixel - calculate bytes per pixel 331 + * @pps: DRM struct with all required DSC values 332 + * 333 + * Based on the information inside drm_dsc_config, this function calculates the 334 + * total of bytes per pixel. 335 + * 336 + * @note This calculation requires float point operation, most of it executes 337 + * under kernel_fpu_{begin,end}. 338 + * 339 + * Return: 340 + * Return the number of bytes per pixel 341 + */ 342 + u32 calc_dsc_bytes_per_pixel(const struct drm_dsc_config *pps) 343 + 344 + { 345 + u32 ret; 346 + u8 drm_bpp = pps->bits_per_pixel; 347 + int slice_width = pps->slice_width; 348 + bool is_navite_422_or_420 = pps->native_422 || pps->native_420; 349 + 350 + DC_FP_START(); 351 + ret = _do_bytes_per_pixel_calc(slice_width, drm_bpp, 352 + is_navite_422_or_420); 353 + DC_FP_END(); 354 + return ret; 355 + } 356 + 357 + /** 358 + * calc_dsc_bpp_x16 - retrieve the dsc bits per pixel 359 + * @stream_bandwidth_kbps: 360 + * @pix_clk_100hz: 361 + * @bpp_increment_div: 362 + * 363 + * Calculate the total of bits per pixel for DSC configuration. 364 + * 365 + * @note This calculation requires float point operation, most of it executes 366 + * under kernel_fpu_{begin,end}. 367 + */ 368 + u32 calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz, 369 + u32 bpp_increment_div) 370 + { 371 + u32 dsc_bpp; 372 + 373 + DC_FP_START(); 374 + dsc_bpp = _do_calc_dsc_bpp_x16(stream_bandwidth_kbps, pix_clk_100hz, 375 + bpp_increment_div); 376 + DC_FP_END(); 377 + return dsc_bpp; 378 + }
+4 -1
drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h
··· 77 77 78 78 typedef struct qp_entry qp_table[]; 79 79 80 - void calc_rc_params(struct rc_params *rc, enum colour_mode cm, enum bits_per_comp bpc, float bpp, int slice_width, int slice_height, int minor_version); 80 + void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps); 81 + u32 calc_dsc_bytes_per_pixel(const struct drm_dsc_config *pps); 82 + u32 calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz, 83 + u32 bpp_increment_div); 81 84 82 85 #endif 83 86
+2 -25
drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c
··· 27 27 #include "dscc_types.h" 28 28 #include "rc_calc.h" 29 29 30 - double dsc_ceil(double num); 31 - 32 30 static void copy_pps_fields(struct drm_dsc_config *to, const struct drm_dsc_config *from) 33 31 { 34 32 to->line_buf_depth = from->line_buf_depth; ··· 98 100 99 101 int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_parameters *dsc_params) 100 102 { 101 - enum colour_mode mode = pps->convert_rgb ? CM_RGB : 102 - (pps->simple_422 ? CM_444 : 103 - (pps->native_422 ? CM_422 : 104 - pps->native_420 ? CM_420 : CM_444)); 105 - enum bits_per_comp bpc = (pps->bits_per_component == 8) ? BPC_8 : 106 - (pps->bits_per_component == 10) ? BPC_10 : BPC_12; 107 - float bpp = ((float) pps->bits_per_pixel / 16.0); 108 - int slice_width = pps->slice_width; 109 - int slice_height = pps->slice_height; 110 103 int ret; 111 104 struct rc_params rc; 112 105 struct drm_dsc_config dsc_cfg; 113 106 114 - double d_bytes_per_pixel = dsc_ceil(bpp * slice_width / 8.0) / slice_width; 107 + dsc_params->bytes_per_pixel = calc_dsc_bytes_per_pixel(pps); 115 108 116 - // TODO: Make sure the formula for calculating this is precise (ceiling vs. floor, and at what point they should be applied) 117 - if (pps->native_422 || pps->native_420) 118 - d_bytes_per_pixel /= 2; 119 - 120 - dsc_params->bytes_per_pixel = (uint32_t)dsc_ceil(d_bytes_per_pixel * 0x10000000); 121 - 122 - /* in native_422 or native_420 modes, the bits_per_pixel is double the target bpp 123 - * (the latter is what calc_rc_params expects) 124 - */ 125 - if (pps->native_422 || pps->native_420) 126 - bpp /= 2.0; 127 - 128 - calc_rc_params(&rc, mode, bpc, bpp, slice_width, slice_height, pps->dsc_version_minor); 109 + calc_rc_params(&rc, pps); 129 110 dsc_params->pps = *pps; 130 111 dsc_params->pps.initial_scale_value = 8 * rc.rc_model_size / (rc.rc_model_size - rc.initial_fullness_offset); 131 112
+2 -2
drivers/gpu/drm/amd/display/modules/color/color_gamma.c
··· 843 843 pow_buffer_ptr = -1; // reset back to no optimize 844 844 ret = true; 845 845 release: 846 - kfree(coeff); 846 + kvfree(coeff); 847 847 return ret; 848 848 } 849 849 ··· 1777 1777 1778 1778 kfree(rgb_regamma); 1779 1779 rgb_regamma_alloc_fail: 1780 - kvfree(rgb_user); 1780 + kfree(rgb_user); 1781 1781 rgb_user_alloc_fail: 1782 1782 return ret; 1783 1783 }
+1 -1
drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
··· 239 239 240 240 switch (dev_id) { 241 241 case 0x67BA: 242 - case 0x66B1: 242 + case 0x67B1: 243 243 smu_data->power_tune_defaults = &defaults_hawaii_pro; 244 244 break; 245 245 case 0x67B8: