• Umesh Nerlige Ramappa's avatar
    i915/pmu: Add support for total context runtime for GuC back-end · 5aa857db
    Umesh Nerlige Ramappa authored
    GPU accumulates the context runtime in a 32 bit counter - CTX_TIMESTAMP
    in the context image. This value is saved/restored on context switches.
    KMD accumulates these values into a 64 bit counter taking care of any
    overflows as needed. This count provides the basis for client specific
    busyness in the fdinfo interface.
    
    KMD accumulation happens just before the context is unpinned and when
    context switches out. This works for execlist back-end since execlist
    scheduling has visibility into context switches. With GuC mode, KMD does
    not have visibility into context switches and this counter is
    accumulated only when context is unpinned. Context is unpinned once the
    context scheduling is successfully disabled. Disabling context
    scheduling is an asynchronous operation. Also if a context is servicing
    frequent requests, scheduling may never be disabled on it.
    
    For GuC mode, since updates to the context runtime may be delayed, add
    hooks to update the context runtime in a worker thread as well as when
    a user queries for it.
    
    Limitation:
    - If a context is never switched out or runs for a long period of time,
      the runtime value of CTX_TIMESTAMP may never be updated, so the
      counter value may be unreliable. This patch does not support such
      cases. Such support must be available from the GuC FW and it is WIP.
    
    This patch is an extract from previous work authored by John/Umesh here -
    https://patchwork.freedesktop.org/patch/496441/?series=105085&rev=4
    
    v2: (Ashutosh)
    - Drop COPS_RUNTIME_ACTIVE_TOTAL
    - s/guc_context_update_clks/__guc_context_update_stats
    - Pin context before accessing in guc_timestamp_ping
    - In guc_context_unpin, use spinlock to serialize access to runtime stats
    Signed-off-by: default avatarUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
    Co-developed-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
    Signed-off-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
    Reviewed-by: default avatarAshutosh Dixit <ashutosh.dixit@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230427224705.2785566-2-umesh.nerlige.ramappa@intel.com
    5aa857db
intel_context.c 14.1 KB