diff mbox series

[2/5] drm/i915/adlp: Require always a power-of-two sized CCS surface stride

Message ID 20210827150955.3343520-3-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/adlp: Add support for remapping CCS FBs | expand

Commit Message

Imre Deak Aug. 27, 2021, 3:09 p.m. UTC
At the moment CCS FB strides must be power-of-two sized, but a follow-up
change will add support remapping these FBs, allowing the FB passed in
by userspace to have a non-POT sized stride. For these remapped FBs we
can only remap the main surface, not the CCS surface. This means that
userspace has to always generate the CCS surface aligning to the POT
stride padded main surface (by setting up the CCS AUX pagetables
accordingly). Adjust the CCS surface stride check to enforce this.

No functional change.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/display/intel_fb.c | 33 ++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 4 deletions(-)

Comments

kernel test robot Aug. 27, 2021, 10:31 p.m. UTC | #1
Hi Imre,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[cannot apply to drm-intel/for-linux-next v5.14-rc7 next-20210827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Imre-Deak/drm-i915-adlp-Add-support-for-remapping-CCS-FBs/20210827-231214
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-randconfig-a016-20210827 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/ebed87d6cd7dc951ce86f16fa1a438382d14d443
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Imre-Deak/drm-i915-adlp-Add-support-for-remapping-CCS-FBs/20210827-231214
        git checkout ebed87d6cd7dc951ce86f16fa1a438382d14d443
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/display/intel_fb.c:78:14: warning: no previous prototype for 'gen12_ccs_aux_stride' [-Wmissing-prototypes]
      78 | unsigned int gen12_ccs_aux_stride(struct intel_framebuffer *fb, int ccs_plane)
         |              ^~~~~~~~~~~~~~~~~~~~


vim +/gen12_ccs_aux_stride +78 drivers/gpu/drm/i915/display/intel_fb.c

    77	
  > 78	unsigned int gen12_ccs_aux_stride(struct intel_framebuffer *fb, int ccs_plane)
    79	{
    80		struct drm_i915_private *i915 = to_i915(fb->base.dev);
    81		int main_plane = skl_ccs_to_main_plane(&fb->base, ccs_plane);
    82		unsigned int main_stride = fb->base.pitches[main_plane];
    83		unsigned int main_tile_width = intel_tile_width_bytes(&fb->base, main_plane);
    84	
    85		/*
    86		 * On ADL-P the AUX stride must align with a power-of-two aligned main
    87		 * surface stride. The stride of the allocated main surface object can
    88		 * be less than this POT stride, which is then autopadded to the POT
    89		 * size.
    90		 */
    91		if (IS_ALDERLAKE_P(i915))
    92			main_stride = gen12_aligned_scanout_stride(fb, main_plane);
    93	
    94		return DIV_ROUND_UP(main_stride, 4 * main_tile_width) * 64;
    95	}
    96	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Aug. 28, 2021, 12:50 a.m. UTC | #2
Hi Imre,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[cannot apply to drm-intel/for-linux-next v5.14-rc7 next-20210827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Imre-Deak/drm-i915-adlp-Add-support-for-remapping-CCS-FBs/20210827-231214
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-randconfig-r004-20210827 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1076082a0d97bd5c16a25ee7cf3dbb6ee4b5a9fe)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ebed87d6cd7dc951ce86f16fa1a438382d14d443
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Imre-Deak/drm-i915-adlp-Add-support-for-remapping-CCS-FBs/20210827-231214
        git checkout ebed87d6cd7dc951ce86f16fa1a438382d14d443
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/display/intel_fb.c:78:14: warning: no previous prototype for function 'gen12_ccs_aux_stride' [-Wmissing-prototypes]
   unsigned int gen12_ccs_aux_stride(struct intel_framebuffer *fb, int ccs_plane)
                ^
   drivers/gpu/drm/i915/display/intel_fb.c:78:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   unsigned int gen12_ccs_aux_stride(struct intel_framebuffer *fb, int ccs_plane)
   ^
   static 
   1 warning generated.


vim +/gen12_ccs_aux_stride +78 drivers/gpu/drm/i915/display/intel_fb.c

    77	
  > 78	unsigned int gen12_ccs_aux_stride(struct intel_framebuffer *fb, int ccs_plane)
    79	{
    80		struct drm_i915_private *i915 = to_i915(fb->base.dev);
    81		int main_plane = skl_ccs_to_main_plane(&fb->base, ccs_plane);
    82		unsigned int main_stride = fb->base.pitches[main_plane];
    83		unsigned int main_tile_width = intel_tile_width_bytes(&fb->base, main_plane);
    84	
    85		/*
    86		 * On ADL-P the AUX stride must align with a power-of-two aligned main
    87		 * surface stride. The stride of the allocated main surface object can
    88		 * be less than this POT stride, which is then autopadded to the POT
    89		 * size.
    90		 */
    91		if (IS_ALDERLAKE_P(i915))
    92			main_stride = gen12_aligned_scanout_stride(fb, main_plane);
    93	
    94		return DIV_ROUND_UP(main_stride, 4 * main_tile_width) * 64;
    95	}
    96	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Aug. 30, 2021, 2:29 a.m. UTC | #3
Hi Imre,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[cannot apply to drm-intel/for-linux-next v5.14 next-20210827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Imre-Deak/drm-i915-adlp-Add-support-for-remapping-CCS-FBs/20210827-231214
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: x86_64-rhel-8.3-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-348-gf0e6938b-dirty
        # https://github.com/0day-ci/linux/commit/ebed87d6cd7dc951ce86f16fa1a438382d14d443
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Imre-Deak/drm-i915-adlp-Add-support-for-remapping-CCS-FBs/20210827-231214
        git checkout ebed87d6cd7dc951ce86f16fa1a438382d14d443
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/i915/display/intel_fb.c:78:14: sparse: sparse: symbol 'gen12_ccs_aux_stride' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
index 0cf568a9cb1c6..560e386905318 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -63,10 +63,35 @@  int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane)
 	return ccs_plane - fb->format->num_planes / 2;
 }
 
-static int gen12_ccs_aux_stride(struct drm_framebuffer *fb, int ccs_plane)
+static unsigned int gen12_aligned_scanout_stride(const struct intel_framebuffer *fb, int color_plane)
 {
-	return DIV_ROUND_UP(fb->pitches[skl_ccs_to_main_plane(fb, ccs_plane)],
-			    512) * 64;
+	struct drm_i915_private *i915 = to_i915(fb->base.dev);
+	unsigned int stride = fb->base.pitches[color_plane];
+
+	if (IS_ALDERLAKE_P(i915))
+		return roundup_pow_of_two(max(stride,
+					      8u * intel_tile_width_bytes(&fb->base, color_plane)));
+
+	return stride;
+}
+
+unsigned int gen12_ccs_aux_stride(struct intel_framebuffer *fb, int ccs_plane)
+{
+	struct drm_i915_private *i915 = to_i915(fb->base.dev);
+	int main_plane = skl_ccs_to_main_plane(&fb->base, ccs_plane);
+	unsigned int main_stride = fb->base.pitches[main_plane];
+	unsigned int main_tile_width = intel_tile_width_bytes(&fb->base, main_plane);
+
+	/*
+	 * On ADL-P the AUX stride must align with a power-of-two aligned main
+	 * surface stride. The stride of the allocated main surface object can
+	 * be less than this POT stride, which is then autopadded to the POT
+	 * size.
+	 */
+	if (IS_ALDERLAKE_P(i915))
+		main_stride = gen12_aligned_scanout_stride(fb, main_plane);
+
+	return DIV_ROUND_UP(main_stride, 4 * main_tile_width) * 64;
 }
 
 int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane)
@@ -1379,7 +1404,7 @@  int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
 		}
 
 		if (is_gen12_ccs_plane(fb, i) && !is_gen12_ccs_cc_plane(fb, i)) {
-			int ccs_aux_stride = gen12_ccs_aux_stride(fb, i);
+			int ccs_aux_stride = gen12_ccs_aux_stride(intel_fb, i);
 
 			if (fb->pitches[i] != ccs_aux_stride) {
 				drm_dbg_kms(&dev_priv->drm,