Skip to content

Commit 8a7a3d1

Browse files
committed
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 <[email protected]> From: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 7ac98ff + da9cebe commit 8a7a3d1

File tree

10 files changed

+166
-59
lines changed

10 files changed

+166
-59
lines changed

Documentation/gpu/amdgpu.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,14 @@ pp_power_profile_mode
197197
.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
198198
:doc: pp_power_profile_mode
199199

200-
busy_percent
201-
~~~~~~~~~~~~
200+
*_busy_percent
201+
~~~~~~~~~~~~~~
202202
203203
.. 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
205208

206209
GPU Product Information
207210
=======================

drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
696696
* default power levels, write "r" (reset) to the file to reset them.
697697
*
698698
*
699-
* < For Vega20 >
699+
* < For Vega20 and newer ASICs >
700700
*
701701
* Reading the file will display:
702702
*
@@ -1668,7 +1668,7 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,
16681668
}
16691669

16701670
/**
1671-
* DOC: busy_percent
1671+
* DOC: gpu_busy_percent
16721672
*
16731673
* The amdgpu driver provides a sysfs API for reading how busy the GPU
16741674
* is as a percentage. The file gpu_busy_percent is used for this.

drivers/gpu/drm/amd/amdkfd/kfd_priv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <drm/drm_file.h>
4141
#include <drm/drm_drv.h>
4242
#include <drm/drm_device.h>
43+
#include <drm/drm_ioctl.h>
4344
#include <kgd_kfd_interface.h>
4445
#include <linux/swap.h>
4546

@@ -1076,7 +1077,7 @@ static inline int kfd_devcgroup_check_permission(struct kfd_dev *kfd)
10761077
#if defined(CONFIG_CGROUP_DEVICE) || defined(CONFIG_CGROUP_BPF)
10771078
struct drm_device *ddev = kfd->ddev;
10781079

1079-
return devcgroup_check_permission(DEVCG_DEV_CHAR, ddev->driver->major,
1080+
return devcgroup_check_permission(DEVCG_DEV_CHAR, DRM_MAJOR,
10801081
ddev->render->index,
10811082
DEVCG_ACC_WRITE | DEVCG_ACC_READ);
10821083
#else

drivers/gpu/drm/amd/display/dc/dsc/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ endif
2828
endif
2929

3030
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)
3331

3432
DSC = dc_dsc.o rc_calc.o rc_calc_dpi.o
3533

drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
* Author: AMD
2323
*/
2424

25+
#include <drm/drm_dsc.h>
2526
#include "dc_hw_types.h"
2627
#include "dsc.h"
2728
#include <drm/drm_dp_helper.h>
2829
#include "dc.h"
30+
#include "rc_calc.h"
2931

3032
/* This module's internal functions */
3133

@@ -304,22 +306,6 @@ static inline uint32_t dsc_div_by_10_round_up(uint32_t value)
304306
return (value + 9) / 10;
305307
}
306308

307-
static inline uint32_t calc_dsc_bpp_x16(uint32_t stream_bandwidth_kbps, uint32_t pix_clk_100hz, uint32_t bpp_increment_div)
308-
{
309-
uint32_t dsc_target_bpp_x16;
310-
float f_dsc_target_bpp;
311-
float f_stream_bandwidth_100bps = stream_bandwidth_kbps * 10.0f;
312-
uint32_t precision = bpp_increment_div; // bpp_increment_div is actually precision
313-
314-
f_dsc_target_bpp = f_stream_bandwidth_100bps / pix_clk_100hz;
315-
316-
// Round down to the nearest precision stop to bring it into DSC spec range
317-
dsc_target_bpp_x16 = (uint32_t)(f_dsc_target_bpp * precision);
318-
dsc_target_bpp_x16 = (dsc_target_bpp_x16 * 16) / precision;
319-
320-
return dsc_target_bpp_x16;
321-
}
322-
323309
/* Get DSC bandwidth range based on [min_bpp, max_bpp] target bitrate range, and timing's pixel clock
324310
* and uncompressed bandwidth.
325311
*/

drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c

