2022-12-01 12:59:48

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: [PATCH 0/3] Add KUnit support for i915 mock selftests

That's an updated version of my previous KUnit RFC series:
https://patchwork.freedesktop.org/series/110481/

While the RFC series added support for live and perf, let's start with
mock, as running tests in bare metal is not the current focus of KUnit.
So, basically patch 1 was changed to export just mock functions,
and the bare metal patches got removed from this version.

As before, running KUnit on i915 driver requires the --arch parameter:

./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig=drivers/gpu/drm/i915/selftests/ --jobs=`nproc --all`
[13:18:40] Configuring KUnit Kernel ...
[13:18:40] Building KUnit Kernel ...
Populating config with:
$ make ARCH=x86_64 O=.kunit olddefconfig
Building with:
$ make ARCH=x86_64 O=.kunit --jobs=8
[13:23:20] Starting KUnit Kernel (1/1)...
[13:23:20] ============================================================
Running tests with:
$ qemu-system-x86_64 -nodefaults -m 1024 -kernel .kunit/arch/x86/boot/bzImage -append 'kunit.enable=1 console=ttyS0 kunit_shutdown=reboot' -no-reboot -nographic -serial stdio
[13:23:21] ============ i915 mock selftests (18 subtests) =============
[13:23:21] [PASSED] mock_sanitycheck
[13:23:21] [PASSED] mock_shmem
[13:23:24] [PASSED] mock_fence
[13:23:25] [PASSED] mock_scatterlist
[13:23:27] [PASSED] mock_syncmap
[13:23:27] [PASSED] mock_uncore
[13:23:27] [PASSED] mock_ring
[13:23:27] [PASSED] mock_engine
[13:23:31] [PASSED] mock_timelines
[13:23:32] [PASSED] mock_requests
[13:23:32] [PASSED] mock_objects
[13:23:32] [PASSED] mock_phys
[13:23:32] [PASSED] mock_dmabuf
[13:23:38] [PASSED] mock_vma
[13:23:38] [PASSED] mock_evict
[13:23:41] [PASSED] mock_gtt
[13:23:42] [PASSED] mock_hugepages
[13:23:42] [PASSED] mock_memory_region
[13:23:42] =============== [PASSED] i915 mock selftests ===============
[13:23:42] ============================================================
[13:23:42] Testing complete. Ran 18 tests: passed: 18
[13:23:42] Elapsed time: 302.766s total, 0.003s configuring, 280.393s building, 22.341s running

Mauro Carvalho Chehab (3):
drm/i915: place selftest preparation on a separate function
drm/i915: export all mock selftest functions
drm/i915: allow running mock selftests via Kunit

drivers/gpu/drm/i915/Kconfig | 15 +++
drivers/gpu/drm/i915/Makefile | 5 +
.../gpu/drm/i915/gem/selftests/huge_pages.c | 1 +
.../drm/i915/gem/selftests/i915_gem_dmabuf.c | 1 +
.../drm/i915/gem/selftests/i915_gem_object.c | 1 +
.../drm/i915/gem/selftests/i915_gem_phys.c | 1 +
drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 1 +
drivers/gpu/drm/i915/gt/selftest_ring.c | 1 +
drivers/gpu/drm/i915/gt/selftest_timeline.c | 1 +
drivers/gpu/drm/i915/gt/st_shmem_utils.c | 1 +
drivers/gpu/drm/i915/i915_selftest.h | 2 +
drivers/gpu/drm/i915/selftests/.kunitconfig | 12 +++
.../gpu/drm/i915/selftests/i915_gem_evict.c | 1 +
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 1 +
drivers/gpu/drm/i915/selftests/i915_kunit.c | 95 +++++++++++++++++++
drivers/gpu/drm/i915/selftests/i915_request.c | 1 +
.../gpu/drm/i915/selftests/i915_selftest.c | 23 +++--
.../gpu/drm/i915/selftests/i915_sw_fence.c | 1 +
drivers/gpu/drm/i915/selftests/i915_syncmap.c | 1 +
drivers/gpu/drm/i915/selftests/i915_vma.c | 1 +
.../drm/i915/selftests/intel_memory_region.c | 1 +
drivers/gpu/drm/i915/selftests/intel_uncore.c | 1 +
drivers/gpu/drm/i915/selftests/scatterlist.c | 1 +
23 files changed, 161 insertions(+), 8 deletions(-)
create mode 100644 drivers/gpu/drm/i915/selftests/.kunitconfig
create mode 100644 drivers/gpu/drm/i915/selftests/i915_kunit.c

--
2.38.1



2022-12-01 13:00:07

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: [PATCH 1/3] drm/i915: place selftest preparation on a separate function

The selftest preparation logic should also be used by KUnit. So,
place it on a separate function and export it.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 0/3] at: https://lore.kernel.org/all/[email protected]/

