Re: [PATCH i-g-t 2/3] tests/drv_module_reload_basic: Convert sh script to C version.

Chris Wilson
2016-10-24T20:34:21Z

On Mon, Oct 24, 2016 at 09:05:28PM +0300, Marius Vlad wrote:
> On Thu, Oct 20, 2016 at 08:52:23PM +0100, Chris Wilson wrote:
> > On Thu, Oct 20, 2016 at 10:36:48PM +0300, Marius Vlad wrote:
> > > +static const char *tests[] = {
> > > + "gem_alive", "gem_exec_store"
> > > +};
> >
> > gem_alive is just a single ioctl query, simpler and move obvious to do
> > it inline. Then remove tests/gem_alive.c, but it may live on as
> > tools/gem_alive.c (or better yet tools/gem_info.c).
> >
> > gem_exec_store is a couple of ioctls...
> Initially I tried embeddeding them directly. Problem is the at exit drm
> fd handler:
>
> if (is_i915_device(fd)) {
> if (__sync_fetch_and_add(&open_count, 1) == 0) {
> gem_quiescent_gpu(fd);
>
> at_exit_drm_fd = __drm_open_driver(chipset); <-- leaked until igt_exit, at_exit(), exit.
> igt_install_exit_handler(quiescent_gpu_at_exit);
> }
> }
>
> A drm_open_driver() w/o that opened fd allows reloading the driver after
> running those basic tests/subtests.

Ah, yes, for module reload in C, you have to use __drm_open_driver() to
avoid that stray open device filehandle.
-Chris

--
Chris Wilson, Intel Open Source Technology Centre