Merge "msm: kgsl: Add snapshot memory region in minidump only once"

This commit is contained in:
qctecmdr 2021-02-25 22:06:56 -08:00 • committed by Gerrit - the friendly Code Review server
commit 93d8db2eb7
2 changed files with 18 additions and 3 deletions

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2002,2007-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved.
*/
#ifndef __KGSL_DEVICE_H
#define __KGSL_DEVICE_H
@ -261,6 +261,7 @@ struct kgsl_device {
struct {
void *ptr;
u32 size;
bool in_minidump;
} snapshot_memory;
struct kgsl_snapshot *snapshot;

View file

@ -35,16 +35,18 @@ static void add_to_minidump(struct kgsl_device *device)
struct md_region md_entry;
int ret;
if (!msm_minidump_enabled())
if (!msm_minidump_enabled() || device->snapshot_memory.in_minidump)
return;
scnprintf(md_entry.name, sizeof(md_entry.name), "GPU_SNAPSHOT");
md_entry.virt_addr = (u64)(device->snapshot_memory.ptr);
md_entry.phys_addr = __pa(device->snapshot_memory.ptr);
md_entry.size = device->snapshot->size;
md_entry.size = device->snapshot_memory.size;
ret = msm_minidump_add_region(&md_entry);
if (ret < 0)
dev_err(device->dev, "Failed to register snapshot with minidump: %d\n", ret);
else
device->snapshot_memory.in_minidump = true;
}
static void obj_itr_init(struct snapshot_obj_itr *itr, u8 *buf,
@ -1165,6 +1167,7 @@ void kgsl_device_snapshot_probe(struct kgsl_device *device, u32 size)
return;
}
device->snapshot_memory.in_minidump = false;
device->snapshot = NULL;
device->snapshot_faultcount = 0;
device->force_panic = false;
@ -1195,6 +1198,17 @@ void kgsl_device_snapshot_probe(struct kgsl_device *device, u32 size)
*/
void kgsl_device_snapshot_close(struct kgsl_device *device)
{
if (msm_minidump_enabled() && device->snapshot_memory.in_minidump) {
struct md_region md_entry;
scnprintf(md_entry.name, sizeof(md_entry.name), "GPU_SNAPSHOT");
md_entry.virt_addr = (u64)(device->snapshot_memory.ptr);
md_entry.phys_addr = __pa(device->snapshot_memory.ptr);
md_entry.size = device->snapshot_memory.size;
if (msm_minidump_remove_region(&md_entry) < 0)
dev_err(device->dev, "Failed to remove snapshot with minidump\n");
}
sysfs_remove_bin_file(&device->snapshot_kobj, &snapshot_attr);
sysfs_remove_files(&device->snapshot_kobj, snapshot_attrs);