All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1)
@ 2023-02-21 23:33 Lucas De Marchi
  2023-02-21 23:33 ` [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static Lucas De Marchi
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi

Build with W=1 and fix all the warnings after applying both this series
and https://lore.kernel.org/intel-xe/20230221194002.819026-1-lucas.demarchi@intel.com/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(-)

-- 
2.39.0


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

* [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static
  2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
@ 2023-02-21 23:33 ` Lucas De Marchi
  2023-02-22  9:48   ` Matthew Auld
  2023-02-21 23:33 ` [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings Lucas De Marchi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: 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 | void guc_write_params(struct xe_guc *guc)
	      |      ^~~~~~~~~~~~~~~~

Make them static.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index c17279653561..809e9b14c314 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -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;
diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 5cdfdfd0de40..32bcc40463e1 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -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) ?
diff --git a/drivers/gpu/drm/xe/xe_irq.c b/drivers/gpu/drm/xe/xe_irq.c
index 7b7ddd11c2b8..89401c663274 100644
--- a/drivers/gpu/drm/xe/xe_irq.c
+++ b/drivers/gpu/drm/xe/xe_irq.c
@@ -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;
diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index 8a8d814a0e7a..977c963a8cd0 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -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;
 
-- 
2.39.0


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

* [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings
  2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
  2023-02-21 23:33 ` [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static Lucas De Marchi
@ 2023-02-21 23:33 ` Lucas De Marchi
  2023-02-22 10:16   ` Matthew Auld
  2023-02-21 23:33 ` [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes Lucas De Marchi
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: 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 from
xe_gt_record_default_lrcs().

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 809e9b14c314..5a3c8fd5936a 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -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),
diff --git a/drivers/gpu/drm/xe/xe_tuning.c b/drivers/gpu/drm/xe/xe_tuning.c
index 3cc32e3e7a90..595eb2de90ad 100644
--- a/drivers/gpu/drm/xe/xe_tuning.c
+++ b/drivers/gpu/drm/xe/xe_tuning.c
@@ -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, &gt->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);
+}
diff --git a/drivers/gpu/drm/xe/xe_tuning.h b/drivers/gpu/drm/xe/xe_tuning.h
index 66dbc93192bd..2b95b0c8effc 100644
--- a/drivers/gpu/drm/xe/xe_tuning.h
+++ b/drivers/gpu/drm/xe/xe_tuning.h
@@ -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
-- 
2.39.0


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

