Skip to contentSkip to conversation

media: imx-jpeg: Leave a blank space before the configuration data

PATCH Superseded Ming Qian 4 participants 6 messages May 27, 2022 – May 30, 2022

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ming Qian

author
#0 lore raw

PATCH v2 1/1 media: imx-jpeg: Leave a blank space before the configuration data

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

---
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(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +8 -1
index 734e1b65fbc7..c0fd030d0f19 100644
@@ -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;
Signature · 1 line
2.36.1
#1 lore raw
Quoted 48 lines · Ming Qian

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

---
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(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +8 -1
index 734e1b65fbc7..c0fd030d0f19 100644
@@ -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;
Signature · 1 line
2.36.1

Looks good to me!

Thanks,
Tommaso

Signature · 10 lines
Tommaso Merciai
Embedded Linux Engineer
[email protected]
__________________________________

Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
[email protected]
www.amarulasolutions.com
reviewer
#2 lore raw
In reply to Ming Qian

Hi Ming,

Quoted 10 lines · Ming Qian

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

Quoted 3 lines

Fixes tag?

author
#3 lore raw
Quoted 28 lines

From: Fabio Estevam <[email protected]>
Sent: 2022年5月27日 19:12
To: Ming Qian <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>; Mirela Rabulea (OSS) <[email protected]>; Hans Verkuil <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Sascha Hauer <[email protected]>; dl-linux-imx <[email protected]>; linux-media <[email protected]>; linux-kernel <[email protected]>; open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS <[email protected]>; moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <[email protected]>
Subject: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data

Caution: EXT Email

Hi Ming,

Quoted 8 lines · Ming Qian

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

Quoted 5 lines
Quoted 3 lines

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

#4 lore raw

Le vendredi 27 mai 2022 à 11:33 +0000, Ming Qian a écrit :

Quoted 33 lines
Quoted 33 lines

From: Fabio Estevam <[email protected]>
Sent: 2022年5月27日 19:12
To: Ming Qian <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>; Mirela Rabulea (OSS) <[email protected]>; Hans Verkuil <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Sascha Hauer <[email protected]>; dl-linux-imx <[email protected]>; linux-media <[email protected]>; linux-kernel <[email protected]>; open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS <[email protected]>; moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <[email protected]>
Subject: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the
configuration data

Caution: EXT Email

Hi Ming,

Quoted 11 lines · Ming Qian

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

Quoted 6 lines
Quoted 1 line

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

Quoted 2 lines

Ming

author
#5 lore raw
Quoted 59 lines

From: Nicolas Dufresne <[email protected]>
Sent: 2022年5月28日 3:26
To: Ming Qian <[email protected]>; Fabio Estevam <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>; Mirela Rabulea (OSS) <[email protected]>; Hans Verkuil <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Sascha Hauer <[email protected]>; dl-linux-imx <[email protected]>; linux-media <[email protected]>; linux-kernel <[email protected]>; open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS <[email protected]>; moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <[email protected]>
Subject: Re: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data

Caution: EXT Email

Quoted 34 lines · Ming Qian
Quoted 34 lines

From: Fabio Estevam <[email protected]>
Sent: 2022年5月27日 19:12
To: Ming Qian <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>; Mirela Rabulea (OSS) <[email protected]>; Hans Verkuil <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Sascha Hauer <[email protected]>; dl-linux-imx <[email protected]>; linux-media <[email protected]>; linux-kernel <[email protected]>; open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS <[email protected]>; moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <[email protected]>
Subject: [EXT] Re: [PATCH v2] media: imx-jpeg: Leave a blank space before the configuration data

Caution: EXT Email

Hi Ming,

Quoted 12 lines · Ming Qian

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

Reviewed-by Tommaso Merciai

<[email protected]>

Quoted 6 lines
Quoted 1 line

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?

Quoted 7 lines

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.

Quoted 2 lines
Quoted 2 lines

Ming