Lines changed: 145 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Authors: AMD
2424
*
2525
*/
26+
#include <drm/drm_dsc.h>
2627

2728
#include "os_types.h"
2829
#include "rc_calc.h"
@@ -40,7 +41,8 @@
4041
break
4142

4243

43-
void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc, enum max_min max_min, float bpp)
44+
static void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc,
45+
enum max_min max_min, float bpp)
4446
{
4547
int mode = MODE_SELECT(444, 422, 420);
4648
int sel = table_hash(mode, bpc, max_min);
@@ -85,7 +87,7 @@ void get_qp_set(qp_set qps, enum colour_mode cm, enum bits_per_comp bpc, enum ma
8587
memcpy(qps, table[index].qps, sizeof(qp_set));
8688
}
8789

88-
double dsc_roundf(double num)
90+
static double dsc_roundf(double num)
8991
{
9092
if (num < 0.0)
9193
num = num - 0.5;
@@ -95,7 +97,7 @@ double dsc_roundf(double num)
9597
return (int)(num);
9698
}
9799

98-
double dsc_ceil(double num)
100+
static double dsc_ceil(double num)
99101
{
100102
double retval = (int)num;
101103

@@ -105,7 +107,7 @@ double dsc_ceil(double num)
105107
return (int)retval;
106108
}
107109

108-
void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp)
110+
static void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp)
109111
{
110112
int *p = ofs;
111113

@@ -160,7 +162,7 @@ void get_ofs_set(qp_set ofs, enum colour_mode mode, float bpp)
160162
}
161163
}
162164

163-
int median3(int a, int b, int c)
165+
static int median3(int a, int b, int c)
164166
{
165167
if (a > b)
166168
swap(a, b);
@@ -172,13 +174,25 @@ int median3(int a, int b, int c)
172174
return b;
173175
}
174176

175-
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)
177+
static void _do_calc_rc_params(struct rc_params *rc, enum colour_mode cm,
178+
enum bits_per_comp bpc, u8 drm_bpp,
179+
bool is_navite_422_or_420,
180+
int slice_width, int slice_height,
181+
int minor_version)
176182
{
183+
float bpp;
177184
float bpp_group;
178185
float initial_xmit_delay_factor;
179186
int padding_pixels;
180187
int i;
181188

189+
bpp = ((float)drm_bpp / 16.0);
190+
/* in native_422 or native_420 modes, the bits_per_pixel is double the
191+
* target bpp (the latter is what calc_rc_params expects)
192+
*/
193+
if (is_navite_422_or_420)
194+
bpp /= 2.0;
195+
182196
rc->rc_quant_incr_limit0 = ((bpc == BPC_8) ? 11 : (bpc == BPC_10 ? 15 : 19)) - ((minor_version == 1 && cm == CM_444) ? 1 : 0);
183197
rc->rc_quant_incr_limit1 = ((bpc == BPC_8) ? 11 : (bpc == BPC_10 ? 15 : 19)) - ((minor_version == 1 && cm == CM_444) ? 1 : 0);
184198

@@ -251,3 +265,128 @@ void calc_rc_params(struct rc_params *rc, enum colour_mode cm, enum bits_per_com
251265
rc->rc_buf_thresh[13] = 8064;
252266
}
253267

268+
static u32 _do_bytes_per_pixel_calc(int slice_width, u8 drm_bpp,
269+
bool is_navite_422_or_420)
270+
{
271+
float bpp;
272+
u32 bytes_per_pixel;
273+
double d_bytes_per_pixel;
274+
275+
bpp = ((float)drm_bpp / 16.0);
276+
d_bytes_per_pixel = dsc_ceil(bpp * slice_width / 8.0) / slice_width;
277+
// TODO: Make sure the formula for calculating this is precise (ceiling
278+
// vs. floor, and at what point they should be applied)
279+
if (is_navite_422_or_420)
280+
d_bytes_per_pixel /= 2;
281+
282+
bytes_per_pixel = (u32)dsc_ceil(d_bytes_per_pixel * 0x10000000);
283+
284+
return bytes_per_pixel;
285+
}
286+
287+
static u32 _do_calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz,
288+
u32 bpp_increment_div)
289+
{
290+
u32 dsc_target_bpp_x16;
291+
float f_dsc_target_bpp;
292+
float f_stream_bandwidth_100bps;
293+
// bpp_increment_div is actually precision
294+
u32 precision = bpp_increment_div;
295+
296+
f_stream_bandwidth_100bps = stream_bandwidth_kbps * 10.0f;
297+
f_dsc_target_bpp = f_stream_bandwidth_100bps / pix_clk_100hz;
298+
299+
// Round down to the nearest precision stop to bring it into DSC spec
300+
// range
301+
dsc_target_bpp_x16 = (u32)(f_dsc_target_bpp * precision);
302+
dsc_target_bpp_x16 = (dsc_target_bpp_x16 * 16) / precision;
303+
304+
return dsc_target_bpp_x16;
305+
}
306+
307+
/**
308+
* calc_rc_params - reads the user's cmdline mode
309+
* @rc: DC internal DSC parameters
310+
* @pps: DRM struct with all required DSC values
311+
*
312+
* This function expects a drm_dsc_config data struct with all the required DSC
313+
* values previously filled out by our driver and based on this information it
314+
* computes some of the DSC values.
315+
*
316+
* @note This calculation requires float point operation, most of it executes
317+
* under kernel_fpu_{begin,end}.
318+
*/
319+
void calc_rc_params(struct rc_params *rc, const struct drm_dsc_config *pps)
320+
{
321+
enum colour_mode mode;
322+
enum bits_per_comp bpc;
323+
bool is_navite_422_or_420;
324+
u8 drm_bpp = pps->bits_per_pixel;
325+
int slice_width = pps->slice_width;
326+
int slice_height = pps->slice_height;
327+
328+
mode = pps->convert_rgb ? CM_RGB : (pps->simple_422 ? CM_444 :
329+
(pps->native_422 ? CM_422 :
330+
pps->native_420 ? CM_420 : CM_444));
331+
bpc = (pps->bits_per_component == 8) ? BPC_8 : (pps->bits_per_component == 10)
332+
? BPC_10 : BPC_12;
333+
334+
is_navite_422_or_420 = pps->native_422 || pps->native_420;
335+
336+
DC_FP_START();
337+
_do_calc_rc_params(rc, mode, bpc, drm_bpp, is_navite_422_or_420,
338+
slice_width, slice_height,
339+
pps->dsc_version_minor);
340+
DC_FP_END();
341+
}
342+
343+
/**
344+
* calc_dsc_bytes_per_pixel - calculate bytes per pixel
345+
* @pps: DRM struct with all required DSC values
346+
*
347+
* Based on the information inside drm_dsc_config, this function calculates the
348+
* total of bytes per pixel.
349+
*
350+
* @note This calculation requires float point operation, most of it executes
351+
* under kernel_fpu_{begin,end}.
352+
*
353+
* Return:
354+
* Return the number of bytes per pixel
355+
*/
356+
u32 calc_dsc_bytes_per_pixel(const struct drm_dsc_config *pps)
357+
358+
{
359+
u32 ret;
360+
u8 drm_bpp = pps->bits_per_pixel;
361+
int slice_width = pps->slice_width;
362+
bool is_navite_422_or_420 = pps->native_422 || pps->native_420;
363+
364+
DC_FP_START();
365+
ret = _do_bytes_per_pixel_calc(slice_width, drm_bpp,
366+
is_navite_422_or_420);
367+
DC_FP_END();
368+
return ret;
369+
}
370+
371+
/**
372+
* calc_dsc_bpp_x16 - retrieve the dsc bits per pixel
373+
* @stream_bandwidth_kbps:
374+
* @pix_clk_100hz:
375+
* @bpp_increment_div:
376+
*
377+
* Calculate the total of bits per pixel for DSC configuration.
378+
*
379+
* @note This calculation requires float point operation, most of it executes
380+
* under kernel_fpu_{begin,end}.
381+
*/
382+
u32 calc_dsc_bpp_x16(u32 stream_bandwidth_kbps, u32 pix_clk_100hz,
383+
u32 bpp_increment_div)
384+
{
385+
u32 dsc_bpp;
386+
387+
DC_FP_START();
388+
dsc_bpp = _do_calc_dsc_bpp_x16(stream_bandwidth_kbps, pix_clk_100hz,
389+
bpp_increment_div);
390+
DC_FP_END();
391+
return dsc_bpp;
392+
}

drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ struct qp_entry {
7777

7878
typedef struct qp_entry qp_table[];
7979

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);
8184

8285
#endif
8386

drivers/gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include "dscc_types.h"
2828
#include "rc_calc.h"
2929

30-
double dsc_ceil(double num);
31-
3230
static void copy_pps_fields(struct drm_dsc_config *to, const struct drm_dsc_config *from)
3331
{
3432
to->line_buf_depth = from->line_buf_depth;
@@ -100,34 +98,13 @@ static void copy_rc_to_cfg(struct drm_dsc_config *dsc_cfg, const struct rc_param
10098

10199
int dscc_compute_dsc_parameters(const struct drm_dsc_config *pps, struct dsc_parameters *dsc_params)
102100
{
103-
enum colour_mode mode = pps->convert_rgb ? CM_RGB :
104-
(pps->simple_422 ? CM_444 :
105-
(pps->native_422 ? CM_422 :
106-
pps->native_420 ? CM_420 : CM_444));
107-
enum bits_per_comp bpc = (pps->bits_per_component == 8) ? BPC_8 :
108-
(pps->bits_per_component == 10) ? BPC_10 : BPC_12;
109-
float bpp = ((float) pps->bits_per_pixel / 16.0);
110-
int slice_width = pps->slice_width;
111-
int slice_height = pps->slice_height;
112101
int ret;
113102
struct rc_params rc;
114103
struct drm_dsc_config dsc_cfg;
115104

116-
double d_bytes_per_pixel = dsc_ceil(bpp * slice_width / 8.0) / slice_width;
117-
118-
// TODO: Make sure the formula for calculating this is precise (ceiling vs. floor, and at what point they should be applied)
119-
if (pps->native_422 || pps->native_420)
120-
d_bytes_per_pixel /= 2;
121-
122-
dsc_params->bytes_per_pixel = (uint32_t)dsc_ceil(d_bytes_per_pixel * 0x10000000);
123-
124-
/* in native_422 or native_420 modes, the bits_per_pixel is double the target bpp
125-
* (the latter is what calc_rc_params expects)
126-
*/
127-
if (pps->native_422 || pps->native_420)
128-
bpp /= 2.0;
105+
dsc_params->bytes_per_pixel = calc_dsc_bytes_per_pixel(pps);
129106

130-
calc_rc_params(&rc, mode, bpc, bpp, slice_width, slice_height, pps->dsc_version_minor);
107+
calc_rc_params(&rc, pps);
131108
dsc_params->pps = *pps;
132109
dsc_params->pps.initial_scale_value = 8 * rc.rc_model_size / (rc.rc_model_size - rc.initial_fullness_offset);
133110

drivers/gpu/drm/amd/display/modules/color/color_gamma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ static bool build_regamma(struct pwl_float_data_ex *rgb_regamma,
843843
pow_buffer_ptr = -1; // reset back to no optimize
844844
ret = true;
845845
release:
846-
kfree(coeff);
846+
kvfree(coeff);
847847
return ret;
848848
}
849849

@@ -1777,7 +1777,7 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
17771777

17781778
kfree(rgb_regamma);
17791779
rgb_regamma_alloc_fail:
1780-
kvfree(rgb_user);
1780+
kfree(rgb_user);
17811781
rgb_user_alloc_fail:
17821782
return ret;
17831783
}

drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static void ci_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
239239

240240
switch (dev_id) {
241241
case 0x67BA:
242-
case 0x66B1:
242+
case 0x67B1:
243243
smu_data->power_tune_defaults = &defaults_hawaii_pro;
244244
break;
245245
case 0x67B8:

0 commit comments

Comments
 (0)