aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2007-07-26 21:38:35 +0000
committerFelix Fietkau <nbd@openwrt.org>2007-07-26 21:38:35 +0000
commit76da233e45fc92c401dc7337914defaa87c9d3eb (patch)
tree448613dc1ce53fd11b3ffd9b1c13f678e5590d89 /target/linux
parent8f31903a953958707e1d00222ce312c0edf69497 (diff)
downloadupstream-76da233e45fc92c401dc7337914defaa87c9d3eb.tar.gz
upstream-76da233e45fc92c401dc7337914defaa87c9d3eb.tar.bz2
upstream-76da233e45fc92c401dc7337914defaa87c9d3eb.zip
protect the adm5120 pci ops with a spinlock - fixes race conditions that happened in combination with madwifi and more than one card
SVN-Revision: 8186
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/adm5120-2.6/files/arch/mips/pci/ops-adm5120.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/target/linux/adm5120-2.6/files/arch/mips/pci/ops-adm5120.c b/target/linux/adm5120-2.6/files/arch/mips/pci/ops-adm5120.c
index f7e4e6686f..0bd0baa8da 100644
--- a/target/linux/adm5120-2.6/files/arch/mips/pci/ops-adm5120.c
+++ b/target/linux/adm5120-2.6/files/arch/mips/pci/ops-adm5120.c
@@ -28,6 +28,7 @@
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/pci.h>
+#include <linux/spinlock.h>
#include <asm/mach-adm5120/adm5120_defs.h>
@@ -40,6 +41,8 @@
#define PCI_ENABLE 0x80000000
+static spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
+
static inline void write_cfgaddr(u32 addr)
{
*(volatile u32*)KSEG1ADDR(ADM5120_PCICFG_ADDR) = (addr | PCI_ENABLE);
@@ -65,8 +68,10 @@ static inline u32 mkaddr(struct pci_bus *bus, unsigned int devfn, int where)
static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *val)
{
+ unsigned long flags;
u32 data;
+ spin_lock_irqsave(&pci_lock, flags);
write_cfgaddr(mkaddr(bus,devfn,where));
data = read_cfgdata();
@@ -90,6 +95,7 @@ static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
*val = data;
DBG(", 0x%08X returned\n", data);
+ spin_unlock_irqrestore(&pci_lock, flags);
return PCIBIOS_SUCCESSFUL;
}
@@ -97,9 +103,11 @@ static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 val)
{
+ unsigned long flags;
u32 data;
int s;
+ spin_lock_irqsave(&pci_lock, flags);
write_cfgaddr(mkaddr(bus,devfn,where));
data = read_cfgdata();
@@ -124,6 +132,7 @@ static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
write_cfgdata(data);
DBG(", 0x%08X written\n", data);
+ spin_unlock_irqrestore(&pci_lock, flags);
return PCIBIOS_SUCCESSFUL;
}