Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 00:58:08 +0000 (17:58 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 17 Jul 2007 00:58:08 +0000 (17:58 -0700)
* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: (209 commits)
  [POWERPC] Create add_rtc() function to enable the RTC CMOS driver
  [POWERPC] Add H_ILLAN_ATTRIBUTES hcall number
  [POWERPC] xilinxfb: Parameterize xilinxfb platform device registration
  [POWERPC] Oprofile support for Power 5++
  [POWERPC] Enable arbitary speed tty ioctls and split input/output speed
  [POWERPC] Make drivers/char/hvc_console.c:khvcd() static
  [POWERPC] Remove dead code for preventing pread() and pwrite() calls
  [POWERPC] Remove unnecessary #undef printk from prom.c
  [POWERPC] Fix typo in Ebony default DTS
  [POWERPC] Check for NULL ppc_md.init_IRQ() before calling
  [POWERPC] Remove extra return statement
  [POWERPC] pasemi: Don't auto-select CONFIG_EMBEDDED
  [POWERPC] pasemi: Rename platform
  [POWERPC] arch/powerpc/kernel/sysfs.c: Move NUMA exports
  [POWERPC] Add __read_mostly support for powerpc
  [POWERPC] Modify sched_clock() to make CONFIG_PRINTK_TIME more sane
  [POWERPC] Create a dummy zImage if no valid platform has been selected
  [POWERPC] PS3: Bootwrapper support.
  [POWERPC] powermac i2c: Use mutex
  [POWERPC] Schedule removal of arch/ppc
  ...

Fixed up conflicts manually in:

Documentation/feature-removal-schedule.txt
arch/powerpc/kernel/pci_32.c
arch/powerpc/kernel/pci_64.c
include/asm-powerpc/pci.h

and asked the powerpc people to double-check the result..

1  2 
Documentation/feature-removal-schedule.txt
arch/powerpc/Kconfig
arch/powerpc/kernel/pci_64.c
arch/powerpc/platforms/pseries/setup.c
include/asm-powerpc/pci.h
include/asm-powerpc/pgtable-ppc32.h
include/asm-powerpc/pgtable-ppc64.h

@@@ -41,6 -41,14 +41,6 @@@ Who: Pavel Machek <pavel@suse.cz
  
  ---------------------------
  
 -What: RAW driver (CONFIG_RAW_DRIVER)
 -When: December 2005
 -Why:  declared obsolete since kernel 2.6.3
 -      O_DIRECT can be used instead
 -Who:  Adrian Bunk <bunk@stusta.de>
 -
 ----------------------------
 -
  What: old NCR53C9x driver
  When: October 2007
  Why:  Replaced by the much better esp_scsi driver.  Actual low-level
@@@ -111,6 -119,13 +111,6 @@@ Who:    Adrian Bunk <bunk@stusta.de
  
  ---------------------------
  
 -What:  drivers depending on OSS_OBSOLETE_DRIVER
 -When:  options in 2.6.20, code in 2.6.22
 -Why:   OSS drivers with ALSA replacements
 -Who:   Adrian Bunk <bunk@stusta.de>
 -
 ----------------------------
 -
  What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports
        (temporary transition config option provided until then)
        The transition config option will also be removed at the same time.
@@@ -181,6 -196,28 +181,6 @@@ Who:   Adrian Bunk <bunk@stusta.de
  
  ---------------------------
  
 -What: ACPI hooks (X86_SPEEDSTEP_CENTRINO_ACPI) in speedstep-centrino driver
 -When: December 2006
 -Why:  Speedstep-centrino driver with ACPI hooks and acpi-cpufreq driver are
 -      functionally very much similar. They talk to ACPI in same way. Only
 -      difference between them is the way they do frequency transitions.
 -      One uses MSRs and the other one uses IO ports. Functionaliy of
 -      speedstep_centrino with ACPI hooks is now merged into acpi-cpufreq.
 -      That means one common driver will support all Intel Enhanced Speedstep
 -      capable CPUs. That means less confusion over name of
 -      speedstep-centrino driver (with that driver supposed to be used on
 -      non-centrino platforms). That means less duplication of code and
 -      less maintenance effort and no possibility of these two drivers
 -      going out of sync.
 -      Current users of speedstep_centrino with ACPI hooks are requested to
 -      switch over to acpi-cpufreq driver. speedstep-centrino will continue
 -      to work using older non-ACPI static table based scheme even after this
 -      date.
 -
 -Who:  Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
 -
 ----------------------------
 -
  What: /sys/firmware/acpi/namespace
  When: 2.6.21
  Why:  The ACPI namespace is effectively the symbol list for
@@@ -225,6 -262,25 +225,6 @@@ Who:      Richard Purdie <rpurdie@rpsys.net
  
  ---------------------------
  
 -What: Multipath cached routing support in ipv4
 -When: in 2.6.23
 -Why:  Code was merged, then submitter immediately disappeared leaving
 -      us with no maintainer and lots of bugs.  The code should not have
 -      been merged in the first place, and many aspects of it's
 -      implementation are blocking more critical core networking
 -      development.  It's marked EXPERIMENTAL and no distribution
 -      enables it because it cause obscure crashes due to unfixable bugs
 -      (interfaces don't return errors so memory allocation can't be
 -      handled, calling contexts of these interfaces make handling
 -      errors impossible too because they get called after we've
 -      totally commited to creating a route object, for example).
 -      This problem has existed for years and no forward progress
 -      has ever been made, and nobody steps up to try and salvage
 -      this code, so we're going to finally just get rid of it.
 -Who:  David S. Miller <davem@davemloft.net>
 -
 ----------------------------
 -
  What: read_dev_chars(), read_conf_data{,_lpm}() (s390 common I/O layer)
  When: December 2007
  Why:  These functions are a leftover from 2.4 times. They have several
@@@ -249,14 -305,6 +249,14 @@@ Who:     Jean Delvare <khali@linux-fr.org
  
  ---------------------------
  
 +What: 'time' kernel boot parameter
 +When: January 2008
 +Why:  replaced by 'printk.time=<value>' so that printk timestamps can be
 +      enabled or disabled as needed
 +Who:  Randy Dunlap <randy.dunlap@oracle.com>
 +
 +---------------------------
 +
  What:  drivers depending on OSS_OBSOLETE
  When:  options in 2.6.23, code in 2.6.25
  Why:   obsolete OSS drivers
@@@ -282,18 -330,15 +282,31 @@@ Who:  Tejun Heo <htejun@gmail.com
  
  ---------------------------
  
 +What: Legacy RTC drivers (under drivers/i2c/chips)
 +When: November 2007
 +Why:  Obsolete. We have a RTC subsystem with better drivers.
 +Who:  Jean Delvare <khali@linux-fr.org>
 +
 +---------------------------
 +
 +What: iptables SAME target
 +When: 1.1. 2008
 +Files:        net/ipv4/netfilter/ipt_SAME.c, include/linux/netfilter_ipv4/ipt_SAME.h
 +Why:  Obsolete for multiple years now, NAT core provides the same behaviour.
 +      Unfixable broken wrt. 32/64 bit cleanness.
 +Who:  Patrick McHardy <kaber@trash.net>
 +
 +---------------------------
++
+ What: The arch/ppc and include/asm-ppc directories
+ When: Jun 2008
+ Why:  The arch/powerpc tree is the merged architecture for ppc32 and ppc64
+       platforms.  Currently there are efforts underway to port the remaining
+       arch/ppc platforms to the merged tree.  New submissions to the arch/ppc
+       tree have been frozen with the 2.6.22 kernel release and that tree will
+       remain in bug-fix only mode until its scheduled removal.  Platforms
+       that are not ported by June 2008 will be removed due to the lack of an
+       interested maintainer.
+ Who:  linuxppc-dev@ozlabs.org
+ ---------------------------
diff --combined arch/powerpc/Kconfig
@@@ -4,17 -4,7 +4,7 @@@
  
  mainmenu "Linux/PowerPC Kernel Configuration"
  
- config PPC64
-       bool "64-bit kernel"
-       default n
-       help
-         This option selects whether a 32-bit or a 64-bit kernel
-         will be built.
- config PPC_PM_NEEDS_RTC_LIB
-       bool
-       select RTC_LIB
-       default y if PM
+ source "arch/powerpc/platforms/Kconfig.cputype"
  
  config PPC32
        bool
@@@ -66,9 -56,6 +56,9 @@@ config GENERIC_FIND_NEXT_BI
        bool
        default y
  
 +config ARCH_NO_VIRT_TO_BUS
 +      def_bool PPC64
 +
  config PPC
        bool
        default y
@@@ -135,123 -122,6 +125,6 @@@ config PPC64_SWSUS
        depends on PPC64 && (BROKEN || (PPC_PMAC64 && EXPERIMENTAL))
        default y
  
- menu "Processor support"
- choice
-       prompt "Processor Type"
-       depends on PPC32
-       default 6xx
- config CLASSIC32
-       bool "52xx/6xx/7xx/74xx"
-       select PPC_FPU
-       select 6xx
-       help
-         There are four families of PowerPC chips supported.  The more common
-         types (601, 603, 604, 740, 750, 7400), the Motorola embedded
-         versions (821, 823, 850, 855, 860, 52xx, 82xx, 83xx), the AMCC
-         embedded versions (403 and 405) and the high end 64 bit Power
-         processors (POWER 3, POWER4, and IBM PPC970 also known as G5).
-         This option is the catch-all for 6xx types, including some of the
-         embedded versions.  Unless there is see an option for the specific
-         chip family you are using, you want this option.
-         
-         You do not want this if you are building a kernel for a 64 bit
-         IBM RS/6000 or an Apple G5, choose 6xx.
-         
-         If unsure, select this option
-         
-         Note that the kernel runs in 32-bit mode even on 64-bit chips.
- config PPC_82xx
-       bool "Freescale 82xx"
-       select 6xx
-       select PPC_FPU
- config PPC_83xx
-       bool "Freescale 83xx"
-       select 6xx
-       select FSL_SOC
-       select 83xx
-       select PPC_FPU
-       select WANT_DEVICE_TREE
- config PPC_85xx
-       bool "Freescale 85xx"
-       select E500
-       select FSL_SOC
-       select 85xx
-       select WANT_DEVICE_TREE
- config PPC_86xx
-       bool "Freescale 86xx"
-       select 6xx
-       select FSL_SOC
-       select FSL_PCIE
-       select PPC_FPU
-       select ALTIVEC
-       help
-         The Freescale E600 SoCs have 74xx cores.
- config PPC_8xx
-       bool "Freescale 8xx"
-       select FSL_SOC
-       select 8xx
- config 40x
-       bool "AMCC 40x"
-       select PPC_DCR_NATIVE
- config 44x
-       bool "AMCC 44x"
-       select PPC_DCR_NATIVE
-       select WANT_DEVICE_TREE
- config E200
-       bool "Freescale e200"
- endchoice
- config POWER4_ONLY
-       bool "Optimize for POWER4"
-       depends on PPC64
-       default n
-       ---help---
-         Cause the compiler to optimize for POWER4/POWER5/PPC970 processors.
-         The resulting binary will not work on POWER3 or RS64 processors
-         when compiled with binutils 2.15 or later.
- config POWER3
-       bool
-       depends on PPC64
-       default y if !POWER4_ONLY
- config POWER4
-       depends on PPC64
-       def_bool y
- config 6xx
-       bool
- # this is temp to handle compat with arch=ppc
- config 8xx
-       bool
- # this is temp to handle compat with arch=ppc
- config 83xx
-       bool
- # this is temp to handle compat with arch=ppc
- config 85xx
-       bool
- config E500
-       bool
- config PPC_FPU
-       bool
-       default y if PPC64
  config PPC_DCR_NATIVE
        bool
        default n
@@@ -270,134 -140,6 +143,6 @@@ config PPC_OF_PLATFORM_PC
        depends on PPC64 # not supported on 32 bits yet
        default n
  
- config 4xx
-       bool
-       depends on 40x || 44x
-       default y
- config BOOKE
-       bool
-       depends on E200 || E500 || 44x
-       default y
- config FSL_BOOKE
-       bool
-       depends on E200 || E500
-       default y
- config PTE_64BIT
-       bool
-       depends on 44x || E500
-       default y if 44x
-       default y if E500 && PHYS_64BIT
- config PHYS_64BIT
-       bool 'Large physical address support' if E500
-       depends on 44x || E500
-       select RESOURCES_64BIT
-       default y if 44x
-       ---help---
-         This option enables kernel support for larger than 32-bit physical
-         addresses.  This features is not be available on all e500 cores.
-         If in doubt, say N here.
- config ALTIVEC
-       bool "AltiVec Support"
-       depends on CLASSIC32 || POWER4
-       ---help---
-         This option enables kernel support for the Altivec extensions to the
-         PowerPC processor. The kernel currently supports saving and restoring
-         altivec registers, and turning on the 'altivec enable' bit so user
-         processes can execute altivec instructions.
-         This option is only usefully if you have a processor that supports
-         altivec (G4, otherwise known as 74xx series), but does not have
-         any affect on a non-altivec cpu (it does, however add code to the
-         kernel).
-         If in doubt, say Y here.
- config SPE
-       bool "SPE Support"
-       depends on E200 || E500
-       default y
-       ---help---
-         This option enables kernel support for the Signal Processing
-         Extensions (SPE) to the PowerPC processor. The kernel currently
-         supports saving and restoring SPE registers, and turning on the
-         'spe enable' bit so user processes can execute SPE instructions.
-         This option is only useful if you have a processor that supports
-         SPE (e500, otherwise known as 85xx series), but does not have any
-         effect on a non-spe cpu (it does, however add code to the kernel).
-         If in doubt, say Y here.
- config PPC_STD_MMU
-       bool
-       depends on 6xx || POWER3 || POWER4 || PPC64
-       default y
- config PPC_STD_MMU_32
-       def_bool y
-       depends on PPC_STD_MMU && PPC32
- config PPC_MM_SLICES
-       bool
-       default y if HUGETLB_PAGE
-       default n
- config VIRT_CPU_ACCOUNTING
-       bool "Deterministic task and CPU time accounting"
-       depends on PPC64
-       default y
-       help
-         Select this option to enable more accurate task and CPU time
-         accounting.  This is done by reading a CPU counter on each
-         kernel entry and exit and on transitions within the kernel
-         between system, softirq and hardirq state, so there is a
-         small performance impact.  This also enables accounting of
-         stolen time on logically-partitioned systems running on
-         IBM POWER5-based machines.
-         If in doubt, say Y here.
- config SMP
-       depends on PPC_STD_MMU
-       bool "Symmetric multi-processing support"
-       ---help---
-         This enables support for systems with more than one CPU. If you have
-         a system with only one CPU, say N. If you have a system with more
-         than one CPU, say Y.  Note that the kernel does not currently
-         support SMP machines with 603/603e/603ev or PPC750 ("G3") processors
-         since they have inadequate hardware support for multiprocessor
-         operation.
-         If you say N here, the kernel will run on single and multiprocessor
-         machines, but will use only one CPU of a multiprocessor machine. If
-         you say Y here, the kernel will run on single-processor machines.
-         On a single-processor machine, the kernel will run faster if you say
-         N here.
-         If you don't know what to do here, say N.
- config NR_CPUS
-       int "Maximum number of CPUs (2-128)"
-       range 2 128
-       depends on SMP
-       default "32" if PPC64
-       default "4"
- config NOT_COHERENT_CACHE
-       bool
-       depends on 4xx || 8xx || E200
-       default y
- config CONFIG_CHECK_CACHE_COHERENCY
-       bool
- endmenu
  source "init/Kconfig"
  
  source "arch/powerpc/platforms/Kconfig"
@@@ -677,10 -419,6 +422,6 @@@ config SBU
  config FSL_SOC
        bool
  
- config FSL_PCIE
-       bool
-       depends on PPC_86xx
  # Yes MCA RS/6000s exist but Linux-PPC does not currently support any
  config MCA
        bool
  config PCI
        bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
                || PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
-               || MPC7448HPC2 || PPC_PS3 || PPC_HOLLY
-       default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx \
+               || PPC_PS3
+       default y if !40x && !CPM2 && !8xx && !PPC_83xx \
                && !PPC_85xx && !PPC_86xx
-       default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
+       default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
        default PCI_QSPAN if !4xx && !CPM2 && 8xx
        select ARCH_SUPPORTS_MSI
        help
          infrastructure code to support PCI bus devices.
  
  config PCI_DOMAINS
 -      bool
 -      default PCI
 +      def_bool PCI
 +
 +config PCI_SYSCALL
 +      def_bool PCI
  
  config PCI_QSPAN
        bool "QSpan PCI"
@@@ -22,6 -22,7 +22,7 @@@
  #include <linux/list.h>
  #include <linux/syscalls.h>
  #include <linux/irq.h>
+ #include <linux/vmalloc.h>
  
  #include <asm/processor.h>
  #include <asm/io.h>
  
  unsigned long pci_probe_only = 1;
  int pci_assign_all_buses = 0;
- static int pci_initial_scan_done;
  
  static void fixup_resource(struct resource *res, struct pci_dev *dev);
  static void do_bus_setup(struct pci_bus *bus);
- static void phbs_remap_io(void);
  
  /* pci_io_base -- the base address from which io bars are offsets.
   * This is the lowest I/O base address (so bar values are always positive),
   * and it *must* be the start of ISA space if an ISA bus exists because
-  * ISA drivers use hard coded offsets.  If no ISA bus exists a dummy
-  * page is mapped and isa_io_limit prevents access to it.
+  * ISA drivers use hard coded offsets.  If no ISA bus exists nothing
+  * is mapped on the first 64K of IO space
   */
- unsigned long isa_io_base;    /* NULL if no ISA bus */
- EXPORT_SYMBOL(isa_io_base);
- unsigned long pci_io_base;
+ unsigned long pci_io_base = ISA_IO_BASE;
  EXPORT_SYMBOL(pci_io_base);
  
- void iSeries_pcibios_init(void);
  LIST_HEAD(hose_list);
  
  static struct dma_mapping_ops *pci_dma_ops;
  
- int global_phb_number;                /* Global phb counter */
- /* Cached ISA bridge dev. */
- struct pci_dev *ppc64_isabridge_dev = NULL;
- EXPORT_SYMBOL_GPL(ppc64_isabridge_dev);
  void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
  {
        pci_dma_ops = dma_ops;
@@@ -100,7 -89,7 +89,7 @@@ void  pcibios_resource_to_bus(struct pc
                return;
  
        if (res->flags & IORESOURCE_IO)
-               offset = (unsigned long)hose->io_base_virt - pci_io_base;
+               offset = (unsigned long)hose->io_base_virt - _IO_BASE;
  
        if (res->flags & IORESOURCE_MEM)
                offset = hose->pci_mem_offset;
@@@ -119,7 -108,7 +108,7 @@@ void pcibios_bus_to_resource(struct pci
                return;
  
        if (res->flags & IORESOURCE_IO)
-               offset = (unsigned long)hose->io_base_virt - pci_io_base;
+               offset = (unsigned long)hose->io_base_virt - _IO_BASE;
  
        if (res->flags & IORESOURCE_MEM)
                offset = hose->pci_mem_offset;
@@@ -156,7 -145,7 +145,7 @@@ void pcibios_align_resource(void *data
  
        if (res->flags & IORESOURCE_IO) {
                unsigned long offset = (unsigned long)hose->io_base_virt -
-                                       pci_io_base;
+                                       _IO_BASE;
                /* Make sure we start at our min on all hoses */
                if (start - offset < PCIBIOS_MIN_IO)
                        start = PCIBIOS_MIN_IO + offset;
        res->start = start;
  }
  
- static DEFINE_SPINLOCK(hose_spinlock);
- /*
-  * pci_controller(phb) initialized common variables.
-  */
- static void __devinit pci_setup_pci_controller(struct pci_controller *hose)
- {
-       memset(hose, 0, sizeof(struct pci_controller));
-       spin_lock(&hose_spinlock);
-       hose->global_number = global_phb_number++;
-       list_add_tail(&hose->list_node, &hose_list);
-       spin_unlock(&hose_spinlock);
- }
- struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
- {
-       struct pci_controller *phb;
-       if (mem_init_done)
-               phb = kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
-       else
-               phb = alloc_bootmem(sizeof (struct pci_controller));
-       if (phb == NULL)
-               return NULL;
-       pci_setup_pci_controller(phb);
-       phb->arch_data = dev;
-       phb->is_dynamic = mem_init_done;
-       if (dev) {
-               int nid = of_node_to_nid(dev);
-               if (nid < 0 || !node_online(nid))
-                       nid = -1;
-               PHB_SET_NODE(phb, nid);
-       }
-       return phb;
- }
- void pcibios_free_controller(struct pci_controller *phb)
- {
-       spin_lock(&hose_spinlock);
-       list_del(&phb->list_node);
-       spin_unlock(&hose_spinlock);
-       if (phb->is_dynamic)
-               kfree(phb);
- }
  void __devinit pcibios_claim_one_bus(struct pci_bus *b)
  {
        struct pci_dev *dev;
@@@ -291,7 -231,6 +231,6 @@@ static unsigned int pci_parse_of_flags(
        return flags;
  }
  
- #define GET_64BIT(prop, i)    ((((u64) (prop)[(i)]) << 32) | (prop)[(i)+1])
  
  static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
  {
                flags = pci_parse_of_flags(addrs[0]);
                if (!flags)
                        continue;
-               base = GET_64BIT(addrs, 1);
-               size = GET_64BIT(addrs, 3);
+               base = of_read_number(&addrs[1], 2);
+               size = of_read_number(&addrs[3], 2);
                if (!size)
                        continue;
                i = addrs[0] & 0xff;
@@@ -367,10 -306,8 +306,10 @@@ struct pci_dev *of_create_pci_dev(struc
        sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
                dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
        dev->class = get_int_prop(node, "class-code", 0);
 +      dev->revision = get_int_prop(node, "revision-id", 0);
  
        DBG("    class: 0x%x\n", dev->class);
 +      DBG("    revision: 0x%x\n", dev->revision);
  
        dev->current_state = 4;         /* unknown power state */
        dev->error_state = pci_channel_io_normal;
@@@ -479,7 -416,7 +418,7 @@@ void __devinit of_scan_pci_bridge(struc
        i = 1;
        for (; len >= 32; len -= 32, ranges += 8) {
                flags = pci_parse_of_flags(ranges[0]);
-               size = GET_64BIT(ranges, 6);
+               size = of_read_number(&ranges[6], 2);
                if (flags == 0 || size == 0)
                        continue;
                if (flags & IORESOURCE_IO) {
                        res = bus->resource[i];
                        ++i;
                }
-               res->start = GET_64BIT(ranges, 1);
+               res->start = of_read_number(&ranges[1], 2);
                res->end = res->start + size - 1;
                res->flags = flags;
                fixup_resource(res, dev);
@@@ -537,10 -474,16 +476,16 @@@ void __devinit scan_phb(struct pci_cont
        bus->secondary = hose->first_busno;
        hose->bus = bus;
  
+       if (!firmware_has_feature(FW_FEATURE_ISERIES))
+               pcibios_map_io_space(bus);
        bus->resource[0] = res = &hose->io_resource;
-       if (res->flags && request_resource(&ioport_resource, res))
+       if (res->flags && request_resource(&ioport_resource, res)) {
                printk(KERN_ERR "Failed to request PCI IO region "
                       "on PCI domain %04x\n", hose->global_number);
+               DBG("res->start = 0x%016lx, res->end = 0x%016lx\n",
+                   res->start, res->end);
+       }
  
        for (i = 0; i < 3; ++i) {
                res = &hose->mem_resources[i];
@@@ -598,17 -541,6 +543,6 @@@ static int __init pcibios_init(void
        if (ppc_md.pcibios_fixup)
                ppc_md.pcibios_fixup();
  
-       /* Cache the location of the ISA bridge (if we have one) */
-       ppc64_isabridge_dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
-       if (ppc64_isabridge_dev != NULL)
-               printk(KERN_DEBUG "ISA bridge at %s\n", pci_name(ppc64_isabridge_dev));
-       if (!firmware_has_feature(FW_FEATURE_ISERIES))
-               /* map in PCI I/O space */
-               phbs_remap_io();
-       pci_initial_scan_done = 1;
        printk(KERN_DEBUG "PCI: Probing PCI hardware done\n");
  
        return 0;
  
  subsys_initcall(pcibios_init);
  
- char __init *pcibios_setup(char *str)
- {
-       return str;
- }
  int pcibios_enable_device(struct pci_dev *dev, int mask)
  {
        u16 cmd, oldcmd;
        return 0;
  }
  
- /*
-  * Return the domain number for this bus.
-  */
- int pci_domain_nr(struct pci_bus *bus)
- {
-       if (firmware_has_feature(FW_FEATURE_ISERIES))
-               return 0;
-       else {
-               struct pci_controller *hose = pci_bus_to_host(bus);
-               return hose->global_number;
-       }
- }
- EXPORT_SYMBOL(pci_domain_nr);
  /* Decide whether to display the domain number in /proc */
  int pci_proc_domain(struct pci_bus *bus)
  {
        }
  }
  
- /*
-  * Platform support for /proc/bus/pci/X/Y mmap()s,
-  * modelled on the sparc64 implementation by Dave Miller.
-  *  -- paulus.
-  */
- /*
-  * Adjust vm_pgoff of VMA such that it is the physical page offset
-  * corresponding to the 32-bit pci bus offset for DEV requested by the user.
-  *
-  * Basically, the user finds the base address for his device which he wishes
-  * to mmap.  They read the 32-bit value from the config space base register,
-  * add whatever PAGE_SIZE multiple offset they wish, and feed this into the
-  * offset parameter of mmap on /proc/bus/pci/XXX for that device.
-  *
-  * Returns negative error code on failure, zero on success.
-  */
- static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
-                                              resource_size_t *offset,
-                                              enum pci_mmap_state mmap_state)
- {
-       struct pci_controller *hose = pci_bus_to_host(dev->bus);
-       unsigned long io_offset = 0;
-       int i, res_bit;
-       if (hose == 0)
-               return NULL;            /* should never happen */
-       /* If memory, add on the PCI bridge address offset */
-       if (mmap_state == pci_mmap_mem) {
- #if 0 /* See comment in pci_resource_to_user() for why this is disabled */
-               *offset += hose->pci_mem_offset;
- #endif
-               res_bit = IORESOURCE_MEM;
-       } else {
-               io_offset = (unsigned long)hose->io_base_virt - pci_io_base;
-               *offset += io_offset;
-               res_bit = IORESOURCE_IO;
-       }
-       /*
-        * Check that the offset requested corresponds to one of the
-        * resources of the device.
-        */
-       for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
-               struct resource *rp = &dev->resource[i];
-               int flags = rp->flags;
-               /* treat ROM as memory (should be already) */
-               if (i == PCI_ROM_RESOURCE)
-                       flags |= IORESOURCE_MEM;
-               /* Active and same type? */
-               if ((flags & res_bit) == 0)
-                       continue;
-               /* In the range of this resource? */
-               if (*offset < (rp->start & PAGE_MASK) || *offset > rp->end)
-                       continue;
-               /* found it! construct the final physical address */
-               if (mmap_state == pci_mmap_io)
-                       *offset += hose->io_base_phys - io_offset;
-               return rp;
-       }
-       return NULL;
- }
- /*
-  * Set vm_page_prot of VMA, as appropriate for this architecture, for a pci
-  * device mapping.
-  */
- static pgprot_t __pci_mmap_set_pgprot(struct pci_dev *dev, struct resource *rp,
-                                     pgprot_t protection,
-                                     enum pci_mmap_state mmap_state,
-                                     int write_combine)
- {
-       unsigned long prot = pgprot_val(protection);
-       /* Write combine is always 0 on non-memory space mappings. On
-        * memory space, if the user didn't pass 1, we check for a
-        * "prefetchable" resource. This is a bit hackish, but we use
-        * this to workaround the inability of /sysfs to provide a write
-        * combine bit
-        */
-       if (mmap_state != pci_mmap_mem)
-               write_combine = 0;
-       else if (write_combine == 0) {
-               if (rp->flags & IORESOURCE_PREFETCH)
-                       write_combine = 1;
-       }
-       /* XXX would be nice to have a way to ask for write-through */
-       prot |= _PAGE_NO_CACHE;
-       if (write_combine)
-               prot &= ~_PAGE_GUARDED;
-       else
-               prot |= _PAGE_GUARDED;
-       return __pgprot(prot);
- }
- /*
-  * This one is used by /dev/mem and fbdev who have no clue about the
-  * PCI device, it tries to find the PCI device first and calls the
-  * above routine
-  */
- pgprot_t pci_phys_mem_access_prot(struct file *file,
-                                 unsigned long pfn,
-                                 unsigned long size,
-                                 pgprot_t protection)
- {
-       struct pci_dev *pdev = NULL;
-       struct resource *found = NULL;
-       unsigned long prot = pgprot_val(protection);
-       unsigned long offset = pfn << PAGE_SHIFT;
-       int i;
-       if (page_is_ram(pfn))
-               return __pgprot(prot);
-       prot |= _PAGE_NO_CACHE | _PAGE_GUARDED;
-       for_each_pci_dev(pdev) {
-               for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
-                       struct resource *rp = &pdev->resource[i];
-                       int flags = rp->flags;
-                       /* Active and same type? */
-                       if ((flags & IORESOURCE_MEM) == 0)
-                               continue;
-                       /* In the range of this resource? */
-                       if (offset < (rp->start & PAGE_MASK) ||
-                           offset > rp->end)
-                               continue;
-                       found = rp;
-                       break;
-               }
-               if (found)
-                       break;
-       }
-       if (found) {
-               if (found->flags & IORESOURCE_PREFETCH)
-                       prot &= ~_PAGE_GUARDED;
-               pci_dev_put(pdev);
-       }
-       DBG("non-PCI map for %lx, prot: %lx\n", offset, prot);
-       return __pgprot(prot);
- }
- /*
-  * Perform the actual remap of the pages for a PCI device mapping, as
-  * appropriate for this architecture.  The region in the process to map
-  * is described by vm_start and vm_end members of VMA, the base physical
-  * address is found in vm_pgoff.
-  * The pci device structure is provided so that architectures may make mapping
-  * decisions on a per-device or per-bus basis.
-  *
-  * Returns a negative error code on failure, zero on success.
-  */
- int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
-                       enum pci_mmap_state mmap_state, int write_combine)
- {
-       resource_size_t offset = vma->vm_pgoff << PAGE_SHIFT;
-       struct resource *rp;
-       int ret;
-       rp = __pci_mmap_make_offset(dev, &offset, mmap_state);
-       if (rp == NULL)
-               return -EINVAL;
-       vma->vm_pgoff = offset >> PAGE_SHIFT;
-       vma->vm_page_prot = __pci_mmap_set_pgprot(dev, rp,
-                                                 vma->vm_page_prot,
-                                                 mmap_state, write_combine);
-       ret = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
-                              vma->vm_end - vma->vm_start, vma->vm_page_prot);
-       return ret;
- }
- static ssize_t pci_show_devspec(struct device *dev,
-               struct device_attribute *attr, char *buf)
- {
-       struct pci_dev *pdev;
-       struct device_node *np;
-       pdev = to_pci_dev (dev);
-       np = pci_device_to_OF_node(pdev);
-       if (np == NULL || np->full_name == NULL)
-               return 0;
-       return sprintf(buf, "%s", np->full_name);
- }
- static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL);
- int pcibios_add_platform_entries(struct pci_dev *pdev)
- {
-       return device_create_file(&pdev->dev, &dev_attr_devspec);
- }
- #define ISA_SPACE_MASK 0x1
- #define ISA_SPACE_IO 0x1
- static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
-                                     unsigned long phb_io_base_phys,
-                                     void __iomem * phb_io_base_virt)
- {
-       /* Remove these asap */
-       struct pci_address {
-               u32 a_hi;
-               u32 a_mid;
-               u32 a_lo;
-       };
-       struct isa_address {
-               u32 a_hi;
-               u32 a_lo;
-       };
-       struct isa_range {
-               struct isa_address isa_addr;
-               struct pci_address pci_addr;
-               unsigned int size;
-       };
-       const struct isa_range *range;
-       unsigned long pci_addr;
-       unsigned int isa_addr;
-       unsigned int size;
-       int rlen = 0;
-       range = of_get_property(isa_node, "ranges", &rlen);
-       if (range == NULL || (rlen < sizeof(struct isa_range))) {
-               printk(KERN_ERR "no ISA ranges or unexpected isa range size,"
-                      "mapping 64k\n");
-               __ioremap_explicit(phb_io_base_phys,
-                                  (unsigned long)phb_io_base_virt,
-                                  0x10000, _PAGE_NO_CACHE | _PAGE_GUARDED);
-               return; 
-       }
-       
-       /* From "ISA Binding to 1275"
-        * The ranges property is laid out as an array of elements,
-        * each of which comprises:
-        *   cells 0 - 1:       an ISA address
-        *   cells 2 - 4:       a PCI address 
-        *                      (size depending on dev->n_addr_cells)
-        *   cell 5:            the size of the range
-        */
-       if ((range->isa_addr.a_hi && ISA_SPACE_MASK) == ISA_SPACE_IO) {
-               isa_addr = range->isa_addr.a_lo;
-               pci_addr = (unsigned long) range->pci_addr.a_mid << 32 | 
-                       range->pci_addr.a_lo;
-               /* Assume these are both zero */
-               if ((pci_addr != 0) || (isa_addr != 0)) {
-                       printk(KERN_ERR "unexpected isa to pci mapping: %s\n",
-                                       __FUNCTION__);
-                       return;
-               }
-               
-               size = PAGE_ALIGN(range->size);
-               __ioremap_explicit(phb_io_base_phys, 
-                                  (unsigned long) phb_io_base_virt, 
-                                  size, _PAGE_NO_CACHE | _PAGE_GUARDED);
-       }
- }
  void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
                                            struct device_node *dev, int prim)
  {
        }
  }
  
- void __devinit pci_setup_phb_io(struct pci_controller *hose, int primary)
+ #ifdef CONFIG_HOTPLUG
+ int pcibios_unmap_io_space(struct pci_bus *bus)
  {
-       unsigned long size = hose->pci_io_size;
-       unsigned long io_virt_offset;
-       struct resource *res;
-       struct device_node *isa_dn;
+       struct pci_controller *hose;
  
-       if (size == 0)
-               return;
+       WARN_ON(bus == NULL);
  
-       hose->io_base_virt = reserve_phb_iospace(size);
-       DBG("phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n",
-               hose->global_number, hose->io_base_phys,
-               (unsigned long) hose->io_base_virt);
-       if (primary) {
-               pci_io_base = (unsigned long)hose->io_base_virt;
-               isa_dn = of_find_node_by_type(NULL, "isa");
-               if (isa_dn) {
-                       isa_io_base = pci_io_base;
-                       pci_process_ISA_OF_ranges(isa_dn, hose->io_base_phys,
-                                               hose->io_base_virt);
-                       of_node_put(isa_dn);
-               }
-       }
+       /* If this is not a PHB, we only flush the hash table over
+        * the area mapped by this bridge. We don't play with the PTE
+        * mappings since we might have to deal with sub-page alignemnts
+        * so flushing the hash table is the only sane way to make sure
+        * that no hash entries are covering that removed bridge area
+        * while still allowing other busses overlapping those pages
+        */
+       if (bus->self) {
+               struct resource *res = bus->resource[0];
  
-       io_virt_offset = (unsigned long)hose->io_base_virt - pci_io_base;
-       res = &hose->io_resource;
-       res->start += io_virt_offset;
-       res->end += io_virt_offset;
+               DBG("IO unmapping for PCI-PCI bridge %s\n",
+                   pci_name(bus->self));
  
-       /* If this is called after the initial PCI scan, then we need to
-        * proceed to IO mappings now
-        */
-       if (pci_initial_scan_done)
-               __ioremap_explicit(hose->io_base_phys,
-                                  (unsigned long)hose->io_base_virt,
-                                  hose->pci_io_size,
-                                  _PAGE_NO_CACHE | _PAGE_GUARDED);
- }
+               __flush_hash_table_range(&init_mm, res->start + _IO_BASE,
+                                        res->end - res->start + 1);
+               return 0;
+       }
  
- void __devinit pci_setup_phb_io_dynamic(struct pci_controller *hose,
-                                       int primary)
- {
-       unsigned long size = hose->pci_io_size;
-       unsigned long io_virt_offset;
-       struct resource *res;
+       /* Get the host bridge */
+       hose = pci_bus_to_host(bus);
  
-       if (size == 0)
-               return;
+       /* Check if we have IOs allocated */
+       if (hose->io_base_alloc == 0)
+               return 0;
  
-       hose->io_base_virt = __ioremap(hose->io_base_phys, size,
-                                       _PAGE_NO_CACHE | _PAGE_GUARDED);
-       DBG("phb%d io_base_phys 0x%lx io_base_virt 0x%lx\n",
-               hose->global_number, hose->io_base_phys,
-               (unsigned long) hose->io_base_virt);
+       DBG("IO unmapping for PHB %s\n",
+           ((struct device_node *)hose->arch_data)->full_name);
+       DBG("  alloc=0x%p\n", hose->io_base_alloc);
  
-       if (primary)
-               pci_io_base = (unsigned long)hose->io_base_virt;
+       /* This is a PHB, we fully unmap the IO area */
+       vunmap(hose->io_base_alloc);
  
-       io_virt_offset = (unsigned long)hose->io_base_virt - pci_io_base;
-       res = &hose->io_resource;
-       res->start += io_virt_offset;
-       res->end += io_virt_offset;
+       return 0;
  }
+ EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
  
+ #endif /* CONFIG_HOTPLUG */
  
- static int get_bus_io_range(struct pci_bus *bus, unsigned long *start_phys,
-                               unsigned long *start_virt, unsigned long *size)
+ int __devinit pcibios_map_io_space(struct pci_bus *bus)
  {
-       struct pci_controller *hose = pci_bus_to_host(bus);
-       struct resource *res;
-       if (bus->self)
-               res = bus->resource[0];
-       else
-               /* Root Bus */
-               res = &hose->io_resource;
-       if (res->end == 0 && res->start == 0)
-               return 1;
+       struct vm_struct *area;
+       unsigned long phys_page;
+       unsigned long size_page;
+       unsigned long io_virt_offset;
+       struct pci_controller *hose;
  
-       *start_virt = pci_io_base + res->start;
-       *start_phys = *start_virt + hose->io_base_phys
-               - (unsigned long) hose->io_base_virt;
+       WARN_ON(bus == NULL);
  
-       if (res->end > res->start)
-               *size = res->end - res->start + 1;
-       else {
-               printk("%s(): unexpected region 0x%lx->0x%lx\n",
-                      __FUNCTION__, res->start, res->end);
-               return 1;
+       /* If this not a PHB, nothing to do, page tables still exist and
+        * thus HPTEs will be faulted in when needed
+        */
+       if (bus->self) {
+               DBG("IO mapping for PCI-PCI bridge %s\n",
+                   pci_name(bus->self));
+               DBG("  virt=0x%016lx...0x%016lx\n",
+                   bus->resource[0]->start + _IO_BASE,
+                   bus->resource[0]->end + _IO_BASE);
+               return 0;
        }
  
-       return 0;
- }
- int unmap_bus_range(struct pci_bus *bus)
- {
-       unsigned long start_phys;
-       unsigned long start_virt;
-       unsigned long size;
+       /* Get the host bridge */
+       hose = pci_bus_to_host(bus);
+       phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
+       size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
  
-       if (!bus) {
-               printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
-               return 1;
-       }
-       
-       if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
-               return 1;
-       if (__iounmap_explicit((void __iomem *) start_virt, size))
-               return 1;
-       return 0;
- }
- EXPORT_SYMBOL(unmap_bus_range);
+       /* Make sure IO area address is clear */
+       hose->io_base_alloc = NULL;
  
- int remap_bus_range(struct pci_bus *bus)
- {
-       unsigned long start_phys;
-       unsigned long start_virt;
-       unsigned long size;
+       /* If there's no IO to map on that bus, get away too */
+       if (hose->pci_io_size == 0 || hose->io_base_phys == 0)
+               return 0;
  
-       if (!bus) {
-               printk(KERN_ERR "%s() expected bus\n", __FUNCTION__);
-               return 1;
-       }
-       
-       
-       if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
-               return 1;
-       if (start_phys == 0)
-               return 1;
-       printk(KERN_DEBUG "mapping IO %lx -> %lx, size: %lx\n", start_phys, start_virt, size);
-       if (__ioremap_explicit(start_phys, start_virt, size,
-                              _PAGE_NO_CACHE | _PAGE_GUARDED))
-               return 1;
+       /* Let's allocate some IO space for that guy. We don't pass
+        * VM_IOREMAP because we don't care about alignment tricks that
+        * the core does in that case. Maybe we should due to stupid card
+        * with incomplete address decoding but I'd rather not deal with
+        * those outside of the reserved 64K legacy region.
+        */
+       area = __get_vm_area(size_page, 0, PHB_IO_BASE, PHB_IO_END);
+       if (area == NULL)
+               return -ENOMEM;
+       hose->io_base_alloc = area->addr;
+       hose->io_base_virt = (void __iomem *)(area->addr +
+                                             hose->io_base_phys - phys_page);
+       DBG("IO mapping for PHB %s\n",
+           ((struct device_node *)hose->arch_data)->full_name);
+       DBG("  phys=0x%016lx, virt=0x%p (alloc=0x%p)\n",
+           hose->io_base_phys, hose->io_base_virt, hose->io_base_alloc);
+       DBG("  size=0x%016lx (alloc=0x%016lx)\n",
+           hose->pci_io_size, size_page);
+       /* Establish the mapping */
+       if (__ioremap_at(phys_page, area->addr, size_page,
+                        _PAGE_NO_CACHE | _PAGE_GUARDED) == NULL)
+               return -ENOMEM;
+       /* Fixup hose IO resource */
+       io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
+       hose->io_resource.start += io_virt_offset;
+       hose->io_resource.end += io_virt_offset;
+       DBG("  hose->io_resource=0x%016lx...0x%016lx\n",
+           hose->io_resource.start, hose->io_resource.end);
  
        return 0;
  }
- EXPORT_SYMBOL(remap_bus_range);
- static void phbs_remap_io(void)
- {
-       struct pci_controller *hose, *tmp;
-       list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
-               remap_bus_range(hose->bus);
- }
+ EXPORT_SYMBOL_GPL(pcibios_map_io_space);
  
  static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
  {
        unsigned long offset;
  
        if (res->flags & IORESOURCE_IO) {
-               offset = (unsigned long)hose->io_base_virt - pci_io_base;
+               offset = (unsigned long)hose->io_base_virt - _IO_BASE;
                res->start += offset;
                res->end += offset;
        } else if (res->flags & IORESOURCE_MEM) {
@@@ -1219,9 -821,20 +823,20 @@@ void __devinit pcibios_fixup_device_res
        /* Update device resources.  */
        int i;
  
-       for (i = 0; i < PCI_NUM_RESOURCES; i++)
-               if (dev->resource[i].flags)
-                       fixup_resource(&dev->resource[i], dev);
+       DBG("%s: Fixup resources:\n", pci_name(dev));
+       for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+               struct resource *res = &dev->resource[i];
+               if (!res->flags)
+                       continue;
+               DBG("  0x%02x < %08lx:0x%016lx...0x%016lx\n",
+                   i, res->flags, res->start, res->end);
+               fixup_resource(res, dev);
+               DBG("       > %08lx:0x%016lx...0x%016lx\n",
+                   res->flags, res->start, res->end);
+       }
  }
  EXPORT_SYMBOL(pcibios_fixup_device_resources);
  
@@@ -1291,119 -904,6 +906,6 @@@ void __devinit pcibios_fixup_bus(struc
  }
  EXPORT_SYMBOL(pcibios_fixup_bus);
  
- /*
-  * Reads the interrupt pin to determine if interrupt is use by card.
-  * If the interrupt is used, then gets the interrupt line from the 
-  * openfirmware and sets it in the pci_dev and pci_config line.
-  */
- int pci_read_irq_line(struct pci_dev *pci_dev)
- {
-       struct of_irq oirq;
-       unsigned int virq;
-       DBG("Try to map irq for %s...\n", pci_name(pci_dev));
- #ifdef DEBUG
-       memset(&oirq, 0xff, sizeof(oirq));
- #endif
-       /* Try to get a mapping from the device-tree */
-       if (of_irq_map_pci(pci_dev, &oirq)) {
-               u8 line, pin;
-               /* If that fails, lets fallback to what is in the config
-                * space and map that through the default controller. We
-                * also set the type to level low since that's what PCI
-                * interrupts are. If your platform does differently, then
-                * either provide a proper interrupt tree or don't use this
-                * function.
-                */
-               if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_PIN, &pin))
-                       return -1;
-               if (pin == 0)
-                       return -1;
-               if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) ||
-                   line == 0xff) {
-                       return -1;
-               }
-               DBG(" -> no map ! Using irq line %d from PCI config\n", line);
-               virq = irq_create_mapping(NULL, line);
-               if (virq != NO_IRQ)
-                       set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
-       } else {
-               DBG(" -> got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
-                   oirq.size, oirq.specifier[0], oirq.specifier[1],
-                   oirq.controller->full_name);
-               virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
-                                            oirq.size);
-       }
-       if(virq == NO_IRQ) {
-               DBG(" -> failed to map !\n");
-               return -1;
-       }
-       DBG(" -> mapped to linux irq %d\n", virq);
-       pci_dev->irq = virq;
-       return 0;
- }
- EXPORT_SYMBOL(pci_read_irq_line);
- void pci_resource_to_user(const struct pci_dev *dev, int bar,
-                         const struct resource *rsrc,
-                         resource_size_t *start, resource_size_t *end)
- {
-       struct pci_controller *hose = pci_bus_to_host(dev->bus);
-       resource_size_t offset = 0;
-       if (hose == NULL)
-               return;
-       if (rsrc->flags & IORESOURCE_IO)
-               offset = (unsigned long)hose->io_base_virt - pci_io_base;
-       /* We pass a fully fixed up address to userland for MMIO instead of
-        * a BAR value because X is lame and expects to be able to use that
-        * to pass to /dev/mem !
-        *
-        * That means that we'll have potentially 64 bits values where some
-        * userland apps only expect 32 (like X itself since it thinks only
-        * Sparc has 64 bits MMIO) but if we don't do that, we break it on
-        * 32 bits CHRPs :-(
-        *
-        * Hopefully, the sysfs insterface is immune to that gunk. Once X
-        * has been fixed (and the fix spread enough), we can re-enable the
-        * 2 lines below and pass down a BAR value to userland. In that case
-        * we'll also have to re-enable the matching code in
-        * __pci_mmap_make_offset().
-        *
-        * BenH.
-        */
- #if 0
-       else if (rsrc->flags & IORESOURCE_MEM)
-               offset = hose->pci_mem_offset;
- #endif
-       *start = rsrc->start - offset;
-       *end = rsrc->end - offset;
- }
- struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
- {
-       if (!have_of)
-               return NULL;
-       while(node) {
-               struct pci_controller *hose, *tmp;
-               list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
-                       if (hose->arch_data == node)
-                               return hose;
-               node = node->parent;
-       }
-       return NULL;
- }
  unsigned long pci_address_to_pio(phys_addr_t address)
  {
        struct pci_controller *hose, *tmp;
                if (address >= hose->io_base_phys &&
                    address < (hose->io_base_phys + hose->pci_io_size)) {
                        unsigned long base =
-                               (unsigned long)hose->io_base_virt - pci_io_base;
+                               (unsigned long)hose->io_base_virt - _IO_BASE;
                        return base + (address - hose->io_base_phys);
                }
        }
