Skip to contentSkip to conversation

drm/i915: initialize uncore->lock in uncore_init

PATCH In review Daniele Ceraolo Spurio 3 participants 9 messages Apr 1, 2019 – Apr 2, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: initialize uncore->lock in uncore_init

Now that all the uncore management is hidden under the uncore struct, move the lock initialization under the uncore_init as well for better encapsulation.

---
 drivers/gpu/drm/i915/i915_drv.c     | 1 -
 drivers/gpu/drm/i915/intel_uncore.c | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +0 -1
index 0ca57dc5da5c..667177b7d821 100644
@@ -873,7 +873,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
 	spin_lock_init(&dev_priv->irq_lock);
 	spin_lock_init(&dev_priv->gpu_error.lock);
 	mutex_init(&dev_priv->backlight_lock);
-	spin_lock_init(&dev_priv->uncore.lock);
 
 	mutex_init(&dev_priv->sb_lock);
 	mutex_init(&dev_priv->av_mutex);
drivers/gpu/drm/i915/intel_uncore.c +2 -0
index 106df24f20a5..250496f792e5 100644
@@ -1530,6 +1530,8 @@ int intel_uncore_init(struct intel_uncore *uncore)
 	struct drm_i915_private *i915 = uncore_to_i915(uncore);
 	int ret;
 
+	spin_lock_init(&uncore->lock);
+
 	ret = uncore_mmio_setup(uncore);
 	if (ret)
 		return ret;
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

Quoting Daniele Ceraolo Spurio (2019-04-01 21:14:11)

Quoted 29 lines

Now that all the uncore management is hidden under the uncore struct, move the lock initialization under the uncore_init as well for better encapsulation.

---
 drivers/gpu/drm/i915/i915_drv.c     | 1 -
 drivers/gpu/drm/i915/intel_uncore.c | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +0 -1
index 0ca57dc5da5c..667177b7d821 100644
@@ -873,7 +873,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
        spin_lock_init(&dev_priv->irq_lock);
        spin_lock_init(&dev_priv->gpu_error.lock);
        mutex_init(&dev_priv->backlight_lock);
-       spin_lock_init(&dev_priv->uncore.lock);
 
        mutex_init(&dev_priv->sb_lock);
        mutex_init(&dev_priv->av_mutex);
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index 106df24f20a5..250496f792e5 100644

drivers/gpu/drm/i915/intel_uncore.c int intel_uncore_init(struct intel_uncore *uncore) · line 1533

Quoted 4 lines
drivers/gpu/drm/i915/intel_uncore.c +1 -0
@@ -1530,6 +1530,8 @@ int intel_uncore_init(struct intel_uncore *uncore)
        struct drm_i915_private *i915 = uncore_to_i915(uncore);
        int ret;
 
+       spin_lock_init(&uncore->lock);

Be consistent and make an init_early(). And while you are here this should be called intel_uncore_init_mmio().

Eventually we will have the phases annotated.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
Quoted 33 lines · Chris Wilson

Quoting Daniele Ceraolo Spurio (2019-04-01 21:14:11)

Quoted 32 lines

Now that all the uncore management is hidden under the uncore struct, move the lock initialization under the uncore_init as well for better encapsulation.

---
  drivers/gpu/drm/i915/i915_drv.c     | 1 -
  drivers/gpu/drm/i915/intel_uncore.c | 2 ++
  2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +0 -1
index 0ca57dc5da5c..667177b7d821 100644
@@ -873,7 +873,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
         spin_lock_init(&dev_priv->irq_lock);
         spin_lock_init(&dev_priv->gpu_error.lock);
         mutex_init(&dev_priv->backlight_lock);
-       spin_lock_init(&dev_priv->uncore.lock);
 
         mutex_init(&dev_priv->sb_lock);
         mutex_init(&dev_priv->av_mutex);
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index 106df24f20a5..250496f792e5 100644
@@ -1530,6 +1530,8 @@ int intel_uncore_init(struct intel_uncore *uncore)
         struct drm_i915_private *i915 = uncore_to_i915(uncore);
         int ret;
 
Quoted 4 lines

drivers/gpu/drm/i915/intel_uncore.c int intel_uncore_init(struct intel_uncore *uncore) · line 1533

Quoted 1 line
drivers/gpu/drm/i915/intel_uncore.c +1 -0
+       spin_lock_init(&uncore->lock);

Be consistent and make an init_early(). And while you are here this should be called intel_uncore_init_mmio().

