dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] Fix memory and firmware leaks
@ 2016-06-02 14:39 Alex Deucher
  2016-06-02 14:39 ` [PATCH 01/13] drm/amdgpu: fix mem leak in smumgr Alex Deucher
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher

This patch set fixes several memory leaks and cases where
we forgot to release the firmware.

Monk Liu (13):
  drm/amdgpu: fix mem leak in smumgr
  drm/amdgpu: fix mem leak in pplib/hwmgr
  drm/amdgpu: fix mem leak in atombios
  drm/amdgpu: fix memleak in pptable_init
  drm/amdgpu: fix missing free wb for cond_exec
  drm/amdgpu: fix gfx8 ucode mem leak
  drm/amdgpu: fix gfx 7 ucode mem leak
  drm/amdgpu: fix uvd fini mem leak
  drm/amdgpu: fix sdma3 ucode mem leak
  drm/amdgpu: fix sdma24 ucode mem leak
  drm/amdgpu: fix cik sdma ucode memleak
  drm/amdgpu: fix fiji smu fini mem leak
  drm/amdgpu: fix tonga smu_fini mem leak

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         |  4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            | 19 ++++----
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c              | 11 +++++
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c              | 17 +++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              | 22 ++++++++-
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c             | 10 ++++
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c             | 10 ++++
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      |  8 +++-
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c        |  7 +++
 .../amd/powerplay/hwmgr/tonga_processpptables.c    | 54 ++++++++++------------
 drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c |  4 ++
 drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c      |  1 +
 .../gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c    |  5 ++
 14 files changed, 132 insertions(+), 41 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] 14+ messages in thread

* [PATCH 01/13] drm/amdgpu: fix mem leak in smumgr
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 02/13] drm/amdgpu: fix mem leak in pplib/hwmgr Alex Deucher
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

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

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index c483baf..0728c1e3 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -81,6 +81,7 @@ int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle)
 
 int smum_fini(struct pp_smumgr *smumgr)
 {
+	kfree(smumgr->device);
 	kfree(smumgr);
 	return 0;
 }
-- 
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] 14+ messages in thread

* [PATCH 02/13] drm/amdgpu: fix mem leak in pplib/hwmgr
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
  2016-06-02 14:39 ` [PATCH 01/13] drm/amdgpu: fix mem leak in smumgr Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 03/13] drm/amdgpu: fix mem leak in atombios Alex Deucher
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

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

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 1c48917..910d56d 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -93,6 +93,13 @@ int hwmgr_fini(struct pp_hwmgr *hwmgr)
 	if (hwmgr == NULL || hwmgr->ps == NULL)
 		return -EINVAL;
 
+	/* do hwmgr finish*/
+	kfree(hwmgr->backend);
+
+	kfree(hwmgr->start_thermal_controller.function_list);
+
+	kfree(hwmgr->set_temperature_range.function_list);
+
 	kfree(hwmgr->ps);
 	kfree(hwmgr);
 	return 0;
-- 
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] 14+ messages in thread

* [PATCH 03/13] drm/amdgpu: fix mem leak in atombios
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
  2016-06-02 14:39 ` [PATCH 01/13] drm/amdgpu: fix mem leak in smumgr Alex Deucher
  2016-06-02 14:39 ` [PATCH 02/13] drm/amdgpu: fix mem leak in pplib/hwmgr Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 04/13] drm/amdgpu: fix memleak in pptable_init Alex Deucher
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 1727a4d..964f314 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -827,8 +827,10 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)
  */
 static void amdgpu_atombios_fini(struct amdgpu_device *adev)
 {
-	if (adev->mode_info.atom_context)
+	if (adev->mode_info.atom_context) {
 		kfree(adev->mode_info.atom_context->scratch);
+		kfree(adev->mode_info.atom_context->iio);
+	}
 	kfree(adev->mode_info.atom_context);
 	adev->mode_info.atom_context = NULL;
 	kfree(adev->mode_info.atom_card_info);
-- 
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] 14+ messages in thread

* [PATCH 04/13] drm/amdgpu: fix memleak in pptable_init
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (2 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 03/13] drm/amdgpu: fix mem leak in atombios Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 05/13] drm/amdgpu: fix missing free wb for cond_exec Alex Deucher
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      |  8 +++-
 .../amd/powerplay/hwmgr/tonga_processpptables.c    | 54 ++++++++++------------
 2 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 8e345bf..e629f8a 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -73,11 +73,14 @@ static int pp_sw_init(void *handle)
 
 	ret = hwmgr->hwmgr_func->backend_init(hwmgr);
 	if (ret)
