Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 004d05d4 authored by Neeraj Upadhyay's avatar Neeraj Upadhyay
Browse files

soc: qcom: Improve msm_minidump_remove_region api



Improve the api to better handle certain error scenarios
and move console prints outside of irq/locked code
sections.

Change-Id: I0ec6f37400949c014ea2e94f61a239294c954bf5
Signed-off-by: default avatarNeeraj Upadhyay <neeraju@codeaurora.org>
parent be60e6e7
Loading
Loading
Loading
Loading
+16 −18
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "Minidump: " fmt
@@ -371,7 +371,7 @@ int msm_minidump_clear_headers(const struct md_region *entry)

int msm_minidump_remove_region(const struct md_region *entry)
{
	int rcount, ecount, seq = 0, rgno, ret;
	int rcount, ecount, seq = 0, rgno, entryno, ret;
	unsigned long flags;

	if (!entry || !minidump_table.md_ss_toc ||
@@ -381,30 +381,28 @@ int msm_minidump_remove_region(const struct md_region *entry)

	spin_lock_irqsave(&mdt_lock, flags);
	write_lock(&mdt_remove_lock);
	entryno = md_entry_num(entry);
	rgno = md_region_num(entry->name, &seq);
	if (entryno < 0 || rgno < 0) {
		write_unlock(&mdt_remove_lock);
		spin_unlock_irqrestore(&mdt_lock, flags);
		pr_err("Not able to find the entry %s (%d,%d) in table\n",
			entry->name, entryno, rgno);
		return -EINVAL;
	}
	ecount = minidump_table.num_regions;
	rcount = minidump_table.md_ss_toc->ss_region_count;
	rgno = md_entry_num(entry);
	if (rgno < 0) {
		pr_err("Not able to find the entry in table\n");
		goto out;
	}

	if (first_removed_entry > rgno)
		first_removed_entry = rgno;
	if (first_removed_entry > entryno)
		first_removed_entry = entryno;
	minidump_table.md_ss_toc->md_ss_toc_init = 0;

	/* Remove entry from: entry list, ss region list and elf header */
	memmove(&minidump_table.entry[rgno], &minidump_table.entry[rgno + 1],
		((ecount - rgno - 1) * sizeof(struct md_region)));
	memmove(&minidump_table.entry[entryno],
		&minidump_table.entry[entryno + 1],
		((ecount - entryno - 1) * sizeof(struct md_region)));
	memset(&minidump_table.entry[ecount - 1], 0, sizeof(struct md_region));


	rgno = md_region_num(entry->name, &seq);
	if (rgno < 0) {
		pr_err("Not able to find region in table\n");
		goto out;
	}

	memmove(&minidump_table.md_regions[rgno],
		&minidump_table.md_regions[rgno + 1],
		((rcount - rgno - 1) * sizeof(struct md_ss_region)));