lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y5HtQr6G1Ha8ybeX@aptenodytes>
Date:   Thu, 8 Dec 2022 14:57:22 +0100
From:   Paul Kocialkowski <paul.kocialkowski@...tlin.com>
To:     Conor Dooley <conor@...nel.org>
Cc:     Nathan Chancellor <nathan@...nel.org>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-media@...r.kernel.org, devicetree@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
        linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzk+dt@...nel.org>,
        Chen-Yu Tsai <wens@...e.org>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        Samuel Holland <samuel@...lland.org>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Hans Verkuil <hans.verkuil@...co.com>,
        Laurent Pinchart <laurent.pinchart@...asonboard.com>,
        Maxime Ripard <mripard@...nel.org>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
        llvm@...ts.linux.dev
Subject: Re: [PATCH v8 3/6] staging: media: Add support for the Allwinner A31
 ISP

Hi Conor, Nathan,

On Wed 07 Dec 22, 10:06, Conor Dooley wrote:
> On Sun, Nov 27, 2022 at 11:31:41PM -0700, Nathan Chancellor wrote:
> > Hi Paul,
> > 
> > On Thu, Nov 03, 2022 at 05:37:14PM +0100, Paul Kocialkowski wrote:
> > > Some Allwinner platforms come with an Image Signal Processor, which
> > > supports various features in order to enhance and transform data
> > > received by image sensors into good-looking pictures. In most cases,
> > > the data is raw bayer, which gets internally converted to RGB and
> > > finally YUV, which is what the hardware produces.
> > > 
> > > This driver supports ISPs that are similar to the A31 ISP, which was
> > > the first standalone ISP found in Allwinner platforms. Simpler ISP
> > > blocks were found in the A10 and A20, where they are tied to a CSI
> > > controller. Newer generations of Allwinner SoCs (starting with the
> > > H6, H616, etc) come with a new camera subsystem and revised ISP.
> > > Even though these previous and next-generation ISPs are somewhat
> > > similar to the A31 ISP, they have enough significant differences to
> > > be out of the scope of this driver.
> > > 
> > > While the ISP supports many features, including 3A and many
> > > enhancement blocks, this implementation is limited to the following:
> > > - V3s (V3/S3) platform support;
> > > - Bayer media bus formats as input;
> > > - Semi-planar YUV (NV12/NV21) as output;
> > > - Debayering with per-component gain and offset configuration;
> > > - 2D noise filtering with configurable coefficients.
> > > 
> > > Since many features are missing from the associated uAPI, the driver
> > > is aimed to integrate staging until all features are properly
> > > described.
> > > 
> > > On the technical side, it uses the v4l2 and media controller APIs,
> > > with a video node for capture, a processor subdev and a video node
> > > for parameters submission. A specific uAPI structure and associated
> > > v4l2 meta format are used to configure parameters of the supported
> > > modules.
> > > 
> > > One particular thing about the hardware is that configuration for
> > > module registers needs to be stored in a DMA buffer and gets copied
> > > to actual registers by the hardware at the next vsync, when instructed
> > > by a flag. This is handled by the "state" mechanism in the driver.
> > > 
> > > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
> > 
> > This patch is now in -next as commit e3185e1d7c14 ("media: staging:
> > media: Add support for the Allwinner A31 ISP"), where it causes the
> > following clang warnings:
> 
> FWIW, this is (as yet) unfixed & thus breaking allmodconfig w/ clang.
> I had a quick look on lore but could not see a proposed fix other than
> what Nathan has pasted below.

Sorry for the inconvenience. I've just sent a fix series which should resolve
these issues (and other ones too): "Allwinner A31/A83T CSI/ISP/MIPI CSI-2 media
fixes" (version 2).

Thanks for the report!

Paul

> > > +void sun6i_isp_capture_configure(struct sun6i_isp_device *isp_dev)
> > > +{
> > > +	unsigned int width, height;
> > > +	unsigned int stride_luma, stride_chroma = 0;
> > > +	unsigned int stride_luma_div4, stride_chroma_div4;
> > > +	const struct sun6i_isp_capture_format *format;
> > > +	const struct v4l2_format_info *info;
> > > +	u32 pixelformat;
> > > +
> > > +	sun6i_isp_capture_dimensions(isp_dev, &width, &height);
> > > +	sun6i_isp_capture_format(isp_dev, &pixelformat);
> > > +
> > > +	format = sun6i_isp_capture_format_find(pixelformat);
> > > +	if (WARN_ON(!format))
> > > +		return;
> > > +
> > > +	sun6i_isp_load_write(isp_dev, SUN6I_ISP_MCH_SIZE_CFG_REG,
> > > +			     SUN6I_ISP_MCH_SIZE_CFG_WIDTH(width) |
> > > +			     SUN6I_ISP_MCH_SIZE_CFG_HEIGHT(height));
> > > +
> > > +	info = v4l2_format_info(pixelformat);
> > > +	if (WARN_ON(!info))
> > > +		return;
> > > +
> > > +	stride_luma = width * info->bpp[0];
> > > +	stride_luma_div4 = DIV_ROUND_UP(stride_luma, 4);
> > > +
> > > +	if (info->comp_planes > 1) {
> > > +		stride_chroma = width * info->bpp[1] / info->hdiv;
> > > +		stride_chroma_div4 = DIV_ROUND_UP(stride_chroma, 4);
> > > +	}
> > > +
> > > +	sun6i_isp_load_write(isp_dev, SUN6I_ISP_MCH_CFG_REG,
> > > +			     SUN6I_ISP_MCH_CFG_EN |
> > > +			     SUN6I_ISP_MCH_CFG_OUTPUT_FMT(format->output_format) |
> > > +			     SUN6I_ISP_MCH_CFG_STRIDE_Y_DIV4(stride_luma_div4) |
> > > +			     SUN6I_ISP_MCH_CFG_STRIDE_UV_DIV4(stride_chroma_div4));
> > > +}
> > 
> > 
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c:135:6: error: variable 'stride_chroma_div4' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> >           if (info->comp_planes > 1) {
> >               ^~~~~~~~~~~~~~~~~~~~~
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c:144:42: note: uninitialized use occurs here
> >                               SUN6I_ISP_MCH_CFG_STRIDE_UV_DIV4(stride_chroma_div4));
> >                                                                 ^~~~~~~~~~~~~~~~~~
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_reg.h:249:48: note: expanded from macro 'SUN6I_ISP_MCH_CFG_STRIDE_UV_DIV4'
> >   #define SUN6I_ISP_MCH_CFG_STRIDE_UV_DIV4(v)     (((v) << 20) & GENMASK(30, 20))
> >                                                     ^
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c:135:2: note: remove the 'if' if its condition is always true
> >           if (info->comp_planes > 1) {
> >           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c:112:51: note: initialize the variable 'stride_chroma_div4' to silence this warning
> >           unsigned int stride_luma_div4, stride_chroma_div4;
> >                                                           ^
> >                                                             = 0
> > 
> > Does stride_chroma_div4 want to just be initialized to zero?
> > 
> > > +static int sun6i_isp_proc_notifier_bound(struct v4l2_async_notifier *notifier,
> > > +					 struct v4l2_subdev *remote_subdev,
> > > +					 struct v4l2_async_subdev *async_subdev)
> > > +{
> > > +	struct sun6i_isp_device *isp_dev =
> > > +		container_of(notifier, struct sun6i_isp_device, proc.notifier);
> > > +	struct sun6i_isp_proc_async_subdev *proc_async_subdev =
> > > +		container_of(async_subdev, struct sun6i_isp_proc_async_subdev,
> > > +			     async_subdev);
> > > +	struct sun6i_isp_proc *proc = &isp_dev->proc;
> > > +	struct sun6i_isp_proc_source *source = proc_async_subdev->source;
> > > +	bool enabled;
> > > +
> > > +	switch (source->endpoint.base.port) {
> > > +	case SUN6I_ISP_PORT_CSI0:
> > > +		source = &proc->source_csi0;
> > > +		enabled = true;
> > > +		break;
> > > +	case SUN6I_ISP_PORT_CSI1:
> > > +		source = &proc->source_csi1;
> > > +		enabled = !proc->source_csi0.expected;
> > > +		break;
> > > +	default:
> > > +		break;
> > > +	}
> > > +
> > > +	source->subdev = remote_subdev;
> > > +
> > > +	return sun6i_isp_proc_link(isp_dev, SUN6I_ISP_PROC_PAD_SINK_CSI,
> > > +				   remote_subdev, enabled);
> > > +}
> > 
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c:418:2: error: variable 'enabled' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
> >           default:
> >           ^~~~~~~
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c:425:23: note: uninitialized use occurs here
> >                                     remote_subdev, enabled);
> >                                                     ^~~~~~~
> >   drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c:407:14: note: initialize the variable 'enabled' to silence this warning
> >           bool enabled;
> >                       ^
> >                       = 0
> > 
> > Should there be an early return in the default case?
> > 
> > I do not mind sending patches if you are unable to, assuming I have the
> > right fixes.
> > 
> > Cheers,
> > Nathan
> > 



-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