linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: vop2: use correct destination rectangle height check
@ 2025-10-11 13:04 Alok Tiwari
  2025-10-12  3:12 ` kernel test robot
  2025-10-12 11:28 ` Christian Hewitt
  0 siblings, 2 replies; 4+ messages in thread
From: Alok Tiwari @ 2025-10-11 13:04 UTC (permalink / raw)
  To: michael.riesch, robh, s.hauer, dri-devel, simona, airlied,
	tzimmermann, mripard, hjc, heiko, andy.yan, maarten.lankhorst
  Cc: alok.a.tiwari, linux-arm-kernel, linux-rockchip

The vop2_plane_atomic_check() function incorrectly checks
drm_rect_width(dest) twice instead of verifying both width and height.
Fix the second condition to use drm_rect_height(dest) so that invalid
destination rectangles with height < 4 are correctly rejected.

Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index b50927a824b4..697f54777a32 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1031,7 +1031,7 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
 		return format;
 
 	if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 ||
-	    drm_rect_width(dest) < 4 || drm_rect_width(dest) < 4) {
+	    drm_rect_width(dest) < 4 || drm_rect_heigh(dest) < 4) {
 		drm_err(vop2->drm, "Invalid size: %dx%d->%dx%d, min size is 4x4\n",
 			drm_rect_width(src) >> 16, drm_rect_height(src) >> 16,
 			drm_rect_width(dest), drm_rect_height(dest));
-- 
2.50.1



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

* Re: [PATCH] drm/rockchip: vop2: use correct destination rectangle height check
  2025-10-11 13:04 [PATCH] drm/rockchip: vop2: use correct destination rectangle height check Alok Tiwari
@ 2025-10-12  3:12 ` kernel test robot
  2025-10-12 11:28 ` Christian Hewitt
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-10-12  3:12 UTC (permalink / raw)
  To: Alok Tiwari, michael.riesch, robh, s.hauer, dri-devel, simona,
	airlied, tzimmermann, mripard, hjc, heiko, andy.yan,
	maarten.lankhorst
  Cc: llvm, oe-kbuild-all, alok.a.tiwari, linux-arm-kernel,
	linux-rockchip

Hi Alok,

kernel test robot noticed the following build errors:

[auto build test ERROR on rockchip/for-next]
[also build test ERROR on linus/master v6.17 next-20251010]
[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/Alok-Tiwari/drm-rockchip-vop2-use-correct-destination-rectangle-height-check/20251011-210653
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
patch link:    https://lore.kernel.org/r/20251011130450.123444-1-alok.a.tiwari%40oracle.com
patch subject: [PATCH] drm/rockchip: vop2: use correct destination rectangle height check
config: sparc64-randconfig-001-20251012 (https://download.01.org/0day-ci/archive/20251012/202510121013.tqU2DAEC-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251012/202510121013.tqU2DAEC-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510121013.tqU2DAEC-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/rockchip/rockchip_drm_vop2.c:1034:34: error: call to undeclared function 'drm_rect_heigh'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    1034 |             drm_rect_width(dest) < 4 || drm_rect_heigh(dest) < 4) {
         |                                         ^
   drivers/gpu/drm/rockchip/rockchip_drm_vop2.c:1034:34: note: did you mean 'drm_rect_height'?
   include/drm/drm_rect.h:196:19: note: 'drm_rect_height' declared here
     196 | static inline int drm_rect_height(const struct drm_rect *r)
         |                   ^
   1 error generated.


vim +/drm_rect_heigh +1034 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

   991	
   992	static int vop2_plane_atomic_check(struct drm_plane *plane,
   993					   struct drm_atomic_state *astate)
   994	{
   995		struct drm_plane_state *pstate = drm_atomic_get_new_plane_state(astate, plane);
   996		struct drm_framebuffer *fb = pstate->fb;
   997		struct drm_crtc *crtc = pstate->crtc;
   998		struct drm_crtc_state *cstate;
   999		struct vop2_video_port *vp;
  1000		struct vop2 *vop2;
  1001		const struct vop2_data *vop2_data;
  1002		struct drm_rect *dest = &pstate->dst;
  1003		struct drm_rect *src = &pstate->src;
  1004		int min_scale = FRAC_16_16(1, 8);
  1005		int max_scale = FRAC_16_16(8, 1);
  1006		int format;
  1007		int ret;
  1008	
  1009		if (!crtc)
  1010			return 0;
  1011	
  1012		vp = to_vop2_video_port(crtc);
  1013		vop2 = vp->vop2;
  1014		vop2_data = vop2->data;
  1015	
  1016		cstate = drm_atomic_get_existing_crtc_state(pstate->state, crtc);
  1017		if (WARN_ON(!cstate))
  1018			return -EINVAL;
  1019	
  1020		ret = drm_atomic_helper_check_plane_state(pstate, cstate,
  1021							  min_scale, max_scale,
  1022							  true, true);
  1023		if (ret)
  1024			return ret;
  1025	
  1026		if (!pstate->visible)
  1027			return 0;
  1028	
  1029		format = vop2_convert_format(fb->format->format);
  1030		if (format < 0)
  1031			return format;
  1032	
  1033		if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 ||
> 1034		    drm_rect_width(dest) < 4 || drm_rect_heigh(dest) < 4) {
  1035			drm_err(vop2->drm, "Invalid size: %dx%d->%dx%d, min size is 4x4\n",
  1036				drm_rect_width(src) >> 16, drm_rect_height(src) >> 16,
  1037				drm_rect_width(dest), drm_rect_height(dest));
  1038			pstate->visible = false;
  1039			return 0;
  1040		}
  1041	
  1042		if (drm_rect_width(src) >> 16 > vop2_data->max_input.width ||
  1043		    drm_rect_height(src) >> 16 > vop2_data->max_input.height) {
  1044			drm_err(vop2->drm, "Invalid source: %dx%d. max input: %dx%d\n",
  1045				drm_rect_width(src) >> 16,
  1046				drm_rect_height(src) >> 16,
  1047				vop2_data->max_input.width,
  1048				vop2_data->max_input.height);
  1049			return -EINVAL;
  1050		}
  1051	
  1052		/*
  1053		 * Src.x1 can be odd when do clip, but yuv plane start point
  1054		 * need align with 2 pixel.
  1055		 */
  1056		if (fb->format->is_yuv && ((pstate->src.x1 >> 16) % 2)) {
  1057			drm_err(vop2->drm, "Invalid Source: Yuv format not support odd xpos\n");
  1058			return -EINVAL;
  1059		}
  1060	
  1061		return 0;
  1062	}
  1063	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


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

* Re: [PATCH] drm/rockchip: vop2: use correct destination rectangle height check
  2025-10-11 13:04 [PATCH] drm/rockchip: vop2: use correct destination rectangle height check Alok Tiwari
  2025-10-12  3:12 ` kernel test robot
@ 2025-10-12 11:28 ` Christian Hewitt
  2025-10-12 11:31   ` [External] : " ALOK TIWARI
  1 sibling, 1 reply; 4+ messages in thread
From: Christian Hewitt @ 2025-10-12 11:28 UTC (permalink / raw)
  To: Alok Tiwari
  Cc: michael.riesch, robh, s.hauer, dri-devel, simona, airlied,
	tzimmermann, mripard, hjc, heiko, andy.yan, maarten.lankhorst,
	linux-arm-kernel, linux-rockchip

> On 11 Oct 2025, at 5:04 pm, Alok Tiwari <alok.a.tiwari@oracle.com> wrote:
> 
> The vop2_plane_atomic_check() function incorrectly checks
> drm_rect_width(dest) twice instead of verifying both width and height.
> Fix the second condition to use drm_rect_height(dest) so that invalid
> destination rectangles with height < 4 are correctly rejected.
> 
> Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
> drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> index b50927a824b4..697f54777a32 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> @@ -1031,7 +1031,7 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
> return format;
> 
> if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 ||
> -    drm_rect_width(dest) < 4 || drm_rect_width(dest) < 4) {
> +    drm_rect_width(dest) < 4 || drm_rect_heigh(dest) < 4) {

Typo: s/drm_rect_heigh/drm_rect_height

Christian



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

* Re: [External] : Re: [PATCH] drm/rockchip: vop2: use correct destination rectangle height check
  2025-10-12 11:28 ` Christian Hewitt
@ 2025-10-12 11:31   ` ALOK TIWARI
  0 siblings, 0 replies; 4+ messages in thread
From: ALOK TIWARI @ 2025-10-12 11:31 UTC (permalink / raw)
  To: Christian Hewitt
  Cc: michael.riesch, robh, s.hauer, dri-devel, simona, airlied,
	tzimmermann, mripard, hjc, heiko, andy.yan, maarten.lankhorst,
	linux-arm-kernel, linux-rockchip



On 10/12/2025 4:58 PM, Christian Hewitt wrote:
>> On 11 Oct 2025, at 5:04 pm, Alok Tiwari <alok.a.tiwari@oracle.com> wrote:
>>
>> The vop2_plane_atomic_check() function incorrectly checks
>> drm_rect_width(dest) twice instead of verifying both width and height.
>> Fix the second condition to use drm_rect_height(dest) so that invalid
>> destination rectangles with height < 4 are correctly rejected.
>>
>> Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver")
>> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
>> ---
>> drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
>> index b50927a824b4..697f54777a32 100644
>> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
>> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
>> @@ -1031,7 +1031,7 @@ static int vop2_plane_atomic_check(struct drm_plane *plane,
>> return format;
>>
>> if (drm_rect_width(src) >> 16 < 4 || drm_rect_height(src) >> 16 < 4 ||
>> -    drm_rect_width(dest) < 4 || drm_rect_width(dest) < 4) {
>> +    drm_rect_width(dest) < 4 || drm_rect_heigh(dest) < 4) {
> 
> Typo: s/drm_rect_heigh/drm_rect_height
> 
> Christian
> 

Thanks Christian. I will correct it and send v2.

Thanks,
Alok


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

end of thread, other threads:[~2025-10-12 11:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-11 13:04 [PATCH] drm/rockchip: vop2: use correct destination rectangle height check Alok Tiwari
2025-10-12  3:12 ` kernel test robot
2025-10-12 11:28 ` Christian Hewitt
2025-10-12 11:31   ` [External] : " ALOK TIWARI

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).