Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b88163e3 authored by Lucas Stach's avatar Lucas Stach
Browse files

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: default avatarLucas Stach <l.stach@pengutronix.de>
parent e07c0db5
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -1437,37 +1437,41 @@ static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu)
	return 0;
}

static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms)
{
	if (gpu->buffer) {
		unsigned long timeout;
	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);

		/* Replace the last WAIT with END */
		etnaviv_buffer_end(gpu);

		/*
		 * We know that only the FE is busy here, this should
		 * happen quickly (as the WAIT is only 200 cycles).  If
		 * we fail, just warn and continue.
		 */
		timeout = jiffies + msecs_to_jiffies(100);
	do {
		u32 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);

		if ((idle & gpu->idle_mask) == gpu->idle_mask)
				break;
			return 0;

		if (time_is_before_jiffies(timeout)) {
			dev_warn(gpu->dev,
				 "timed out waiting for idle: idle=0x%x\n",
				 idle);
				break;
			return -ETIMEDOUT;
		}

		udelay(5);
	} while (1);
}

static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
{
	if (gpu->buffer) {
		/* Replace the last WAIT with END */
		etnaviv_buffer_end(gpu);

		/*
		 * We know that only the FE is busy here, this should
		 * happen quickly (as the WAIT is only 200 cycles).  If
		 * we fail, just warn and continue.
		 */
		etnaviv_gpu_wait_idle(gpu, 100);
	}

	return etnaviv_gpu_clk_disable(gpu);
}

+1 −0
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ struct etnaviv_cmdbuf *etnaviv_gpu_cmdbuf_new(struct etnaviv_gpu *gpu,
void etnaviv_gpu_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf);
int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu);
void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);
int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms);

extern struct platform_driver etnaviv_gpu_driver;