[igt-dev] [PATCH i-g-t] igt/kms_frontbuffer_tracking: Restore modparams around test

Paulo Zanoni paulo.r.zanoni at intel.com
Mon Aug 6 20:56:15 UTC 2018


Em Seg, 2018-08-06 às 21:22 +0100, Chris Wilson escreveu:
> Save the module parameters from setup and restore them on teardown,
> so
> that we leave the system in the same state as we found it.

Currently kms_fbt uses igt_set_module_param_int() which uses
igt_save_module_param(), which installs an exit handler, which is
already supposed to accomplish what's described in the sentence above.
What's missing from the current exit handler? Why is the new strategy
better?

Thanks,
Paulo

> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  tests/kms_frontbuffer_tracking.c | 43 +++++++++++++++++++++++++++++-
> --
>  1 file changed, 39 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/kms_frontbuffer_tracking.c
> b/tests/kms_frontbuffer_tracking.c
> index 1dfd7c1ce..503a6fb6d 100644
> --- a/tests/kms_frontbuffer_tracking.c
> +++ b/tests/kms_frontbuffer_tracking.c
> @@ -155,6 +155,7 @@ struct rect {
>  struct {
>  	int fd;
>  	int debugfs;
> +	int modparams;
>  	igt_display_t display;
>  
>  	drm_intel_bufmgr *bufmgr;
> @@ -939,10 +940,10 @@ static bool
> drrs_wait_until_rr_switch_to_low(void)
>  	return igt_wait(is_drrs_low(), 5000, 1);
>  }
>  
> -#define fbc_enable() igt_set_module_param_int("enable_fbc", 1)
> -#define fbc_disable() igt_set_module_param_int("enable_fbc", 0)
> -#define psr_enable() igt_set_module_param_int("enable_psr", 1)
> -#define psr_disable() igt_set_module_param_int("enable_psr", 0)
> +#define fbc_enable() igt_sysfs_set(drm.modparams, "enable_fbc", "1")
> +#define fbc_disable() igt_sysfs_set(drm.modparams, "enable_fbc",
> "0")
> +#define psr_enable() igt_sysfs_set(drm.modparams, "enable_psr", "1")
> +#define psr_disable() igt_sysfs_set(drm.modparams, "enable_psr",
> "0")
>  #define drrs_enable()	drrs_set(1)
>  #define drrs_disable()	drrs_set(0)
>  
> @@ -1286,6 +1287,7 @@ static void setup_drm(void)
>  {
>  	drm.fd = drm_open_driver_master(DRIVER_INTEL);
>  	drm.debugfs = igt_debugfs_dir(drm.fd);
> +	drm.modparams = igt_sysfs_open_parameters(drm.fd);
>  
>  	kmstest_set_vt_graphics_mode();
>  	igt_display_init(&drm.display, drm.fd);
> @@ -1299,6 +1301,7 @@ static void teardown_drm(void)
>  {
>  	drm_intel_bufmgr_destroy(drm.bufmgr);
>  	igt_display_fini(&drm.display);
> +	close(drm.modparams);
>  	close(drm.fd);
>  }
>  
> @@ -1467,11 +1470,40 @@ static void setup_drrs(void)
>  	drrs.can_test = true;
>  }
>  
> +static struct {
> +	const char *param;
> +	char buf[12];
> +	int len;
> +} modparams[] = {
> +	{ "enable_psr" },
> +	{ "enable_fbc" },
> +	{ }
> +};
> +
> +static void save_modparams(void)
> +{
> +	for (typeof(*modparams) *p = modparams; p->param; p++)
> +		p->len = igt_sysfs_read(drm.modparams,
> +					p->param, p->buf, sizeof(p-
> >buf));
> +}
> +
> +static void restore_modparams(void)
> +{
> +	for (typeof(*modparams) *p = modparams; p->param; p++) {
> +		if (p->len <= 0)
> +			continue;
> +
> +		igt_sysfs_write(drm.modparams, p->param, p->buf, p-
> >len);
> +	}
> +}
> +
>  static void setup_environment(void)
>  {
>  	setup_drm();
>  	setup_modeset();
>  
> +	save_modparams();
> +
>  	setup_fbc();
>  	setup_psr();
>  	setup_drrs();
> @@ -1486,6 +1518,9 @@ static void teardown_environment(void)
>  	teardown_crcs();
>  	teardown_psr();
>  	teardown_fbc();
> +
> +	restore_modparams();
> +
>  	teardown_modeset();
>  	teardown_drm();
>  }


More information about the igt-dev mailing list