Skip to contentSkip to conversation

fix module unloading with powerplay enabled

PATCH New Alex Deucher 1 participant 4 messages May 26, 2016

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

cover fix module unloading with powerplay enabled

This patch set fixes module unloading when powerplay is enabled. The issue is a dependency between the the IH (interrupt handler) IP module and the powerplay (power management) IP modules. The IH module may call back into other IP modules to disable interrupt sources after the other modules have already been torn down. This adds a new late_fini callback to avoid freeing the necessary bits in powerplay before the IH module has finished.

Monk Liu (3):
drm/amdgpu: add late_fini for ip_funcs
drm/amdgpu: impl late_fini for amdgpu_pp_ip
drm/amdgpu: fix pplib finish bug

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c     | 24 ++++++++++++++++-------
 drivers/gpu/drm/amd/include/amd_shared.h          |  1 +
 drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c |  3 ---
 4 files changed, 23 insertions(+), 10 deletions(-)
Signature · 6 lines
2.5.5

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

PATCH 1/3 drm/amdgpu: add late_fini for ip_funcs

From: Monk Liu <[email protected]>

This give IP modules an optional late cleanup function. This is needed to handle tricky inter-module dependencies during tear down.

---
 drivers/gpu/drm/amd/include/amd_shared.h | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
index 6080951..afce1ed 100644
@@ -157,6 +157,7 @@ struct amd_ip_funcs {
 	int (*hw_init)(void *handle);
 	/* tears down the hw state */
 	int (*hw_fini)(void *handle);
+	void (*late_fini)(void *handle);
 	/* handles IP specific hw/sw changes for suspend */
 	int (*suspend)(void *handle);
 	/* handles IP specific hw/sw changes for resume */
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 2/3 drm/amdgpu: impl late_fini for amdgpu_pp_ip

In reply to Alex Deucher

From: Monk Liu <[email protected]>

This implements late_init support for powerplay.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +17 -0
index 6bd961f..1cd53c6 100644
@@ -223,6 +223,22 @@ static int amdgpu_pp_hw_fini(void *handle)
 	return ret;
 }
 
+static void amdgpu_pp_late_fini(void *handle)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+#ifdef CONFIG_DRM_AMD_POWERPLAY
+	if (adev->pp_enabled) {
+		amdgpu_pm_sysfs_fini(adev);
+		amd_powerplay_fini(adev->powerplay.pp_handle);
+	}
+
+	if (adev->powerplay.ip_funcs->late_fini)
+		adev->powerplay.ip_funcs->late_fini(
+			  adev->powerplay.pp_handle);
+#endif
+}
+
 static int amdgpu_pp_suspend(void *handle)
 {
 	int ret = 0;
@@ -311,6 +327,7 @@ const struct amd_ip_funcs amdgpu_pp_ip_funcs = {
 	.sw_fini = amdgpu_pp_sw_fini,
 	.hw_init = amdgpu_pp_hw_init,
 	.hw_fini = amdgpu_pp_hw_fini,
+	.late_fini = amdgpu_pp_late_fini,
 	.suspend = amdgpu_pp_suspend,
 	.resume = amdgpu_pp_resume,
 	.is_idle = amdgpu_pp_is_idle,
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 3/3 drm/amdgpu: fix pplib finish bug

In reply to Alex Deucher

From: Monk Liu <[email protected]>

1,should use late_fini to kfree all resource otherwise the released pointer maybe accessed in IRQ ip fini routine.

2,hwmgr should not be kfree by pem_fini which is invoked by hw fini path.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        | 5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c     | 7 -------
 drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c | 3 ---
 3 files changed, 5 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
index bb8b149..1996670 100644
@@ -1325,6 +1325,11 @@ static int amdgpu_fini(struct amdgpu_device *adev)
 		adev->ip_block_status[i].valid = false;
 	}
 
+	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
+		if (adev->ip_blocks[i].funcs->late_fini)
+			adev->ip_blocks[i].funcs->late_fini((void *)adev);
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +0 -7
index 1cd53c6..10b1be5 100644
@@ -183,13 +183,6 @@ static int amdgpu_pp_sw_fini(void *handle)
 	if (ret)
 		return ret;
 
-#ifdef CONFIG_DRM_AMD_POWERPLAY
-	if (adev->pp_enabled) {
-		amdgpu_pm_sysfs_fini(adev);
-		amd_powerplay_fini(adev->powerplay.pp_handle);
-	}
-#endif
-
 	return ret;
 }
 
drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c +0 -3
index 46410e3..fb88e4e 100644
@@ -58,9 +58,6 @@ static void pem_fini(struct pp_eventmgr *eventmgr)
 	pem_unregister_interrupts(eventmgr);
 
 	pem_handle_event(eventmgr, AMD_PP_EVENT_UNINITIALIZE, &event_data);
-
-	if (eventmgr != NULL)
-		kfree(eventmgr);
 }
 
 int eventmgr_init(struct pp_instance *handle)
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel