Skip to content
Snippets Groups Projects
  1. Feb 17, 2021
    • Ben Widawsky's avatar
      cxl/mem: Add basic IOCTL interface · 583fa5e7
      Ben Widawsky authored
      
      Add a straightforward IOCTL that provides a mechanism for userspace to
      query the supported memory device commands. CXL commands as they appear
      to userspace are described as part of the UAPI kerneldoc. The command
      list returned via this IOCTL will contain the full set of commands that
      the driver supports, however, some of those commands may not be
      available for use by userspace.
      
      Memory device commands first appear in the CXL 2.0 specification. They
      are submitted through a mailbox mechanism specified in the CXL 2.0
      specification.
      
      The send command allows userspace to issue mailbox commands directly to
      the hardware. The list of available commands to send are the output of
      the query command. The driver verifies basic properties of the command
      and possibly inspect the input (or output) payload to determine whether
      or not the command is allowed (or might taint the kernel).
      
      Reported-by: kernel test robot <lkp@intel.com> # bug in earlier revision
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarBen Widawsky <ben.widawsky@intel.com>
      Reviewed-by: Dan Williams <dan.j.williams@intel.com> (v2)
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Link: https://lore.kernel.org/r/20210217040958.1354670-5-ben.widawsky@intel.com
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      583fa5e7
    • Dan Williams's avatar
      cxl/mem: Register CXL memX devices · b39cb105
      Dan Williams authored
      
      Create the /sys/bus/cxl hierarchy to enumerate:
      
      * Memory Devices (per-endpoint control devices)
      
      * Memory Address Space Devices (platform address ranges with
        interleaving, performance, and persistence attributes)
      
      * Memory Regions (active provisioned memory from an address space device
        that is in use as System RAM or delegated to libnvdimm as Persistent
        Memory regions).
      
      For now, only the per-endpoint control devices are registered on the
      'cxl' bus. However, going forward it will provide a mechanism to
      coordinate cross-device interleave.
      
      Signed-off-by: default avatarBen Widawsky <ben.widawsky@intel.com>
      Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> (v2)
      Link: https://lore.kernel.org/r/20210217040958.1354670-4-ben.widawsky@intel.com
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      b39cb105
    • Ben Widawsky's avatar
      cxl/mem: Find device capabilities · 8adaf747
      Ben Widawsky authored
      
      Provide enough functionality to utilize the mailbox of a memory device.
      The mailbox is used to interact with the firmware running on the memory
      device. The flow is proven with one implemented command, "identify".
      Because the class code has already told the driver this is a memory
      device and the identify command is mandatory.
      
      CXL devices contain an array of capabilities that describe the
      interactions software can have with the device or firmware running on
      the device. A CXL compliant device must implement the device status and
      the mailbox capability. Additionally, a CXL compliant memory device must
      implement the memory device capability. Each of the capabilities can
      [will] provide an offset within the MMIO region for interacting with the
      CXL device.
      
      The capabilities tell the driver how to find and map the register space
      for CXL Memory Devices. The registers are required to utilize the CXL
      spec defined mailbox interface. The spec outlines two mailboxes, primary
      and secondary. The secondary mailbox is earmarked for system firmware,
      and not handled in this driver.
      
      Primary mailboxes are capable of generating an interrupt when submitting
      a background command. That implementation is saved for a later time.
      
      Reported-by: Colin Ian King <colin.king@canonical.com> (coverity)
      Reported-by: Dan Carpenter <dan.carpenter@oracle.com> (smatch)
      Signed-off-by: default avatarBen Widawsky <ben.widawsky@intel.com>
      Reviewed-by: Dan Williams <dan.j.williams@intel.com> (v2)
      Link: https://www.computeexpresslink.org/download-the-specification
      Link: https://lore.kernel.org/r/20210217040958.1354670-3-ben.widawsky@intel.com
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      8adaf747
    • Dan Williams's avatar
      cxl/mem: Introduce a driver for CXL-2.0-Type-3 endpoints · 4cdadfd5
      Dan Williams authored
      
      The CXL.mem protocol allows a device to act as a provider of "System
      RAM" and/or "Persistent Memory" that is fully coherent as if the memory
      was attached to the typical CPU memory controller.
      
      With the CXL-2.0 specification a PCI endpoint can implement a "Type-3"
      device interface and give the operating system control over "Host
      Managed Device Memory". See section 2.3 Type 3 CXL Device.
      
      The memory range exported by the device may optionally be described by
      the platform firmware memory map, or by infrastructure like LIBNVDIMM to
      provision persistent memory capacity from one, or more, CXL.mem devices.
      
      A pre-requisite for Linux-managed memory-capacity provisioning is this
      cxl_mem driver that can speak the mailbox protocol defined in section
      8.2.8.4 Mailbox Registers.
      
      For now just land the initial driver boiler-plate and Documentation/
      infrastructure.
      
      Signed-off-by: default avatarBen Widawsky <ben.widawsky@intel.com>
      Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Acked-by: David Rientjes <rientjes@google.com> (v1)
      Cc: Jonathan Corbet <corbet@lwn.net>
      Link: https://www.computeexpresslink.org/download-the-specification
      Link: https://lore.kernel.org/r/20210217040958.1354670-2-ben.widawsky@intel.com
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      4cdadfd5
Loading