Skip to content

Commit 1691e00

Browse files
committed
drm/msm/gpu: Also snapshot GMU HFI buffer
This also includes a history of start index of the last 8 messages on each queue, since parsing backwards to decode recently sent HFI messages is hard(ish). Signed-off-by: Rob Clark <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Clark <[email protected]>
1 parent 203dcd5 commit 1691e00

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ struct a6xx_gpu_state {
4343
int nr_cx_debugbus;
4444

4545
struct msm_gpu_state_bo *gmu_log;
46+
struct msm_gpu_state_bo *gmu_hfi;
47+
48+
s32 hfi_queue_history[2][HFI_HISTORY_SZ];
4649

4750
struct list_head objs;
4851
};
@@ -822,6 +825,25 @@ static struct msm_gpu_state_bo *a6xx_snapshot_gmu_bo(
822825
return snapshot;
823826
}
824827

828+
static void a6xx_snapshot_gmu_hfi_history(struct msm_gpu *gpu,
829+
struct a6xx_gpu_state *a6xx_state)
830+
{
831+
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
832+
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
833+
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
834+
unsigned i, j;
835+
836+
BUILD_BUG_ON(ARRAY_SIZE(gmu->queues) != ARRAY_SIZE(a6xx_state->hfi_queue_history));
837+
838+
for (i = 0; i < ARRAY_SIZE(gmu->queues); i++) {
839+
struct a6xx_hfi_queue *queue = &gmu->queues[i];
840+
for (j = 0; j < HFI_HISTORY_SZ; j++) {
841+
unsigned idx = (j + queue->history_idx) % HFI_HISTORY_SZ;
842+
a6xx_state->hfi_queue_history[i][j] = queue->history[idx];
843+
}
844+
}
845+
}
846+
825847
#define A6XX_GBIF_REGLIST_SIZE 1
826848
static void a6xx_get_registers(struct msm_gpu *gpu,
827849
struct a6xx_gpu_state *a6xx_state,
@@ -960,6 +982,9 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu)
960982
a6xx_get_gmu_registers(gpu, a6xx_state);
961983

962984
a6xx_state->gmu_log = a6xx_snapshot_gmu_bo(a6xx_state, &a6xx_gpu->gmu.log);
985+
a6xx_state->gmu_hfi = a6xx_snapshot_gmu_bo(a6xx_state, &a6xx_gpu->gmu.hfi);
986+
987+
a6xx_snapshot_gmu_hfi_history(gpu, a6xx_state);
963988

964989
/* If GX isn't on the rest of the data isn't going to be accessible */
965990
if (!a6xx_gmu_gx_is_on(&a6xx_gpu->gmu))
@@ -1005,6 +1030,9 @@ static void a6xx_gpu_state_destroy(struct kref *kref)
10051030
if (a6xx_state->gmu_log)
10061031
kvfree(a6xx_state->gmu_log->data);
10071032

1033+
if (a6xx_state->gmu_hfi)
1034+
kvfree(a6xx_state->gmu_hfi->data);
1035+
10081036
list_for_each_entry_safe(obj, tmp, &a6xx_state->objs, node)
10091037
kfree(obj);
10101038

@@ -1223,11 +1251,29 @@ void a6xx_show(struct msm_gpu *gpu, struct msm_gpu_state *state,
12231251
struct msm_gpu_state_bo *gmu_log = a6xx_state->gmu_log;
12241252

12251253
drm_printf(p, " iova: 0x%016llx\n", gmu_log->iova);
1226-
drm_printf(p, " size: %d\n", gmu_log->size);
1254+
drm_printf(p, " size: %zu\n", gmu_log->size);
12271255
adreno_show_object(p, &gmu_log->data, gmu_log->size,
12281256
&gmu_log->encoded);
12291257
}
12301258

1259+
drm_puts(p, "gmu-hfi:\n");
1260+
if (a6xx_state->gmu_hfi) {
1261+
struct msm_gpu_state_bo *gmu_hfi = a6xx_state->gmu_hfi;
1262+
unsigned i, j;
1263+
1264+
drm_printf(p, " iova: 0x%016llx\n", gmu_hfi->iova);
1265+
drm_printf(p, " size: %zu\n", gmu_hfi->size);
1266+
for (i = 0; i < ARRAY_SIZE(a6xx_state->hfi_queue_history); i++) {
1267+
drm_printf(p, " queue-history[%u]:", i);
1268+
for (j = 0; j < HFI_HISTORY_SZ; j++) {
1269+
drm_printf(p, " %d", a6xx_state->hfi_queue_history[i][j]);
1270+
}
1271+
drm_printf(p, "\n");
1272+
}
1273+
adreno_show_object(p, &gmu_hfi->data, gmu_hfi->size,
1274+
&gmu_hfi->encoded);
1275+
}
1276+
12311277
drm_puts(p, "registers:\n");
12321278
for (i = 0; i < a6xx_state->nr_registers; i++) {
12331279
struct a6xx_gpu_state_obj *obj = &a6xx_state->registers[i];

drivers/gpu/drm/msm/adreno/a6xx_hfi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static int a6xx_hfi_queue_read(struct a6xx_gmu *gmu,
3636

3737
hdr = queue->data[index];
3838

39+
queue->history[(queue->history_idx++) % HFI_HISTORY_SZ] = index;
40+
3941
/*
4042
* If we are to assume that the GMU firmware is in fact a rational actor
4143
* and is programmed to not send us a larger response than we expect
@@ -75,6 +77,8 @@ static int a6xx_hfi_queue_write(struct a6xx_gmu *gmu,
7577
return -ENOSPC;
7678
}
7779

80+
queue->history[(queue->history_idx++) % HFI_HISTORY_SZ] = index;
81+
7882
for (i = 0; i < dwords; i++) {
7983
queue->data[index] = data[i];
8084
index = (index + 1) % header->size;
@@ -600,6 +604,9 @@ void a6xx_hfi_stop(struct a6xx_gmu *gmu)
600604

601605
queue->header->read_index = 0;
602606
queue->header->write_index = 0;
607+
608+
memset(&queue->history, 0xff, sizeof(queue->history));
609+
queue->history_idx = 0;
603610
}
604611
}
605612

@@ -612,6 +619,9 @@ static void a6xx_hfi_queue_init(struct a6xx_hfi_queue *queue,
612619
queue->data = virt;
613620
atomic_set(&queue->seqnum, 0);
614621

622+
memset(&queue->history, 0xff, sizeof(queue->history));
623+
queue->history_idx = 0;
624+
615625
/* Set up the shared memory header */
616626
header->iova = iova;
617627
header->type = 10 << 8 | id;

drivers/gpu/drm/msm/adreno/a6xx_hfi.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ struct a6xx_hfi_queue {
3333
spinlock_t lock;
3434
u32 *data;
3535
atomic_t seqnum;
36+
37+
/*
38+
* Tracking for the start index of the last N messages in the
39+
* queue, for the benefit of devcore dump / crashdec (since
40+
* parsing in the reverse direction to decode the last N
41+
* messages is difficult to do and would rely on heuristics
42+
* which are not guaranteed to be correct)
43+
*/
44+
#define HFI_HISTORY_SZ 8
45+
s32 history[HFI_HISTORY_SZ];
46+
u8 history_idx;
3647
};
3748

3849
/* This is the outgoing queue to the GMU */

0 commit comments

Comments
 (0)