fs debugging: incorporated Chris' feedback
cover fs debugging: incorporated Chris' feedback
This is the revised patch series for fragment shader debugging.
There is no major change, though of interest are:
* forcewaked acts more like a daemon
* forcewaked isn't needed for debugging only there for sample
* i915 detection is now done by stating i915_forcewake_user_lock
* register range checking fails for gen2/gen3
drm:
intel/Makefile.am | 3 ++- intel/intel_debug.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletions(-)
mesa:
src/mesa/drivers/dri/i965/Makefile | 1 + src/mesa/drivers/dri/i965/brw_context.h | 6 + src/mesa/drivers/dri/i965/brw_eu.c | 6 + src/mesa/drivers/dri/i965/brw_eu.h | 1 + src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 15 +- src/mesa/drivers/dri/i965/brw_misc_state.c | 12 +- src/mesa/drivers/dri/i965/brw_state.h | 6 +- src/mesa/drivers/dri/i965/brw_state_cache.c | 49 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 18 +- src/mesa/drivers/dri/i965/brw_wm.c | 27 +- src/mesa/drivers/dri/i965/brw_wm.h | 2 + src/mesa/drivers/dri/i965/brw_wm_debug.c | 108 + src/mesa/drivers/dri/i965/brw_wm_emit.c | 2 + src/mesa/drivers/dri/i965/gen6_wm_sr.c | 31 + src/mesa/drivers/dri/i965/gen_wm_sr.g4a |32826 ++++++++++++++++++++++++++ 15 files changed, 33087 insertions(+), 23 deletions(-)
intel-gpu-tools:
configure.ac | 1 + debugger/Makefile.am | 12 + debugger/debug_rdata.c | 141 +++++++ debugger/eudb.c | 604 ++++++++++++++++++++++++++++++ debugger/system_routine/Makefile | 84 ++++ debugger/system_routine/eviction_macro.c | 48 +++ debugger/system_routine/pre_cpp.py | 123 ++++++ debugger/system_routine/sr.g4a | 277 ++++++++++++++ debugger/system_routine/test.g4a | 64 ++++ lib/Makefile.am | 1 + lib/debug.h | 92 +++++ lib/intel_chipset.h | 8 + lib/intel_gpu_tools.h | 27 ++ lib/intel_mmio.c | 162 ++++++++- lib/intel_reg.h | 4 + lib/intel_reg_map.c | 178 +++++++++ tools/Makefile.am | 1 + tools/forcewaked.c | 106 ++++++ 18 files changed, 1932 insertions(+), 1 deletions(-)
Thanks.
Ben
PATCH 1/10 intel: shared header for shader debugging
--- intel/Makefile.am | 3 ++- intel/intel_debug.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletions(-)
intel/Makefile.am +2 -1
@@ -45,6 +45,7 @@ libdrm_intel_la_SOURCES = \ mm.h libdrm_intelincludedir = ${includedir}/libdrm -libdrm_intelinclude_HEADERS = intel_bufmgr.h +libdrm_intelinclude_HEADERS = intel_bufmgr.h \ + intel_debug.h pkgconfig_DATA = libdrm_intel.pc
intel/intel_debug.h new file +44 -0
44 lines not on this page · raw message
Signature · 6 lines
1.7.6 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/10 i965: copy in system routine, reserve extra scratch
In reply to Ben WidawskyThe debugger shared memory needs to be a fixed size. Since this is scratch memory that is already used by register spilling, add appropriate hooks to do the right thing when debugging.
v2: Include the bytes for a known good system routine and upload it into the instruction state cache
--- src/mesa/drivers/dri/i965/Makefile | 1 + src/mesa/drivers/dri/i965/brw_context.h | 6 + src/mesa/drivers/dri/i965/brw_state.h | 6 +- src/mesa/drivers/dri/i965/brw_state_cache.c | 49 +- src/mesa/drivers/dri/i965/brw_state_upload.c | 18 +- src/mesa/drivers/dri/i965/brw_wm.c | 24 +- src/mesa/drivers/dri/i965/brw_wm.h | 2 + src/mesa/drivers/dri/i965/brw_wm_debug.c | 29 + src/mesa/drivers/dri/i965/gen6_wm_sr.c | 31 + src/mesa/drivers/dri/i965/gen_wm_sr.g4a |32826 ++++++++++++++++++++++++++ 10 files changed, 32975 insertions(+), 17 deletions(-)
src/mesa/drivers/dri/i965/Makefile +1 -0
@@ -98,6 +98,7 @@ DRIVER_SOURCES = \ gen6_urb.c \ gen6_viewport_state.c \ gen6_vs_state.c \ + gen6_wm_sr.c \ gen6_wm_state.c \ gen7_cc_state.c \ gen7_clip_state.c \
src/mesa/drivers/dri/i965/brw_context.h +6 -0
@@ -407,10 +407,12 @@ struct brw_cache {struct brw_context *brw;struct brw_cache_item **items; +struct brw_cache_item *debugger;drm_intel_bo *bo;GLuint size, n_items;uint32_t next_offset; +uint32_t persistent_size;bool bo_used_by_gpu; };
@@ -747,6 +749,10 @@ struct brw_context* Pre-gen6, push constants live in the CURBE. */ uint32_t push_const_offset; + +/** Debug the wm shaders with the system routine */ +bool debugging; +uint32_t sip_offset; } wm;
src/mesa/drivers/dri/i965/brw_state.h +4 -2
@@ -145,6 +145,9 @@ void brw_clear_validated_bos(struct brw_context *brw);* brw_state_cache.c */ +void brw_upload_debugger_cache (struct brw_context *brw, +void *sytem_routine, +uint32_t length); void brw_upload_cache(struct brw_cache *cache, enum brw_cache_id cache_id, const void *key,
@@ -161,8 +164,7 @@ bool brw_search_cache(struct brw_cache *cache,GLuint key_size, uint32_t *inout_offset, void *out_aux);void brw_state_cache_check_size (struct brw_context *brw ); - -void brw_init_caches (struct brw_context *brw ); +void brw_init_caches (struct brw_context *brw,uint32_t size );void brw_destroy_caches (struct brw_context *brw );/***********************************************************************
src/mesa/drivers/dri/i965/brw_state_cache.c +46 -3
81 lines not on this page · raw message
src/mesa/drivers/dri/i965/brw_state_upload.c +16 -2
@@ -33,9 +33,13 @@#include "brw_context.h" #include "brw_state.h" +#include "brw_wm.h" #include "intel_batchbuffer.h" #include "intel_buffers.h" +extern char *const gen_wm_debugger; +extern const int gen_wm_debugger_size; +/* This is used to initialize brw->state.atoms[]. We could use this * list directly except for a single atom, brw_constant_buffer, which * has a .dirty value which changes according to the parameters of the
@@ -239,8 +243,18 @@ void brw_init_state( struct brw_context *brw ) {const struct brw_tracked_state **atoms;int num_atoms; - -brw_init_caches (brw); +uint32_t rsvd_cache_space =0 ; +char *const shader_debug =getenv ("INTEL_SHADER_DEBUG" ); + +if (shader_debug) { +if (!strncmp ("wm" , shader_debug,2 )) { +brw_init_caches ( brw,4096 + gen_wm_debugger_size ); +brw_upload_debugger_cache ( brw, gen_wm_debugger, gen_wm_debugger_size ); +brw_wm_init_debug (brw); + } + }else { +brw_init_caches ( brw,4096 ); + }if (brw->intel.gen >=7 ) { atoms = gen7_atoms;
src/mesa/drivers/dri/i965/brw_wm.c +14 -10
@@ -194,6 +194,7 @@ bool do_wm_prog(struct brw_context *brw,struct brw_wm_compile *c;const GLuint *program;GLuint program_size; +uint32_t total_scratch =0 ; c = brw->wm.compile_data;if (c ==NULL ) {
@@ -239,18 +240,17 @@ bool do_wm_prog(struct brw_context *brw, c->prog_data.dispatch_width =16 ; } -/* Scratch space is used for register spilling */ -if (c->last_scratch) { -uint32_t total_scratch; - +/* Scratch space is used for register spilling and debugger shared memory. +* Since the debugger must know the size in advance, we try for a fixed size, +* and hope it's large enough +*/ +if (c->last_scratch && !brw->wm.debugging) {/* Per-thread scratch space is power-of-two sized. */ for (c->prog_data.total_scratch =1024 ; c->prog_data.total_scratch <= c->last_scratch; c->prog_data.total_scratch *=2 ) {/* empty */ } - total_scratch = c->prog_data.total_scratch * brw->wm_max_threads; -if (brw->wm.scratch_bo && total_scratch > brw->wm.scratch_bo->size) {drm_intel_bo_unreference (brw->wm.scratch_bo); brw->wm.scratch_bo =NULL ;
@@ -261,8 +261,12 @@ bool do_wm_prog(struct brw_context *brw, total_scratch, 4096); } - } -else { + }else if (brw->wm.debugging) { +uint32_t thread_scratch = brw->wm.scratch_bo->size / brw->wm_max_threads; +assert (brw->wm.scratch_bo); +assert (thread_scratch /2 >= c->last_scratch); + c->prog_data.total_scratch = thread_scratch; + }else { c->prog_data.total_scratch =0 ; }
@@ -284,8 +288,8 @@ bool do_wm_prog(struct brw_context *brw, -static void brw_wm_populate_key (struct brw_context *brw, -struct brw_wm_prog_key *key ) +void brw_wm_populate_key (struct brw_context *brw, +struct brw_wm_prog_key *key ) {struct gl_context *ctx = &brw->intel.ctx;/* BRW_NEW_FRAGMENT_PROGRAM */
src/mesa/drivers/dri/i965/brw_wm.h +2 -0
@@ -321,6 +321,8 @@ void brw_wm_print_insn( struct brw_wm_compile *c,void brw_wm_print_program (struct brw_wm_compile *c,const char *stage ); +void brw_wm_init_debug (struct brw_context *brw ); +void brw_wm_lookup_iz (struct intel_context *intel,struct brw_wm_compile *c);
src/mesa/drivers/dri/i965/brw_wm_debug.c +29 -0
@@ -31,8 +31,10 @@#include "brw_context.h" +#include "brw_state.h" #include "brw_wm.h" +extern char gen_wm_debugger[];void brw_wm_print_value (struct brw_wm_compile *c,struct brw_wm_value *value )
@@ -172,3 +174,30 @@ void brw_wm_print_program( struct brw_wm_compile *c,printf ("\n" ); } +#define SCRATCH_SIZE (512 * 1024) +void brw_wm_init_debug (struct brw_context *brw ) +{ +struct intel_context *intel = &brw->intel; +uint32_t name; +int ret; + +/* In the debug case, we allocate the buffer now because we'll need to attach +* with the debugger at a later time when flink will not work (the ring / +* struct_mutex are likely to be frozen). If we make the buffer visible early +* enough, the debugger can map it before the first breakpoint. +*/ + brw->wm.scratch_bo =drm_intel_bo_alloc (intel->bufmgr, +"wm scratch" , +SCRATCH_SIZE * brw->wm_max_threads, +4096 ); +assert (brw->wm.scratch_bo); + +drm_intel_bo_map (brw->wm.scratch_bo,0 ); +memset (brw->wm.scratch_bo->virtual,0xa5 ,SCRATCH_SIZE * brw->wm_max_threads); +drm_intel_bo_unmap (brw->wm.scratch_bo); + + ret =drm_intel_bo_flink (brw->wm.scratch_bo, &name); +assert (ret ==0 ); + + brw->wm.debugging = true; +}
src/mesa/drivers/dri/i965/gen6_wm_sr.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright © 2011 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +* Authors: +* Ben Widawsky <[email protected]> +* +*/ + +#include "gen_wm_sr.g4a" + +char *gen_wm_debugger = gen_eu_bytes; +const int gen_wm_debugger_size =sizeof (gen_eu_bytes);
src/mesa/drivers/dri/i965/gen_wm_sr.g4a new file +32826 -0
2,706 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.7.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Part of the diff is not shown here. View the raw message.
PATCH 3/10 i965: Reserve scratch space for debugger communication
In reply to Ben WidawskySince the debug system routine will share scratch space with threads doing register spilling, we must offset the registers to accommodate. This is more easily accomplished (and less bug prone) in Mesa.
The debugger will only work with the new fragment shader backend.
--- src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 15 +++++++++++++-- src/mesa/drivers/dri/i965/brw_wm_emit.c | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-)
src/mesa/drivers/dri/i965/brw_fs_emit.cpp +13 -2
@@ -455,6 +455,17 @@ fs_visitor::generate_discard(fs_inst *inst) } } +static GLuint +brw_get_scratch_offset(struct brw_context *brw, fs_inst *inst) +{ + /* Split buffer 50-50 */ + if (brw->wm.debugging) { + return inst->offset + (brw->wm.scratch_bo->size / brw->wm_max_threads) / 2; + } else { + return inst->offset; + } +} + void fs_visitor::generate_spill(fs_inst *inst, struct brw_reg src) {
@@ -464,7 +475,7 @@ fs_visitor::generate_spill(fs_inst *inst, struct brw_reg src) retype(brw_message_reg(inst->base_mrf + 1), BRW_REGISTER_TYPE_UD), retype(src, BRW_REGISTER_TYPE_UD)); brw_oword_block_write_scratch(p, brw_message_reg(inst->base_mrf), 1, - inst->offset); + brw_get_scratch_offset(brw, inst)); } void
@@ -486,7 +497,7 @@ fs_visitor::generate_unspill(fs_inst *inst, struct brw_reg dst) brw_MOV(p, brw_null_reg(), dst); brw_oword_block_read_scratch(p, dst, brw_message_reg(inst->base_mrf), 1, - inst->offset); + brw_get_scratch_offset(brw, inst)); if (intel->gen == 4 && !intel->is_g4x) { /* gen4 errata: destination from a send can't be used as a
src/mesa/drivers/dri/i965/brw_wm_emit.c +2 -0
@@ -1560,6 +1560,8 @@ static void emit_spill( struct brw_wm_compile *c,mov (1) r0.2<1>:d 0x00000080:d { Align1 NoMask } send (16) null.0<1>:uw m1 r0.0<8;8,1>:uw 0x053003ff:ud { Align1 } */ +if (p->brw->wm.debugging) +abort ();brw_oword_block_write_scratch (p,brw_message_reg (1 ),2 , slot); }
Signature · 1 line
1.7.6
PATCH 4/10 i965: setup system routine
In reply to Ben WidawskyUpload the system routine as part of the invariant state if debugging.
Remove SIP setting if not debugging to make it more friendly for others that may be debugging shaders or media kernels.
v2: removed comment per Chris
--- src/mesa/drivers/dri/i965/brw_misc_state.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-)
src/mesa/drivers/dri/i965/brw_misc_state.c +8 -4
@@ -652,10 +652,14 @@ static void upload_invarient_state( struct brw_context *brw ) } } -BEGIN_BATCH (2 ); -OUT_BATCH (CMD_STATE_SIP <<16 | (2 -2 )); -OUT_BATCH (0 ); -ADVANCE_BATCH (); +/* The system routine must be set after a change to Instruction base */ +if (brw->wm.debugging) { +assert (brw->wm.sip_offset !=0 ); +BEGIN_BATCH (2 ); +OUT_BATCH (CMD_STATE_SIP <<16 | (2 -2 )); +OUT_BATCH (brw->wm.sip_offset); +ADVANCE_BATCH (); + }BEGIN_BATCH (1 ); OUT_BATCH(brw->CMD_VF_STATISTICS << 16 |
Signature · 1 line
1.7.6
Re: [Intel-gfx] [PATCH 04/10] i965: setup system routine
Quoted 6 lines · Ben Widawsky
Upload the system routine as part of the invariant state if debugging.
Remove SIP setting if not debugging to make it more friendly for others that may be debugging shaders or media kernels.
v2: removed comment per Chris
This patch doesn't really make sense to me. Nothing good will come of my driver's buffer execution landing inside someone else's debug kernel, right? So why should my driver's batchbuffer be leaving their SIP in place?
Of course, if we're landing in a SIP at all from our !brw->wm.debugging batchbuffers, we're screwed if we don't have actual SIP instructions in place, so I guess this doesn't *really* change anything.
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [PATCH 04/10] i965: setup system routine
Quoted 6 lines · Eric Anholt
Quoted 5 lines · Ben Widawsky
Upload the system routine as part of the invariant state if debugging.
Remove SIP setting if not debugging to make it more friendly for others that may be debugging shaders or media kernels.
Quoted 6 lines
Quoted 1 line
v2: removed comment per Chris
This patch doesn't really make sense to me. Nothing good will come of my driver's buffer execution landing inside someone else's debug kernel, right? So why should my driver's batchbuffer be leaving their SIP in place?
Yeah you're right. Furthermore, the default value should be 0, which should be all good all around. Initially I was trying to do something fancier here, detecting when the SIP has been changed external to mesa, but I gave up on that.
I will remove the condition and always set sip.
Ben
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/10 i965: emit breakpoints
In reply to Ben WidawskyProvide a function to allow emitting breakpoints in the instruction oword. Use breakpoints when debugging.
--- src/mesa/drivers/dri/i965/brw_eu.c | 6 ++++++ src/mesa/drivers/dri/i965/brw_eu.h | 1 + src/mesa/drivers/dri/i965/brw_wm.c | 3 +++ 3 files changed, 10 insertions(+), 0 deletions(-)
src/mesa/drivers/dri/i965/brw_eu.c +6 -0
@@ -150,6 +150,12 @@ void brw_set_acc_write_control(struct brw_compile *p, GLuint value) p->current->header.acc_wr_control = value; } +void brw_set_breakpoint (struct brw_compile *p) +{ +if (p->brw->intel.gen >=6 ) + p->current->header.debug_control =1 ; +} +void brw_push_insn_state (struct brw_compile *p ) {assert (p->current != &p->stack[BRW_EU_MAX_INSN_STACK -1 ]);
src/mesa/drivers/dri/i965/brw_eu.h +1 -0
@@ -793,6 +793,7 @@ void brw_set_predicate_control( struct brw_compile *p, GLuint pc );void brw_set_predicate_inverse (struct brw_compile *p,bool predicate_inverse);void brw_set_conditionalmod (struct brw_compile *p,GLuint conditional );void brw_set_acc_write_control (struct brw_compile *p,GLuint value); +void brw_set_breakpoint (struct brw_compile *p );void brw_init_compile (struct brw_context *,struct brw_compile *p,void *mem_ctx);
src/mesa/drivers/dri/i965/brw_wm.c +3 -0
@@ -229,6 +229,9 @@ bool do_wm_prog(struct brw_context *brw,brw_init_compile (brw, &c->func, c); +if (brw->wm.debugging) +brw_set_breakpoint (&c->func); +if (prog && prog->FragmentProgram) {if (!brw_wm_fs_emit (brw, c, prog))return false;
Signature · 1 line
1.7.6
PATCH 6/10 i965: attach to a listening debugger
In reply to Ben WidawskyUse unix domain sockets to connect to a debugger and send the information the debugger will use to properly handle debug events.
--- src/mesa/drivers/dri/i965/brw_wm_debug.c | 85 ++++++++++++++++++++++++++++- 1 files changed, 82 insertions(+), 3 deletions(-)
src/mesa/drivers/dri/i965/brw_wm_debug.c +82 -3
@@ -175,12 +175,82 @@ void brw_wm_print_program( struct brw_wm_compile *c, }#define SCRATCH_SIZE (512 * 1024) +#ifndef NO_DEBUGGER_LISTENING +#include <unistd.h> +#include <sys/un.h> +#include <sys/socket.h> +#include "intel_debug.h" + +static int +attach_to_debugger () +{ +struct sockaddr_un addr; +int fd, ret; + + fd =socket (AF_UNIX ,SOCK_STREAM ,0 ); +if (fd ==-1 ) +return -1 ; + +memset (&addr,0 ,sizeof (addr)); + addr.sun_family =AF_UNIX ; +strncpy (addr.sun_path,SHADER_DEBUG_SOCKET ,sizeof (addr.sun_path) -1 ); + + ret =connect (fd, &addr,sizeof (addr)); +if (ret) +return ret; + +return fd; +} + +static int +start_debugger (int fd,int flink_handle) +{ +struct intel_debug_handshake dh; +int reply, ret; + + dh.version =DEBUG_HANDSHAKE_VERSION ; + dh.flink_handle = flink_handle; + dh.per_thread_scratch =SCRATCH_SIZE ; + ret =write (fd, &dh,sizeof (dh)); +if (ret !=sizeof (dh)) { + ret =-1 ; + goto done; + } + + ret =read (fd, &reply,sizeof (reply)); +if (ret !=sizeof (reply)) { + ret =-1 ; + goto done; + } + +if (strncmp (DEBUG_HANDSHAKE_ACK , (char *)&reply,strlen (DEBUG_HANDSHAKE_ACK ))) { + ret =1 ; + goto done; + } + + ret =0 ; + +done: +close (fd); +return ret; +} +#endif +void brw_wm_init_debug (struct brw_context *brw ) {struct intel_context *intel = &brw->intel;uint32_t name; +int debugger_fd;int ret; +/* Simple system routines do not need a debugger present */ +#ifndef NO_DEBUGGER_LISTENING +if ((debugger_fd =attach_to_debugger ()) <0 ) { +fprintf (stderr,"Failed to attach to debugger\n" ); +return ; + } +#endif +/* In the debug case, we allocate the buffer now because we'll need to attach * with the debugger at a later time when flink will not work (the ring / * struct_mutex are likely to be frozen). If we make the buffer visible early
@@ -192,12 +262,21 @@ void brw_wm_init_debug( struct brw_context *brw ) 4096);assert (brw->wm.scratch_bo); + ret =drm_intel_bo_flink (brw->wm.scratch_bo, &name); +assert (ret ==0 ); + +#ifndef NO_DEBUGGER_LISTENING + ret =start_debugger (debugger_fd, name); +if (ret !=0 ) { +drm_intel_bo_unreference (brw->wm.scratch_bo); +return ; + } +#endif + +/* Put a nice pattern in the buffer to hopefully help detect errors */ drm_intel_bo_map (brw->wm.scratch_bo,0 );memset (brw->wm.scratch_bo->virtual,0xa5 ,SCRATCH_SIZE * brw->wm_max_threads);drm_intel_bo_unmap (brw->wm.scratch_bo); - ret =drm_intel_bo_flink (brw->wm.scratch_bo, &name); -assert (ret ==0 ); - brw->wm.debugging = true; }
Signature · 1 line
1.7.6
PATCH 7/10 intel-gpu-tools: register range handling for forcewake hooks
In reply to Ben WidawskyWe can deprecate the old code by using the non-safe flag in the new API. The safe flag should allow the previous behavior to continue.
The code also adds some range checking on register access. This code is gives hooks to prevent tools from doing bad things.
v2: fixes from Chris
try /debug after /sys/kernel/debug fails
stat the debugfs file before returning success
whitespace fix
warn for gen2/gen3/gen7
--- lib/Makefile.am | 1 + lib/intel_chipset.h | 8 ++ lib/intel_gpu_tools.h | 27 ++++++++ lib/intel_mmio.c | 162 ++++++++++++++++++++++++++++++++++++++++++++- lib/intel_reg_map.c | 178 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 375 insertions(+), 1 deletions(-)
lib/Makefile.am +1 -0
@@ -8,6 +8,7 @@ libintel_tools_la_SOURCES = \ intel_mmio.c \ intel_pci.c \ intel_reg.h \ + intel_reg_map.c \ instdone.c \ instdone.h \ drmtest.h
lib/intel_chipset.h +8 -0
@@ -168,3 +168,11 @@#define HAS_BLT_RING (devid) (IS_GEN6(devid) || \ IS_GEN7(devid)) + +#define IS_BROADWATER (devid) (devid == PCI_CHIP_I946_GZ || \ + devid == PCI_CHIP_I965_G_1 || \ + devid == PCI_CHIP_I965_Q || \ + devid == PCI_CHIP_I965_G) + +#define IS_CRESTLINE (devid) (devid == PCI_CHIP_I965_GM || \ + devid == PCI_CHIP_I965_GME)
lib/intel_gpu_tools.h +27 -0
@@ -37,6 +37,33 @@extern void *mmio;void intel_get_mmio (struct pci_device *pci_dev); +/* New style register access API */ +int intel_register_access_init (struct pci_device *pci_dev,int safe); +void intel_register_access_fini (void ); +uint32_t intel_register_read (uint32_t reg); +void intel_register_write (uint32_t reg,uint32_t val); + +#define INTEL_RANGE_RSVD (0<<0)/* Shouldn't be read or written */ +#define INTEL_RANGE_READ (1<<0) +#define INTEL_RANGE_WRITE (1<<1) +#define INTEL_RANGE_RW (INTEL_RANGE_READ | INTEL_RANGE_WRITE) +#define INTEL_RANGE_END (1<<31) + +struct intel_register_range { +uint32_t base; +uint32_t size; +uint32_t flags; +}; + +struct intel_register_map { +struct intel_register_range *map; +uint32_t top; +uint32_t alignment_mask; +}; +struct intel_register_map intel_get_register_map (uint32_t devid); +struct intel_register_range *intel_get_register_range (struct intel_register_map map,uint32_t offset,int mode); + +static inline uint32_t INREG (uint32_t reg) {
lib/intel_mmio.c +161 -1
182 lines not on this page · raw message
lib/intel_reg_map.c new file +178 -0
178 lines not on this page · raw message
Signature · 1 line
1.7.6
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/10 intel-gpu-tools/forcewaked: sample forcewake app
In reply to Ben WidawskyThis app is required for debug features which seem to (undocumented) reset themselves if/when the GT goes to sleep.
It is also useful for those doing general debugging or profiling from userspace when they do not wish to have the GT sleep.
v2: made forcewaked more daemon-like
--- tools/Makefile.am | 1 + tools/forcewaked.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 0 deletions(-)
tools/Makefile.am +1 -0
@@ -12,6 +12,7 @@ bin_PROGRAMS = \ intel_reg_snapshot \ intel_reg_write \ intel_reg_read \ + forcewaked \ $(NULL) noinst_PROGRAMS = \
tools/forcewaked.c new file +106 -0
106 lines not on this page · raw message
Signature · 6 lines
1.7.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/10 debugging: add important debug regs
In reply to Ben Widawsky--- lib/intel_reg.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
lib/intel_reg.h +4 -0
@@ -359,6 +359,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#define THREE_D_INST_DISABLE 0x04#define STATE_VAR_UPDATE_DISABLE 0x02#define PAL_STIP_DISABLE 0x01 +#define GEN6_GLOBAL_DEBUG_ENABLE 0x10#define MEMMODE 0x20dc
@@ -3488,5 +3489,8 @@ typedef enum {#define TRANS_DP_HSYNC_ACTIVE_HIGH (1<<3)#define TRANS_DP_HSYNC_ACTIVE_LOW 0 +/* Debug regs */ +#define GEN6_TD_CTL 0x7000/* <= GEN5 was at 0x8000 */ +#define GEN6_TD_CTL_FORCE_TD_BKPT (1<<4)#endif /* _I810_REG_H */
Signature · 1 line
1.7.6
PATCH 10/10 debugging: shader debugging
In reply to Ben Widawskyhigh level summary of the files:
* debug_rdata - get current state from debug registers. Helpful when developing the debugger, and could serve some purpose in the future.
* eudb - the debugger itself
* eviction_macro - generate the proper macro to flush the EU render cache until I get control flow working
* pre_cpp - an evaluating c preprocesser like thing, to be used before cpp
* sr - the system routine, exception handler which runs on the EU
* test - a very basic test system routine
* debug.h
--- configure.ac | 1 + debugger/Makefile.am | 12 + debugger/debug_rdata.c | 141 +++++++ debugger/eudb.c | 604 ++++++++++++++++++++++++++++++ debugger/system_routine/Makefile | 84 ++++ debugger/system_routine/eviction_macro.c | 48 +++ debugger/system_routine/pre_cpp.py | 123 ++++++ debugger/system_routine/sr.g4a | 277 ++++++++++++++ debugger/system_routine/test.g4a | 64 ++++ lib/debug.h | 92 +++++ 10 files changed, 1446 insertions(+), 0 deletions(-)
configure.ac +1 -0
@@ -98,5 +98,6 @@ AC_CONFIG_FILES([ scripts/Makefile tests/Makefile tools/Makefile + debugger/Makefile ]) AC_OUTPUT
debugger/Makefile.am new file +12 -0
@@ -0,0 +1,12 @@ +SUBDIRS=system_routine + +bin_PROGRAMS = \ + eudb \ + debug_rdata \ + $(NULL) + +LDADD = ../lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) + +AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(WARN_CFLAGS) \ + -I$(srcdir)/.. \ + -I$(srcdir)/../lib
debugger/debug_rdata.c new file +141 -0
141 lines not on this page · raw message
debugger/eudb.c new file +604 -0
604 lines not on this page · raw message
debugger/system_routine/Makefile new file +84 -0
84 lines not on this page · raw message
debugger/system_routine/eviction_macro.c new file +48 -0
48 lines not on this page · raw message
debugger/system_routine/pre_cpp.py new file +123 -0
123 lines not on this page · raw message
debugger/system_routine/sr.g4a new file +277 -0
277 lines not on this page · raw message
debugger/system_routine/test.g4a new file +64 -0
64 lines not on this page · raw message
lib/debug.h new file +92 -0
92 lines not on this page · raw message
Signature · 6 lines
1.7.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx