Commit 2646699f authored by Dave Airlie's avatar Dave Airlie

Merge branch 'etnaviv/next' of https://git.pengutronix.de/git/lst/linux into drm-next

Nothing too exciting:
- a cleanup of our clock handling and improved error handling in this
area from Lubomir
- conversion to pin_user_pages for long page references from John
- fixed PM runtime API error handling from Navid
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
From: Lucas Stach <l.stach@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/d9e2660d71051bf3cab8aa7afc9f62102ac910d9.camel@pengutronix.de
parents 5a394f19 c5d5a32e
...@@ -675,10 +675,10 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj) ...@@ -675,10 +675,10 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj)
uint64_t ptr = userptr->ptr + pinned * PAGE_SIZE; uint64_t ptr = userptr->ptr + pinned * PAGE_SIZE;
struct page **pages = pvec + pinned; struct page **pages = pvec + pinned;
ret = get_user_pages_fast(ptr, num_pages, ret = pin_user_pages_fast(ptr, num_pages,
!userptr->ro ? FOLL_WRITE : 0, pages); !userptr->ro ? FOLL_WRITE : 0, pages);
if (ret < 0) { if (ret < 0) {
release_pages(pvec, pinned); unpin_user_pages(pvec, pinned);
kvfree(pvec); kvfree(pvec);
return ret; return ret;
} }
...@@ -702,7 +702,7 @@ static void etnaviv_gem_userptr_release(struct etnaviv_gem_object *etnaviv_obj) ...@@ -702,7 +702,7 @@ static void etnaviv_gem_userptr_release(struct etnaviv_gem_object *etnaviv_obj)
if (etnaviv_obj->pages) { if (etnaviv_obj->pages) {
int npages = etnaviv_obj->base.size >> PAGE_SHIFT; int npages = etnaviv_obj->base.size >> PAGE_SHIFT;
release_pages(etnaviv_obj->pages, npages); unpin_user_pages(etnaviv_obj->pages, npages);
kvfree(etnaviv_obj->pages); kvfree(etnaviv_obj->pages);
} }
} }
......
...@@ -722,7 +722,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) ...@@ -722,7 +722,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
ret = pm_runtime_get_sync(gpu->dev); ret = pm_runtime_get_sync(gpu->dev);
if (ret < 0) { if (ret < 0) {
dev_err(gpu->dev, "Failed to enable GPU power domain\n"); dev_err(gpu->dev, "Failed to enable GPU power domain\n");
return ret; goto pm_put;
} }
etnaviv_hw_identify(gpu); etnaviv_hw_identify(gpu);
...@@ -819,6 +819,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) ...@@ -819,6 +819,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
fail: fail:
pm_runtime_mark_last_busy(gpu->dev); pm_runtime_mark_last_busy(gpu->dev);
pm_put:
pm_runtime_put_autosuspend(gpu->dev); pm_runtime_put_autosuspend(gpu->dev);
return ret; return ret;
...@@ -859,7 +860,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) ...@@ -859,7 +860,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
ret = pm_runtime_get_sync(gpu->dev); ret = pm_runtime_get_sync(gpu->dev);
if (ret < 0) if (ret < 0)
return ret; goto pm_put;
dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW); dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW);
dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH); dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH);
...@@ -1003,6 +1004,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) ...@@ -1003,6 +1004,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
ret = 0; ret = 0;
pm_runtime_mark_last_busy(gpu->dev); pm_runtime_mark_last_busy(gpu->dev);
pm_put:
pm_runtime_put_autosuspend(gpu->dev); pm_runtime_put_autosuspend(gpu->dev);
return ret; return ret;
...@@ -1016,7 +1018,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu) ...@@ -1016,7 +1018,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
dev_err(gpu->dev, "recover hung GPU!\n"); dev_err(gpu->dev, "recover hung GPU!\n");
if (pm_runtime_get_sync(gpu->dev) < 0) if (pm_runtime_get_sync(gpu->dev) < 0)
return; goto pm_put;
mutex_lock(&gpu->lock); mutex_lock(&gpu->lock);
...@@ -1035,6 +1037,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu) ...@@ -1035,6 +1037,7 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
mutex_unlock(&gpu->lock); mutex_unlock(&gpu->lock);
pm_runtime_mark_last_busy(gpu->dev); pm_runtime_mark_last_busy(gpu->dev);
pm_put:
pm_runtime_put_autosuspend(gpu->dev); pm_runtime_put_autosuspend(gpu->dev);
} }
...@@ -1308,8 +1311,10 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit) ...@@ -1308,8 +1311,10 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
if (!submit->runtime_resumed) { if (!submit->runtime_resumed) {
ret = pm_runtime_get_sync(gpu->dev); ret = pm_runtime_get_sync(gpu->dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put_noidle(gpu->dev);
return NULL; return NULL;
}
submit->runtime_resumed = true; submit->runtime_resumed = true;
} }
...@@ -1326,6 +1331,7 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit) ...@@ -1326,6 +1331,7 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
ret = event_alloc(gpu, nr_events, event); ret = event_alloc(gpu, nr_events, event);
if (ret) { if (ret) {
DRM_ERROR("no free events\n"); DRM_ERROR("no free events\n");
pm_runtime_put_noidle(gpu->dev);
return NULL; return NULL;
} }
...@@ -1487,51 +1493,39 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) ...@@ -1487,51 +1493,39 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
{ {
int ret; int ret;
if (gpu->clk_reg) {
ret = clk_prepare_enable(gpu->clk_reg); ret = clk_prepare_enable(gpu->clk_reg);
if (ret) if (ret)
return ret; return ret;
}
if (gpu->clk_bus) {
ret = clk_prepare_enable(gpu->clk_bus); ret = clk_prepare_enable(gpu->clk_bus);
if (ret) if (ret)
return ret; goto disable_clk_reg;
}
if (gpu->clk_core) {
ret = clk_prepare_enable(gpu->clk_core); ret = clk_prepare_enable(gpu->clk_core);
if (ret) if (ret)
goto disable_clk_bus; goto disable_clk_bus;
}
if (gpu->clk_shader) {
ret = clk_prepare_enable(gpu->clk_shader); ret = clk_prepare_enable(gpu->clk_shader);
if (ret) if (ret)
goto disable_clk_core; goto disable_clk_core;
}
return 0; return 0;
disable_clk_core: disable_clk_core:
if (gpu->clk_core)
clk_disable_unprepare(gpu->clk_core); clk_disable_unprepare(gpu->clk_core);
disable_clk_bus: disable_clk_bus:
if (gpu->clk_bus)
clk_disable_unprepare(gpu->clk_bus); clk_disable_unprepare(gpu->clk_bus);
disable_clk_reg:
clk_disable_unprepare(gpu->clk_reg);
return ret; return ret;
} }
static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu) static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu)
{ {
if (gpu->clk_shader)
clk_disable_unprepare(gpu->clk_shader); clk_disable_unprepare(gpu->clk_shader);
if (gpu->clk_core)
clk_disable_unprepare(gpu->clk_core); clk_disable_unprepare(gpu->clk_core);
if (gpu->clk_bus)
clk_disable_unprepare(gpu->clk_bus); clk_disable_unprepare(gpu->clk_bus);
if (gpu->clk_reg)
clk_disable_unprepare(gpu->clk_reg); clk_disable_unprepare(gpu->clk_reg);
return 0; return 0;
...@@ -1783,26 +1777,26 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) ...@@ -1783,26 +1777,26 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
} }
/* Get Clocks: */ /* Get Clocks: */
gpu->clk_reg = devm_clk_get(&pdev->dev, "reg"); gpu->clk_reg = devm_clk_get_optional(&pdev->dev, "reg");
DBG("clk_reg: %p", gpu->clk_reg); DBG("clk_reg: %p", gpu->clk_reg);
if (IS_ERR(gpu->clk_reg)) if (IS_ERR(gpu->clk_reg))
gpu->clk_reg = NULL; return PTR_ERR(gpu->clk_reg);
gpu->clk_bus = devm_clk_get(&pdev->dev, "bus"); gpu->clk_bus = devm_clk_get_optional(&pdev->dev, "bus");
DBG("clk_bus: %p", gpu->clk_bus); DBG("clk_bus: %p", gpu->clk_bus);
if (IS_ERR(gpu->clk_bus)) if (IS_ERR(gpu->clk_bus))
gpu->clk_bus = NULL; return PTR_ERR(gpu->clk_bus);
gpu->clk_core = devm_clk_get(&pdev->dev, "core"); gpu->clk_core = devm_clk_get(&pdev->dev, "core");
DBG("clk_core: %p", gpu->clk_core); DBG("clk_core: %p", gpu->clk_core);
if (IS_ERR(gpu->clk_core)) if (IS_ERR(gpu->clk_core))
gpu->clk_core = NULL; return PTR_ERR(gpu->clk_core);
gpu->base_rate_core = clk_get_rate(gpu->clk_core); gpu->base_rate_core = clk_get_rate(gpu->clk_core);
gpu->clk_shader = devm_clk_get(&pdev->dev, "shader"); gpu->clk_shader = devm_clk_get_optional(&pdev->dev, "shader");
DBG("clk_shader: %p", gpu->clk_shader); DBG("clk_shader: %p", gpu->clk_shader);
if (IS_ERR(gpu->clk_shader)) if (IS_ERR(gpu->clk_shader))
gpu->clk_shader = NULL; return PTR_ERR(gpu->clk_shader);
gpu->base_rate_shader = clk_get_rate(gpu->clk_shader); gpu->base_rate_shader = clk_get_rate(gpu->clk_shader);
/* TODO: figure out max mapped size */ /* TODO: figure out max mapped size */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment