media: imx-jpeg: Disable some unused interrupt
PATCH v2 1/1 media: imx-jpeg: Disable some unused interrupt
The interrupt STMBUF_HALF may be triggered after frame done. It may led to system hang if driver try to access the register after power off.
And interrupt STMBUF_HALF and STMBUF_RTND have no other effect. So disable them and the unused interrupts.
---
v2
- add Fixes tag
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +1 -1
@@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); }void mxc_jpeg_sw_reset (void __iomem *reg)
Signature · 1 line
2.36.1
Hi Ming,
Quoted 19 lines · Ming Qian
The interrupt
STMBUF_HALFmay be triggered after frame done. It may led to system hang if driver try to access the register after power off.
And interruptSTMBUF_HALFandSTMBUF_RTNDhave no other effect. So disable them and the unused interrupts.Fixes 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")Signed-off-by Ming Qian <[email protected]>---
v2
- add Fixes tagdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c void print_wrapper_info(struct device *dev, void __iomem *reg) · line 79
Quoted 5 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +1
-1@@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN ));
There is another way, less aggressive, to go around this, disable all the interrupts once FRMDONE is received (or some other error condition), interrupts will get re-enabled at the next device_run. I checked this works, in mxc_jpeg_dec_irq:buffers_done:
writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));
Either way, I would also replace this:
if (!ctx) {
dev_err(dev,
"Instance released before the end of transaction.\n");
/* soft reset only resets internal state, not registers */
mxc_jpeg_sw_reset(reg);
/* clear all interrupts */
writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_STATUS));
goto job_unlock;
}With something like:BUG_ON(!ctx)
The initial intent of this code was to cope with the same problem, STMBUF_HALF interrupt received after FRMDONE, which could not be cleared, but it was not done right, I can see the hang in some rare cases. We should not run into it anymore, with interrupts disabled, either the way you proposed, or mine.
Regards,
Mirela
Quoted 3 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0}void mxc_jpeg_sw_reset (void __iomem *reg)
Quoted 46 lines
From: Mirela Rabulea (OSS) <[email protected]>
Sent: 2022年6月6日 0:43
To: Ming Qian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interruptHi Ming,
Quoted 21 lines · Ming Qian
The interrupt
STMBUF_HALFmay be triggered after frame done. It may led to system hang if driver try to access the register after power off.
And interruptSTMBUF_HALFandSTMBUF_RTNDhave no other effect. So disable them and the unused interrupts.Fixes 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEGEncoder/Decoder")
Signed-off-by Ming Qian <[email protected]>---
v2
- add Fixes tagdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c void print_wrapper_info(struct device *dev, void · line 80
Quoted 6 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +1
-1@@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN ));There is another way, less aggressive, to go around this, disable all the interrupts once FRMDONE is received (or some other error condition), interrupts will get re-enabled at the next
device_run. I checked this works, inmxc_jpeg_dec_irq:buffers_done:
Quoted 2 lines
writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));
Hi Mirela,
Yes, I think it should work if we disable slot interrupt when frame done. And which solution do you prefer?
Ming
Quoted 26 lines
Either way, I would also replace this:
if (!ctx) { dev_err(dev, "Instance released before the end of transaction.\n"); /* soft reset only resets internal state, not registers */ mxc_jpeg_sw_reset(reg); /* clear all interrupts */ writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_STATUS)); goto job_unlock; }With something like:
BUG_ON(!ctx)The initial intent of this code was to cope with the same problem,
STMBUF_HALFinterrupt received after FRMDONE, which could not be cleared, but it was not done right, I can see the hang in some rare cases. We should not run into it anymore, with interrupts disabled, either the way you proposed, or mine.Regards,
MirelaQuoted 3 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0}void
mxc_jpeg_sw_reset(void __iomem *reg)
Quoted 49 lines · Ming Qian
Quoted 46 lines
From: Mirela Rabulea (OSS) <[email protected]>
Sent: 2022年6月6日 0:43
To: Ming Qian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interruptHi Ming,
Quoted 21 lines · Ming Qian
The interrupt
STMBUF_HALFmay be triggered after frame done. It may led to system hang if driver try to access the register after power off.
And interruptSTMBUF_HALFandSTMBUF_RTNDhave no other effect. So disable them and the unused interrupts.Fixes 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEGEncoder/Decoder")
Signed-off-by Ming Qian <[email protected]>---
v2
- add Fixes tagdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c void print_wrapper_info(struct device *dev, void · line 80
Quoted 6 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +1
-1@@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN ));There is another way, less aggressive, to go around this, disable all the interrupts once FRMDONE is received (or some other error condition), interrupts will get re-enabled at the next
device_run. I checked this works, inmxc_jpeg_dec_irq:buffers_done:Quoted 2 lines
writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));
Quoted 4 lines
Hi Mirela,
Yes, I think it should work if we disable slot interrupt when frame done. And which solution do you prefer?
Hi Ming, I don't have a strong preference, but just in case we decide to later use some of these interrupts, I would suggest to go with the disabling after FRMDONE.
Please do not forget to clean the other code related to "Instance released before the end of transaction".
Thanks,
Mirela
Quoted 29 lines
Ming
Quoted 26 lines
Either way, I would also replace this:
if (!ctx) { dev_err(dev, "Instance released before the end of transaction.\n"); /* soft reset only resets internal state, not registers */ mxc_jpeg_sw_reset(reg); /* clear all interrupts */ writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_STATUS)); goto job_unlock; }With something like:
BUG_ON(!ctx)The initial intent of this code was to cope with the same problem,
STMBUF_HALFinterrupt received after FRMDONE, which could not be cleared, but it was not done right, I can see the hang in some rare cases. We should not run into it anymore, with interrupts disabled, either the way you proposed, or mine.Regards,
MirelaQuoted 3 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0}void
mxc_jpeg_sw_reset(void __iomem *reg)
Quoted 75 lines
From: Mirela Rabulea (OSS) <[email protected]>
Sent: 2022年6月6日 17:41
To: Ming Qian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interruptQuoted 53 lines · Ming Qian
Quoted 50 lines
From: Mirela Rabulea (OSS) <[email protected]>
Sent: 2022年6月6日 0:43
To: Ming Qian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interruptHi Ming,
Quoted 22 lines · Ming Qian
The interrupt
STMBUF_HALFmay be triggered after frame done. It may led to system hang if driver try to access the register after power off.
And interruptSTMBUF_HALFandSTMBUF_RTNDhave no other effect. So disable them and the unused interrupts.Fixes 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8JPEG
Encoder/Decoder")Signed-off-by Ming Qian <[email protected]>---
v2
- add Fixes tagdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c void print_wrapper_info(struct device *dev, void · line 80
Quoted 6 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +1
-1@@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN ));There is another way, less aggressive, to go around this, disable all the interrupts once FRMDONE is received (or some other error condition), interrupts will get re-enabled at the next
device_run. I checked this works, inmxc_jpeg_dec_irq:buffers_done:Quoted 2 lines
writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));Quoted 4 lines
Hi Mirela,
Yes, I think it should work if we disable slot interrupt when frame done. And which solution do you prefer?
Hi Ming, I don't have a strong preference, but just in case we decide to later use some of these interrupts, I would suggest to go with the disabling after FRMDONE.
Quoted 6 lines
Please do not forget to clean the other code related to "Instance released before the end of transaction".
Thanks,
Mirela
OK, I'll make another patch that disable slot interrupt when frame done, and clean the code.
Quoted 29 lines
Quoted 29 lines
Ming
Quoted 26 lines
Either way, I would also replace this:
if (!ctx) { dev_err(dev, "Instance released before the end of transaction.\n"); /* soft reset only resets internal state, not registers */ mxc_jpeg_sw_reset(reg); /* clear all interrupts */ writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot, SLOT_STATUS)); goto job_unlock; }With something like:
BUG_ON(!ctx)The initial intent of this code was to cope with the same problem,
STMBUF_HALFinterrupt received after FRMDONE, which could not be cleared, but it was not done right, I can see the hang in some rare cases. We should not run into it anymore, with interrupts disabled, either the way you proposed, or mine.Regards,
MirelaQuoted 3 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0}void
mxc_jpeg_sw_reset(void __iomem *reg)
This patch can be superseded now.
It was replaced by another patch https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
Quoted 126 lines
From: Ming Qian
Sent: 2022年6月7日 9:49
To: Mirela Rabulea (OSS) <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v2] media: imx-jpeg: Disable some unused interruptQuoted 76 lines
From: Mirela Rabulea (OSS) <[email protected]>
Sent: 2022年6月6日 17:41
To: Ming Qian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interruptQuoted 53 lines · Ming Qian
Quoted 50 lines
From: Mirela Rabulea (OSS) <[email protected]>
Sent: 2022年6月6日 0:43
To: Ming Qian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] media: imx-jpeg: Disable some unused interruptHi Ming,
Quoted 22 lines · Ming Qian
The interrupt
STMBUF_HALFmay be triggered after frame done. It may led to system hang if driver try to access the register after power off.
And interruptSTMBUF_HALFandSTMBUF_RTNDhave no other effect. So disable them and the unused interrupts.Fixes 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8JPEG
Encoder/Decoder")Signed-off-by Ming Qian <[email protected]>---
v2
- add Fixes tagdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c void print_wrapper_info(struct device *dev, void · line 80
Quoted 6 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +1
-1@@ -76,7 +76,7 @@ void print_wrapper_info(struct device *dev, void __iomem *reg)void mxc_jpeg_enable_irq (void __iomem *reg,int slot) { -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +writel (0xF0C , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN ));There is another way, less aggressive, to go around this, disable all the interrupts once FRMDONE is received (or some other error condition), interrupts will get re-enabled at the next
device_run. I checked this works, inmxc_jpeg_dec_irq:buffers_done:Quoted 2 lines
writel(0x0, reg + MXC_SLOT_OFFSET(slot, SLOT_IRQ_EN));Quoted 4 lines
Hi Mirela,
Yes, I think it should work if we disable slot interrupt when frame done. And which solution do you prefer?
Hi Ming, I don't have a strong preference, but just in case we decide to later use some of these interrupts, I would suggest to go with the disabling after FRMDONE.
Quoted 6 lines
Please do not forget to clean the other code related to "Instance released before the end of transaction".
Thanks,
MirelaOK, I'll make another patch that disable slot interrupt when frame done, and clean the code.
Quoted 11 lines
Quoted 11 lines
Ming
Quoted 8 lines
Either way, I would also replace this:
if (!ctx) { dev_err(dev, "Instance released before the end of transaction.\n"); /* soft reset only resets internal state, not registers */ mxc_jpeg_sw_reset(reg); /* clear all interrupts */ writel(0xFFFFFFFF, reg + MXC_SLOT_OFFSET(slot,
SLOT_STATUS));Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
goto job_unlock; }With something like:
BUG_ON(!ctx)The initial intent of this code was to cope with the same problem,
STMBUF_HALFinterrupt received after FRMDONE, which could not be cleared, but it was not done right, I can see the hang in some rare cases. We should not run into it anymore, with interrupts disabled, either the way you proposed, or mine.Regards,
MirelaQuoted 3 lines
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +0
-0}void
mxc_jpeg_sw_reset(void __iomem *reg)