* [PATCH] drm/format-helper: Make conversion_buf_size() support sub-byte pixel fmts
@ 2023-03-07 19:34 Javier Martinez Canillas
2023-03-07 21:03 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Javier Martinez Canillas @ 2023-03-07 19:34 UTC (permalink / raw)
To: linux-kernel
Cc: Arthur Grillo, Maíra Canal, Thomas Zimmermann,
Maxime Ripard, Javier Martinez Canillas, Daniel Vetter,
David Airlie, David Gow, José Expósito, dri-devel
There are DRM fourcc formats that have pixels smaller than a byte, but the
conversion_buf_size() function assumes that pixels are a multiple of bytes
and use the struct drm_format_info .cpp field to calculate the dst_pitch.
Instead, calculate it by using the bits per pixel (bpp) and char per pixel
(cpp) to account for formats that have sub-byte pixels.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
Tested by making sure that the following command still succeeds:
./tools/testing/kunit/kunit.py run \
--kunitconfig=drivers/gpu/drm/tests/.kunitconfig
drivers/gpu/drm/tests/drm_format_helper_test.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 9536829c6e3a..f200347a1db7 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -409,12 +409,16 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
const struct drm_rect *clip)
{
const struct drm_format_info *dst_fi = drm_format_info(dst_format);
+ unsigned int bpp, cpp;
if (!dst_fi)
return -EINVAL;
- if (!dst_pitch)
- dst_pitch = drm_rect_width(clip) * dst_fi->cpp[0];
+ if (!dst_pitch) {
+ bpp = drm_format_info_bpp(dst_fi, 0);
+ cpp = DIV_ROUND_UP(bpp, 8);
+ dst_pitch = DIV_ROUND_UP(drm_rect_width(clip) * bpp, 8);
+ }
return dst_pitch * drm_rect_height(clip);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/format-helper: Make conversion_buf_size() support sub-byte pixel fmts
2023-03-07 19:34 [PATCH] drm/format-helper: Make conversion_buf_size() support sub-byte pixel fmts Javier Martinez Canillas
@ 2023-03-07 21:03 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2023-03-07 21:03 UTC (permalink / raw)
To: Javier Martinez Canillas, linux-kernel
Cc: oe-kbuild-all, Thomas Zimmermann, Javier Martinez Canillas,
dri-devel, Maíra Canal, Maxime Ripard, David Gow,
José Expósito, Arthur Grillo
Hi Javier,
I love your patch! Perhaps something to improve:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v6.3-rc1 next-20230307]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Javier-Martinez-Canillas/drm-format-helper-Make-conversion_buf_size-support-sub-byte-pixel-fmts/20230308-033619
base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link: https://lore.kernel.org/r/20230307193457.331360-1-javierm%40redhat.com
patch subject: [PATCH] drm/format-helper: Make conversion_buf_size() support sub-byte pixel fmts
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230308/202303080420.T1VvHVxo-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
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/intel-lab-lkp/linux/commit/5f0f9d30de18661bdabebde361180893b8ddba27
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Javier-Martinez-Canillas/drm-format-helper-Make-conversion_buf_size-support-sub-byte-pixel-fmts/20230308-033619
git checkout 5f0f9d30de18661bdabebde361180893b8ddba27
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/gpu/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303080420.T1VvHVxo-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/tests/drm_format_helper_test.c: In function 'conversion_buf_size':
>> drivers/gpu/drm/tests/drm_format_helper_test.c:412:27: warning: variable 'cpp' set but not used [-Wunused-but-set-variable]
412 | unsigned int bpp, cpp;
| ^~~
vim +/cpp +412 drivers/gpu/drm/tests/drm_format_helper_test.c
397
398 /*
399 * conversion_buf_size - Return the destination buffer size required to convert
400 * between formats.
401 * @dst_format: destination buffer pixel format (DRM_FORMAT_*)
402 * @dst_pitch: Number of bytes between two consecutive scanlines within dst
403 * @clip: Clip rectangle area to convert
404 *
405 * Returns:
406 * The size of the destination buffer or negative value on error.
407 */
408 static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
409 const struct drm_rect *clip)
410 {
411 const struct drm_format_info *dst_fi = drm_format_info(dst_format);
> 412 unsigned int bpp, cpp;
413
414 if (!dst_fi)
415 return -EINVAL;
416
417 if (!dst_pitch) {
418 bpp = drm_format_info_bpp(dst_fi, 0);
419 cpp = DIV_ROUND_UP(bpp, 8);
420 dst_pitch = DIV_ROUND_UP(drm_rect_width(clip) * bpp, 8);
421 }
422
423 return dst_pitch * drm_rect_height(clip);
424 }
425
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-07 21:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 19:34 [PATCH] drm/format-helper: Make conversion_buf_size() support sub-byte pixel fmts Javier Martinez Canillas
2023-03-07 21:03 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).