kmod

kmod — Wrappers around libkmod for module loading/unloading

Functions

Types and Values

Includes

#include <igt.h>

Description

This library provides helpers to load/unload module driver.

Note on loading/reloading:

Loading/unload/reloading the driver requires that resources to /dev/dri to be released (closed). A potential mistake would be to submit commands to the GPU by having a fd returned by drm_open_driver , which is closed by atexit signal handler so reloading/unloading the driver will fail if performed afterwards. One possible solution to this issue is to use __drm_open_driver() or use igt_set_module_param() to set module parameters dynamically.

Functions

igt_kmod_is_loaded ()

bool
igt_kmod_is_loaded (const char *mod_name);

Parameters

mod_name

The name of the module.

 

Returns

True in case the module has been found or false otherwise.

Function to check the existance of module mod_name in list of loaded kernel modules.


igt_kmod_list_loaded ()

void
igt_kmod_list_loaded (void);

igt_kmod_has_param ()

bool
igt_kmod_has_param (const char *mod_name,
                    const char *param);

Parameters

mod_name

The name of the module

 

param

The name of the parameter

 

Returns

true if the module has the parameter, false otherwise.


igt_kmod_load ()

int
igt_kmod_load (const char *mod_name,
               const char *opts);

This function loads a kernel module using the name specified in mod_name .

Parameters

mod_name

The name of the module

 

opts

Parameters for the module. NULL in case no parameters are to be passed, or a '\0' terminated string otherwise.

 

Returns

0 in case of success or -errno in case the module could not be loaded.


igt_kmod_unload ()

int
igt_kmod_unload (const char *mod_name);

Parameters

mod_name

Module name.

 

Returns

0 in case of success or -errno otherwise.

Removes the module mod_name .


igt_audio_driver_unload ()

int
igt_audio_driver_unload (char **whom);

igt_intel_driver_load ()

int
igt_intel_driver_load (const char *opts,
                       const char *driver);

Loads an Intel driver and its dependencies.

Parameters

opts

options to pass to Intel driver

 

igt_intel_driver_unload ()

int
igt_intel_driver_unload (const char *driver);

Unloads an Intel driver and its dependencies.


igt_amdgpu_driver_load ()

int
igt_amdgpu_driver_load (const char *opts);

Parameters

opts

options to pass to amdgpu driver

 

Returns

IGT_EXIT_SUCCESS or IGT_EXIT_FAILURE.

Loads the amdgpu driver and its dependencies.


igt_amdgpu_driver_unload ()

int
igt_amdgpu_driver_unload (void);

Returns

IGT_EXIT_SUCCESS on success, IGT_EXIT_FAILURE on failure and IGT_EXIT_SKIP if amdgpu could not be unloaded.

Unloads the amdgpu driver and its dependencies.


igt_kunit ()

void
igt_kunit (const char *module_name,
           const char *name,
           const char *opts);

Loads the test module, parses its (k)tap dmesg output, then unloads it

Parameters

module_name

the name of the module

 

suite

the name of test suite to be executed, also used as subtest name; if NULL then test cases from all test suites provided by the module are executed as dynamic sub-subtests of one IGT subtest, which name is derived from the module name by cutting off its optional trailing _test or _kunit suffix

 

opts

options to load the module

 

igt_kselftests ()

void
igt_kselftests (const char *module_name,
                const char *module_options,
                const char *result_option,
                const char *filter);

igt_ktest_init ()

int
igt_ktest_init (struct igt_ktest *tst,
                const char *module_name);

igt_ktest_begin ()

int
igt_ktest_begin (struct igt_ktest *tst);

igt_kselftest_get_tests ()

void
igt_kselftest_get_tests (struct kmod_module *kmod,
                         const char *filter,
                         struct igt_list_head *tests);

igt_kselftest_execute ()

int
igt_kselftest_execute (struct igt_ktest *tst,
                       struct igt_kselftest_list *tl,
                       const char *module_options,
                       const char *result);

igt_ktest_end ()

void
igt_ktest_end (struct igt_ktest *tst);

igt_ktest_fini ()

void
igt_ktest_fini (struct igt_ktest *tst);

Types and Values

struct igt_ktest

struct igt_ktest {
	struct kmod_module *kmod;
	char *module_name;
	int kmsg;
};

struct igt_kselftest_list

struct igt_kselftest_list {
	struct igt_list_head link;
	unsigned int number;
	char *name;
	char param[];
};