Skip to contentSkip to conversation

mips: Fix using smp_processor_id() when preemptible

PATCH In review [email protected] 2 participants 2 messages Aug 9, 2017 – Aug 10, 2017 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: Fix using smp_processor_id() when preemptible

From: Corey Minyard <[email protected]>

I was getting the following:

BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
caller is pcibios_set_cache_line_size+0x10/0x58

pcibios_set_cache_line_size() used current_cpu_data outside of an unpreemptible context.

---
 arch/mips/pci/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/mips/pci/pci.c +4 -1
index bd67ac7..afd2f8a 100644
@@ -28,9 +28,11 @@ EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
 
 static int __init pcibios_set_cache_line_size(void)
 {
-	struct cpuinfo_mips *c = &current_cpu_data;
+	struct cpuinfo_mips *c;
 	unsigned int lsize;
 
+	preempt_disable();
+	c = &current_cpu_data;
 	/*
 	 * Set PCI cacheline size to that of the highest level in the
 	 * cache hierarchy.
@@ -38,6 +40,7 @@ static int __init pcibios_set_cache_line_size(void)
 	lsize = c->dcache.linesz;
 	lsize = c->scache.linesz ? : lsize;
 	lsize = c->tcache.linesz ? : lsize;
+	preempt_enable();
 
 	BUG_ON(!lsize);
 
Signature · 1 line
2.7.4
#1 lore raw

Hi Corey,

This has already been fixed here:
https://git.linux-mips.org/cgit/ralf/upstream-sfr.git/commit/?id=21da5332327b6d183bd93336ecf29c70bc609b7b

https://git.linux-mips.org/cgit/ralf/upstream-sfr.git/commit/?id=735302665c353d6756e7fa2a2cf41b039299f732

Marcin

Quoted 41 lines · On 09.08.2017 23:25, [email protected] wrote:

From: Corey Minyard <[email protected]>

I was getting the following:

BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
caller is pcibios_set_cache_line_size+0x10/0x58

pcibios_set_cache_line_size() used current_cpu_data outside of an unpreemptible context.

---
  arch/mips/pci/pci.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
arch/mips/pci/pci.c +4 -1
index bd67ac7..afd2f8a 100644
@@ -28,9 +28,11 @@ EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
 
  static int __init pcibios_set_cache_line_size(void)
  {
-	struct cpuinfo_mips *c = &current_cpu_data;
+	struct cpuinfo_mips *c;
  	unsigned int lsize;
 
+	preempt_disable();
+	c = &current_cpu_data;
  	/*
  	 * Set PCI cacheline size to that of the highest level in the
  	 * cache hierarchy.
@@ -38,6 +40,7 @@ static int __init pcibios_set_cache_line_size(void)
  	lsize = c->dcache.linesz;
  	lsize = c->scache.linesz ? : lsize;
  	lsize = c->tcache.linesz ? : lsize;
+	preempt_enable();
 
  	BUG_ON(!lsize);