All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase
@ 2019-05-31 21:47 Jae Hyun Yoo
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 1/3] media: aspeed: remove source buffer allocation before mode detection Jae Hyun Yoo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-05-31 21:47 UTC (permalink / raw)
  To: Eddie James, Joel Stanley, Andrew Jeffery; +Cc: openbmc, Jae Hyun Yoo

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(-)

-- 
2.21.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 dev-5.1 1/3] media: aspeed: remove source buffer allocation before mode detection
  2019-05-31 21:47 [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Jae Hyun Yoo
@ 2019-05-31 21:47 ` Jae Hyun Yoo
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 2/3] media: aspeed: use different delays for triggering VE H/W reset Jae Hyun Yoo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-05-31 21:47 UTC (permalink / raw)
  To: Eddie James, Joel Stanley, Andrew Jeffery; +Cc: openbmc, Jae Hyun Yoo

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

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Tested-by: Eddie James <eajames@linux.ibm.com>
---
v1 -> v2:
- Corrected re-allocation logic of source buffers.

 drivers/media/platform/aspeed-video.c | 37 ++++-----------------------
 1 file changed, 5 insertions(+), 32 deletions(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index 1bb863b32836..fed51fd22ce2 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -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;
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 dev-5.1 2/3] media: aspeed: use different delays for triggering VE H/W reset
  2019-05-31 21:47 [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Jae Hyun Yoo
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 1/3] media: aspeed: remove source buffer allocation before mode detection Jae Hyun Yoo
@ 2019-05-31 21:47 ` Jae Hyun Yoo
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 3/3] media: aspeed: add a workaround to fix a silicon bug Jae Hyun Yoo
  2019-06-04  6:25 ` [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Joel Stanley
  3 siblings, 0 replies; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-05-31 21:47 UTC (permalink / raw)
  To: Eddie James, Joel Stanley, Andrew Jeffery; +Cc: openbmc, 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.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Tested-by: Eddie James <eajames@linux.ibm.com>
---
v1 -> v2:
 None.

 drivers/media/platform/aspeed-video.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index fed51fd22ce2..67d6380d4ef3 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -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;
 		}
 	}
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 dev-5.1 3/3] media: aspeed: add a workaround to fix a silicon bug
  2019-05-31 21:47 [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Jae Hyun Yoo
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 1/3] media: aspeed: remove source buffer allocation before mode detection Jae Hyun Yoo
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 2/3] media: aspeed: use different delays for triggering VE H/W reset Jae Hyun Yoo
@ 2019-05-31 21:47 ` Jae Hyun Yoo
  2019-06-04  6:25 ` [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Joel Stanley
  3 siblings, 0 replies; 5+ messages in thread
From: Jae Hyun Yoo @ 2019-05-31 21:47 UTC (permalink / raw)
  To: Eddie James, Joel Stanley, Andrew Jeffery; +Cc: openbmc, 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.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
---
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(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index 67d6380d4ef3..f58f44eab588 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -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) {
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase
  2019-05-31 21:47 [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Jae Hyun Yoo
                   ` (2 preceding siblings ...)
  2019-05-31 21:47 ` [PATCH v2 dev-5.1 3/3] media: aspeed: add a workaround to fix a silicon bug Jae Hyun Yoo
@ 2019-06-04  6:25 ` Joel Stanley
  3 siblings, 0 replies; 5+ messages in thread
From: Joel Stanley @ 2019-06-04  6:25 UTC (permalink / raw)
  To: Jae Hyun Yoo; +Cc: Eddie James, Andrew Jeffery, OpenBMC Maillist

Hi Jae,

On Fri, 31 May 2019 at 21:47, Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> wrote:

> 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.

>   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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-04  6:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 21:47 [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Jae Hyun Yoo
2019-05-31 21:47 ` [PATCH v2 dev-5.1 1/3] media: aspeed: remove source buffer allocation before mode detection Jae Hyun Yoo
2019-05-31 21:47 ` [PATCH v2 dev-5.1 2/3] media: aspeed: use different delays for triggering VE H/W reset Jae Hyun Yoo
2019-05-31 21:47 ` [PATCH v2 dev-5.1 3/3] media: aspeed: add a workaround to fix a silicon bug Jae Hyun Yoo
2019-06-04  6:25 ` [PATCH v2 dev-5.1 0/3] Improve stability of Aspeed video engine driver - 3rd phase Joel Stanley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.