1. 08 12月, 2015 1 次提交
  2. 07 10月, 2015 1 次提交
    • C
      cxl: Fix number of allocated pages in SPA · 4108efb0
      Christophe Lombard 提交于
      The scheduled process area is currently allocated before assigning the
      correct maximum processes to the AFU, which will mean we only ever
      allocate a fixed number of pages for the scheduled process area. This
      will limit us to 958 processes with 2 x 64K pages. If we try to use more
      processes than that we'd probably overrun the buffer and corrupt memory
      or crash.
      
      AFUs that require three or more interrupts per process will not be
      affected as they are already limited to less processes than that, but we
      could hit it on an AFU that requires 0, 1 or 2 interrupts per process,
      or when using 4K pages.
      
      This patch moves the initialisation of the num_procs to before the SPA
      allocation so that enough pages will be allocated for the number of
      processes that the AFU supports.
      Signed-off-by: NChristophe Lombard <clombard@linux.vnet.ibm.com>
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Cc: <stable@vger.kernel.org> # 3.18+
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      4108efb0
  3. 14 8月, 2015 2 次提交
    • D
      cxl: Allocate and release the SPA with the AFU · 05155772
      Daniel Axtens 提交于
      Previously the SPA was allocated and freed upon entering and leaving
      AFU-directed mode. This causes some issues for error recovery - contexts
      hold a pointer inside the SPA, and they may persist after the AFU has
      been detached.
      
      We would ideally like to allocate the SPA when the AFU is allocated, and
      release it until the AFU is released. However, we don't know how big the
      SPA needs to be until we read the AFU descriptor.
      
      Therefore, restructure the code:
      
       - Allocate the SPA only once, on the first attach.
      
       - Release the SPA only when the entire AFU is being released (not
         detached). Guard the release with a NULL check, so we don't free
         if it was never allocated (e.g. dedicated mode)
      Acked-by: NCyril Bur <cyrilbur@gmail.com>
      Signed-off-by: NDaniel Axtens <dja@axtens.net>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      05155772
    • D
      cxl: Drop commands if the PCI channel is not in normal state · 0b3f9c75
      Daniel Axtens 提交于
      If the PCI channel has gone down, don't attempt to poke the hardware.
      
      We need to guard every time cxl_whatever_(read|write) is called. This
      is because a call to those functions will dereference an offset into an
      mmio register, and the mmio mappings get invalidated in the EEH
      teardown.
      
      Check in the read/write functions in the header.
      We give them the same semantics as usual PCI operations:
       - a write to a channel that is down is ignored.
       - a read from a channel that is down returns all fs.
      
      Also, we try to access the MMIO space of a vPHB device as part of the
      PCI disable path. Because that's a read that bypasses most of our usual
      checks, we handle it explicitly.
      
      As far as user visible warnings go:
       - Check link state in file ops, return -EIO if down.
       - Be reasonably quiet if there's an error in a teardown path,
         or when we already know the hardware is going down.
       - Throw a big WARN if someone tries to start a CXL operation
         while the card is down. This gives a useful stacktrace for
         debugging whatever is doing that.
      Signed-off-by: NDaniel Axtens <dja@axtens.net>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      0b3f9c75
  4. 06 8月, 2015 1 次提交
  5. 13 7月, 2015 1 次提交
  6. 03 6月, 2015 4 次提交
  7. 22 1月, 2015 1 次提交
    • I
      cxl: Add tracepoints · 9bcf28cd
      Ian Munsie 提交于
      This patch adds tracepoints throughout the cxl driver, which can provide
      insight into:
      
      - Context lifetimes
      - Commands sent to the PSL and AFU and their completion status
      - Segment and page table misses and their resolution
      - PSL and AFU interrupts
      - slbia calls from the powerpc copro_fault code
      
      These tracepoints are mostly intended to aid in debugging (particularly
      for new AFU designs), and may be useful standalone or in conjunction
      with hardware traces collected by the PSL (read out via the trace
      interface in debugfs) and AFUs.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      9bcf28cd
  8. 29 12月, 2014 1 次提交
    • I
      cxl: Disable SPAP register when freeing SPA · db7933f3
      Ian Munsie 提交于
      When we deactivate the AFU directed mode we free the scheduled process
      area, but did not clear the register in the hardware that has a pointer
      to it.
      
      This should be fine since we will have already cleared out every context
      and we won't do anything that would cause the hardware to access it
      until after we have allocated a new one, but just to be safe this patch
      clears out the register when we free the page.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      db7933f3
  9. 12 12月, 2014 2 次提交
    • I
      cxl: Add timeout to process element commands · a98e6e9f
      Ian Munsie 提交于
      In the event that something goes wrong in the hardware and it is unable
      to complete a process element comment we would end up polling forever,
      effectively making the associated process unkillable.
      
      This patch adds a timeout to the process element command code path, so
      that we will give up if the hardware does not respond in a reasonable
      time.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      a98e6e9f
    • I
      cxl: Change contexts_lock to a mutex to fix sleep while atomic bug · ee41d11d
      Ian Munsie 提交于
      We had a known sleep while atomic bug if a CXL device was forcefully
      unbound while it was in use. This could occur as a result of EEH, or
      manually induced with something like this while the device was in use:
      
      echo 0000:01:00.0 > /sys/bus/pci/drivers/cxl-pci/unbind
      
      The issue was that in this code path we iterated over each context and
      forcefully detached it with the contexts_lock spin lock held, however
      the detach also needed to take the spu_mutex, and call schedule.
      
      This patch changes the contexts_lock to a mutex so that we are not in
      atomic context while doing the detach, thereby avoiding the sleep while
      atomic.
      
      Also delete the related TODO comment, which suggested an alternate
      solution which turned out to not be workable.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      ee41d11d
  10. 27 11月, 2014 1 次提交
    • I
      CXL: Return error to PSL if IRQ demultiplexing fails & print clearer warning · 27bbcef2
      Ian Munsie 提交于
      If an AFU has a hardware bug that causes it to acknowledge a context
      terminate or remove while that context has outstanding transactions, it
      is possible for the kernel to receive an interrupt for that context
      after we have removed it from the context list.
      
      The kernel will not be able to demultiplex the interrupt (or worse - if
      we have already reallocated the process handle we could mis-attribute it
      to the new context), and printed a big scary warning.
      
      It did not acknowledge the interrupt, which would effectively halt
      further translation fault processing on the PSL.
      
      This patch makes the warning clearer about the likely cause of the issue
      (i.e. hardware bug) to make it obvious to future AFU designers of what
      needs to be fixed. It also prints out the process handle which can then
      be matched up with hardware and software traces for debugging.
      
      It also acknowledges the interrupt to the PSL with either an address
      error or acknowledge, so that the PSL can continue with other
      translations.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      27bbcef2
  11. 18 11月, 2014 1 次提交
    • I
      cxl: Return error to PSL if IRQ demultiplexing fails & print clearer warning · bc78b05b
      Ian Munsie 提交于
      If an AFU has a hardware bug that causes it to acknowledge a context
      terminate or remove while that context has outstanding transactions, it
      is possible for the kernel to receive an interrupt for that context
      after we have removed it from the context list.
      
      The kernel will not be able to demultiplex the interrupt (or worse - if
      we have already reallocated the process handle we could mis-attribute it
      to the new context), and printed a big scary warning.
      
      It did not acknowledge the interrupt, which would effectively halt
      further translation fault processing on the PSL.
      
      This patch makes the warning clearer about the likely cause of the issue
      (i.e. hardware bug) to make it obvious to future AFU designers of what
      needs to be fixed. It also prints out the process handle which can then
      be matched up with hardware and software traces for debugging.
      
      It also acknowledges the interrupt to the PSL with either an address
      error or acknowledge, so that the PSL can continue with other
      translations.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      bc78b05b
  12. 28 10月, 2014 1 次提交
    • I
      cxl: Disable secondary hash in segment table · 5100a9d6
      Ian Munsie 提交于
      This patch simplifies the process of finding a free segment table entry
      by disabling the secondary hash. This reduces the number of possible
      entries in the segment table for a given address from 16 to 8.
      
      Due to the large segment sizes we use it is extremely unlikely that the
      secondary hash would ever have been used in practice, so this should not
      have any negative impacts and may even improve performance due to the
      reduced number of comparisons that software & hardware need to perform.
      
      This patch clears the SC bit in the hardware's state register
      (CXL_PSL_SR_An) to disable the secondary hash in the hardware since we
      can no longer fill out entries using it.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      5100a9d6
  13. 08 10月, 2014 1 次提交
    • I
      cxl: Driver code for powernv PCIe based cards for userspace access · f204e0b8
      Ian Munsie 提交于
      This is the core of the cxl driver.
      
      It adds support for using cxl cards in the powernv environment only (ie POWER8
      bare metal). It allows access to cxl accelerators by userspace using the
      /dev/cxl/afuM.N char devices.
      
      The kernel driver has no knowledge of the function implemented by the
      accelerator. It provides services to userspace via the /dev/cxl/afuM.N
      devices. When a program opens this device and runs the start work IOCTL, the
      accelerator will have coherent access to that processes memory using the same
      virtual addresses. That process may mmap the device to access any MMIO space
      the accelerator provides.  Also, reads on the device will allow interrupts to
      be received. These services are further documented in a later patch in
      Documentation/powerpc/cxl.txt.
      
      Documentation of the cxl hardware architecture and userspace API is provided in
      subsequent patches.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Neuling <mikey@neuling.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      f204e0b8