1. 12 May, 2023 5 commits
    • Alan Previn's avatar
      drm/i915/pxp: Add ARB session creation and cleanup · 99afb7cc
      Alan Previn authored
      Add MTL's function for ARB session creation using PXP firmware
      version 4.3 ABI structure format.
      
      While relooking at the ARB session creation flow in intel_pxp_start,
      let's address missing UAPI documentation. Without actually changing
      backward compatible behavior, update i915's drm-uapi comments
      that describe the possible error values when creating a context
      with I915_CONTEXT_PARAM_PROTECTED_CONTENT:
         Since the first merge of PXP support on ADL, i915 returns -ENXIO
         if a dependency such as firmware or component driver was yet to
         be loaded or returns -EIO if the creation attempt failed when
         requested by the PXP firmware (specific firmware error responses
         are reported in dmesg).
      
      Add MTL's function for ARB session invalidation but this
      reuses PXP firmware version 4.2 ABI structure format.
      
      For both cases, in the back-end gsccs functions for sending messages
      to the firmware inspect the GSC-CS-Mem-Header's pending-bit which
      means the GSC firmware is busy and we should retry.
      
      Given the last hw requirement, lets also update functions in
      front-end layer that wait for session creation or teardown
      completion to use new worst case timeout periods.
      Signed-off-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
      Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Signed-off-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-6-alan.previn.teres.alexis@intel.com
      99afb7cc
    • Alan Previn's avatar
      drm/i915/pxp: Add GSC-CS backend to send GSC fw messages · dc9ac125
      Alan Previn authored
      Add GSC engine based method for sending PXP firmware packets
      to the GSC firmware for MTL (and future) products.
      
      Use the newly added helpers to populate the GSC-CS memory
      header and send the message packet to the FW by dispatching
      the GSC_HECI_CMD_PKT instruction on the GSC engine.
      
      We use non-priveleged batches for submission to GSC engine
      which require two buffers for the request:
           - a buffer for the HECI packet that contains PXP FW commands
           - a batch-buffer that contains the engine instruction for
             sending the HECI packet to the GSC firmware.
      
      Thus, add the allocation and freeing of these buffers in gsccs
      init and fini.
      
      The GSC-fw may reply to commands with a SUCCESS but with an
      additional pending-bit set in the reply packet. This bit
      means the GSC-FW is currently busy and the caller needs to
      try again with the gsc_message_handle the fw returned. Thus,
      add a wrapper to continuously retry send_message while
      replaying the gsc_message_handle. Retries need to follow the
      arch-spec count and delay until GSC-FW replies with the real
      SUCCESS or timeout after that spec'd delay.
      
      The GSC-fw requires a non-zero host_session_handle provided
      by the caller to enable gsc_message_handle tracking. Thus,
      allocate the host_session_handle at init and destroy it
      at fini (the latter requiring an FYI to the gsc-firmware).
      Signed-off-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
      Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Signed-off-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-5-alan.previn.teres.alexis@intel.com
      dc9ac125
    • Alan Previn's avatar
      drm/i915/pxp: Add MTL helpers to submit Heci-Cmd-Packet to GSC · e5e1e6d2
      Alan Previn authored
      Add helper functions into a new file for heci-packet-submission.
      The helpers will handle generating the MTL GSC-CS Memory-Header
      and submission of the Heci-Cmd-Packet instructions to the engine.
      
      NOTE1: These common functions for heci-packet-submission will be used
      by different i915 callers:
           1- GSC-SW-Proxy: This is pending upstream publication awaiting
              a few remaining opens
           2- MTL-HDCP: An equivalent patch has also been published at:
              https://patchwork.freedesktop.org/series/111876/. (Patch 1)
           3- PXP: This series.
      
      NOTE2: A difference in this patch vs what is appearing is in bullet 2
      above is that HDCP (and SW-Proxy) will be using priveleged submission
      (GGTT and common gsc-uc-context) while PXP will be using non-priveleged
      PPGTT, context and batch buffer. Therefore this patch will only slightly
      overlap with the MTL-HDCP patches despite have very similar function
      names (emit_foo vs emit_nonpriv_foo). This is because HECI_CMD_PKT
      instructions require different flows and hw-specific code when done
      via PPGTT based submission (not different from other engines). MTL-HDCP
      contains the same intel_gsc_mtl_header_t structures as this but the
      helpers there are different. Both add the same new file names.
      
      NOTE3: Additional clarity about the heci-cmd-pkt layout and where the
             common helpers come in:
           - On MTL, when an i915 subsystem needs to send a command request
             to the security firmware, it will send that via the GSC-
             engine-command-streamer.
           - However those commands, (lets call them "gsc_specific_fw_api"
             calls), are not understood by the GSC command streamer hw.
           - The GSC CS only looks at the GSC_HECI_CMD_PKT instruction and
             passes it along to the GSC firmware.
           - The GSC FW on the other hand needs additional metadata to know
             which usage service is being called (PXP, HDCP, proxy, etc) along
             with session specific info. Thus an extra header called GSC-CS
             HECI Memory Header, (C) in below diagram is prepended before
             the FW specific API, (D).
           - Thus, the structural layout of the request submitted would
             need to look like the diagram below (for non-priv PXP).
           - In the diagram, the common helper for HDCP, (GSC-Sw-Proxy) and
             PXP (i.e. new function intel_gsc_uc_heci_cmd_emit_mtl_header)
             will populate blob (C) while additional helpers, different for
             PPGGTT (this patch) vs GGTT (HDCP series) will populate
             blobs (A) and (B) below.
            ___________________________________________________________
       (A)  |  MI_BATCH_BUFFER_START (ppgtt, batchbuff-addr, ...)     |
            |     |                                                   |
            |    _|________________________________________________   |
            | (B)| GSC_HECI_CMD_PKT (pkt-addr-in, pkt-size-in,    |   |
            |    |                   pkt-addr-out, pkt-size-out)  |--------
            |    | MI_BATCH_BUFFER_END                            |   |   |
            |    |________________________________________________|   |   |
            |                                                         |   |
            |_________________________________________________________|   |
                                                                          |
                  ---------------------------------------------------------
                  |
                 \|/
            ______V___________________________________________
            |   _________________________________________    |
            |(C)|                                       |    |
            |   | struct intel_gsc_mtl_header {         |    |
            |   |   validity marker                     |    |
            |   |   heci_clent_id                       |    |
            |   |   ...                                 |    |
            |   |  }                                    |    |
            |   |_______________________________________|    |
            |(D)|                                       |    |
            |   | struct gsc_fw_specific_api_foobar {   |    |
            |   |     ...                               |    |
            |   |     For an example, see               |    |
            |   |     'struct pxp43_create_arb_in' at   |    |
            |   |     intel_pxp_cmd_interface_43.h      |    |
            |   |                                       |    |
            |   | }                                     |    |
            |   |  Struture depends on command type     |    |
            |   | struct gsc_fw_specific_api_foobar {   |    |
            |   |_______________________________________|    |
            |________________________________________________|
      
      That said, this patch provides basic helpers but leaves the
      PXP subsystem (i.e. the caller) to handle (D) and everything
      else such as input/output size verification or handling the
      responses from security firmware (for example, requiring a retry).
      Signed-off-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
      Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Signed-off-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-4-alan.previn.teres.alexis@intel.com
      e5e1e6d2
    • Alan Previn's avatar
      drm/i915/pxp: Add MTL hw-plumbing enabling for KCR operation · 5adacf19
      Alan Previn authored
      Add MTL hw-plumbing enabling for KCR operation under PXP
      which includes:
      
      1. Updating 'pick-gt' to get the media tile for
         KCR interrupt handling
      2. Adding MTL's KCR registers for PXP operation
         (init, status-checking, etc.).
      
      While doing #2, lets create a separate registers header file for PXP
      to be consistent with other i915 global subsystems.
      Signed-off-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
      Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Signed-off-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-3-alan.previn.teres.alexis@intel.com
      5adacf19
    • Alan Previn's avatar
      drm/i915/pxp: Add GSC-CS back-end resource init and cleanup · d6bf74de
      Alan Previn authored
      For MTL, the PXP back-end transport uses the GSC engine to submit
      HECI packets through the HW to the GSC firmware for PXP arb
      session management. This submission uses a non-priveleged
      batch buffer, a buffer for the command packet and of course
      a context targeting the GSC-CS.
      
      Thus for MTL, we need to allocate and free a set of execution
      submission resources for the management of the arbitration session.
      Lets start with the context creation first since that object and
      its usage is very straight-forward. We'll add the buffer allocation
      and freeing later when we introduce the gsccs' send-message function.
      
      Do this one time allocation of gsccs specific resources in
      a new gsccs source file with intel_pxp_gsccs_init / fini functions
      and hook them up from the PXP front-end.
      Signed-off-by: default avatarAlan Previn <alan.previn.teres.alexis@intel.com>
      Reviewed-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Signed-off-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230511231738.1077674-2-alan.previn.teres.alexis@intel.com
      d6bf74de
  2. 11 May, 2023 2 commits
    • Fei Yang's avatar
      drm/i915: use pat_index instead of cache_level · 9275277d
      Fei Yang authored
      Currently the KMD is using enum i915_cache_level to set caching policy for
      buffer objects. This is flaky because the PAT index which really controls
      the caching behavior in PTE has far more levels than what's defined in the
      enum. In addition, the PAT index is platform dependent, having to translate
      between i915_cache_level and PAT index is not reliable, and makes the code
      more complicated.
      
      From UMD's perspective there is also a necessity to set caching policy for
      performance fine tuning. It's much easier for the UMD to directly use PAT
      index because the behavior of each PAT index is clearly defined in Bspec.
      Having the abstracted i915_cache_level sitting in between would only cause
      more ambiguity. PAT is expected to work much like MOCS already works today,
      and by design userspace is expected to select the index that exactly
      matches the desired behavior described in the hardware specification.
      
      For these reasons this patch replaces i915_cache_level with PAT index. Also
      note, the cache_level is not completely removed yet, because the KMD still
      has the need of creating buffer objects with simple cache settings such as
      cached, uncached, or writethrough. For kernel objects, cache_level is used
      for simplicity and backward compatibility. For Pre-gen12 platforms PAT can
      have 1:1 mapping to i915_cache_level, so these two are interchangeable. see
      the use of LEGACY_CACHELEVEL.
      
      One consequence of this change is that gen8_pte_encode is no longer working
      for gen12 platforms due to the fact that gen12 platforms has different PAT
      definitions. In the meantime the mtl_pte_encode introduced specfically for
      MTL becomes generic for all gen12 platforms. This patch renames the MTL
      PTE encode function into gen12_pte_encode and apply it to all gen12. Even
      though this change looks unrelated, but separating them would temporarily
      break gen12 PTE encoding, thus squash them in one patch.
      
      Special note: this patch changes the way caching behavior is controlled in
      the sense that some objects are left to be managed by userspace. For such
      objects we need to be careful not to change the userspace settings.There
      are kerneldoc and comments added around obj->cache_coherent, cache_dirty,
      and how to bypass the checkings by i915_gem_object_has_cache_level. For
      full understanding, these changes need to be looked at together with the
      two follow-up patches, one disables the {set|get}_caching ioctl's and the
      other adds set_pat extension to the GEM_CREATE uAPI.
      
      Bspec: 63019
      
      Cc: Chris Wilson <chris.p.wilson@linux.intel.com>
      Signed-off-by: default avatarFei Yang <fei.yang@intel.com>
      Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
      Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230509165200.1740-3-fei.yang@intel.com
      9275277d
    • Fei Yang's avatar
      drm/i915: preparation for using PAT index · 5e352e32
      Fei Yang authored
      This patch is a preparation for replacing enum i915_cache_level with PAT
      index. Caching policy for buffer objects is set through the PAT index in
      PTE, the old i915_cache_level is not sufficient to represent all caching
      modes supported by the hardware.
      
      Preparing the transition by adding some platform dependent data structures
      and helper functions to translate the cache_level to pat_index.
      
      cachelevel_to_pat: a platform dependent array mapping cache_level to
                         pat_index.
      
      max_pat_index: the maximum PAT index recommended in hardware specification
                     Needed for validating the PAT index passed in from user
                     space.
      
      i915_gem_get_pat_index: function to convert cache_level to PAT index.
      
      obj_to_i915(obj): macro moved to header file for wider usage.
      
      I915_MAX_CACHE_LEVEL: upper bound of i915_cache_level for the
                            convenience of coding.
      
      Cc: Chris Wilson <chris.p.wilson@linux.intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Signed-off-by: default avatarFei Yang <fei.yang@intel.com>
      Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
      Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
      Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230509165200.1740-2-fei.yang@intel.com
      5e352e32
  3. 08 May, 2023 3 commits
  4. 05 May, 2023 12 commits
  5. 04 May, 2023 18 commits