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);

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.

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

Note : This functions doesn't automatically resolve other module dependencies so make make sure you load the dependencies module(s) before this one.


igt_kmod_unload ()

int
igt_kmod_unload (const char *mod_name,
                 unsigned int flags);

Parameters

mod_name

Module name.

 

flags

flags are passed directly to libkmod and can be: KMOD_REMOVE_FORCE or KMOD_REMOVE_NOWAIT.

 

Returns

0 in case of success or -errno otherwise.

Removes the module mod_name .


igt_i915_driver_load ()

int
igt_i915_driver_load (const char *opts);

Loads the i915 driver and its dependencies.

Parameters

opts

options to pass to i915 driver

 

igt_i915_driver_unload ()

int
igt_i915_driver_unload (void);

Unloads the i915 driver and its dependencies.


igt_kselftests ()

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

igt_kselftest_init ()

int
igt_kselftest_init (struct igt_kselftest *tst,
                    const char *module_name);

igt_kselftest_begin ()

int
igt_kselftest_begin (struct igt_kselftest *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_kselftest *tst,
                       struct igt_kselftest_list *tl,
                       const char *module_options,
                       const char *result);

igt_kselftest_end ()

void
igt_kselftest_end (struct igt_kselftest *tst);

igt_kselftest_fini ()

void
igt_kselftest_fini (struct igt_kselftest *tst);

Types and Values

struct igt_kselftest

struct igt_kselftest {
	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[];
};