[Intel-gfx] [RFC 6/8] drm/i915: drop forcewake_user_get/put
Daniele Ceraolo Spurio
daniele.ceraolospurio at intel.com
Thu Jun 6 21:52:15 UTC 2019
Now that we've split out the mmio_debug, we can manipulate that
independently from the debugfs and just call the normal forcewake
get/put functions.
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 19 +++++--
drivers/gpu/drm/i915/i915_drv.c | 2 +-
drivers/gpu/drm/i915/i915_drv.h | 1 +
drivers/gpu/drm/i915/intel_uncore.c | 80 +++++++++--------------------
drivers/gpu/drm/i915/intel_uncore.h | 14 ++---
5 files changed, 45 insertions(+), 71 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index f212241a2758..7e69829008e6 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1391,7 +1391,7 @@ static int i915_forcewake_domains(struct seq_file *m, void *data)
unsigned int tmp;
seq_printf(m, "user.bypass_count = %u\n",
- uncore->user_forcewake.count);
+ atomic_read(&i915->user_forcewake_count));
for_each_fw_domain(fw_domain, uncore, tmp)
seq_printf(m, "%s.wake_count = %u\n",
@@ -4219,7 +4219,11 @@ static int i915_forcewake_open(struct inode *inode, struct file *file)
return 0;
file->private_data = (void *)(uintptr_t)intel_runtime_pm_get(i915);
- intel_uncore_forcewake_user_get(&i915->uncore);
+
+ if (atomic_inc_return(&i915->user_forcewake_count) == 1) {
+ intel_uncore_forcewake_get(&i915->uncore, FORCEWAKE_ALL);
+ intel_uncore_mmio_debug_suspend(&i915->mmio_debug);
+ }
return 0;
}
@@ -4231,9 +4235,14 @@ static int i915_forcewake_release(struct inode *inode, struct file *file)
if (INTEL_GEN(i915) < 6)
return 0;
- intel_uncore_forcewake_user_put(&i915->uncore);
- intel_runtime_pm_put(i915,
- (intel_wakeref_t)(uintptr_t)file->private_data);
+ if (atomic_dec_and_test(&i915->user_forcewake_count)) {
+ if (intel_uncore_unclaimed_mmio(&i915->uncore))
+ dev_info(i915->drm.dev,
+ "Invalid mmio detected during user access\n");
+
+ intel_uncore_mmio_debug_resume(&i915->mmio_debug);
+ intel_uncore_forcewake_put(&i915->uncore, FORCEWAKE_ALL);
+ }
return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 8fdd668eb7c7..024f270f6f00 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2187,7 +2187,7 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation)
out:
enable_rpm_wakeref_asserts(dev_priv);
- if (!dev_priv->uncore.user_forcewake.count)
+ if (!atomic_read(&dev_priv->user_forcewake_count))
intel_runtime_pm_cleanup(dev_priv);
return ret;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 5522132a2ad2..dc6b3e4af575 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1399,6 +1399,7 @@ struct drm_i915_private {
struct intel_uncore uncore;
struct intel_uncore_mmio_debug mmio_debug;
+ atomic_t user_forcewake_count;
struct i915_virtual_gpu vgpu;
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 8e42476ea4a7..c460426b0562 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -41,6 +41,28 @@ intel_uncore_mmio_debug_init_early(struct intel_uncore_mmio_debug *mmio_debug)
mmio_debug->unclaimed_mmio_check = 1;
}
+/* Save and disable mmio debugging for the user bypass */
+void intel_uncore_mmio_debug_suspend(struct intel_uncore_mmio_debug *mmio_debug)
+{
+ spin_lock_irq(&mmio_debug->lock);
+ if (!mmio_debug->suspended) {
+ mmio_debug->saved_mmio_check = mmio_debug->unclaimed_mmio_check;
+ mmio_debug->unclaimed_mmio_check = 0;
+ mmio_debug->suspended = true;
+ }
+ spin_unlock_irq(&mmio_debug->lock);
+}
+
+void intel_uncore_mmio_debug_resume(struct intel_uncore_mmio_debug *mmio_debug)
+{
+ spin_lock_irq(&mmio_debug->lock);
+ if (mmio_debug->suspended) {
+ mmio_debug->unclaimed_mmio_check = mmio_debug->saved_mmio_check;
+ mmio_debug->suspended = false;
+ }
+ spin_unlock_irq(&mmio_debug->lock);
+}
+
static const char * const forcewake_domain_names[] = {
"render",
"blitter",
@@ -482,6 +504,9 @@ check_for_unclaimed_mmio(struct intel_uncore *uncore)
lockdep_assert_held(&uncore->debug->lock);
+ if (uncore->debug->suspended)
+ return false;
+
if (intel_uncore_has_fpga_dbg_unclaimed(uncore))
ret |= fpga_check_for_unclaimed_mmio(uncore);
@@ -593,61 +618,6 @@ void intel_uncore_forcewake_get(struct intel_uncore *uncore,
spin_unlock_irqrestore(&uncore->lock, irqflags);
}
-/**
- * intel_uncore_forcewake_user_get - claim forcewake on behalf of userspace
- * @uncore: the intel_uncore structure
- *
- * This function is a wrapper around intel_uncore_forcewake_get() to acquire
- * the GT powerwell and in the process disable our debugging for the
- * duration of userspace's bypass.
- */
-void intel_uncore_forcewake_user_get(struct intel_uncore *uncore)
-{
- spin_lock_irq(&uncore->lock);
- spin_lock_irq(&uncore->debug->lock);
- if (!uncore->user_forcewake.count++) {
- intel_uncore_forcewake_get__locked(uncore, FORCEWAKE_ALL);
-
- /* Save and disable mmio debugging for the user bypass */
- uncore->user_forcewake.saved_mmio_check =
- uncore->debug->unclaimed_mmio_check;
- uncore->user_forcewake.saved_mmio_debug =
- i915_modparams.mmio_debug;
-
- uncore->debug->unclaimed_mmio_check = 0;
- i915_modparams.mmio_debug = 0;
- }
- spin_unlock_irq(&uncore->debug->lock);
- spin_unlock_irq(&uncore->lock);
-}
-
-/**
- * intel_uncore_forcewake_user_put - release forcewake on behalf of userspace
- * @uncore: the intel_uncore structure
- *
- * This function complements intel_uncore_forcewake_user_get() and releases
- * the GT powerwell taken on behalf of the userspace bypass.
- */
-void intel_uncore_forcewake_user_put(struct intel_uncore *uncore)
-{
- spin_lock_irq(&uncore->lock);
- spin_lock_irq(&uncore->debug->lock);
- if (!--uncore->user_forcewake.count) {
- if (check_for_unclaimed_mmio(uncore))
- dev_info(uncore_to_i915(uncore)->drm.dev,
- "Invalid mmio detected during user access\n");
-
- uncore->debug->unclaimed_mmio_check =
- uncore->user_forcewake.saved_mmio_check;
- i915_modparams.mmio_debug =
- uncore->user_forcewake.saved_mmio_debug;
-
- intel_uncore_forcewake_put__locked(uncore, FORCEWAKE_ALL);
- }
- spin_unlock_irq(&uncore->debug->lock);
- spin_unlock_irq(&uncore->lock);
-}
-
/**
* intel_uncore_forcewake_get__locked - grab forcewake domain references
* @uncore: the intel_uncore structure
diff --git a/drivers/gpu/drm/i915/intel_uncore.h b/drivers/gpu/drm/i915/intel_uncore.h
index 53c1a334e2ae..1de1e8505124 100644
--- a/drivers/gpu/drm/i915/intel_uncore.h
+++ b/drivers/gpu/drm/i915/intel_uncore.h
@@ -39,6 +39,8 @@ struct intel_uncore;
struct intel_uncore_mmio_debug {
spinlock_t lock; /** lock is also taken in irq contexts. */
int unclaimed_mmio_check;
+ int saved_mmio_check;
+ bool suspended;
};
enum forcewake_domain_id {
@@ -140,13 +142,6 @@ struct intel_uncore {
u32 __iomem *reg_ack;
} *fw_domain[FW_DOMAIN_ID_COUNT];
- struct {
- unsigned int count;
-
- int saved_mmio_check;
- int saved_mmio_debug;
- } user_forcewake;
-
struct intel_uncore_mmio_debug *debug;
};
@@ -184,6 +179,8 @@ intel_uncore_has_fifo(const struct intel_uncore *uncore)
void
intel_uncore_mmio_debug_init_early(struct intel_uncore_mmio_debug *mmio_debug);
+void intel_uncore_mmio_debug_suspend(struct intel_uncore_mmio_debug *mmio_debug);
+void intel_uncore_mmio_debug_resume(struct intel_uncore_mmio_debug *mmio_debug);
void intel_uncore_init_early(struct intel_uncore *uncore);
int intel_uncore_init_mmio(struct intel_uncore *uncore);
@@ -219,9 +216,6 @@ void intel_uncore_forcewake_get__locked(struct intel_uncore *uncore,
void intel_uncore_forcewake_put__locked(struct intel_uncore *uncore,
enum forcewake_domains domains);
-void intel_uncore_forcewake_user_get(struct intel_uncore *uncore);
-void intel_uncore_forcewake_user_put(struct intel_uncore *uncore);
-
int __intel_wait_for_register(struct intel_uncore *uncore,
i915_reg_t reg,
u32 mask,
--
2.20.1
More information about the Intel-gfx
mailing list