s5p-jpeg fixes
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20170808112254eucas1p20aacd5bb0737ff85ba4756724af189aa@eucas1p2.samsung.com
cover s5p-jpeg fixes
Hi All,
This series contains a number of fixes to the s5p-jpeg driver.
There are two patches from Tony K Nadackal, which got lost long time ago.
@Thierry:
The patch changing the software reset routine you sent recently was actually a resend of Tony's patch. I investigated the question why this patch is needed. The encoder/decoder should be disabled as soon as possible, in the interrupt service routine; please see the commit message. I am resending Tony's patch again, with updated commit message. Thank you for reminding about the patch in question!
There are also three patches from me, please see appropriate commit messages.
Rebased onto Mauro's master.
Andrzej Pietrasiewicz (3):
media: platform: s5p-jpeg: disable encoder/decoder in exynos4-like
hardware after use
media: platform: s5p-jpeg: fix number of components macro
media: platform: s5p-jpeg: directly use parsed subsampling on 5433
Tony K Nadackal (2):
media: platform: s5p-jpeg: Fix crash in jpeg isr due to multiple
interrupts.
media: platform: s5p-jpeg: Clear JPEG_CODEC_ON bits in sw reset
function
drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 +++++++- drivers/media/platform/s5p-jpeg/jpeg-core.h | 1 + drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 9 ++++++++- drivers/media/platform/s5p-jpeg/jpeg-regs.h | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/5 media: platform: s5p-jpeg: Fix crash in jpeg isr due to multiple interrupts.
From: Tony K Nadackal <[email protected]>
In case of corrupt images, multiple interrupts may occur due to different error scenarios.
Since we are removing the src and dest buffers in the first interrupt itself, crash occurs in the second error interrupts.
Disable the global interrupt before we start processing the interrupt avoid the crash.
Disable System interrupt in isr to avoid the crash below.
Unable to handle kernel NULL pointer dereference at virtual address 000000c8 pgd = ffffffc0007db000 [000000c8] *pgd=00000000fb006003, *pud=00000000fb006003, *pmd=00000000fb007003, *pte=0060000011001707 Internal error: Oops: 96000007 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.18.0-next-20141210+ #22 Hardware name: Samsung Exynos7 Espresso board based on EXYNOS7 (DT) task: ffffffc00075e5c0 ti: ffffffc00074c000 task.ti: ffffffc00074c000 PC is at exynos4_jpeg_irq+0x30/0x15c LR is at exynos4_jpeg_irq+0x2c/0x15c pc : [<ffffffc00040873c>] lr : [<ffffffc000408738>] pstate: 800001c5
sp : ffffffc00074fc60
x29: ffffffc00074fc60 x28: 0000004040000000
x27: ffffffc000673928 x26: ffffffc000673940
x25: ffffffc0007a030c x24: ffffffc0bb20a400
x23: 0000000000000030 x22: ffffffc0ba56ba40
x21: 0000000000000000 x20: 0000000000000000
x19: ffffffc0ba56ba18 x18: 0000000000000000
x17: 0000000000000000 x16: ffffffc00018b508
x15: 0000000000000000 x14: 0000000000000000
x13: 0098968000000000 x12: 0000000000989680
x11: 0000000000000004 x10: 0101010101010101
x9 : 00000020a285a9ea x8 : ffffffc0007af880
x7 : ffffffc0bac001a8 x6 : ffffffc0bac00000
x5 : 00000000fffffffa x4 : ffffffc00040870c
x3 : 0000000000000003 x2 : 0000000000010003
x1 : 0000000000010002 x0 : 0000000000000000
Process swapper/0 (pid: 0, stack limit = 0xffffffc00074c058)
Stack: (0xffffffc00074fc60 to 0xffffffc000750000)
fc60: 0074fca0 ffffffc0 000e4508 ffffffc0 bb225300 ffffffc0 bb20a494 ffffffc0
fc80: 00000000 00000000 00000000 00000000 00000030 00000000 000f8c6c ffffffc0
fca0: 0074fd00 ffffffc0 000e4644 ffffffc0 bb20a400 ffffffc0 bb20a494 ffffffc0
fcc0: 00776a00 ffffffc0 00670da8 ffffffc0 00000000 00000000 00000001 00000000
fce0: bb008000 ffffffc0 407db000 00000000 00081230 ffffffc0 000e4638 ffffffc0
fd00: 0074fd40 ffffffc0 000e7338 ffffffc0 bb20a400 ffffffc0 bb20a494 ffffffc0
fd20: 00776a00 ffffffc0 000e7280 ffffffc0 bb225300 ffffffc0 000e72e0 ffffffc0
fd40: 0074fd70 ffffffc0 000e3d60 ffffffc0 00000030 00000000 00743000 ffffffc0
fd60: 0066e000 ffffffc0 006c2000 ffffffc0 0074fd90 ffffffc0 000e3e90 ffffffc0
fd80: 007437c8 ffffffc0 000e3e6c ffffffc0 0074fdf0 ffffffc0 00082404 ffffffc0
fda0: 0074fe20 ffffffc0 0075a000 ffffffc0 0000200c ffffff80 00002010 ffffff80
fdc0: 60000145 00000000 00672cc8 ffffffc0 407d9000 00000000 befb9b40 ffffffc0
fde0: 0074fe20 ffffffc0 000001d2 00000000 0074ff40 ffffffc0 00085da8 ffffffc0
fe00: 00758584 ffffffc0 0052c000 ffffffc0 0074ff40 ffffffc0 00087114 ffffffc0
fe20: 00000000 00000000 0074ff50 ffffffc0 0067d760 ffffffc0 befb9adc ffffffc0
fe40: 00000001 00000000 d4414200 00000020 d6a39c00 00000020 007a6a18 ffffffc0
fe60: 0075eb00 ffffffc0 0074fd60 ffffffc0 ffffc185 00000000 00000020 00000000
fe80: 0052d340 ffffffc0 00000030 00000000 fffffffe 0fffffff 00000000 00000000
fea0: 0018b508 ffffffc0 00000000 00000000 00000000 00000000 00758584 ffffffc0
fec0: 0052c000 ffffffc0 006c24e8 ffffffc0 007a030a ffffffc0 00000001 00000000
fee0: 00672cc8 ffffffc0 407d9000 00000000 407db000 00000000 00081230 ffffffc0
ff00: 40000000 00000040 0074ff40 ffffffc0 00087110 ffffffc0 0074ff40 ffffffc0
ff20: 00087114 ffffffc0 60000145 00000000 00758584 ffffffc0 0052c000 ffffffc0
ff40: 0074ff50 ffffffc0 000db568 ffffffc0 0074ff90 ffffffc0 00515fdc ffffffc0
ff60: 00758000 ffffffc0 007a3000 ffffffc0 007a3000 ffffffc0 befc8940 ffffffc0
ff80: 40760000 00000000 40000000 00000000 0074ffb0 ffffffc0 006ff998 ffffffc0
ffa0: 00000002 00000000 006ff988 ffffffc0 00000000 00000000 400826c0 00000000
ffc0: 8f03a688 00000000 00000e11 00000000 48000000 00000000 410fd030 00000000
ffe0: 0072c250 ffffffc0 00000000 00000000 00000000 00000000 00000000 00000000
Call trace: [<ffffffc00040873c>] exynos4_jpeg_irq+0x30/0x15c [<ffffffc0000e4504>] handle_irq_event_percpu+0x6c/0x160 [<ffffffc0000e4640>] handle_irq_event+0x48/0x78 [<ffffffc0000e7334>] handle_fasteoi_irq+0xe0/0x198 [<ffffffc0000e3d5c>] generic_handle_irq+0x24/0x40 [<ffffffc0000e3e8c>] __handle_domain_irq+0x80/0xf0 [<ffffffc000082400>] gic_handle_irq+0x30/0x80 Exception stack(0xffffffc00074fe00 to 0xffffffc00074ff20)
fe00: 00758584 ffffffc0 0052c000 ffffffc0 0074ff40 ffffffc0 00087114 ffffffc0
fe20: 00000000 00000000 0074ff50 ffffffc0 0067d760 ffffffc0 befb9adc ffffffc0
fe40: 00000001 00000000 d4414200 00000020 d6a39c00 00000020 007a6a18 ffffffc0
fe60: 0075eb00 ffffffc0 0074fd60 ffffffc0 ffffc185 00000000 00000020 00000000
fe80: 0052d340 ffffffc0 00000030 00000000 fffffffe 0fffffff 00000000 00000000
fea0: 0018b508 ffffffc0 00000000 00000000 00000000 00000000 00758584 ffffffc0
fec0: 0052c000 ffffffc0 006c24e8 ffffffc0 007a030a ffffffc0 00000001 00000000
fee0: 00672cc8 ffffffc0 407d9000 00000000 407db000 00000000 00081230 ffffffc0
ff00: 40000000 00000040 0074ff40 ffffffc0 00087110 ffffffc0 0074ff40 ffffffc0
[<ffffffc000085da4>] el1_irq+0x64/0xd8 [<ffffffc0000db564>] cpu_startup_entry+0x118/0x168 [<ffffffc000515fd8>] rest_init+0x7c/0x88 [<ffffffc0006ff994>] start_kernel+0x3a8/0x3bc Code: 94045c34 f9406e60 97ffdc74 aa0003f4 (f9406400) ---[ end trace fa6dc0ea2efad21f ]--- Kernel panic - not syncing: Fatal exception in interrupt ---[ end Kernel panic - not syncing: Fatal exception in interrupt
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-core.c +3 -0
@@ -2259,6 +2259,7 @@ static void exynos4_jpeg_device_run(void *priv)exynos4_jpeg_set_dec_bitstream_size (jpeg->regs, bitstream_size); } +exynos4_jpeg_set_sys_int_enable (jpeg->regs,1 );exynos4_jpeg_set_enc_dec_mode (jpeg->regs, ctx->mode);spin_unlock_irqrestore (&jpeg->slock, flags);
@@ -2662,6 +2663,8 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void *priv)spin_lock (&jpeg->slock); +exynos4_jpeg_set_sys_int_enable (jpeg->regs,0 ); + curr_ctx =v4l2_m2m_get_curr_priv (jpeg->m2m_dev); src_vb =v4l2_m2m_src_buf_remove (curr_ctx->fh.m2m_ctx);
Signature · 1 line
1.9.1
PATCH 2/5 media: platform: s5p-jpeg: disable encoder/decoder in exynos4-like hardware after use
Clearing the bits turns off the encoder/decoder. If the hardware is not turned off after use, at subsequent uses it does not work in a stable manner, resulting in incorrect interrupt status value being read and e.g. erroneous read of compressed bitstream size.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 ++ drivers/media/platform/s5p-jpeg/jpeg-core.h | 1 + drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +2 -0
@@ -2713,6 +2713,8 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void *priv)if (jpeg->variant->version ==SJPEG_EXYNOS4 ) curr_ctx->subsampling =exynos4_jpeg_get_frame_fmt (jpeg->regs); +exynos4_jpeg_set_enc_dec_mode (jpeg->regs,S5P_JPEG_DISABLE ); +spin_unlock (&jpeg->slock);v4l2_m2m_job_finish (jpeg->m2m_dev, curr_ctx->fh.m2m_ctx);
drivers/media/platform/s5p-jpeg/jpeg-core.h +1 -0
@@ -63,6 +63,7 @@#define S5P_JPEG_ENCODE 0#define S5P_JPEG_DECODE 1 +#define S5P_JPEG_DISABLE -1#define FMT_TYPE_OUTPUT 0#define FMT_TYPE_CAPTURE 1
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c +4 -1
@@ -38,10 +38,13 @@ void exynos4_jpeg_set_enc_dec_mode(void __iomem *base, unsigned int mode)writel ((reg &EXYNOS4_ENC_DEC_MODE_MASK ) |EXYNOS4_DEC_MODE , base +EXYNOS4_JPEG_CNTL_REG ); - }else {/* encode */ + }else if (mode ==S5P_JPEG_ENCODE ) {/* encode */ writel ((reg &EXYNOS4_ENC_DEC_MODE_MASK ) |EXYNOS4_ENC_MODE , base +EXYNOS4_JPEG_CNTL_REG ); + }else {/* disable both */ +writel (reg &EXYNOS4_ENC_DEC_MODE_MASK , + base +EXYNOS4_JPEG_CNTL_REG ); } }
Signature · 1 line
1.9.1
PATCH 3/5 media: platform: s5p-jpeg: Clear JPEG_CODEC_ON bits in sw reset function
In reply to Andrzej PietrasiewiczFrom: Tony K Nadackal <[email protected]>
Bits EXYNOS4_DEC_MODE and EXYNOS4_ENC_MODE do not get cleared on software reset. These bits need to be cleared explicitly.
Even though the bits in question are already cleared in interrupt service routine, the reset should also clear them in case e.g. bootloader uses the codec and leaves it in a bad state.
--- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c +4 -0
@@ -21,6 +21,10 @@ void exynos4_jpeg_sw_reset(void __iomem *base)unsigned int reg; reg =readl (base +EXYNOS4_JPEG_CNTL_REG ); +writel (reg & ~(EXYNOS4_DEC_MODE |EXYNOS4_ENC_MODE ), + base +EXYNOS4_JPEG_CNTL_REG ); + + reg =readl (base +EXYNOS4_JPEG_CNTL_REG );writel (reg & ~EXYNOS4_SOFT_RESET_HI , base +EXYNOS4_JPEG_CNTL_REG );udelay (100 );
Signature · 1 line
1.9.1
PATCH 4/5 media: platform: s5p-jpeg: fix number of components macro
In reply to Andrzej PietrasiewiczThe value to be processed must be first masked and then shifted, not the other way round.
--- drivers/media/platform/s5p-jpeg/jpeg-regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-regs.h +1 -1
@@ -371,7 +371,7 @@#define EXYNOS4_NF_SHIFT 16#define EXYNOS4_NF_MASK 0xff#define EXYNOS4_NF (x) \ - (((x) << EXYNOS4_NF_SHIFT) & EXYNOS4_NF_MASK) + (((x) & EXYNOS4_NF_MASK) << EXYNOS4_NF_SHIFT)/* JPEG quantizer table register */ #define EXYNOS4_QTBL_CONTENT (n) (0x100 + (n) * 0x40)
Signature · 1 line
1.9.1
PATCH 4/5 media: platform: s5p-jpeg: fix number of components macro
Quoted 13 lines · Andrzej Pietrasiewicz
The value to be processed must be first masked and then shifted, not the other way round.
Signed-off-by Andrzej Pietrasiewicz <[email protected]>--- drivers/media/platform/s5p-jpeg/jpeg-regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/s5p-jpeg/jpeg-regs.h +0
-0
drivers/media/platform/s5p-jpeg/jpeg-regs.h line 374
Quoted 5 lines
drivers/media/platform/s5p-jpeg/jpeg-regs.h +1
-1@@ -371,7 +371,7 @@#define EXYNOS4_NF_SHIFT 16#define EXYNOS4_NF_MASK 0xff#define EXYNOS4_NF (x) \ - (((x) << EXYNOS4_NF_SHIFT) & EXYNOS4_NF_MASK) + (((x) & EXYNOS4_NF_MASK) << EXYNOS4_NF_SHIFT)
I'm going to add below tag when applying this patch.
Signature · 2 lines
Regards, Sylwester
PATCH 5/5 media: platform: s5p-jpeg: directly use parsed subsampling on 5433
In reply to Andrzej PietrasiewiczOn 5433 variant JPEG data is parsed by hardware only from SOS marker, so subsampling is parsed by software. As such, its value need not be translated from hardware-specific encoding to V4L2 encoding.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +2 -1
@@ -627,10 +627,11 @@ static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx)return V4L2_JPEG_CHROMA_SUBSAMPLING_411 ;return exynos3250_decoded_subsampling[ctx->subsampling];case SJPEG_EXYNOS4 : -case SJPEG_EXYNOS5433 :if (ctx->subsampling >2 )return V4L2_JPEG_CHROMA_SUBSAMPLING_420 ;return exynos4x12_decoded_subsampling[ctx->subsampling]; +case SJPEG_EXYNOS5433 : +return ctx->subsampling;/* parsed from header */ default :return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY ; }
Signature · 1 line
1.9.1
cover More s5p-jpeg fixes
In reply to Andrzej PietrasiewiczHi All,
The first patch in the series fixes decoding path, the second patch fixes encoding path. Please see appropriate commit messages.
Andrzej Pietrasiewicz (2):
media: s5p-jpeg: don't overwrite result's "size" member
media: s5p-jpeg: set w/h when encoding
drivers/media/platform/s5p-jpeg/jpeg-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 media: s5p-jpeg: don't overwrite result's "size" member
Originally the "size" member was modified in a local variable passed to s5p_jpeg_parse_hdr() but the member was not used by the caller, so it did not matter. After applying the patch
media: s5p-jpeg: Don't use temporary structure in s5p_jpeg_buf_queue
the unnecessary assignment caused the actually used "size" member of the passed structure to assume a meaningless value.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
@@ -1264,7 +1264,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, } result->sof = sof; result->sof_len = sof_len; - result->size = result->components = components; + result->components = components;return true; }
Signature · 1 line
1.9.1
PATCH 2/2 media: s5p-jpeg: set w/h when encoding
In reply to Andrzej Pietrasiewiczq_data w/h must be set when encoding.
--- drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +6 -2
@@ -1634,6 +1634,12 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) FMT_TYPE_OUTPUT :FMT_TYPE_CAPTURE ; q_data->fmt =s5p_jpeg_find_format (ct, pix->pixelformat, f_type); +if (ct->mode ==S5P_JPEG_ENCODE || + (ct->mode ==S5P_JPEG_DECODE && + q_data->fmt->fourcc !=V4L2_PIX_FMT_JPEG )) { + q_data->w = pix->width; + q_data->h = pix->height; + }if (q_data->fmt->fourcc !=V4L2_PIX_FMT_JPEG ) {/* * During encoding Exynos4x12 SoCs access wider memory area
@@ -1641,8 +1647,6 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)* the JPEG_IMAGE_SIZE register. In order to avoid sysmmu * page fault calculate proper buffer size in such a case. */ - q_data->w = pix->width; - q_data->h = pix->height;if (ct->jpeg->variant->hw_ex4_compat && f_type ==FMT_TYPE_OUTPUT && ct->mode ==S5P_JPEG_ENCODE ) q_data->size = exynos4_jpeg_get_output_buffer_size(ct,
Signature · 1 line
1.9.1
cover More s5p-jpeg fixes
In reply to Andrzej PietrasiewiczHi Andrzej,
Thanks for the patches.
Quoted 6 lines · Andrzej Pietrasiewicz
Hi All,
The first patch in the series fixes decoding path, the second patch fixes encoding path. Please see appropriate commit messages.
Quoted 7 lines
Andrzej Pietrasiewicz (2):
media: s5p-jpeg: don't overwrite result's "size" member
media: s5p-jpeg: set w/h when encodingdrivers/media/platform/s5p-jpeg/jpeg-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Signature · 2 lines
Best regards, Jacek Anaszewski
cover s5p-jpeg fixes
In reply to Andrzej PietrasiewiczHi Andrzej,
Thanks for the patch set.
Quoted 31 lines · Andrzej Pietrasiewicz
Hi All,
This series contains a number of fixes to the s5p-jpeg driver.
There are two patches from Tony K Nadackal, which got lost long time ago.
@Thierry:
The patch changing the software reset routine you sent recently was actually a resend of Tony's patch. I investigated the question why this patch is needed. The encoder/decoder should be disabled as soon as possible, in the interrupt service routine; please see the commit message. I am resending Tony's patch again, with updated commit message. Thank you for reminding about the patch in question!There are also three patches from me, please see appropriate commit messages.
Rebased onto Mauro's master.
Andrzej Pietrasiewicz (3):
media: platform: s5p-jpeg: disable encoder/decoder in exynos4-like
hardware after use
media: platform: s5p-jpeg: fix number of components macro
media: platform: s5p-jpeg: directly use parsed subsampling on 5433Tony K Nadackal (2):
media: platform: s5p-jpeg: Fix crash in jpeg isr due to multiple
interrupts.
media: platform: s5p-jpeg: ClearJPEG_CODEC_ONbits in sw reset
function
Quoted 6 lines
drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 +++++++- drivers/media/platform/s5p-jpeg/jpeg-core.h | 1 + drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 9 ++++++++- drivers/media/platform/s5p-jpeg/jpeg-regs.h | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-)
For the whole series:
Signature · 2 lines
Best regards, Jacek Anaszewski