-		goto err;
+		goto err1;
 
 	pr_info("amdgpu: powerplay initialized\n");
 
 	return 0;
+err1:
+	if (hwmgr->pptable_func->pptable_fini)
+		hwmgr->pptable_func->pptable_fini(hwmgr);
 err:
 	pr_err("amdgpu: powerplay initialization failed\n");
 	return ret;
@@ -100,6 +103,9 @@ static int pp_sw_fini(void *handle)
 	if (hwmgr->hwmgr_func->backend_fini != NULL)
 		ret = hwmgr->hwmgr_func->backend_fini(hwmgr);
 
+	if (hwmgr->pptable_func->pptable_fini)
+		hwmgr->pptable_func->pptable_fini(hwmgr);
+
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
index 10e3630..296ec7e 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
@@ -1040,48 +1040,44 @@ int tonga_pp_tables_uninitialize(struct pp_hwmgr *hwmgr)
 	struct phm_ppt_v1_information *pp_table_information =
 		(struct phm_ppt_v1_information *)(hwmgr->pptable);
 
-	if (NULL != hwmgr->soft_pp_table) {
-		kfree(hwmgr->soft_pp_table);
+	if (NULL != hwmgr->soft_pp_table)
 		hwmgr->soft_pp_table = NULL;
-	}
 
-	if (NULL != pp_table_information->vdd_dep_on_sclk)
-		pp_table_information->vdd_dep_on_sclk = NULL;
+	kfree(pp_table_information->vdd_dep_on_sclk);
+	pp_table_information->vdd_dep_on_sclk = NULL;
 
-	if (NULL != pp_table_information->vdd_dep_on_mclk)
-		pp_table_information->vdd_dep_on_mclk = NULL;
+	kfree(pp_table_information->vdd_dep_on_mclk);
+	pp_table_information->vdd_dep_on_mclk = NULL;
 
-	if (NULL != pp_table_information->valid_mclk_values)
-		pp_table_information->valid_mclk_values = NULL;
+	kfree(pp_table_information->valid_mclk_values);
+	pp_table_information->valid_mclk_values = NULL;
 
-	if (NULL != pp_table_information->valid_sclk_values)
-		pp_table_information->valid_sclk_values = NULL;
+	kfree(pp_table_information->valid_sclk_values);
+	pp_table_information->valid_sclk_values = NULL;
 
-	if (NULL != pp_table_information->vddc_lookup_table)
-		pp_table_information->vddc_lookup_table = NULL;
+	kfree(pp_table_information->vddc_lookup_table);
+	pp_table_information->vddc_lookup_table = NULL;
 
-	if (NULL != pp_table_information->vddgfx_lookup_table)
-		pp_table_information->vddgfx_lookup_table = NULL;
+	kfree(pp_table_information->vddgfx_lookup_table);
+	pp_table_information->vddgfx_lookup_table = NULL;
 
-	if (NULL != pp_table_information->mm_dep_table)
-		pp_table_information->mm_dep_table = NULL;
+	kfree(pp_table_information->mm_dep_table);
+	pp_table_information->mm_dep_table = NULL;
 
-	if (NULL != pp_table_information->cac_dtp_table)
-		pp_table_information->cac_dtp_table = NULL;
+	kfree(pp_table_information->cac_dtp_table);
+	pp_table_information->cac_dtp_table = NULL;
 
-	if (NULL != hwmgr->dyn_state.cac_dtp_table)
-		hwmgr->dyn_state.cac_dtp_table = NULL;
+	kfree(hwmgr->dyn_state.cac_dtp_table);
+	hwmgr->dyn_state.cac_dtp_table = NULL;
 
-	if (NULL != pp_table_information->ppm_parameter_table)
-		pp_table_information->ppm_parameter_table = NULL;
+	kfree(pp_table_information->ppm_parameter_table);
+	pp_table_information->ppm_parameter_table = NULL;
 
-	if (NULL != pp_table_information->pcie_table)
-		pp_table_information->pcie_table = NULL;
+	kfree(pp_table_information->pcie_table);
+	pp_table_information->pcie_table = NULL;
 
-	if (NULL != hwmgr->pptable) {
-		kfree(hwmgr->pptable);
-		hwmgr->pptable = NULL;
-	}
+	kfree(hwmgr->pptable);
+	hwmgr->pptable = NULL;
 
 	return result;
 }
