From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753543AbcAOOWD (ORCPT ); Fri, 15 Jan 2016 09:22:03 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:46807 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753309AbcAOOWA (ORCPT ); Fri, 15 Jan 2016 09:22:00 -0500 From: Grygorii Strashko To: , Russell King , CC: , , Sekhar Nori , Grygorii Strashko Subject: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps() Date: Fri, 15 Jan 2016 16:20:47 +0200 Message-ID: <1452867647-1410-1-git-send-email-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.7.0 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now the random crashes are observed on ARM TI am437x-idk-evm used with -RT Kernel v4.4-rt2 and with Highmem enabled. The reason of issue is that, newly introduced switch_kmaps() does not take into account FIX_KMAP_BEGIN, which was re-added by commit a5f4c561b3b1 ("ARM: 8415/1: early fixmap support for earlycon") (K4.3) for ARM and since that the value of FIX_KMAP_BEGIN is not 0 any more. Hence update switch_kmaps() so it will take into FIX_KMAP_BEGIN while calculating fixmap idx. This patch also introduces fixmap_idx() to make code simpler and remove duplicated code. Signed-off-by: Grygorii Strashko Signed-off-by: Russell King --- arch/arm/mm/highmem.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index deabc36..542692d 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -34,6 +34,11 @@ static inline pte_t get_fixmap_pte(unsigned long vaddr) return *ptep; } +static unsigned int fixmap_idx(int type) +{ + return FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id(); +} + void *kmap(struct page *page) { might_sleep(); @@ -80,7 +85,7 @@ void *kmap_atomic(struct page *page) type = kmap_atomic_idx_push(); - idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id(); + idx = fixmap_idx(type); vaddr = __fix_to_virt(idx); #ifdef CONFIG_DEBUG_HIGHMEM /* @@ -110,7 +115,7 @@ void __kunmap_atomic(void *kvaddr) if (kvaddr >= (void *)FIXADDR_START) { type = kmap_atomic_idx(); - idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id(); + idx = fixmap_idx(type); if (cache_is_vivt()) __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE); @@ -146,7 +151,7 @@ void *kmap_atomic_pfn(unsigned long pfn) return page_address(page); type = kmap_atomic_idx_push(); - idx = FIX_KMAP_BEGIN + type + KM_TYPE_NR * smp_processor_id(); + idx = fixmap_idx(type); vaddr = __fix_to_virt(idx); #ifdef CONFIG_DEBUG_HIGHMEM BUG_ON(!pte_none(get_fixmap_pte(vaddr))); @@ -167,7 +172,7 @@ void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p) * Clear @prev's kmap_atomic mappings */ for (i = 0; i < prev_p->kmap_idx; i++) { - int idx = i + KM_TYPE_NR * smp_processor_id(); + int idx = fixmap_idx(i); set_fixmap_pte(idx, __pte(0)); } @@ -175,7 +180,7 @@ void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p) * Restore @next_p's kmap_atomic mappings */ for (i = 0; i < next_p->kmap_idx; i++) { - int idx = i + KM_TYPE_NR * smp_processor_id(); + int idx = fixmap_idx(i); if (!pte_none(next_p->kmap_pte[i])) set_fixmap_pte(idx, next_p->kmap_pte[i]); -- 2.7.0