[Intel-gfx] [PATCH i-g-t 1/2] lib: Open debugfs files for the given DRM device
Chris Wilson
chris at chris-wilson.co.uk
Wed Mar 8 15:15:40 UTC 2017
On Wed, Mar 08, 2017 at 02:29:59PM +0100, Tomeu Vizoso wrote:
> When opening a DRM debugfs file, locate the right path based on the
> given DRM device FD.
>
> This is needed so, in setups with more than one DRM device, any
> operations on debugfs files affect the expected DRM device.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
>
> ---
>
> Guess we could be more conservative and just rename the existing
> functions to have a _legacy postfix and have the new ones accept a FD
> param. Then existing i915-specific code could keep opening the first
> debugfs dir that contains i915-prefixed files and only the generic tests
> would need to be changed to pass the DRM fd.
>
> But the "right" thing to do is to not assume that there's only one DRM
> device on the system, so maybe we want to do the changes in this patch.
Indeed, flag day and get it over with.
> static void pipe_crc_exit_handler(int sig)
> {
> - igt_pipe_crc_reset();
> + struct dirent *dirent;
> + char buf[128];
> + DIR *dir;
> + int fd;
> +
> + dir = opendir("/dev/dri");
> + if (!dir)
> + return;
> +
> + /*
> + * Try to reset CRC capture for all DRM devices, this is only needed
> + * for the legacy CRC ABI and can be completely removed once the
> + * legacy codepaths are removed.
> + */
> + while ((dirent = readdir(dir))) {
> + if (strncmp(dirent->d_name, "card", 4) != 0)
> + continue;
> +
> + sprintf(buf, "/dev/dri/%s", dirent->d_name);
> + fd = open(buf, O_WRONLY);
> +
> + igt_pipe_crc_reset(fd);
> +
> + close(fd);
> + }
> + closedir(dir);
> }
To be strict, we shouldn't be doing these operation inside an exit
handler as they need to be signalsafe.
Other than that, pretty mechanical and we should try to get the big
change in first and bikeshed later.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list