Skip to content

Commit 43a9e6a

Browse files
committed
LoongArch: Consolidate early_ioremap()/ioremap_prot()
1. Use phys_addr_t instead of u64, which can work for both 32/64 bits. 2. Check whether the input physical address is above TO_PHYS_MASK (and return NULL if yes) for the DMW version. Note: In theory early_ioremap() also need the TO_PHYS_MASK checking, but the UEFI BIOS pass some DMW virtual addresses. Cc: stable@vger.kernel.org Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 4e67526 commit 43a9e6a

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

arch/loongarch/include/asm/io.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <asm/pgtable-bits.h>
1515
#include <asm/string.h>
1616

17-
extern void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size);
17+
extern void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size);
1818
extern void __init early_iounmap(void __iomem *addr, unsigned long size);
1919

2020
#define early_memremap early_ioremap
@@ -25,6 +25,9 @@ extern void __init early_iounmap(void __iomem *addr, unsigned long size);
2525
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
2626
pgprot_t prot)
2727
{
28+
if (offset > TO_PHYS_MASK)
29+
return NULL;
30+
2831
switch (pgprot_val(prot) & _CACHE_MASK) {
2932
case _CACHE_CC:
3033
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);

arch/loongarch/mm/ioremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <asm/io.h>
77
#include <asm-generic/early_ioremap.h>
88

9-
void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size)
9+
void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size)
1010
{
1111
return ((void __iomem *)TO_CACHE(phys_addr));
1212
}

0 commit comments

Comments
 (0)