-- 
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] 14+ messages in thread

* [PATCH 05/13] drm/amdgpu: fix missing free wb for cond_exec
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (3 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 04/13] drm/amdgpu: fix memleak in pptable_init Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 06/13] drm/amdgpu: fix gfx8 ucode mem leak Alex Deucher
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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_ring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index a4b3f44..dc8a7bb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -346,6 +346,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)
 	ring->ring = NULL;
 	ring->ring_obj = NULL;
 
+	amdgpu_wb_free(ring->adev, ring->cond_exe_offs);
 	amdgpu_wb_free(ring->adev, ring->fence_offs);
 	amdgpu_wb_free(ring->adev, ring->rptr_offs);
 	amdgpu_wb_free(ring->adev, ring->wptr_offs);
-- 
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] 14+ messages in thread

* [PATCH 06/13] drm/amdgpu: fix gfx8 ucode mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (4 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 05/13] drm/amdgpu: fix missing free wb for cond_exec Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 07/13] drm/amdgpu: fix gfx 7 " Alex Deucher
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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/gfx_v8_0.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 4d747ba..9f6f866 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -836,6 +836,26 @@ err1:
 	return r;
 }
 
+
+static void gfx_v8_0_free_microcode(struct amdgpu_device *adev) {
+	release_firmware(adev->gfx.pfp_fw);
+	adev->gfx.pfp_fw = NULL;
+	release_firmware(adev->gfx.me_fw);
+	adev->gfx.me_fw = NULL;
+	release_firmware(adev->gfx.ce_fw);
+	adev->gfx.ce_fw = NULL;
+	release_firmware(adev->gfx.rlc_fw);
+	adev->gfx.rlc_fw = NULL;
+	release_firmware(adev->gfx.mec_fw);
+	adev->gfx.mec_fw = NULL;
+	if ((adev->asic_type != CHIP_STONEY) &&
+	    (adev->asic_type != CHIP_TOPAZ))
+		release_firmware(adev->gfx.mec2_fw);
+	adev->gfx.mec2_fw = NULL;
+
+	kfree(adev->gfx.rlc.register_list_format);
+}
+
 static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)
 {
 	const char *chip_name;
@@ -1983,7 +2003,7 @@ static int gfx_v8_0_sw_fini(void *handle)
 
 	gfx_v8_0_rlc_fini(adev);
 
-	kfree(adev->gfx.rlc.register_list_format);
+	gfx_v8_0_free_microcode(adev);
 
 	return 0;
 }
-- 
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] 14+ messages in thread

* [PATCH 07/13] drm/amdgpu: fix gfx 7 ucode mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (5 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 06/13] drm/amdgpu: fix gfx8 ucode mem leak Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 08/13] drm/amdgpu: fix uvd fini " Alex Deucher
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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/gfx_v7_0.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index 7f18a53..8c6ad1e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -991,6 +991,22 @@ out:
 	return err;
 }
 
