Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1310155 > unrolled thread

[4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()

Started byGrygorii Strashko <grygorii.strashko@ti.com>
First post2016-01-15 15:30 +0100
Last post2016-01-20 21:30 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps() Grygorii Strashko <grygorii.strashko@ti.com> - 2016-01-15 15:30 +0100
    Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN  in switch_kmaps() Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-01-15 18:00 +0100
    Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN  in switch_kmaps() Russell King - ARM Linux <linux@arm.linux.org.uk> - 2016-01-20 21:30 +0100
      Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in  switch_kmaps() Grygorii Strashko <grygorii.strashko@ti.com> - 2016-01-20 21:40 +0100
    Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN  in switch_kmaps() Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2016-01-20 21:30 +0100

#1310155 — [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()

FromGrygorii Strashko <grygorii.strashko@ti.com>
Date2016-01-15 15:30 +0100
Subject[4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()
Message-ID<qRdy2-7l8-13@gated-at.bofh.it>
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 <grygorii.strashko@ti.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 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

[toc] | [next] | [standalone]


#1310276 — Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2016-01-15 18:00 +0100
SubjectRe: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()
Message-ID<qRfTc-p1-21@gated-at.bofh.it>
In reply to#1310155
* Grygorii Strashko | 2016-01-15 16:20:47 [+0200]:

>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.

Thank you debugging and fixing this. I will fold this into the initial
patch since it is a v4.1..v4.4 fallout. Regarding your "nobody else be
me" question in the other mail: once I managed something ARM+highmem I
I see this:

|Welcome to Debian GNU/Linux stretch/sid!
|
|[   11.738637] systemd[1]: Set hostname to <vexpress>.
|[   11.909949] ------------[ cut here ]------------
|[   11.909958] kernel BUG at arch/arm/mm/highmem.c:90!

So I did not get as far as a shell to start anything.

>Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Sebastian

[toc] | [prev] | [next] | [standalone]


#1313510 — Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()

FromRussell King - ARM Linux <linux@arm.linux.org.uk>
Date2016-01-20 21:30 +0100
SubjectRe: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()
Message-ID<qT7yb-3ae-35@gated-at.bofh.it>
In reply to#1310155
On Wed, Jan 20, 2016 at 09:21:39PM +0100, Sebastian Andrzej Siewior wrote:
> * Grygorii Strashko | 2016-01-15 16:20:47 [+0200]:
> 
> >--- a/arch/arm/mm/highmem.c
> >+++ b/arch/arm/mm/highmem.c
> >@@ -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]);
> 
> Grygorii, if you remove this chunk then it should apply upstream. Could
> you forward it upstream then please? So the -RT piece would shrink a
> little:)

Or I could commit my own patch which forms a proportion of this change.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

[toc] | [prev] | [next] | [standalone]


#1313515 — Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()

FromGrygorii Strashko <grygorii.strashko@ti.com>
Date2016-01-20 21:40 +0100
SubjectRe: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()
Message-ID<qT7HQ-3eL-17@gated-at.bofh.it>
In reply to#1313510
On 01/20/2016 10:23 PM, Russell King - ARM Linux wrote:
> On Wed, Jan 20, 2016 at 09:21:39PM +0100, Sebastian Andrzej Siewior wrote:
>> * Grygorii Strashko | 2016-01-15 16:20:47 [+0200]:
>>
>>> --- a/arch/arm/mm/highmem.c
>>> +++ b/arch/arm/mm/highmem.c
>>> @@ -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]);
>>
>> Grygorii, if you remove this chunk then it should apply upstream. Could
>> you forward it upstream then please? So the -RT piece would shrink a
>> little:)
>
> Or I could commit my own patch which forms a proportion of this change.
>

np from my side.

-- 
regards,
-grygorii

[toc] | [prev] | [next] | [standalone]


#1313511 — Re: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()

FromSebastian Andrzej Siewior <bigeasy@linutronix.de>
Date2016-01-20 21:30 +0100
SubjectRe: [4.4-rt2 PATCH] ARM: highmem: take into account FIX_KMAP_BEGIN in switch_kmaps()
Message-ID<qT7yb-3ae-37@gated-at.bofh.it>
In reply to#1310155
* Grygorii Strashko | 2016-01-15 16:20:47 [+0200]:

>--- a/arch/arm/mm/highmem.c
>+++ b/arch/arm/mm/highmem.c
>@@ -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]);

Grygorii, if you remove this chunk then it should apply upstream. Could
you forward it upstream then please? So the -RT piece would shrink a
little:)

Sebastian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web