Skip to content

Commit

Permalink
[POWERPC] iSeries: eliminate pci_dn bussubno
Browse files Browse the repository at this point in the history
xlate_iomm_address() really wants the ds_addr to pass to the HV, so store
that value (instead of the BAR number) when we allocate the device bars.
This is not a fast path, so we can look up the device_node property
there instead of using the bussubno field of the pci_dn.

The other user of iseries_ds_addr() was already scanning the device tree,
so looking up a property will not slow it down any more.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Stephen Rothwell authored and Paul Mackerras committed Jan 17, 2008
1 parent b6ed42a commit 885b86e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
5 changes: 0 additions & 5 deletions arch/powerpc/kernel/pci_dn.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ static void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
pdn->busno = (regs[0] >> 16) & 0xff;
pdn->devfn = (regs[0] >> 8) & 0xff;
}
if (firmware_has_feature(FW_FEATURE_ISERIES)) {
const u32 *busp = of_get_property(dn, "linux,subbus", NULL);
if (busp)
pdn->bussubno = *busp;
}

pdn->pci_ext_config_space = (type && *type == 1);
return NULL;
Expand Down
12 changes: 7 additions & 5 deletions arch/powerpc/platforms/iseries/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/of.h>

#include <asm/types.h>
#include <asm/io.h>
Expand Down Expand Up @@ -70,7 +71,7 @@ static long current_iomm_table_entry;
* Lookup Tables.
*/
static struct device_node *iomm_table[IOMM_TABLE_MAX_ENTRIES];
static u8 iobar_table[IOMM_TABLE_MAX_ENTRIES];
static u64 ds_addr_table[IOMM_TABLE_MAX_ENTRIES];

static DEFINE_SPINLOCK(iomm_table_lock);

Expand All @@ -80,8 +81,9 @@ static DEFINE_SPINLOCK(iomm_table_lock);
static inline u64 iseries_ds_addr(struct device_node *node)
{
struct pci_dn *pdn = PCI_DN(node);
const u32 *sbp = of_get_property(node, "linux,subbus", NULL);

return ((u64)pdn->busno << 48) + ((u64)pdn->bussubno << 40)
return ((u64)pdn->busno << 48) + ((u64)(sbp ? *sbp : 0) << 40)
+ ((u64)0x10 << 32);
}

Expand Down Expand Up @@ -333,7 +335,8 @@ static void __init iomm_table_allocate_entry(struct pci_dev *dev, int bar_num)
*/
while (bar_size > 0 ) {
iomm_table[current_iomm_table_entry] = dev->sysdata;
iobar_table[current_iomm_table_entry] = bar_num;
ds_addr_table[current_iomm_table_entry] =
iseries_ds_addr(dev->sysdata) | (bar_num << 24);
bar_size -= IOMM_TABLE_ENTRY_SIZE;
++current_iomm_table_entry;
}
Expand Down Expand Up @@ -598,8 +601,7 @@ static inline struct device_node *xlate_iomm_address(
dn = iomm_table[ind];

if (dn != NULL) {
int barnum = iobar_table[ind];
*dsaptr = iseries_ds_addr(dn) | (barnum << 24);
*dsaptr = ds_addr_table[ind];
*bar_offset = base_addr % IOMM_TABLE_ENTRY_SIZE;
} else
panic("PCI: Invalid PCI IO address detected!\n");
Expand Down
1 change: 0 additions & 1 deletion include/asm-powerpc/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ struct iommu_table;

struct pci_dn {
int busno; /* pci bus number */
int bussubno; /* pci subordinate bus number */
int devfn; /* pci device and function number */

struct pci_controller *phb; /* for pci devices */
Expand Down

0 comments on commit 885b86e

Please sign in to comment.