2019-08-12 09:29:35 +00:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
2017-10-04 18:13:40 +00:00
|
|
|
/*
|
2019-08-12 09:29:35 +00:00
|
|
|
* Copyright © 2014-2019 Intel Corporation
|
2017-10-04 18:13:40 +00:00
|
|
|
*/
|
|
|
|
|
2017-11-24 08:20:50 +00:00
|
|
|
#ifndef _INTEL_GUC_SUBMISSION_H_
|
|
|
|
#define _INTEL_GUC_SUBMISSION_H_
|
2017-10-04 18:13:40 +00:00
|
|
|
|
2019-12-05 22:02:42 +00:00
|
|
|
#include <linux/types.h>
|
2017-10-04 18:13:40 +00:00
|
|
|
|
2020-02-18 22:33:24 +00:00
|
|
|
#include "intel_guc.h"
|
|
|
|
|
2021-07-21 21:50:59 +00:00
|
|
|
struct drm_printer;
|
2019-12-05 22:02:42 +00:00
|
|
|
struct intel_engine_cs;
|
2017-10-04 18:13:40 +00:00
|
|
|
|
2019-07-31 22:33:20 +00:00
|
|
|
void intel_guc_submission_init_early(struct intel_guc *guc);
|
2017-11-16 13:32:39 +00:00
|
|
|
int intel_guc_submission_init(struct intel_guc *guc);
|
drm/i915/guc: kill doorbell code and selftests
Instead of relying on the workqueue, the upcoming reworked GuC
submission flow will offer the host driver indipendent control over
the execution status of each context submitted to GuC. As part of this,
the doorbell usage model has been reworked, with each doorbell being
paired to a single lrc and a doorbell ring representing new work
available for that specific context. This mechanism, however, limits
the number of contexts that can be registered with GuC to the number of
doorbells, which is an undesired limitation. To avoid this limitation,
we requested the GuC team to also provide a H2G that will allow the host
to notify the GuC of work available for a specified lrc, so we can use
that mechanism instead of relying on the doorbells. We can therefore drop
the doorbell code we currently have, also given the fact that in the
unlikely case we'd want to switch back to using doorbells we'd have to
heavily rework it.
The workqueue will still have a use in the new interface to pass special
commands, so that code has been retained for now.
With the doorbells gone and the GuC client becoming even simpler, the
existing GuC selftests don't give us any meaningful coverage so we can
remove them as well. Some selftests might come with the new code, but
they will look different from what we have now so if doesn't seem worth
it to keep the file around in the meantime.
v2: fix comments and commit message (John)
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191205220243.27403-3-daniele.ceraolospurio@intel.com
2019-12-05 22:02:41 +00:00
|
|
|
void intel_guc_submission_enable(struct intel_guc *guc);
|
2017-11-16 13:32:39 +00:00
|
|
|
void intel_guc_submission_disable(struct intel_guc *guc);
|
|
|
|
void intel_guc_submission_fini(struct intel_guc *guc);
|
2017-12-13 22:13:47 +00:00
|
|
|
int intel_guc_preempt_work_create(struct intel_guc *guc);
|
|
|
|
void intel_guc_preempt_work_destroy(struct intel_guc *guc);
|
2021-01-13 02:12:35 +00:00
|
|
|
int intel_guc_submission_setup(struct intel_engine_cs *engine);
|
2021-07-21 21:50:59 +00:00
|
|
|
void intel_guc_submission_print_info(struct intel_guc *guc,
|
|
|
|
struct drm_printer *p);
|
|
|
|
void intel_guc_submission_print_context_info(struct intel_guc *guc,
|
|
|
|
struct drm_printer *p);
|
2021-07-27 00:23:34 +00:00
|
|
|
void intel_guc_dump_active_requests(struct intel_engine_cs *engine,
|
|
|
|
struct i915_request *hung_rq,
|
|
|
|
struct drm_printer *m);
|
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
|
|
|
void intel_guc_busyness_park(struct intel_gt *gt);
|
|
|
|
void intel_guc_busyness_unpark(struct intel_gt *gt);
|
2017-10-04 18:13:40 +00:00
|
|
|
|
2021-07-27 00:23:16 +00:00
|
|
|
bool intel_guc_virtual_engine_has_heartbeat(const struct intel_engine_cs *ve);
|
|
|
|
|
2021-07-27 00:23:26 +00:00
|
|
|
int intel_guc_wait_for_pending_msg(struct intel_guc *guc,
|
|
|
|
atomic_t *wait_var,
|
|
|
|
bool interruptible,
|
|
|
|
long timeout);
|
|
|
|
|
2020-02-18 22:33:24 +00:00
|
|
|
static inline bool intel_guc_submission_is_supported(struct intel_guc *guc)
|
|
|
|
{
|
2021-07-27 00:23:48 +00:00
|
|
|
return guc->submission_supported;
|
2020-02-18 22:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool intel_guc_submission_is_wanted(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
return guc->submission_selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool intel_guc_submission_is_used(struct intel_guc *guc)
|
|
|
|
{
|
|
|
|
return intel_guc_is_used(guc) && intel_guc_submission_is_wanted(guc);
|
|
|
|
}
|
|
|
|
|
2017-10-04 18:13:40 +00:00
|
|
|
#endif
|