Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 63875
b: refs/heads/master
c: 3320ad9
h: refs/heads/master
i:
  63873: 323d0ce
  63871: 831dcce
v: v3
  • Loading branch information
dean gaudet authored and Linus Torvalds committed Aug 11, 2007
1 parent 68d9d4f commit fdc06be
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9535239f6bc99f68e0cfae44505ad402b53ed24c
refs/heads/master: 3320ad994afb2c44ad34b3b34c3c5cf0da297331
14 changes: 6 additions & 8 deletions trunk/arch/i386/pci/mmconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,15 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus,

switch (len) {
case 1:
*value = readb(mmcfg_virt_addr + reg);
*value = mmio_config_readb(mmcfg_virt_addr + reg);
break;
case 2:
*value = readw(mmcfg_virt_addr + reg);
*value = mmio_config_readw(mmcfg_virt_addr + reg);
break;
case 4:
*value = readl(mmcfg_virt_addr + reg);
*value = mmio_config_readl(mmcfg_virt_addr + reg);
break;
}

spin_unlock_irqrestore(&pci_config_lock, flags);

return 0;
Expand All @@ -116,16 +115,15 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,

switch (len) {
case 1:
writeb(value, mmcfg_virt_addr + reg);
mmio_config_writeb(mmcfg_virt_addr, value);
break;
case 2:
writew(value, mmcfg_virt_addr + reg);
mmio_config_writew(mmcfg_virt_addr, value);
break;
case 4:
writel(value, mmcfg_virt_addr + reg);
mmio_config_writel(mmcfg_virt_addr, value);
break;
}

spin_unlock_irqrestore(&pci_config_lock, flags);

return 0;
Expand Down
43 changes: 43 additions & 0 deletions trunk/arch/i386/pci/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,46 @@ extern DECLARE_BITMAP(pci_mmcfg_fallback_slots, 32*PCI_MMCFG_MAX_CHECK_BUS);
extern int __init pci_mmcfg_arch_reachable(unsigned int seg, unsigned int bus,
unsigned int devfn);
extern int __init pci_mmcfg_arch_init(void);

/*
* AMD Fam10h CPUs are buggy, and cannot access MMIO config space
* on their northbrige except through the * %eax register. As such, you MUST
* NOT use normal IOMEM accesses, you need to only use the magic mmio-config
* accessor functions.
* In fact just use pci_config_*, nothing else please.
*/
static inline unsigned char mmio_config_readb(void __iomem *pos)
{
u8 val;
asm volatile("movb (%1),%%al" : "=a" (val) : "r" (pos));
return val;
}

static inline unsigned short mmio_config_readw(void __iomem *pos)
{
u16 val;
asm volatile("movw (%1),%%ax" : "=a" (val) : "r" (pos));
return val;
}

static inline unsigned int mmio_config_readl(void __iomem *pos)
{
u32 val;
asm volatile("movl (%1),%%eax" : "=a" (val) : "r" (pos));
return val;
}

static inline void mmio_config_writeb(void __iomem *pos, u8 val)
{
asm volatile("movb %%al,(%1)" :: "a" (val), "r" (pos) : "memory");
}

static inline void mmio_config_writew(void __iomem *pos, u16 val)
{
asm volatile("movw %%ax,(%1)" :: "a" (val), "r" (pos) : "memory");
}

static inline void mmio_config_writel(void __iomem *pos, u32 val)
{
asm volatile("movl %%eax,(%1)" :: "a" (val), "r" (pos) : "memory");
}
12 changes: 6 additions & 6 deletions trunk/arch/x86_64/pci/mmconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus,

switch (len) {
case 1:
*value = readb(addr + reg);
*value = mmio_config_readb(addr + reg);
break;
case 2:
*value = readw(addr + reg);
*value = mmio_config_readw(addr + reg);
break;
case 4:
*value = readl(addr + reg);
*value = mmio_config_readl(addr + reg);
break;
}

Expand All @@ -94,13 +94,13 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus,

switch (len) {
case 1:
writeb(value, addr + reg);
mmio_config_writeb(addr + reg, value);
break;
case 2:
writew(value, addr + reg);
mmio_config_writew(addr + reg, value);
break;
case 4:
writel(value, addr + reg);
mmio_config_writel(addr + reg, value);
break;
}

Expand Down

0 comments on commit fdc06be

Please sign in to comment.