All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation
@ 2020-02-20 16:08 Stanislav Lisovskiy
  2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stanislav Lisovskiy @ 2020-02-20 16:08 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

There seems to be a bit of confusing redundancy in a way, how
plane data rate/min cdclk are calculated.
In fact both min cdclk, pixel rate and plane data rate are all
part of the same formula as per BSpec.

However currently we have intel_plane_data_rate, which is used
to calculate plane data rate and which is also used in bandwidth
calculations. However for calculating min_cdclk we have another
piece of code, doing almost same calculation, but a bit differently
and in a different place. However as both are actually part of same
formula, probably would be wise to use plane data rate calculations
as a basis anyway, thus avoiding code duplication and possible bugs
related to this.

Another thing is that I've noticed that during min_cdclk calculations
we account for plane scaling, while for plane data rate, we don't.
crtc->pixel_rate seems to account only for pipe ratio, however it is
clearly stated in BSpec that plane data rate also need to account
plane ratio as well.

So what this commit does is:
- Adds a plane ratio calculation to intel_plane_data_rate
- Removes redundant calculations from skl_plane_min_cdclk which is
  used for gen9+ and now uses intel_plane_data_rate as a basis from
  there as well.

v2: - Don't use 64 division if not needed(Ville Syrjälä)
    - Now use intel_plane_pixel_rate as a basis for calculations both
      at intel_plane_data_rate and skl_plane_min_cdclk(Ville Syrjälä)

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
---
 .../gpu/drm/i915/display/intel_atomic_plane.c | 22 +++++++++++++++-
 .../gpu/drm/i915/display/intel_atomic_plane.h |  3 +++
 drivers/gpu/drm/i915/display/intel_sprite.c   | 26 +++++++------------
 3 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index c86d7a35c816..3bd7ea9bf1b4 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -133,11 +133,31 @@ intel_plane_destroy_state(struct drm_plane *plane,
 	kfree(plane_state);
 }
 
+unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
+				    const struct intel_plane_state *plane_state)
+{
+	unsigned int src_w, src_h, dst_w, dst_h;
+
+	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
+	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
+	dst_w = drm_rect_width(&plane_state->uapi.dst);
+	dst_h = drm_rect_height(&plane_state->uapi.dst);
+
+	/* Downscaling limits the maximum pixel rate */
+	dst_w = min(src_w, dst_w);
+	dst_h = min(src_h, dst_h);
+
+	return DIV_ROUND_UP(mul_u32_u32(crtc_state->pixel_rate,
+			    src_w * src_h),
+			    mul_u32_u32(dst_w, dst_h));
+}
+
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 				   const struct intel_plane_state *plane_state)
 {
 	const struct drm_framebuffer *fb = plane_state->hw.fb;
 	unsigned int cpp;
+	unsigned int plane_pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
 
 	if (!plane_state->uapi.visible)
 		return 0;
@@ -153,7 +173,7 @@ unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 	if (fb->format->is_yuv && fb->format->num_planes > 1)
 		cpp *= 4;
 
-	return cpp * crtc_state->pixel_rate;
+	return mul_u32_u32(plane_pixel_rate, cpp);
 }
 
 int intel_plane_calc_min_cdclk(struct intel_atomic_state *state,
diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
index 2bcf15e34728..a6bbf42bae1f 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
@@ -18,6 +18,9 @@ struct intel_plane_state;
 
 extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
 
+unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
+				    const struct intel_plane_state *plane_state);
+
 unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
 				   const struct intel_plane_state *plane_state);
 void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c
index 7abeefe8dce5..4fa3081e2074 100644
--- a/drivers/gpu/drm/i915/display/intel_sprite.c
+++ b/drivers/gpu/drm/i915/display/intel_sprite.c
@@ -330,9 +330,9 @@ bool icl_is_hdr_plane(struct drm_i915_private *dev_priv, enum plane_id plane_id)
 }
 
 static void
-skl_plane_ratio(const struct intel_crtc_state *crtc_state,
-		const struct intel_plane_state *plane_state,
-		unsigned int *num, unsigned int *den)
+skl_plane_bpp_constraints(const struct intel_crtc_state *crtc_state,
+			  const struct intel_plane_state *plane_state,
+			  unsigned int *num, unsigned int *den)
 {
 	struct drm_i915_private *dev_priv = to_i915(plane_state->uapi.plane->dev);
 	const struct drm_framebuffer *fb = plane_state->hw.fb;
@@ -355,27 +355,19 @@ static int skl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
 			       const struct intel_plane_state *plane_state)
 {
 	struct drm_i915_private *dev_priv = to_i915(plane_state->uapi.plane->dev);
-	unsigned int pixel_rate = crtc_state->pixel_rate;
-	unsigned int src_w, src_h, dst_w, dst_h;
 	unsigned int num, den;
+	int plane_pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);
 
