Skip to contentSkip to conversation

Improve stability of Aspeed video engine driver - 3rd phase

PATCH In review Jae Hyun Yoo 2 participants 5 messages May 31, 2019 – Jun 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Improve stability of Aspeed video engine driver - 3rd phase

This patch series adds bug fixes and improvements into the Aspeed video engine driver.

Changes since v1:
- Fixed a side effect caused by the first patch.
- Removed an incorrect patch from this series.
- Added more details into the silicon bug workaround fix comment.

Jae Hyun Yoo (3):
media: aspeed: remove source buffer allocation before mode detection
media: aspeed: use different delays for triggering VE H/W reset
media: aspeed: add a workaround to fix a silicon bug

 drivers/media/platform/aspeed-video.c | 74 +++++++++++----------------
 1 file changed, 31 insertions(+), 43 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v2 1/3 media: aspeed: remove source buffer allocation before mode detection

Mode detection doesn't require source buffer allocation so this commit removes that.

---
v1 -> v2:
- Corrected re-allocation logic of source buffers.

 drivers/media/platform/aspeed-video.c | 37 ++++-----------------------
 1 file changed, 5 insertions(+), 32 deletions(-)
drivers/media/platform/aspeed-video.c +5 -32
index 1bb863b32836..fed51fd22ce2 100644
@@ -733,27 +733,6 @@ static void aspeed_video_get_resolution(struct aspeed_video *video)
 	det->height = MIN_HEIGHT;
 	video->v4l2_input_status = V4L2_IN_ST_NO_SIGNAL;
 
-	/*
-	 * Since we need max buffer size for detection, free the second source
-	 * buffer first.
-	 */
-	if (video->srcs[1].size)
-		aspeed_video_free_buf(video, &video->srcs[1]);
-
-	if (video->srcs[0].size < VE_MAX_SRC_BUFFER_SIZE) {
-		if (video->srcs[0].size)
-			aspeed_video_free_buf(video, &video->srcs[0]);
-
-		if (!aspeed_video_alloc_buf(video, &video->srcs[0],
-					    VE_MAX_SRC_BUFFER_SIZE)) {
-			dev_err(video->dev,
-				"Failed to allocate source buffers\n");
-			return;
-		}
-	}
-
-	aspeed_video_write(video, VE_SRC0_ADDR, video->srcs[0].dma);
-
 	do {
 		if (tries) {
 			set_current_state(TASK_INTERRUPTIBLE);
@@ -873,20 +852,14 @@ static void aspeed_video_set_resolution(struct aspeed_video *video)
 
 	size *= 4;
 
-	if (size == video->srcs[0].size / 2) {
-		aspeed_video_write(video, VE_SRC1_ADDR,
-				   video->srcs[0].dma + size);
-	} else if (size == video->srcs[0].size) {
-		if (!aspeed_video_alloc_buf(video, &video->srcs[1], size))
-			goto err_mem;
-
-		aspeed_video_write(video, VE_SRC1_ADDR, video->srcs[1].dma);
-	} else {
-		aspeed_video_free_buf(video, &video->srcs[0]);
+	if (size != video->srcs[0].size) {
+		if (video->srcs[0].size)
+			aspeed_video_free_buf(video, &video->srcs[0]);
+		if (video->srcs[1].size)
+			aspeed_video_free_buf(video, &video->srcs[1]);
 
 		if (!aspeed_video_alloc_buf(video, &video->srcs[0], size))
 			goto err_mem;
-
 		if (!aspeed_video_alloc_buf(video, &video->srcs[1], size))
 			goto err_mem;
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH v2 2/3 media: aspeed: use different delays for triggering VE H/W reset

In reply to Jae Hyun Yoo

In case of watchdog timeout detected while doing mode detection, it's better triggering video engine hardware reset immediately so this commit fixes code for the case. Other than the case, it will trigger video engine hardware reset after RESOLUTION_CHANGE_DELAY.

---
v1 -> v2:
None.

 drivers/media/platform/aspeed-video.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/platform/aspeed-video.c +5 -4
index fed51fd22ce2..67d6380d4ef3 100644
@@ -522,7 +522,7 @@ static void aspeed_video_bufs_done(struct aspeed_video *video,
 	spin_unlock_irqrestore(&video->lock, flags);
 }
 
-static void aspeed_video_irq_res_change(struct aspeed_video *video)
+static void aspeed_video_irq_res_change(struct aspeed_video *video, ulong delay)
 {
 	spin_lock(&video->lock);
 	dev_dbg(video->dev, "Resolution changed; resetting\n");
@@ -534,7 +534,7 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video)
 	spin_unlock(&video->lock);
 	aspeed_video_bufs_done(video, VB2_BUF_STATE_ERROR);
 
-	schedule_delayed_work(&video->res_work, RESOLUTION_CHANGE_DELAY);
+	schedule_delayed_work(&video->res_work, delay);
 }
 
 static irqreturn_t aspeed_video_irq(int irq, void *arg)
@@ -547,7 +547,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)
 	 * re-initialize
 	 */
 	if (sts & VE_INTERRUPT_MODE_DETECT_WD) {
-		aspeed_video_irq_res_change(video);
+		aspeed_video_irq_res_change(video, 0);
 		return IRQ_HANDLED;
 	}
 
@@ -565,7 +565,8 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)
 			 * Signal acquired while NOT doing resolution
 			 * detection; reset the engine and re-initialize
 			 */
-			aspeed_video_irq_res_change(video);
+			aspeed_video_irq_res_change(video,
+						    RESOLUTION_CHANGE_DELAY);
 			return IRQ_HANDLED;
 		}
 	}
