linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data
@ 2022-05-27 10:24 Ming Qian
  2022-05-27 10:28 ` Tommaso Merciai
  2022-05-27 11:11 ` Fabio Estevam
  0 siblings, 2 replies; 6+ messages in thread
From: Ming Qian @ 2022-05-27 10:24 UTC (permalink / raw)
  To: mchehab, mirela.rabulea, hverkuil-cisco
  Cc: shawnguo, s.hauer, kernel, festevam, linux-imx, linux-media,
	linux-kernel, devicetree, linux-arm-kernel

There is a hardware bug that it will load
the first 128 bytes of configuration data twice,
it will led to some configure error.
so shift the configuration data 128 bytes,
and make the first 128 bytes all zero,
then hardware will load the 128 zero twice,
and ignore them as garbage.
then the configuration data can be loaded correctly

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
---
v2
- add some comments about why the 0x80 offset is needed
 drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index 734e1b65fbc7..c0fd030d0f19 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -519,6 +519,7 @@ static bool mxc_jpeg_alloc_slot_data(struct mxc_jpeg_dev *jpeg,
 				     GFP_ATOMIC);
 	if (!cfg_stm)
 		goto err;
+	memset(cfg_stm, 0, MXC_JPEG_MAX_CFG_STREAM);
 	jpeg->slot_data[slot].cfg_stream_vaddr = cfg_stm;
 
 skip_alloc:
