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

Commit d01447b3 authored by Paul Mundt's avatar Paul Mundt
Browse files

sh: Merge legacy and dynamic PMB modes.



This implements a bit of rework for the PMB code, which permits us to
kill off the legacy PMB mode completely. Rather than trusting the boot
loader to do the right thing, we do a quick verification of the PMB
contents to determine whether to have the kernel setup the initial
mappings or whether it needs to mangle them later on instead.

If we're booting from legacy mappings, the kernel will now take control
of them and make them match the kernel's initial mapping configuration.
This is accomplished by breaking the initialization phase out in to
multiple steps: synchronization, merging, and resizing. With the recent
rework, the synchronization code establishes page links for compound
mappings already, so we build on top of this for promoting mappings and
reclaiming unused slots.

At the same time, the changes introduced for the uncached helpers also
permit us to dynamically resize the uncached mapping without any
particular headaches. The smallest page size is more than sufficient for
mapping all of kernel text, and as we're careful not to jump to any far
off locations in the setup code the mapping can safely be resized
regardless of whether we are executing from it or not.

Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 2e450643
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ void decompress_kernel(void)
	output_addr = (CONFIG_MEMORY_START + 0x2000);
#else
	output_addr = __pa((unsigned long)&_text+PAGE_SIZE);
#if defined(CONFIG_29BIT) || defined(CONFIG_PMB_LEGACY)
#if defined(CONFIG_29BIT)
	output_addr |= P2SEG;
#endif
#endif
+3 −9
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ typedef struct {
long pmb_remap(unsigned long virt, unsigned long phys,
	       unsigned long size, pgprot_t prot);
void pmb_unmap(unsigned long addr);
int pmb_init(void);
void pmb_init(void);
bool __in_29bit_mode(void);
#else
static inline long pmb_remap(unsigned long virt, unsigned long phys,
@@ -67,14 +67,8 @@ static inline long pmb_remap(unsigned long virt, unsigned long phys,
	return -EINVAL;
}

static inline void pmb_unmap(unsigned long addr)
{
}

static inline int pmb_init(void)
{
	return -ENODEV;
}
#define pmb_unmap(addr)		do { } while (0)
#define pmb_init(addr)		do { } while (0)

#ifdef CONFIG_29BIT
#define __in_29bit_mode()	(1)
+1 −10
Original line number Diff line number Diff line
@@ -45,21 +45,12 @@
#endif

#ifndef __ASSEMBLY__
#include <asm/uncached.h>

extern unsigned long shm_align_mask;
extern unsigned long max_low_pfn, min_low_pfn;
extern unsigned long memory_start, memory_end;

#ifdef CONFIG_UNCACHED_MAPPING
extern unsigned long uncached_start, uncached_end;

extern int virt_addr_uncached(unsigned long kaddr);
extern void uncached_init(void);
#else
#define virt_addr_uncached(kaddr)	(0)
#define uncached_init()			do { } while (0)
#endif

static inline unsigned long
pages_do_alias(unsigned long addr1, unsigned long addr2)
{
+18 −0
Original line number Diff line number Diff line
#ifndef __ASM_SH_UNCACHED_H
#define __ASM_SH_UNCACHED_H

#include <linux/bug.h>

#ifdef CONFIG_UNCACHED_MAPPING
extern unsigned long uncached_start, uncached_end;

extern int virt_addr_uncached(unsigned long kaddr);
extern void uncached_init(void);
extern void uncached_resize(unsigned long size);
#else
#define virt_addr_uncached(kaddr)	(0)
#define uncached_init()			do { } while (0)
#define uncached_resize(size)		BUG()
#endif

#endif /* __ASM_SH_UNCACHED_H */
+38 −4
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ ENTRY(_stext)
	ldc	r0, r7_bank	! ... and initial thread_info
#endif

#if defined(CONFIG_PMB) && !defined(CONFIG_PMB_LEGACY)
#ifdef CONFIG_PMB
/*
 * Reconfigure the initial PMB mappings setup by the hardware.
 *
@@ -139,7 +139,6 @@ ENTRY(_stext)
	mov.l	r0, @r1

	mov.l	.LMEMORY_SIZE, r5
	mov	r5, r7

	mov	#PMB_E_SHIFT, r0
	mov	#0x1, r4
@@ -150,6 +149,40 @@ ENTRY(_stext)
	mov.l	.LFIRST_ADDR_ENTRY, r2
	mov.l	.LPMB_ADDR, r3

	/*
	 * First we need to walk the PMB and figure out if there are any
	 * existing mappings that match the initial mappings VPN/PPN.
	 * If these have already been established by the bootloader, we
	 * don't bother setting up new entries here, and let the late PMB
	 * initialization take care of things instead.
	 *
	 * Note that we may need to coalesce and merge entries in order
	 * to reclaim more available PMB slots, which is much more than
	 * we want to do at this early stage.
	 */
	mov	#0, r10
	mov	#NR_PMB_ENTRIES, r9

	mov	r1, r7		/* temporary PMB_DATA iter */

.Lvalidate_existing_mappings:

	mov.l	@r7, r8
	and	r0, r8
	cmp/eq	r0, r8		/* Check for valid __MEMORY_START mappings */
	bt	.Lpmb_done

	add	#1, r10		/* Increment the loop counter */
	cmp/eq	r9, r10
	bf/s	.Lvalidate_existing_mappings
	 add	r4, r7		/* Increment to the next PMB_DATA entry */

	/*
	 * If we've fallen through, continue with setting up the initial
	 * mappings.
	 */

	mov	r5, r7		/* cached_to_uncached */
	mov	#0, r10

#ifdef CONFIG_UNCACHED_MAPPING
@@ -252,7 +285,8 @@ ENTRY(_stext)
	mov.l	6f, r0
	icbi	@r0

#endif /* !CONFIG_PMB_LEGACY */
.Lpmb_done:
#endif /* CONFIG_PMB */

#ifndef CONFIG_SH_NO_BSS_INIT
	/*
@@ -304,7 +338,7 @@ ENTRY(stack_start)
6:	.long	sh_cpu_init
7:	.long	init_thread_union

#if defined(CONFIG_PMB) && !defined(CONFIG_PMB_LEGACY)
#ifdef CONFIG_PMB
.LPMB_ADDR:		.long	PMB_ADDR
.LPMB_DATA:		.long	PMB_DATA
.LFIRST_ADDR_ENTRY:	.long	PAGE_OFFSET | PMB_V
Loading