you mean to rename uncore_mmio_setup to intel_uncore_init_mmio, or are you suggesting to rename intel_uncore_init itself? I was planning to split out uncore_mmio_setup in the future to allow multiple uncore structures to be initialized separately from the mapping of the bar and to pull out unrelated init calls from uncore_init. Something like:

static int i915_driver_init_mmio(...)

{
	[... bridge dev init ...]

	ret = intel_uncore_mmio_setup(&dev_priv->uncore);
	if (ret < 0)
		goto err_bridge;

	i915_check_vgpu(i915);

	intel_uncore_init_mmio_access(&dev_priv->uncore);

	[... other stuff ...]
}

I was planning on sending this later once I had more code for the display uncore ready, but I can send it by itself to clean up the ordering.

Thanks,
Daniele

Quoted 4 lines

Eventually we will have the phases annotated.
-Chris

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Quoting Daniele Ceraolo Spurio (2019-04-01 22:06:00)

Quoted 62 lines · Chris Wilson
Quoted 33 lines

Quoting Daniele Ceraolo Spurio (2019-04-01 21:14:11)

Quoted 32 lines

Now that all the uncore management is hidden under the uncore struct, move the lock initialization under the uncore_init as well for better encapsulation.

---
  drivers/gpu/drm/i915/i915_drv.c     | 1 -
  drivers/gpu/drm/i915/intel_uncore.c | 2 ++
  2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +0 -1
index 0ca57dc5da5c..667177b7d821 100644
@@ -873,7 +873,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
         spin_lock_init(&dev_priv->irq_lock);
         spin_lock_init(&dev_priv->gpu_error.lock);
         mutex_init(&dev_priv->backlight_lock);
-       spin_lock_init(&dev_priv->uncore.lock);
 
         mutex_init(&dev_priv->sb_lock);
         mutex_init(&dev_priv->av_mutex);
drivers/gpu/drm/i915/intel_uncore.c +0 -0
index 106df24f20a5..250496f792e5 100644
@@ -1530,6 +1530,8 @@ int intel_uncore_init(struct intel_uncore *uncore)
         struct drm_i915_private *i915 = uncore_to_i915(uncore);
         int ret;
 
Quoted 4 lines

drivers/gpu/drm/i915/intel_uncore.c int intel_uncore_init(struct intel_uncore *uncore) · line 1533

Quoted 1 line
drivers/gpu/drm/i915/intel_uncore.c +1 -0
+       spin_lock_init(&uncore->lock);

Be consistent and make an init_early(). And while you are here this should be called intel_uncore_init_mmio().

you mean to rename uncore_mmio_setup to intel_uncore_init_mmio, or are you suggesting to rename intel_uncore_init itself? I was planning to split out uncore_mmio_setup in the future to allow multiple uncore structures to be initialized separately from the mapping of the bar and to pull out unrelated init calls from uncore_init. Something like:

static int i915_driver_init_mmio(...)

{
        [... bridge dev init ...]

        ret = intel_uncore_mmio_setup(&dev_priv->uncore);
        if (ret < 0)
                goto err_bridge;

        i915_check_vgpu(i915);

        intel_uncore_init_mmio_access(&dev_priv->uncore);

        [... other stuff ...]
}
Quoted 2 lines

I was planning on sending this later once I had more code for the display uncore ready, but I can send it by itself to clean up the ordering.

Nothing so dramatic for now, just pointing out

index 3ee7a72e664e..4bfcd927bce1 100644

drivers/gpu/drm/i915/i915_drv.c +3 -2
@@ -874,10 +874,11 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
 
        intel_device_info_subplatform_init(dev_priv);
 
+       intel_uncore_init_early(&dev_priv->uncore);
+
        spin_lock_init(&dev_priv->irq_lock);
        spin_lock_init(&dev_priv->gpu_error.lock);
        mutex_init(&dev_priv->backlight_lock);
-       spin_lock_init(&dev_priv->uncore.lock);
 
        mutex_init(&dev_priv->sb_lock);
        mutex_init(&dev_priv->av_mutex);
@@ -960,7 +961,7 @@ static int i915_driver_init_mmio(struct drm_i915_private *dev_priv)
        if (i915_get_bridge_dev(dev_priv))
                return -EIO;
 
-       ret = intel_uncore_init(&dev_priv->uncore);
+       ret = intel_uncore_init_mmio(&dev_priv->uncore);
        if (ret < 0)
                goto err_bridge;
 
