From: "Lowry Li (Arm Technology China)" Subject: [PATCH v1 2/2] drm/komeda: Adds layer horizontal input size limitation check for D71 Date: Fri, 30 Aug 2019 09:09:02 +0000 Message-ID: <20190830090835.8747-3-lowry.li@arm.com> References: <20190830090835.8747-1-lowry.li@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20190830090835.8747-1-lowry.li@arm.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Liviu Dudau , "james qian wang (Arm Technology China)" , "maarten.lankhorst@linux.intel.com" , "seanpaul@chromium.org" , "airlied@linux.ie" , Brian Starkey , Mihail Atanassov Cc: "Julien Yin (Arm Technology China)" , "Jonathan Chai (Arm Technology China)" , Ayan Halder , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , nd List-Id: dri-devel@lists.freedesktop.org Adds maximum line size check according to the AFBC decoder limitation and special Line size limitation(2046) for format: YUV420_10BIT and X0L2. Signed-off-by: Lowry Li (Arm Technology China) --- .../arm/display/komeda/d71/d71_component.c | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c b/drive= rs/gpu/drm/arm/display/komeda/d71/d71_component.c index a56dc56a72fb..41b5bfcbd027 100644 --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c @@ -401,7 +401,56 @@ static void d71_layer_dump(struct komeda_component *c,= struct seq_file *sf) seq_printf(sf, "%sAD_V_CROP:\t\t0x%X\n", prefix, v[2]); } =20 +static int d71_layer_validate(struct komeda_component *c, + struct komeda_component_state *state) +{ + struct komeda_layer_state *st =3D to_layer_st(state); + struct komeda_layer *layer =3D to_layer(c); + struct drm_plane_state *plane_st; + struct drm_framebuffer *fb; + u32 fourcc, line_sz, max_line_sz; + + plane_st =3D drm_atomic_get_new_plane_state(state->obj.state, + state->plane); + fb =3D plane_st->fb; + fourcc =3D fb->format->format; + + if (drm_rotation_90_or_270(st->rot)) + line_sz =3D st->vsize - st->afbc_crop_t - st->afbc_crop_b; + else + line_sz =3D st->hsize - st->afbc_crop_l - st->afbc_crop_r; + + if (fb->modifier) { + if ((fb->modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK) =3D=3D + AFBC_FORMAT_MOD_BLOCK_SIZE_32x8) + max_line_sz =3D layer->line_sz; + else + max_line_sz =3D layer->line_sz / 2; + + if (line_sz > max_line_sz) { + DRM_DEBUG_ATOMIC("afbc request line_sz: %d exceed the max afbc line_sz:= %d.\n", + line_sz, max_line_sz); + return -EINVAL; + } + } + + if (fourcc =3D=3D DRM_FORMAT_YUV420_10BIT && line_sz > 2046 && (st->afbc_= crop_l % 4)) { + DRM_DEBUG_ATOMIC("YUV420_10BIT input_hsize: %d exceed the max size 2046.= \n", + line_sz); + return -EINVAL; + } + + if (fourcc =3D=3D DRM_FORMAT_X0L2 && line_sz > 2046 && (st->addr[0] % 16)= ) { + DRM_DEBUG_ATOMIC("X0L2 input_hsize: %d exceed the max size 2046.\n", + line_sz); + return -EINVAL; + } + + return 0; +} + static const struct komeda_component_funcs d71_layer_funcs =3D { + .validate =3D d71_layer_validate, .update =3D d71_layer_update, .disable =3D d71_layer_disable, .dump_register =3D d71_layer_dump, --=20 2.17.1