drm/panthor: fix building without CONFIG_DEBUG_FS
Subsystems (3)
PATCH 1/1 drm/panthor: fix building without CONFIG_DEBUG_FS
From: Arnd Bergmann <[email protected]>
When debugfs is disabled, including panthor_gem.h causes warnings about a non-static global function defined in a header:
In file included from drivers/gpu/drm/panthor/panthor_drv.c:30:drivers/gpu/drm/panthor/panthor_gem.h:222:6: error: no previous prototype for 'panthor_gem_debugfs_set_usage_flags' [-Werror=missing-prototypes]
222 | void panthor_gem_debugfs_set_usage_flags(struct panthor_gem_object *bo, u32 usage_flags) {};
This could be changed to a static inline function, but as the normal one is also static inline, just move the #ifdef check in there. The #ifdef is still needed to avoid accessing a struct member that does not exist without debugfs.
--- drivers/gpu/drm/panthor/panthor_gem.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/panthor/panthor_gem.h +2 -5
@@ -209,17 +209,14 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,void panthor_kernel_bo_destroy (struct panthor_kernel_bo *bo); -#ifdef CONFIG_DEBUG_FS void panthor_gem_debugfs_print_bos (struct panthor_device *pfdev,struct seq_file *m);static inline void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) { +#ifdef CONFIG_DEBUG_FS bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; -} - -#else -void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) {};#endif +}#endif /* __PANTHOR_GEM_H__ */
Signature · 1 line
2.39.5
Boris Brezillon
maintainerQuoted 33 lines · On Thu, 24 Apr 2025 13:25:47 +0200 Arnd Bergmann <[email protected]> wrote:
From: Arnd Bergmann <[email protected]>
When debugfs is disabled, including
panthor_gem.hcauses warnings about a non-static global function defined in a header:In file included from
drivers/gpu/drm/panthor/panthor_drv.c:30:drivers/gpu/drm/panthor/panthor_gem.h:222:6: error: no previous prototype for 'panthor_gem_debugfs_set_usage_flags' [-Werror=missing-prototypes]
222 | voidpanthor_gem_debugfs_set_usage_flags(struct panthor_gem_object *bo, u32 usage_flags){};This could be changed to a static inline function, but as the normal one is also static inline, just move the #ifdef check in there. The #ifdef is still needed to avoid accessing a struct member that does not exist without debugfs.
Fixes a3707f53eb3f ("drm/panthor: show device-wide list of DRM GEM objects over DebugFS")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/drm/panthor/panthor_gem.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/panthor/panthor_gem.h +0
-1@@ -209,17 +209,14 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,void panthor_kernel_bo_destroy (struct panthor_kernel_bo *bo); -#ifdef CONFIG_DEBUG_FS void panthor_gem_debugfs_print_bos (struct panthor_device *pfdev,struct seq_file *m);static inline void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags)
drivers/gpu/drm/panthor/panthor_gem.h panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm, · line 221
Quoted 10 lines
drivers/gpu/drm/panthor/panthor_gem.h +2
-4{ +#ifdef CONFIG_DEBUG_FS bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; -} - -#else -void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) {};#endif +}
Oops. I actually don't see a good reason to expose this function, so could we go for something like that instead?
drivers/gpu/drm/panthor/panthor_gem.c +9 -0
@@ -42,11 +42,20 @@ static void panthor_gem_debugfs_bo_rm(struct panthor_gem_object *bo) mutex_unlock(&ptdev->gems.lock); } +static void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo, +u32 usage_flags) +{ + bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; +}#else static void panthor_gem_debugfs_bo_add (struct panthor_device *ptdev,struct panthor_gem_object *bo) {}static void panthor_gem_debugfs_bo_rm (struct panthor_gem_object *bo) {} +static void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo, +u32 usage_flags) +{ +}#endif static void panthor_gem_free_object (struct drm_gem_object *obj)
drivers/gpu/drm/panthor/panthor_gem.h +0 -8
@@ -212,14 +212,6 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo);#ifdef CONFIG_DEBUG_FS void panthor_gem_debugfs_print_bos (struct panthor_device *pfdev,struct seq_file *m); -static inline void -panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) -{ - bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; -} - -#else -void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) {};#endif #endif /* __PANTHOR_GEM_H__ */
Quoted 13 lines · Boris Brezillon
On Thu, 24 Apr 2025 13:25:47 +0200
drivers/gpu/drm/panthor/panthor_gem.h void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo);
Quoted 9 lines
drivers/gpu/drm/panthor/panthor_gem.h +2
-4+#ifdef CONFIG_DEBUG_FS bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; -} - -#else -void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) {};#endif +}Oops. I actually don't see a good reason to expose this function, so could we go for something like that instead?
I think moving it into pantor_gem.c makes sense, and it certainly avoids the build warning.
Review
Quoted 9 lines
#else
static void panthor_gem_debugfs_bo_add(structpanthor_device*ptdev,
structpanthor_gem_object*bo)
{}
static voidpanthor_gem_debugfs_bo_rm(struct panthor_gem_object *bo){}
+static void panthor_gem_debugfs_set_usage_flags(structpanthor_gem_object*bo,(quoted diff) +2
-0+ u32 usage_flags) +{
Side note: I think the panthor_gem_debugfs_bo_{add,rm} stubs could actually be replaced with an IS_ENABLED() check in the normal functions, but that wouldn't work for panthor_gem_debugfs_set_usage_flags or panthor_gem_debugfs_print_bos().
Arnd
Boris Brezillon
maintainerQuoted 18 lines · On Thu, 24 Apr 2025 14:10:16 +0200 "Arnd Bergmann" <[email protected]> wrote:
Quoted 13 lines · Boris Brezillon
On Thu, 24 Apr 2025 13:25:47 +0200
drivers/gpu/drm/panthor/panthor_gem.h void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo);
Quoted 9 lines
drivers/gpu/drm/panthor/panthor_gem.h +2
-4+#ifdef CONFIG_DEBUG_FS bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; -} - -#else -void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) {};#endif +}Oops. I actually don't see a good reason to expose this function, so could we go for something like that instead?
I think moving it into
pantor_gem.cmakes sense, and it certainly avoids the build warning.
Quoted 15 lines
Review
Quoted 9 lines
#else
static void panthor_gem_debugfs_bo_add(structpanthor_device*ptdev,
structpanthor_gem_object*bo)
{}
static voidpanthor_gem_debugfs_bo_rm(struct panthor_gem_object *bo){}
+static void panthor_gem_debugfs_set_usage_flags(structpanthor_gem_object*bo,(quoted diff) +2
-0+ u32 usage_flags) +{Side note: I think the panthor_gem_debugfs_bo_{add,rm} stubs could actually be replaced with an
IS_ENABLED()check in the normal functions, but that wouldn't work forpanthor_gem_debugfs_set_usage_flagsorpanthor_gem_debugfs_print_bos().
Yeah, I think I prefer consistency over saving a few LoC ;-). Do you plan to send a v2 with the suggested changes, or should we take care of that?
Hi Arnd,
Thanks for the fix. I've already submitted a second attempt because I thought the build being broken is something we ought to deal with ASAP. I've added you as a bug reporter and also made mention of this thread in the new patch.
Kind Regards,
Adrian
Quoted 46 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When debugfs is disabled, including
panthor_gem.hcauses warnings about a non-static global function defined in a header:In file included from
drivers/gpu/drm/panthor/panthor_drv.c:30:drivers/gpu/drm/panthor/panthor_gem.h:222:6: error: no previous prototype for 'panthor_gem_debugfs_set_usage_flags' [-Werror=missing-prototypes]
222 | voidpanthor_gem_debugfs_set_usage_flags(struct panthor_gem_object *bo, u32 usage_flags){};This could be changed to a static inline function, but as the normal one is also static inline, just move the #ifdef check in there. The #ifdef is still needed to avoid accessing a struct member that does not exist without debugfs.
Fixes a3707f53eb3f ("drm/panthor: show device-wide list of DRM GEM objects over DebugFS")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/drm/panthor/panthor_gem.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/panthor/panthor_gem.h +2
-6@@ -209,17 +209,14 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,void panthor_kernel_bo_destroy (struct panthor_kernel_bo *bo); -#ifdef CONFIG_DEBUG_FS void panthor_gem_debugfs_print_bos (struct panthor_device *pfdev,struct seq_file *m);static inline void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) { +#ifdef CONFIG_DEBUG_FS bo->debugfs.flags = usage_flags |PANTHOR_DEBUGFS_GEM_USAGE_FLAG_INITIALIZED ; -} - -#else -void panthor_gem_debugfs_set_usage_flags (struct panthor_gem_object *bo,u32 usage_flags) {};#endif +}#endif /* __PANTHOR_GEM_H__ */ --2.39.5