From: kevin.rogovin@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Kevin Rogovin <kevin.rogovin@intel.com>
Subject: [PATCH 2/3] i965: define stuff for scratch page checking in intel_screen
Date: Tue, 5 Dec 2017 09:48:13 +0200 [thread overview]
Message-ID: <1512460094-4615-3-git-send-email-kevin.rogovin@intel.com> (raw)
In-Reply-To: <1512460094-4615-1-git-send-email-kevin.rogovin@intel.com>
From: Kevin Rogovin <kevin.rogovin@intel.com>
---
src/intel/common/gen_debug.c | 1 +
src/intel/common/gen_debug.h | 1 +
src/mesa/drivers/dri/i965/intel_screen.c | 26 ++++++++++++++++++++++++++
src/mesa/drivers/dri/i965/intel_screen.h | 12 ++++++++++++
4 files changed, 40 insertions(+)
diff --git a/src/intel/common/gen_debug.c b/src/intel/common/gen_debug.c
index f58c593c44..7bd6723311 100644
--- a/src/intel/common/gen_debug.c
+++ b/src/intel/common/gen_debug.c
@@ -84,6 +84,7 @@ static const struct debug_control debug_control[] = {
{ "nohiz", DEBUG_NO_HIZ },
{ "color", DEBUG_COLOR },
{ "reemit", DEBUG_REEMIT },
+ { "check_scratch", DEBUG_CHECK_SCRATH },
{ NULL, 0 }
};
diff --git a/src/intel/common/gen_debug.h b/src/intel/common/gen_debug.h
index e418e3fb16..5e224a45f0 100644
--- a/src/intel/common/gen_debug.h
+++ b/src/intel/common/gen_debug.h
@@ -83,6 +83,7 @@ extern uint64_t INTEL_DEBUG;
#define DEBUG_NO_HIZ (1ull << 39)
#define DEBUG_COLOR (1ull << 40)
#define DEBUG_REEMIT (1ull << 41)
+#define DEBUG_CHECK_SCRATH (1ull << 42)
#ifdef HAVE_ANDROID_PLATFORM
#define LOG_TAG "INTEL-MESA"
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 38769babf0..044be8fe85 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1557,6 +1557,12 @@ intelDestroyScreen(__DRIscreen * sPriv)
brw_bufmgr_destroy(screen->bufmgr);
driDestroyOptionInfo(&screen->optionCache);
+ if (screen->debug_batchbuffer.enabled) {
+ simple_mtx_destroy(&screen->debug_batchbuffer.mutex);
+ free(screen->debug_batchbuffer.noise_values);
+ free(screen->debug_batchbuffer.tmp);
+ }
+
ralloc_free(screen);
sPriv->driverPrivate = NULL;
}
@@ -2610,6 +2616,26 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
}
}
+ screen->debug_batchbuffer.enabled = false;
+ if (INTEL_DEBUG & DEBUG_CHECK_SCRATH) {
+ struct drm_i915_scratch_page sc;
+ int err;
+
+ sc.buffer_size = 0;
+ sc.buffer_ptr = 0;
+ err = drmIoctl(dri_screen->fd, DRM_IOCTL_I915_READ_SCRATCH_PAGE, &sc);
+ if (err == 0) {
+ screen->debug_batchbuffer.enabled = true;
+ simple_mtx_init(&screen->debug_batchbuffer.mutex, mtx_plain);
+ screen->debug_batchbuffer.buffer_size = sc.buffer_size;
+ screen->debug_batchbuffer.noise_values = calloc(screen->debug_batchbuffer.buffer_size, 1);
+ screen->debug_batchbuffer.tmp = calloc(screen->debug_batchbuffer.buffer_size, 1);
+ for (uint64_t i = 0; i < screen->debug_batchbuffer.buffer_size; ++i) {
+ screen->debug_batchbuffer.noise_values[i] = rand() & 0xFF;
+ }
+ }
+ }
+
return (const __DRIconfig**) intel_screen_make_configs(dri_screen);
}
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
index 7948617b7f..7d56106aa2 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -37,6 +37,7 @@
#include "common/gen_device_info.h"
#include "i915_drm.h"
#include "util/xmlconfig.h"
+#include "util/simple_mtx.h"
#include "isl/isl.h"
@@ -114,6 +115,17 @@ struct intel_screen
*/
int eu_total;
+ /**
+ * Struct to perform out-of-bound GEM BO write checking
+ */
+ struct {
+ bool enabled;
+ simple_mtx_t mutex;
+ uint32_t buffer_size;
+ uint8_t *noise_values;
+ uint8_t *tmp;
+ } debug_batchbuffer;
+
bool mesa_format_supports_texture[MESA_FORMAT_COUNT];
bool mesa_format_supports_render[MESA_FORMAT_COUNT];
enum isl_format mesa_to_isl_render_format[MESA_FORMAT_COUNT];
--
2.15.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-12-05 7:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 7:48 [PATCH 0/3] RFC: Scratch page checking kevin.rogovin
2017-12-05 7:48 ` [PATCH 1/3] drm-uapi: define interface to kernel for scratch page read kevin.rogovin
2017-12-05 7:57 ` Rogovin, Kevin
2017-12-05 7:48 ` kevin.rogovin [this message]
2017-12-05 7:58 ` [PATCH 2/3] i965: define stuff for scratch page checking in intel_screen Rogovin, Kevin
2017-12-05 7:48 ` [PATCH 3/3] i965: check scratch page in a locked fashion on each ioctl kevin.rogovin
2017-12-05 10:07 ` Chris Wilson
2017-12-05 10:30 ` Rogovin, Kevin
2017-12-05 10:39 ` Chris Wilson
2017-12-05 10:41 ` Rogovin, Kevin
2017-12-05 13:59 ` Joonas Lahtinen
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=1512460094-4615-3-git-send-email-kevin.rogovin@intel.com \
--to=kevin.rogovin@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox