1. 28 6月, 2016 2 次提交
    • M
      cxl: Add set and get private data to context struct · ad42de85
      Michael Neuling 提交于
      This provides AFU drivers a means to associate private data with a cxl
      context. This is particularly intended for make the new callbacks for
      driver specific events easier for AFU drivers to use, as they can easily
      get back to any private data structures they may use.
      Signed-off-by: NMichael Neuling <mikey@neuling.org>
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: Philippe Bergheaud <felix@linux.vnet.ibm.com
      Reviewed-by: NMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
      Reviewed-by: NAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      ad42de85
    • P
      cxl: Add mechanism for delivering AFU driver specific events · b810253b
      Philippe Bergheaud 提交于
      This adds an afu_driver_ops structure with fetch_event() and
      event_delivered() callbacks. An AFU driver such as cxlflash can fill
      this out and associate it with a context to enable passing custom AFU
      specific events to userspace.
      
      This also adds a new kernel API function cxl_context_pending_events(),
      that the AFU driver can use to notify the cxl driver that new specific
      events are ready to be delivered, and wake up anyone waiting on the
      context wait queue.
      
      The current count of AFU driver specific events is stored in the field
      afu_driver_events of the context structure.
      
      The cxl driver checks the afu_driver_events count during poll, select,
      read, etc. calls to check if an AFU driver specific event is pending,
      and calls fetch_event() to obtain and deliver that event. This way, the
      cxl driver takes care of all the usual locking semantics around these
      calls and handles all the generic cxl events, so that the AFU driver
      only needs to worry about it's own events.
      
      fetch_event() return a struct cxl_event_afu_driver_reserved, allocated
      by the AFU driver, and filled in with the specific event information and
      size. Total event size (header + data) should not be greater than
      CXL_READ_MIN_SIZE (4K).
      
      Th cxl driver prepends an appropriate cxl event header, copies the event
      to userspace, and finally calls event_delivered() to return the status of
      the operation to the AFU driver. The event is identified by the context
      and cxl_event_afu_driver_reserved pointers.
      
      Since AFU drivers provide their own means for userspace to obtain the
      AFU file descriptor (i.e. cxlflash uses an ioctl on their scsi file
      descriptor to obtain the AFU file descriptor) and the generic cxl driver
      will never use this event, the ABI of the event is up to each individual
      AFU driver.
      Signed-off-by: NPhilippe Bergheaud <felix@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      b810253b
  2. 16 6月, 2016 3 次提交
    • I
      cxl: Add support for CAPP DMA mode · b385c9e9
      Ian Munsie 提交于
      This adds support for using CAPP DMA mode, which is required for XSL
      based cards such as the Mellanox CX4 to function.
      
      This is currently an RFC as it depends on the corresponding support to
      be merged into skiboot first, which was submitted here:
      http://patchwork.ozlabs.org/patch/625582/
      
      In the event that the skiboot on the system does not have the above
      support, it will indicate as such in the kernel log and abort the init
      process.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      b385c9e9
    • F
      cxl: Abstract the differences between the PSL and XSL · 6d382616
      Frederic Barrat 提交于
      The XSL (Translation Service Layer) is a stripped down version of the
      PSL (Power Service Layer) used in some cards such as the Mellanox CX4.
      
      Like the PSL, it implements the CAIA architecture, but has a number of
      differences, mostly in it's implementation dependent registers. This
      adds an ops structure to abstract these differences to bring initial
      support for XSL CAPI devices.
      
      The XSL does not implement the optional architected SERR register,
      however while it treats it as a reserved register and should work with
      no special treatment, attempting to access it will cause the XSL_FEC
      (First Error Capture) register to be filled out, preventing it from
      capturing any subsequent errors. Therefore, this patch also prevents the
      kernel from trying to set up the SERR register so that the FEC register
      may still be useful, and to save one interrupt.
      
      The XSL also uses a special DMA cxl mode, which uses a slightly
      different init sequence for the CAPP and PHB. The kernel support for
      this will be in a future patch once the corresponding support has been
      merged into skiboot.
      Co-authored-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      6d382616
    • I
      cxl: Update process element after allocating interrupts · 292841b0
      Ian Munsie 提交于
      In the kernel API, it is possible to attempt to allocate AFU interrupts
      after already starting a context. Since the process element structure
      used by the hardware is only filled out at the time the context is
      started, it will not be updated with the interrupt numbers that have
      just been allocated and therefore AFU interrupts will not work unless
      they were allocated prior to starting the context.
      
      This can present some difficulties as each CAPI enabled PCI device in
      the kernel API has a default context, which may need to be started very
      early to enable translations, potentially before interrupts can easily
      be set up.
      
      This patch makes the API more flexible to allow interrupts to be
      allocated after a context has already been started and takes care of
      updating the PE structure used by the hardware and notifying it to
      discard any cached copy it may have.
      
      The update is currently performed via a terminate/remove/add sequence.
      This is necessary on some hardware such as the XSL that does not
      properly support the update LLCMD.
      
      Note that this is only supported on powernv at present - attempting to
      perform this ordering on PowerVM will raise a warning.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: NFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      292841b0
  3. 11 5月, 2016 3 次提交
    • C
      cxl: Check periodically the coherent platform function's state · 266eab8f
      Christophe Lombard 提交于
      In the PowerVM environment, the PHYP CoherentAccel component manages
      the state of the Coherent Accelerator Processor Interface adapter and
      virtualizes CAPI resources, handles CAPP, PSL, PSL Slice errors - and
      interrupts - and provides a new set of hcalls for the OS APIs to utilize
      Accelerator Function Unit (AFU).
      
      During the course of operation, a coherent platform function can
      encounter errors. Some possible reason for errors are:
      • Hardware recoverable and unrecoverable errors
      • Transient and over-threshold correctable errors
      
      PHYP implements its own state model for the coherent platform function.
      The state of the AFU is available through a hcall.
      
      The current implementation of the cxl driver, for the PowerVM
      environment, checks this state of the AFU only when an action is
      requested - open a device, ioctl command, memory map, attach/detach a
      process - from an external driver - cxlflash, libcxl. If an error is
      detected the cxl driver handles the error according the content of the
      Power Architecture Platform Requirements document.
      
      But in case of low-level troubles (or error injection), the PHYP
      component may reset the card and change the AFU state. The PHYP
      interface doesn't provide any way to be notified when that happens thus
      implies that the cxl driver:
      • cannot handle immediatly the state change of the AFU.
      • cannot notify other drivers (cxlflash, ...)
      
      The purpose of this patch is to wake up the cpu periodically to check
      the current state of each AFU and to see if we need to enter an error
      recovery path.
      Signed-off-by: NChristophe Lombard <clombard@linux.vnet.ibm.com>
      Acked-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      266eab8f
    • I
      cxl: Add kernel API to allow a context to operate with relocate disabled · 7a0d85d3
      Ian Munsie 提交于
      cxl devices typically access memory using an MMU in much the same way as
      the CPU, and each context includes a state register much like the MSR in
      the CPU. Like the CPU, the state register includes a bit to enable
      relocation, which we currently always enable.
      
      In some cases, it may be desirable to allow a device to access memory
      using real addresses instead of effective addresses, so this adds a new
      API, cxl_set_translation_mode, that can be used to disable relocation
      on a given kernel context. This can allow for the creation of a special
      privileged context that the device can use if it needs relocation
      disabled, and can use regular contexts at times when it needs relocation
      enabled.
      
      This interface is only available to users of the kernel API for obvious
      reasons, and will never be supported in a virtualised environment.
      
      This will be used by the upcoming cxl support in the mlx5 driver.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      7a0d85d3
    • I
      cxl: Remove duplicate #defines · 0e5b5ba1
      Ian Munsie 提交于
      These defines are not used, but other equivalent definitions
      (CXL_SPA_SW_CMD_*) are used. Remove the unused defines.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Reviewed-by: NAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      0e5b5ba1
  4. 27 4月, 2016 1 次提交
  5. 22 4月, 2016 1 次提交
  6. 09 3月, 2016 14 次提交
  7. 05 1月, 2016 1 次提交
  8. 24 11月, 2015 1 次提交
    • V
      cxl: Fix possible idr warning when contexts are released · 1b5df59e
      Vaibhav Jain 提交于
      An idr warning is reported when a context is release after the capi card
      is unbound from the cxl driver via sysfs. Below are the steps to
      reproduce:
      
      1. Create multiple afu contexts in an user-space application using libcxl.
      2. Unbind capi card from cxl using command of form
         echo <capi-card-pci-addr> > /sys/bus/pci/drivers/cxl-pci/unbind
      3. Exit/kill the application owning afu contexts.
      
      After above steps a warning message is usually seen in the kernel logs
      of the form "idr_remove called for id=<context-id> which is not
      allocated."
      
      This is caused by the function cxl_release_afu which destroys the
      contexts_idr table. So when a context is release no entry for context pe
      is found in the contexts_idr table and idr code prints this warning.
      
      This patch fixes this issue by increasing & decreasing the ref-count on
      the afu device when a context is initialized or when its freed
      respectively. This prevents the afu from being released until all the
      afu contexts have been released. The patch introduces two new functions
      namely cxl_afu_get/put that manage the ref-count on the afu device.
      
      Also the patch removes code inside cxl_dev_context_init that increases ref
      on the afu device as its guaranteed to be alive during this function.
      Reported-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NVaibhav Jain <vaibhav@linux.vnet.ibm.com>
      Acked-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      1b5df59e
  9. 01 10月, 2015 1 次提交
  10. 30 8月, 2015 2 次提交
  11. 18 8月, 2015 1 次提交
    • I
      cxl: Add alternate MMIO error handling · d9232a3d
      Ian Munsie 提交于
      userspace programs using cxl currently have to use two strategies for
      dealing with MMIO errors simultaneously. They have to check every read
      for a return of all Fs in case the adapter has gone away and the kernel
      has not yet noticed, and they have to deal with SIGBUS in case the
      kernel has already noticed, invalidated the mapping and marked the
      context as failed.
      
      In order to simplify things, this patch adds an alternative approach
      where the kernel will return a page filled with Fs instead of delivering
      a SIGBUS. This allows userspace to only need to deal with one of these
      two error paths, and is intended for use in libraries that use cxl
      transparently and may not be able to safely install a signal handler.
      
      This approach will only work if certain constraints are met. Namely, if
      the application is both reading and writing to an address in the problem
      state area it cannot assume that a non-FF read is OK, as it may just be
      reading out a value it has previously written. Further - since only one
      page is used per context a write to a given offset would be visible when
      reading the same offset from a different page in the mapping (this only
      applies within a single context, not between contexts).
      
      An application could deal with this by e.g. making sure it also reads
      from a read-only offset after any reads to a read/write offset.
      
      Due to these constraints, this functionality must be explicitly
      requested by userspace when starting the context by passing in the
      CXL_START_WORK_ERR_FF flag.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Acked-by: NMichael Neuling <mikey@neuling.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      d9232a3d
  12. 14 8月, 2015 5 次提交
    • D
      cxl: EEH support · 9e8df8a2
      Daniel Axtens 提交于
      EEH (Enhanced Error Handling) allows a driver to recover from the
      temporary failure of an attached PCI card. Enable basic CXL support
      for EEH.
      Signed-off-by: NDaniel Axtens <dja@axtens.net>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      9e8df8a2
    • D
      cxl: Allow the kernel to trust that an image won't change on PERST. · 13e68d8b
      Daniel Axtens 提交于
      Provide a kernel API and a sysfs entry which allow a user to specify
      that when a card is PERSTed, it's image will stay the same, allowing
      it to participate in EEH.
      
      cxl_reset is used to reflash the card. In that case, we cannot safely
      assert that the image will not change. Therefore, disallow cxl_reset
      if the flag is set.
      Signed-off-by: NDaniel Axtens <dja@axtens.net>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      13e68d8b
    • 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
    • D
      cxl: Convert MMIO read/write macros to inline functions · 588b34be
      Daniel Axtens 提交于
      We're about to make these more complex, so make them functions
      first.
      Signed-off-by: NDaniel Axtens <dja@axtens.net>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      588b34be
  13. 03 6月, 2015 5 次提交