Shader debugging
The following patches enable GEN hardware shader debugging features. This is for >= GEN6 only.
The patches are not usable without patches to the DDX as well as Mesa. Furthermore currently a kernel ioctl is required (more on that later). As these are all in tools, I figure I would post these now while I continue cleaning up the other patches. Furthermore, no interactive debugging is yet supported.
The system routine has been tested on a fragment shader (though it should work for vertex shaders as well).
Here is a brief description of what is missing (ie. not yet ready for mailing list):
- DDX state setup needs to cooperate when setting the Instruction Base address.
- Mesa state setup needs to cooperate.
- Mesa need some way to set breakpoints.
- Mesa register allocation needs modification.
- Kernel ioctl to set the system routine instruction pointer
Here is what is working in the current implementation:
- System routine upload (done in Kernel IOCTL currently)
- Basic system routine
- Coherent EU/CPU communication (while ring is frozen)
- EU architectural state saving (just MRF 1-15, GRF 0-15, SR, and CR), and saved into CPU visible space.
- Tool to read architectural state (mostly for reference).
Here is what is planned next:
- Clean up and send out what I have for Mesa, DDX, and kernel (even though I know most of those need changes anyway).
- When I started this work nobody was using the instuction base pointer, so I need to cooperate more closely with that now.
- Work on EU side communication (do different things based on CPU commands).
- Change eviction macro to a loop
There's probably more which I'm forgetting right now. The 4th patch is the gigantic, not sure how to split it up, patch. I will probably add an extremely, more simpler system routine for basic sanity testing.
PATCH 1/4 intel-gpu-tools: register range handling for forcewake hooks
We 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.
--- lib/Makefile.am | 1 + lib/intel_chipset.h | 8 ++ lib/intel_gpu_tools.h | 27 +++++++ lib/intel_mmio.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/intel_reg_map.c | 174 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 407 insertions(+), 0 deletions(-) create mode 100644 lib/intel_reg_map.c
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,int greedy); +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 +197 -0
218 lines not on this page · raw message
lib/intel_reg_map.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
1.7.5.2
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 intel-gpu-tools/forcewaked: simple 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.
--- tools/Makefile.am | 1 + tools/forcewaked.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 tools/forcewaked.c
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 +45 -0
45 lines not on this page · raw message
Signature · 6 lines
1.7.5.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 intel-gpu-tools: add important debug regs
In reply to Ben Widawsky--- lib/intel_reg.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
lib/intel_reg.h +5 -0
@@ -3488,5 +3488,10 @@ typedef enum {#define TRANS_DP_HSYNC_ACTIVE_HIGH (1<<3)#define TRANS_DP_HSYNC_ACTIVE_LOW 0 +/* Debug */ +#define INSTPM 0x20c0 +#define INSTPM_GLOBAL_DEBUG_EN (1<<4) +#define GEN6_TD_CTL 0x7000 +#define TD_CTL_FORCE_TD_BKPT (1<<4)#endif /* _I810_REG_H */
Signature · 1 line
1.7.5.2
PATCH 4/4 intel-gpu-tools: shader debug
In reply to Ben WidawskyPreliminary code for shader debugging. This provides a trace like implementation which can get EU architectural state at each instruction.
The code currently only supports the most basic set of state and features.
--- configure.ac | 1 + debugger/Makefile.am | 13 + debugger/debug_rdata.c | 141 +++++++++ debugger/eudb.c | 493 ++++++++++++++++++++++++++++++ debugger/sr_loader.c | 118 +++++++ debugger/system_routine/Makefile | 69 +++++ debugger/system_routine/eviction_macro.c | 48 +++ debugger/system_routine/pre_cpp.py | 123 ++++++++ debugger/system_routine/sr.g4a | 277 +++++++++++++++++ lib/debug.h | 92 ++++++ 10 files changed, 1375 insertions(+), 0 deletions(-) create mode 100644 debugger/Makefile.am create mode 100644 debugger/debug_rdata.c create mode 100644 debugger/eudb.c create mode 100644 debugger/sr_loader.c create mode 100644 debugger/system_routine/Makefile create mode 100644 debugger/system_routine/eviction_macro.c create mode 100755 debugger/system_routine/pre_cpp.py create mode 100644 debugger/system_routine/sr.g4a create mode 100644 lib/debug.h
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 +13 -0
@@ -0,0 +1,13 @@ +SUBDIRS=system_routine + +bin_PROGRAMS = \ + eudb \ + sr_loader \ + 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 +493 -0
493 lines not on this page · raw message
debugger/sr_loader.c new file +118 -0
118 lines not on this page · raw message
debugger/system_routine/Makefile new file +69 -0
69 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
lib/debug.h new file +92 -0
92 lines not on this page · raw message
Signature · 6 lines
1.7.5.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx