All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] fix module unloading with powerplay enabled
@ 2016-05-26 22:00 Alex Deucher
  2016-05-26 22:00 ` [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs Alex Deucher
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alex Deucher @ 2016-05-26 22:00 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

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(-)

-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs
  2016-05-26 22:00 [PATCH 0/3] fix module unloading with powerplay enabled Alex Deucher
@ 2016-05-26 22:00 ` Alex Deucher
  2016-05-26 22:00 ` [PATCH 2/3] drm/amdgpu: impl late_fini for amdgpu_pp_ip Alex Deucher
  2016-05-26 22:00 ` [PATCH 3/3] drm/amdgpu: fix pplib finish bug Alex Deucher
  2 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2016-05-26 22:00 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

From: Monk Liu <Monk.Liu@amd.com>

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

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/include/amd_shared.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 6080951..afce1ed 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -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 */
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] drm/amdgpu: impl late_fini for amdgpu_pp_ip
  2016-05-26 22:00 [PATCH 0/3] fix module unloading with powerplay enabled Alex Deucher
  2016-05-26 22:00 ` [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs Alex Deucher
@ 2016-05-26 22:00 ` Alex Deucher
  2016-05-26 22:00 ` [PATCH 3/3] drm/amdgpu: fix pplib finish bug Alex Deucher
  2 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2016-05-26 22:00 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

From: Monk Liu <Monk.Liu@amd.com>

This implements late_init support for powerplay.

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index 6bd961f..1cd53c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -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,
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] drm/amdgpu: fix pplib finish bug
  2016-05-26 22:00 [PATCH 0/3] fix module unloading with powerplay enabled Alex Deucher
  2016-05-26 22:00 ` [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs Alex Deucher
  2016-05-26 22:00 ` [PATCH 2/3] drm/amdgpu: impl late_fini for amdgpu_pp_ip Alex Deucher
@ 2016-05-26 22:00 ` Alex Deucher
  2 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2016-05-26 22:00 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

From: Monk Liu <Monk.Liu@amd.com>

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.

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index bb8b149..1996670 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
index 1cd53c6..10b1be5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
@@ -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;
 }
 
diff --git a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c b/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c
index 46410e3..fb88e4e 100644
--- a/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c
@@ -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)
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs
  2016-06-01 21:17 [PATCH 0/3] fix module unloading with powerplay enabled Alex Deucher
@ 2016-06-01 21:17 ` Alex Deucher
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2016-06-01 21:17 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

From: Monk Liu <Monk.Liu@amd.com>

This adds a late_fini function for handling special
ordering issues between ip modules at tear down time.

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/include/amd_shared.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 147b2eb..afbd876 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -159,6 +159,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 */
-- 
2.5.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-01 21:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-26 22:00 [PATCH 0/3] fix module unloading with powerplay enabled Alex Deucher
2016-05-26 22:00 ` [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs Alex Deucher
2016-05-26 22:00 ` [PATCH 2/3] drm/amdgpu: impl late_fini for amdgpu_pp_ip Alex Deucher
2016-05-26 22:00 ` [PATCH 3/3] drm/amdgpu: fix pplib finish bug Alex Deucher
2016-06-01 21:17 [PATCH 0/3] fix module unloading with powerplay enabled Alex Deucher
2016-06-01 21:17 ` [PATCH 1/3] drm/amdgpu: add late_fini for ip_funcs Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.