Port of amdgpu watermark improvements to radeon-kms.
Subsystems (2)
Hi,
a direct port of the patches we already have in amdgpu, for completeness.
These are tested on an old HD-5770, DCE4 only.
-mario
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1492990389-10156-1-git-send-email-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/2 drm/radeon: Avoid overflows/divide-by-zero in latency_watermark calculations.
At dot clocks > approx. 250 Mhz, some of these calcs will overflow and cause miscalculation of latency watermarks, and for some overflows also divide-by-zero driver crash. Make calcs more overflow resistant.
This is a direct port of the corresponding patch from amdgpu-kms, copy-paste for cik from dce-8 and si from dce-6, with a slightly simpler variant for evergreen dce-4/5.
Only tested on DCE-4 evergreen with a Radeon HD-5770.
--- drivers/gpu/drm/radeon/cik.c | 19 +++---------------- drivers/gpu/drm/radeon/evergreen.c | 8 +------- drivers/gpu/drm/radeon/si.c | 19 +++---------------- 3 files changed, 7 insertions(+), 39 deletions(-)
drivers/gpu/drm/radeon/cik.c +3 -16
@@ -9150,23 +9150,10 @@ static u32 dce8_latency_watermark(struct dce8_wm_params *wm) a.full =dfixed_const (available_bandwidth); b.full =dfixed_const (wm->num_heads); a.full =dfixed_div (a, b); + tmp =div_u64 ((u64 ) dmif_size * (u64 ) wm->disp_clk, mc_latency +512 ); + tmp =min (dfixed_trunc (a), tmp); - b.full =dfixed_const (mc_latency +512 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (b, c); - - c.full =dfixed_const (dmif_size); - b.full =dfixed_div (c, b); - - tmp =min (dfixed_trunc (a),dfixed_trunc (b)); - - b.full =dfixed_const (1000 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (c, b); - c.full =dfixed_const (wm->bytes_per_pixel); - b.full =dfixed_mul (b, c); - - lb_fill_bw =min (tmp,dfixed_trunc (b)); + lb_fill_bw =min (tmp, wm->disp_clk * wm->bytes_per_pixel /1000 ); a.full =dfixed_const (max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); b.full =dfixed_const (1000 );
drivers/gpu/drm/radeon/evergreen.c +1 -7
@@ -2188,13 +2188,7 @@ static u32 evergreen_latency_watermark(struct evergreen_wm_params *wm) b.full =dfixed_const (wm->num_heads); a.full =dfixed_div (a, b); - b.full =dfixed_const (1000 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (c, b); - c.full =dfixed_const (wm->bytes_per_pixel); - b.full =dfixed_mul (b, c); - - lb_fill_bw =min (dfixed_trunc (a),dfixed_trunc (b)); + lb_fill_bw =min (dfixed_trunc (a), wm->disp_clk * wm->bytes_per_pixel /1000 ); a.full =dfixed_const (max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); b.full =dfixed_const (1000 );
drivers/gpu/drm/radeon/si.c +3 -16
@@ -2204,23 +2204,10 @@ static u32 dce6_latency_watermark(struct dce6_wm_params *wm) a.full =dfixed_const (available_bandwidth); b.full =dfixed_const (wm->num_heads); a.full =dfixed_div (a, b); + tmp =div_u64 ((u64 ) dmif_size * (u64 ) wm->disp_clk, mc_latency +512 ); + tmp =min (dfixed_trunc (a), tmp); - b.full =dfixed_const (mc_latency +512 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (b, c); - - c.full =dfixed_const (dmif_size); - b.full =dfixed_div (c, b); - - tmp =min (dfixed_trunc (a),dfixed_trunc (b)); - - b.full =dfixed_const (1000 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (c, b); - c.full =dfixed_const (wm->bytes_per_pixel); - b.full =dfixed_mul (b, c); - - lb_fill_bw =min (tmp,dfixed_trunc (b)); + lb_fill_bw =min (tmp, wm->disp_clk * wm->bytes_per_pixel /1000 ); a.full =dfixed_const (max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); b.full =dfixed_const (1000 );
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1492990389-10156-2-git-send-email-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Alex Deucher
AppliedRe: [PATCH 1/2] drm/radeon: Avoid overflows/divide-by-zero in latency_watermark calculations.
Quoted 4 lines · Mario Kleiner
At dot clocks > approx. 250 Mhz, some of these calcs will overflow and cause miscalculation of latency watermarks, and for some overflows also divide-by-zero driver crash. Make calcs more overflow resistant.
Quoted 8 lines
This is a direct port of the corresponding patch from amdgpu-kms, copy-paste for cik from dce-8 and si from dce-6, with a slightly simpler variant for evergreen dce-4/5.
Only tested on DCE-4 evergreen with a Radeon HD-5770.
Signed-off-by Mario Kleiner <[email protected]>Cc Alex Deucher <[email protected]>
Applied the series. thanks!
Alex
Quoted 90 lines
--- drivers/gpu/drm/radeon/cik.c | 19 +++---------------- drivers/gpu/drm/radeon/evergreen.c | 8 +------- drivers/gpu/drm/radeon/si.c | 19 +++---------------- 3 files changed, 7 insertions(+), 39 deletions(-)drivers/gpu/drm/radeon/cik.c +3
-16@@ -9150,23 +9150,10 @@ static u32 dce8_latency_watermark(struct dce8_wm_params *wm) a.full =dfixed_const (available_bandwidth); b.full =dfixed_const (wm->num_heads); a.full =dfixed_div (a, b); + tmp =div_u64 ((u64 ) dmif_size * (u64 ) wm->disp_clk, mc_latency +512 ); + tmp =min (dfixed_trunc (a), tmp); - b.full =dfixed_const (mc_latency +512 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (b, c); - - c.full =dfixed_const (dmif_size); - b.full =dfixed_div (c, b); - - tmp =min (dfixed_trunc (a),dfixed_trunc (b)); - - b.full =dfixed_const (1000 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (c, b); - c.full =dfixed_const (wm->bytes_per_pixel); - b.full =dfixed_mul (b, c); - - lb_fill_bw =min (tmp,dfixed_trunc (b)); + lb_fill_bw =min (tmp, wm->disp_clk * wm->bytes_per_pixel /1000 ); a.full =dfixed_const (max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); b.full =dfixed_const (1000 );drivers/gpu/drm/radeon/evergreen.c +1
-7@@ -2188,13 +2188,7 @@ static u32 evergreen_latency_watermark(struct evergreen_wm_params *wm) b.full =dfixed_const (wm->num_heads); a.full =dfixed_div (a, b); - b.full =dfixed_const (1000 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (c, b); - c.full =dfixed_const (wm->bytes_per_pixel); - b.full =dfixed_mul (b, c); - - lb_fill_bw =min (dfixed_trunc (a),dfixed_trunc (b)); + lb_fill_bw =min (dfixed_trunc (a), wm->disp_clk * wm->bytes_per_pixel /1000 ); a.full =dfixed_const (max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); b.full =dfixed_const (1000 );drivers/gpu/drm/radeon/si.c +3
-17@@ -2204,23 +2204,10 @@ static u32 dce6_latency_watermark(struct dce6_wm_params *wm) a.full =dfixed_const (available_bandwidth); b.full =dfixed_const (wm->num_heads); a.full =dfixed_div (a, b); + tmp =div_u64 ((u64 ) dmif_size * (u64 ) wm->disp_clk, mc_latency +512 ); + tmp =min (dfixed_trunc (a), tmp); - b.full =dfixed_const (mc_latency +512 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (b, c); - - c.full =dfixed_const (dmif_size); - b.full =dfixed_div (c, b); - - tmp =min (dfixed_trunc (a),dfixed_trunc (b)); - - b.full =dfixed_const (1000 ); - c.full =dfixed_const (wm->disp_clk); - b.full =dfixed_div (c, b); - c.full =dfixed_const (wm->bytes_per_pixel); - b.full =dfixed_mul (b, c); - - lb_fill_bw =min (tmp,dfixed_trunc (b)); + lb_fill_bw =min (tmp, wm->disp_clk * wm->bytes_per_pixel /1000 ); a.full =dfixed_const (max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); b.full =dfixed_const (1000 ); --2.7.4
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/radeon: Make display watermark calculations more accurate
In reply to Mario KleinerAvoid big roundoff errors in scanline/hactive durations for high pixel clocks, especially for >= 500 Mhz, and thereby program more accurate display fifo watermarks.
This is a port of the corresponding amdgpu patch.
Implemented for DCE 4,6,8.
Tested on Evergreen/DCE-4 with Radeon HD-5770.
--- drivers/gpu/drm/radeon/cik.c | 10 +++++----- drivers/gpu/drm/radeon/evergreen.c | 10 +++++----- drivers/gpu/drm/radeon/si.c | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/radeon/cik.c +5 -5
@@ -9261,14 +9261,14 @@ static void dce8_program_watermarks(struct radeon_device *rdev, {struct drm_display_mode *mode = &radeon_crtc->base.mode;struct dce8_wm_params wm_low, wm_high; -u32 pixel_period; +u32 active_time;u32 line_time =0 ;u32 latency_watermark_a =0 , latency_watermark_b =0 ;u32 tmp, wm_mask;if (radeon_crtc->base.enabled && num_heads && mode) { - pixel_period =1000000 / (u32 )mode->clock; - line_time =min ((u32 )mode->crtc_htotal * pixel_period, (u32 )65535 ); + active_time =1000000UL * (u32 )mode->crtc_hdisplay / (u32 )mode->clock; + line_time =min ((u32) (1000000UL * (u32 )mode->crtc_htotal / (u32 )mode->clock), (u32 )65535 );/* watermark for high clocks */ if ((rdev->pm.pm_method == PM_METHOD_DPM) &&
@@ -9284,7 +9284,7 @@ static void dce8_program_watermarks(struct radeon_device *rdev, wm_high.disp_clk = mode->clock; wm_high.src_width = mode->crtc_hdisplay; - wm_high.active_time = mode->crtc_hdisplay * pixel_period; + wm_high.active_time = active_time; wm_high.blank_time = line_time - wm_high.active_time; wm_high.interlaced = false;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
@@ -9324,7 +9324,7 @@ static void dce8_program_watermarks(struct radeon_device *rdev, wm_low.disp_clk = mode->clock; wm_low.src_width = mode->crtc_hdisplay; - wm_low.active_time = mode->crtc_hdisplay * pixel_period; + wm_low.active_time = active_time; wm_low.blank_time = line_time - wm_low.active_time; wm_low.interlaced = false;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
drivers/gpu/drm/radeon/evergreen.c +5 -5
@@ -2255,7 +2255,7 @@ static void evergreen_program_watermarks(struct radeon_device *rdev,struct drm_display_mode *mode = &radeon_crtc->base.mode;struct evergreen_wm_params wm_low, wm_high;u32 dram_channels; -u32 pixel_period; +u32 active_time;u32 line_time =0 ;u32 latency_watermark_a =0 , latency_watermark_b =0 ;u32 priority_a_mark =0 , priority_b_mark =0 ;
@@ -2266,8 +2266,8 @@ static void evergreen_program_watermarks(struct radeon_device *rdev,fixed20_12 a, b, c;if (radeon_crtc->base.enabled && num_heads && mode) { - pixel_period =1000000 / (u32 )mode->clock; - line_time =min ((u32 )mode->crtc_htotal * pixel_period, (u32 )65535 ); + active_time =1000000UL * (u32 )mode->crtc_hdisplay / (u32 )mode->clock; + line_time =min ((u32) (1000000UL * (u32 )mode->crtc_htotal / (u32 )mode->clock), (u32 )65535 ); priority_a_cnt =0 ; priority_b_cnt =0 ; dram_channels =evergreen_get_number_of_dram_channels (rdev);
@@ -2285,7 +2285,7 @@ static void evergreen_program_watermarks(struct radeon_device *rdev, wm_high.disp_clk = mode->clock; wm_high.src_width = mode->crtc_hdisplay; - wm_high.active_time = mode->crtc_hdisplay * pixel_period; + wm_high.active_time = active_time; wm_high.blank_time = line_time - wm_high.active_time; wm_high.interlaced = false;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
@@ -2312,7 +2312,7 @@ static void evergreen_program_watermarks(struct radeon_device *rdev, wm_low.disp_clk = mode->clock; wm_low.src_width = mode->crtc_hdisplay; - wm_low.active_time = mode->crtc_hdisplay * pixel_period; + wm_low.active_time = active_time; wm_low.blank_time = line_time - wm_low.active_time; wm_low.interlaced = false;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
drivers/gpu/drm/radeon/si.c +5 -5
@@ -2274,7 +2274,7 @@ static void dce6_program_watermarks(struct radeon_device *rdev,struct drm_display_mode *mode = &radeon_crtc->base.mode;struct dce6_wm_params wm_low, wm_high;u32 dram_channels; -u32 pixel_period; +u32 active_time;u32 line_time =0 ;u32 latency_watermark_a =0 , latency_watermark_b =0 ;u32 priority_a_mark =0 , priority_b_mark =0 ;
@@ -2284,8 +2284,8 @@ static void dce6_program_watermarks(struct radeon_device *rdev,fixed20_12 a, b, c;if (radeon_crtc->base.enabled && num_heads && mode) { - pixel_period =1000000 / (u32 )mode->clock; - line_time =min ((u32 )mode->crtc_htotal * pixel_period, (u32 )65535 ); + active_time =1000000UL * (u32 )mode->crtc_hdisplay / (u32 )mode->clock; + line_time =min ((u32) (1000000UL * (u32 )mode->crtc_htotal / (u32 )mode->clock), (u32 )65535 ); priority_a_cnt =0 ; priority_b_cnt =0 ;
@@ -2307,7 +2307,7 @@ static void dce6_program_watermarks(struct radeon_device *rdev, wm_high.disp_clk = mode->clock; wm_high.src_width = mode->crtc_hdisplay; - wm_high.active_time = mode->crtc_hdisplay * pixel_period; + wm_high.active_time = active_time; wm_high.blank_time = line_time - wm_high.active_time; wm_high.interlaced = false;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
@@ -2334,7 +2334,7 @@ static void dce6_program_watermarks(struct radeon_device *rdev, wm_low.disp_clk = mode->clock; wm_low.src_width = mode->crtc_hdisplay; - wm_low.active_time = mode->crtc_hdisplay * pixel_period; + wm_low.active_time = active_time; wm_low.blank_time = line_time - wm_low.active_time; wm_low.interlaced = false;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel