From patchwork Wed May 31 17:00:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Argenziano X-Patchwork-Id: 9757791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3CF1C603F7 for ; Wed, 31 May 2017 17:01:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D71328420 for ; Wed, 31 May 2017 17:01:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2266328445; Wed, 31 May 2017 17:01:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 41DA128420 for ; Wed, 31 May 2017 17:01:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D799D6E297; Wed, 31 May 2017 17:01:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C92C6E297 for ; Wed, 31 May 2017 17:01:22 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 31 May 2017 10:01:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,275,1493708400"; d="scan'208";a="93986731" Received: from relo-linux-2.fm.intel.com ([10.1.27.122]) by orsmga002.jf.intel.com with ESMTP; 31 May 2017 10:01:16 -0700 From: Antonio Argenziano To: intel-gfx@lists.freedesktop.org Date: Wed, 31 May 2017 10:00:37 -0700 Message-Id: <20170531170037.35344-2-antonio.argenziano@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170531170037.35344-1-antonio.argenziano@intel.com> References: <20170531170037.35344-1-antonio.argenziano@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC i-g-t 1/1] tests/gem_bad_address: Fix and update gem_bad_address X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP When writing to an invalid memory location, the HW should be clever enough to silently discard the write without disrupting execution. gem_bad_address aim at just that. The test has been updated to move away from the libDrm wrappers and use the IOCTL wrappers instead. Also the invalid address has been updated to be just outside of the GTT space. Since the test is considered to be HW focused, meaning that it doesn't really exercise the deriver but rather an HW feature, a new folder has been created to host such tests. The commit moves the test in the newly created folder for HW focused tests. Signed-off-by: Antonio Argenziano --- Makefile.am | 4 ++ configure.ac | 11 ++++++ tests_hw/Makefile.am | 36 ++++++++++++++++++ tests_hw/Makefile.sources | 8 ++++ {tests => tests_hw}/gem_bad_address.c | 69 ++++++++++++++++++++--------------- 5 files changed, 98 insertions(+), 30 deletions(-) create mode 100644 tests_hw/Makefile.am create mode 100644 tests_hw/Makefile.sources rename {tests => tests_hw}/gem_bad_address.c (50%) diff --git a/Makefile.am b/Makefile.am index 60168628..dca76bf0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,6 +23,10 @@ ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4 SUBDIRS = lib man tools scripts benchmarks +if BUILD_HW_TESTS +SUBDIRS += tests_hw +endif + if BUILD_TESTS SUBDIRS += tests endif diff --git a/configure.ac b/configure.ac index 5342e33c..85885f25 100644 --- a/configure.ac +++ b/configure.ac @@ -333,6 +333,15 @@ fi AM_CONDITIONAL(BUILD_TESTS, [test "x$BUILD_TESTS" = xyes]) AC_DEFINE_UNQUOTED(TARGET_CPU_PLATFORM, ["$host_cpu"], [Target platform]) +AC_ARG_ENABLE(tests_hw, + AS_HELP_STRING([--disable-hw-tests], + [Disable HW tests build (default: enabled)]), + [BUILD_HW_TESTS=$enableval], [BUILD_HW_TESTS="yes"]) +if test "x$BUILD_TESTS" = xyes; then + AC_DEFINE(BUILD_HW_TESTS, 1, [Build hw tests]) +fi +AM_CONDITIONAL(BUILD_HW_TESTS, [test "x$BUILD_HW_TESTS" = xyes]) + files="broadwell cherryview haswell ivybridge sandybridge valleyview skylake" for file in $files; do REGISTER_FILES="$REGISTER_FILES $file `cat $srcdir/tools/registers/$file`" @@ -353,6 +362,7 @@ AC_CONFIG_FILES([ man/Makefile scripts/Makefile tests/Makefile + tests_hw/Makefile tools/Makefile tools/null_state_gen/Makefile tools/registers/Makefile @@ -376,6 +386,7 @@ echo "Intel GPU tools" echo "" echo " • Tests:" echo " Build tests : ${BUILD_TESTS}" +echo " Build hw tests : ${BUILD_HW_TESTS}" echo " Compile prime tests: ${NOUVEAU}" echo " Print stack traces : ${with_libunwind}" echo " Debug flags : ${DEBUG_CFLAGS}" diff --git a/tests_hw/Makefile.am b/tests_hw/Makefile.am new file mode 100644 index 00000000..36ed9eb9 --- /dev/null +++ b/tests_hw/Makefile.am @@ -0,0 +1,36 @@ +include Makefile.sources + +if BUILD_HW_TESTS + +hw-test-list.txt: Makefile.sources + @echo TESTLIST > $@ + @echo ${hw_tests_all} >> $@ + @echo TESTLIST >> $@ + +all-local: .gitignore +.gitignore: Makefile.sources + @echo "$(HW_TESTS_PROGS) hw-test-list.txt .gitignore" | sed 's/\s\+/\n/g' | sort > $@ + +pkglibexec_PROGRAMS = \ + $(HW_TESTS_PROGS) \ + $(NULL) + +pkgdata_DATA = hw-test-list.txt + +CLEANFILES = hw-test-list.txt .gitignore + +AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\ + -I$(srcdir)/.. \ + -I$(srcdir)/../lib \ + -include "$(srcdir)/../lib/check-ndebug.h" \ + -DIGT_SRCDIR=\""$(abs_srcdir)"\" \ + -DIGT_DATADIR=\""$(pkgdatadir)"\" \ + $(LIBUNWIND_CFLAGS) $(WERROR_CFLAGS) \ + $(NULL) + +LDADD = ../lib/libintel_tools.la $(GLIB_LIBS) $(XMLRPC_LIBS) $(DLOPEN_LIBS) + +AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) +AM_LDFLAGS = -Wl,--as-needed + +endif diff --git a/tests_hw/Makefile.sources b/tests_hw/Makefile.sources new file mode 100644 index 00000000..25d181c0 --- /dev/null +++ b/tests_hw/Makefile.sources @@ -0,0 +1,8 @@ +HW_TESTS_PROGS = \ + gem_bad_address \ + $(NULL) + +#This target contains all testcases +hw_tests_all = \ + $(HW_TESTS_PROGS) \ + $(NULL) diff --git a/tests/gem_bad_address.c b/tests_hw/gem_bad_address.c similarity index 50% rename from tests/gem_bad_address.c rename to tests_hw/gem_bad_address.c index a970dfa4..c254f894 100644 --- a/tests/gem_bad_address.c +++ b/tests_hw/gem_bad_address.c @@ -23,37 +23,53 @@ * Authors: * Eric Anholt * Jesse Barnes (based on gem_bad_blit.c) + * Antonio Argenziano * */ #include "igt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "drm.h" -#include "intel_bufmgr.h" -static drm_intel_bufmgr *bufmgr; -struct intel_batchbuffer *batch; - -#define BAD_GTT_DEST ((512*1024*1024)) /* past end of aperture */ +/* + * This test aims at verifying that writing to an invalid location in memory, + * doesn't cause hangs. The store command should be ignored completely by the + * HW and the whole process should be transparent to the user. Therefore, + * the test doesn't perform any validation check but expects the wrapping + * execution environment to check no hangs have occurred. + * + * The test needs to send a privileged batch to be able to write to the GTT. + */ static void -bad_store(void) +bad_store(uint32_t fd, uint32_t engine) { - BEGIN_BATCH(4, 0); - OUT_BATCH(MI_STORE_DWORD_IMM | MI_MEM_VIRTUAL | 1 << 21); - OUT_BATCH(0); - OUT_BATCH(BAD_GTT_DEST); - OUT_BATCH(0xdeadbeef); - ADVANCE_BATCH(); + struct drm_i915_gem_exec_object2 obj; + struct drm_i915_gem_execbuffer2 execbuf; + + uint32_t batch[16]; + int i = 0; + + memset(&obj, 0, sizeof(obj)); + memset(&execbuf, 0, sizeof(execbuf)); + + execbuf.buffers_ptr = to_user_pointer(&obj); + execbuf.buffer_count = 1; + execbuf.flags = engine; + execbuf.flags |= I915_EXEC_SECURE; - intel_batchbuffer_flush(batch); + obj.handle = gem_create(fd, 4096); + + batch[i++] = MI_STORE_DWORD_IMM | MI_MEM_VIRTUAL; + batch[i++] = 0x0; //Low part of the GTT address = 4GByte + batch[i++] = 0x1; //High part of the GTT address > GTT size + batch[i++] = 0xdeadbeef; + + batch[i++] = MI_BATCH_BUFFER_END; + batch[i++] = 0x0; + + gem_write(fd, obj.handle, 0, batch, sizeof(batch)); + gem_execbuf(fd, &execbuf); + + gem_close(fd, obj.handle); } igt_simple_main @@ -62,14 +78,7 @@ igt_simple_main fd = drm_open_driver(DRIVER_INTEL); - bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); - drm_intel_bufmgr_gem_enable_reuse(bufmgr); - batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); - - bad_store(); - - intel_batchbuffer_free(batch); - drm_intel_bufmgr_destroy(bufmgr); + bad_store(fd, I915_EXEC_BLT); close(fd); }