From: Marius Vlad Subject: Re: [PATCH i-g-t] tests/pm_rpm tests for set_caching and set_tiling ioctl(s) Date: Thu, 26 Nov 2015 12:55:39 +0200 Message-ID: <20151126105538.GA26960@mcvlad-wk.rb.intel.com> References: <1448405820.8137.33.camel@intel.com> <1448471779-24328-1-git-send-email-marius.c.vlad@intel.com> <1448471779-24328-2-git-send-email-marius.c.vlad@intel.com> <1448482101.32235.136.camel@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0405248392==" Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F5BE6E9D2 for ; Thu, 26 Nov 2015 02:55:24 -0800 (PST) In-Reply-To: <1448482101.32235.136.camel@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Imre Deak Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0405248392== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 25, 2015 at 10:08:21PM +0200, Imre Deak wrote: > On ke, 2015-11-25 at 19:16 +0200, marius.c.vlad@intel.com wrote: > > From: Marius Vlad > >=20 > > Signed-off-by: Marius Vlad > > --- > > =A0tests/pm_rpm.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++ > > =A01 file changed, 120 insertions(+) > >=20 > > diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c > > index c4fb19c..157cf29 100644 > > --- a/tests/pm_rpm.c > > +++ b/tests/pm_rpm.c > > @@ -1729,6 +1729,120 @@ static void planes_subtest(bool universal, bool= dpms) > > =A0 } > > =A0} > > =A0 > > +static void pm_test_tiling(void) > > +{ > > + uint32_t *handles; > > + uint8_t **gem_bufs; > > + > > + int max_gem_objs =3D 0; > > + uint8_t off_bit =3D 20; > > + uint32_t gtt_obj_max_size =3D (16 * 1024 * 1024); > > + > > + uint32_t i, j, tiling_modes[3] =3D { > > + I915_TILING_NONE, > > + I915_TILING_X, > > + I915_TILING_Y, > > + }; > > + uint32_t ti, sw; > > + > > + /* default value */ > > + uint32_t stride =3D 1024; > > + > > + /* calculate how many objects we can map */ > > + for (j =3D 1 << off_bit; j <=3D gtt_obj_max_size; j <<=3D 1, max_gem_= objs++) > > + ; >=20 > With these sizes we may end up with all objects properly aligned, > that's why I suggested smaller objects. Based on I830_FENCE_START_MASK > we could allocate for example starting from 16kB to 256kB. >=20 Initially, I've tried with smaller sizes, but the assertion(s) failed. I'll try as you suggested. > > + > > + gem_bufs =3D calloc(max_gem_objs, sizeof(uint8_t *)); > > + handles =3D malloc(sizeof(uint32_t) * max_gem_objs); >=20 > Nitpick: sizeof(*ptr) is safer and you could've used calloc in both > cases. Indeed. >=20 > > + > > + /* map to gtt and store some random data */ > > + for (i =3D 0, j =3D 1 << off_bit; j <=3D gtt_obj_max_size; j <<=3D 1,= i++) { > > + handles[i] =3D gem_create(drm_fd, j); > > + gem_bufs[i] =3D gem_mmap__gtt(drm_fd, handles[i], j, PROT_WRITE); > > + memset(gem_bufs[i], 0x65, j); > > + } > > + > > + /* try to set different tiling for each handle */ > > + for (i =3D 0; i < ARRAY_SIZE(tiling_modes); i++) { > > + disable_all_screens_and_wait(&ms_data); > > + > > + for (j =3D 0; j < max_gem_objs; j++) { > > + gem_set_tiling(drm_fd, handles[j], tiling_modes[i], stride); > > + > > + gem_get_tiling(drm_fd, handles[j], &ti, &sw); > > + igt_assert(tiling_modes[i] =3D=3D ti); > > + } > > + > > + enable_one_screen_and_wait(&ms_data); >=20 > Ok, but after the second iteration all objects could be properly > aligned, so it's better to close/realloc/memset the objects in each > iteration. Alright. I'll do that. >=20 > > + } > > + > > + for (i =3D 0, j =3D 1 << off_bit; j <=3D gtt_obj_max_size; j <<=3D 1,= i++) { > > + igt_assert(munmap(gem_bufs[i], j) =3D=3D 0); > > + gem_close(drm_fd, handles[i]); > > + } > > + > > + free(gem_bufs); > > + free(handles); > > +} > > + > > +static void pm_test_caching(void) > > +{ > > + uint32_t *handles; > > + uint8_t **gem_bufs; > > + int8_t has_caching_display =3D -1; > > + > > + uint32_t i, j, got_caching; > > + uint32_t gtt_obj_max_size =3D (16 * 1024 * 1024); > > + uint32_t cache_levels[3] =3D { > > + I915_CACHING_NONE, > > + I915_CACHING_CACHED, /* LLC caching */ > > + I915_CACHING_DISPLAY, /* eDRAM caching */ > > + }; > > + > > + int max_gem_objs =3D 0; > > + uint8_t off_bit =3D 20; > > + > > + for (j =3D 1 << off_bit; j <=3D gtt_obj_max_size; j <<=3D 1, max_gem_= objs++) > > + ; >=20 > No need to bother about alignment here, so we can just use a single > 16kB object for example. Alright. >=20 > > + > > + gem_bufs =3D calloc(max_gem_objs, sizeof(uint8_t *)); > > + handles =3D malloc(sizeof(uint32_t) * max_gem_objs); > > + > > + for (i =3D 0, j =3D 1 << off_bit; j <=3D gtt_obj_max_size; j <<=3D 1,= i++) { > > + handles[i] =3D gem_create(drm_fd, j); > > + gem_bufs[i] =3D gem_mmap__gtt(drm_fd, handles[i], j, PROT_WRITE); > > + memset(gem_bufs[i], 0x65, j); > > + } > > + > > + /* figure out if we have cache display available on the platform */ > > + gem_set_caching(drm_fd, handles[0], I915_CACHING_DISPLAY); > > + if (gem_get_caching(drm_fd, handles[0])) >=20 > No need to hardcode I915_CACHING_NONE here. Also I liked the original > version to check this everywhere better, by accepting both > CACHING_DISPLAY and CACHING_NONE as a result. I don't think I get it. As far as I understand CACHING_DISPLAY will fall-back to CACHING_NONE if the platform doesn't have support for it. Is there a proper way to check for this? igt_require()/igt_skip_on()/igt_require_f() can indeed be used to bypass certain test(s), but there has to be a way to determine apriori if (indeed) the platform supports CACHING_DISPLAY, before asserting the status. Most likely this kind of issue has come up in other circumstances... >=20 > > + has_caching_display++; > > + > > + for (i =3D 0; i < ARRAY_SIZE(cache_levels) + has_caching_display; i++= ) { > > + disable_all_screens_and_wait(&ms_data); > > + > > + for (j =3D 0; j < max_gem_objs; j++) { > > + gem_set_caching(drm_fd, handles[j], cache_levels[i]); > > + > > + igt_debug("Verying cache for handle %u, level %u\n", j, i); > > + got_caching =3D gem_get_caching(drm_fd, handles[j]); > > + > > + igt_assert(got_caching =3D=3D cache_levels[i]); > > + } > > + > > + enable_one_screen_and_wait(&ms_data); >=20 > The object can be unbound after the IOCTL so you need to do a memset at > the begin of each iteration. Okay. Will redo and send another try. Thanks for taking to time to review!. >=20 > > + } > > + > > + for (i =3D 0, j =3D 1 << off_bit; j <=3D gtt_obj_max_size; j <<=3D 1,= i++) { > > + igt_assert(munmap(gem_bufs[i], j) =3D=3D 0); > > + gem_close(drm_fd, handles[i]); > > + } > > + > > + free(handles); > > + free(gem_bufs); > > +} > > + > > =A0static void fences_subtest(bool dpms) > > =A0{ > > =A0 int i; > > @@ -1927,6 +2041,12 @@ int main(int argc, char *argv[]) > > =A0 igt_subtest("gem-execbuf-stress-extra-wait") > > =A0 gem_execbuf_stress_subtest(rounds, WAIT_STATUS | WAIT_EXTRA); > > =A0 > > + /* power-wake reference tests */ > > + igt_subtest("pm-tiling") > > + pm_test_tiling(); > > + igt_subtest("pm-caching") > > + pm_test_caching(); > > + > > =A0 igt_fixture > > =A0 teardown_environment(); > > =A0 --ZPt4rx8FFjLCG7dd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWVuUqAAoJELmLWIAQzyE+lBgH/2pMQgq0VdT4sfTgVcbKgJFR 61wcq5S3XpHv3KrJhIVDGa5j2sJ9S0JSnAeZf5z1pNUj+JIJMnMgNi3RjRZjeGLu Uyxbi4yNQSLvOcBD75t/1a601xL+65iWrv6dNcA31FsTBEImJBzdc5vQkdyXi8uV zHplU5dZPXAn+KiE6ZEt4zNIVLWw3TJHncUD4lTwURfj72i4mT5djXwVsuT255IM 5jXw+hC4F4MDzEniwMQPrRxoLkZtY/FNErxU2s/SVO2LX7rB1TV1uL2ku9azykBY J/942HC63Yctj0BShy8oC+IGGBB4ZiOT+PdTWqy8lGpD7V2yQ4NBy8iNU23/C/o= =s6R7 -----END PGP SIGNATURE----- --ZPt4rx8FFjLCG7dd-- --===============0405248392== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pbnRlbC1nZngK --===============0405248392==--