+static void gfx_v7_0_free_microcode(struct amdgpu_device *adev)
+{
+	release_firmware(adev->gfx.pfp_fw);
+	adev->gfx.pfp_fw = NULL;
+	release_firmware(adev->gfx.me_fw);
+	adev->gfx.me_fw = NULL;
+	release_firmware(adev->gfx.ce_fw);
+	adev->gfx.ce_fw = NULL;
+	release_firmware(adev->gfx.mec_fw);
+	adev->gfx.mec_fw = NULL;
+	release_firmware(adev->gfx.mec2_fw);
+	adev->gfx.mec2_fw = NULL;
+	release_firmware(adev->gfx.rlc_fw);
+	adev->gfx.rlc_fw = NULL;
+}
+
 /**
  * gfx_v7_0_tiling_mode_table_init - init the hw tiling table
  *
@@ -4489,6 +4505,7 @@ static int gfx_v7_0_sw_fini(void *handle)
 	gfx_v7_0_cp_compute_fini(adev);
 	gfx_v7_0_rlc_fini(adev);
 	gfx_v7_0_mec_fini(adev);
+	gfx_v7_0_free_microcode(adev);
 
 	return 0;
 }
-- 
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] 14+ messages in thread

* [PATCH 08/13] drm/amdgpu: fix uvd fini mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (6 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 07/13] drm/amdgpu: fix gfx 7 " Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 09/13] drm/amdgpu: fix sdma3 ucode " Alex Deucher
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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_uvd.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 01abfc2..e19520c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -253,19 +253,20 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)
 {
 	int r;
 
-	if (adev->uvd.vcpu_bo == NULL)
-		return 0;
+	kfree(adev->uvd.saved_bo);
 
 	amd_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity);
 
-	r = amdgpu_bo_reserve(adev->uvd.vcpu_bo, false);
-	if (!r) {
-		amdgpu_bo_kunmap(adev->uvd.vcpu_bo);
-		amdgpu_bo_unpin(adev->uvd.vcpu_bo);
-		amdgpu_bo_unreserve(adev->uvd.vcpu_bo);
-	}
+	if (adev->uvd.vcpu_bo) {
+		r = amdgpu_bo_reserve(adev->uvd.vcpu_bo, false);
+		if (!r) {
+			amdgpu_bo_kunmap(adev->uvd.vcpu_bo);
+			amdgpu_bo_unpin(adev->uvd.vcpu_bo);
+			amdgpu_bo_unreserve(adev->uvd.vcpu_bo);
+		}
 
-	amdgpu_bo_unref(&adev->uvd.vcpu_bo);
+		amdgpu_bo_unref(&adev->uvd.vcpu_bo);
+	}
 
 	amdgpu_ring_fini(&adev->uvd.ring);
 
-- 
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] 14+ messages in thread

* [PATCH 09/13] drm/amdgpu: fix sdma3 ucode mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (7 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 08/13] drm/amdgpu: fix uvd fini " Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 10/13] drm/amdgpu: fix sdma24 " Alex Deucher
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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/sdma_v3_0.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index 33605d4..532ea88 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -236,6 +236,15 @@ static void sdma_v3_0_init_golden_registers(struct amdgpu_device *adev)
 	}
 }
 
+static void sdma_v3_0_free_microcode(struct amdgpu_device *adev)
+{
+	int i;
+	for (i = 0; i < adev->sdma.num_instances; i++) {
+		release_firmware(adev->sdma.instance[i].fw);
+		adev->sdma.instance[i].fw = NULL;
+	}
+}
+
 /**
  * sdma_v3_0_init_microcode - load ucode images from disk
  *
@@ -1256,6 +1265,7 @@ static int sdma_v3_0_sw_fini(void *handle)
 	for (i = 0; i < adev->sdma.num_instances; i++)
 		amdgpu_ring_fini(&adev->sdma.instance[i].ring);
 
+	sdma_v3_0_free_microcode(adev);
 	return 0;
 }
 
-- 
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] 14+ messages in thread

* [PATCH 10/13] drm/amdgpu: fix sdma24 ucode mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (8 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 09/13] drm/amdgpu: fix sdma3 ucode " Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 11/13] drm/amdgpu: fix cik sdma ucode memleak Alex Deucher
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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/sdma_v2_4.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
index f6014b0..b556bd0 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
@@ -105,6 +105,15 @@ static void sdma_v2_4_init_golden_registers(struct amdgpu_device *adev)
 	}
 }
 
+static void sdma_v2_4_free_microcode(struct amdgpu_device *adev)
+{
+	int i;
+	for (i = 0; i < adev->sdma.num_instances; i++) {
+		release_firmware(adev->sdma.instance[i].fw);
+		adev->sdma.instance[i].fw = NULL;
+	}
+}
+
 /**
  * sdma_v2_4_init_microcode - load ucode images from disk
  *
@@ -1018,6 +1027,7 @@ static int sdma_v2_4_sw_fini(void *handle)
 	for (i = 0; i < adev->sdma.num_instances; i++)
 		amdgpu_ring_fini(&adev->sdma.instance[i].ring);
 
+	sdma_v2_4_free_microcode(adev);
 	return 0;
 }
 
-- 
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] 14+ messages in thread

* [PATCH 11/13] drm/amdgpu: fix cik sdma ucode memleak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (9 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 10/13] drm/amdgpu: fix sdma24 " Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 12/13] drm/amdgpu: fix fiji smu fini mem leak Alex Deucher
  2016-06-02 14:39 ` [PATCH 13/13] drm/amdgpu: fix tonga smu_fini " Alex Deucher
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

Signed-off-by: Monk Liu <Monk.Liu@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/cik_sdma.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 0079916..9dc4e24 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -66,6 +66,16 @@ MODULE_FIRMWARE("radeon/mullins_sdma1.bin");
 
 u32 amdgpu_cik_gpu_check_soft_reset(struct amdgpu_device *adev);
 
+
+static void cik_sdma_free_microcode(struct amdgpu_device *adev)
+{
+	int i;
+	for (i = 0; i < adev->sdma.num_instances; i++) {
+			release_firmware(adev->sdma.instance[i].fw);
+			adev->sdma.instance[i].fw = NULL;
+	}
+}
+
 /*
  * sDMA - System DMA
  * Starting with CIK, the GPU has new asynchronous
@@ -1005,6 +1015,7 @@ static int cik_sdma_sw_fini(void *handle)
 	for (i = 0; i < adev->sdma.num_instances; i++)
 		amdgpu_ring_fini(&adev->sdma.instance[i].ring);
 
+	cik_sdma_free_microcode(adev);
 	return 0;
 }
 
-- 
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] 14+ messages in thread

* [PATCH 12/13] drm/amdgpu: fix fiji smu fini mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (10 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 11/13] drm/amdgpu: fix cik sdma ucode memleak Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  2016-06-02 14:39 ` [PATCH 13/13] drm/amdgpu: fix tonga smu_fini " Alex Deucher
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

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

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
index 673a75c..0ac8642 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
@@ -1006,6 +1006,10 @@ static int fiji_smu_init(struct pp_smumgr *smumgr)
 
 static int fiji_smu_fini(struct pp_smumgr *smumgr)
 {
+	struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend);
+
+	smu_free_memory(smumgr->device, (void *)priv->header_buffer.handle);
+
 	if (smumgr->backend) {
 		kfree(smumgr->backend);
 		smumgr->backend = NULL;
-- 
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] 14+ messages in thread

* [PATCH 13/13] drm/amdgpu: fix tonga smu_fini mem leak
  2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
                   ` (11 preceding siblings ...)
  2016-06-02 14:39 ` [PATCH 12/13] drm/amdgpu: fix fiji smu fini mem leak Alex Deucher
@ 2016-06-02 14:39 ` Alex Deucher
  12 siblings, 0 replies; 14+ messages in thread
From: Alex Deucher @ 2016-06-02 14:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, Monk Liu

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

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

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
index 32820b6..70d3ecf 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
@@ -328,6 +328,11 @@ int tonga_write_smc_sram_dword(struct pp_smumgr *smumgr,
 
 static int tonga_smu_fini(struct pp_smumgr *smumgr)
 {
+	struct tonga_smumgr *priv = (struct tonga_smumgr *)(smumgr->backend);
+
+	smu_free_memory(smumgr->device, (void *)priv->smu_buffer.handle);
+	smu_free_memory(smumgr->device, (void *)priv->header_buffer.handle);
+
 	if (smumgr->backend != NULL) {
 		kfree(smumgr->backend);
 		smumgr->backend = NULL;
-- 
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] 14+ messages in thread

end of thread, other threads:[~2016-06-02 14:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02 14:39 [PATCH 00/13] Fix memory and firmware leaks Alex Deucher
2016-06-02 14:39 ` [PATCH 01/13] drm/amdgpu: fix mem leak in smumgr Alex Deucher
2016-06-02 14:39 ` [PATCH 02/13] drm/amdgpu: fix mem leak in pplib/hwmgr Alex Deucher
2016-06-02 14:39 ` [PATCH 03/13] drm/amdgpu: fix mem leak in atombios Alex Deucher
2016-06-02 14:39 ` [PATCH 04/13] drm/amdgpu: fix memleak in pptable_init Alex Deucher
2016-06-02 14:39 ` [PATCH 05/13] drm/amdgpu: fix missing free wb for cond_exec Alex Deucher
2016-06-02 14:39 ` [PATCH 06/13] drm/amdgpu: fix gfx8 ucode mem leak Alex Deucher
2016-06-02 14:39 ` [PATCH 07/13] drm/amdgpu: fix gfx 7 " Alex Deucher
2016-06-02 14:39 ` [PATCH 08/13] drm/amdgpu: fix uvd fini " Alex Deucher
2016-06-02 14:39 ` [PATCH 09/13] drm/amdgpu: fix sdma3 ucode " Alex Deucher
2016-06-02 14:39 ` [PATCH 10/13] drm/amdgpu: fix sdma24 " Alex Deucher
2016-06-02 14:39 ` [PATCH 11/13] drm/amdgpu: fix cik sdma ucode memleak Alex Deucher
2016-06-02 14:39 ` [PATCH 12/13] drm/amdgpu: fix fiji smu fini mem leak Alex Deucher
2016-06-02 14:39 ` [PATCH 13/13] drm/amdgpu: fix tonga smu_fini " Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox