Commit 2cf7bf6f authored by Daniele Ceraolo Spurio's avatar Daniele Ceraolo Spurio Committed by Chris Wilson

drm/i915: add uncore flags for unclaimed mmio

Save the HW capabilities to avoid having to jump back to dev_priv
every time.
Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190325214940.23632-4-daniele.ceraolospurio@intel.com
parent 5a0ba777
...@@ -2887,7 +2887,7 @@ static int intel_runtime_suspend(struct device *kdev) ...@@ -2887,7 +2887,7 @@ static int intel_runtime_suspend(struct device *kdev)
enable_rpm_wakeref_asserts(dev_priv); enable_rpm_wakeref_asserts(dev_priv);
intel_runtime_pm_cleanup(dev_priv); intel_runtime_pm_cleanup(dev_priv);
if (intel_uncore_arm_unclaimed_mmio_detection(dev_priv)) if (intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore))
DRM_ERROR("Unclaimed access detected prior to suspending\n"); DRM_ERROR("Unclaimed access detected prior to suspending\n");
dev_priv->runtime_pm.suspended = true; dev_priv->runtime_pm.suspended = true;
...@@ -2941,7 +2941,7 @@ static int intel_runtime_resume(struct device *kdev) ...@@ -2941,7 +2941,7 @@ static int intel_runtime_resume(struct device *kdev)
intel_opregion_notify_adapter(dev_priv, PCI_D0); intel_opregion_notify_adapter(dev_priv, PCI_D0);
dev_priv->runtime_pm.suspended = false; dev_priv->runtime_pm.suspended = false;
if (intel_uncore_unclaimed_mmio(dev_priv)) if (intel_uncore_unclaimed_mmio(&dev_priv->uncore))
DRM_DEBUG_DRIVER("Unclaimed access during suspend, bios?\n"); DRM_DEBUG_DRIVER("Unclaimed access during suspend, bios?\n");
if (INTEL_GEN(dev_priv) >= 11) { if (INTEL_GEN(dev_priv) >= 11) {
......
...@@ -13533,7 +13533,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state) ...@@ -13533,7 +13533,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
* so enable debugging for the next modeset - and hope we catch * so enable debugging for the next modeset - and hope we catch
* the culprit. * the culprit.
*/ */
intel_uncore_arm_unclaimed_mmio_detection(dev_priv); intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore);
intel_display_power_put(dev_priv, POWER_DOMAIN_MODESET, wakeref); intel_display_power_put(dev_priv, POWER_DOMAIN_MODESET, wakeref);
} }
......
...@@ -270,7 +270,7 @@ static void i915_hangcheck_elapsed(struct work_struct *work) ...@@ -270,7 +270,7 @@ static void i915_hangcheck_elapsed(struct work_struct *work)
* periodically arm the mmio checker to see if we are triggering * periodically arm the mmio checker to see if we are triggering
* any invalid access. * any invalid access.
*/ */
intel_uncore_arm_unclaimed_mmio_detection(dev_priv); intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore);
for_each_engine(engine, dev_priv, id) { for_each_engine(engine, dev_priv, id) {
struct hangcheck hc; struct hangcheck hc;
......
...@@ -509,18 +509,17 @@ gen6_check_for_fifo_debug(struct intel_uncore *uncore) ...@@ -509,18 +509,17 @@ gen6_check_for_fifo_debug(struct intel_uncore *uncore)
} }
static bool static bool
check_for_unclaimed_mmio(struct drm_i915_private *dev_priv) check_for_unclaimed_mmio(struct intel_uncore *uncore)
{ {
struct intel_uncore *uncore = &dev_priv->uncore;
bool ret = false; bool ret = false;
if (HAS_FPGA_DBG_UNCLAIMED(dev_priv)) if (intel_uncore_has_fpga_dbg_unclaimed(uncore))
ret |= fpga_check_for_unclaimed_mmio(uncore); ret |= fpga_check_for_unclaimed_mmio(uncore);
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) if (intel_uncore_has_dbg_unclaimed(uncore))
ret |= vlv_check_for_unclaimed_mmio(uncore); ret |= vlv_check_for_unclaimed_mmio(uncore);
if (IS_GEN_RANGE(dev_priv, 6, 7)) if (intel_uncore_has_fifo(uncore))
ret |= gen6_check_for_fifo_debug(uncore); ret |= gen6_check_for_fifo_debug(uncore);
return ret; return ret;
...@@ -529,14 +528,12 @@ check_for_unclaimed_mmio(struct drm_i915_private *dev_priv) ...@@ -529,14 +528,12 @@ check_for_unclaimed_mmio(struct drm_i915_private *dev_priv)
static void __intel_uncore_early_sanitize(struct intel_uncore *uncore, static void __intel_uncore_early_sanitize(struct intel_uncore *uncore,
unsigned int restore_forcewake) unsigned int restore_forcewake)
{ {
struct drm_i915_private *i915 = uncore_to_i915(uncore);
/* clear out unclaimed reg detection bit */ /* clear out unclaimed reg detection bit */
if (check_for_unclaimed_mmio(i915)) if (check_for_unclaimed_mmio(uncore))
DRM_DEBUG("unclaimed mmio detected on uncore init, clearing\n"); DRM_DEBUG("unclaimed mmio detected on uncore init, clearing\n");
/* WaDisableShadowRegForCpd:chv */ /* WaDisableShadowRegForCpd:chv */
if (IS_CHERRYVIEW(i915)) { if (IS_CHERRYVIEW(uncore_to_i915(uncore))) {
__raw_uncore_write32(uncore, GTFIFOCTL, __raw_uncore_write32(uncore, GTFIFOCTL,
__raw_uncore_read32(uncore, GTFIFOCTL) | __raw_uncore_read32(uncore, GTFIFOCTL) |
GT_FIFO_CTL_BLOCK_ALL_POLICY_STALL | GT_FIFO_CTL_BLOCK_ALL_POLICY_STALL |
...@@ -549,7 +546,7 @@ static void __intel_uncore_early_sanitize(struct intel_uncore *uncore, ...@@ -549,7 +546,7 @@ static void __intel_uncore_early_sanitize(struct intel_uncore *uncore,
spin_lock_irq(&uncore->lock); spin_lock_irq(&uncore->lock);
uncore->funcs.force_wake_get(uncore, restore_forcewake); uncore->funcs.force_wake_get(uncore, restore_forcewake);
if (IS_GEN_RANGE(i915, 6, 7)) if (intel_uncore_has_fifo(uncore))
uncore->fifo_count = fifo_free_entries(uncore); uncore->fifo_count = fifo_free_entries(uncore);
spin_unlock_irq(&uncore->lock); spin_unlock_irq(&uncore->lock);
} }
...@@ -668,12 +665,10 @@ void intel_uncore_forcewake_user_get(struct intel_uncore *uncore) ...@@ -668,12 +665,10 @@ void intel_uncore_forcewake_user_get(struct intel_uncore *uncore)
*/ */
void intel_uncore_forcewake_user_put(struct intel_uncore *uncore) void intel_uncore_forcewake_user_put(struct intel_uncore *uncore)
{ {
struct drm_i915_private *i915 = uncore_to_i915(uncore);
spin_lock_irq(&uncore->lock); spin_lock_irq(&uncore->lock);
if (!--uncore->user_forcewake.count) { if (!--uncore->user_forcewake.count) {
if (intel_uncore_unclaimed_mmio(i915)) if (intel_uncore_unclaimed_mmio(uncore))
dev_info(i915->drm.dev, dev_info(uncore_to_i915(uncore)->drm.dev,
"Invalid mmio detected during user access\n"); "Invalid mmio detected during user access\n");
uncore->unclaimed_mmio_check = uncore->unclaimed_mmio_check =
...@@ -1072,12 +1067,12 @@ ilk_dummy_write(struct intel_uncore *uncore) ...@@ -1072,12 +1067,12 @@ ilk_dummy_write(struct intel_uncore *uncore)
} }
static void static void
__unclaimed_reg_debug(struct drm_i915_private *dev_priv, __unclaimed_reg_debug(struct intel_uncore *uncore,
const i915_reg_t reg, const i915_reg_t reg,
const bool read, const bool read,
const bool before) const bool before)
{ {
if (WARN(check_for_unclaimed_mmio(dev_priv) && !before, if (WARN(check_for_unclaimed_mmio(uncore) && !before,
"Unclaimed %s register 0x%x\n", "Unclaimed %s register 0x%x\n",
read ? "read from" : "write to", read ? "read from" : "write to",
i915_mmio_reg_offset(reg))) i915_mmio_reg_offset(reg)))
...@@ -1086,7 +1081,7 @@ __unclaimed_reg_debug(struct drm_i915_private *dev_priv, ...@@ -1086,7 +1081,7 @@ __unclaimed_reg_debug(struct drm_i915_private *dev_priv,
} }
static inline void static inline void
unclaimed_reg_debug(struct drm_i915_private *dev_priv, unclaimed_reg_debug(struct intel_uncore *uncore,
const i915_reg_t reg, const i915_reg_t reg,
const bool read, const bool read,
const bool before) const bool before)
...@@ -1094,7 +1089,7 @@ unclaimed_reg_debug(struct drm_i915_private *dev_priv, ...@@ -1094,7 +1089,7 @@ unclaimed_reg_debug(struct drm_i915_private *dev_priv,
if (likely(!i915_modparams.mmio_debug)) if (likely(!i915_modparams.mmio_debug))
return; return;
__unclaimed_reg_debug(dev_priv, reg, read, before); __unclaimed_reg_debug(uncore, reg, read, before);
} }
#define GEN2_READ_HEADER(x) \ #define GEN2_READ_HEADER(x) \
...@@ -1145,10 +1140,10 @@ __gen2_read(64) ...@@ -1145,10 +1140,10 @@ __gen2_read(64)
u##x val = 0; \ u##x val = 0; \
assert_rpm_wakelock_held(dev_priv); \ assert_rpm_wakelock_held(dev_priv); \
spin_lock_irqsave(&uncore->lock, irqflags); \ spin_lock_irqsave(&uncore->lock, irqflags); \
unclaimed_reg_debug(dev_priv, reg, true, true) unclaimed_reg_debug(uncore, reg, true, true)
#define GEN6_READ_FOOTER \ #define GEN6_READ_FOOTER \
unclaimed_reg_debug(dev_priv, reg, true, false); \ unclaimed_reg_debug(uncore, reg, true, false); \
spin_unlock_irqrestore(&uncore->lock, irqflags); \ spin_unlock_irqrestore(&uncore->lock, irqflags); \
trace_i915_reg_rw(false, reg, val, sizeof(val), trace); \ trace_i915_reg_rw(false, reg, val, sizeof(val), trace); \
return val return val
...@@ -1259,10 +1254,10 @@ __gen2_write(32) ...@@ -1259,10 +1254,10 @@ __gen2_write(32)
trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \ trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \
assert_rpm_wakelock_held(dev_priv); \ assert_rpm_wakelock_held(dev_priv); \
spin_lock_irqsave(&uncore->lock, irqflags); \ spin_lock_irqsave(&uncore->lock, irqflags); \
unclaimed_reg_debug(dev_priv, reg, false, true) unclaimed_reg_debug(uncore, reg, false, true)
#define GEN6_WRITE_FOOTER \ #define GEN6_WRITE_FOOTER \
unclaimed_reg_debug(dev_priv, reg, false, false); \ unclaimed_reg_debug(uncore, reg, false, false); \
spin_unlock_irqrestore(&uncore->lock, irqflags) spin_unlock_irqrestore(&uncore->lock, irqflags)
#define __gen6_write(x) \ #define __gen6_write(x) \
...@@ -1638,6 +1633,15 @@ int intel_uncore_init(struct intel_uncore *uncore) ...@@ -1638,6 +1633,15 @@ int intel_uncore_init(struct intel_uncore *uncore)
ASSIGN_READ_MMIO_VFUNCS(uncore, gen11_fwtable); ASSIGN_READ_MMIO_VFUNCS(uncore, gen11_fwtable);
} }
if (HAS_FPGA_DBG_UNCLAIMED(i915))
uncore->flags |= UNCORE_HAS_FPGA_DBG_UNCLAIMED;
if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
uncore->flags |= UNCORE_HAS_DBG_UNCLAIMED;
if (IS_GEN_RANGE(i915, 6, 7))
uncore->flags |= UNCORE_HAS_FIFO;
iosf_mbi_register_pmic_bus_access_notifier(&uncore->pmic_bus_access_nb); iosf_mbi_register_pmic_bus_access_notifier(&uncore->pmic_bus_access_nb);
return 0; return 0;
...@@ -1869,15 +1873,14 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv, ...@@ -1869,15 +1873,14 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv,
return ret; return ret;
} }
bool intel_uncore_unclaimed_mmio(struct drm_i915_private *dev_priv) bool intel_uncore_unclaimed_mmio(struct intel_uncore *uncore)
{ {
return check_for_unclaimed_mmio(dev_priv); return check_for_unclaimed_mmio(uncore);
} }
bool bool
intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private *dev_priv) intel_uncore_arm_unclaimed_mmio_detection(struct intel_uncore *uncore)
{ {
struct intel_uncore *uncore = &dev_priv->uncore;
bool ret = false; bool ret = false;
spin_lock_irq(&uncore->lock); spin_lock_irq(&uncore->lock);
...@@ -1885,7 +1888,7 @@ intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private *dev_priv) ...@@ -1885,7 +1888,7 @@ intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private *dev_priv)
if (unlikely(uncore->unclaimed_mmio_check <= 0)) if (unlikely(uncore->unclaimed_mmio_check <= 0))
goto out; goto out;
if (unlikely(intel_uncore_unclaimed_mmio(dev_priv))) { if (unlikely(intel_uncore_unclaimed_mmio(uncore))) {
if (!i915_modparams.mmio_debug) { if (!i915_modparams.mmio_debug) {
DRM_DEBUG("Unclaimed register detected, " DRM_DEBUG("Unclaimed register detected, "
"enabling oneshot unclaimed register reporting. " "enabling oneshot unclaimed register reporting. "
......
...@@ -99,6 +99,9 @@ struct intel_uncore { ...@@ -99,6 +99,9 @@ struct intel_uncore {
unsigned int flags; unsigned int flags;
#define UNCORE_HAS_FORCEWAKE BIT(0) #define UNCORE_HAS_FORCEWAKE BIT(0)
#define UNCORE_HAS_FPGA_DBG_UNCLAIMED BIT(1)
#define UNCORE_HAS_DBG_UNCLAIMED BIT(2)
#define UNCORE_HAS_FIFO BIT(3)
const struct intel_forcewake_range *fw_domains_table; const struct intel_forcewake_range *fw_domains_table;
unsigned int fw_domains_table_entries; unsigned int fw_domains_table_entries;
...@@ -152,11 +155,29 @@ intel_uncore_has_forcewake(const struct intel_uncore *uncore) ...@@ -152,11 +155,29 @@ intel_uncore_has_forcewake(const struct intel_uncore *uncore)
return uncore->flags & UNCORE_HAS_FORCEWAKE; return uncore->flags & UNCORE_HAS_FORCEWAKE;
} }
static inline bool
intel_uncore_has_fpga_dbg_unclaimed(const struct intel_uncore *uncore)
{
return uncore->flags & UNCORE_HAS_FPGA_DBG_UNCLAIMED;
}
static inline bool
intel_uncore_has_dbg_unclaimed(const struct intel_uncore *uncore)
{
return uncore->flags & UNCORE_HAS_DBG_UNCLAIMED;
}
static inline bool
intel_uncore_has_fifo(const struct intel_uncore *uncore)
{
return uncore->flags & UNCORE_HAS_FIFO;
}
void intel_uncore_sanitize(struct drm_i915_private *dev_priv); void intel_uncore_sanitize(struct drm_i915_private *dev_priv);
int intel_uncore_init(struct intel_uncore *uncore); int intel_uncore_init(struct intel_uncore *uncore);
void intel_uncore_prune(struct intel_uncore *uncore); void intel_uncore_prune(struct intel_uncore *uncore);
bool intel_uncore_unclaimed_mmio(struct drm_i915_private *dev_priv); bool intel_uncore_unclaimed_mmio(struct intel_uncore *uncore);
bool intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private *dev_priv); bool intel_uncore_arm_unclaimed_mmio_detection(struct intel_uncore *uncore);
void intel_uncore_fini(struct intel_uncore *uncore); void intel_uncore_fini(struct intel_uncore *uncore);
void intel_uncore_suspend(struct intel_uncore *uncore); void intel_uncore_suspend(struct intel_uncore *uncore);
void intel_uncore_resume_early(struct intel_uncore *uncore); void intel_uncore_resume_early(struct intel_uncore *uncore);
......
...@@ -244,6 +244,7 @@ static int live_forcewake_domains(void *arg) ...@@ -244,6 +244,7 @@ static int live_forcewake_domains(void *arg)
{ {
#define FW_RANGE 0x40000 #define FW_RANGE 0x40000
struct drm_i915_private *dev_priv = arg; struct drm_i915_private *dev_priv = arg;
struct intel_uncore *uncore = &dev_priv->uncore;
unsigned long *valid; unsigned long *valid;
u32 offset; u32 offset;
int err; int err;
...@@ -263,31 +264,31 @@ static int live_forcewake_domains(void *arg) ...@@ -263,31 +264,31 @@ static int live_forcewake_domains(void *arg)
if (!valid) if (!valid)
return -ENOMEM; return -ENOMEM;
intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL); intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
check_for_unclaimed_mmio(dev_priv); check_for_unclaimed_mmio(uncore);
for (offset = 0; offset < FW_RANGE; offset += 4) { for (offset = 0; offset < FW_RANGE; offset += 4) {
i915_reg_t reg = { offset }; i915_reg_t reg = { offset };
(void)I915_READ_FW(reg); (void)I915_READ_FW(reg);
if (!check_for_unclaimed_mmio(dev_priv)) if (!check_for_unclaimed_mmio(uncore))
set_bit(offset, valid); set_bit(offset, valid);
} }
intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL); intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL);
err = 0; err = 0;
for_each_set_bit(offset, valid, FW_RANGE) { for_each_set_bit(offset, valid, FW_RANGE) {
i915_reg_t reg = { offset }; i915_reg_t reg = { offset };
iosf_mbi_punit_acquire(); iosf_mbi_punit_acquire();
intel_uncore_forcewake_reset(&dev_priv->uncore); intel_uncore_forcewake_reset(uncore);
iosf_mbi_punit_release(); iosf_mbi_punit_release();
check_for_unclaimed_mmio(dev_priv); check_for_unclaimed_mmio(uncore);
(void)I915_READ(reg); (void)I915_READ(reg);
if (check_for_unclaimed_mmio(dev_priv)) { if (check_for_unclaimed_mmio(uncore)) {
pr_err("Unclaimed mmio read to register 0x%04x\n", pr_err("Unclaimed mmio read to register 0x%04x\n",
offset); offset);
err = -EINVAL; err = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment