2019-08-12 09:29:35 +00:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
2017-10-04 18:13:41 +00:00
|
|
|
/*
|
2019-08-12 09:29:35 +00:00
|
|
|
* Copyright © 2014-2019 Intel Corporation
|
2017-10-04 18:13:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INTEL_GUC_H_
|
|
|
|
#define _INTEL_GUC_H_
|
|
|
|
|
2021-07-21 21:50:46 +00:00
|
|
|
#include <linux/xarray.h>
|
2021-07-21 21:50:49 +00:00
|
|
|
#include <linux/delay.h>
|
2021-07-21 21:50:46 +00:00
|
|
|
|
2017-10-04 18:13:41 +00:00
|
|
|
#include "intel_uncore.h"
|
2017-10-16 14:47:14 +00:00
|
|
|
#include "intel_guc_fw.h"
|
2017-10-04 18:13:41 +00:00
|
|
|
#include "intel_guc_fwif.h"
|
|
|
|
#include "intel_guc_ct.h"
|
|
|
|
#include "intel_guc_log.h"
|
2017-11-24 09:53:40 +00:00
|
|
|
#include "intel_guc_reg.h"
|
2021-07-30 20:21:06 +00:00
|
|
|
#include "intel_guc_slpc_types.h"
|
2017-10-04 18:13:41 +00:00
|
|
|
#include "intel_uc_fw.h"
|
2019-03-08 13:25:17 +00:00
|
|
|
#include "i915_utils.h"
|
2017-10-04 18:13:41 +00:00
|
|
|
#include "i915_vma.h"
|
|
|
|
|
2019-07-01 10:04:51 +00:00
|
|
|
struct __guc_ads_blob;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* struct intel_guc - Top level structure of GuC.
|
|
|
|
*
|
|
|
|
* It handles firmware loading and manages client pool. intel_guc owns an
|
|
|
|
* i915_sched_engine for submission.
|
2017-10-16 14:47:13 +00:00
|
|
|
*/
|
2017-10-04 18:13:41 +00:00
|
|
|
struct intel_guc {
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @fw: the GuC firmware */
|
2017-10-04 18:13:41 +00:00
|
|
|
struct intel_uc_fw fw;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @log: sub-structure containing GuC log related data and objects */
|
2017-10-04 18:13:41 +00:00
|
|
|
struct intel_guc_log log;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @ct: the command transport communication channel */
|
2017-10-04 18:13:41 +00:00
|
|
|
struct intel_guc_ct ct;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @slpc: sub-structure containing SLPC related data and objects */
|
2021-07-30 20:21:06 +00:00
|
|
|
struct intel_guc_slpc slpc;
|
2017-10-04 18:13:41 +00:00
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @sched_engine: Global engine used to submit requests to GuC */
|
2021-07-21 21:50:47 +00:00
|
|
|
struct i915_sched_engine *sched_engine;
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @stalled_request: if GuC can't process a request for any reason, we
|
|
|
|
* save it until GuC restarts processing. No other request can be
|
|
|
|
* submitted until the stalled request is processed.
|
|
|
|
*/
|
2021-07-21 21:50:47 +00:00
|
|
|
struct i915_request *stalled_request;
|
2021-10-14 17:19:52 +00:00
|
|
|
/**
|
|
|
|
* @submission_stall_reason: reason why submission is stalled
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
STALL_NONE,
|
|
|
|
STALL_REGISTER_CONTEXT,
|
|
|
|
STALL_MOVE_LRC_TAIL,
|
|
|
|
STALL_ADD_REQUEST,
|
|
|
|
} submission_stall_reason;
|
2021-07-21 21:50:47 +00:00
|
|
|
|
2017-10-04 18:13:41 +00:00
|
|
|
/* intel_guc_recv interrupt related state */
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @irq_lock: protects GuC irq state */
|
2018-03-19 09:53:36 +00:00
|
|
|
spinlock_t irq_lock;
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @msg_enabled_mask: mask of events that are processed when receiving
|
|
|
|
* an INTEL_GUC_ACTION_DEFAULT G2H message.
|
|
|
|
*/
|
2018-03-19 09:53:36 +00:00
|
|
|
unsigned int msg_enabled_mask;
|
2017-10-04 18:13:41 +00:00
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @outstanding_submission_g2h: number of outstanding GuC to Host
|
|
|
|
* responses related to GuC submission, used to determine if the GT is
|
|
|
|
* idle
|
|
|
|
*/
|
2021-07-21 21:50:58 +00:00
|
|
|
atomic_t outstanding_submission_g2h;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @interrupts: pointers to GuC interrupt-managing functions. */
|
2019-05-27 18:36:07 +00:00
|
|
|
struct {
|
2019-07-13 10:00:09 +00:00
|
|
|
void (*reset)(struct intel_guc *guc);
|
|
|
|
void (*enable)(struct intel_guc *guc);
|
|
|
|
void (*disable)(struct intel_guc *guc);
|
2019-05-27 18:36:07 +00:00
|
|
|
} interrupts;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
2021-10-14 17:19:41 +00:00
|
|
|
* @submission_state: sub-structure for submission state protected by
|
|
|
|
* single lock
|
2021-07-21 21:50:49 +00:00
|
|
|
*/
|
2021-10-14 17:19:41 +00:00
|
|
|
struct {
|
|
|
|
/**
|
|
|
|
* @lock: protects everything in submission_state,
|
|
|
|
* ce->guc_id.id, and ce->guc_id.ref when transitioning in and
|
|
|
|
* out of zero
|
|
|
|
*/
|
|
|
|
spinlock_t lock;
|
|
|
|
/**
|
2021-10-14 17:19:50 +00:00
|
|
|
* @guc_ids: used to allocate new guc_ids, single-lrc
|
2021-10-14 17:19:41 +00:00
|
|
|
*/
|
|
|
|
struct ida guc_ids;
|
2021-12-14 17:05:00 +00:00
|
|
|
/**
|
|
|
|
* @num_guc_ids: Number of guc_ids, selftest feature to be able
|
|
|
|
* to reduce this number while testing.
|
|
|
|
*/
|
|
|
|
int num_guc_ids;
|
2021-10-14 17:19:50 +00:00
|
|
|
/**
|
|
|
|
* @guc_ids_bitmap: used to allocate new guc_ids, multi-lrc
|
|
|
|
*/
|
|
|
|
unsigned long *guc_ids_bitmap;
|
2021-10-14 17:19:41 +00:00
|
|
|
/**
|
|
|
|
* @guc_id_list: list of intel_context with valid guc_ids but no
|
|
|
|
* refs
|
|
|
|
*/
|
|
|
|
struct list_head guc_id_list;
|
2021-10-14 17:19:42 +00:00
|
|
|
/**
|
|
|
|
* @destroyed_contexts: list of contexts waiting to be destroyed
|
|
|
|
* (deregistered with the GuC)
|
|
|
|
*/
|
|
|
|
struct list_head destroyed_contexts;
|
|
|
|
/**
|
|
|
|
* @destroyed_worker: worker to deregister contexts, need as we
|
|
|
|
* need to take a GT PM reference and can't from destroy
|
|
|
|
* function as it might be in an atomic context (no sleeping)
|
|
|
|
*/
|
|
|
|
struct work_struct destroyed_worker;
|
2021-10-14 17:19:41 +00:00
|
|
|
} submission_state;
|
2021-07-21 21:50:49 +00:00
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @submission_supported: tracks whether we support GuC submission on
|
|
|
|
* the current platform
|
|
|
|
*/
|
2021-07-27 00:23:48 +00:00
|
|
|
bool submission_supported;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @submission_selected: tracks whether the user enabled GuC submission */
|
2020-02-18 22:33:24 +00:00
|
|
|
bool submission_selected;
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @rc_supported: tracks whether we support GuC rc on the current platform
|
|
|
|
*/
|
2021-07-30 20:21:19 +00:00
|
|
|
bool rc_supported;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @rc_selected: tracks whether the user enabled GuC rc */
|
2021-07-30 20:21:19 +00:00
|
|
|
bool rc_selected;
|
2019-07-31 22:33:20 +00:00
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @ads_vma: object allocated to hold the GuC ADS */
|
2017-10-04 18:13:41 +00:00
|
|
|
struct i915_vma *ads_vma;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @ads_blob: contents of the GuC ADS */
|
2019-07-01 10:04:51 +00:00
|
|
|
struct __guc_ads_blob *ads_blob;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @ads_regset_size: size of the save/restore regsets in the ADS */
|
2021-07-27 00:23:30 +00:00
|
|
|
u32 ads_regset_size;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @ads_golden_ctxt_size: size of the golden contexts in the ADS */
|
2021-07-27 00:23:38 +00:00
|
|
|
u32 ads_golden_ctxt_size;
|
drm/i915/pmu: Connect engine busyness stats from GuC to pmu
With GuC handling scheduling, i915 is not aware of the time that a
context is scheduled in and out of the engine. Since i915 pmu relies on
this info to provide engine busyness to the user, GuC shares this info
with i915 for all engines using shared memory. For each engine, this
info contains:
- total busyness: total time that the context was running (total)
- id: id of the running context (id)
- start timestamp: timestamp when the context started running (start)
At the time (now) of sampling the engine busyness, if the id is valid
(!= ~0), and start is non-zero, then the context is considered to be
active and the engine busyness is calculated using the below equation
engine busyness = total + (now - start)
All times are obtained from the gt clock base. For inactive contexts,
engine busyness is just equal to the total.
The start and total values provided by GuC are 32 bits and wrap around
in a few minutes. Since perf pmu provides busyness as 64 bit
monotonically increasing values, there is a need for this implementation
to account for overflows and extend the time to 64 bits before returning
busyness to the user. In order to do that, a worker runs periodically at
frequency = 1/8th the time it takes for the timestamp to wrap. As an
example, that would be once in 27 seconds for a gt clock frequency of
19.2 MHz.
Note:
There might be an over-accounting of busyness due to the fact that GuC
may be updating the total and start values while kmd is reading them.
(i.e kmd may read the updated total and the stale start). In such a
case, user may see higher busyness value followed by smaller ones which
would eventually catch up to the higher value.
v2: (Tvrtko)
- Include details in commit message
- Move intel engine busyness function into execlist code
- Use union inside engine->stats
- Use natural type for ping delay jiffies
- Drop active_work condition checks
- Use for_each_engine if iterating all engines
- Drop seq locking, use spinlock at GuC level to update engine stats
- Document worker specific details
v3: (Tvrtko/Umesh)
- Demarcate GuC and execlist stat objects with comments
- Document known over-accounting issue in commit
- Provide a consistent view of GuC state
- Add hooks to gt park/unpark for GuC busyness
- Stop/start worker in gt park/unpark path
- Drop inline
- Move spinlock and worker inits to GuC initialization
- Drop helpers that are called only once
v4: (Tvrtko/Matt/Umesh)
- Drop addressed opens from commit message
- Get runtime pm in ping, remove from the park path
- Use cancel_delayed_work_sync in disable_submission path
- Update stats during reset prepare
- Skip ping if reset in progress
- Explicitly name execlists and GuC stats objects
- Since disable_submission is called from many places, move resetting
stats to intel_guc_submission_reset_prepare
v5: (Tvrtko)
- Add a trylock helper that does not sleep and synchronize PMU event
callbacks and worker with gt reset
v6: (CI BAT failures)
- DUTs using execlist submission failed to boot since __gt_unpark is
called during i915 load. This ends up calling the GuC busyness unpark
hook and results in kick-starting an uninitialized worker. Let
park/unpark hooks check if GuC submission has been initialized.
- drop cant_sleep() from trylock helper since rcu_read_lock takes care
of that.
v7: (CI) Fix igt@i915_selftest@live@gt_engines
- For GuC mode of submission the engine busyness is derived from gt time
domain. Use gt time elapsed as reference in the selftest.
- Increase busyness calculation to 10ms duration to ensure batch runs
longer and falls within the busyness tolerances in selftest.
v8:
- Use ktime_get in selftest as before
- intel_reset_trylock_no_wait results in a lockdep splat that is not
trivial to fix since the PMU callback runs in irq context and the
reset paths are tightly knit into the driver. The test that uncovers
this is igt@perf_pmu@faulting-read. Drop intel_reset_trylock_no_wait,
instead use the reset_count to synchronize with gt reset during pmu
callback. For the ping, continue to use intel_reset_trylock since ping
is not run in irq context.
- GuC PM timestamp does not tick when GuC is idle. This can potentially
result in wrong busyness values when a context is active on the
engine, but GuC is idle. Use the RING TIMESTAMP as GPU timestamp to
process the GuC busyness stats. This works since both GuC timestamp and
RING timestamp are synced with the same clock.
- The busyness stats may get updated after the batch starts running.
This delay causes the busyness reported for 100us duration to fall
below 95% in the selftest. The only option at this time is to wait for
GuC busyness to change from idle to active before we sample busyness
over a 100us period.
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Acked-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211027004821.66097-2-umesh.nerlige.ramappa@intel.com
2021-10-27 00:48:21 +00:00
|
|
|
/** @ads_engine_usage_size: size of engine usage in the ADS */
|
|
|
|
u32 ads_engine_usage_size;
|
2019-07-01 10:04:51 +00:00
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @lrc_desc_pool: object allocated to hold the GuC LRC descriptor pool */
|
2021-07-21 21:50:45 +00:00
|
|
|
struct i915_vma *lrc_desc_pool;
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @lrc_desc_pool_vaddr: contents of the GuC LRC descriptor pool */
|
2021-07-21 21:50:45 +00:00
|
|
|
void *lrc_desc_pool_vaddr;
|
2017-10-04 18:13:41 +00:00
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @context_lookup: used to resolve intel_context from guc_id, if a
|
|
|
|
* context is present in this structure it is registered with the GuC
|
|
|
|
*/
|
2021-07-21 21:50:46 +00:00
|
|
|
struct xarray context_lookup;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @params: Control params for fw initialization */
|
2019-07-24 08:58:49 +00:00
|
|
|
u32 params[GUC_CTL_MAX_DWORDS];
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @send_regs: GuC's FW specific registers used for sending MMIO H2G */
|
2017-10-04 18:13:41 +00:00
|
|
|
struct {
|
|
|
|
u32 base;
|
|
|
|
unsigned int count;
|
|
|
|
enum forcewake_domains fw_domains;
|
|
|
|
} send_regs;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @notify_reg: register used to send interrupts to the GuC FW */
|
2019-12-17 01:23:15 +00:00
|
|
|
i915_reg_t notify_reg;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/**
|
|
|
|
* @mmio_msg: notification bitmask that the GuC writes in one of its
|
|
|
|
* registers when the CT channel is disabled, to be processed when the
|
|
|
|
* channel is back up.
|
|
|
|
*/
|
2019-06-21 18:21:23 +00:00
|
|
|
u32 mmio_msg;
|
|
|
|
|
2021-09-09 16:47:44 +00:00
|
|
|
/** @send_mutex: used to serialize the intel_guc_send actions */
|
2017-10-04 18:13:41 +00:00
|
|
|
struct mutex send_mutex;
|
drm/i915/pmu: Connect engine busyness stats from GuC to pmu
With GuC handling scheduling, i915 is not aware of the time that a
context is scheduled in and out of the engine. Since i915 pmu relies on
this info to provide engine busyness to the user, GuC shares this info
with i915 for all engines using shared memory. For each engine, this
info contains:
- total busyness: total time that the context was running (total)
- id: id of the running context (id)
- start timestamp: timestamp when the context started running (start)
At the time (now) of sampling the engine busyness, if the id is valid
(!= ~0), and start is non-zero, then the context is considered to be
active and the engine busyness is calculated using the below equation
engine busyness = total + (now - start)
All times are obtained from the gt clock base. For inactive contexts,
engine busyness is just equal to the total.
The start and total values provided by GuC are 32 bits and wrap around
in a few minutes. Since perf pmu provides busyness as 64 bit
monotonically increasing values, there is a need for this implementation
to account for overflows and extend the time to 64 bits before returning
busyness to the user. In order to do that, a worker runs periodically at
frequency = 1/8th the time it takes for the timestamp to wrap. As an
example, that would be once in 27 seconds for a gt clock frequency of
19.2 MHz.
Note:
There might be an over-accounting of busyness due to the fact that GuC
may be updating the total and start values while kmd is reading them.
(i.e kmd may read the updated total and the stale start). In such a
case, user may see higher busyness value followed by smaller ones which
would eventually catch up to the higher value.
v2: (Tvrtko)
- Include details in commit message
- Move intel engine busyness function into execlist code
- Use union inside engine->stats
- Use natural type for ping delay jiffies
- Drop active_work condition checks
- Use for_each_engine if iterating all engines
- Drop seq locking, use spinlock at GuC level to update engine stats
- Document worker specific details
v3: (Tvrtko/Umesh)
- Demarcate GuC and execlist stat objects with comments
- Document known over-accounting issue in commit
- Provide a consistent view of GuC state
- Add hooks to gt park/unpark for GuC busyness
- Stop/start worker in gt park/unpark path
- Drop inline
- Move spinlock and worker inits to GuC initialization
- Drop helpers that are called only once
v4: (Tvrtko/Matt/Umesh)
- Drop addressed opens from commit message
- Get runtime pm in ping, remove from the park path
- Use cancel_delayed_work_sync in disable_submission path
- Update stats during reset prepare
- Skip ping if reset in progress
- Explicitly name execlists and GuC stats objects
- Since disable_submission is called from many places, move resetting
stats to intel_guc_submission_reset_prepare
v5: (Tvrtko)
- Add a trylock helper that does not sleep and synchronize PMU event
callbacks and worker with gt reset
v6: (CI BAT failures)
- DUTs using execlist submission failed to boot since __gt_unpark is
called during i915 load. This ends up calling the GuC busyness unpark
hook and results in kick-starting an uninitialized worker. Let
park/unpark hooks check if GuC submission has been initialized.
- drop cant_sleep() from trylock helper since rcu_read_lock takes care
of that.
v7: (CI) Fix igt@i915_selftest@live@gt_engines
- For GuC mode of submission the engine busyness is derived from gt time
domain. Use gt time elapsed as reference in the selftest.
- Increase busyness calculation to 10ms duration to ensure batch runs
longer and falls within the busyness tolerances in selftest.
v8:
- Use ktime_get in selftest as before
- intel_reset_trylock_no_wait results in a lockdep splat that is not
trivial to fix since the PMU callback runs in irq context and the
reset paths are tightly knit into the driver. The test that uncovers
this is igt@perf_pmu@faulting-read. Drop intel_reset_trylock_no_wait,
instead use the reset_count to synchronize with gt reset during pmu
callback. For the ping, continue to use intel_reset_trylock since ping
is not run in irq context.
- GuC PM timestamp does not tick when GuC is idle. This can potentially
result in wrong busyness values when a context is active on the
engine, but GuC is idle. Use the RING TIMESTAMP as GPU timestamp to
process the GuC busyness stats. This works since both GuC timestamp and
RING timestamp are synced with the same clock.
- The busyness stats may get updated after the batch starts running.
This delay causes the busyness reported for 100us duration to fall
below 95% in the selftest. The only option at this time is to wait for
GuC busyness to change from idle to active before we sample busyness
over a 100us period.
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Acked-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211027004821.66097-2-umesh.nerlige.ramappa@intel.com
2021-10-27 00:48:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @timestamp: GT timestamp object that stores a copy of the timestamp
|
|
|
|
* and adjusts it for overflow using a worker.
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
/**
|
|
|
|
* @lock: Lock protecting the below fields and the engine stats.
|
|
|
|
*/
|
|
|
|
spinlock_t lock;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @gt_stamp: 64 bit extended value of the GT timestamp.
|
|
|
|
*/
|
|
|
|
u64 gt_stamp;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ping_delay: Period for polling the GT timestamp for
|
|
|
|
* overflow.
|
|
|
|
*/
|
|
|
|
unsigned long ping_delay;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @work: Periodic work to adjust GT timestamp, engine and
|
|
|
|
* context usage for overflows.
|
|
|
|
*/
|
|
|
|
struct delayed_work work;
|
|
|
|
} timestamp;
|
2021-12-14 17:05:00 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DRM_I915_SELFTEST
|
|
|
|
/**
|
|
|
|
* @number_guc_id_stolen: The number of guc_ids that have been stolen
|
|
|
|
*/
|
|
|
|
int number_guc_id_stolen;
|
|
|
|
#endif
|
2017-10-04 18:13:41 +00:00
|
|
|
};
|
|
|
|
|
2020-03-26 18:11:20 +00:00
|
|
|
static inline struct intel_guc *log_to_guc(struct intel_guc_log *log)
|
|
|
|
{
|
|
|
|
return container_of(log, struct intel_guc, log);
|
|
|
|
}
|
|
|
|
|
2017-10-04 18:13:41 +00:00
|
|
|
static
|
|
|
|
inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
|
|
|
|
{
|
2021-07-08 16:20:52 +00:00
|
|
|
return intel_guc_ct_send(&guc->ct, action, len, NULL, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
2021-07-21 21:50:57 +00:00
|
|
|
inline int intel_guc_send_nb(struct intel_guc *guc, const u32 *action, u32 len,
|
|
|
|
u32 g2h_len_dw)
|
2021-07-08 16:20:52 +00:00
|
|
|
{
|
|
|
|
return intel_guc_ct_send(&guc->ct, action, len, NULL, 0,
|
2021-07-21 21:50:57 +00:00
|
|
|
MAKE_SEND_FLAGS(g2h_len_dw));
|
2018-03-26 19:48:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
intel_guc_send_and_receive(struct intel_guc *guc, const u32 *action, u32 len,
|
|
|
|
u32 *response_buf, u32 response_buf_size)
|
|
|
|
{
|
2019-12-17 01:23:14 +00:00
|
|
|
return intel_guc_ct_send(&guc->ct, action, len,
|
2021-07-08 16:20:52 +00:00
|
|
|
response_buf, response_buf_size, 0);
|
2017-10-04 18:13:41 +00:00
|
|
|
}
|
|
|
|
|
2021-07-21 21:50:49 +00:00
|
|
|
static inline int intel_guc_send_busy_loop(struct intel_guc *guc,
|
|
|
|
const u32 *action,
|
|
|
|
u32 len,
|
2021-07-21 21:50:57 +00:00
|
|
|
u32 g2h_len_dw,
|
2021-07-21 21:50:49 +00:00
|
|
|
bool loop)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
unsigned int sleep_period_ms = 1;
|
|
|
|
bool not_atomic = !in_atomic() && !irqs_disabled();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: Have caller pass in if we are in an atomic context to avoid
|
|
|
|
* using in_atomic(). It is likely safe here as we check for irqs
|
|
|
|
* disabled which basically all the spin locks in the i915 do but
|
|
|
|
* regardless this should be cleaned up.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* No sleeping with spin locks, just busy loop */
|
|
|
|
might_sleep_if(loop && not_atomic);
|
|
|
|
|
|
|
|
retry:
|
2021-07-21 21:50:57 +00:00
|
|
|
err = intel_guc_send_nb(guc, action, len, g2h_len_dw);
|
2021-07-21 21:50:49 +00:00
|
|
|
if (unlikely(err == -EBUSY && loop)) {
|
|
|
|
if (likely(not_atomic)) {
|
|
|
|
if (msleep_interruptible(sleep_period_ms))
|
|
|
|
return -EINTR;
|
|
|
|
sleep_period_ms = sleep_period_ms << 1;
|
|
|
|
} else {
|
|
|
|
cpu_relax();
|
|
|
|
}
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2018-03-26 19:48:22 +00:00
|
|
|
static inline void intel_guc_to_host_event_handler(struct intel_guc *guc)
|
|
|
|
{
|
2019-12-17 01:23:14 +00:00
|
|
|
intel_guc_ct_event_handler(&guc->ct);
|
2018-03-26 19:48:22 +00:00
|
|
|
}
|
|
|
|
|
2018-03-14 00:32:49 +00:00
|
|
|
/* GuC addresses above GUC_GGTT_TOP also don't map through the GTT */
|
|
|
|
#define GUC_GGTT_TOP 0xFEE00000
|
|
|
|
|
|
|
|
/**
|
|
|
|
* intel_guc_ggtt_offset() - Get and validate the GGTT offset of @vma
|
|
|
|
* @guc: intel_guc structure.
|
|
|
|
* @vma: i915 graphics virtual memory area.
|
|
|
|
*
|
2018-03-14 00:32:50 +00:00
|
|
|
* GuC does not allow any gfx GGTT address that falls into range
|
2018-07-27 14:11:45 +00:00
|
|
|
* [0, ggtt.pin_bias), which is reserved for Boot ROM, SRAM and WOPCM.
|
|
|
|
* Currently, in order to exclude [0, ggtt.pin_bias) address space from
|
2018-03-14 00:32:50 +00:00
|
|
|
* GGTT, all gfx objects used by GuC are allocated with intel_guc_allocate_vma()
|
2018-07-27 14:11:45 +00:00
|
|
|
* and pinned with PIN_OFFSET_BIAS along with the value of ggtt.pin_bias.
|
2018-03-14 00:32:49 +00:00
|
|
|
*
|
2018-03-14 00:32:50 +00:00
|
|
|
* Return: GGTT offset of the @vma.
|
2017-10-16 14:47:13 +00:00
|
|
|
*/
|
2018-03-14 00:32:49 +00:00
|
|
|
static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc,
|
|
|
|
struct i915_vma *vma)
|
2017-10-04 18:13:41 +00:00
|
|
|
{
|
|
|
|
u32 offset = i915_ggtt_offset(vma);
|
|
|
|
|
2018-07-27 14:11:45 +00:00
|
|
|
GEM_BUG_ON(offset < i915_ggtt_pin_bias(vma));
|
2017-10-04 18:13:41 +00:00
|
|
|
GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void intel_guc_init_early(struct intel_guc *guc);
|
2021-07-27 00:23:38 +00:00
|
|
|
void intel_guc_init_late(struct intel_guc *guc);
|
2017-10-04 18:13:41 +00:00
|
|
|
void intel_guc_init_send_regs(struct intel_guc *guc);
|
2019-07-24 08:58:49 +00:00
|
|
|
void intel_guc_write_params(struct intel_guc *guc);
|
2017-12-13 22:13:46 +00:00
|
|
|
int intel_guc_init(struct intel_guc *guc);
|
|
|
|
void intel_guc_fini(struct intel_guc *guc);
|
2019-12-17 01:23:15 +00:00
|
|
|
void intel_guc_notify(struct intel_guc *guc);
|
2018-03-26 19:48:20 +00:00
|
|
|
int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
|
|
|
|
u32 *response_buf, u32 response_buf_size);
|
2019-03-21 12:00:04 +00:00
|
|
|
int intel_guc_to_host_process_recv_msg(struct intel_guc *guc,
|
|
|
|
const u32 *payload, u32 len);
|
2017-10-04 18:13:41 +00:00
|
|
|
int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
|
2018-03-02 11:15:49 +00:00
|
|
|
int intel_guc_suspend(struct intel_guc *guc);
|
|
|
|
int intel_guc_resume(struct intel_guc *guc);
|
2017-10-04 18:13:41 +00:00
|
|
|
struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
|
2019-12-05 22:02:40 +00:00
|
|
|
int intel_guc_allocate_and_map_vma(struct intel_guc *guc, u32 size,
|
|
|
|
struct i915_vma **out_vma, void **out_vaddr);
|
2017-10-04 18:13:41 +00:00
|
|
|
|
2019-07-31 22:33:19 +00:00
|
|
|
static inline bool intel_guc_is_supported(struct intel_guc *guc)
|
|
|
|
{
|
2019-08-16 20:56:58 +00:00
|
|
|
return intel_uc_fw_is_supported(&guc->fw);
|
|
|
|
}
|
|
|
|
|
2020-02-18 22:33:23 +00:00
|
|
|
static inline bool intel_guc_is_wanted(struct intel_guc *guc)
|
2019-08-16 20:56:58 +00:00
|
|
|
{
|
|
|
|
return intel_uc_fw_is_enabled(&guc->fw);
|
2019-07-31 22:33:19 +00:00
|
|
|
}
|
|
|
|
|
2020-02-18 22:33:23 +00:00
|
|
|
static inline bool intel_guc_is_used(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
GEM_BUG_ON(__intel_uc_fw_status(&guc->fw) == INTEL_UC_FIRMWARE_SELECTED);
|
|
|
|
return intel_uc_fw_is_available(&guc->fw);
|
|
|
|
}
|
|
|
|
|
2020-01-31 15:37:06 +00:00
|
|
|
static inline bool intel_guc_is_fw_running(struct intel_guc *guc)
|
2019-05-22 19:31:58 +00:00
|
|
|
{
|
2019-07-25 00:18:09 +00:00
|
|
|
return intel_uc_fw_is_running(&guc->fw);
|
2019-05-22 19:31:58 +00:00
|
|
|
}
|
|
|
|
|
2020-01-31 15:37:06 +00:00
|
|
|
static inline bool intel_guc_is_ready(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
return intel_guc_is_fw_running(guc) && intel_guc_ct_enabled(&guc->ct);
|
|
|
|
}
|
|
|
|
|
2021-07-27 00:23:25 +00:00
|
|
|
static inline void intel_guc_reset_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->interrupts.reset(guc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_guc_enable_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->interrupts.enable(guc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_guc_disable_interrupts(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
guc->interrupts.disable(guc);
|
|
|
|
}
|
|
|
|
|
2018-03-12 13:03:07 +00:00
|
|
|
static inline int intel_guc_sanitize(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
intel_uc_fw_sanitize(&guc->fw);
|
2021-07-27 00:23:25 +00:00
|
|
|
intel_guc_disable_interrupts(guc);
|
2020-02-07 13:19:38 +00:00
|
|
|
intel_guc_ct_sanitize(&guc->ct);
|
2019-06-21 18:21:23 +00:00
|
|
|
guc->mmio_msg = 0;
|
|
|
|
|
2018-03-12 13:03:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-20 18:14:19 +00:00
|
|
|
static inline void intel_guc_enable_msg(struct intel_guc *guc, u32 mask)
|
|
|
|
{
|
|
|
|
spin_lock_irq(&guc->irq_lock);
|
|
|
|
guc->msg_enabled_mask |= mask;
|
|
|
|
spin_unlock_irq(&guc->irq_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void intel_guc_disable_msg(struct intel_guc *guc, u32 mask)
|
|
|
|
{
|
|
|
|
spin_lock_irq(&guc->irq_lock);
|
|
|
|
guc->msg_enabled_mask &= ~mask;
|
|
|
|
spin_unlock_irq(&guc->irq_lock);
|
|
|
|
}
|
|
|
|
|
2021-07-21 21:50:58 +00:00
|
|
|
int intel_guc_wait_for_idle(struct intel_guc *guc, long timeout);
|
|
|
|
|
2021-07-21 21:50:49 +00:00
|
|
|
int intel_guc_deregister_done_process_msg(struct intel_guc *guc,
|
|
|
|
const u32 *msg, u32 len);
|
2021-07-21 21:50:51 +00:00
|
|
|
int intel_guc_sched_done_process_msg(struct intel_guc *guc,
|
|
|
|
const u32 *msg, u32 len);
|
2021-07-27 00:23:27 +00:00
|
|
|
int intel_guc_context_reset_process_msg(struct intel_guc *guc,
|
|
|
|
const u32 *msg, u32 len);
|
2021-07-27 00:23:28 +00:00
|
|
|
int intel_guc_engine_failure_process_msg(struct intel_guc *guc,
|
|
|
|
const u32 *msg, u32 len);
|
2021-07-21 21:50:49 +00:00
|
|
|
|
2021-07-27 00:23:34 +00:00
|
|
|
void intel_guc_find_hung_context(struct intel_engine_cs *engine);
|
|
|
|
|
2021-07-27 00:23:35 +00:00
|
|
|
int intel_guc_global_policies_update(struct intel_guc *guc);
|
|
|
|
|
2021-07-27 00:23:39 +00:00
|
|
|
void intel_guc_context_ban(struct intel_context *ce, struct i915_request *rq);
|
|
|
|
|
2021-07-27 00:23:23 +00:00
|
|
|
void intel_guc_submission_reset_prepare(struct intel_guc *guc);
|
|
|
|
void intel_guc_submission_reset(struct intel_guc *guc, bool stalled);
|
|
|
|
void intel_guc_submission_reset_finish(struct intel_guc *guc);
|
|
|
|
void intel_guc_submission_cancel_requests(struct intel_guc *guc);
|
|
|
|
|
2020-03-26 18:11:19 +00:00
|
|
|
void intel_guc_load_status(struct intel_guc *guc, struct drm_printer *p);
|
|
|
|
|
2021-10-14 17:19:52 +00:00
|
|
|
void intel_guc_write_barrier(struct intel_guc *guc);
|
|
|
|
|
2017-10-04 18:13:41 +00:00
|
|
|
#endif
|