drm/i915: Invert the GEM wakeref hierarchy
In the current scheme, on submitting a request we take a single global
GEM wakeref, which trickles down to wake up all GT power domains. This
is undesirable as we would like to be able to localise our power
management to the available power domains and to remove the global GEM
operations from the heart of the driver. (The intent there is to push
global GEM decisions to the boundary as used by the GEM user interface.)
Now during request construction, each request is responsible via its
logical context to acquire a wakeref on each power domain it intends to
utilize. Currently, each request takes a wakeref on the engine(s) and
the engines themselves take a chipset wakeref. This gives us a
transition on each engine which we can extend if we want to insert more
powermangement control (such as soft rc6). The global GEM operations
that currently require a struct_mutex are reduced to listening to pm
events from the chipset GT wakeref. As we reduce the struct_mutex
requirement, these listeners should evaporate.
Perhaps the biggest immediate change is that this removes the
struct_mutex requirement around GT power management, allowing us greater
flexibility in request construction. Another important knock-on effect,
is that by tracking engine usage, we can insert a switch back to the
kernel context on that engine immediately, avoiding any extra delay or
inserting global synchronisation barriers. This makes tracking when an
engine and its associated contexts are idle much easier -- important for
when we forgo our assumed execution ordering and need idle barriers to
unpin used contexts. In the process, it means we remove a large chunk of
code whose only purpose was to switch back to the kernel context.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
2019-04-24 21:07:17 +01:00
/*
* SPDX - License - Identifier : MIT
*
* Copyright © 2019 Intel Corporation
*/
# ifndef INTEL_ENGINE_PM_H
# define INTEL_ENGINE_PM_H
2019-11-25 10:58:56 +00:00
# include "i915_request.h"
2019-06-25 14:01:14 +01:00
# include "intel_engine_types.h"
# include "intel_wakeref.h"
static inline bool
intel_engine_pm_is_awake ( const struct intel_engine_cs * engine )
{
return intel_wakeref_is_active ( & engine - > wakeref ) ;
}
2019-08-08 21:27:58 +01:00
static inline void intel_engine_pm_get ( struct intel_engine_cs * engine )
{
intel_wakeref_get ( & engine - > wakeref ) ;
}
static inline bool intel_engine_pm_get_if_awake ( struct intel_engine_cs * engine )
2019-06-26 16:45:47 +01:00
{
return intel_wakeref_get_if_active ( & engine - > wakeref ) ;
}
2019-08-08 21:27:58 +01:00
static inline void intel_engine_pm_put ( struct intel_engine_cs * engine )
{
intel_wakeref_put ( & engine - > wakeref ) ;
}
2019-05-03 09:09:42 +01:00
2019-11-20 12:54:33 +00:00
static inline void intel_engine_pm_put_async ( struct intel_engine_cs * engine )
{
intel_wakeref_put_async ( & engine - > wakeref ) ;
}
2020-03-23 10:32:21 +00:00
static inline void intel_engine_pm_put_delay ( struct intel_engine_cs * engine ,
unsigned long delay )
{
intel_wakeref_put_delay ( & engine - > wakeref , delay ) ;
}
2019-11-20 12:54:33 +00:00
static inline void intel_engine_pm_flush ( struct intel_engine_cs * engine )
{
intel_wakeref_unlock_wait ( & engine - > wakeref ) ;
}
2019-11-25 10:58:56 +00:00
static inline struct i915_request *
intel_engine_create_kernel_request ( struct intel_engine_cs * engine )
{
struct i915_request * rq ;
/*
* The engine - > kernel_context is special as it is used inside
* the engine - pm barrier ( see __engine_park ( ) ) , circumventing
* the usual mutexes and relying on the engine - pm barrier
* instead . So whenever we use the engine - > kernel_context
* outside of the barrier , we must manually handle the
* engine wakeref to serialise with the use inside .
*/
intel_engine_pm_get ( engine ) ;
rq = i915_request_create ( engine - > kernel_context ) ;
intel_engine_pm_put ( engine ) ;
return rq ;
}
drm/i915: Invert the GEM wakeref hierarchy
In the current scheme, on submitting a request we take a single global
GEM wakeref, which trickles down to wake up all GT power domains. This
is undesirable as we would like to be able to localise our power
management to the available power domains and to remove the global GEM
operations from the heart of the driver. (The intent there is to push
global GEM decisions to the boundary as used by the GEM user interface.)
Now during request construction, each request is responsible via its
logical context to acquire a wakeref on each power domain it intends to
utilize. Currently, each request takes a wakeref on the engine(s) and
the engines themselves take a chipset wakeref. This gives us a
transition on each engine which we can extend if we want to insert more
powermangement control (such as soft rc6). The global GEM operations
that currently require a struct_mutex are reduced to listening to pm
events from the chipset GT wakeref. As we reduce the struct_mutex
requirement, these listeners should evaporate.
Perhaps the biggest immediate change is that this removes the
struct_mutex requirement around GT power management, allowing us greater
flexibility in request construction. Another important knock-on effect,
is that by tracking engine usage, we can insert a switch back to the
kernel context on that engine immediately, avoiding any extra delay or
inserting global synchronisation barriers. This makes tracking when an
engine and its associated contexts are idle much easier -- important for
when we forgo our assumed execution ordering and need idle barriers to
unpin used contexts. In the process, it means we remove a large chunk of
code whose only purpose was to switch back to the kernel context.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190424200717.1686-5-chris@chris-wilson.co.uk
2019-04-24 21:07:17 +01:00
void intel_engine_init__pm ( struct intel_engine_cs * engine ) ;
# endif /* INTEL_ENGINE_PM_H */