Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62456
b: refs/heads/master
c: 08f1c19
h: refs/heads/master
v: v3
  • Loading branch information
Muli Ben-Yehuda authored and Linus Torvalds committed Jul 22, 2007
1 parent 8669995 commit faec417
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 32 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: 7557244ba27f63404236cb27277b98c27d856692
refs/heads/master: 08f1c192c3c32797068bfe97738babb3295bbf42
32 changes: 27 additions & 5 deletions trunk/arch/i386/pci/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,42 @@
struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum)
{
struct pci_bus *bus;
struct pci_sysdata *sd;
int pxm;

/* Allocate per-root-bus (not per bus) arch-specific data.
* TODO: leak; this memory is never freed.
* It's arguable whether it's worth the trouble to care.
*/
sd = kzalloc(sizeof(*sd), GFP_KERNEL);
if (!sd) {
printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
return NULL;
}

if (domain != 0) {
printk(KERN_WARNING "PCI: Multiple domains not supported\n");
kfree(sd);
return NULL;
}

bus = pcibios_scan_root(busnum);
sd->node = -1;

pxm = acpi_get_pxm(device->handle);
#ifdef CONFIG_ACPI_NUMA
if (pxm >= 0)
sd->node = pxm_to_node(pxm);
#endif

bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
if (!bus)
kfree(sd);

#ifdef CONFIG_ACPI_NUMA
if (bus != NULL) {
int pxm = acpi_get_pxm(device->handle);
if (pxm >= 0) {
bus->sysdata = (void *)(unsigned long)pxm_to_node(pxm);
printk("bus %d -> pxm %d -> node %ld\n",
busnum, pxm, (long)(bus->sysdata));
printk("bus %d -> pxm %d -> node %d\n",
busnum, pxm, sd->node);
}
}
#endif
Expand Down
13 changes: 12 additions & 1 deletion trunk/arch/i386/pci/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
struct pci_bus * __devinit pcibios_scan_root(int busnum)
{
struct pci_bus *bus = NULL;
struct pci_sysdata *sd;

dmi_check_system(pciprobe_dmi_table);

Expand All @@ -303,9 +304,19 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
}
}

/* Allocate per-root-bus (not per bus) arch-specific data.
* TODO: leak; this memory is never freed.
* It's arguable whether it's worth the trouble to care.
*/
sd = kzalloc(sizeof(*sd), GFP_KERNEL);
if (!sd) {
printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
return NULL;
}

printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);

return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, NULL);
return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
}

extern u8 pci_cache_line_size;
Expand Down
29 changes: 15 additions & 14 deletions trunk/arch/x86_64/kernel/pci-calgary.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static inline struct iommu_table *find_iommu_table(struct device *dev)
else
pbus = pdev->bus;

tbl = pbus->self->sysdata;
tbl = pci_iommu(pbus);

BUG_ON(pdev->bus->parent &&
(tbl->it_busno != pdev->bus->parent->number));
Expand Down Expand Up @@ -716,15 +716,15 @@ static void __init calgary_reserve_mem_region(struct pci_dev *dev, u64 start,
limit++;

numpages = ((limit - start) >> PAGE_SHIFT);
iommu_range_reserve(dev->sysdata, start, numpages);
iommu_range_reserve(pci_iommu(dev->bus), start, numpages);
}

