Skip to content

Commit

Permalink
drm/i915: take a ref to the rpm in the uncore structure
Browse files Browse the repository at this point in the history
Remove a bit of pointer dancing in the reg access path.

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190325214940.23632-5-daniele.ceraolospurio@intel.com
  • Loading branch information
Daniele Ceraolo Spurio authored and Chris Wilson committed Mar 26, 2019
1 parent 2cf7bf6 commit eb17af6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
16 changes: 11 additions & 5 deletions drivers/gpu/drm/i915/intel_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2269,20 +2269,26 @@ void icl_dbuf_slices_update(struct drm_i915_private *dev_priv,
u8 req_slices);

static inline void
assert_rpm_device_not_suspended(struct drm_i915_private *i915)
assert_rpm_device_not_suspended(struct i915_runtime_pm *rpm)
{
WARN_ONCE(i915->runtime_pm.suspended,
WARN_ONCE(rpm->suspended,
"Device suspended during HW access\n");
}

static inline void
assert_rpm_wakelock_held(struct drm_i915_private *i915)
__assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
{
assert_rpm_device_not_suspended(i915);
WARN_ONCE(!atomic_read(&i915->runtime_pm.wakeref_count),
assert_rpm_device_not_suspended(rpm);
WARN_ONCE(!atomic_read(&rpm->wakeref_count),
"RPM wakelock ref not held during HW access");
}

static inline void
assert_rpm_wakelock_held(struct drm_i915_private *i915)
{
__assert_rpm_wakelock_held(&i915->runtime_pm);
}

/**
* disable_rpm_wakeref_asserts - disable the RPM assert checks
* @i915: i915 device instance
Expand Down
16 changes: 9 additions & 7 deletions drivers/gpu/drm/i915/intel_uncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ intel_uncore_fw_release_timer(struct hrtimer *timer)
struct intel_uncore *uncore = forcewake_domain_to_uncore(domain);
unsigned long irqflags;

assert_rpm_device_not_suspended(uncore_to_i915(uncore));
assert_rpm_device_not_suspended(uncore->rpm);

if (xchg(&domain->active, false))
return HRTIMER_RESTART;
Expand Down Expand Up @@ -623,7 +623,7 @@ void intel_uncore_forcewake_get(struct intel_uncore *uncore,
if (!uncore->funcs.force_wake_get)
return;

assert_rpm_wakelock_held(uncore_to_i915(uncore));
__assert_rpm_wakelock_held(uncore->rpm);

spin_lock_irqsave(&uncore->lock, irqflags);
__intel_uncore_forcewake_get(uncore, fw_domains);
Expand Down Expand Up @@ -777,7 +777,7 @@ void assert_forcewakes_active(struct intel_uncore *uncore,
if (!uncore->funcs.force_wake_get)
return;

assert_rpm_wakelock_held(uncore_to_i915(uncore));
__assert_rpm_wakelock_held(uncore->rpm);

fw_domains &= uncore->fw_domains;
WARN(fw_domains & ~uncore->fw_domains_active,
Expand Down Expand Up @@ -1095,7 +1095,7 @@ unclaimed_reg_debug(struct intel_uncore *uncore,
#define GEN2_READ_HEADER(x) \
struct intel_uncore *uncore = &dev_priv->uncore; \
u##x val = 0; \
assert_rpm_wakelock_held(dev_priv);
__assert_rpm_wakelock_held(uncore->rpm);

#define GEN2_READ_FOOTER \
trace_i915_reg_rw(false, reg, val, sizeof(val), trace); \
Expand Down Expand Up @@ -1138,7 +1138,7 @@ __gen2_read(64)
u32 offset = i915_mmio_reg_offset(reg); \
unsigned long irqflags; \
u##x val = 0; \
assert_rpm_wakelock_held(dev_priv); \
__assert_rpm_wakelock_held(uncore->rpm); \
spin_lock_irqsave(&uncore->lock, irqflags); \
unclaimed_reg_debug(uncore, reg, true, true)

Expand Down Expand Up @@ -1213,7 +1213,7 @@ __gen6_read(64)
#define GEN2_WRITE_HEADER \
struct intel_uncore *uncore = &dev_priv->uncore; \
trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \
assert_rpm_wakelock_held(dev_priv); \
__assert_rpm_wakelock_held(uncore->rpm); \

#define GEN2_WRITE_FOOTER

Expand Down Expand Up @@ -1252,7 +1252,7 @@ __gen2_write(32)
u32 offset = i915_mmio_reg_offset(reg); \
unsigned long irqflags; \
trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \
assert_rpm_wakelock_held(dev_priv); \
__assert_rpm_wakelock_held(uncore->rpm); \
spin_lock_irqsave(&uncore->lock, irqflags); \
unclaimed_reg_debug(uncore, reg, false, true)

Expand Down Expand Up @@ -1596,6 +1596,8 @@ int intel_uncore_init(struct intel_uncore *uncore)
uncore->pmic_bus_access_nb.notifier_call =
i915_pmic_bus_access_notifier;

uncore->rpm = &i915->runtime_pm;

if (!intel_uncore_has_forcewake(uncore)) {
if (IS_GEN(i915, 5)) {
ASSIGN_WRITE_MMIO_VFUNCS(uncore, gen5);
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/intel_uncore.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "i915_reg.h"

struct drm_i915_private;
struct i915_runtime_pm;
struct intel_uncore;

enum forcewake_domain_id {
Expand Down Expand Up @@ -95,6 +96,8 @@ struct intel_forcewake_range {
struct intel_uncore {
void __iomem *regs;

struct i915_runtime_pm *rpm;

spinlock_t lock; /** lock is also taken in irq contexts. */

unsigned int flags;
Expand Down

0 comments on commit eb17af6

Please sign in to comment.