mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-02-09 04:51:55 +02:00
protect the adm5120 pci ops with a spinlock - fixes race conditions that happened in combination with madwifi and more than one card
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8186 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
14a08a0fb2
commit
4921c52586
@ -28,6 +28,7 @@
|
|||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
|
||||||
#include <asm/mach-adm5120/adm5120_defs.h>
|
#include <asm/mach-adm5120/adm5120_defs.h>
|
||||||
|
|
||||||
@ -40,6 +41,8 @@
|
|||||||
|
|
||||||
#define PCI_ENABLE 0x80000000
|
#define PCI_ENABLE 0x80000000
|
||||||
|
|
||||||
|
static spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
|
||||||
|
|
||||||
static inline void write_cfgaddr(u32 addr)
|
static inline void write_cfgaddr(u32 addr)
|
||||||
{
|
{
|
||||||
*(volatile u32*)KSEG1ADDR(ADM5120_PCICFG_ADDR) = (addr | PCI_ENABLE);
|
*(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,
|
static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
|
||||||
int size, u32 *val)
|
int size, u32 *val)
|
||||||
{
|
{
|
||||||
|
unsigned long flags;
|
||||||
u32 data;
|
u32 data;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&pci_lock, flags);
|
||||||
write_cfgaddr(mkaddr(bus,devfn,where));
|
write_cfgaddr(mkaddr(bus,devfn,where));
|
||||||
data = read_cfgdata();
|
data = read_cfgdata();
|
||||||
|
|
||||||
@ -90,6 +95,7 @@ static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
|
|||||||
|
|
||||||
*val = data;
|
*val = data;
|
||||||
DBG(", 0x%08X returned\n", data);
|
DBG(", 0x%08X returned\n", data);
|
||||||
|
spin_unlock_irqrestore(&pci_lock, flags);
|
||||||
|
|
||||||
return PCIBIOS_SUCCESSFUL;
|
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,
|
static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
|
||||||
int size, u32 val)
|
int size, u32 val)
|
||||||
{
|
{
|
||||||
|
unsigned long flags;
|
||||||
u32 data;
|
u32 data;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&pci_lock, flags);
|
||||||
write_cfgaddr(mkaddr(bus,devfn,where));
|
write_cfgaddr(mkaddr(bus,devfn,where));
|
||||||
data = read_cfgdata();
|
data = read_cfgdata();
|
||||||
|
|
||||||
@ -124,6 +132,7 @@ static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
|
|||||||
|
|
||||||
write_cfgdata(data);
|
write_cfgdata(data);
|
||||||
DBG(", 0x%08X written\n", data);
|
DBG(", 0x%08X written\n", data);
|
||||||
|
spin_unlock_irqrestore(&pci_lock, flags);
|
||||||
|
|
||||||
return PCIBIOS_SUCCESSFUL;
|
return PCIBIOS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user