All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org, petri.latvala@intel.com,
	jani.nikula@linux.intel.com, daniel@ffwll.ch
Subject: Re: [PATCH i-g-t 2/4 v4] lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter.
Date: Sun, 30 Oct 2016 12:59:12 +0000	[thread overview]
Message-ID: <20161030125912.GA6896@nuc-i3427.alporthouse.com> (raw)
In-Reply-To: <20161030124755.txeiuzzdlue2y6wh@mcvlad-wk.rb.intel.com>

On Sun, Oct 30, 2016 at 02:47:56PM +0200, Marius Vlad wrote:
> On Fri, Oct 28, 2016 at 11:08:19AM +0100, Chris Wilson wrote:
> > On Fri, Oct 28, 2016 at 12:31:27PM +0300, Marius Vlad wrote:
> > > Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
> > > ---
> > >  lib/igt_gvt.c     | 42 +++++++++++++++++++++++++++++++++++-------
> > >  tests/gvt_basic.c |  2 +-
> > >  2 files changed, 36 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/lib/igt_gvt.c b/lib/igt_gvt.c
> > > index 8bbf9bd..d868cb3 100644
> > > --- a/lib/igt_gvt.c
> > > +++ b/lib/igt_gvt.c
> > > @@ -24,23 +24,26 @@
> > >  #include "igt.h"
> > >  #include "igt_gvt.h"
> > >  #include "igt_sysfs.h"
> > > +#include "igt_kmod.h"
> > >  
> > > +#include <signal.h>
> > >  #include <dirent.h>
> > >  #include <unistd.h>
> > >  #include <fcntl.h>
> > > +#include <time.h>
> > >  
> > >  static bool is_gvt_enabled(void)
> > >  {
> > >  	FILE *file;
> > > -	int value;
> > > +	char value;
> > >  	bool enabled = false;
> > >  
> > >  	file = fopen("/sys/module/i915/parameters/enable_gvt", "r");
> > >  	if (!file)
> > >  		return false;
> > >  
> > > -	if (fscanf(file, "%d", &value) == 1)
> > > -		enabled = value;
> > > +	if (fscanf(file, "%c", &value) == 1)
> > > +		enabled = (value == 'Y' ? true : false);
> > 	enabled = value == 'Y';
> > else if (fscanf(file, "%d", &value) == 1)
> > 	enabled = value;
> > 
> > Do I see a igt_kmod_parameter_get_boolean() in the future, I think I do!
> > 
> > >  	fclose(file);
> > >  
> > >  	errno = 0;
> > > @@ -50,9 +53,20 @@ static bool is_gvt_enabled(void)
> > >  static void unload_i915(void)
> > >  {
> > >  	kick_fbcon(false);
> > > -	/* pkill alsact */
> > >  
> > > -	igt_ignore_warn(system("/sbin/modprobe -s -r i915"));
> > > +
> > > +	if (igt_kmod_is_loaded("i915")) {
> > > +
> > > +		if (igt_kmod_is_loaded("snd_hda_intel")) {
> > > +			igt_assert(!igt_pkill(SIGTERM, "alsactl"));
> > > +			igt_assert(!igt_kmod_unload("snd_hda_intel", 0));
> > > +		}
> > > +
> > > +		igt_assert(!igt_kmod_unload("i915", 0));
> > > +		igt_assert(!igt_kmod_unload("drm_kms_helper", 0));
> > > +		igt_assert(!igt_kmod_unload("drm", 0));
> > 
> > But don't we already have this routine...
> 
> No. But I guess I can add a driver_load()/driver_unload() in
> lib/igt_kmod which does that, if that is what you meant.

This is the same sequence as required for reloading any kms driver.
However, note here we only require i915 to be reloaded, we can avoid
taking further risk in reloading the drm layer. So perhaps we don't want
the same code here as drv_module_reload. (Or a more complete interface
that gives finer control.)

> > 
> > For this test, we shouldn't fail if we can't setup the environment as we
> > need, but skip the test.
> 
> Right, maybe I got it wrong, but you call
> igt_require(igt_gvt_load_module()) which in turn calls is_gvt_enabled().
> igt_require will skip if igt_gvt_load_module() is false. That is why I
> kept like that. Besides that, I haven't checked what happens when the
> modules are built-in, so the assert might fail in that case.

The asserts are indeed testing something unrelated to the test, only the
setup of its environment. If we can't set up the environment for the
test, we skip.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-10-30 12:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28  9:31 [PATCH i-g-t 0/4 v4] Convert sh scripts to C variants Marius Vlad
2016-10-28  9:31 ` [PATCH i-g-t 1/4 v4] lib/{igt_sysfs, igt_aux}: Make available to other users kick_fbcon() (unbind_fbcon()), and added helpers to lib/igt_aux, lib/igt_kmod Marius Vlad
2016-11-26 15:31   ` Chris Wilson
2016-10-28  9:31 ` [PATCH i-g-t 2/4 v4] lib/igt_gvt: Make use of libkmod helpers and fix reading gvt parameter Marius Vlad
2016-10-28 10:08   ` Chris Wilson
2016-10-30 12:47     ` Marius Vlad
2016-10-30 12:59       ` Chris Wilson [this message]
2016-10-28  9:31 ` [PATCH i-g-t 3/4 v4] tests/drv_module_reload: Convert sh script to C version Marius Vlad
2016-10-28  9:48   ` Chris Wilson
2016-10-30 10:53     ` Marius Vlad
2016-10-28  9:31 ` [PATCH i-g-t 4/4 v4] tests/kms_sysfs_edid_timing: Convert sh " Marius Vlad
2016-10-28 10:03   ` Chris Wilson
2016-10-30 11:41     ` Marius Vlad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161030125912.GA6896@nuc-i3427.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.