mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 17:59:32 +00:00
drm/i915: Local debug BUG_ON for intel_wakeref
Avoid pulling in i915_gem.h just so that we can use a conditional BUG_ON for debugging. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190621183801.23252-5-chris@chris-wilson.co.uk
This commit is contained in:
parent
12c255b5da
commit
fb993aa7a4
2 changed files with 12 additions and 4 deletions
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "intel_runtime_pm.h"
|
#include "intel_runtime_pm.h"
|
||||||
#include "i915_gem.h"
|
#include "intel_wakeref.h"
|
||||||
|
|
||||||
static void rpm_get(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
|
static void rpm_get(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ static void rpm_put(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
|
||||||
intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
|
intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
|
||||||
|
|
||||||
intel_runtime_pm_put(rpm, wakeref);
|
intel_runtime_pm_put(rpm, wakeref);
|
||||||
GEM_BUG_ON(!wakeref);
|
INTEL_WAKEREF_BUG_ON(!wakeref);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
|
int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
|
||||||
|
@ -48,6 +48,7 @@ int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
|
||||||
atomic_inc(&wf->count);
|
atomic_inc(&wf->count);
|
||||||
mutex_unlock(&wf->mutex);
|
mutex_unlock(&wf->mutex);
|
||||||
|
|
||||||
|
INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
|
||||||
if (!refcount_inc_not_zero(&wf->count)) {
|
if (!refcount_inc_not_zero(&wf->count)) {
|
||||||
spin_lock_irqsave(&wf->lock, flags);
|
spin_lock_irqsave(&wf->lock, flags);
|
||||||
if (!refcount_inc_not_zero(&wf->count)) {
|
if (!refcount_inc_not_zero(&wf->count)) {
|
||||||
GEM_BUG_ON(wf->wakeref);
|
INTEL_WAKEREF_BUG_ON(wf->wakeref);
|
||||||
wf->wakeref = intel_runtime_pm_get_if_in_use(wf->rpm);
|
wf->wakeref = intel_runtime_pm_get_if_in_use(wf->rpm);
|
||||||
refcount_set(&wf->count, 1);
|
refcount_set(&wf->count, 1);
|
||||||
}
|
}
|
||||||
|
@ -134,5 +135,5 @@ void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
|
||||||
void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
|
void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
|
||||||
{
|
{
|
||||||
intel_wakeref_auto(wf, 0);
|
intel_wakeref_auto(wf, 0);
|
||||||
GEM_BUG_ON(wf->wakeref);
|
INTEL_WAKEREF_BUG_ON(wf->wakeref);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
#include <linux/stackdepot.h>
|
#include <linux/stackdepot.h>
|
||||||
#include <linux/timer.h>
|
#include <linux/timer.h>
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
|
||||||
|
#define INTEL_WAKEREF_BUG_ON(expr) BUG_ON(expr)
|
||||||
|
#else
|
||||||
|
#define INTEL_WAKEREF_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
|
||||||
|
#endif
|
||||||
|
|
||||||
struct intel_runtime_pm;
|
struct intel_runtime_pm;
|
||||||
|
|
||||||
typedef depot_stack_handle_t intel_wakeref_t;
|
typedef depot_stack_handle_t intel_wakeref_t;
|
||||||
|
@ -86,6 +92,7 @@ intel_wakeref_put(struct intel_runtime_pm *rpm,
|
||||||
struct intel_wakeref *wf,
|
struct intel_wakeref *wf,
|
||||||
int (*fn)(struct intel_wakeref *wf))
|
int (*fn)(struct intel_wakeref *wf))
|
||||||
{
|
{
|
||||||
|
INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
|
||||||
if (atomic_dec_and_mutex_lock(&wf->count, &wf->mutex))
|
if (atomic_dec_and_mutex_lock(&wf->count, &wf->mutex))
|
||||||
return __intel_wakeref_put_last(rpm, wf, fn);
|
return __intel_wakeref_put_last(rpm, wf, fn);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue