mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-25 12:37:11 +08:00
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> Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
#include <asm/pgtable-bits.h>
|
#include <asm/pgtable-bits.h>
|
||||||
#include <asm/string.h>
|
#include <asm/string.h>
|
||||||
|
|
||||||
extern void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size);
|
extern void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size);
|
||||||
extern void __init early_iounmap(void __iomem *addr, unsigned long size);
|
extern void __init early_iounmap(void __iomem *addr, unsigned long size);
|
||||||
|
|
||||||
#define early_memremap early_ioremap
|
#define early_memremap early_ioremap
|
||||||
@@ -25,6 +25,9 @@ extern void __init early_iounmap(void __iomem *addr, unsigned long size);
|
|||||||
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
|
static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
|
||||||
unsigned long prot_val)
|
unsigned long prot_val)
|
||||||
{
|
{
|
||||||
|
if (offset > TO_PHYS_MASK)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
switch (prot_val & _CACHE_MASK) {
|
switch (prot_val & _CACHE_MASK) {
|
||||||
case _CACHE_CC:
|
case _CACHE_CC:
|
||||||
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
|
return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <asm-generic/early_ioremap.h>
|
#include <asm-generic/early_ioremap.h>
|
||||||
|
|
||||||
void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size)
|
void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size)
|
||||||
{
|
{
|
||||||
return ((void __iomem *)TO_CACHE(phys_addr));
|
return ((void __iomem *)TO_CACHE(phys_addr));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user