Signature · 1 line
2.21.0
#3 lore raw

PATCH v2 3/3 media: aspeed: add a workaround to fix a silicon bug

In reply to Jae Hyun Yoo

AST2500 silicon revision A1 and A2 have a silicon bug which causes extremly long capturing time on specific resolutions (1680 width). To fix the bug, this commit adjusts the capturing window register setting to 1728 if detected width is 1680. The compression window register setting will be kept as the original width so output result will be the same.

---
v1 -> v2:
- Added more detail comments why the value 1728 is picked.

 drivers/media/platform/aspeed-video.c | 28 ++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/media/platform/aspeed-video.c +21 -7
index 67d6380d4ef3..f58f44eab588 100644
@@ -826,8 +826,29 @@ static void aspeed_video_set_resolution(struct aspeed_video *video)
 	struct v4l2_bt_timings *act = &video->active_timings;
 	unsigned int size = act->width * act->height;
 
+	/* Set capture/compression frame sizes */
 	aspeed_video_calc_compressed_size(video, size);
 
+	if (video->active_timings.width == 1680) {
+		/*
+		 * This is a workaround to fix a silicon bug on A1 and A2
+		 * revisions. Since it doesn't break capturing operation of
+		 * other revisions, use it for all revisions without checking
+		 * the revision ID. It picked 1728 which is a very next
+		 * 64-pixels aligned value to 1680 to minimize memory bandwidth
+		 * and to get better access speed from video engine.
+		 */
+		aspeed_video_write(video, VE_CAP_WINDOW,
+				   1728 << 16 | act->height);
+		size += (1728 - 1680) * video->active_timings.height;
+	} else {
+		aspeed_video_write(video, VE_CAP_WINDOW,
+				   act->width << 16 | act->height);
+	}
+	aspeed_video_write(video, VE_COMP_WINDOW,
+			   act->width << 16 | act->height);
+	aspeed_video_write(video, VE_SRC_SCANLINE_OFFSET, act->width * 4);
+
 	/* Don't use direct mode below 1024 x 768 (irqs don't fire) */
 	if (size < DIRECT_FETCH_THRESHOLD) {
 		aspeed_video_write(video, VE_TGS_0,
@@ -844,13 +865,6 @@ static void aspeed_video_set_resolution(struct aspeed_video *video)
 		aspeed_video_update(video, VE_CTRL, 0, VE_CTRL_DIRECT_FETCH);
 	}
 
-	/* Set capture/compression frame sizes */
-	aspeed_video_write(video, VE_CAP_WINDOW,
-			   act->width << 16 | act->height);
-	aspeed_video_write(video, VE_COMP_WINDOW,
-			   act->width << 16 | act->height);
-	aspeed_video_write(video, VE_SRC_SCANLINE_OFFSET, act->width * 4);
-
 	size *= 4;
 
 	if (size != video->srcs[0].size) {
Signature · 1 line
2.21.0
maintainer
#4 lore raw
In reply to Jae Hyun Yoo

Hi Jae,

Quoted 3 lines · Jae Hyun Yoo

Jae Hyun Yoo (3):
media: aspeed: remove source buffer allocation before mode detection
media: aspeed: use different delays for triggering VE H/W reset

I've applied these two.

Quoted 1 line

media: aspeed: add a workaround to fix a silicon bug

Can we get Eddie to ack this one? The justification looks reasonable to me.

Cheers,

Joel