drm/msm/a6xx: devcore dump fixes
Subsystems (4)
cover drm/msm/a6xx: devcore dump fixes
From: Rob Clark <[email protected]>
First patch fixes a recently introduced memory corruption, the remaining two are cleanups.
Rob Clark (3):
drm/msm/a6xx: Fix kvzalloc vs state_kcalloc usage drm/msm/a6xx: Skip snapshotting unused GMU buffers drm/msm/a6xx: Remove state objects from list before freeing
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 18 ++++++++++++++++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 7 ++++++- 2 files changed, 22 insertions(+), 3 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/3 drm/msm/a6xx: Fix kvzalloc vs state_kcalloc usage
From: Rob Clark <[email protected]>
adreno_show_object() is a trap! It will re-allocate the pointer it is passed on first call, when the data is ascii85 encoded, using kvmalloc/ kvfree(). Which means the data *passed* to it must be kvmalloc'd, ie. we cannot use the state_kcalloc() helper.
This partially revertsec8f1813bf8d ("drm/msm/a6xx: Replace kcalloc() with kvzalloc()"), but fix the missing kvfree() to fix the memory leak that was present previously. And adds a warning comment.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 11 ++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +10 -1
@@ -819,7 +819,7 @@ static struct msm_gpu_state_bo *a6xx_snapshot_gmu_bo( snapshot->iova = bo->iova; snapshot->size = bo->size; - snapshot->data =state_kcalloc (a6xx_state,1 , snapshot->size); + snapshot->data =kvzalloc (snapshot->size,GFP_KERNEL );if (!snapshot->data)return NULL ;
@@ -1034,6 +1034,15 @@ static void a6xx_gpu_state_destroy(struct kref *kref)struct a6xx_gpu_state *a6xx_state =container_of (state, struct a6xx_gpu_state, base); +if (a6xx_state->gmu_log) +kvfree (a6xx_state->gmu_log->data); + +if (a6xx_state->gmu_hfi) +kvfree (a6xx_state->gmu_hfi->data); + +if (a6xx_state->gmu_debug) +kvfree (a6xx_state->gmu_debug->data); +list_for_each_entry_safe (obj, tmp, &a6xx_state->objs, node)kvfree (obj);
drivers/gpu/drm/msm/adreno/adreno_gpu.c +6 -1
@@ -729,7 +729,12 @@ static char *adreno_gpu_ascii85_encode(u32 *src, size_t len)return buf; } -/* len is expected to be in bytes */ +/* len is expected to be in bytes +* +* WARNING: *ptr should be allocated with kvmalloc or friends. It can be free'd +* with kvfree() and replaced with a newly kvmalloc'd buffer on the first call +* when the unencoded raw data is encoded +*/ void adreno_show_object (struct drm_printer *p,void **ptr,int len,bool *encoded) {
Signature · 1 line
2.37.3
PATCH 2/3 drm/msm/a6xx: Skip snapshotting unused GMU buffers
In reply to Rob ClarkFrom: Rob Clark <[email protected]>
Some buffers are unused on certain sub-generations of a6xx. So just skip them.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +3 -0
@@ -813,6 +813,9 @@ static struct msm_gpu_state_bo *a6xx_snapshot_gmu_bo( {struct msm_gpu_state_bo *snapshot; +if (!bo->size) +return NULL ; + snapshot =state_kcalloc (a6xx_state,1 ,sizeof (*snapshot));if (!snapshot)return NULL ;
Signature · 1 line
2.37.3
PATCH 3/3 drm/msm/a6xx: Remove state objects from list before freeing
In reply to Rob ClarkFrom: Rob Clark <[email protected]>
Technically it worked as it was before, only because it was using the _safe version of the iterator. But it is sloppy practice to leave dangling pointers.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +3 -1
@@ -1046,8 +1046,10 @@ static void a6xx_gpu_state_destroy(struct kref *kref)if (a6xx_state->gmu_debug)kvfree (a6xx_state->gmu_debug->data); -list_for_each_entry_safe (obj, tmp, &a6xx_state->objs, node) +list_for_each_entry_safe (obj, tmp, &a6xx_state->objs, node) { +list_del (&obj->node);kvfree (obj); + }adreno_gpu_state_destroy (state);kfree (a6xx_state);
Signature · 1 line
2.37.3
Quoted 5 lines · Rob Clark
From: Rob Clark <[email protected]>
First patch fixes a recently introduced memory corruption, the remaining two are cleanups.
Series is
Quoted 12 lines
Rob Clark (3):
drm/msm/a6xx: Fix kvzalloc vsstate_kcallocusage drm/msm/a6xx: Skip snapshotting unused GMU buffers drm/msm/a6xx: Remove state objects from list before freeingdrivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 18 ++++++++++++++++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 7 ++++++- 2 files changed, 22 insertions(+), 3 deletions(-)--
2.37.3
Quoted 5 lines · Rob Clark
From: Rob Clark <[email protected]>
First patch fixes a recently introduced memory corruption, the remaining two are cleanups.
Quoted 8 lines
Rob Clark (3):
drm/msm/a6xx: Fix kvzalloc vsstate_kcallocusage drm/msm/a6xx: Skip snapshotting unused GMU buffers drm/msm/a6xx: Remove state objects from list before freeingdrivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 18 ++++++++++++++++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 7 ++++++- 2 files changed, 22 insertions(+), 3 deletions(-)
For the entire series:
-Akhil