From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: ARC-Seal: i=1; a=rsa-sha256; t=1516758463; cv=none; d=google.com; s=arc-20160816; b=sPlMEs/XIdor6LsettRtX+VkG3aGczCV+Dj6GjMnHXd6knraXp2SKGl6xijIrn/oDD b8NY0VPGLR/GqvDoSClBTdenNNrf6Qv6Jzmzpe3T2oS4M65keEACy+u5LyrZJhuypxOt le3N4hVi3AVxA3TjTaElpay4X/iqALaWCF4IQJihya2IG3t/shyGmkT4ijBphpdBYg1L zc5/CMheG4yS7GdQpjSGolVUMnkrJWKFdbaTW27aZRYB1c5NG6ra8lb7+urefbHY/JMm 5/k+IMCYXIu+Ze2hn3n9JusnS2x819tYTuc/TGNXcXyplawWNOnpFu53LYEZCMS7ZiDF 5CWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=+6BOLDAHz8jA3U5+rsbM16zt0QbGjlQq3upvatb+0Yc=; b=Y5Q5/+y5lBZ1gZcZ4ugpk/oFrspC+z9KnFRSvEi9bdnKZtzrJ1qEnsk4cyZ2elRDgb E2XSvHoAqTni3hRDrJWMtDt31HvtApIoajvs4T6v1Q6k1ZPssrinDUD+EHZFHEkBzKln QWu6CgET/fYsy00HphDIRM3DCxDSaN8iiuJOEDu6hIJSLtwLVask4i2YhnEJfbhuijrd ZgIuskk+vZd/5Jq/aktD1ync+KVNe1gI1JwUM4I3Ge/5F1BV45aMCpFDkgMfMOYdBLgv EComT1yQQROP8OQ/A3pdJLy7RgTn88npad4GYZ682mLx8qW04q6QLsbTFSCeu4/Z87pE Zf3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bteDOAuW; spf=pass (google.com: domain of f.fainelli@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=f.fainelli@gmail.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bteDOAuW; spf=pass (google.com: domain of f.fainelli@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=f.fainelli@gmail.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com X-Google-Smtp-Source: AH8x226tFovb2Ggi7FT2ihEgw8zhdUdh29Q8vBYi5XXB5sKoTQDfh/qGpcF5hiYrE+5r1d/3bBrCXA== From: Florian Fainelli To: linux-mips@linux-mips.org Cc: Florian Fainelli , Florian Fainelli , Ralf Baechle , Kevin Cernekee , James Hogan , Paul Burton , Matt Redfearn , "Maciej W. Rozycki" , Huacai Chen , Kate Stewart , Greg Kroah-Hartman , Marcin Nowakowski , Andrew Morton , "Eric W. Biederman" , Ingo Molnar , David Howells , Kees Cook , Thomas Meyer , "Bryan O'Donoghue" , Robin Murphy , Michal Hocko , Lucas Stach , Vladimir Murzin , Bart Van Assche , linux-kernel@vger.kernel.org (open list) Subject: [PATCH RFC 4/6] MIPS: Prepare for supporting eXtended KSEG0/1 Date: Tue, 23 Jan 2018 17:47:04 -0800 Message-Id: <1516758426-8127-5-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516758426-8127-1-git-send-email-f.fainelli@gmail.com> References: <1516758426-8127-1-git-send-email-f.fainelli@gmail.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590436522427541627?= X-GMAIL-MSGID: =?utf-8?q?1590436522427541627?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: From: Florian Fainelli Prepare the core MIPS files to support Broadcom's eXtended KSEG0/1: - add MIPS_CPU_XKS01 feature flag - flag BMIPS4380/5000/5200 with MIPS_CPU_XKS01 - update ioremap and CAC_ADDR() checks Signed-off-by: Florian Fainelli --- arch/mips/include/asm/cpu-features.h | 8 ++++++++ arch/mips/include/asm/cpu.h | 1 + arch/mips/include/asm/io.h | 18 ++++++++++-------- arch/mips/include/asm/page.h | 4 ++++ arch/mips/kernel/cpu-probe.c | 3 ++- arch/mips/mm/ioremap.c | 16 +++++++++------- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 721b698bfe3c..43e1163921a9 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -623,4 +623,12 @@ #define cpu_guest_has_dyn_maar (cpu_data[0].guest.options_dyn & MIPS_CPU_MAAR) #endif +#if defined(CONFIG_XKS01) +#ifndef cpu_has_xks01 +# define cpu_has_xks01 (cpu_data[0].options & MIPS_CPU_XKS01) +#endif +#else +# define cpu_has_xks01 0 +#endif /* CONFIG_XKS01 */ + #endif /* __ASM_CPU_FEATURES_H */ diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h index d39324c4adf1..298356b9f7e6 100644 --- a/arch/mips/include/asm/cpu.h +++ b/arch/mips/include/asm/cpu.h @@ -418,6 +418,7 @@ enum cpu_type_enum { MBIT_ULL(54) /* CPU shares FTLB RAM with another */ #define MIPS_CPU_SHARED_FTLB_ENTRIES \ MBIT_ULL(55) /* CPU shares FTLB entries with another */ +#define MIPS_CPU_XKS01 MBIT_ULL(56) /* CPU has eXtended KSEG0/1 */ /* * CPU ASE encodings diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index 0cbf3af37eca..9f4ac0c394be 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -206,14 +206,16 @@ static inline void __iomem * __ioremap_mode(phys_addr_t offset, unsigned long si if (!size || last_addr < phys_addr) return NULL; - /* - * Map uncached objects in the low 512MB of address - * space using KSEG1. - */ - if (__IS_LOW512(phys_addr) && __IS_LOW512(last_addr) && - flags == _CACHE_UNCACHED) - return (void __iomem *) - (unsigned long)CKSEG1ADDR(phys_addr); + if (likely(!cpu_has_xks01)) { + /* + * Map uncached objects in the low 512MB of address + * space using KSEG1. + */ + if (__IS_LOW512(phys_addr) && __IS_LOW512(last_addr) && + flags == _CACHE_UNCACHED) + return (void __iomem *) + (unsigned long)CKSEG1ADDR(phys_addr); + } } return __ioremap(offset, size, flags); diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h index ad461216b5a1..7b8eea14b80e 100644 --- a/arch/mips/include/asm/page.h +++ b/arch/mips/include/asm/page.h @@ -252,8 +252,12 @@ extern int __virt_addr_valid(const volatile void *kaddr); ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) +#ifdef CONFIG_XKS01 +#define CAC_ADDR(addr) ({ BUG(); NULL; }) +#else #define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE) #define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET) +#endif #include #include diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index cf3fd549e16d..200087ce9963 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -1760,6 +1760,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) __cpu_name[cpu] = "Broadcom BMIPS4380"; set_elf_platform(cpu, "bmips4380"); c->options |= MIPS_CPU_RIXI; + c->options |= MIPS_CPU_XKS01; } else { c->cputype = CPU_BMIPS4350; __cpu_name[cpu] = "Broadcom BMIPS4350"; @@ -1775,7 +1776,7 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) else __cpu_name[cpu] = "Broadcom BMIPS5000"; set_elf_platform(cpu, "bmips5000"); - c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI; + c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI | MIPS_CPU_XKS01; break; } } diff --git a/arch/mips/mm/ioremap.c b/arch/mips/mm/ioremap.c index 1986e09fb457..f8fd14188909 100644 --- a/arch/mips/mm/ioremap.c +++ b/arch/mips/mm/ioremap.c @@ -128,13 +128,15 @@ void __iomem * __ioremap(phys_addr_t phys_addr, phys_addr_t size, unsigned long if (!size || last_addr < phys_addr) return NULL; - /* - * Map uncached objects in the low 512mb of address space using KSEG1, - * otherwise map using page tables. - */ - if (IS_LOW512(phys_addr) && IS_LOW512(last_addr) && - flags == _CACHE_UNCACHED) - return (void __iomem *) CKSEG1ADDR(phys_addr); + if (likely(!cpu_has_xks01)) { + /* + * Map uncached objects in the low 512mb of address space using + * KSEG1, otherwise map using page tables. + */ + if (IS_LOW512(phys_addr) && IS_LOW512(last_addr) && + flags == _CACHE_UNCACHED) + return (void __iomem *) CKSEG1ADDR(phys_addr); + } /* * Don't allow anybody to remap normal RAM that we're using.. -- 2.7.4