From a176f9de5446787a9c4fd85bbef73db88ec9075b Mon Sep 17 00:00:00 2001 From: Laurentiu Palcu Date: Fri, 28 Sep 2018 08:56:54 +0300 Subject: MLK-19623: change hdmi keep-alive check mechanism The current keep-alive check mechanism uses a static variable that is initialized to 0. When the function is first called, it may happen to catch the 8-bit keep-alive counter right when it overflows, hence returning BUSY. This patch will keep checking the counter for 10us, every 1us, but it will immediately return if the keep-alive counter changed. Signed-off-by: Laurentiu Palcu (cherry picked from commit a809d62f2060cf2e907257806bebf688ffc8c924) --- drivers/video/imx/hdp/API_General.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/video/imx/hdp/API_General.c b/drivers/video/imx/hdp/API_General.c index f52e994b24..4f08c2be74 100644 --- a/drivers/video/imx/hdp/API_General.c +++ b/drivers/video/imx/hdp/API_General.c @@ -264,14 +264,27 @@ CDN_API_STATUS cdn_api_get_debug_reg_val(uint16_t *val) CDN_API_STATUS cdn_api_checkalive(void) { - static unsigned int alive; - unsigned int newalive; - if (cdn_apb_read(KEEP_ALIVE << 2, &newalive)) + unsigned int alive, newalive; + uint8_t retries_left = 10; + + if (cdn_apb_read(KEEP_ALIVE << 2, &alive)) return CDN_ERR; - if (alive == newalive) - return CDN_BSY; - alive = newalive; - return CDN_OK; + + while (retries_left--) { + udelay(1); + + if (cdn_apb_read(KEEP_ALIVE << 2, &newalive)) + return CDN_ERR; + + if (alive == newalive) + continue; + + return CDN_OK; + } + + printf("%s: keep-alive counter did not increment for 10us...\n", __func__); + + return CDN_BSY; } CDN_API_STATUS cdn_api_checkalive_blocking(void) -- cgit v1.2.3