drivers/gpu/drm/i915/intel_uncore.c +5 -1
index 106df24f20a5..0cfbc36aa15c 100644
@@ -1524,8 +1524,12 @@ static void uncore_mmio_cleanup(struct intel_uncore *uncore)
        pci_iounmap(pdev, uncore->regs);
 }
 
+int intel_uncore_init_early(struct intel_uncore *uncore)
+{
+       spin_lock_init(&uncore->lock);
+}
 
-int intel_uncore_init(struct intel_uncore *uncore)
+int intel_uncore_init_mmio(struct intel_uncore *uncore)
 {
        struct drm_i915_private *i915 = uncore_to_i915(uncore);
        int ret;

would marry the function names to the init phases. -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH v2 1/2 drm/i915: add intel_uncore_init_early

In reply to Daniele Ceraolo Spurio

Encapsulate the uncore early init and be consistent with the "_early" naming.

---
 drivers/gpu/drm/i915/i915_drv.c     | 3 ++-
 drivers/gpu/drm/i915/intel_uncore.c | 4 ++++
 drivers/gpu/drm/i915/intel_uncore.h | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +2 -1
index 0ca57dc5da5c..5bfacf353fa4 100644
@@ -870,10 +870,11 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
 
 	intel_device_info_subplatform_init(dev_priv);
 
+	intel_uncore_init_early(&dev_priv->uncore);
+
 	spin_lock_init(&dev_priv->irq_lock);
 	spin_lock_init(&dev_priv->gpu_error.lock);
 	mutex_init(&dev_priv->backlight_lock);
-	spin_lock_init(&dev_priv->uncore.lock);
 
 	mutex_init(&dev_priv->sb_lock);
 	mutex_init(&dev_priv->av_mutex);
drivers/gpu/drm/i915/intel_uncore.c +4 -0
index 106df24f20a5..3ccda8b7b783 100644
@@ -1524,6 +1524,10 @@ static void uncore_mmio_cleanup(struct intel_uncore *uncore)
 	pci_iounmap(pdev, uncore->regs);
 }
 
+void intel_uncore_init_early(struct intel_uncore *uncore)
+{
+	spin_lock_init(&uncore->lock);
+}
 
 int intel_uncore_init(struct intel_uncore *uncore)
 {
drivers/gpu/drm/i915/intel_uncore.h +1 -0
index 896585a1c2dd..78de1af59334 100644
@@ -178,6 +178,7 @@ intel_uncore_has_fifo(const struct intel_uncore *uncore)
 }
 
 void intel_uncore_sanitize(struct drm_i915_private *dev_priv);
+void intel_uncore_init_early(struct intel_uncore *uncore);
 int intel_uncore_init(struct intel_uncore *uncore);
 void intel_uncore_prune(struct intel_uncore *uncore);
 bool intel_uncore_unclaimed_mmio(struct intel_uncore *uncore);
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v2 2/2 drm/i915: rename init/fini/prune uncore functions

Add "_mmio" postfix to be consistent from the init/fini phase they're called from.

---
 drivers/gpu/drm/i915/i915_drv.c     | 8 ++++----
 drivers/gpu/drm/i915/intel_uncore.c | 6 +++---
 drivers/gpu/drm/i915/intel_uncore.h | 6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +4 -4
index 5bfacf353fa4..0bbf3f5db5fc 100644
@@ -957,7 +957,7 @@ static int i915_driver_init_mmio(struct drm_i915_private *dev_priv)
 	if (i915_get_bridge_dev(dev_priv))
 		return -EIO;
 
-	ret = intel_uncore_init(&dev_priv->uncore);
+	ret = intel_uncore_init_mmio(&dev_priv->uncore);
 	if (ret < 0)
 		goto err_bridge;
 
@@ -966,7 +966,7 @@ static int i915_driver_init_mmio(struct drm_i915_private *dev_priv)
 
 	intel_device_info_init_mmio(dev_priv);
 
-	intel_uncore_prune(&dev_priv->uncore);
+	intel_uncore_prune_mmio_domains(&dev_priv->uncore);
 
 	intel_uc_init_mmio(dev_priv);
 
@@ -980,7 +980,7 @@ static int i915_driver_init_mmio(struct drm_i915_private *dev_priv)
 
 err_uncore:
 	intel_teardown_mchbar(dev_priv);
