Skip to contentSkip to conversation

drm/amdgpu/pm: Remove gpu_od if it's an empty directory

PATCH In review Ma Jun 4 participants 4 messages Apr 17, 2024 – Apr 18, 2024

Subsystems (3)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH 1/1 drm/amdgpu/pm: Remove gpu_od if it's an empty directory

gpu_od should be removed if it's an empty directory

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +7 -0
index a20e03e69d38..0c13e5520e77 100644
@@ -4338,6 +4338,13 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev)
 		}
 	}
 
+	/*
+	 * If gpu_od is the first member in the list, that means gpu_od is an
+	 * empty directory, so remove it.
+	 */
+	if (list_is_first(&top_set->entry, &adev->pm.od_kobj_list))
+		goto err_out;
+
 	return 0;
 
 err_out:
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Best Regards,
Kevin

-----Original Message-----
From: Ma, Jun <[email protected]>
Sent: 2024年4月17日 13:54
To: [email protected]
Cc: Feng, Kenneth <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Lazar, Lijo <[email protected]>; Ma, Jun <[email protected]>
Subject: [PATCH] drm/amdgpu/pm: Remove gpu_od if it's an empty directory

gpu_od should be removed if it's an empty directory

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +7 -0
index a20e03e69d38..0c13e5520e77 100644
@@ -4338,6 +4338,13 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev)
 		}
 	}
 
+	/*
+	 * If gpu_od is the first member in the list, that means gpu_od is an
+	 * empty directory, so remove it.
+	 */
+	if (list_is_first(&top_set->entry, &adev->pm.od_kobj_list))
+		goto err_out;
+
 	return 0;
 
 err_out:
Signature · 1 line
2.34.1
#2 lore raw
In reply to Ma Jun
Quoted 13 lines · Ma Jun

gpu_od should be removed if it's an empty directory

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
index a20e03e69d38..0c13e5520e77 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int amdgpu_od_set_init(struct amdgpu_device *adev) · line 4345

Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +5 -0
@@ -4338,6 +4338,13 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev)
 		}
 	}
 
+	/*
+	 * If gpu_od is the first member in the list, that means gpu_od is an
+	 * empty directory, so remove it.
+	 */
+	if (list_is_first(&top_set->entry, &adev->pm.od_kobj_list))

Instead of assuming any order, what about using "list_is_singular" - if this is the only entry in the list?

Thanks,
Lijo

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -0
+		goto err_out;
+
 	return 0;
 
 err_out:
#3 lore raw
Quoted 19 lines · Lijo
Quoted 16 lines · Ma Jun

gpu_od should be removed if it's an empty directory

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
index a20e03e69d38..0c13e5520e77 100644
@@ -4338,6 +4338,13 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev)
 		}
 	}
 
Quoted 9 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int amdgpu_od_set_init(struct amdgpu_device *adev) · line 4345

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +5 -0
+	/*
+	 * If gpu_od is the first member in the list, that means gpu_od is an
+	 * empty directory, so remove it.
+	 */
+	if (list_is_first(&top_set->entry, &adev->pm.od_kobj_list))

Instead of assuming any order, what about using "list_is_singular" - if this is the only entry in the list?

Thanks, will update it when push.

Regards,
Ma Jun

Quoted 7 lines

Thanks,
Lijo

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -0
+		goto err_out;
+
 	return 0;
 
 err_out: