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

Commit 6e731105 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: mem-offline: Restore page table mappings properly in online path"

parents 24ed5bd0 f400169d
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/memory.h>
#include <linux/module.h>
#include <linux/memblock.h>
#include <linux/mmu_context.h>
#include <linux/mmzone.h>
#include <linux/ktime.h>
#include <linux/of.h>
@@ -93,6 +94,22 @@ static void clear_pgtable_mapping(phys_addr_t start, phys_addr_t end)
	flush_tlb_kernel_range(virt, addr_end);
}

static void init_pgtable_mapping(phys_addr_t start, phys_addr_t end)
{
	unsigned long size = end - start;

	/*
	 * When rodata_full is enabled, memory is mapped at a page size
	 * granule, as opposed to a block mapping, so restore the attribute
	 * of each PTE when rodata_full is enabled.
	 */
	if (rodata_full)
		set_memory_valid((unsigned long)phys_to_virt(start),
				 size >> PAGE_SHIFT, (int)true);
	else
		create_pgtable_mapping(start, end);
}

static void record_stat(unsigned long sec, ktime_t delay, int mode)
{
	unsigned int total_sec = end_section_nr - start_section_nr + 1;
@@ -324,7 +341,7 @@ static int mem_event_callback(struct notifier_block *self,

		if (!debug_pagealloc_enabled()) {
			/* Create kernel page-tables */
			create_pgtable_mapping(start_addr, end_addr);
			init_pgtable_mapping(start_addr, end_addr);
		}

		break;