static void __init calgary_reserve_peripheral_mem_1(struct pci_dev *dev)
{
void __iomem *target;
u64 low, high, sizelow;
u64 start, limit;
struct iommu_table *tbl = dev->sysdata;
struct iommu_table *tbl = pci_iommu(dev->bus);
unsigned char busnum = dev->bus->number;
void __iomem *bbar = tbl->bbar;

Expand All @@ -748,7 +748,7 @@ static void __init calgary_reserve_peripheral_mem_2(struct pci_dev *dev)
u32 val32;
u64 low, high, sizelow, sizehigh;
u64 start, limit;
struct iommu_table *tbl = dev->sysdata;
struct iommu_table *tbl = pci_iommu(dev->bus);
unsigned char busnum = dev->bus->number;
void __iomem *bbar = tbl->bbar;

Expand Down Expand Up @@ -784,7 +784,7 @@ static void __init calgary_reserve_regions(struct pci_dev *dev)
{
unsigned int npages;
u64 start;
struct iommu_table *tbl = dev->sysdata;
struct iommu_table *tbl = pci_iommu(dev->bus);

/* reserve EMERGENCY_PAGES from bad_dma_address and up */
iommu_range_reserve(tbl, bad_dma_address, EMERGENCY_PAGES);
Expand Down Expand Up @@ -818,7 +818,7 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
if (ret)
return ret;

tbl = dev->sysdata;
tbl = pci_iommu(dev->bus);
tbl->it_base = (unsigned long)bus_info[dev->bus->number].tce_space;
tce_free(tbl, 0, tbl->it_size);

Expand Down Expand Up @@ -855,7 +855,7 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
static void __init calgary_free_bus(struct pci_dev *dev)
{
u64 val64;
struct iommu_table *tbl = dev->sysdata;
struct iommu_table *tbl = pci_iommu(dev->bus);
void __iomem *target;
unsigned int bitmapsz;

Expand All @@ -870,7 +870,8 @@ static void __init calgary_free_bus(struct pci_dev *dev)
tbl->it_map = NULL;

kfree(tbl);
dev->sysdata = NULL;

set_pci_iommu(dev->bus, NULL);

/* Can't free bootmem allocated memory after system is up :-( */
bus_info[dev->bus->number].tce_space = NULL;
Expand Down Expand Up @@ -943,7 +944,7 @@ static void calioc2_dump_error_regs(struct iommu_table *tbl)
static void calgary_watchdog(unsigned long data)
{
struct pci_dev *dev = (struct pci_dev *)data;
struct iommu_table *tbl = dev->sysdata;
struct iommu_table *tbl = pci_iommu(dev->bus);
void __iomem *bbar = tbl->bbar;
u32 val32;
void __iomem *target;
Expand Down Expand Up @@ -1041,7 +1042,7 @@ static void __init calgary_enable_translation(struct pci_dev *dev)
struct iommu_table *tbl;

busnum = dev->bus->number;
tbl = dev->sysdata;
tbl = pci_iommu(dev->bus);
bbar = tbl->bbar;

/* enable TCE in PHB Config Register */
Expand Down Expand Up @@ -1073,7 +1074,7 @@ static void __init calgary_disable_translation(struct pci_dev *dev)
struct iommu_table *tbl;

busnum = dev->bus->number;
tbl = dev->sysdata;
tbl = pci_iommu(dev->bus);
bbar = tbl->bbar;

/* disable TCE in PHB Config Register */
Expand All @@ -1091,7 +1092,7 @@ static void __init calgary_disable_translation(struct pci_dev *dev)
static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
{
pci_dev_get(dev);
dev->sysdata = NULL;
set_pci_iommu(dev->bus, NULL);

/* is the device behind a bridge? */
if (dev->bus->parent)
Expand Down Expand Up @@ -1123,7 +1124,7 @@ static int __init calgary_init_one(struct pci_dev *dev)
} else
dev->bus->self = dev;

tbl = dev->sysdata;
tbl = pci_iommu(dev->bus);
tbl->chip_ops->handle_quirks(tbl, dev);

calgary_enable_translation(dev);
Expand Down Expand Up @@ -1520,7 +1521,7 @@ static void __init calgary_fixup_one_tce_space(struct pci_dev *dev)
unsigned int npages;
int i;

tbl = dev->sysdata;
tbl = pci_iommu(dev->bus);

for (i = 0; i < 4; i++) {
struct resource *r = &dev->resource[PCI_BRIDGE_RESOURCES + i];
Expand Down
12 changes: 4 additions & 8 deletions trunk/arch/x86_64/kernel/tce.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ int build_tce_table(struct pci_dev *dev, void __iomem *bbar)
struct iommu_table *tbl;
int ret;

if (dev->sysdata) {
printk(KERN_ERR "Calgary: dev %p has sysdata %p\n",
dev, dev->sysdata);
if (pci_iommu(dev->bus)) {
printk(KERN_ERR "Calgary: dev %p has sysdata->iommu %p\n",
dev, pci_iommu(dev->bus));
BUG();
}

Expand All @@ -155,11 +155,7 @@ int build_tce_table(struct pci_dev *dev, void __iomem *bbar)

tbl->bbar = bbar;

/*
* NUMA is already using the bus's sysdata pointer, so we use
* the bus's pci_dev's sysdata instead.
*/
dev->sysdata = tbl;
set_pci_iommu(dev->bus, tbl);

return 0;

Expand Down
6 changes: 5 additions & 1 deletion trunk/arch/x86_64/pci/k8-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ fill_mp_bus_to_cpumask(void)
j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
j++) {
struct pci_bus *bus;
struct pci_sysdata *sd;

long node = NODE_ID(nid);
/* Algorithm a bit dumb, but
it shouldn't matter here */
Expand All @@ -67,7 +69,9 @@ fill_mp_bus_to_cpumask(void)
continue;
if (!node_online(node))
node = 0;
bus->sysdata = (void *)node;

sd = bus->sysdata;
sd->node = node;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/asm-i386/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@


#ifdef __KERNEL__

struct pci_sysdata {
int node; /* NUMA node */
};

#include <linux/mm.h> /* for struct page */

/* Can be used to override the logic in pci_scan_bus for skipping
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/asm-i386/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static inline int node_to_first_cpu(int node)
return first_cpu(mask);
}

#define pcibus_to_node(bus) ((long) (bus)->sysdata)
#define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node
#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus))

/* sched_domains SD_NODE_INIT for NUMAQ machines */
Expand Down
19 changes: 19 additions & 0 deletions trunk/include/asm-x86_64/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@

#ifdef __KERNEL__

struct pci_sysdata {
int node; /* NUMA node */
void* iommu; /* IOMMU private data */
};

#ifdef CONFIG_CALGARY_IOMMU
static inline void* pci_iommu(struct pci_bus *bus)
{
struct pci_sysdata *sd = bus->sysdata;
return sd->iommu;
}

static inline void set_pci_iommu(struct pci_bus *bus, void *val)
{
struct pci_sysdata *sd = bus->sysdata;
sd->iommu = val;
}
#endif /* CONFIG_CALGARY_IOMMU */

#include <linux/mm.h> /* for struct page */

/* Can be used to override the logic in pci_scan_bus for skipping
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/asm-x86_64/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern int __node_distance(int, int);
#define parent_node(node) (node)
#define node_to_first_cpu(node) (first_cpu(node_to_cpumask[node]))
#define node_to_cpumask(node) (node_to_cpumask[node])
#define pcibus_to_node(bus) ((long)(bus->sysdata))
#define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node
#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus));

#define numa_node_id() read_pda(nodenumber)
Expand Down

0 comments on commit faec417

Please sign in to comment.