@@@ -176,7 -176,7 +176,7 @@@ static void __init pseries_mpic_init_IR
                return;
  
        cascade_irq = irq_of_parse_and_map(cascade, 0);
 -      if (cascade == NO_IRQ) {
 +      if (cascade_irq == NO_IRQ) {
                printk(KERN_ERR "mpic: failed to map cascade interrupt");
                return;
        }
@@@ -399,6 -399,7 +399,7 @@@ static void pseries_dedicated_idle_slee
         * a good time to find other work to dispatch.
         */
        get_lppaca()->idle = 1;
+       get_lppaca()->donate_dedicated_cpu = 1;
  
        /*
         * We come in with interrupts disabled, and need_resched()
  
  out:
        HMT_medium();
+       get_lppaca()->donate_dedicated_cpu = 0;
        get_lppaca()->idle = 0;
  }
  
@@@ -74,6 -74,18 +74,6 @@@ static inline int pci_get_legacy_ide_ir
  extern void set_pci_dma_ops(struct dma_mapping_ops *dma_ops);
  extern struct dma_mapping_ops *get_pci_dma_ops(void);
  
 -/* For DAC DMA, we currently don't support it by default, but
 - * we let 64-bit platforms override this.
 - */
 -static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask)
 -{
 -      struct dma_mapping_ops *d = get_pci_dma_ops();
 -
 -      if (d && d->dac_dma_supported)
 -              return d->dac_dma_supported(&hwdev->dev, mask);
 -      return 0;
 -}
 -
  static inline void pci_dma_burst_advice(struct pci_dev *pdev,
                                        enum pci_dma_burst_strategy *strat,
                                        unsigned long *strategy_parameter)
  #define get_pci_dma_ops()     NULL
  #endif
  
- extern int pci_domain_nr(struct pci_bus *bus);
  /* Decide whether to display the domain number in /proc */
  extern int pci_proc_domain(struct pci_bus *bus);
  
@@@ -112,9 -122,12 +110,6 @@@ static inline void pci_dma_burst_advice
  }
  #endif
  
- /* Return the index of the PCI controller for device PDEV. */
- #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
 -/*
 - * At present there are very few 32-bit PPC machines that can have
 - * memory above the 4GB point, and we don't support that.
 - */
 -#define pci_dac_dma_supported(pci_dev, mask)  (0)
--
  /* Set the name of the bus as it appears in /proc/bus/pci */
  static inline int pci_proc_domain(struct pci_bus *bus)
  {
  
  #endif /* CONFIG_PPC64 */
  
+ extern int pci_domain_nr(struct pci_bus *bus);
  struct vm_area_struct;
  /* Map a range of PCI memory or I/O space for a device into user space */
  int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
@@@ -202,10 -217,6 +199,6 @@@ static inline struct resource *pcibios_
        return root;
  }
  
- extern int unmap_bus_range(struct pci_bus *bus);
- extern int remap_bus_range(struct pci_bus *bus);
  extern void pcibios_fixup_device_resources(struct pci_dev *dev,
                        struct pci_bus *bus);
  
@@@ -225,6 -236,8 +218,6 @@@ extern void of_scan_bus(struct device_n
  
  extern int pci_read_irq_line(struct pci_dev *dev);
  
 -extern void pcibios_add_platform_entries(struct pci_dev *dev);
 -
  struct file;
  extern pgprot_t       pci_phys_mem_access_prot(struct file *file,
                                         unsigned long pfn,
@@@ -6,11 -6,7 +6,7 @@@
  #ifndef __ASSEMBLY__
  #include <linux/sched.h>
  #include <linux/threads.h>
- #include <asm/processor.h>            /* For TASK_SIZE */
- #include <asm/mmu.h>
- #include <asm/page.h>
  #include <asm/io.h>                   /* For sub-arch specific PPC_PIN_SIZE */
- struct mm_struct;
  
  extern unsigned long va_to_phys(unsigned long address);
  extern pte_t *va_to_pte(unsigned long address);
@@@ -488,14 -484,6 +484,6 @@@ extern unsigned long bad_call_to_PMD_PA
  #define pfn_pte(pfn, prot)    __pte(((pte_basic_t)(pfn) << PFN_SHIFT_OFFSET) |\
                                        pgprot_val(prot))
  #define mk_pte(page, prot)    pfn_pte(page_to_pfn(page), prot)
- /*
-  * ZERO_PAGE is a global shared page that is always zero: used
-  * for zero-mapped memory areas etc..
-  */
- extern unsigned long empty_zero_page[1024];
- #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  #endif /* __ASSEMBLY__ */
  
  #define pte_none(pte)         ((pte_val(pte) & ~_PTE_NONE_MASK) == 0)
   * The following only work if pte_present() is true.
   * Undefined behaviour if not..
   */
 -static inline int pte_read(pte_t pte)         { return pte_val(pte) & _PAGE_USER; }
  static inline int pte_write(pte_t pte)                { return pte_val(pte) & _PAGE_RW; }
 -static inline int pte_exec(pte_t pte)         { return pte_val(pte) & _PAGE_EXEC; }
  static inline int pte_dirty(pte_t pte)                { return pte_val(pte) & _PAGE_DIRTY; }
  static inline int pte_young(pte_t pte)                { return pte_val(pte) & _PAGE_ACCESSED; }
  static inline int pte_file(pte_t pte)         { return pte_val(pte) & _PAGE_FILE; }
  static inline void pte_uncache(pte_t pte)       { pte_val(pte) |= _PAGE_NO_CACHE; }
  static inline void pte_cache(pte_t pte)         { pte_val(pte) &= ~_PAGE_NO_CACHE; }
  
 -static inline pte_t pte_rdprotect(pte_t pte) {
 -      pte_val(pte) &= ~_PAGE_USER; return pte; }
  static inline pte_t pte_wrprotect(pte_t pte) {
        pte_val(pte) &= ~(_PAGE_RW | _PAGE_HWWRITE); return pte; }
 -static inline pte_t pte_exprotect(pte_t pte) {
 -      pte_val(pte) &= ~_PAGE_EXEC; return pte; }
  static inline pte_t pte_mkclean(pte_t pte) {
        pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HWWRITE); return pte; }
  static inline pte_t pte_mkold(pte_t pte) {
        pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
  
 -static inline pte_t pte_mkread(pte_t pte) {
 -      pte_val(pte) |= _PAGE_USER; return pte; }
 -static inline pte_t pte_mkexec(pte_t pte) {
 -      pte_val(pte) |= _PAGE_USER | _PAGE_EXEC; return pte; }
  static inline pte_t pte_mkwrite(pte_t pte) {
        pte_val(pte) |= _PAGE_RW; return pte; }
  static inline pte_t pte_mkdirty(pte_t pte) {
@@@ -724,10 -722,6 +712,6 @@@ extern pgprot_t phys_mem_access_prot(st
  #define pte_unmap(pte)                kunmap_atomic(pte, KM_PTE0)
  #define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1)
  
- extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
- extern void paging_init(void);
  /*
   * Encode and decode a swap entry.
   * Note that the bits we use in a PTE for representing a swap entry
  #define pte_to_pgoff(pte)     (pte_val(pte) >> 3)
  #define pgoff_to_pte(off)     ((pte_t) { ((off) << 3) | _PAGE_FILE })
  
- /* CONFIG_APUS */
- /* For virtual address to physical address conversion */
- extern void cache_clear(__u32 addr, int length);
- extern void cache_push(__u32 addr, int length);
- extern int mm_end_of_chunk (unsigned long addr, int len);
- extern unsigned long iopa(unsigned long addr);
- extern unsigned long mm_ptov(unsigned long addr) __attribute_const__;
- /* Values for nocacheflag and cmode */
- /* These are not used by the APUS kernel_map, but prevents
-    compilation errors. */
- #define       KERNELMAP_FULL_CACHING          0
- #define       KERNELMAP_NOCACHE_SER           1
- #define       KERNELMAP_NOCACHE_NONSER        2
- #define       KERNELMAP_NO_COPYBACK           3
- /*
-  * Map some physical address range into the kernel address space.
-  */
- extern unsigned long kernel_map(unsigned long paddr, unsigned long size,
-                               int nocacheflag, unsigned long *memavailp );
- /*
-  * Set cache mode of (kernel space) address range.
-  */
- extern void kernel_set_cachemode (unsigned long address, unsigned long size,
-                                  unsigned int cmode);
- /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
- #define kern_addr_valid(addr) (1)
- #define io_remap_pfn_range(vma, vaddr, pfn, size, prot)               \
-               remap_pfn_range(vma, vaddr, pfn, size, prot)
  /*
   * No page table caches to initialise
   */
@@@ -7,11 -7,7 +7,7 @@@
  
  #ifndef __ASSEMBLY__
  #include <linux/stddef.h>
- #include <asm/processor.h>            /* For TASK_SIZE */
- #include <asm/mmu.h>
- #include <asm/page.h>
  #include <asm/tlbflush.h>
- struct mm_struct;
  #endif /* __ASSEMBLY__ */
  
  #ifdef CONFIG_PPC_64K_PAGES
@@@ -27,7 -23,7 +23,7 @@@
   */
  #define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
                            PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT)
- #define PGTABLE_RANGE (1UL << PGTABLE_EADDR_SIZE)
+ #define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE)
  
  #if TASK_SIZE_USER64 > PGTABLE_RANGE
  #error TASK_SIZE_USER64 exceeds pagetable range
  #error TASK_SIZE_USER64 exceeds user VSID range
  #endif
  
  /*
   * Define the address range of the vmalloc VM area.
   */
  #define VMALLOC_START ASM_CONST(0xD000000000000000)
- #define VMALLOC_SIZE  ASM_CONST(0x80000000000)
+ #define VMALLOC_SIZE  (PGTABLE_RANGE >> 1)
  #define VMALLOC_END   (VMALLOC_START + VMALLOC_SIZE)
  
  /*
-  * Define the address range of the imalloc VM area.
+  * Define the address ranges for MMIO and IO space :
+  *
+  *  ISA_IO_BASE = VMALLOC_END, 64K reserved area
+  *  PHB_IO_BASE = ISA_IO_BASE + 64K to ISA_IO_BASE + 2G, PHB IO spaces
+  * IOREMAP_BASE = ISA_IO_BASE + 2G to VMALLOC_START + PGTABLE_RANGE
   */
- #define PHBS_IO_BASE  VMALLOC_END
- #define IMALLOC_BASE  (PHBS_IO_BASE + 0x80000000ul)   /* Reserve 2 gigs for PHBs */
- #define IMALLOC_END   (VMALLOC_START + PGTABLE_RANGE)
+ #define FULL_IO_SIZE  0x80000000ul
+ #define  ISA_IO_BASE  (VMALLOC_END)
+ #define  ISA_IO_END   (VMALLOC_END + 0x10000ul)
+ #define  PHB_IO_BASE  (ISA_IO_END)
+ #define  PHB_IO_END   (VMALLOC_END + FULL_IO_SIZE)
+ #define IOREMAP_BASE  (PHB_IO_END)
+ #define IOREMAP_END   (VMALLOC_START + PGTABLE_RANGE)
  
  /*
   * Region IDs
  #define __S110        PAGE_SHARED_X
  #define __S111        PAGE_SHARED_X
  
- #ifndef __ASSEMBLY__
- /*
-  * ZERO_PAGE is a global shared page that is always zero: used
-  * for zero-mapped memory areas etc..
-  */
- extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
- #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
- #endif /* __ASSEMBLY__ */
  #ifdef CONFIG_HUGETLB_PAGE
  
  #define HAVE_ARCH_UNMAPPED_AREA
@@@ -232,7 -227,9 +227,7 @@@ static inline pte_t pfn_pte(unsigned lo
   * The following only work if pte_present() is true.
   * Undefined behaviour if not..
   */
 -static inline int pte_read(pte_t pte)  { return pte_val(pte) & _PAGE_USER;}
  static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW;}
 -static inline int pte_exec(pte_t pte)  { return pte_val(pte) & _PAGE_EXEC;}
  static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
  static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
  static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
  static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
  static inline void pte_cache(pte_t pte)   { pte_val(pte) &= ~_PAGE_NO_CACHE; }
  
 -static inline pte_t pte_rdprotect(pte_t pte) {
 -      pte_val(pte) &= ~_PAGE_USER; return pte; }
 -static inline pte_t pte_exprotect(pte_t pte) {
 -      pte_val(pte) &= ~_PAGE_EXEC; return pte; }
  static inline pte_t pte_wrprotect(pte_t pte) {
        pte_val(pte) &= ~(_PAGE_RW); return pte; }
  static inline pte_t pte_mkclean(pte_t pte) {
        pte_val(pte) &= ~(_PAGE_DIRTY); return pte; }
  static inline pte_t pte_mkold(pte_t pte) {
        pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
 -static inline pte_t pte_mkread(pte_t pte) {
 -      pte_val(pte) |= _PAGE_USER; return pte; }
 -static inline pte_t pte_mkexec(pte_t pte) {
 -      pte_val(pte) |= _PAGE_USER | _PAGE_EXEC; return pte; }
  static inline pte_t pte_mkwrite(pte_t pte) {
        pte_val(pte) |= _PAGE_RW; return pte; }
  static inline pte_t pte_mkdirty(pte_t pte) {
@@@ -432,10 -437,6 +427,6 @@@ extern pgprot_t phys_mem_access_prot(st
  #define pgd_ERROR(e) \
        printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
  
- extern pgd_t swapper_pg_dir[];
- extern void paging_init(void);
  /* Encode and de-code a swap entry */
  #define __swp_type(entry)     (((entry).val >> 1) & 0x3f)
  #define __swp_offset(entry)   ((entry).val >> 8)
  #define pgoff_to_pte(off)     ((pte_t) {((off) << PTE_RPN_SHIFT)|_PAGE_FILE})
  #define PTE_FILE_MAX_BITS     (BITS_PER_LONG - PTE_RPN_SHIFT)
  
- /*
-  * kern_addr_valid is intended to indicate whether an address is a valid
-  * kernel address.  Most 32-bit archs define it as always true (like this)
-  * but most 64-bit archs actually perform a test.  What should we do here?
-  * The only use is in fs/ncpfs/dir.c
-  */
- #define kern_addr_valid(addr) (1)
- #define io_remap_pfn_range(vma, vaddr, pfn, size, prot)               \
-               remap_pfn_range(vma, vaddr, pfn, size, prot)
  void pgtable_cache_init(void);
  
  /*