Skip to content

Commit f098f9b

Browse files
committed
drm/etnaviv: move runtime PM handling to events
Conceptually events are the right abstraction to handle the GPU runtime PM state: as long as any event is pending the GPU can not be idle. Events are also properly freed and reallocated when the GPU has been reset after a hang. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
1 parent 80f6b63 commit f098f9b

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct etnaviv_gem_submit {
9797
struct list_head node; /* GPU active submit list */
9898
struct etnaviv_cmdbuf cmdbuf;
9999
struct pid *pid; /* submitting process */
100-
bool runtime_resumed;
101100
u32 exec_state;
102101
u32 flags;
103102
unsigned int nr_pmrs;

drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,6 @@ static void submit_cleanup(struct kref *kref)
362362
container_of(kref, struct etnaviv_gem_submit, refcount);
363363
unsigned i;
364364

365-
if (submit->runtime_resumed)
366-
pm_runtime_put_autosuspend(submit->gpu->dev);
367-
368365
if (submit->cmdbuf.suballoc)
369366
etnaviv_cmdbuf_free(&submit->cmdbuf);
370367

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,8 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
11471147
unsigned int *events)
11481148
{
11491149
unsigned long timeout = msecs_to_jiffies(10 * 10000);
1150-
unsigned i, acquired = 0;
1150+
unsigned i, acquired = 0, rpm_count = 0;
1151+
int ret;
11511152

11521153
for (i = 0; i < nr_events; i++) {
11531154
unsigned long ret;
@@ -1156,6 +1157,7 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
11561157

11571158
if (!ret) {
11581159
dev_err(gpu->dev, "wait_for_completion_timeout failed");
1160+
ret = -EBUSY;
11591161
goto out;
11601162
}
11611163

@@ -1175,13 +1177,23 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
11751177

11761178
spin_unlock(&gpu->event_spinlock);
11771179

1180+
for (i = 0; i < nr_events; i++) {
1181+
ret = pm_runtime_resume_and_get(gpu->dev);
1182+
if (ret)
1183+
goto out_rpm;
1184+
rpm_count++;
1185+
}
1186+
11781187
return 0;
11791188

1189+
out_rpm:
1190+
for (i = 0; i < rpm_count; i++)
1191+
pm_runtime_put_autosuspend(gpu->dev);
11801192
out:
11811193
for (i = 0; i < acquired; i++)
11821194
complete(&gpu->event_free);
11831195

1184-
return -EBUSY;
1196+
return ret;
11851197
}
11861198

11871199
static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
@@ -1193,6 +1205,8 @@ static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
11931205
clear_bit(event, gpu->event_bitmap);
11941206
complete(&gpu->event_free);
11951207
}
1208+
1209+
pm_runtime_put_autosuspend(gpu->dev);
11961210
}
11971211

11981212
/*
@@ -1335,15 +1349,6 @@ struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
13351349
unsigned int i, nr_events = 1, event[3];
13361350
int ret;
13371351

1338-
if (!submit->runtime_resumed) {
1339-
ret = pm_runtime_get_sync(gpu->dev);
1340-
if (ret < 0) {
1341-
pm_runtime_put_noidle(gpu->dev);
1342-
return NULL;
1343-
}
1344-
submit->runtime_resumed = true;
1345-
}
1346-
13471352
/*
13481353
* if there are performance monitor requests we need to have
13491354
* - a sync point to re-configure gpu and process ETNA_PM_PROCESS_PRE

0 commit comments

Comments
 (0)