Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2669463pxb; Mon, 11 Jan 2021 16:40:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu9aWGXhmG1kUg2PF7BddfIlbhTfPTvYZZpCk6HCuMcvRSQl6eA/Z+P3SmaOuv4nx1V4po X-Received: by 2002:a17:907:28d4:: with SMTP id en20mr1398872ejc.196.1610412006714; Mon, 11 Jan 2021 16:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610412006; cv=none; d=google.com; s=arc-20160816; b=zTOo2IHFiIO3Ms5nn/hWhkwmLlyNvYILdBWwkVsb3x5SXS2QzM/tN/PnaiVUg/OHhZ ItgoRh+8GPQnFrbZHOa0+/iyDgKs2Rs/+/l+t3JnhvMmsMJoe1XXHEGAfB+qbv7il8EG kG18v9sZdnbubWZCLuGuZ6w+6V/3fcQGLdn82VodWFvx1wIE5KKQdITD4qW3URzbZO00 dhb2Svktxf6zPIf6btWOzWzWjvleFLDQ4p0Cabk1WuqKbQSkdo9VIdRNnMDlTccLp2is pFKSqntyormCwyD1BorQobTPqTnb2zu0wAFPAdBzx4XP2FzzqTvOuN00e+xbuV/8ptN3 jk6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=E3TObj0DpnQ+C6+diTMVXIRK8fmCTHUzn1Fp+y0pweE=; b=r4RaaPktG/W7aSzJaooRugAPX4YiK3bnsXvUOpoSI675QL0AVt2XGfFlNbxGTSBFjF agcWccOAxsetsYQ0GIOV2CSg199TlVEZsdRoiAbqA5AieD8AxX08WMKufR8a7LASu4O8 AszhwZU199GmgIHBI1mZN4nG71eHSPkZXiWGmusc2hkesrXmQlch/0C20jLCSdqrzsAd /zn0OiB7W6L/5LYSQvSJ2HA2cyUvvjkU45heLsOYsQh8gqWfWHsF8xNInZPBEMY5UGrV XbVWid7eLIzDydy6Y/c8XCrf1+fAoVK1RObmCXlElxYDWCWgBbAeGifP04Z074jzwM88 IRvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZGDMj2yX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si548268edw.349.2021.01.11.16.39.42; Mon, 11 Jan 2021 16:40:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZGDMj2yX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726251AbhAKMXB (ORCPT + 99 others); Mon, 11 Jan 2021 07:23:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbhAKMXA (ORCPT ); Mon, 11 Jan 2021 07:23:00 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31536C061786 for ; Mon, 11 Jan 2021 04:22:20 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id q1so3154207ion.8 for ; Mon, 11 Jan 2021 04:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E3TObj0DpnQ+C6+diTMVXIRK8fmCTHUzn1Fp+y0pweE=; b=ZGDMj2yXM/sj19/ajRO5Z3wQwVep6XJ3i5tFwpvUIEBz7202mNkOILo5acwjn/Q/On p1HhQRcnCM8uvdlT6VFHgeQcnbTfbQATmu+he4Vn4HBQpgZyKHgW6pyoSdH+TdDoeR53 q2Vf5u0VpfCoo4pE/BEzVZLGebm7L0rtZiGeQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E3TObj0DpnQ+C6+diTMVXIRK8fmCTHUzn1Fp+y0pweE=; b=qpGxGH4k7GR+WERxQshf+L7wQ1tZ2UQAFiuZGQfMe00rFsuiAATr7KaYLGwWj2MCQI WS8XgO7ywNjWbbHV7Zwv14jVYnf0+GwlnGK4FPjAWdqwqgSAO7bGREWvrTdDzmAvHxnI t5CL7iSfE+Pcmii5gOAKIxtT2WE6m5dMT/nuzl20hOJePJ2ivCfiltaMk5aEUePDwSxL xLDISlvlsnPWGDFKYNtqQll7hmGuiVS1Z8rDj3DdIalOJ0d3iB7GR0Cqmp/cItscre3w xp3F1fhWBuyAyQWvJSfE9ETEIPJpU4yAoNKR1Y7J0aap4r/fuI5CeqVM5GmUGAIFbOF4 xZ4w== X-Gm-Message-State: AOAM5330rEaxKxjZiyncCggtFif49mSvMnesag0x0erd0VUdhqHX2YYo icvrjeOWjcYlUzIcJ2XCLNwKkU8P39dWSLea X-Received: by 2002:a6b:8bc7:: with SMTP id n190mr14490339iod.98.1610367739220; Mon, 11 Jan 2021 04:22:19 -0800 (PST) Received: from mail-io1-f52.google.com (mail-io1-f52.google.com. [209.85.166.52]) by smtp.gmail.com with ESMTPSA id b12sm15273625ilc.21.2021.01.11.04.22.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Jan 2021 04:22:18 -0800 (PST) Received: by mail-io1-f52.google.com with SMTP id q137so17556816iod.9 for ; Mon, 11 Jan 2021 04:22:18 -0800 (PST) X-Received: by 2002:a6b:c414:: with SMTP id y20mr14242726ioa.150.1610367737624; Mon, 11 Jan 2021 04:22:17 -0800 (PST) MIME-Version: 1.0 References: <20210111113529.45488-1-ribalda@chromium.org> In-Reply-To: From: Ricardo Ribalda Date: Mon, 11 Jan 2021 13:22:06 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] hantro: Format IOCTLs compliance fixes To: Ezequiel Garcia Cc: Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linux Media Mailing List , linux-rockchip@lists.infradead.org, devel@driverdev.osuosl.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ezequiel On Mon, Jan 11, 2021 at 12:55 PM Ricardo Ribalda wrote: > > Hi Ezequiel > > On Mon, Jan 11, 2021 at 12:48 PM Ezequiel Garcia wrote: > > > > Hi Ricardo, > > > > On Mon, 2021-01-11 at 12:35 +0100, Ricardo Ribalda wrote: > > > Clear the reserved fields. > > > > > > Fixes: > > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > > test VIDIOC_TRY_FMT: FAIL > > > fail: v4l2-test-formats.cpp(482): pix_mp.plane_fmt[0].reserved not zeroed > > > test VIDIOC_S_FMT: FAIL > > > > > > Signed-off-by: Ricardo Ribalda > > > --- > > > drivers/staging/media/hantro/hantro_v4l2.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c > > > index b668a82d40ad..9b384fbffc93 100644 > > > --- a/drivers/staging/media/hantro/hantro_v4l2.c > > > +++ b/drivers/staging/media/hantro/hantro_v4l2.c > > > @@ -239,6 +239,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > > const struct hantro_fmt *fmt, *vpu_fmt; > > > bool capture = V4L2_TYPE_IS_CAPTURE(type); > > > bool coded; > > > + int i; > > > > > > coded = capture == ctx->is_encoder; > > > > > > @@ -293,6 +294,10 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, > > > pix_mp->width * pix_mp->height * fmt->max_depth; > > > } > > > > > > + for (i = 0; i < pix_mp->num_planes; i++) > > > + memset(pix_mp->plane_fmt[i].reserved, 0, > > > + sizeof(pix_mp->plane_fmt[i].reserved)); > > > + > > > > This looks like something that should be handled at the core, > > probably in drivers/media/v4l2-core/v4l2-ioctl.c::v4l_try_fmt(). > > The core does clear the reserved field from v4l2_pix_format_mplane, My bad, It is also clearing the per plane reserved field. I was testing in an old kernel. The grep it is still valid though. We can remove all the memsets in the drivers. > but not the reserved field for every plane. I can try to add it to the > core as well. At least these drivers have code duplication: > > git grep reserved | grep memset | grep plane_fmt > drivers/media/pci/intel/ipu3/ipu3-cio2.c: > memset(mpix->plane_fmt[0].reserved, 0, > drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c: > memset(pix_mp->plane_fmt[i].reserved, 0, > drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: > memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: > memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: > memset(&(pix->plane_fmt[i].reserved[0]), 0x0, > drivers/media/platform/rcar_fdp1.c: > memset(pix->plane_fmt[i].reserved, 0, > drivers/media/platform/rcar_fdp1.c: > memset(pix->plane_fmt[2].reserved, 0, > drivers/media/platform/rcar_jpu.c: > memset(pix->plane_fmt[0].reserved, 0, > drivers/media/platform/rcar_jpu.c: > memset(pix->plane_fmt[i].reserved, 0, > drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: > memset(pix->plane_fmt[i].reserved, 0, > drivers/media/platform/ti-vpe/vpe.c: > memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved)); > drivers/media/test-drivers/vicodec/vicodec-core.c: > memset(pix_mp->plane_fmt[0].reserved, 0, > drivers/staging/media/hantro/hantro_v4l2.c: > memset(pix_mp->plane_fmt[i].reserved, 0, > drivers/staging/media/ipu3/ipu3-v4l2.c: memset(pixm->plane_fmt[0].reserved, 0, > > > > > Thanks, > > Ezequiel > > > > > -- > Ricardo Ribalda -- Ricardo Ribalda