media: ti-vpe: cal: fix disable_irqs to only the intended target
Subsystems (2)
PATCH 1/1 media: ti-vpe: cal: fix disable_irqs to only the intended target
disable_irqs() was mistakenly disabling all interrupts when called. This cause all port stream to stop even if only stopping one of them.
--- drivers/media/platform/ti-vpe/cal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/media/platform/ti-vpe/cal.c +8 -8
@@ -722,16 +722,16 @@ static void enable_irqs(struct cal_ctx *ctx)static void disable_irqs (struct cal_ctx *ctx) { +u32 val; +/* Disable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (2 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); + val =0 ; +set_field (&val,CAL_HL_IRQ_CLEAR ,CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (2 ), val);/* Disable IRQ_WDMA_START 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (3 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); + val =0 ; +set_field (&val,CAL_HL_IRQ_CLEAR ,CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (3 ), val);/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0 ); }
Signature · 1 line
2.17.1
Quoted 29 lines · Benoit Parrot
disable_irqs()was mistakenly disabling all interrupts when called. This cause all port stream to stop even if only stopping one of them.Cc stable <[email protected]>Signed-off-by Benoit Parrot <[email protected]>--- drivers/media/platform/ti-vpe/cal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/media/platform/ti-vpe/cal.c +5
-4@@ -722,16 +722,16 @@ static void enable_irqs(struct cal_ctx *ctx)static void disable_irqs (struct cal_ctx *ctx) { +u32 val; +/* Disable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (2 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); + val =0 ; +set_field (&val,CAL_HL_IRQ_CLEAR ,CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (2 ), val);/* Disable IRQ_WDMA_START 0/1 */
drivers/media/platform/ti-vpe/cal.c static void enable_irqs(struct cal_ctx *ctx) · line 737
Quoted 10 lines
drivers/media/platform/ti-vpe/cal.c +3
-4-reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (3 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); + val =0 ; +set_field (&val,CAL_HL_IRQ_CLEAR ,CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (3 ), val);/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0 ); }
I think the above works. But the enable_irqs is broken too, even if it doesn't cause any issues. Both IRQ_SET and IRQ_CLR are not supposed to be "modified" by a read-mod-write operation, but just written to.
The macros used also make the code very difficult to read. Something like this fixes both irq enable and disable, and makes it readable:
drivers/media/platform/ti-vpe/cal.c +4 -16
@@ -707,15 +707,9 @@ static void cal_quickdump_regs(struct cal_dev *dev)static void enable_irqs (struct cal_ctx *ctx) {/* Enable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_SET (2 ), -CAL_HL_IRQ_ENABLE , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_SET (2 ),1 << (ctx->csi2_port -1 ));/* Enable IRQ_WDMA_START 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_SET (3 ), -CAL_HL_IRQ_ENABLE , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_SET (3 ),1 << (ctx->csi2_port -1 ));/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0xFF000000 ); }
@@ -723,15 +717,9 @@ static void enable_irqs(struct cal_ctx *ctx)static void disable_irqs (struct cal_ctx *ctx) {/* Disable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (2 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (2 ),1 << (ctx->csi2_port -1 ));/* Disable IRQ_WDMA_START 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (3 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (3 ),1 << (ctx->csi2_port -1 ));/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0 ); }
Tomi
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Tomi,
Thanks for the review.
Tomi Valkeinen <[email protected]> wrote on Wed [2020-Mar-04 10:49:55 +0200]:
Quoted 34 lines · Benoit Parrot
Quoted 33 lines
disable_irqs()was mistakenly disabling all interrupts when called. This cause all port stream to stop even if only stopping one of them.Cc stable <[email protected]>Signed-off-by Benoit Parrot <[email protected]>--- drivers/media/platform/ti-vpe/cal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/media/platform/ti-vpe/cal.c +6
-8@@ -722,16 +722,16 @@ static void enable_irqs(struct cal_ctx *ctx)static void disable_irqs (struct cal_ctx *ctx) { +u32 val; +/* Disable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (2 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); + val =0 ; +set_field (&val,CAL_HL_IRQ_CLEAR ,CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (2 ), val);/* Disable IRQ_WDMA_START 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (3 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); + val =0 ;
Quoted 9 lines
drivers/media/platform/ti-vpe/cal.c static void enable_irqs(struct cal_ctx *ctx) · line 725
Quoted 6 lines
drivers/media/platform/ti-vpe/cal.c +2
-0+set_field (&val,CAL_HL_IRQ_CLEAR ,CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (3 ), val);/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0 ); }I think the above works. But the
enable_irqsis broken too, even if it doesn't cause any issues. BothIRQ_SETandIRQ_CLRare not supposed to be "modified" by a read-mod-write operation, but just written to.
Well maybe not consistent now, that disable_irqs has been modified but not broken per se.
Quoted 1 line
The macros used also make the code very difficult to read. Something like this fixes both irq enable and disable, and makes it readable:
Ah but the mask macro are all consistent with each other, whether that create one too many level of abstraction is a different subject. This setup was oroginally requested by the maintainer. So I'll "fix" enable_irqs also but I'll keep the macro as is.
Benoit
Quoted 47 lines
drivers/media/platform/ti-vpe/cal.c +4
-16@@ -707,15 +707,9 @@ static void cal_quickdump_regs(struct cal_dev *dev)static void enable_irqs (struct cal_ctx *ctx) {/* Enable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_SET (2 ), -CAL_HL_IRQ_ENABLE , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_SET (2 ),1 << (ctx->csi2_port -1 ));/* Enable IRQ_WDMA_START 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_SET (3 ), -CAL_HL_IRQ_ENABLE , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_SET (3 ),1 << (ctx->csi2_port -1 ));/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0xFF000000 ); }@@ -723,15 +717,9 @@ static void enable_irqs(struct cal_ctx *ctx)static void disable_irqs (struct cal_ctx *ctx) {/* Disable IRQ_WDMA_END 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (2 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (2 ),1 << (ctx->csi2_port -1 ));/* Disable IRQ_WDMA_START 0/1 */ -reg_write_field (ctx->dev, -CAL_HL_IRQENABLE_CLR (3 ), -CAL_HL_IRQ_CLEAR , -CAL_HL_IRQ_MASK (ctx->csi2_port)); +reg_write (ctx->dev,CAL_HL_IRQENABLE_CLR (3 ),1 << (ctx->csi2_port -1 ));/* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */ reg_write (ctx->dev,CAL_CSI2_VC_IRQENABLE (1 ),0 ); }Tomi
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Sasha Levin
maintainerHi
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.5.7, v5.4.23, v4.19.107, v4.14.172, v4.9.215, v4.4.215.
v5.5.7: Build OK!
v5.4.23: Build OK!
v4.19.107: Build OK!
v4.14.172: Build OK!
v4.9.215: Build OK!
v4.4.215: Failed to apply! Possible dependencies:
343e89a792a5 ("[media] media: ti-vpe: Add CAL v4l2 camera capture driver")NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
Signature · 2 lines
Thanks Sasha