From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marius Vlad 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 14:47:56 +0200 Message-ID: <20161030124755.txeiuzzdlue2y6wh@mcvlad-wk.rb.intel.com> References: <20161028093129.13275-1-marius.c.vlad@intel.com> <20161028093129.13275-3-marius.c.vlad@intel.com> <20161028100819.GD29769@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1866557264==" Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 02DC189D79 for ; Sun, 30 Oct 2016 12:41:44 +0000 (UTC) In-Reply-To: <20161028100819.GD29769@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson , intel-gfx@lists.freedesktop.org, petri.latvala@intel.com, jani.nikula@linux.intel.com, daniel@ffwll.ch List-Id: intel-gfx@lists.freedesktop.org --===============1866557264== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fmswwspi3stxlpd6" Content-Disposition: inline --fmswwspi3stxlpd6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 > > --- > > lib/igt_gvt.c | 42 +++++++++++++++++++++++++++++++++++------- > > tests/gvt_basic.c | 2 +- > > 2 files changed, 36 insertions(+), 8 deletions(-) > >=20 > > 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" > > =20 > > +#include > > #include > > #include > > #include > > +#include > > =20 > > static bool is_gvt_enabled(void) > > { > > FILE *file; > > - int value; > > + char value; > > bool enabled =3D false; > > =20 > > file =3D fopen("/sys/module/i915/parameters/enable_gvt", "r"); > > if (!file) > > return false; > > =20 > > - if (fscanf(file, "%d", &value) =3D=3D 1) > > - enabled =3D value; > > + if (fscanf(file, "%c", &value) =3D=3D 1) > > + enabled =3D (value =3D=3D 'Y' ? true : false); > enabled =3D value =3D=3D 'Y'; > else if (fscanf(file, "%d", &value) =3D=3D 1) > enabled =3D value; >=20 > Do I see a igt_kmod_parameter_get_boolean() in the future, I think I do! >=20 > > fclose(file); > > =20 > > errno =3D 0; > > @@ -50,9 +53,20 @@ static bool is_gvt_enabled(void) > > static void unload_i915(void) > > { > > kick_fbcon(false); > > - /* pkill alsact */ > > =20 > > - 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)); >=20 > 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. >=20 > 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. > -Chris >=20 > --=20 > Chris Wilson, Intel Open Source Technology Centre --fmswwspi3stxlpd6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAABCAAGBQJYFev7AAoJELmLWIAQzyE+xKcH/jWZ1Ql4y7Vl/qqgZgmgXDYq mvT2LfBZ2ub934i5qyPRCi5NWvol74b5hahIG6e5szVXqEGxGEGYzJhs81vYL9Ds l1eRswOllgLqdi6Do1Y77RYH5Lebj3+17+fpgUExv6/gf5MTM6+woH84WUvcd59B Jkqf62jL4kzSta9Z0nhfho7d/hjfrOUUmqNjnJziyTHedLmyJnFy757rPROKAV+G llzZNl4bhGUqxSLwsD6MFTDMu32mM5PQfduYmY3zQafdOJCEV6IQyNgnqXLt3j73 UqpFFPic+bkz7g0DhhN4hsNxmI33o0DiwjFfaiSRKn/sDpF737Vf2aQfFRQiUO8= =1/1M -----END PGP SIGNATURE----- --fmswwspi3stxlpd6-- --===============1866557264== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============1866557264==--