amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/pm: Make use of __free for cleanup
@ 2025-08-18  6:17 Lijo Lazar
  2025-08-18  7:08 ` Lazar, Lijo
  0 siblings, 1 reply; 2+ messages in thread
From: Lijo Lazar @ 2025-08-18  6:17 UTC (permalink / raw)
  To: amd-gfx; +Cc: Hawking.Zhang, Alexander.Deucher, Asad.Kamal

Use __free() for cleanup during table initialization in SMUv13.0.6

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 30 +++++++++----------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 627a8188d868..f9363edf16dc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -535,6 +535,9 @@ static int smu_v13_0_6_tables_init(struct smu_context *smu)
 {
 	struct smu_table_context *smu_table = &smu->smu_table;
 	struct smu_table *tables = smu_table->tables;
+	void *gpu_metrics_table __free(kfree) = NULL;
+	void *driver_pptable __free(kfree) = NULL;
+	void *metrics_table __free(kfree) = NULL;
 	struct amdgpu_device *adev = smu->adev;
 	int gpu_metrcs_size = METRICS_TABLE_SIZE;
 	int ret;
@@ -553,37 +556,32 @@ static int smu_v13_0_6_tables_init(struct smu_context *smu)
 		       PAGE_SIZE,
 		       AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT);
 
-	smu_table->metrics_table = kzalloc(METRICS_TABLE_SIZE, GFP_KERNEL);
-	if (!smu_table->metrics_table)
+	metrics_table = kzalloc(METRICS_TABLE_SIZE, GFP_KERNEL);
+	if (!metrics_table)
 		return -ENOMEM;
 	smu_table->metrics_time = 0;
 
 	smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v1_8);
-	smu_table->gpu_metrics_table =
+	gpu_metrics_table =
 		kzalloc(smu_table->gpu_metrics_table_size, GFP_KERNEL);
-	if (!smu_table->gpu_metrics_table) {
-		kfree(smu_table->metrics_table);
+	if (!gpu_metrics_table)
 		return -ENOMEM;
-	}
 
-	smu_table->driver_pptable =
-		kzalloc(sizeof(struct PPTable_t), GFP_KERNEL);
-	if (!smu_table->driver_pptable) {
-		kfree(smu_table->metrics_table);
-		kfree(smu_table->gpu_metrics_table);
+	driver_pptable = kzalloc(sizeof(struct PPTable_t), GFP_KERNEL);
+	if (!driver_pptable)
 		return -ENOMEM;
-	}
 
 	if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) ==
 	    IP_VERSION(13, 0, 12)) {
 		ret = smu_v13_0_12_tables_init(smu);
-		if (ret) {
-			kfree(smu_table->metrics_table);
-			kfree(smu_table->gpu_metrics_table);
+		if (ret)
 			return ret;
-		}
 	}
 
+	smu_table->gpu_metrics_table = no_free_ptr(gpu_metrics_table);
+	smu_table->metrics_table = no_free_ptr(metrics_table);
+	smu_table->driver_pptable = no_free_ptr(driver_pptable);
+
 	return 0;
 }
 
-- 
2.49.0


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

* RE: [PATCH] drm/amd/pm: Make use of __free for cleanup
  2025-08-18  6:17 [PATCH] drm/amd/pm: Make use of __free for cleanup Lijo Lazar
@ 2025-08-18  7:08 ` Lazar, Lijo
  0 siblings, 0 replies; 2+ messages in thread
From: Lazar, Lijo @ 2025-08-18  7:08 UTC (permalink / raw)
  To: Lazar, Lijo, amd-gfx@lists.freedesktop.org
  Cc: Zhang, Hawking, Deucher, Alexander, Kamal, Asad

[Public]

Please ignore this. There are a few more places; will send a v2 covering other ones as well.

Thanks,
Lijo
-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Lijo Lazar
Sent: Monday, August 18, 2025 11:47 AM
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking <Hawking.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Kamal, Asad <Asad.Kamal@amd.com>
Subject: [PATCH] drm/amd/pm: Make use of __free for cleanup

Use __free() for cleanup during table initialization in SMUv13.0.6

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 30 +++++++++----------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
index 627a8188d868..f9363edf16dc 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
@@ -535,6 +535,9 @@ static int smu_v13_0_6_tables_init(struct smu_context *smu)  {
        struct smu_table_context *smu_table = &smu->smu_table;
        struct smu_table *tables = smu_table->tables;
+       void *gpu_metrics_table __free(kfree) = NULL;
+       void *driver_pptable __free(kfree) = NULL;
+       void *metrics_table __free(kfree) = NULL;
        struct amdgpu_device *adev = smu->adev;
        int gpu_metrcs_size = METRICS_TABLE_SIZE;
        int ret;
@@ -553,37 +556,32 @@ static int smu_v13_0_6_tables_init(struct smu_context *smu)
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT);

-       smu_table->metrics_table = kzalloc(METRICS_TABLE_SIZE, GFP_KERNEL);
-       if (!smu_table->metrics_table)
+       metrics_table = kzalloc(METRICS_TABLE_SIZE, GFP_KERNEL);
+       if (!metrics_table)
                return -ENOMEM;
        smu_table->metrics_time = 0;

        smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v1_8);
-       smu_table->gpu_metrics_table =
+       gpu_metrics_table =
                kzalloc(smu_table->gpu_metrics_table_size, GFP_KERNEL);
-       if (!smu_table->gpu_metrics_table) {
-               kfree(smu_table->metrics_table);
+       if (!gpu_metrics_table)
                return -ENOMEM;
-       }

-       smu_table->driver_pptable =
-               kzalloc(sizeof(struct PPTable_t), GFP_KERNEL);
-       if (!smu_table->driver_pptable) {
-               kfree(smu_table->metrics_table);
-               kfree(smu_table->gpu_metrics_table);
+       driver_pptable = kzalloc(sizeof(struct PPTable_t), GFP_KERNEL);
+       if (!driver_pptable)
                return -ENOMEM;
-       }

        if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) ==
            IP_VERSION(13, 0, 12)) {
                ret = smu_v13_0_12_tables_init(smu);
-               if (ret) {
-                       kfree(smu_table->metrics_table);
-                       kfree(smu_table->gpu_metrics_table);
+               if (ret)
                        return ret;
-               }
        }

+       smu_table->gpu_metrics_table = no_free_ptr(gpu_metrics_table);
+       smu_table->metrics_table = no_free_ptr(metrics_table);
+       smu_table->driver_pptable = no_free_ptr(driver_pptable);
+
        return 0;
 }

--
2.49.0


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

end of thread, other threads:[~2025-08-18  7:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18  6:17 [PATCH] drm/amd/pm: Make use of __free for cleanup Lijo Lazar
2025-08-18  7:08 ` Lazar, Lijo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).