1. 20 12月, 2011 1 次提交
    • S
      powerpc: Rename mapping based RELOCATABLE to DYNAMIC_MEMSTART for BookE · 0f890c8d
      Suzuki Poulose 提交于
      The current implementation of CONFIG_RELOCATABLE in BookE is based
      on mapping the page aligned kernel load address to KERNELBASE. This
      approach however is not enough for platforms, where the TLB page size
      is large (e.g, 256M on 44x). So we are renaming the RELOCATABLE used
      currently in BookE to DYNAMIC_MEMSTART to reflect the actual method.
      
      The CONFIG_RELOCATABLE for PPC32(BookE) based on processing of the
      dynamic relocations will be introduced in the later in the patch series.
      
      This change would allow the use of the old method of RELOCATABLE for
      platforms which can afford to enforce the page alignment (platforms with
      smaller TLB size).
      
      Changes since v3:
      
      * Introduced a new config, NONSTATIC_KERNEL, to denote a kernel which is
        either a RELOCATABLE or DYNAMIC_MEMSTART(Suggested by: Josh Boyer)
      Suggested-by: NScott Wood <scottwood@freescale.com>
      Tested-by: NScott Wood <scottwood@freescale.com>
      Signed-off-by: NSuzuki K. Poulose <suzuki@in.ibm.com>
      Cc: Scott Wood <scottwood@freescale.com>
      Cc: Kumar Gala <galak@kernel.crashing.org>
      Cc: Josh Boyer <jwboyer@gmail.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: linux ppc dev <linuxppc-dev@lists.ozlabs.org>
      Signed-off-by: NJosh Boyer <jwboyer@gmail.com>
      0f890c8d
  2. 19 12月, 2011 4 次提交
    • A
      powerpc: Fix comment explaining our VSID layout · b206590c
      Anton Blanchard 提交于
      We support 16TB of user address space and half a million contexts
      so update the comment to reflect this.
      Signed-off-by: NAnton Blanchard <anton@samba.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      b206590c
    • A
      powerpc: Fix wrong divisor in usecs_to_cputime · 9f5072d4
      Andreas Schwab 提交于
      Commit d57af9b2 (taskstats: use real microsecond granularity for CPU times)
      renamed msecs_to_cputime to usecs_to_cputime, but failed to update all
      numbers on the way.  This causes nonsensical cpu idle/iowait values to be
      displayed in /proc/stat (the only user of usecs_to_cputime so far).
      
      This also renames __cputime_msec_factor to __cputime_usec_factor, adapting
      its value and using it directly in cputime_to_usecs instead of doing two
      multiplications.
      Signed-off-by: NAndreas Schwab <schwab@linux-m68k.org>
      Acked-by: NAnton Blanchard <anton@samba.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      9f5072d4
    • M
      powerpc: Add __SANE_USERSPACE_TYPES__ to asm/types.h for LL64 · 2c9c6ce0
      Matt Evans 提交于
      PPC64 uses long long for u64 in the kernel, but powerpc's asm/types.h
      prevents 64-bit userland from seeing this definition, instead defaulting
      to u64 == long in userspace.  Some user programs (e.g. kvmtool) may actually
      want LL64, so this patch adds a check for __SANE_USERSPACE_TYPES__ so that,
      if defined, int-ll64.h is included instead.
      Signed-off-by: NMatt Evans <matt@ozlabs.org>
      Acked-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      2c9c6ce0
    • A
      powerpc: POWER7 optimised copy_to_user/copy_from_user using VMX · a66086b8
      Anton Blanchard 提交于
      Implement a POWER7 optimised copy_to_user/copy_from_user using VMX.
      For large aligned copies this new loop is over 10% faster, and for
      large unaligned copies it is over 200% faster.
      
      If we take a fault we fall back to the old version, this keeps
      things relatively simple and easy to verify.
      
      On POWER7 unaligned stores rarely slow down - they only flush when
      a store crosses a 4KB page boundary. Furthermore this flush is
      handled completely in hardware and should be 20-30 cycles.
      
      Unaligned loads on the other hand flush much more often - whenever
      crossing a 128 byte cache line, or a 32 byte sector if either sector
      is an L1 miss.
      
      Considering this information we really want to get the loads aligned
      and not worry about the alignment of the stores. Microbenchmarks
      confirm that this approach is much faster than the current unaligned
      copy loop that uses shifts and rotates to ensure both loads and
      stores are aligned.
      
      We also want to try and do the stores in cacheline aligned, cacheline
      sized chunks. If the store queue is unable to merge an entire
      cacheline of stores then the L2 cache will have to do a
      read/modify/write. Even worse, we will serialise this with the stores
      in the next iteration of the copy loop since both iterations hit
      the same cacheline.
      
      Based on this, the new loop does the following things:
      
      1 - 127 bytes
      Get the source 8 byte aligned and use 8 byte loads and stores. Pretty
      boring and similar to how the current loop works.
      
      128 - 4095 bytes
      Get the source 8 byte aligned and use 8 byte loads and stores,
      1 cacheline at a time. We aren't doing the stores in cacheline
      aligned chunks so we will potentially serialise once per cacheline.
      Even so it is much better than the loop we have today.
      
      4096 - bytes
      If both source and destination have the same alignment get them both
      16 byte aligned, then get the destination cacheline aligned. Do
      cacheline sized loads and stores using VMX.
      
      If source and destination do not have the same alignment, we get the
      destination cacheline aligned, and use permute to do aligned loads.
      
      In both cases the VMX loop should be optimal - we always do aligned
      loads and stores and are always doing stores in cacheline aligned,
      cacheline sized chunks.
      
      To be able to use VMX we must be careful about interrupts and
      sleeping. We don't use the VMX loop when in an interrupt (which should
      be rare anyway) and we wrap the VMX loop in disable/enable_pagefault
      and fall back to the existing copy_tofrom_user loop if we do need to
      sleep.
      
      The VMX breakpoint of 4096 bytes was chosen using this microbenchmark:
      
      http://ozlabs.org/~anton/junkcode/copy_to_user.c
      
      Since we are using VMX and there is a cost to saving and restoring
      the user VMX state there are two broad cases we need to benchmark:
      
      - Best case - userspace never uses VMX
      
      - Worst case - userspace always uses VMX
      
      In reality a userspace process will sit somewhere between these two
      extremes. Since we need to test both aligned and unaligned copies we
      end up with 4 combinations. The point at which the VMX loop begins to
      win is:
      
      0% VMX
      aligned		2048 bytes
      unaligned	2048 bytes
      
      100% VMX
      aligned		16384 bytes
      unaligned	8192 bytes
      
      Considering this is a microbenchmark, the data is hot in cache and
      the VMX loop has better store queue merging properties we set the
      breakpoint to 4096 bytes, a little below the unaligned breakpoints.
      
      Some future optimisations we can look at:
      
      - Looking at the perf data, a significant part of the cost when a
        task is always using VMX is the extra exception we take to restore
        the VMX state. As such we should do something similar to the x86
        optimisation that restores FPU state for heavy users. ie:
      
              /*
               * If the task has used fpu the last 5 timeslices, just do a full
               * restore of the math state immediately to avoid the trap; the
               * chances of needing FPU soon are obviously high now
               */
              preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;
      
        and
      
              /*
               * fpu_counter contains the number of consecutive context switches
               * that the FPU is used. If this is over a threshold, the lazy fpu
               * saving becomes unlazy to save the trap. This is an unsigned char
               * so that after 256 times the counter wraps and the behavior turns
               * lazy again; this to deal with bursty apps that only use FPU for
               * a short time
               */
      
      - We could create a paca bit to mirror the VMX enabled MSR bit and check
        that first, avoiding multiple calls to calling enable_kernel_altivec.
        That should help with iovec based system calls like readv.
      
      - We could have two VMX breakpoints, one for when we know the user VMX
        state is loaded into the registers and one when it isn't. This could
        be a second bit in the paca so we can calculate the break points quickly.
      
      - One suggestion from Ben was to save and restore the VSX registers
        we use inline instead of using enable_kernel_altivec.
      
      [BenH: Fixed a problem with preempt and fixed build without CONFIG_ALTIVEC]
      Signed-off-by: NAnton Blanchard <anton@samba.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      a66086b8
  3. 16 12月, 2011 1 次提交
  4. 09 12月, 2011 1 次提交
  5. 08 12月, 2011 12 次提交
  6. 07 12月, 2011 11 次提交
  7. 28 11月, 2011 1 次提交
    • S
      powerpc: Implement CONFIG_STRICT_DEVMEM · 1d54cf2b
      sukadev@linux.vnet.ibm.com 提交于
      As described in the help text in the patch, this token restricts general
      access to /dev/mem as a way of increasing the security. Specifically, access
      to exclusive IOMEM and kernel RAM is denied unless CONFIG_STRICT_DEVMEM is
      set to 'n'.
      
      Implement the 'devmem_is_allowed()' interface for Powerpc. It will be
      called from range_is_allowed() when userpsace attempts to access /dev/mem.
      
      This patch is based on an earlier patch from Steve Best and with input from
      Paul Mackerras and Scott Wood.
      
      [BenH] Fixed a typo or two and removed the generic change which should
             be submitted as a separate patch
      Signed-off-by: NSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      1d54cf2b
  8. 25 11月, 2011 9 次提交
    • B
      powerpc/powernv: PCI support for p7IOC under OPAL v2 · 184cd4a3
      Benjamin Herrenschmidt 提交于
      This adds support for p7IOC (and possibly other IODA v1 IO Hubs)
      using OPAL v2 interfaces.
      
      We completely take over resource assignment and assign them using an
      algorithm that hands out device BARs in a way that makes them fit in
      individual segments of the M32 window of the bridge, which enables us
      to assign individual PEs to devices and functions.
      
      The current implementation gives out a PE per functions on PCIe, and a
      PE for the entire bridge for PCIe to PCI-X bridges.
      
      This can be adjusted / fine tuned later.
      
      We also setup DMA resources (32-bit only for now) and MSIs (both 32-bit
      and 64-bit MSI are supported).
      
      The DMA allocation tries to divide the available 256M segments of the
      32-bit DMA address space "fairly" among PEs. This is done using a
      "weight" heuristic which assigns less value to things like OHCI USB
      controllers than, for example SCSI RAID controllers. This algorithm
      will probably want some fine tuning for specific devices or device
      types.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      184cd4a3
    • B
      powerpc/powernv: Add TCE SW invalidation support · 1f1616e8
      Benjamin Herrenschmidt 提交于
      This is used for newer IO Hubs such as p7IOC.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      1f1616e8
    • B
      powerpc/pci: Add a platform hook after probe and before resource survey · 491b98c3
      Benjamin Herrenschmidt 提交于
      Some platforms need to perform resource allocation using a custom algorithm
      due to HW constraints, or may want to tweak things globally below a host
      bridge. For example OPAL support for IODA will need to perform a
      resource allocation pass that applies IODA specific segmentation
      constraints to MMIO which cannot be done simply using the kernel generic
      resource management code.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      491b98c3
    • G
      powerpc: Add pgprot_cached_noncoherent() · 09c188c4
      Geoff Thorpe 提交于
      This adds a pgprot combination required by some cache-enabled IO device
      mappings, such as Freescale datapath (QMan and BMan) portals.
      Signed-off-by: NGeoff Thorpe <geoff@geoffthorpe.net>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      09c188c4
    • R
      powerpc/pseries: Cancel RTAS event scan before firmware flash · df17f56d
      Ravi K. Nittala 提交于
      The RTAS firmware flash update is conducted using an RTAS call that is
      serialized by lock_rtas() which uses spin_lock. While the flash is in
      progress, rtasd performs scan for any RTAS events that are generated by
      the system. rtasd keeps scanning for the RTAS events generated on the
      machine. This is performed via workqueue mechanism. The rtas_event_scan()
      also uses an RTAS call to scan the events, eventually trying to acquire
      the spin_lock before issuing the request.
      
      The flash update takes a while to complete and during this time, any other
      RTAS call has to wait. In this case, rtas_event_scan() waits for a long time
      on the spin_lock resulting in a soft lockup.
      
      Fix: Just before the flash update is performed, the queued rtas_event_scan()
      work item is cancelled from the work queue so that there is no other RTAS
      call issued while the flash is in progress. After the flash completes, the
      system reboots and the rtas_event_scan() is rescheduled.
      Signed-off-by: NSuzuki Poulose <suzuki@in.ibm.com>
      Signed-off-by: NRavi Nittala <ravi.nittala@in.ibm.com>
      Reported-by: NDivya Vikas <divya.vikas@in.ibm.com>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      df17f56d
    • J
      powerpc/book3e: Add ICSWX/ACOP support to Book3e cores like A2 · fac26ad4
      Jimi Xenidis 提交于
      ICSWX is also used by the A2 processor to access coprocessors,
      although not all "chips" that contain A2s have coprocessors.
      Signed-off-by: NJimi Xenidis <jimix@pobox.com>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      fac26ad4
    • M
      powerpc/pseries: Software invalidatation of TCEs · 8d3d589a
      Milton Miller 提交于
      Some pseries IOMMUs cache TCEs but don't snoop when the TCEs are changed
      in memory, hence we need manually invalidate in software.
      
      This adds code to do the invalidate.  It keys off a device tree property
      to say where the to do the MMIO for the invalidate and some information
      on what the format of the invalidate including some magic routing info.
      
      it_busno get overloaded with this magic routing info and it_index with
      the MMIO address for the invalidate command.
      
      This then gets hooked into the building and freeing of TCEs.
      
      This is only useful on bare metal pseries.  pHyp takes care of this when
      virtualised.
      
      Based on patch from Milton with cleanups from Mikey.
      Signed-off-by: NMilton Miller <miltonm@bga.com>
      Signed-off-by: NMichael Neuling <mikey@neuling.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      8d3d589a
    • A
      powerpc/time: Optimise decrementer_check_overflow · 7df10275
      Anton Blanchard 提交于
      decrementer_check_overflow is called from arch_local_irq_restore so
      we want to make it as light weight as possible. As such, turn
      decrementer_check_overflow into an inline function.
      
      To avoid a circular mess of includes, separate out the two components
      of struct decrementer_clock and keep the struct clock_event_device
      part local to time.c.
      
      The fast path improves from:
      
      arch_local_irq_restore
           0:       mflr    r0
           4:       std     r0,16(r1)
           8:       stdu    r1,-112(r1)
           c:       stb     r3,578(r13)
          10:       cmpdi   cr7,r3,0
          14:       beq-    cr7,24 <.arch_local_irq_restore+0x24>
      ...
          24:       addi    r1,r1,112
          28:       ld      r0,16(r1)
          2c:       mtlr    r0
          30:       blr
      
      to:
      
      arch_local_irq_restore
          0:       std     r30,-16(r1)
          4:       ld      r30,0(r2)
          8:       stb     r3,578(r13)
          c:       cmpdi   cr7,r3,0
         10:       beq-    cr7,6c <.arch_local_irq_restore+0x6c>
      ...
         6c:       ld      r30,-16(r1)
         70:       blr
      
      Unfortunately we still setup a local TOC (due to -mminimal-toc). Yet
      another sign we should be moving to -mcmodel=medium.
      Signed-off-by: NAnton Blanchard <anton@samba.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      7df10275
    • A
      powerpc/time: Handle wrapping of decrementer · 37fb9a02
      Anton Blanchard 提交于
      When re-enabling interrupts we have code to handle edge sensitive
      decrementers by resetting the decrementer to 1 whenever it is negative.
      If interrupts were disabled long enough that the decrementer wrapped to
      positive we do nothing. This means interrupts can be delayed for a long
      time until it finally goes negative again.
      
      While we hope interrupts are never be disabled long enough for the
      decrementer to go positive, we have a very good test team that can
      drive any kernel into the ground. The softlockup data we get back
      from these fails could be seconds in the future, completely missing
      the cause of the lockup.
      
      We already keep track of the timebase of the next event so use that
      to work out if we should trigger a decrementer exception.
      Signed-off-by: NAnton Blanchard <anton@samba.org>
      Cc: stable@kernel.org
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      37fb9a02