drivers/gpu/drm/i915/i915_selftest.h | 2 ++
.../gpu/drm/i915/selftests/i915_selftest.c | 22 ++++++++++++-------
2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_selftest.h b/drivers/gpu/drm/i915/i915_selftest.h
index bdf3e22c0a34..cd0065033ed9 100644
--- a/drivers/gpu/drm/i915/i915_selftest.h
+++ b/drivers/gpu/drm/i915/i915_selftest.h
@@ -44,6 +44,7 @@ struct i915_selftest {

extern struct i915_selftest i915_selftest;

+void i915_prepare_selftests(const char *name);
int i915_mock_selftests(void);
int i915_live_selftests(struct pci_dev *pdev);
int i915_perf_selftests(struct pci_dev *pdev);
@@ -113,6 +114,7 @@ int __i915_subtests(const char *caller,

#else /* !IS_ENABLED(CONFIG_DRM_I915_SELFTEST) */

+static inline void i915_prepare_selftests(const char *) {};
static inline int i915_mock_selftests(void) { return 0; }
static inline int i915_live_selftests(struct pci_dev *pdev) { return 0; }
static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
diff --git a/drivers/gpu/drm/i915/selftests/i915_selftest.c b/drivers/gpu/drm/i915/selftests/i915_selftest.c
index 39da0fb0d6d2..bc85dac4eb15 100644
--- a/drivers/gpu/drm/i915/selftests/i915_selftest.c
+++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c
@@ -127,13 +127,8 @@ static void set_default_test_all(struct selftest *st, unsigned int count)
st[i].enabled = true;
}

-static int __run_selftests(const char *name,
- struct selftest *st,
- unsigned int count,
- void *data)
+void i915_prepare_selftests(const char *name)
{
- int err = 0;
-
while (!i915_selftest.random_seed)
i915_selftest.random_seed = get_random_u32();

@@ -142,10 +137,21 @@ static int __run_selftests(const char *name,
msecs_to_jiffies_timeout(i915_selftest.timeout_ms) :
MAX_SCHEDULE_TIMEOUT;

- set_default_test_all(st, count);
-
pr_info(DRIVER_NAME ": Performing %s selftests with st_random_seed=0x%x st_timeout=%u\n",
name, i915_selftest.random_seed, i915_selftest.timeout_ms);
+}
+EXPORT_SYMBOL_NS_GPL(i915_prepare_selftests, I915_SELFTEST);
+
+static int __run_selftests(const char *name,
+ struct selftest *st,
+ unsigned int count,
+ void *data)
+{
+ int err = 0;
+
+ i915_prepare_selftests(name);
+
+ set_default_test_all(st, count);

/* Tests are listed in order in i915_*_selftests.h */
for (; count--; st++) {
--
2.38.1

2022-12-02 18:53:14

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 1/3] drm/i915: place selftest preparation on a separate function

Hi Mauro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-intel/for-linux-next-fixes drm-tip/drm-tip drm/drm-next drm-misc/drm-misc-next linus/master v6.1-rc7 next-20221202]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Mauro-Carvalho-Chehab/Add-KUnit-support-for-i915-mock-selftests/20221201-203541
base: git://anongit.freedesktop.org/drm-intel for-linux-next
patch link: https://lore.kernel.org/r/c0ebcad250fc68e4822a921d7ea7a63ae16d381f.1669897668.git.mchehab%40kernel.org
patch subject: [PATCH 1/3] drm/i915: place selftest preparation on a separate function
config: i386-randconfig-a004
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/1a66d45e9cb9e62baf4eef1e30ddaed30269d3b9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Mauro-Carvalho-Chehab/Add-KUnit-support-for-i915-mock-selftests/20221201-203541
git checkout 1a66d45e9cb9e62baf4eef1e30ddaed30269d3b9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/gpu/drm/i915/i915_driver.c:52:
In file included from drivers/gpu/drm/i915/display/intel_display_types.h:49:
In file included from drivers/gpu/drm/i915/i915_vma.h:33:
In file included from drivers/gpu/drm/i915/gt/intel_ggtt_fencing.h:12:
In file included from drivers/gpu/drm/i915/i915_active.h:13:
In file included from drivers/gpu/drm/i915/i915_request.h:34:
In file included from drivers/gpu/drm/i915/gem/i915_gem_context_types.h:20:
In file included from drivers/gpu/drm/i915/gt/intel_context_types.h:18:
In file included from drivers/gpu/drm/i915/gt/intel_engine_types.h:23:
>> drivers/gpu/drm/i915/i915_selftest.h:117:55: warning: omitting the parameter name in a function definition is a C2x extension [-Wc2x-extensions]
static inline void i915_prepare_selftests(const char *) {};
^
1 warning generated.
--
In file included from drivers/gpu/drm/i915/i915_sw_fence.c:13:
>> drivers/gpu/drm/i915/i915_selftest.h:117:55: warning: omitting the parameter name in a function definition is a C2x extension [-Wc2x-extensions]
static inline void i915_prepare_selftests(const char *) {};
^
drivers/gpu/drm/i915/i915_sw_fence.c:97:20: warning: unused function 'debug_fence_init_onstack' [-Wunused-function]
static inline void debug_fence_init_onstack(struct i915_sw_fence *fence)
^
drivers/gpu/drm/i915/i915_sw_fence.c:118:20: warning: unused function 'debug_fence_free' [-Wunused-function]
static inline void debug_fence_free(struct i915_sw_fence *fence)
^
3 warnings generated.


vim +117 drivers/gpu/drm/i915/i915_selftest.h

116
> 117 static inline void i915_prepare_selftests(const char *) {};
118 static inline int i915_mock_selftests(void) { return 0; }
119 static inline int i915_live_selftests(struct pci_dev *pdev) { return 0; }
120 static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
121

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (4.01 kB)
config (132.91 kB)
Download all attachments