Cleanup warnings (fix build with W=1)
Subsystems (2)
cover Cleanup warnings (fix build with W=1)
Build with W=1 and fix all the warnings after applying both this series
and https://lore.kernel.org/intel-xe/[email protected]/T/#t
([PATCH v3 00/13] Start register cleanup).
References: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/211
Lucas De Marchi (6):
drm/xe: Make local functions static
drm/xe: Fix application of LRC tunings
drm/xe: Fix kunit integration due to missing prototypes drm/xe: Remove unused functions
drm/xe: Add missing doc for xe parameter drm/xe: Add missing include xe_wait_user_fence.h
drivers/gpu/drm/xe/tests/xe_bo.c | 54 ++++++++++++++----------- drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 + drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++ drivers/gpu/drm/xe/xe_gt.c | 7 ++-- drivers/gpu/drm/xe/xe_gt_topology.c | 25 ------------ drivers/gpu/drm/xe/xe_guc.c | 4 +- drivers/gpu/drm/xe/xe_irq.c | 2 +- drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 1 + drivers/gpu/drm/xe/xe_tuning.c | 15 ++++++- drivers/gpu/drm/xe/xe_tuning.h | 2 + drivers/gpu/drm/xe/xe_wait_user_fence.c | 8 ++-- 11 files changed, 68 insertions(+), 58 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/6 drm/xe: Make local functions static
A few static functions not being declared like that break the build with W=1, like e.g.
cc1: all warnings being treated as errors
make[2]: *** [../scripts/Makefile.build:250: drivers/gpu/drm/xe/xe_gt.o] Error 1 ../drivers/gpu/drm/xe/xe_guc.c:240:6: error: no previous prototype for ‘guc_write_params’ [-Werror=missing-prototypes]
240 | void guc_write_params(struct xe_guc *guc)
| ^~~~~~~~~~~~~~~~
Make them static.
--- drivers/gpu/drm/xe/xe_gt.c | 6 +++--- drivers/gpu/drm/xe/xe_guc.c | 4 ++-- drivers/gpu/drm/xe/xe_irq.c | 2 +- drivers/gpu/drm/xe/xe_wait_user_fence.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +3 -3
@@ -218,7 +218,7 @@ static void gt_fini(struct drm_device *drm, void *arg)static void gt_reset_worker (struct work_struct *w); -int emit_nop_job (struct xe_gt *gt,struct xe_engine *e) +static int emit_nop_job (struct xe_gt *gt,struct xe_engine *e) {struct xe_sched_job *job;struct xe_bb *bb;
@@ -252,7 +252,7 @@ int emit_nop_job(struct xe_gt *gt, struct xe_engine *e)return 0 ; } -int emit_wa_job (struct xe_gt *gt,struct xe_engine *e) +static int emit_wa_job (struct xe_gt *gt,struct xe_engine *e) {struct xe_reg_sr *sr = &e->hwe->reg_lrc;struct xe_reg_sr_entry *entry;
@@ -609,7 +609,7 @@ int xe_gt_init(struct xe_gt *gt)return 0 ; } -int do_gt_reset (struct xe_gt *gt) +static int do_gt_reset (struct xe_gt *gt) {struct xe_device *xe =gt_to_xe (gt);int err;
drivers/gpu/drm/xe/xe_guc.c +2 -2
@@ -237,7 +237,7 @@ static void guc_init_params(struct xe_guc *guc)* transfer. These parameters are read by the firmware on startup * and cannot be changed thereafter. */ -void guc_write_params (struct xe_guc *guc) +static void guc_write_params (struct xe_guc *guc) {struct xe_gt *gt =guc_to_gt (guc);int i;
@@ -560,7 +560,7 @@ static void guc_handle_mmio_msg(struct xe_guc *guc) "Received early GuC exception notification!\n"); } -void guc_enable_irq (struct xe_guc *guc) +static void guc_enable_irq (struct xe_guc *guc) {struct xe_gt *gt =guc_to_gt (guc); u32 events = xe_gt_is_media_type(gt) ?
drivers/gpu/drm/xe/xe_irq.c +1 -1
@@ -457,7 +457,7 @@ static void dg1_irq_reset(struct xe_gt *gt)GEN3_IRQ_RESET (gt,GEN8_PCU_ ); } -void xe_irq_reset (struct xe_device *xe) +static void xe_irq_reset (struct xe_device *xe) {struct xe_gt *gt;u8 id;
drivers/gpu/drm/xe/xe_wait_user_fence.c +3 -3
@@ -56,9 +56,9 @@ static const enum xe_engine_class user_to_xe_engine_class[] = { [DRM_XE_ENGINE_CLASS_COMPUTE] = XE_ENGINE_CLASS_COMPUTE, }; -int check_hw_engines (struct xe_device *xe, -struct drm_xe_engine_class_instance *eci, -int num_engines) +static int check_hw_engines (struct xe_device *xe, +struct drm_xe_engine_class_instance *eci, +int num_engines) {int i;
Signature · 1 line
2.39.0
Re: [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static
Quoted 10 lines · Lucas De Marchi
A few static functions not being declared like that break the build with W=1, like e.g.
cc1: all warnings being treated as errors
make[2]: *** [../scripts/Makefile.build:250:drivers/gpu/drm/xe/xe_gt.o] Error 1../drivers/gpu/drm/xe/xe_guc.c:240:6: error: no previous prototype for ‘guc_write_params’ [-Werror=missing-prototypes]
240 | voidguc_write_params(struct xe_guc *guc)
| ^~~~~~~~~~~~~~~~
Quoted 3 lines
Make them static.
Signed-off-by Lucas De Marchi <[email protected]>
PATCH 2/6 drm/xe: Fix application of LRC tunings
In reply to Lucas De MarchiLRC tunings were added after the gt ones and didn't add the call in xe_gt_record_default_lrcs() to process them like is done for workarounds. Add such a function and call it from xe_gt_record_default_lrcs().
--- drivers/gpu/drm/xe/xe_gt.c | 1 + drivers/gpu/drm/xe/xe_tuning.c | 15 ++++++++++++++- drivers/gpu/drm/xe/xe_tuning.h | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_gt.c +1 -0
@@ -320,6 +320,7 @@ int xe_gt_record_default_lrcs(struct xe_gt *gt)xe_reg_sr_init (&hwe->reg_lrc,"LRC" , xe);xe_wa_process_lrc (hwe); +xe_tuning_process_lrc (hwe); default_lrc = drmm_kzalloc(&xe->drm, xe_lrc_size(xe, hwe->class),
drivers/gpu/drm/xe/xe_tuning.c +14 -1
@@ -24,7 +24,7 @@ static const struct xe_rtp_entry gt_tunings[] = { {} }; -static const struct xe_rtp_entry context_tunings[] = { +static const struct xe_rtp_entry lrc_tunings[] = { {XE_RTP_NAME ("1604555607" ),XE_RTP_RULES (GRAPHICS_VERSION (1200 )), XE_RTP_ACTIONS(FIELD_SET_NO_READ_MASK(XEHP_FF_MODE2,
@@ -38,3 +38,16 @@ void xe_tuning_process_gt(struct xe_gt *gt) {xe_rtp_process (gt_tunings, >->reg_sr, gt,NULL ); } + +/** +* xe_tuning_process_lrc - process lrc tunings +* @hwe: engine instance to process tunings for +* +* Process LRC table for this platform, saving in @hwe all the tunings that need +* to be applied on context restore. These are tunings touching registers that +* are part of the HW context image. +*/ +void xe_tuning_process_lrc (struct xe_hw_engine *hwe) +{ +xe_rtp_process (lrc_tunings, &hwe->reg_lrc, hwe->gt, hwe); +}
drivers/gpu/drm/xe/xe_tuning.h +2 -0
@@ -7,7 +7,9 @@#define _XE_TUNING_struct xe_gt ; +struct xe_hw_engine ;void xe_tuning_process_gt (struct xe_gt *gt); +void xe_tuning_process_lrc (struct xe_hw_engine *hwe);#endif
Signature · 1 line
2.39.0
Re: [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings
Quoted 7 lines · Lucas De Marchi
LRC tunings were added after the gt ones and didn't add the call in
xe_gt_record_default_lrcs()to process them like is done for workarounds. Add such a function and call it fromxe_gt_record_default_lrcs().Signed-off-by Lucas De Marchi <[email protected]>
PATCH 3/6 drm/xe: Fix kunit integration due to missing prototypes
In reply to Lucas De MarchiIn order to avoid -Werror=missing-prototypes, add the prototypes and move the functions to the end of the file, surrounded by #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST).
--- drivers/gpu/drm/xe/tests/xe_bo.c | 54 +++++++++++++++------------ drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 + drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++ 3 files changed, 39 insertions(+), 23 deletions(-)
drivers/gpu/drm/xe/tests/xe_bo.c +31 -23
@@ -141,29 +141,6 @@ static void ccs_test_run_gt(struct xe_device *xe, struct xe_gt *gt,xe_bo_put (bo); } -static int ccs_test_run_device (struct xe_device *xe) -{ -struct kunit *test =xe_cur_kunit (); -struct xe_gt *gt; -int id; - -if (!xe_device_has_flat_ccs (xe)) { -kunit_info (test,"Skipping non-flat-ccs device.\n" ); -return 0 ; - } - -for_each_gt (gt, xe, id) -ccs_test_run_gt (xe, gt, test); - -return 0 ; -} - -void xe_ccs_migrate_kunit (struct kunit *test) -{ -xe_call_for_each_device (ccs_test_run_device); -} -EXPORT_SYMBOL (xe_ccs_migrate_kunit); -static int evict_test_run_gt (struct xe_device *xe,struct xe_gt *gt,struct kunit *test) {struct xe_bo *bo, *external;
@@ -278,6 +255,8 @@ static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kunireturn 0 ; } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int evict_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();
@@ -296,8 +275,37 @@ static int evict_test_run_device(struct xe_device *xe)return 0 ; } +void xe_bo_evict_kunit (struct kunit *test); +void xe_bo_evict_kunit (struct kunit *test) {xe_call_for_each_device (evict_test_run_device); }EXPORT_SYMBOL (xe_bo_evict_kunit); + +static int ccs_test_run_device (struct xe_device *xe) +{ +struct kunit *test =xe_cur_kunit (); +struct xe_gt *gt; +int id; + +if (!xe_device_has_flat_ccs (xe)) { +kunit_info (test,"Skipping non-flat-ccs device.\n" ); +return 0 ; + } + +for_each_gt (gt, xe, id) +ccs_test_run_gt (xe, gt, test); + +return 0 ; +} + +void xe_ccs_migrate_kunit (struct kunit *test); + +void xe_ccs_migrate_kunit (struct kunit *test) +{ +xe_call_for_each_device (ccs_test_run_device); +} +EXPORT_SYMBOL (xe_ccs_migrate_kunit); + +#endif
drivers/gpu/drm/xe/tests/xe_dma_buf.c +2 -0
@@ -252,6 +252,8 @@ static int dma_buf_run_device(struct xe_device *xe)return 0 ; } +void xe_dma_buf_kunit (struct kunit *test); +void xe_dma_buf_kunit (struct kunit *test) {xe_call_for_each_device (dma_buf_run_device);
drivers/gpu/drm/xe/tests/xe_migrate.c +6 -0
@@ -352,6 +352,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)xe_bo_vunmap (m->pt_bo); } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int migrate_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();
@@ -371,8 +373,12 @@ static int migrate_test_run_device(struct xe_device *xe) return 0; } +void xe_migrate_sanity_kunit (struct kunit *test); +void xe_migrate_sanity_kunit (struct kunit *test) {xe_call_for_each_device (migrate_test_run_device); }EXPORT_SYMBOL (xe_migrate_sanity_kunit); + +#endif
Signature · 1 line
2.39.0
Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
Quoted 4 lines · Lucas De Marchi
In order to avoid -Werror=missing-prototypes, add the prototypes and move the functions to the end of the file, surrounded by
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST).
Is everything under tests/ not excluded from compilation when !XE_KUNIT_TEST?
Quoted 131 lines
Signed-off-by Lucas De Marchi <[email protected]>--- drivers/gpu/drm/xe/tests/xe_bo.c | 54 +++++++++++++++------------ drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 + drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++ 3 files changed, 39 insertions(+), 23 deletions(-)drivers/gpu/drm/xe/tests/xe_bo.c +31
-23@@ -141,29 +141,6 @@ static void ccs_test_run_gt(struct xe_device *xe, struct xe_gt *gt,xe_bo_put (bo); } -static int ccs_test_run_device (struct xe_device *xe) -{ -struct kunit *test =xe_cur_kunit (); -struct xe_gt *gt; -int id; - -if (!xe_device_has_flat_ccs (xe)) { -kunit_info (test,"Skipping non-flat-ccs device.\n" ); -return 0 ; - } - -for_each_gt (gt, xe, id) -ccs_test_run_gt (xe, gt, test); - -return 0 ; -} - -void xe_ccs_migrate_kunit (struct kunit *test) -{ -xe_call_for_each_device (ccs_test_run_device); -} -EXPORT_SYMBOL (xe_ccs_migrate_kunit); -static int evict_test_run_gt (struct xe_device *xe,struct xe_gt *gt,struct kunit *test) {struct xe_bo *bo, *external;@@ -278,6 +255,8 @@ static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kunireturn 0 ; } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int evict_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -296,8 +275,37 @@ static int evict_test_run_device(struct xe_device *xe)return 0 ; } +void xe_bo_evict_kunit (struct kunit *test); +void xe_bo_evict_kunit (struct kunit *test) {xe_call_for_each_device (evict_test_run_device); }EXPORT_SYMBOL (xe_bo_evict_kunit); + +static int ccs_test_run_device (struct xe_device *xe) +{ +struct kunit *test =xe_cur_kunit (); +struct xe_gt *gt; +int id; + +if (!xe_device_has_flat_ccs (xe)) { +kunit_info (test,"Skipping non-flat-ccs device.\n" ); +return 0 ; + } + +for_each_gt (gt, xe, id) +ccs_test_run_gt (xe, gt, test); + +return 0 ; +} + +void xe_ccs_migrate_kunit (struct kunit *test); + +void xe_ccs_migrate_kunit (struct kunit *test) +{ +xe_call_for_each_device (ccs_test_run_device); +} +EXPORT_SYMBOL (xe_ccs_migrate_kunit); + +#endif drivers/gpu/drm/xe/tests/xe_dma_buf.c +2
-0@@ -252,6 +252,8 @@ static int dma_buf_run_device(struct xe_device *xe)return 0 ; } +void xe_dma_buf_kunit (struct kunit *test); +void xe_dma_buf_kunit (struct kunit *test) {xe_call_for_each_device (dma_buf_run_device);drivers/gpu/drm/xe/tests/xe_migrate.c +6
-1@@ -352,6 +352,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)xe_bo_vunmap (m->pt_bo); } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int migrate_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -371,8 +373,12 @@ static int migrate_test_run_device(struct xe_device *xe) return 0; } +void xe_migrate_sanity_kunit (struct kunit *test); +void xe_migrate_sanity_kunit (struct kunit *test) {xe_call_for_each_device (migrate_test_run_device); }EXPORT_SYMBOL (xe_migrate_sanity_kunit); + +#endif --2.39.0
Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
Quoted 7 lines · Matthew Auld
Quoted 4 lines · Lucas De Marchi
In order to avoid -Werror=missing-prototypes, add the prototypes and move the functions to the end of the file, surrounded by
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST).Is everything under tests/ not excluded from compilation when !XE_KUNIT_TEST?
yes, except the ifdef is not in tests/. Example:drivers/gpu/drm/xe/tests/xe_bo.c
The way the kunit tests in xe are split is: each .o in tests/ will create a separate module. In order to test a function like we are doing, the function needs to be declared !static and exported so the other module can call it.
There are other possible ways to test functions on a different
compilation unit: https://kunit.dev/third_party/kernel/docs/tips.html?highlight=static%20function#testing-static-functions
I'm not so familiar with kunit yet to be able to say which one
is better for our case, so I just went with the easy fix.
+Thomas
Lucas De Marchi
Quoted 132 lines
Quoted 132 lines
Signed-off-by Lucas De Marchi <[email protected]>--- drivers/gpu/drm/xe/tests/xe_bo.c | 54 +++++++++++++++------------ drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 + drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++ 3 files changed, 39 insertions(+), 23 deletions(-)drivers/gpu/drm/xe/tests/xe_bo.c +31
-23@@ -141,29 +141,6 @@ static void ccs_test_run_gt(struct xe_device *xe, struct xe_gt *gt,xe_bo_put (bo); } -static int ccs_test_run_device (struct xe_device *xe) -{ -struct kunit *test =xe_cur_kunit (); -struct xe_gt *gt; -int id; - -if (!xe_device_has_flat_ccs (xe)) { -kunit_info (test,"Skipping non-flat-ccs device.\n" ); -return 0 ; - } - -for_each_gt (gt, xe, id) -ccs_test_run_gt (xe, gt, test); - -return 0 ; -} - -void xe_ccs_migrate_kunit (struct kunit *test) -{ -xe_call_for_each_device (ccs_test_run_device); -} -EXPORT_SYMBOL (xe_ccs_migrate_kunit); -static int evict_test_run_gt (struct xe_device *xe,struct xe_gt *gt,struct kunit *test) {struct xe_bo *bo, *external;@@ -278,6 +255,8 @@ static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kunireturn 0 ; } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int evict_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -296,8 +275,37 @@ static int evict_test_run_device(struct xe_device *xe)return 0 ; } +void xe_bo_evict_kunit (struct kunit *test); +void xe_bo_evict_kunit (struct kunit *test) {xe_call_for_each_device (evict_test_run_device); }EXPORT_SYMBOL (xe_bo_evict_kunit); + +static int ccs_test_run_device (struct xe_device *xe) +{ +struct kunit *test =xe_cur_kunit (); +struct xe_gt *gt; +int id; + +if (!xe_device_has_flat_ccs (xe)) { +kunit_info (test,"Skipping non-flat-ccs device.\n" ); +return 0 ; + } + +for_each_gt (gt, xe, id) +ccs_test_run_gt (xe, gt, test); + +return 0 ; +} + +void xe_ccs_migrate_kunit (struct kunit *test); + +void xe_ccs_migrate_kunit (struct kunit *test) +{ +xe_call_for_each_device (ccs_test_run_device); +} +EXPORT_SYMBOL (xe_ccs_migrate_kunit); + +#endif drivers/gpu/drm/xe/tests/xe_dma_buf.c +2
-0@@ -252,6 +252,8 @@ static int dma_buf_run_device(struct xe_device *xe)return 0 ; } +void xe_dma_buf_kunit (struct kunit *test); +void xe_dma_buf_kunit (struct kunit *test) {xe_call_for_each_device (dma_buf_run_device);drivers/gpu/drm/xe/tests/xe_migrate.c +6
-1@@ -352,6 +352,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)xe_bo_vunmap (m->pt_bo); } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int migrate_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -371,8 +373,12 @@ static int migrate_test_run_device(struct xe_device *xe) return 0; } +void xe_migrate_sanity_kunit (struct kunit *test); +void xe_migrate_sanity_kunit (struct kunit *test) {xe_call_for_each_device (migrate_test_run_device); }EXPORT_SYMBOL (xe_migrate_sanity_kunit); + +#endif --2.39.0
Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
Quoted 4 lines · Lucas De Marchi
Quoted 2 lines · Matthew Auld
Quoted 1 line · Lucas De Marchi
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
In order to avoid -Werror=missing-prototypes, add the prototypes and move the functions to the end of the file, surrounded by
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST).Is everything under tests/ not excluded from compilation when !XE_KUNIT_TEST?
yes, except the ifdef is not in tests/. Example:
drivers/gpu/drm/xe/tests/xe_bo.c
AFAICT xe/tests is only compiled if XE_KUNIT_TEST is enabled (looking at the Makefile). tests/xe_bo.c is included at the bottom of xe_bo.c but that is also wrapped in ifdef. So not seeing why we need to add the ifdef stuff directly in tests/xe_bo.c, for example.
Quoted 147 lines
The way the kunit tests in xe are split is: each .o in tests/ will create a separate module. In order to test a function like we are doing, the function needs to be declared !static and exported so the other module can call it.
There are other possible ways to test functions on a different
compilation unit: https://kunit.dev/third_party/kernel/docs/tips.html?highlight=static%20function#testing-static-functions
I'm not so familiar with kunit yet to be able to say which one
is better for our case, so I just went with the easy fix.+Thomas
Lucas De Marchi
Quoted 132 lines
Quoted 132 lines
Signed-off-by Lucas De Marchi <[email protected]>--- drivers/gpu/drm/xe/tests/xe_bo.c | 54 +++++++++++++++------------ drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 + drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++ 3 files changed, 39 insertions(+), 23 deletions(-)drivers/gpu/drm/xe/tests/xe_bo.c +31
-23@@ -141,29 +141,6 @@ static void ccs_test_run_gt(struct xe_device *xe, struct xe_gt *gt,xe_bo_put (bo); } -static int ccs_test_run_device (struct xe_device *xe) -{ -struct kunit *test =xe_cur_kunit (); -struct xe_gt *gt; -int id; - -if (!xe_device_has_flat_ccs (xe)) { -kunit_info (test,"Skipping non-flat-ccs device.\n" ); -return 0 ; - } - -for_each_gt (gt, xe, id) -ccs_test_run_gt (xe, gt, test); - -return 0 ; -} - -void xe_ccs_migrate_kunit (struct kunit *test) -{ -xe_call_for_each_device (ccs_test_run_device); -} -EXPORT_SYMBOL (xe_ccs_migrate_kunit); -static int evict_test_run_gt (struct xe_device *xe,struct xe_gt *gt,struct kunit *test) {struct xe_bo *bo, *external;@@ -278,6 +255,8 @@ static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kunireturn 0 ; } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int evict_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -296,8 +275,37 @@ static int evict_test_run_device(struct xe_device *xe)return 0 ; } +void xe_bo_evict_kunit (struct kunit *test); +void xe_bo_evict_kunit (struct kunit *test) {xe_call_for_each_device (evict_test_run_device); }EXPORT_SYMBOL (xe_bo_evict_kunit); + +static int ccs_test_run_device (struct xe_device *xe) +{ +struct kunit *test =xe_cur_kunit (); +struct xe_gt *gt; +int id; + +if (!xe_device_has_flat_ccs (xe)) { +kunit_info (test,"Skipping non-flat-ccs device.\n" ); +return 0 ; + } + +for_each_gt (gt, xe, id) +ccs_test_run_gt (xe, gt, test); + +return 0 ; +} + +void xe_ccs_migrate_kunit (struct kunit *test); + +void xe_ccs_migrate_kunit (struct kunit *test) +{ +xe_call_for_each_device (ccs_test_run_device); +} +EXPORT_SYMBOL (xe_ccs_migrate_kunit); + +#endif drivers/gpu/drm/xe/tests/xe_dma_buf.c +2
-0@@ -252,6 +252,8 @@ static int dma_buf_run_device(struct xe_device *xe)return 0 ; } +void xe_dma_buf_kunit (struct kunit *test); +void xe_dma_buf_kunit (struct kunit *test) {xe_call_for_each_device (dma_buf_run_device);drivers/gpu/drm/xe/tests/xe_migrate.c +6
-1@@ -352,6 +352,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)xe_bo_vunmap (m->pt_bo); } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int migrate_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -371,8 +373,12 @@ static int migrate_test_run_device(struct xe_device *xe) return 0; } +void xe_migrate_sanity_kunit (struct kunit *test); +void xe_migrate_sanity_kunit (struct kunit *test) {xe_call_for_each_device (migrate_test_run_device); }EXPORT_SYMBOL (xe_migrate_sanity_kunit); + +#endif --2.39.0
Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
Quoted 11 lines · Matthew Auld
Quoted 10 lines · Lucas De Marchi
Quoted 7 lines · Matthew Auld
Quoted 4 lines · Lucas De Marchi
In order to avoid -Werror=missing-prototypes, add the prototypes and move the functions to the end of the file, surrounded by
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST).Is everything under tests/ not excluded from compilation when !XE_KUNIT_TEST?
Quoted 7 lines
Quoted 2 lines
yes, except the ifdef is not in tests/. Example:
drivers/gpu/drm/xe/tests/xe_bo.cAFAICT xe/tests is only compiled if
XE_KUNIT_TESTis enabled (looking at theMakefile).tests/xe_bo.cis included at the bottom ofxe_bo.cbut that is also wrapped in ifdef. So not seeing why we need to add the ifdef stuff directly intests/xe_bo.c, for example.
ugh... I read what I paste, sorry.
indeed, it shouldn't build that, so I think it's just the missing prototype that I need to add. I will rework this patch.
thanks
Lucas De Marchi
Quoted 148 lines
Quoted 148 lines
The way the kunit tests in xe are split is: each .o in tests/ will create a separate module. In order to test a function like we are doing, the function needs to be declared !static and exported so the other module can call it.
There are other possible ways to test functions on a different
compilation unit: https://kunit.dev/third_party/kernel/docs/tips.html?highlight=static%20function#testing-static-functions
I'm not so familiar with kunit yet to be able to say which one
is better for our case, so I just went with the easy fix.+Thomas
Lucas De Marchi
Quoted 132 lines
Quoted 132 lines
Signed-off-by Lucas De Marchi <[email protected]>--- drivers/gpu/drm/xe/tests/xe_bo.c | 54 +++++++++++++++------------ drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 + drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +++ 3 files changed, 39 insertions(+), 23 deletions(-)drivers/gpu/drm/xe/tests/xe_bo.c +31
-23@@ -141,29 +141,6 @@ static void ccs_test_run_gt(struct xe_device *xe, struct xe_gt *gt,xe_bo_put (bo); } -static int ccs_test_run_device (struct xe_device *xe) -{ -struct kunit *test =xe_cur_kunit (); -struct xe_gt *gt; -int id; - -if (!xe_device_has_flat_ccs (xe)) { -kunit_info (test,"Skipping non-flat-ccs device.\n" ); -return 0 ; - } - -for_each_gt (gt, xe, id) -ccs_test_run_gt (xe, gt, test); - -return 0 ; -} - -void xe_ccs_migrate_kunit (struct kunit *test) -{ -xe_call_for_each_device (ccs_test_run_device); -} -EXPORT_SYMBOL (xe_ccs_migrate_kunit); -static int evict_test_run_gt (struct xe_device *xe,struct xe_gt *gt,struct kunit *test) {struct xe_bo *bo, *external;@@ -278,6 +255,8 @@ static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kunireturn 0 ; } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int evict_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -296,8 +275,37 @@ static int evict_test_run_device(struct xe_device *xe)return 0 ; } +void xe_bo_evict_kunit (struct kunit *test); +void xe_bo_evict_kunit (struct kunit *test) {xe_call_for_each_device (evict_test_run_device); }EXPORT_SYMBOL (xe_bo_evict_kunit); + +static int ccs_test_run_device (struct xe_device *xe) +{ +struct kunit *test =xe_cur_kunit (); +struct xe_gt *gt; +int id; + +if (!xe_device_has_flat_ccs (xe)) { +kunit_info (test,"Skipping non-flat-ccs device.\n" ); +return 0 ; + } + +for_each_gt (gt, xe, id) +ccs_test_run_gt (xe, gt, test); + +return 0 ; +} + +void xe_ccs_migrate_kunit (struct kunit *test); + +void xe_ccs_migrate_kunit (struct kunit *test) +{ +xe_call_for_each_device (ccs_test_run_device); +} +EXPORT_SYMBOL (xe_ccs_migrate_kunit); + +#endif drivers/gpu/drm/xe/tests/xe_dma_buf.c +2
-0@@ -252,6 +252,8 @@ static int dma_buf_run_device(struct xe_device *xe)return 0 ; } +void xe_dma_buf_kunit (struct kunit *test); +void xe_dma_buf_kunit (struct kunit *test) {xe_call_for_each_device (dma_buf_run_device);drivers/gpu/drm/xe/tests/xe_migrate.c +6
-1@@ -352,6 +352,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)xe_bo_vunmap (m->pt_bo); } +#if IS_ENABLED (CONFIG_DRM_XE_KUNIT_TEST ) +static int migrate_test_run_device (struct xe_device *xe) {struct kunit *test =xe_cur_kunit ();@@ -371,8 +373,12 @@ static int migrate_test_run_device(struct xe_device *xe) return 0; } +void xe_migrate_sanity_kunit (struct kunit *test); +void xe_migrate_sanity_kunit (struct kunit *test) {xe_call_for_each_device (migrate_test_run_device); }EXPORT_SYMBOL (xe_migrate_sanity_kunit); + +#endif --2.39.0
PATCH 4/6 drm/xe: Remove unused functions
In reply to Lucas De Marchixe_gt_topology_dss_group_mask and xe_gt_topology_count_dss are probably leftover from initial implementation - they are not called from anywhere. Remove those functions.
--- drivers/gpu/drm/xe/xe_gt_topology.c | 25 ------------------------- 1 file changed, 25 deletions(-)
drivers/gpu/drm/xe/xe_gt_topology.c +0 -25
@@ -94,31 +94,6 @@ xe_gt_topology_init(struct xe_gt *gt)xe_gt_topology_dump (gt, &p); } -unsigned int -xe_gt_topology_count_dss (xe_dss_mask_t mask) -{ -return bitmap_weight (mask,XE_MAX_DSS_FUSE_BITS ); -} - -u64 -xe_gt_topology_dss_group_mask (xe_dss_mask_t mask,int grpsize) -{ -xe_dss_mask_t per_dss_mask = {}; -u64 grpmask =0 ; - -WARN_ON (DIV_ROUND_UP (XE_MAX_DSS_FUSE_BITS , grpsize) >BITS_PER_TYPE (grpmask)); - -bitmap_fill (per_dss_mask, grpsize); -for (int i =0 ; !bitmap_empty (mask,XE_MAX_DSS_FUSE_BITS ); i++) { -if (bitmap_intersects (mask, per_dss_mask, grpsize)) - grpmask |=BIT (i); - -bitmap_shift_right (mask, mask, grpsize,XE_MAX_DSS_FUSE_BITS ); - } - -return grpmask; -} -void xe_gt_topology_dump (struct xe_gt *gt,struct drm_printer *p) {
Signature · 1 line
2.39.0
Re: [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions
Quoted 6 lines · Lucas De Marchi
xe_gt_topology_dss_group_maskandxe_gt_topology_count_dssare probably leftover from initial implementation - they are not called from anywhere. Remove those functions.Signed-off-by Lucas De Marchi <[email protected]>
PATCH 5/6 drm/xe: Add missing doc for xe parameter
In reply to Lucas De MarchiFix the following warning:
../drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c:55: warning: Function parameter or member 'xe' not described in 'xe_ttm_stolen_cpu_inaccessible'
--- drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c +1 -0
@@ -41,6 +41,7 @@ to_stolen_mgr(struct ttm_resource_manager *man)/** * xe_ttm_stolen_cpu_inaccessible - Can we directly CPU access stolen memory for * this device. +* @xe: xe device * * On some integrated platforms we can't directly access stolen via the CPU * (like some normal system memory). Also on small-bar systems for discrete,
Signature · 1 line
2.39.0
Re: [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter
Quoted 8 lines · Lucas De Marchi
Fix the following warning:
../drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c:55: warning: Function parameter or member 'xe' not described in 'xe_ttm_stolen_cpu_inaccessible'Signed-off-by Lucas De Marchi <[email protected]>
PATCH 6/6 drm/xe: Add missing include xe_wait_user_fence.h
In reply to Lucas De MarchiMake xe_wait_user_fence.c include xe_wait_user_fence.h so it doesn't rely on indirect includes and also doesn't fail the build due to missing prototype for xe_wait_user_fence_ioctl().
--- drivers/gpu/drm/xe/xe_wait_user_fence.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/xe/xe_wait_user_fence.c +2 -0
@@ -3,6 +3,8 @@* Copyright © 2022 Intel Corporation */ +#include "xe_wait_user_fence.h" +#include <drm/drm_device.h> #include <drm/drm_file.h> #include <drm/xe_drm.h>
Signature · 1 line
2.39.0
Re: [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h
Quoted 6 lines · Lucas De Marchi
Make
xe_wait_user_fence.cincludexe_wait_user_fence.hso it doesn't rely on indirect includes and also doesn't fail the build due to missing prototype forxe_wait_user_fence_ioctl().Signed-off-by Lucas De Marchi <[email protected]>
Lucas De Marchi
AppliedRe: [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h
Quoted 8 lines · Matthew Auld
Quoted 6 lines · Lucas De Marchi
Make
xe_wait_user_fence.cincludexe_wait_user_fence.hso it doesn't rely on indirect includes and also doesn't fail the build due to missing prototype forxe_wait_user_fence_ioctl().Signed-off-by Lucas De Marchi <[email protected]>Reviewed-by Matthew Auld <[email protected]>
thanks, applied all the patches except the third, "drm/xe: Fix kunit integration due to missing prototypes"
I will re-submit it with the new version I shared
Lucas De Marchi