From ff759ee370e57e630e55e95b6627ed3fc74432f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=AD=90=E6=87=BF?= Date: Mon, 9 Sep 2024 14:46:46 +0800 Subject: [PATCH] drivers: gpu: fix VGLite finish early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VGLite might invoke interrupt before drawing is done, wait until GPU is idle. Signed-off-by: 黄子懿 --- drivers/gpu/vglite/vg_lite_hal.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/vglite/vg_lite_hal.c b/drivers/gpu/vglite/vg_lite_hal.c index 889c800b2da7..dc4e8fc323e0 100644 --- a/drivers/gpu/vglite/vg_lite_hal.c +++ b/drivers/gpu/vglite/vg_lite_hal.c @@ -353,38 +353,36 @@ int vg_lite_hal_wait_interrupt(u32 timeout, u32 mask, u32 *value) #define IGNORE_INTERRUPT 1 #if IGNORE_INTERRUPT unsigned int int_flag; + u32 idle = 0x7fffffff; #endif + /* Convert timeval to jiffies. */ if (timeout == VG_LITE_INFINITE) { /* Set 1 second timeout. */ - // FIXME: tv.tv_sec = 1; - // tv.tv_usec = 0; jiffies = msecs_to_jiffies(1000); } else { /* Convert timeout in ms to timeval. */ - // tv.tv_sec = timeout / 1000; - // tv.tv_usec = (timeout % 1000) * 1000; jiffies = msecs_to_jiffies(timeout); } - /* Convert timeval to jiffies. */ - // jiffies = timeval_to_jiffies(&tv); - /* Wait for interrupt, ignoring timeout. */ do { result = wait_event_interruptible_timeout( device->int_queue, device->int_flags & mask, jiffies); #if IGNORE_INTERRUPT + /* Wait until GPU is idle */ int_flag = vg_lite_hal_peek(0x10); - if (int_flag) + idle = vg_lite_hal_peek(0x04); + if (int_flag) { result = int_flag; - dev_vdbg(device->dev, - "vg_lite: waiting... idle: 0x%08X, int: 0x%08X, FE: 0x%08X 0x%08X 0x%08X\n", - vg_lite_hal_peek(0x4), int_flag, vg_lite_hal_peek(0x500), - vg_lite_hal_peek(0x504), vg_lite_hal_peek(0x508) - ); + dev_vdbg(device->dev, + "vg_lite: waiting... idle: 0x%08X, int: 0x%08X, FE: 0x%08X 0x%08X 0x%08X\n", + idle, int_flag, vg_lite_hal_peek(0x500), + vg_lite_hal_peek(0x504), vg_lite_hal_peek(0x508) + ); + } #endif - } while (timeout == VG_LITE_INFINITE && result == 0); + } while ((timeout == VG_LITE_INFINITE && result == 0) || (idle != 0x7fffffff)); /* Report the event(s) got. */ if (value)