* [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
  2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
  2023-02-21 23:33 ` [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static Lucas De Marchi
  2023-02-21 23:33 ` [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings Lucas De Marchi
@ 2023-02-21 23:33 ` Lucas De Marchi
  2023-02-22 10:02   ` Matthew Auld
  2023-02-21 23:33 ` [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions Lucas De Marchi
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: 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)`.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
index 87ac21cc8ca9..2c94ddaacda6 100644
--- a/drivers/gpu/drm/xe/tests/xe_bo.c
+++ b/drivers/gpu/drm/xe/tests/xe_bo.c
@@ -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 kuni
 	return 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
diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
index 615d22e3f731..d8ad135d0e04 100644
--- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
+++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
@@ -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);
diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
index 03a60d5b42f1..7be0c2543916 100644
--- a/drivers/gpu/drm/xe/tests/xe_migrate.c
+++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
@@ -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


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

* [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions
  2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
                   ` (2 preceding siblings ...)
  2023-02-21 23:33 ` [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes Lucas De Marchi
@ 2023-02-21 23:33 ` Lucas De Marchi
  2023-02-22 10:05   ` Matthew Auld
  2023-02-21 23:33 ` [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter Lucas De Marchi
  2023-02-21 23:33 ` [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h Lucas De Marchi
  5 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi

xe_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.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_gt_topology.c | 25 -------------------------
 1 file changed, 25 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_topology.c b/drivers/gpu/drm/xe/xe_gt_topology.c
index 8e02e362ba27..3dd7cbbff071 100644
--- a/drivers/gpu/drm/xe/xe_gt_topology.c
+++ b/drivers/gpu/drm/xe/xe_gt_topology.c
@@ -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)
 {
-- 
2.39.0


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

* [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter
  2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
                   ` (3 preceding siblings ...)
  2023-02-21 23:33 ` [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions Lucas De Marchi
@ 2023-02-21 23:33 ` Lucas De Marchi
  2023-02-22 10:06   ` Matthew Auld
  2023-02-21 23:33 ` [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h Lucas De Marchi
  5 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: 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 <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index e20c567f276f..097454f78286 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -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,
-- 
2.39.0


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

* [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h
  2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
                   ` (4 preceding siblings ...)
  2023-02-21 23:33 ` [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter Lucas De Marchi
@ 2023-02-21 23:33 ` Lucas De Marchi
  2023-02-22 10:07   ` Matthew Auld
  5 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-21 23:33 UTC (permalink / raw)
  To: intel-xe; +Cc: Lucas De Marchi

Make 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().

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/xe/xe_wait_user_fence.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index 977c963a8cd0..15c2e5aa08d2 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -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>
-- 
2.39.0


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

* Re: [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static
  2023-02-21 23:33 ` [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static Lucas De Marchi
@ 2023-02-22  9:48   ` Matthew Auld
  0 siblings, 0 replies; 17+ messages in thread
From: Matthew Auld @ 2023-02-22  9:48 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> 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.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

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

* Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
  2023-02-21 23:33 ` [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes Lucas De Marchi
@ 2023-02-22 10:02   ` Matthew Auld
  2023-02-22 14:59     ` Lucas De Marchi
  0 siblings, 1 reply; 17+ messages in thread
From: Matthew Auld @ 2023-02-22 10:02 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> 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?

>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
>  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(-)
>
> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
> index 87ac21cc8ca9..2c94ddaacda6 100644
> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
> @@ -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 kuni
>         return 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
> diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> index 615d22e3f731..d8ad135d0e04 100644
> --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> @@ -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);
> diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
> index 03a60d5b42f1..7be0c2543916 100644
> --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
> @@ -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
>

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

* Re: [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions
  2023-02-21 23:33 ` [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions Lucas De Marchi
@ 2023-02-22 10:05   ` Matthew Auld
  0 siblings, 0 replies; 17+ messages in thread
From: Matthew Auld @ 2023-02-22 10:05 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> xe_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.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

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

* Re: [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter
  2023-02-21 23:33 ` [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter Lucas De Marchi
@ 2023-02-22 10:06   ` Matthew Auld
  0 siblings, 0 replies; 17+ messages in thread
From: Matthew Auld @ 2023-02-22 10:06 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> 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 <lucas.demarchi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

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

* Re: [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h
  2023-02-21 23:33 ` [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h Lucas De Marchi
@ 2023-02-22 10:07   ` Matthew Auld
  2023-02-23  0:37     ` Lucas De Marchi
  0 siblings, 1 reply; 17+ messages in thread
From: Matthew Auld @ 2023-02-22 10:07 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> Make 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().
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

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

* Re: [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings
  2023-02-21 23:33 ` [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings Lucas De Marchi
@ 2023-02-22 10:16   ` Matthew Auld
  0 siblings, 0 replies; 17+ messages in thread
From: Matthew Auld @ 2023-02-22 10:16 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> 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 from
> xe_gt_record_default_lrcs().
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

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

* Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
  2023-02-22 10:02   ` Matthew Auld
@ 2023-02-22 14:59     ` Lucas De Marchi
  2023-02-22 17:10       ` Matthew Auld
  0 siblings, 1 reply; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-22 14:59 UTC (permalink / raw)
  To: Matthew Auld; +Cc: intel-xe

On Wed, Feb 22, 2023 at 10:02:08AM +0000, Matthew Auld wrote:
>On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>>
>> 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

>
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> ---
>>  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(-)
>>
>> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
>> index 87ac21cc8ca9..2c94ddaacda6 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
>> @@ -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 kuni
>>         return 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
>> diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
>> index 615d22e3f731..d8ad135d0e04 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
>> @@ -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);
>> diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
>> index 03a60d5b42f1..7be0c2543916 100644
>> --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
>> +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
>> @@ -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
>>

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

* Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
  2023-02-22 14:59     ` Lucas De Marchi
@ 2023-02-22 17:10       ` Matthew Auld
  2023-02-22 17:42         ` Lucas De Marchi
  0 siblings, 1 reply; 17+ messages in thread
From: Matthew Auld @ 2023-02-22 17:10 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Wed, 22 Feb 2023 at 14:59, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> On Wed, Feb 22, 2023 at 10:02:08AM +0000, Matthew Auld wrote:
> >On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
> >>
> >> 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.

>
> 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
>
> >
> >>
> >> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> >> ---
> >>  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(-)
> >>
> >> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
> >> index 87ac21cc8ca9..2c94ddaacda6 100644
> >> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
> >> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
> >> @@ -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 kuni
> >>         return 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
> >> diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> >> index 615d22e3f731..d8ad135d0e04 100644
> >> --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> >> +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> >> @@ -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);
> >> diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
> >> index 03a60d5b42f1..7be0c2543916 100644
> >> --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
> >> +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
> >> @@ -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
> >>

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

* Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
  2023-02-22 17:10       ` Matthew Auld
@ 2023-02-22 17:42         ` Lucas De Marchi
  0 siblings, 0 replies; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-22 17:42 UTC (permalink / raw)
  To: Matthew Auld; +Cc: intel-xe

On Wed, Feb 22, 2023 at 05:10:55PM +0000, Matthew Auld wrote:
>On Wed, 22 Feb 2023 at 14:59, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>>
>> On Wed, Feb 22, 2023 at 10:02:08AM +0000, Matthew Auld wrote:
>> >On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>> >>
>> >> 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.

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

>
>>
>> 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
>>
>> >
>> >>
>> >> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>> >> ---
>> >>  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(-)
>> >>
>> >> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
>> >> index 87ac21cc8ca9..2c94ddaacda6 100644
>> >> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
>> >> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
>> >> @@ -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 kuni
>> >>         return 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
>> >> diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
>> >> index 615d22e3f731..d8ad135d0e04 100644
>> >> --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
>> >> +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
>> >> @@ -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);
>> >> diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
>> >> index 03a60d5b42f1..7be0c2543916 100644
>> >> --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
>> >> +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
>> >> @@ -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
>> >>

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

* Re: [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h
  2023-02-22 10:07   ` Matthew Auld
@ 2023-02-23  0:37     ` Lucas De Marchi
  0 siblings, 0 replies; 17+ messages in thread
From: Lucas De Marchi @ 2023-02-23  0:37 UTC (permalink / raw)
  To: Matthew Auld; +Cc: intel-xe

On Wed, Feb 22, 2023 at 10:07:16AM +0000, Matthew Auld wrote:
>On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>>
>> Make 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().
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>Reviewed-by: Matthew Auld <matthew.auld@intel.com>

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

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

end of thread, other threads:[~2023-02-23  0:37 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
2023-02-21 23:33 ` [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static Lucas De Marchi
2023-02-22  9:48   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings Lucas De Marchi
2023-02-22 10:16   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes Lucas De Marchi
2023-02-22 10:02   ` Matthew Auld
2023-02-22 14:59     ` Lucas De Marchi
2023-02-22 17:10       ` Matthew Auld
2023-02-22 17:42         ` Lucas De Marchi
2023-02-21 23:33 ` [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions Lucas De Marchi
2023-02-22 10:05   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter Lucas De Marchi
2023-02-22 10:06   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h Lucas De Marchi
2023-02-22 10:07   ` Matthew Auld
2023-02-23  0:37     ` Lucas De Marchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.