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

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

sh: fixed PMB mode refactoring.



This introduces some much overdue chainsawing of the fixed PMB support.
fixed PMB was introduced initially to work around the fact that dynamic
PMB mode was relatively broken, though they were never intended to
converge. The main areas where there are differences are whether the
system is booted in 29-bit mode or 32-bit mode, and whether legacy
mappings are to be preserved. Any system booting in true 32-bit mode will
not care about legacy mappings, so these are roughly decoupled.

Regardless of the entry point, PMB and 32BIT are directly related as far
as the kernel is concerned, so we also switch back to having one select
the other.

With legacy mappings iterated through and applied in the initialization
path it's now possible to finally merge the two implementations and
permit dynamic remapping overtop of remaining entries regardless of
whether boot mappings are crafted by hand or inherited from the boot
loader.

Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 7f33306e
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -46,15 +46,8 @@ $(obj)/romImage: $(obj)/romimage/vmlinux FORCE
$(obj)/romimage/vmlinux: $(obj)/zImage FORCE
	$(Q)$(MAKE) $(build)=$(obj)/romimage $@

KERNEL_MEMORY := 0x00000000
ifeq ($(CONFIG_PMB_FIXED),y)
KERNEL_MEMORY	:= $(shell /bin/bash -c 'printf "0x%08x" \
		     $$[$(CONFIG_MEMORY_START) & 0x1fffffff]')
endif
ifeq ($(CONFIG_29BIT),y)
KERNEL_MEMORY := $(shell /bin/bash -c 'printf "0x%08x" \
		     $$[$(CONFIG_MEMORY_START)]')
endif

KERNEL_LOAD	:= $(shell /bin/bash -c 'printf "0x%08x" \
		     $$[$(CONFIG_PAGE_OFFSET)  + \
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
/* Returns the privileged segment base of a given address  */
#define PXSEG(a)	(((unsigned long)(a)) & 0xe0000000)

#if defined(CONFIG_29BIT) || defined(CONFIG_PMB_FIXED)
#ifdef CONFIG_29BIT
/*
 * Map an address to a certain privileged segment
 */
@@ -40,7 +40,7 @@
	((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG))
#define P4SEGADDR(a)	\
	((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG))
#endif /* 29BIT || PMB_FIXED */
#endif /* 29BIT */
#endif /* P1SEG */

/* Check if an address can be reached in 29 bits */
+18 −9
Original line number Diff line number Diff line
@@ -244,18 +244,11 @@ __ioremap(unsigned long offset, unsigned long size, unsigned long flags)
}

static inline void __iomem *
__ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
__ioremap_29bit(unsigned long offset, unsigned long size, unsigned long flags)
{
#if defined(CONFIG_SUPERH32) && !defined(CONFIG_PMB_FIXED) && !defined(CONFIG_PMB)
#ifdef CONFIG_29BIT
	unsigned long last_addr = offset + size - 1;
#endif
	void __iomem *ret;

	ret = __ioremap_trapped(offset, size);
	if (ret)
		return ret;

#if defined(CONFIG_SUPERH32) && !defined(CONFIG_PMB_FIXED) && !defined(CONFIG_PMB)
	/*
	 * For P1 and P2 space this is trivial, as everything is already
	 * mapped. Uncached access for P1 addresses are done through P2.
@@ -274,6 +267,22 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
		return (void __iomem *)P4SEGADDR(offset);
#endif

	return NULL;
}

static inline void __iomem *
__ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
{
	void __iomem *ret;

	ret = __ioremap_trapped(offset, size);
	if (ret)
		return ret;

	ret = __ioremap_29bit(offset, size, flags);
	if (ret)
		return ret;

	return __ioremap(offset, size, flags);
}
#else
+18 −0
Original line number Diff line number Diff line
@@ -65,11 +65,29 @@ struct pmb_entry {
	struct pmb_entry *link;
};

#ifdef CONFIG_PMB
/* arch/sh/mm/pmb.c */
long pmb_remap(unsigned long virt, unsigned long phys,
	       unsigned long size, unsigned long flags);
void pmb_unmap(unsigned long addr);
int pmb_init(void);
#else
static inline long pmb_remap(unsigned long virt, unsigned long phys,
			     unsigned long size, unsigned long flags)
{
	return -EINVAL
}

static inline void pmb_unmap(unsigned long addr)
{
}

static inline int pmb_init(void)
{
	return -ENODEV;
}
#endif /* CONFIG_PMB */

#endif /* __ASSEMBLY__ */

#endif /* __MMU_H */
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ typedef struct page *pgtable_t;
 * is not visible (it is part of the PMB mapping) and so needs to be
 * added or subtracted as required.
 */
#if defined(CONFIG_PMB_FIXED)
#if defined(CONFIG_PMB_LEGACY)
/* phys = virt - PAGE_OFFSET - (__MEMORY_START & 0xe0000000) */
#define PMB_OFFSET	(PAGE_OFFSET - PXSEG(__MEMORY_START))
#define __pa(x)	((unsigned long)(x) - PMB_OFFSET)
Loading