From e6617020d82e7d17ee3eb9bbf9afa5cc0a572fa8 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Fri, 7 Jan 2005 21:40:27 -0800 Subject: [PATCH] ppc64: IOMMU cleanups: Main cleanup patch Earlier cleanup efforts of the ppc64 IOMMU code have mostly been targeted at simplifying the allocation schemes and modularising things for the various platforms. The IOMMU init functions are still a mess. This is an attempt to clean them up and make them somewhat easier to follow. The new rules are: 1. iommu_init_early_ is called before any PCI/VIO init is done 2. The pcibios fixup routines will call the iommu_{bus,dev}_setup functions appropriately as devices are added. TCE space allocation has changed somewhat: * On LPARs, nothing is really different. ibm,dma-window properties are still used to determine table sizes. * On pSeries SMP-mode (non-LPAR), the full TCE space per PHB is split up in 256MB chunks, each handed out to one child bus/slot as needed. This makes current max 7 child buses per PHB, something we're currently below on all machine models I'm aware of. * Exception to the above: Pre-POWER4 machines with Python PHBs have a full GB of DMA space allocated at the PHB level, since there are no EADS-level tables on such systems. * PowerMac and Maple still work like before: all buses/slots share one table. * VIO works like before, ibm,my-dma-window is used like before. * iSeries has not been touched much at all, besides the changed unit of the it_size variable in struct iommu_table. Other things changed: * Powermac and maple PCI/IOMMU inits have been changed a bit to conform to the new init structure * pci_dma_direct.c has been renamed pci_direct_iommu.c to match pci_iommu.c (see separate patch) * Likewise, a couple of the pci direct init functions have been renamed. Signed-off-by: Olof Johansson Acked-by: Paul Mackerras Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-ppc64/iommu.h | 13 +++++-------- include/asm-ppc64/machdep.h | 2 ++ include/asm-ppc64/pci-bridge.h | 8 ++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/asm-ppc64/iommu.h b/include/asm-ppc64/iommu.h index aea9a3b5f23f..19f57ab59641 100644 --- a/include/asm-ppc64/iommu.h +++ b/include/asm-ppc64/iommu.h @@ -69,18 +69,16 @@ union tce_entry { struct iommu_table { unsigned long it_busno; /* Bus number this table belongs to */ - unsigned long it_size; /* Size in pages of iommu table */ + unsigned long it_size; /* Size of iommu table in entries */ unsigned long it_offset; /* Offset into global table */ unsigned long it_base; /* mapped address of tce table */ unsigned long it_index; /* which iommu table this is */ unsigned long it_type; /* type: PCI or Virtual Bus */ - unsigned long it_entrysize; /* Size of an entry in bytes */ unsigned long it_blocksize; /* Entries in each block (cacheline) */ unsigned long it_hint; /* Hint for next alloc */ unsigned long it_largehint; /* Hint for large allocs */ unsigned long it_halfpoint; /* Breaking point for small/large allocs */ spinlock_t it_lock; /* Protects it_map */ - unsigned long it_mapsize; /* Size of map in # of entries (bits) */ unsigned long *it_map; /* A simple allocation bitmap for now */ }; @@ -156,14 +154,13 @@ extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr, extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, size_t size, enum dma_data_direction direction); -extern void tce_init_pSeries(void); -extern void tce_init_iSeries(void); +extern void iommu_init_early_pSeries(void); +extern void iommu_init_early_iSeries(void); +extern void iommu_init_early_u3(void); extern void pci_iommu_init(void); -extern void pci_dma_init_direct(void); +extern void pci_direct_iommu_init(void); extern void alloc_u3_dart_table(void); -extern int ppc64_iommu_off; - #endif /* _ASM_IOMMU_H */ diff --git a/include/asm-ppc64/machdep.h b/include/asm-ppc64/machdep.h index 1dd70a419b95..ae1c4fd4a7cf 100644 --- a/include/asm-ppc64/machdep.h +++ b/include/asm-ppc64/machdep.h @@ -70,6 +70,8 @@ struct machdep_calls { long index, long npages); void (*tce_flush)(struct iommu_table *tbl); + void (*iommu_dev_setup)(struct pci_dev *dev); + void (*iommu_bus_setup)(struct pci_bus *bus); int (*probe)(int platform); void (*setup_arch)(void); diff --git a/include/asm-ppc64/pci-bridge.h b/include/asm-ppc64/pci-bridge.h index 428cc1947d95..51cfa8b72812 100644 --- a/include/asm-ppc64/pci-bridge.h +++ b/include/asm-ppc64/pci-bridge.h @@ -79,6 +79,14 @@ static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) return fetch_dev_dn(dev); } +static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) +{ + if (bus->self) + return pci_device_to_OF_node(bus->self); + else + return bus->sysdata; /* Must be root bus (PHB) */ +} + extern void pci_process_bridge_OF_ranges(struct pci_controller *hose, struct device_node *dev); -- cgit v1.2.3