Skip to contentSkip to conversation

drm/amdgpu: fix GTT manager warning message

PATCH In review Karl Mehltretter 2 participants 2 messages Aug 8 – Aug 10

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

PATCH 1/1 drm/amdgpu: fix GTT manager warning message

WARN_ON_ONCE() takes a condition, not a message. The string literal is always true, so the warning still triggers but the message is never printed.

Use WARN_ONCE(1, ...) instead to print the message and keep the once-only behavior.

Found with a Coccinelle script. Clang's -Wstring-conversion also flags such calls but is not enabled in kernel builds.

Fixes 7554886daa31 ("drm/amdgpu: Fix size validation for non-exclusive domains (v4)")
Assisted-by Claude:claude-fable-5 coccinelle
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
index f98bfba59a2c..f2ea881d39e3 100644
@@ -565,7 +565,8 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
 
 	if (!man) {
 		if (domain & AMDGPU_GEM_DOMAIN_GTT)
-			WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
+			WARN_ONCE(1,
+				  "GTT domain requested but GTT mem manager uninitialized");
 		return false;
 	}
 
Signature · 1 line
2.39.5 (Apple Git-154)
maintainer
#1 lore raw
Quoted 24 lines · Karl Mehltretter

[Sie erhalten nicht häufig E-Mails von [email protected]. Weitere Informationen, warum dies wichtig ist, finden Sie unter https://aka.ms/LearnAboutSenderIdentification ]

WARN_ON_ONCE() takes a condition, not a message. The string literal is always true, so the warning still triggers but the message is never printed.

Use WARN_ONCE(1, ...) instead to print the message and keep the once-only behavior.

Found with a Coccinelle script. Clang's -Wstring-conversion also flags such calls but is not enabled in kernel builds.

Fixes 7554886daa31 ("drm/amdgpu: Fix size validation for non-exclusive domains (v4)")
Assisted-by Claude:claude-fable-5 coccinelle
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index f98bfba59a2c..f2ea881d39e3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, · line 569

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
@@ -565,7 +565,8 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,
 
        if (!man) {
                if (domain & AMDGPU_GEM_DOMAIN_GTT)
-                       WARN_ON_ONCE("GTT domain requested but GTT mem manager uninitialized");
+                       WARN_ONCE(1,
+                                 "GTT domain requested but GTT mem manager uninitialized");

As far as I can see that warning is completely superfluous to begin with.

GTT is mandatory to load the FW so we can't enter this without any GTT manager.

Regards,
Christian.

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -1
                return false;
        }
 
--

2.39.5 (Apple Git-154)