Improve stability of Aspeed video engine driver - 2nd phase
Subsystems (2)
v2 cover Improve stability of Aspeed video engine driver - 2nd phase
This patch series improves stability of Aspeed video engine driver by fixing interrupt handling logic and by reducing noisy log printings in the driver.
Jae Hyun Yoo (4):
media: aspeed: remove IRQF_SHARED flag
media: aspeed: reduce noisy log printing outs
media: aspeed: remove checking of VE_INTERRUPT_CAPTURE_COMPLETE
media: aspeed: refine interrupt handling logic
drivers/media/platform/aspeed-video.c | 32 ++++++++++++--------------- 1 file changed, 14 insertions(+), 18 deletions(-)
Signature · 1 line
2.21.0
PATCH v2 1/4 media: aspeed: remove IRQF_SHARED flag
Video Engine has a dedicated interrupt line so this driver doesn't need to use IRQF_SHARED flag so remove it. Also, it'd be good for following what Thomas recommended in the IRQF_ONESHOT support patch like below:
"Note that for now IRQF_ONESHOT cannot be used with IRQF_SHARED to avoid complex accounting mechanisms."
---
Changes since v1:
None
drivers/media/platform/aspeed-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/aspeed-video.c +1 -2
@@ -1616,8 +1616,7 @@ static int aspeed_video_init(struct aspeed_video *video) } rc =devm_request_threaded_irq (dev, irq,NULL , aspeed_video_irq, -IRQF_ONESHOT |IRQF_SHARED ,DEVICE_NAME , - video); +IRQF_ONESHOT ,DEVICE_NAME , video);if (rc <0 ) {dev_err (dev,"Unable to request IRQ %d\n" , irq);return rc;
Signature · 1 line
2.21.0
PATCH v2 2/4 media: aspeed: reduce noisy log printing outs
In reply to Jae Hyun YooCurrently, this driver prints out too much log messages when a mode change happens, video turned off by screen saver and etc. Actually, all cases are reported to user space properly. Also, these are not critical errors but recoverable things, so this commit changes the log level of some noisy printing outs.
---
Changes since v1:
None
drivers/media/platform/aspeed-video.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/platform/aspeed-video.c +5 -5
@@ -441,7 +441,7 @@ static int aspeed_video_start_frame(struct aspeed_video *video)if (!(seq_ctrl &VE_SEQ_CTRL_COMP_BUSY ) || !(seq_ctrl &VE_SEQ_CTRL_CAP_BUSY )) { -dev_err (video->dev,"Engine busy; don't start frame\n" ); +dev_dbg (video->dev,"Engine busy; don't start frame\n" );return -EBUSY ; }
@@ -771,7 +771,7 @@ static void aspeed_video_get_resolution(struct aspeed_video *video)res_check (video), MODE_DETECT_TIMEOUT);if (!rc) { -dev_err (video->dev,"Timed out; first mode detect\n" ); +dev_dbg (video->dev,"Timed out; first mode detect\n" );clear_bit (VIDEO_RES_DETECT , &video->flags);return ; }
@@ -789,7 +789,7 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) MODE_DETECT_TIMEOUT);clear_bit (VIDEO_RES_DETECT , &video->flags);if (!rc) { -dev_err (video->dev,"Timed out; second mode detect\n" ); +dev_dbg (video->dev,"Timed out; second mode detect\n" );return ; }
@@ -823,7 +823,7 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) }while (invalid_resolution && (tries++ <INVALID_RESOLUTION_RETRIES ));if (invalid_resolution) { -dev_err (video->dev,"Invalid resolution detected\n" ); +dev_dbg (video->dev,"Invalid resolution detected\n" );return ; }
@@ -1471,7 +1471,7 @@ static void aspeed_video_stop_streaming(struct vb2_queue *q) !test_bit (VIDEO_FRAME_INPRG , &video->flags), STOP_TIMEOUT);if (!rc) { -dev_err (video->dev,"Timed out when stopping streaming\n" ); +dev_dbg (video->dev,"Timed out when stopping streaming\n" );/* * Need to force stop any DMA and try and get HW into a good
Signature · 1 line
2.21.0
PATCH v2 3/4 media: aspeed: remove checking of VE_INTERRUPT_CAPTURE_COMPLETE
In reply to Jae Hyun YooVE_INTERRUPT_CAPTURE_COMPLETE and VE_INTERRUPT_COMP_COMPLETE are not set at the same time but the current interrupt handling mechanism of this driver doesn't clear the interrupt flag until both two are set, and this behavior causes unnecessary interrupt handler calls. In fact, this driver provides JPEG format only so taking care of the VE_INTERRUPT_COMP_COMPLETE is enough for getting compressed image frame so this commit gets rid of the VE_INTERRUPT_CAPTURE_COMPLETE checking logic to simplify the logic. Handling of VE_INTERRUPT_CAPTURE_COMPLETE could be added back later when it's actually needed.
---
Changes since v1:
None
drivers/media/platform/aspeed-video.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/media/platform/aspeed-video.c +4 -8
@@ -463,8 +463,7 @@ static int aspeed_video_start_frame(struct aspeed_video *video)aspeed_video_write (video,VE_COMP_ADDR , addr);aspeed_video_update (video,VE_INTERRUPT_CTRL ,0 , -VE_INTERRUPT_COMP_COMPLETE | -VE_INTERRUPT_CAPTURE_COMPLETE ); +VE_INTERRUPT_COMP_COMPLETE );aspeed_video_update (video,VE_SEQ_CTRL ,0 ,VE_SEQ_CTRL_TRIG_CAPTURE |VE_SEQ_CTRL_TRIG_COMP );
@@ -570,8 +569,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) } } -if ((sts &VE_INTERRUPT_COMP_COMPLETE ) && - (sts &VE_INTERRUPT_CAPTURE_COMPLETE )) { +if (sts &VE_INTERRUPT_COMP_COMPLETE ) {struct aspeed_video_buffer *buf;u32 frame_size =aspeed_video_read (video,VE_OFFSET_COMP_STREAM );
@@ -600,11 +598,9 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)VE_SEQ_CTRL_FORCE_IDLE | VE_SEQ_CTRL_TRIG_COMP, 0);aspeed_video_update (video,VE_INTERRUPT_CTRL , -VE_INTERRUPT_COMP_COMPLETE | -VE_INTERRUPT_CAPTURE_COMPLETE ,0 ); +VE_INTERRUPT_COMP_COMPLETE ,0 );aspeed_video_write (video,VE_INTERRUPT_STATUS , -VE_INTERRUPT_COMP_COMPLETE | -VE_INTERRUPT_CAPTURE_COMPLETE ); +VE_INTERRUPT_COMP_COMPLETE );if (test_bit (VIDEO_STREAMING , &video->flags) && buf)aspeed_video_start_frame (video);
Signature · 1 line
2.21.0
Re: [PATCH v2 dev-5.0 3/4] media: aspeed: remove checking of VE_INTERRUPT_CAPTURE_COMPLETE
Quoted 11 lines · Jae Hyun Yoo
VE_INTERRUPT_CAPTURE_COMPLETEandVE_INTERRUPT_COMP_COMPLETEare not set at the same time but the current interrupt handling mechanism of this driver doesn't clear the interrupt flag until both two are set, and this behavior causes unnecessary interrupt handler calls. In fact, this driver provides JPEG format only so taking care of theVE_INTERRUPT_COMP_COMPLETEis enough for getting compressed image frame so this commit gets rid of theVE_INTERRUPT_CAPTURE_COMPLETEchecking logic to simplify the logic. Handling ofVE_INTERRUPT_CAPTURE_COMPLETEcould be added back later when it's actually needed.
Quoted 2 lines
Signed-off-by Jae Hyun Yoo <[email protected]>Reviewed-by Eddie James <[email protected]>
Quoted 51 lines
---
Changes since v1:
Nonedrivers/media/platform/aspeed-video.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)drivers/media/platform/aspeed-video.c +1
-2@@ -463,8 +463,7 @@ static int aspeed_video_start_frame(struct aspeed_video *video)aspeed_video_write (video ,VE_COMP_ADDR ,addr );aspeed_video_update (video,VE_INTERRUPT_CTRL ,0 , -VE_INTERRUPT_COMP_COMPLETE | -VE_INTERRUPT_CAPTURE_COMPLETE ); +VE_INTERRUPT_COMP_COMPLETE ); aspeed_video_update(video, VE_SEQ_CTRL, 0,drivers/media/platform/aspeed-video.c +3
-6VE_SEQ_CTRL_TRIG_CAPTURE | VE_SEQ_CTRL_TRIG_COMP);@@ -570,8 +569,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) } } -if ((sts &VE_INTERRUPT_COMP_COMPLETE ) && - (sts &VE_INTERRUPT_CAPTURE_COMPLETE )) { +if (sts &VE_INTERRUPT_COMP_COMPLETE ) {struct aspeed_video_buffer *buf;u32 frame_size =aspeed_video_read (video,VE_OFFSET_COMP_STREAM );@@ -600,11 +598,9 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)VE_SEQ_CTRL_FORCE_IDLE | VE_SEQ_CTRL_TRIG_COMP, 0);aspeed_video_update (video,VE_INTERRUPT_CTRL , -VE_INTERRUPT_COMP_COMPLETE | -VE_INTERRUPT_CAPTURE_COMPLETE ,0 ); +VE_INTERRUPT_COMP_COMPLETE ,0 );aspeed_video_write (video,VE_INTERRUPT_STATUS , -VE_INTERRUPT_COMP_COMPLETE | -VE_INTERRUPT_CAPTURE_COMPLETE ); +VE_INTERRUPT_COMP_COMPLETE );if (test_bit (VIDEO_STREAMING , &video->flags) && buf)aspeed_video_start_frame (video);Signature · 1 line
2.21.0
PATCH v2 4/4 media: aspeed: refine interrupt handling logic
In reply to Jae Hyun YooThere are cases that interrupt bits are cleared by a 500ms delayed work which causes unnecessary irq calls. Also, the current interrupt handler returns IRQ_HANDLED always but it should return IRQ_NONE if there is any unhandled interrupt. So this commit refines the interrupt handling logic to fix these issues.
---
Changes since v1:
* Moved bits clearing point to aspeed_video_off().
* Made irq handler return IRQ_NONE when there is any remaining bit.
drivers/media/platform/aspeed-video.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/aspeed-video.c +4 -3
@@ -488,6 +488,7 @@ static void aspeed_video_off(struct aspeed_video *video)/* Disable interrupts */ aspeed_video_write (video,VE_INTERRUPT_CTRL ,0 ); +aspeed_video_write (video,VE_INTERRUPT_STATUS ,0xffffffff );/* Turn off the relevant clocks */ clk_disable (video->vclk);
@@ -556,7 +557,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) VE_INTERRUPT_MODE_DETECT, 0);aspeed_video_write (video,VE_INTERRUPT_STATUS ,VE_INTERRUPT_MODE_DETECT ); - + sts &= ~VE_INTERRUPT_MODE_DETECT ;set_bit (VIDEO_MODE_DETECT_DONE , &video->flags);wake_up_interruptible_all (&video->wait); }else {
@@ -601,12 +602,12 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) VE_INTERRUPT_COMP_COMPLETE, 0);aspeed_video_write (video,VE_INTERRUPT_STATUS ,VE_INTERRUPT_COMP_COMPLETE ); - + sts &= ~VE_INTERRUPT_COMP_COMPLETE ;if (test_bit (VIDEO_STREAMING , &video->flags) && buf)aspeed_video_start_frame (video); } -return IRQ_HANDLED ; +return sts ?IRQ_NONE :IRQ_HANDLED ; }static void aspeed_video_check_and_set_polarity (struct aspeed_video *video)
Signature · 1 line
2.21.0
Re: [PATCH v2 dev-5.0 4/4] media: aspeed: refine interrupt handling logic
Quoted 7 lines · Jae Hyun Yoo
There are cases that interrupt bits are cleared by a 500ms delayed work which causes unnecessary irq calls. Also, the current interrupt handler returns
IRQ_HANDLEDalways but it should returnIRQ_NONEif there is any unhandled interrupt. So this commit refines the interrupt handling logic to fix these issues.Signed-off-by Jae Hyun Yoo <[email protected]>
Quoted 50 lines
---
Changes since v1:
* Moved bits clearing point toaspeed_video_off().
* Made irq handler returnIRQ_NONEwhen there is any remaining bit.drivers/media/platform/aspeed-video.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/media/platform/aspeed-video.c +1
-0@@ -488,6 +488,7 @@ static void aspeed_video_off(struct aspeed_video *video)/* Disable interrupts */ aspeed_video_write (video,VE_INTERRUPT_CTRL ,0 ); +aspeed_video_write (video,VE_INTERRUPT_STATUS ,0xffffffff );/* Turn off the relevant clocks */ drivers/media/platform/aspeed-video.c +3
-3clk_disable (video->vclk);@@ -556,7 +557,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) VE_INTERRUPT_MODE_DETECT, 0);aspeed_video_write (video,VE_INTERRUPT_STATUS ,VE_INTERRUPT_MODE_DETECT ); - + sts &= ~VE_INTERRUPT_MODE_DETECT ;set_bit (VIDEO_MODE_DETECT_DONE , &video->flags);wake_up_interruptible_all (&video->wait); }else {@@ -601,12 +602,12 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) VE_INTERRUPT_COMP_COMPLETE, 0);aspeed_video_write (video,VE_INTERRUPT_STATUS ,VE_INTERRUPT_COMP_COMPLETE ); - + sts &= ~VE_INTERRUPT_COMP_COMPLETE ;if (test_bit (VIDEO_STREAMING , &video->flags) && buf)aspeed_video_start_frame (video); } -return IRQ_HANDLED ; +return sts ?IRQ_NONE :IRQ_HANDLED ; }static void aspeed_video_check_and_set_polarity (struct aspeed_video *video)Signature · 1 line
2.21.0