summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2023-02-24 13:03:23 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2023-02-24 13:03:23 -0800
commita974adf2d5d75b6a95d6d8c72c9d65a80f8caca8 (patch)
tree9acd5b9b37e7ea75731cf17fafe2efc978c52610
parentc51f11792b4aa556e64b2b2dbc4eabc63f375881 (diff)
parent3a06da43aaf88ad1acde81d02d01915e979e15cf (diff)
downloadgraphics-a974adf2d5d75b6a95d6d8c72c9d65a80f8caca8.tar.gz
Merge "msm: kgsl: Capture eventlog buffer in snapshot"
-rw-r--r--kgsl_eventlog.c42
-rw-r--r--kgsl_eventlog.h3
-rw-r--r--kgsl_snapshot.c6
-rw-r--r--kgsl_snapshot.h12
4 files changed, 57 insertions, 6 deletions
diff --git a/kgsl_eventlog.c b/kgsl_eventlog.c
index e60ecce..908efdc 100644
--- a/kgsl_eventlog.c
+++ b/kgsl_eventlog.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/sched.h>
@@ -10,12 +11,16 @@
#include "kgsl_device.h"
#include "kgsl_eventlog.h"
+#include "kgsl_snapshot.h"
#include "kgsl_util.h"
#define EVENTLOG_SIZE (SZ_64K + SZ_32K)
#define MAGIC 0xabbaabba
#define LOG_FENCE_NAME_LEN 74
+#define KGSL_SNAPSHOT_EVENTLOG_TYPE 0x1
+#define KGSL_SNAPSHOT_EVENTLOG_VERSION 0x0
+
/*
* This an internal event used to skip empty space at the bottom of the
* ringbuffer
@@ -35,10 +40,15 @@ static void *kgsl_eventlog;
static int eventlog_wptr;
struct kgsl_log_header {
+ /** @magic: Magic value to identify header */
u32 magic;
+ /** @pid: : PID of the process */
int pid;
+ /** @time: System time in nanoseconds */
u64 time;
- u32 eventid;
+ /** @event: bits[0:15] specify the event ID. bits[16:31] specify event version */
+ u32 event;
+ /** @size: Size of the event data in bytes */
u32 size;
};
@@ -50,11 +60,11 @@ static void add_skip_header(u32 offset)
header->magic = MAGIC;
header->time = local_clock();
header->pid = 0;
- header->eventid = LOG_SKIP;
+ header->event = FIELD_PREP(GENMASK(15, 0), LOG_SKIP);
header->size = EVENTLOG_SIZE - sizeof(*header) - offset;
}
-static void *kgsl_eventlog_alloc(u32 eventid, u32 size)
+static void *kgsl_eventlog_alloc(u16 eventid, u32 size)
{
struct kgsl_log_header *header;
u32 datasize = size + sizeof(*header);
@@ -80,7 +90,7 @@ static void *kgsl_eventlog_alloc(u32 eventid, u32 size)
header->magic = MAGIC;
header->time = local_clock();
header->pid = current->pid;
- header->eventid = eventid;
+ header->event = FIELD_PREP(GENMASK(15, 0), eventid);
header->size = size;
return data + sizeof(*header);
@@ -230,3 +240,27 @@ void log_kgsl_timeline_fence_release_event(u32 id, u64 seqno)
entry->id = id;
entry->seqno = seqno;
}
+
+size_t kgsl_snapshot_eventlog_buffer(struct kgsl_device *device,
+ u8 *buf, size_t remain, void *priv)
+{
+ struct kgsl_snapshot_eventlog *hdr =
+ (struct kgsl_snapshot_eventlog *)buf;
+ u32 *data = (u32 *)(buf + sizeof(*hdr));
+
+ if (!kgsl_eventlog)
+ return 0;
+
+ if (remain < EVENTLOG_SIZE + sizeof(*hdr)) {
+ dev_err(device->dev,
+ "snapshot: Not enough memory for eventlog\n");
+ return 0;
+ }
+
+ hdr->size = EVENTLOG_SIZE;
+ hdr->type = KGSL_SNAPSHOT_EVENTLOG_TYPE;
+ hdr->version = KGSL_SNAPSHOT_EVENTLOG_VERSION;
+ memcpy(data, kgsl_eventlog, EVENTLOG_SIZE);
+
+ return EVENTLOG_SIZE + sizeof(*hdr);
+}
diff --git a/kgsl_eventlog.h b/kgsl_eventlog.h
index 5e6e017..119799e 100644
--- a/kgsl_eventlog.h
+++ b/kgsl_eventlog.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _KGSL_EVENTLOG_H
@@ -17,4 +18,6 @@ void log_kgsl_syncpoint_fence_event(u32 id, char *fence_name);
void log_kgsl_syncpoint_fence_expire_event(u32 id, char *fence_name);
void log_kgsl_timeline_fence_alloc_event(u32 id, u64 seqno);
void log_kgsl_timeline_fence_release_event(u32 id, u64 seqno);
+size_t kgsl_snapshot_eventlog_buffer(struct kgsl_device *device,
+ u8 *buf, size_t remain, void *priv);
#endif
diff --git a/kgsl_snapshot.c b/kgsl_snapshot.c
index 9ad8b2e..d775b80 100644
--- a/kgsl_snapshot.c
+++ b/kgsl_snapshot.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/of.h>
@@ -11,6 +11,7 @@
#include "adreno_cp_parser.h"
#include "kgsl_device.h"
+#include "kgsl_eventlog.h"
#include "kgsl_sharedmem.h"
#include "kgsl_snapshot.h"
#include "kgsl_util.h"
@@ -544,6 +545,9 @@ static void kgsl_device_snapshot_atomic(struct kgsl_device *device)
if (device->ftbl->snapshot)
device->ftbl->snapshot(device, snapshot, NULL, NULL);
+ kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_EVENTLOG,
+ snapshot, kgsl_snapshot_eventlog_buffer, NULL);
+
/*
* The timestamp is the seconds since boot so it is easier to match to
* the kernel log
diff --git a/kgsl_snapshot.h b/kgsl_snapshot.h
index 779e7ee..bf7860c 100644
--- a/kgsl_snapshot.h
+++ b/kgsl_snapshot.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef _KGSL_SNAPSHOT_H_
@@ -59,6 +59,7 @@ struct kgsl_snapshot_section_header {
#define KGSL_SNAPSHOT_SECTION_GMU_MEMORY 0x1701
#define KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS 0x1801
#define KGSL_SNAPSHOT_SECTION_TRACE_BUFFER 0x1901
+#define KGSL_SNAPSHOT_SECTION_EVENTLOG 0x1A01
#define KGSL_SNAPSHOT_SECTION_END 0xFFFF
@@ -361,6 +362,15 @@ struct kgsl_snapshot_gpu_object_v2 {
__u64 size; /* Size of the object (in dwords) */
} __packed;
+struct kgsl_snapshot_eventlog {
+ /** @type: Type of the event log buffer */
+ __u16 type;
+ /** @version: Version of the event log buffer */
+ __u16 version;
+ /** @size: Size of the eventlog buffer in bytes */
+ u32 size;
+} __packed;
+
struct kgsl_device;
struct kgsl_process_private;