-	skl_plane_ratio(crtc_state, plane_state, &num, &den);
+	skl_plane_bpp_constraints(crtc_state, plane_state, &num, &den);
 
 	/* two pixels per clock on glk+ */
 	if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
 		den *= 2;
 
-	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
-	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
-	dst_w = drm_rect_width(&plane_state->uapi.dst);
-	dst_h = drm_rect_height(&plane_state->uapi.dst);
-
-	/* Downscaling limits the maximum pixel rate */
-	dst_w = min(src_w, dst_w);
-	dst_h = min(src_h, dst_h);
-
-	return DIV64_U64_ROUND_UP(mul_u32_u32(pixel_rate * num, src_w * src_h),
-				  mul_u32_u32(den, dst_w * dst_h));
+	/*
+	 * Plane pixel rate is a pipe pixel rate * plane ratio * pipe ratio
+	 */
+	return DIV64_U64_ROUND_UP(plane_pixel_rate * num, den);
 }
 
 static unsigned int
-- 
2.24.1.485.gad05a3d8e5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2)
  2020-02-20 16:08 [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Stanislav Lisovskiy
@ 2020-02-20 20:50 ` Patchwork
  2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BUILD: warning " Patchwork
  2020-02-21 14:04 ` [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Ville Syrjälä
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2020-02-20 20:50 UTC (permalink / raw)
  To: Stanislav Lisovskiy; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2)
URL   : https://patchwork.freedesktop.org/series/73718/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7975 -> Patchwork_16647
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_16647 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_16647, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/index.html

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_16647:

### IGT changes ###

#### Possible regressions ####

  * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
    - fi-pnv-d510:        [PASS][1] -> [DMESG-WARN][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-pnv-d510/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-pnv-d510/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html
    - fi-gdg-551:         [PASS][3] -> [DMESG-WARN][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-gdg-551/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-gdg-551/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html

  
#### Suppressed ####

  The following results come from untrusted machines, tests, or statuses.
  They do not affect the overall result.

  * {igt@kms_busy@basic@flip}:
    - fi-icl-guc:         [PASS][5] -> [INCOMPLETE][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-icl-guc/igt@kms_busy@basic@flip.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-icl-guc/igt@kms_busy@basic@flip.html
    - fi-hsw-4770:        [PASS][7] -> [INCOMPLETE][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-hsw-4770/igt@kms_busy@basic@flip.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-hsw-4770/igt@kms_busy@basic@flip.html
    - {fi-tgl-u}:         [PASS][9] -> [INCOMPLETE][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-tgl-u/igt@kms_busy@basic@flip.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-tgl-u/igt@kms_busy@basic@flip.html
    - {fi-kbl-7560u}:     NOTRUN -> [INCOMPLETE][11]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-kbl-7560u/igt@kms_busy@basic@flip.html
    - fi-cfl-guc:         [PASS][12] -> [INCOMPLETE][13]
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-cfl-guc/igt@kms_busy@basic@flip.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-cfl-guc/igt@kms_busy@basic@flip.html
    - fi-bsw-n3050:       [PASS][14] -> [INCOMPLETE][15]
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-bsw-n3050/igt@kms_busy@basic@flip.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-bsw-n3050/igt@kms_busy@basic@flip.html
    - fi-skl-guc:         [PASS][16] -> [INCOMPLETE][17]
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-skl-guc/igt@kms_busy@basic@flip.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-skl-guc/igt@kms_busy@basic@flip.html
    - fi-ilk-650:         [PASS][18] -> [INCOMPLETE][19]
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-ilk-650/igt@kms_busy@basic@flip.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-ilk-650/igt@kms_busy@basic@flip.html
    - fi-icl-y:           [PASS][20] -> [INCOMPLETE][21]
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-icl-y/igt@kms_busy@basic@flip.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-icl-y/igt@kms_busy@basic@flip.html
    - fi-hsw-4770r:       [PASS][22] -> [INCOMPLETE][23]
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-hsw-4770r/igt@kms_busy@basic@flip.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-hsw-4770r/igt@kms_busy@basic@flip.html
    - fi-skl-6700k2:      [PASS][24] -> [INCOMPLETE][25]
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-skl-6700k2/igt@kms_busy@basic@flip.html
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-skl-6700k2/igt@kms_busy@basic@flip.html
    - fi-icl-u2:          [PASS][26] -> [INCOMPLETE][27]
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-icl-u2/igt@kms_busy@basic@flip.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-icl-u2/igt@kms_busy@basic@flip.html
    - fi-hsw-peppy:       [PASS][28] -> [INCOMPLETE][29]
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-hsw-peppy/igt@kms_busy@basic@flip.html
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-hsw-peppy/igt@kms_busy@basic@flip.html
    - fi-cfl-8700k:       [PASS][30] -> [INCOMPLETE][31]
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-cfl-8700k/igt@kms_busy@basic@flip.html
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-cfl-8700k/igt@kms_busy@basic@flip.html
    - {fi-tgl-dsi}:       NOTRUN -> [INCOMPLETE][32]
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-tgl-dsi/igt@kms_busy@basic@flip.html
    - fi-snb-2520m:       NOTRUN -> [INCOMPLETE][33]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-snb-2520m/igt@kms_busy@basic@flip.html
    - fi-icl-dsi:         [PASS][34] -> [INCOMPLETE][35]
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-icl-dsi/igt@kms_busy@basic@flip.html
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-icl-dsi/igt@kms_busy@basic@flip.html
    - fi-bsw-kefka:       [PASS][36] -> [INCOMPLETE][37]
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-bsw-kefka/igt@kms_busy@basic@flip.html
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-bsw-kefka/igt@kms_busy@basic@flip.html
    - fi-bdw-5557u:       [PASS][38] -> [INCOMPLETE][39]
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-bdw-5557u/igt@kms_busy@basic@flip.html
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-bdw-5557u/igt@kms_busy@basic@flip.html
    - fi-kbl-x1275:       [PASS][40] -> [INCOMPLETE][41]
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-kbl-x1275/igt@kms_busy@basic@flip.html
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-kbl-x1275/igt@kms_busy@basic@flip.html
    - fi-cfl-8109u:       [PASS][42] -> [INCOMPLETE][43]
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-cfl-8109u/igt@kms_busy@basic@flip.html
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-cfl-8109u/igt@kms_busy@basic@flip.html
    - fi-kbl-7500u:       [PASS][44] -> [INCOMPLETE][45]
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-kbl-7500u/igt@kms_busy@basic@flip.html
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-kbl-7500u/igt@kms_busy@basic@flip.html
    - {fi-ehl-1}:         [PASS][46] -> [INCOMPLETE][47]
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-ehl-1/igt@kms_busy@basic@flip.html
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-ehl-1/igt@kms_busy@basic@flip.html
    - fi-skl-lmem:        [PASS][48] -> [INCOMPLETE][49]
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-skl-lmem/igt@kms_busy@basic@flip.html
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-skl-lmem/igt@kms_busy@basic@flip.html
    - fi-kbl-r:           NOTRUN -> [INCOMPLETE][50]
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-kbl-r/igt@kms_busy@basic@flip.html

  
Known issues
------------

  Here are the changes found in Patchwork_16647 that come from known issues:

### IGT changes ###

#### Possible fixes ####

  * igt@gem_close_race@basic-threads:
    - fi-hsw-4770r:       [TIMEOUT][51] ([fdo#112271] / [i915#1084]) -> [PASS][52]
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-hsw-4770r/igt@gem_close_race@basic-threads.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-hsw-4770r/igt@gem_close_race@basic-threads.html
    - fi-byt-n2820:       [INCOMPLETE][53] ([i915#45]) -> [PASS][54]
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7975/fi-byt-n2820/igt@gem_close_race@basic-threads.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/fi-byt-n2820/igt@gem_close_race@basic-threads.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [CI#94]: https://gitlab.freedesktop.org/gfx-ci/i915-infra/issues/94
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#112271]: https://bugs.freedesktop.org/show_bug.cgi?id=112271
  [i915#1084]: https://gitlab.freedesktop.org/drm/intel/issues/1084
  [i915#283]: https://gitlab.freedesktop.org/drm/intel/issues/283
  [i915#45]: https://gitlab.freedesktop.org/drm/intel/issues/45
  [i915#585]: https://gitlab.freedesktop.org/drm/intel/issues/585


Participating hosts (47 -> 42)
------------------------------

  Additional (5): fi-tgl-dsi fi-glk-dsi fi-snb-2520m fi-kbl-7560u fi-kbl-r 
  Missing    (10): fi-ilk-m540 fi-bdw-samus fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-ivb-3770 fi-blb-e6850 fi-byt-clapper fi-skl-6600u fi-snb-2600 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_7975 -> Patchwork_16647

  CI-20190529: 20190529
  CI_DRM_7975: f66891f7bdc3c60bb6f06fd6bc0718a0bd975896 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5453: cae9a5881ed2c5be2c2518a255740b612a927f9a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_16647: c72d584adc34fccaacf86b8c033093ade8f9d71a @ git://anongit.freedesktop.org/gfx-ci/linux


== Kernel 32bit build ==

Warning: Kernel 32bit buildtest failed:
https://intel-gfx-ci.01.org/Patchwork_16647/build_32bit.log

  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h
Kernel: arch/x86/boot/bzImage is ready  (#1)
  MODPOST 121 modules
ERROR: "__udivdi3" [drivers/gpu/drm/i915/i915.ko] undefined!
scripts/Makefile.modpost:93: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1281: recipe for target 'modules' failed
make: *** [modules] Error 2


== Linux commits ==

c72d584adc34 drm/i915: Use intel_plane_data_rate for min_cdclk calculation

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BUILD: warning for drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2)
  2020-02-20 16:08 [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Stanislav Lisovskiy
  2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2) Patchwork
@ 2020-02-20 20:50 ` Patchwork
  2020-02-21 14:04 ` [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Ville Syrjälä
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2020-02-20 20:50 UTC (permalink / raw)
  To: Stanislav Lisovskiy; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2)
URL   : https://patchwork.freedesktop.org/series/73718/
State : warning

== Summary ==

CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  CHK     include/generated/compile.h
Kernel: arch/x86/boot/bzImage is ready  (#1)
  MODPOST 121 modules
ERROR: "__udivdi3" [drivers/gpu/drm/i915/i915.ko] undefined!
scripts/Makefile.modpost:93: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1281: recipe for target 'modules' failed
make: *** [modules] Error 2

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16647/build_32bit.log
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation
  2020-02-20 16:08 [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Stanislav Lisovskiy
  2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2) Patchwork
  2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BUILD: warning " Patchwork
@ 2020-02-21 14:04 ` Ville Syrjälä
  2020-02-21 14:38   ` Lisovskiy, Stanislav
  2 siblings, 1 reply; 6+ messages in thread
From: Ville Syrjälä @ 2020-02-21 14:04 UTC (permalink / raw)
  To: Stanislav Lisovskiy; +Cc: jani.nikula, intel-gfx

On Thu, Feb 20, 2020 at 06:08:56PM +0200, Stanislav Lisovskiy wrote:
> There seems to be a bit of confusing redundancy in a way, how
> plane data rate/min cdclk are calculated.
> In fact both min cdclk, pixel rate and plane data rate are all
> part of the same formula as per BSpec.
> 
> However currently we have intel_plane_data_rate, which is used
> to calculate plane data rate and which is also used in bandwidth
> calculations. However for calculating min_cdclk we have another
> piece of code, doing almost same calculation, but a bit differently
> and in a different place. However as both are actually part of same
> formula, probably would be wise to use plane data rate calculations
> as a basis anyway, thus avoiding code duplication and possible bugs
> related to this.
> 
> Another thing is that I've noticed that during min_cdclk calculations
> we account for plane scaling, while for plane data rate, we don't.
> crtc->pixel_rate seems to account only for pipe ratio, however it is
> clearly stated in BSpec that plane data rate also need to account
> plane ratio as well.
> 
> So what this commit does is:
> - Adds a plane ratio calculation to intel_plane_data_rate
> - Removes redundant calculations from skl_plane_min_cdclk which is
>   used for gen9+ and now uses intel_plane_data_rate as a basis from
>   there as well.
> 
> v2: - Don't use 64 division if not needed(Ville Syrjälä)
>     - Now use intel_plane_pixel_rate as a basis for calculations both
>       at intel_plane_data_rate and skl_plane_min_cdclk(Ville Syrjälä)
> 
> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> ---
>  .../gpu/drm/i915/display/intel_atomic_plane.c | 22 +++++++++++++++-
>  .../gpu/drm/i915/display/intel_atomic_plane.h |  3 +++
>  drivers/gpu/drm/i915/display/intel_sprite.c   | 26 +++++++------------
>  3 files changed, 33 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> index c86d7a35c816..3bd7ea9bf1b4 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> @@ -133,11 +133,31 @@ intel_plane_destroy_state(struct drm_plane *plane,
>  	kfree(plane_state);
>  }
>  
> +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> +				    const struct intel_plane_state *plane_state)
> +{
> +	unsigned int src_w, src_h, dst_w, dst_h;
> +
> +	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
> +	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
> +	dst_w = drm_rect_width(&plane_state->uapi.dst);
> +	dst_h = drm_rect_height(&plane_state->uapi.dst);
> +
> +	/* Downscaling limits the maximum pixel rate */
> +	dst_w = min(src_w, dst_w);
> +	dst_h = min(src_h, dst_h);
> +
> +	return DIV_ROUND_UP(mul_u32_u32(crtc_state->pixel_rate,

Wrong macro for 64/32->32 division.

> +			    src_w * src_h),
> +			    mul_u32_u32(dst_w, dst_h));

And the divisor shouldn't be a u64.

> +}
> +
>  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
>  				   const struct intel_plane_state *plane_state)
>  {
>  	const struct drm_framebuffer *fb = plane_state->hw.fb;
>  	unsigned int cpp;
> +	unsigned int plane_pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);

Just 'pixel_rate' should do. We know the rest from the fact that this
is a plane function. Also I'd put this first so the declaration block
looks at least a bit less messy.

>  
>  	if (!plane_state->uapi.visible)
>  		return 0;
> @@ -153,7 +173,7 @@ unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
>  	if (fb->format->is_yuv && fb->format->num_planes > 1)
>  		cpp *= 4;
>  
> -	return cpp * crtc_state->pixel_rate;
> +	return mul_u32_u32(plane_pixel_rate, cpp);

We're not returning a u64.

>  }
>  
>  int intel_plane_calc_min_cdclk(struct intel_atomic_state *state,
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> index 2bcf15e34728..a6bbf42bae1f 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> @@ -18,6 +18,9 @@ struct intel_plane_state;
>  
>  extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
>  
> +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> +				    const struct intel_plane_state *plane_state);
> +
>  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
>  				   const struct intel_plane_state *plane_state);
>  void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
> diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c
> index 7abeefe8dce5..4fa3081e2074 100644
> --- a/drivers/gpu/drm/i915/display/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/display/intel_sprite.c
> @@ -330,9 +330,9 @@ bool icl_is_hdr_plane(struct drm_i915_private *dev_priv, enum plane_id plane_id)
>  }
>  
>  static void
> -skl_plane_ratio(const struct intel_crtc_state *crtc_state,
> -		const struct intel_plane_state *plane_state,
> -		unsigned int *num, unsigned int *den)
> +skl_plane_bpp_constraints(const struct intel_crtc_state *crtc_state,
> +			  const struct intel_plane_state *plane_state,
> +			  unsigned int *num, unsigned int *den)

Bogus rename.

>  {
>  	struct drm_i915_private *dev_priv = to_i915(plane_state->uapi.plane->dev);
>  	const struct drm_framebuffer *fb = plane_state->hw.fb;
> @@ -355,27 +355,19 @@ static int skl_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
>  			       const struct intel_plane_state *plane_state)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(plane_state->uapi.plane->dev);
> -	unsigned int pixel_rate = crtc_state->pixel_rate;
> -	unsigned int src_w, src_h, dst_w, dst_h;
>  	unsigned int num, den;
> +	int plane_pixel_rate = intel_plane_pixel_rate(crtc_state, plane_state);

same comments as for the other call site.

>  
> -	skl_plane_ratio(crtc_state, plane_state, &num, &den);
> +	skl_plane_bpp_constraints(crtc_state, plane_state, &num, &den);
>  
>  	/* two pixels per clock on glk+ */
>  	if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
>  		den *= 2;
>  
> -	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
> -	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
> -	dst_w = drm_rect_width(&plane_state->uapi.dst);
> -	dst_h = drm_rect_height(&plane_state->uapi.dst);
> -
> -	/* Downscaling limits the maximum pixel rate */
> -	dst_w = min(src_w, dst_w);
> -	dst_h = min(src_h, dst_h);
> -
> -	return DIV64_U64_ROUND_UP(mul_u32_u32(pixel_rate * num, src_w * src_h),
> -				  mul_u32_u32(den, dst_w * dst_h));
> +	/*
> +	 * Plane pixel rate is a pipe pixel rate * plane ratio * pipe ratio
> +	 */

Should be obvious.

> +	return DIV64_U64_ROUND_UP(plane_pixel_rate * num, den);
>  }
>  
>  static unsigned int
> -- 
> 2.24.1.485.gad05a3d8e5

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation
  2020-02-21 14:04 ` [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Ville Syrjälä
@ 2020-02-21 14:38   ` Lisovskiy, Stanislav
  2020-02-21 15:02     ` Ville Syrjälä
  0 siblings, 1 reply; 6+ messages in thread
From: Lisovskiy, Stanislav @ 2020-02-21 14:38 UTC (permalink / raw)
  To: ville.syrjala; +Cc: Nikula, Jani, intel-gfx

On Fri, 2020-02-21 at 16:04 +0200, Ville Syrjälä wrote:
> On Thu, Feb 20, 2020 at 06:08:56PM +0200, Stanislav Lisovskiy wrote:
> > There seems to be a bit of confusing redundancy in a way, how
> > plane data rate/min cdclk are calculated.
> > In fact both min cdclk, pixel rate and plane data rate are all
> > part of the same formula as per BSpec.
> > 
> > However currently we have intel_plane_data_rate, which is used
> > to calculate plane data rate and which is also used in bandwidth
> > calculations. However for calculating min_cdclk we have another
> > piece of code, doing almost same calculation, but a bit differently
> > and in a different place. However as both are actually part of same
> > formula, probably would be wise to use plane data rate calculations
> > as a basis anyway, thus avoiding code duplication and possible bugs
> > related to this.
> > 
> > Another thing is that I've noticed that during min_cdclk
> > calculations
> > we account for plane scaling, while for plane data rate, we don't.
> > crtc->pixel_rate seems to account only for pipe ratio, however it
> > is
> > clearly stated in BSpec that plane data rate also need to account
> > plane ratio as well.
> > 
> > So what this commit does is:
> > - Adds a plane ratio calculation to intel_plane_data_rate
> > - Removes redundant calculations from skl_plane_min_cdclk which is
> >   used for gen9+ and now uses intel_plane_data_rate as a basis from
> >   there as well.
> > 
> > v2: - Don't use 64 division if not needed(Ville Syrjälä)
> >     - Now use intel_plane_pixel_rate as a basis for calculations
> > both
> >       at intel_plane_data_rate and skl_plane_min_cdclk(Ville
> > Syrjälä)
> > 
> > Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> > ---
> >  .../gpu/drm/i915/display/intel_atomic_plane.c | 22
> > +++++++++++++++-
> >  .../gpu/drm/i915/display/intel_atomic_plane.h |  3 +++
> >  drivers/gpu/drm/i915/display/intel_sprite.c   | 26 +++++++------
> > ------
> >  3 files changed, 33 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > index c86d7a35c816..3bd7ea9bf1b4 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > @@ -133,11 +133,31 @@ intel_plane_destroy_state(struct drm_plane
> > *plane,
> >  	kfree(plane_state);
> >  }
> >  
> > +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state
> > *crtc_state,
> > +				    const struct intel_plane_state
> > *plane_state)
> > +{
> > +	unsigned int src_w, src_h, dst_w, dst_h;
> > +
> > +	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
> > +	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
> > +	dst_w = drm_rect_width(&plane_state->uapi.dst);
> > +	dst_h = drm_rect_height(&plane_state->uapi.dst);
> > +
> > +	/* Downscaling limits the maximum pixel rate */
> > +	dst_w = min(src_w, dst_w);
> > +	dst_h = min(src_h, dst_h);
> > +
> > +	return DIV_ROUND_UP(mul_u32_u32(crtc_state->pixel_rate,
> 
> Wrong macro for 64/32->32 division.

Yes, in fact we should use 64 macro here still. 
As I understand pixel rate is stored in kHz so for instance
for pixel rate 172800 * 4K * 4K we already overflowing u32.
Was just a bit confused with prev comment :)

> 
> > +			    src_w * src_h),
> > +			    mul_u32_u32(dst_w, dst_h));
> 
> And the divisor shouldn't be a u64.

Agree divisor is not, however divident is 64.
> 
> > +}
> > +
> >  unsigned int intel_plane_data_rate(const struct intel_crtc_state
> > *crtc_state,
> >  				   const struct intel_plane_state
> > *plane_state)
> >  {
> >  	const struct drm_framebuffer *fb = plane_state->hw.fb;
> >  	unsigned int cpp;
> > +	unsigned int plane_pixel_rate =
> > intel_plane_pixel_rate(crtc_state, plane_state);
> 
> Just 'pixel_rate' should do. We know the rest from the fact that this
> is a plane function. Also I'd put this first so the declaration block
> looks at least a bit less messy.
> 
> >  
> >  	if (!plane_state->uapi.visible)
> >  		return 0;
> > @@ -153,7 +173,7 @@ unsigned int intel_plane_data_rate(const struct
> > intel_crtc_state *crtc_state,
> >  	if (fb->format->is_yuv && fb->format->num_planes > 1)
> >  		cpp *= 4;
> >  
> > -	return cpp * crtc_state->pixel_rate;
> > +	return mul_u32_u32(plane_pixel_rate, cpp);
> 
> We're not returning a u64.
> 
> >  }
> >  
> >  int intel_plane_calc_min_cdclk(struct intel_atomic_state *state,
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > index 2bcf15e34728..a6bbf42bae1f 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > @@ -18,6 +18,9 @@ struct intel_plane_state;
> >  
> >  extern const struct drm_plane_helper_funcs
> > intel_plane_helper_funcs;
> >  
> > +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state
> > *crtc_state,
> > +				    const struct intel_plane_state
> > *plane_state);
> > +
> >  unsigned int intel_plane_data_rate(const struct intel_crtc_state
> > *crtc_state,
> >  				   const struct intel_plane_state
> > *plane_state);
> >  void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state
> > *plane_state,
> > diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c
> > b/drivers/gpu/drm/i915/display/intel_sprite.c
> > index 7abeefe8dce5..4fa3081e2074 100644
> > --- a/drivers/gpu/drm/i915/display/intel_sprite.c
> > +++ b/drivers/gpu/drm/i915/display/intel_sprite.c
> > @@ -330,9 +330,9 @@ bool icl_is_hdr_plane(struct drm_i915_private
> > *dev_priv, enum plane_id plane_id)
> >  }
> >  
> >  static void
> > -skl_plane_ratio(const struct intel_crtc_state *crtc_state,
> > -		const struct intel_plane_state *plane_state,
> > -		unsigned int *num, unsigned int *den)
> > +skl_plane_bpp_constraints(const struct intel_crtc_state
> > *crtc_state,
> > +			  const struct intel_plane_state *plane_state,
> > +			  unsigned int *num, unsigned int *den)
> 
> Bogus rename.

Well, I guess you agree, that this function is not returning
plane_ratio either :) Was just wondering if it has to be named somewhat
differently.

Stan
> 
> >  {
> >  	struct drm_i915_private *dev_priv = to_i915(plane_state-
> > >uapi.plane->dev);
> >  	const struct drm_framebuffer *fb = plane_state->hw.fb;
> > @@ -355,27 +355,19 @@ static int skl_plane_min_cdclk(const struct
> > intel_crtc_state *crtc_state,
> >  			       const struct intel_plane_state
> > *plane_state)
> >  {
> >  	struct drm_i915_private *dev_priv = to_i915(plane_state-
> > >uapi.plane->dev);
> > -	unsigned int pixel_rate = crtc_state->pixel_rate;
> > -	unsigned int src_w, src_h, dst_w, dst_h;
> >  	unsigned int num, den;
> > +	int plane_pixel_rate = intel_plane_pixel_rate(crtc_state,
> > plane_state);
> 
> same comments as for the other call site.
> 
> >  
> > -	skl_plane_ratio(crtc_state, plane_state, &num, &den);
> > +	skl_plane_bpp_constraints(crtc_state, plane_state, &num, &den);
> >  
> >  	/* two pixels per clock on glk+ */
> >  	if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
> >  		den *= 2;
> >  
> > -	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
> > -	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
> > -	dst_w = drm_rect_width(&plane_state->uapi.dst);
> > -	dst_h = drm_rect_height(&plane_state->uapi.dst);
> > -
> > -	/* Downscaling limits the maximum pixel rate */
> > -	dst_w = min(src_w, dst_w);
> > -	dst_h = min(src_h, dst_h);
> > -
> > -	return DIV64_U64_ROUND_UP(mul_u32_u32(pixel_rate * num, src_w *
> > src_h),
> > -				  mul_u32_u32(den, dst_w * dst_h));
> > +	/*
> > +	 * Plane pixel rate is a pipe pixel rate * plane ratio * pipe
> > ratio
> > +	 */
> 
> Should be obvious.
> 
> > +	return DIV64_U64_ROUND_UP(plane_pixel_rate * num, den);
> >  }
> >  
> >  static unsigned int
> > -- 
> > 2.24.1.485.gad05a3d8e5
> 
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation
  2020-02-21 14:38   ` Lisovskiy, Stanislav
@ 2020-02-21 15:02     ` Ville Syrjälä
  0 siblings, 0 replies; 6+ messages in thread
From: Ville Syrjälä @ 2020-02-21 15:02 UTC (permalink / raw)
  To: Lisovskiy, Stanislav; +Cc: Nikula, Jani, intel-gfx

On Fri, Feb 21, 2020 at 02:38:01PM +0000, Lisovskiy, Stanislav wrote:
> On Fri, 2020-02-21 at 16:04 +0200, Ville Syrjälä wrote:
> > On Thu, Feb 20, 2020 at 06:08:56PM +0200, Stanislav Lisovskiy wrote:
> > > There seems to be a bit of confusing redundancy in a way, how
> > > plane data rate/min cdclk are calculated.
> > > In fact both min cdclk, pixel rate and plane data rate are all
> > > part of the same formula as per BSpec.
> > > 
> > > However currently we have intel_plane_data_rate, which is used
> > > to calculate plane data rate and which is also used in bandwidth
> > > calculations. However for calculating min_cdclk we have another
> > > piece of code, doing almost same calculation, but a bit differently
> > > and in a different place. However as both are actually part of same
> > > formula, probably would be wise to use plane data rate calculations
> > > as a basis anyway, thus avoiding code duplication and possible bugs
> > > related to this.
> > > 
> > > Another thing is that I've noticed that during min_cdclk
> > > calculations
> > > we account for plane scaling, while for plane data rate, we don't.
> > > crtc->pixel_rate seems to account only for pipe ratio, however it
> > > is
> > > clearly stated in BSpec that plane data rate also need to account
> > > plane ratio as well.
> > > 
> > > So what this commit does is:
> > > - Adds a plane ratio calculation to intel_plane_data_rate
> > > - Removes redundant calculations from skl_plane_min_cdclk which is
> > >   used for gen9+ and now uses intel_plane_data_rate as a basis from
> > >   there as well.
> > > 
> > > v2: - Don't use 64 division if not needed(Ville Syrjälä)
> > >     - Now use intel_plane_pixel_rate as a basis for calculations
> > > both
> > >       at intel_plane_data_rate and skl_plane_min_cdclk(Ville
> > > Syrjälä)
> > > 
> > > Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
> > > ---
> > >  .../gpu/drm/i915/display/intel_atomic_plane.c | 22
> > > +++++++++++++++-
> > >  .../gpu/drm/i915/display/intel_atomic_plane.h |  3 +++
> > >  drivers/gpu/drm/i915/display/intel_sprite.c   | 26 +++++++------
> > > ------
> > >  3 files changed, 33 insertions(+), 18 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > > b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > > index c86d7a35c816..3bd7ea9bf1b4 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > > @@ -133,11 +133,31 @@ intel_plane_destroy_state(struct drm_plane
> > > *plane,
> > >  	kfree(plane_state);
> > >  }
> > >  
> > > +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state
> > > *crtc_state,
> > > +				    const struct intel_plane_state
> > > *plane_state)
> > > +{
> > > +	unsigned int src_w, src_h, dst_w, dst_h;
> > > +
> > > +	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
> > > +	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
> > > +	dst_w = drm_rect_width(&plane_state->uapi.dst);
> > > +	dst_h = drm_rect_height(&plane_state->uapi.dst);
> > > +
> > > +	/* Downscaling limits the maximum pixel rate */
> > > +	dst_w = min(src_w, dst_w);
> > > +	dst_h = min(src_h, dst_h);
> > > +
> > > +	return DIV_ROUND_UP(mul_u32_u32(crtc_state->pixel_rate,
> > 
> > Wrong macro for 64/32->32 division.
> 
> Yes, in fact we should use 64 macro here still. 
> As I understand pixel rate is stored in kHz so for instance
> for pixel rate 172800 * 4K * 4K we already overflowing u32.
> Was just a bit confused with prev comment :)
> 
> > 
> > > +			    src_w * src_h),
> > > +			    mul_u32_u32(dst_w, dst_h));
> > 
> > And the divisor shouldn't be a u64.
> 
> Agree divisor is not, however divident is 64.
> > 
> > > +}
> > > +
> > >  unsigned int intel_plane_data_rate(const struct intel_crtc_state
> > > *crtc_state,
> > >  				   const struct intel_plane_state
> > > *plane_state)
> > >  {
> > >  	const struct drm_framebuffer *fb = plane_state->hw.fb;
> > >  	unsigned int cpp;
> > > +	unsigned int plane_pixel_rate =
> > > intel_plane_pixel_rate(crtc_state, plane_state);
> > 
> > Just 'pixel_rate' should do. We know the rest from the fact that this
> > is a plane function. Also I'd put this first so the declaration block
> > looks at least a bit less messy.
> > 
> > >  
> > >  	if (!plane_state->uapi.visible)
> > >  		return 0;
> > > @@ -153,7 +173,7 @@ unsigned int intel_plane_data_rate(const struct
> > > intel_crtc_state *crtc_state,
> > >  	if (fb->format->is_yuv && fb->format->num_planes > 1)
> > >  		cpp *= 4;
> > >  
> > > -	return cpp * crtc_state->pixel_rate;
> > > +	return mul_u32_u32(plane_pixel_rate, cpp);
> > 
> > We're not returning a u64.
> > 
> > >  }
> > >  
> > >  int intel_plane_calc_min_cdclk(struct intel_atomic_state *state,
> > > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > > b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > > index 2bcf15e34728..a6bbf42bae1f 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.h
> > > @@ -18,6 +18,9 @@ struct intel_plane_state;
> > >  
> > >  extern const struct drm_plane_helper_funcs
> > > intel_plane_helper_funcs;
> > >  
> > > +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state
> > > *crtc_state,
> > > +				    const struct intel_plane_state
> > > *plane_state);
> > > +
> > >  unsigned int intel_plane_data_rate(const struct intel_crtc_state
> > > *crtc_state,
> > >  				   const struct intel_plane_state
> > > *plane_state);
> > >  void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state
> > > *plane_state,
> > > diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c
> > > b/drivers/gpu/drm/i915/display/intel_sprite.c
> > > index 7abeefe8dce5..4fa3081e2074 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_sprite.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_sprite.c
> > > @@ -330,9 +330,9 @@ bool icl_is_hdr_plane(struct drm_i915_private
> > > *dev_priv, enum plane_id plane_id)
> > >  }
> > >  
> > >  static void
> > > -skl_plane_ratio(const struct intel_crtc_state *crtc_state,
> > > -		const struct intel_plane_state *plane_state,
> > > -		unsigned int *num, unsigned int *den)
> > > +skl_plane_bpp_constraints(const struct intel_crtc_state
> > > *crtc_state,
> > > +			  const struct intel_plane_state *plane_state,
> > > +			  unsigned int *num, unsigned int *den)
> > 
> > Bogus rename.
> 
> Well, I guess you agree, that this function is not returning
> plane_ratio either :) Was just wondering if it has to be named somewhat
> differently.

It returns the plane ratio excluding the downscaling component.
So seems good enough to me. Or at least I can't immediately
think of anything particularly better.

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-02-21 15:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 16:08 [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Stanislav Lisovskiy
2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: Use intel_plane_data_rate for min_cdclk calculation (rev2) Patchwork
2020-02-20 20:50 ` [Intel-gfx] ✗ Fi.CI.BUILD: warning " Patchwork
2020-02-21 14:04 ` [Intel-gfx] [PATCH v2] drm/i915: Use intel_plane_data_rate for min_cdclk calculation Ville Syrjälä
2020-02-21 14:38   ` Lisovskiy, Stanislav
2020-02-21 15:02     ` Ville Syrjälä

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.