diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2016-08-17 09:16:57 -0400 |
---|---|---|
committer | Lucas Stach <l.stach@pengutronix.de> | 2016-09-15 09:29:38 -0400 |
commit | b88163e36c0256e182447eecffba5f4b2a3f413e (patch) | |
tree | bf24ec618d52c307ac254d3487028bb32245a723 /drivers/gpu | |
parent | e07c0db5e84a5f1a16af8567d5fdde2ca6d2c80e (diff) |
drm/etnaviv: split out wait for gpu idle
Split out into a new externally visible function, as the IOMMUv2
code needs this functionality, too.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 40 | ||||
-rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 1 |
2 files changed, 23 insertions, 18 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 6309d27045a6..74e09dcae75f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c | |||
@@ -1437,11 +1437,30 @@ static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu) | |||
1437 | return 0; | 1437 | return 0; |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms) | ||
1441 | { | ||
1442 | unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms); | ||
1443 | |||
1444 | do { | ||
1445 | u32 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE); | ||
1446 | |||
1447 | if ((idle & gpu->idle_mask) == gpu->idle_mask) | ||
1448 | return 0; | ||
1449 | |||
1450 | if (time_is_before_jiffies(timeout)) { | ||
1451 | dev_warn(gpu->dev, | ||
1452 | "timed out waiting for idle: idle=0x%x\n", | ||
1453 | idle); | ||
1454 | return -ETIMEDOUT; | ||
1455 | } | ||
1456 | |||
1457 | udelay(5); | ||
1458 | } while (1); | ||
1459 | } | ||
1460 | |||
1440 | static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu) | 1461 | static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu) |
1441 | { | 1462 | { |
1442 | if (gpu->buffer) { | 1463 | if (gpu->buffer) { |
1443 | unsigned long timeout; | ||
1444 | |||
1445 | /* Replace the last WAIT with END */ | 1464 | /* Replace the last WAIT with END */ |
1446 | etnaviv_buffer_end(gpu); | 1465 | etnaviv_buffer_end(gpu); |
1447 | 1466 | ||
@@ -1450,22 +1469,7 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu) | |||
1450 | * happen quickly (as the WAIT is only 200 cycles). If | 1469 | * happen quickly (as the WAIT is only 200 cycles). If |
1451 | * we fail, just warn and continue. | 1470 | * we fail, just warn and continue. |
1452 | */ | 1471 | */ |
1453 | timeout = jiffies + msecs_to_jiffies(100); | 1472 | etnaviv_gpu_wait_idle(gpu, 100); |
1454 | do { | ||
1455 | u32 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE); | ||
1456 | |||
1457 | if ((idle & gpu->idle_mask) == gpu->idle_mask) | ||
1458 | break; | ||
1459 | |||
1460 | if (time_is_before_jiffies(timeout)) { | ||
1461 | dev_warn(gpu->dev, | ||
1462 | "timed out waiting for idle: idle=0x%x\n", | ||
1463 | idle); | ||
1464 | break; | ||
1465 | } | ||
1466 | |||
1467 | udelay(5); | ||
1468 | } while (1); | ||
1469 | } | 1473 | } |
1470 | 1474 | ||
1471 | return etnaviv_gpu_clk_disable(gpu); | 1475 | return etnaviv_gpu_clk_disable(gpu); |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h index a69cdd526bf8..303450b1f981 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h | |||
@@ -214,6 +214,7 @@ struct etnaviv_cmdbuf *etnaviv_gpu_cmdbuf_new(struct etnaviv_gpu *gpu, | |||
214 | void etnaviv_gpu_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf); | 214 | void etnaviv_gpu_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf); |
215 | int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu); | 215 | int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu); |
216 | void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu); | 216 | void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu); |
217 | int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms); | ||
217 | 218 | ||
218 | extern struct platform_driver etnaviv_gpu_driver; | 219 | extern struct platform_driver etnaviv_gpu_driver; |
219 | 220 | ||