@@ -755,7 +756,13 @@ static unsigned int mxc_jpeg_setup_cfg_stream(void *cfg_stream_vaddr,
 					      u32 fourcc,
 					      u16 w, u16 h)
 {
-	unsigned int offset = 0;
+	/*
+	 * There is a hardware issue that first 128 bytes of configuration data
+	 * can't be loaded correctly.
+	 * To avoid this issue, we need to write the configuration from
+	 * an offset which should be no less than 0x80 (128 bytes).
+	 */
+	unsigned int offset = 0x80;
 	u8 *cfg = (u8 *)cfg_stream_vaddr;
 	struct mxc_jpeg_sof *sof;
 	struct mxc_jpeg_sos *sos;
-- 
2.36.1


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

* Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data
  2022-05-27 10:24 [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data Ming Qian
@ 2022-05-27 10:28 ` Tommaso Merciai
  2022-05-27 11:11 ` Fabio Estevam
  1 sibling, 0 replies; 6+ messages in thread
From: Tommaso Merciai @ 2022-05-27 10:28 UTC (permalink / raw)
  To: Ming Qian
  Cc: mchehab, mirela.rabulea, hverkuil-cisco, shawnguo, s.hauer,
	kernel, festevam, linux-imx, linux-media, linux-kernel,
	devicetree, linux-arm-kernel

On Fri, May 27, 2022 at 06:24:44PM +0800, Ming Qian wrote:
> There is a hardware bug that it will load
> the first 128 bytes of configuration data twice,
> it will led to some configure error.
> so shift the configuration data 128 bytes,
> and make the first 128 bytes all zero,
> then hardware will load the 128 zero twice,
> and ignore them as garbage.
> then the configuration data can be loaded correctly
> 
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
> ---
> v2
> - add some comments about why the 0x80 offset is needed
>  drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> index 734e1b65fbc7..c0fd030d0f19 100644
> --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> @@ -519,6 +519,7 @@ static bool mxc_jpeg_alloc_slot_data(struct mxc_jpeg_dev *jpeg,
>  				     GFP_ATOMIC);
>  	if (!cfg_stm)
>  		goto err;
> +	memset(cfg_stm, 0, MXC_JPEG_MAX_CFG_STREAM);
>  	jpeg->slot_data[slot].cfg_stream_vaddr = cfg_stm;
>  
>  skip_alloc:
> @@ -755,7 +756,13 @@ static unsigned int mxc_jpeg_setup_cfg_stream(void *cfg_stream_vaddr,
>  					      u32 fourcc,
>  					      u16 w, u16 h)
>  {
> -	unsigned int offset = 0;
> +	/*
> +	 * There is a hardware issue that first 128 bytes of configuration data
> +	 * can't be loaded correctly.
> +	 * To avoid this issue, we need to write the configuration from
> +	 * an offset which should be no less than 0x80 (128 bytes).
> +	 */
> +	unsigned int offset = 0x80;
>  	u8 *cfg = (u8 *)cfg_stream_vaddr;
>  	struct mxc_jpeg_sof *sof;
>  	struct mxc_jpeg_sos *sos;
> -- 
> 2.36.1
> 

Looks good to me!

Thanks,
Tommaso

-- 
Tommaso Merciai
Embedded Linux Engineer
tommaso.merciai@amarulasolutions.com
__________________________________

Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data
  2022-05-27 10:24 [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data Ming Qian
  2022-05-27 10:28 ` Tommaso Merciai
@ 2022-05-27 11:11 ` Fabio Estevam
  2022-05-27 11:33   ` [EXT] " Ming Qian
  1 sibling, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2022-05-27 11:11 UTC (permalink / raw)
  To: Ming Qian
  Cc: Mauro Carvalho Chehab, mirela.rabulea, Hans Verkuil, Shawn Guo,
	Sascha Hauer, Sascha Hauer, NXP Linux Team, linux-media,
	linux-kernel,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Hi Ming,

On Fri, May 27, 2022 at 7:25 AM Ming Qian <ming.qian@nxp.com> wrote:
>
> There is a hardware bug that it will load
> the first 128 bytes of configuration data twice,
> it will led to some configure error.
> so shift the configuration data 128 bytes,
> and make the first 128 bytes all zero,
> then hardware will load the 128 zero twice,
> and ignore them as garbage.
> then the configuration data can be loaded correctly
>
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>

Fixes tag?

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

* RE: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data
  2022-05-27 11:11 ` Fabio Estevam
@ 2022-05-27 11:33   ` Ming Qian
  2022-05-27 19:26     ` Nicolas Dufresne
  0 siblings, 1 reply; 6+ messages in thread
From: Ming Qian @ 2022-05-27 11:33 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Mauro Carvalho Chehab, Mirela Rabulea (OSS),
	Hans Verkuil, Shawn Guo, Sascha Hauer, Sascha Hauer,
	dl-linux-imx, linux-media, linux-kernel,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

> From: Fabio Estevam <festevam@gmail.com>
> Sent: 2022年5月27日 19:12
> To: Ming Qian <ming.qian@nxp.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>; Mirela Rabulea (OSS)
> <mirela.rabulea@oss.nxp.com>; Hans Verkuil <hverkuil-cisco@xs4all.nl>;
> Shawn Guo <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> Sascha Hauer <kernel@pengutronix.de>; dl-linux-imx <linux-imx@nxp.com>;
> linux-media <linux-media@vger.kernel.org>; linux-kernel
> <linux-kernel@vger.kernel.org>; open list:OPEN FIRMWARE AND FLATTENED
> DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; moderated
> list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
> <linux-arm-kernel@lists.infradead.org>
> Subject: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the
> configuration data
> 
> Caution: EXT Email
> 
> Hi Ming,
> 
> On Fri, May 27, 2022 at 7:25 AM Ming Qian <ming.qian@nxp.com> wrote:
> >
> > There is a hardware bug that it will load the first 128 bytes of
> > configuration data twice, it will led to some configure error.
> > so shift the configuration data 128 bytes, and make the first 128
> > bytes all zero, then hardware will load the 128 zero twice, and ignore
> > them as garbage.
> > then the configuration data can be loaded correctly
> >
> > Signed-off-by: Ming Qian <ming.qian@nxp.com>
> > Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> > Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
> 
> Fixes tag?

Hi Fabio,
    It's a hardware issue, so I'm not sure is it a driver issue that I fix it.
    Or I just check which patch includes the code I changed, and add the fix tag?

Ming

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

* Re: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data
  2022-05-27 11:33   ` [EXT] " Ming Qian
@ 2022-05-27 19:26     ` Nicolas Dufresne
  2022-05-30  2:50       ` Ming Qian
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Dufresne @ 2022-05-27 19:26 UTC (permalink / raw)
  To: Ming Qian, Fabio Estevam
  Cc: Mauro Carvalho Chehab, Mirela Rabulea (OSS),
	Hans Verkuil, Shawn Guo, Sascha Hauer, Sascha Hauer,
	dl-linux-imx, linux-media, linux-kernel,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

Le vendredi 27 mai 2022 à 11:33 +0000, Ming Qian a écrit :
> > From: Fabio Estevam <festevam@gmail.com>
> > Sent: 2022年5月27日 19:12
> > To: Ming Qian <ming.qian@nxp.com>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>; Mirela Rabulea (OSS)
> > <mirela.rabulea@oss.nxp.com>; Hans Verkuil <hverkuil-cisco@xs4all.nl>;
> > Shawn Guo <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> > Sascha Hauer <kernel@pengutronix.de>; dl-linux-imx <linux-imx@nxp.com>;
> > linux-media <linux-media@vger.kernel.org>; linux-kernel
> > <linux-kernel@vger.kernel.org>; open list:OPEN FIRMWARE AND FLATTENED
> > DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; moderated
> > list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
> > <linux-arm-kernel@lists.infradead.org>
> > Subject: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before
> > the
> > configuration data
> > 
> > Caution: EXT Email
> > 
> > Hi Ming,
> > 
> > On Fri, May 27, 2022 at 7:25 AM Ming Qian <ming.qian@nxp.com> wrote:
> > > 
> > > There is a hardware bug that it will load the first 128 bytes of
> > > configuration data twice, it will led to some configure error.
> > > so shift the configuration data 128 bytes, and make the first 128
> > > bytes all zero, then hardware will load the 128 zero twice, and ignore
> > > them as garbage.
> > > then the configuration data can be loaded correctly
> > > 
> > > Signed-off-by: Ming Qian <ming.qian@nxp.com>
> > > Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> > > Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
> > 
> > Fixes tag?
> 
> Hi Fabio,
>     It's a hardware issue, so I'm not sure is it a driver issue that I fix it.
>     Or I just check which patch includes the code I changed, and add the fix
> tag?

You can use Fixes tag even though there was no software bug. The point of the
tag is to help locate how far we can backport this patch in order to let stable
kernel users benefit.

regards,
Nicolas

> 
> Ming


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

* RE: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data
  2022-05-27 19:26     ` Nicolas Dufresne
@ 2022-05-30  2:50       ` Ming Qian
  0 siblings, 0 replies; 6+ messages in thread
From: Ming Qian @ 2022-05-30  2:50 UTC (permalink / raw)
  To: Nicolas Dufresne, Fabio Estevam
  Cc: Mauro Carvalho Chehab, Mirela Rabulea (OSS),
	Hans Verkuil, Shawn Guo, Sascha Hauer, Sascha Hauer,
	dl-linux-imx, linux-media, linux-kernel,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

> From: Nicolas Dufresne <nicolas@ndufresne.ca>
> Sent: 2022年5月28日 3:26
> To: Ming Qian <ming.qian@nxp.com>; Fabio Estevam <festevam@gmail.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>; Mirela Rabulea (OSS)
> <mirela.rabulea@oss.nxp.com>; Hans Verkuil <hverkuil-cisco@xs4all.nl>;
> Shawn Guo <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> Sascha Hauer <kernel@pengutronix.de>; dl-linux-imx <linux-imx@nxp.com>;
> linux-media <linux-media@vger.kernel.org>; linux-kernel
> <linux-kernel@vger.kernel.org>; open list:OPEN FIRMWARE AND FLATTENED
> DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; moderated
> list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
> <linux-arm-kernel@lists.infradead.org>
> Subject: Re: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before
> the configuration data
> 
> Caution: EXT Email
> 
> Le vendredi 27 mai 2022 à 11:33 +0000, Ming Qian a écrit :
> > > From: Fabio Estevam <festevam@gmail.com>
> > > Sent: 2022年5月27日 19:12
> > > To: Ming Qian <ming.qian@nxp.com>
> > > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>; Mirela Rabulea (OSS)
> > > <mirela.rabulea@oss.nxp.com>; Hans Verkuil
> > > <hverkuil-cisco@xs4all.nl>; Shawn Guo <shawnguo@kernel.org>; Sascha
> > > Hauer <s.hauer@pengutronix.de>; Sascha Hauer
> > > <kernel@pengutronix.de>; dl-linux-imx <linux-imx@nxp.com>;
> > > linux-media <linux-media@vger.kernel.org>; linux-kernel
> > > <linux-kernel@vger.kernel.org>; open list:OPEN FIRMWARE AND
> > > FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>;
> > > moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
> > > <linux-arm-kernel@lists.infradead.org>
> > > Subject: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space
> > > before the configuration data
> > >
> > > Caution: EXT Email
> > >
> > > Hi Ming,
> > >
> > > On Fri, May 27, 2022 at 7:25 AM Ming Qian <ming.qian@nxp.com> wrote:
> > > >
> > > > There is a hardware bug that it will load the first 128 bytes of
> > > > configuration data twice, it will led to some configure error.
> > > > so shift the configuration data 128 bytes, and make the first 128
> > > > bytes all zero, then hardware will load the 128 zero twice, and
> > > > ignore them as garbage.
> > > > then the configuration data can be loaded correctly
> > > >
> > > > Signed-off-by: Ming Qian <ming.qian@nxp.com>
> > > > Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> > > > Reviewed-by: Tommaso Merciai
> > > > <tommaso.merciai@amarulasolutions.com>
> > >
> > > Fixes tag?
> >
> > Hi Fabio,
> >     It's a hardware issue, so I'm not sure is it a driver issue that I fix it.
> >     Or I just check which patch includes the code I changed, and add
> > the fix tag?
> 
> You can use Fixes tag even though there was no software bug. The point of the
> tag is to help locate how far we can backport this patch in order to let stable
> kernel users benefit.
> 
> regards,
> Nicolas
> 

Hi Nicolas,
    Thanks for your information, I'll add a fix tag in v3.
Ming.

> >
> > Ming


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

end of thread, other threads:[~2022-05-30  2:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 10:24 [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data Ming Qian
2022-05-27 10:28 ` Tommaso Merciai
2022-05-27 11:11 ` Fabio Estevam
2022-05-27 11:33   ` [EXT] " Ming Qian
2022-05-27 19:26     ` Nicolas Dufresne
2022-05-30  2:50       ` Ming Qian

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