-	intel_uncore_fini(&dev_priv->uncore);
+	intel_uncore_fini_mmio(&dev_priv->uncore);
 err_bridge:
 	pci_dev_put(dev_priv->bridge_dev);
 
@@ -994,7 +994,7 @@ static int i915_driver_init_mmio(struct drm_i915_private *dev_priv)
 static void i915_driver_cleanup_mmio(struct drm_i915_private *dev_priv)
 {
 	intel_teardown_mchbar(dev_priv);
-	intel_uncore_fini(&dev_priv->uncore);
+	intel_uncore_fini_mmio(&dev_priv->uncore);
 	pci_dev_put(dev_priv->bridge_dev);
 }
 
drivers/gpu/drm/i915/intel_uncore.c +3 -3
index 3ccda8b7b783..a01d1b352a7c 100644
@@ -1529,7 +1529,7 @@ void intel_uncore_init_early(struct intel_uncore *uncore)
 	spin_lock_init(&uncore->lock);
 }
 
-int intel_uncore_init(struct intel_uncore *uncore)
+int intel_uncore_init_mmio(struct intel_uncore *uncore)
 {
 	struct drm_i915_private *i915 = uncore_to_i915(uncore);
 	int ret;
@@ -1608,7 +1608,7 @@ int intel_uncore_init(struct intel_uncore *uncore)
  * the forcewake domains. Prune them, to make sure they only reference existing
  * engines.
  */
-void intel_uncore_prune(struct intel_uncore *uncore)
+void intel_uncore_prune_mmio_domains(struct intel_uncore *uncore)
 {
 	struct drm_i915_private *i915 = uncore_to_i915(uncore);
 
@@ -1639,7 +1639,7 @@ void intel_uncore_prune(struct intel_uncore *uncore)
 	}
 }
 
-void intel_uncore_fini(struct intel_uncore *uncore)
+void intel_uncore_fini_mmio(struct intel_uncore *uncore)
 {
 	/* Paranoia: make sure we have disabled everything before we exit. */
 	intel_uncore_sanitize(uncore_to_i915(uncore));
drivers/gpu/drm/i915/intel_uncore.h +3 -3
index 78de1af59334..a64d3dc0db4d 100644
@@ -179,11 +179,11 @@ intel_uncore_has_fifo(const struct intel_uncore *uncore)
 
 void intel_uncore_sanitize(struct drm_i915_private *dev_priv);
 void intel_uncore_init_early(struct intel_uncore *uncore);
-int intel_uncore_init(struct intel_uncore *uncore);
-void intel_uncore_prune(struct intel_uncore *uncore);
+int intel_uncore_init_mmio(struct intel_uncore *uncore);
+void intel_uncore_prune_mmio_domains(struct intel_uncore *uncore);
 bool intel_uncore_unclaimed_mmio(struct intel_uncore *uncore);
 bool intel_uncore_arm_unclaimed_mmio_detection(struct intel_uncore *uncore);
-void intel_uncore_fini(struct intel_uncore *uncore);
+void intel_uncore_fini_mmio(struct intel_uncore *uncore);
 void intel_uncore_suspend(struct intel_uncore *uncore);
 void intel_uncore_resume_early(struct intel_uncore *uncore);
 void intel_uncore_runtime_resume(struct intel_uncore *uncore);
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 2/2
#6 lore raw

Re: [PATCH v2 2/2] drm/i915: rename init/fini/prune uncore functions

Quoting Daniele Ceraolo Spurio (2019-04-01 22:59:25)

Quoted 7 lines

Add "_mmio" postfix to be consistent from the init/fini phase they're called from.

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v2 1/2
#7 lore raw

Re: [PATCH v2 1/2] drm/i915: add intel_uncore_init_early

In reply to Daniele Ceraolo Spurio

Quoting Daniele Ceraolo Spurio (2019-04-01 22:59:24)

Quoted 6 lines

Encapsulate the uncore early init and be consistent with the "_early" naming.

-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

✗ Fi.CI.BAT: failure for drm/i915: initialize uncore->lock in uncore_init (rev2)

In reply to Daniele Ceraolo Spurio
== Series Details ==

== Series Details ==

Series: drm/i915: initialize uncore->lock in uncore_init (rev2)
URL : https://patchwork.freedesktop.org/series/58853/
State : failure

== Summary ==

Applying: drm/i915: initialize uncore->lock in uncore_init
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/i915_drv.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch' to see the failed patch Patch failed at 0001 drm/i915: initialize uncore->lock in uncore_init When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx