diff options
author | Ben Widawsky <benjamin.widawsky@intel.com> | 2015-03-27 11:58:23 -0700 |
---|---|---|
committer | Ben Widawsky <benjamin.widawsky@intel.com> | 2015-04-22 16:39:19 -0700 |
commit | 3f03225d55e72b1d034f33a0388145f4e676dfff (patch) | |
tree | d8fda1aac6cf3dbc1c51fc8459bb5b008b0c9c77 | |
parent | de61efcec1aefeda6ff4a81ea66062c1b1646883 (diff) |
eudb: Clean up, and generalize HWeudb-cleanup
To prepare for supporting other gens, it is beneficial to reorganize the code in
a way where we can easily specify the GEN details externally. This does need
more work to be perfect, but this is a good start.
NOTE: This code hasn't been run in a very long time, and therefore may not work
correctly. Subsequent patches will address that, but at this time it is possible
this patch makes the code go from working->broken. It is more likely this patch
makes things go from broken->broken.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
-rw-r--r-- | debugger/Makefile.am | 1 | ||||
-rw-r--r-- | debugger/eudb.c | 147 | ||||
-rw-r--r-- | debugger/eudb.h | 74 | ||||
-rw-r--r-- | debugger/gen6_eu.c | 66 |
4 files changed, 179 insertions, 109 deletions
diff --git a/debugger/Makefile.am b/debugger/Makefile.am index 0b6028b4..6d7d95cc 100644 --- a/debugger/Makefile.am +++ b/debugger/Makefile.am @@ -1,6 +1,7 @@ SUBDIRS = system_routine +eudb_SOURCES = eudb.c gen6_eu.c bin_PROGRAMS = eudb noinst_PROGRAMS = debug_rdata diff --git a/debugger/eudb.c b/debugger/eudb.c index 0e810db1..46f9ee2d 100644 --- a/debugger/eudb.c +++ b/debugger/eudb.c @@ -1,5 +1,5 @@ /* - * Copyright © 2011 Intel Corporation + * Copyright © 2011,2015 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,128 +24,57 @@ * Ben Widawsky <ben@bwidawsk.net> * * Notes: - * + * TODO: + * Move from flink to dmabuf */ +#include <sys/mman.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/un.h> +#include <assert.h> +#include <fcntl.h> #include <signal.h> +#include <stdint.h> +#include <stdio.h> #include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> #include <string.h> #include <strings.h> -#include <assert.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <sys/un.h> -#include <sys/socket.h> +#include <unistd.h> + +#include "debug.h" #include "drm.h" -#include "i915_drm.h" #include "drmtest.h" -#include "intel_chipset.h" -#include "intel_bufmgr.h" -#include "intel_io.h" +#include "i915_drm.h" #include "intel_batchbuffer.h" +#include "intel_bufmgr.h" +#include "intel_chipset.h" #include "intel_debug.h" -#include "debug.h" +#include "intel_io.h" -#define EU_ATT 0x7810 -#define EU_ATT_CLR 0x7830 - -#define RSVD_EU -1 -#define RSVD_THREAD -1 -#define RSVD_ID EUID(-1, -1, -1) - -enum { - EBAD_SHMEM, - EBAD_PROTOCOL, - EBAD_MAGIC, - EBAD_WRITE -}; - -struct debuggee { - int euid; - int tid; - int fd; - int clr; - uint32_t reg; -}; - -struct debugger { - struct debuggee *debuggees; - int num_threads; - int real_num_threads; - int threads_per_eu; -} *eu_info; - -drm_intel_bufmgr *bufmgr; -struct intel_batchbuffer *batch; -drm_intel_bo *scratch_bo; - -int handle; -int drm_fd; -int debug_fd = 0; -const char *debug_file = "dump_debug.bin"; -int debug; -int clear_waits; -int shutting_down = 0; -struct intel_debug_handshake dh; -int force_clear = 0; -uint32_t old_td_ctl; +#include "eudb.h" -/* - * The docs are wrong about the attention clear bits. The clear bits are - * provided as part of the structure in case they change in future generations. - */ -#define EUID(eu, td, clear) \ - { .euid = eu, .tid = td, .reg = EU_ATT, .fd = -1, .clr = clear } -#define EUID2(eu, td, clear) \ - { .euid = eu, .tid = td, .reg = EU_ATT + 4, .fd = -1, .clr = clear } -struct debuggee gt1_debug_ids[] = { - RSVD_ID, RSVD_ID, - RSVD_ID, EUID(6, 3, 28), EUID(6, 2, 27), EUID(6, 1, 26), EUID(6, 0, 25), - RSVD_ID, EUID(5, 3, 23), EUID(5, 2, 22), EUID(5, 1, 21), EUID(5, 0, 20), - RSVD_ID, EUID(4, 3, 18), EUID(4, 2, 17), EUID(4, 1, 16), EUID(4, 0, 15), - RSVD_ID, EUID(2, 3, 13), EUID(2, 2, 12), EUID(2, 1, 11), EUID(2, 0, 10), - RSVD_ID, EUID(1, 3, 8), EUID(1, 2, 7), EUID(1, 1, 6), EUID(1, 0, 5), - RSVD_ID, EUID(0, 3, 3), EUID(0, 2, 2), EUID(0, 1, 1), EUID(0, 0, 0) -}; - -struct debuggee gt2_debug_ids[] = { - EUID(8, 1, 31), EUID(8, 0, 30), - EUID(6, 4, 29), EUID(6, 3, 28), EUID(6, 2, 27), EUID(6, 1, 26), EUID(6, 0, 25), - EUID(5, 4, 24), EUID(5, 3, 23), EUID(5, 2, 22), EUID(5, 1, 21), EUID(5, 0, 20), - EUID(4, 4, 19), EUID(4, 3, 18), EUID(4, 2, 17), EUID(4, 1, 16), EUID(4, 0, 15), - EUID(2, 4, 14), EUID(2, 3, 13), EUID(2, 2, 12), EUID(2, 1, 11), EUID(2, 0, 10), - EUID(1, 4, 9), EUID(1, 3, 8), EUID(1, 2, 7), EUID(1, 1, 6), EUID(1, 0, 5), - EUID(0, 4, 4), EUID(0, 3, 3), EUID(0, 2, 2), EUID(0, 1, 1), EUID(0, 0, 0), - RSVD_ID, RSVD_ID, RSVD_ID, RSVD_ID, - EUID2(14, 4, 27), EUID2(14, 3, 26), EUID2(14, 2, 25), EUID2(14, 1, 24), EUID2(14, 0, 23), - EUID2(13, 4, 22), EUID2(13, 3, 21), EUID2(13, 2, 20), EUID2(13, 1, 19), EUID2(13, 0, 18), - EUID2(12, 4, 17), EUID2(12, 3, 16), EUID2(12, 2, 15), EUID2(12, 1, 14), EUID2(12, 0, 13), - EUID2(10, 4, 12), EUID2(10, 3, 11), EUID2(10, 2, 10), EUID2(10, 1, 9), EUID2(10, 0, 8), - EUID2(9, 4, 7), EUID2(9, 3, 6), EUID2(9, 2, 5), EUID2(9, 1, 4), EUID2(9, 0, 3), - EUID2(8, 4, 2), EUID2(8, 3, 1), EUID2(8, 2, 0) -}; - -struct debugger gt1 = { - .debuggees = gt1_debug_ids, - .num_threads = 32, - .real_num_threads = 24, - .threads_per_eu = 4 -}; - -struct debugger gt2 = { - .debuggees = gt2_debug_ids, - .num_threads = 64, - .real_num_threads = 60, - .threads_per_eu = 5 -}; +#define DEBUG_FILE "dump_debug.bin" + +static struct debugger *eu_info; + +static drm_intel_bufmgr *bufmgr; +static drm_intel_bo *scratch_bo; + +static int drm_fd; +static int debug_fd; +static int debug; +static int clear_waits; +static int shutting_down; +static struct intel_debug_handshake dh; +static int force_clear; +static uint32_t old_td_ctl; static void dump_debug(void *buf, size_t count) { if (!debug_fd) - debug_fd = open(debug_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRWXO); + debug_fd = open(DEBUG_FILE, O_CREAT | O_WRONLY | O_TRUNC, S_IRWXO); write(debug_fd, buf, count); } @@ -357,13 +286,13 @@ identify_device(int devid) { case PCI_CHIP_SANDYBRIDGE_GT1: case PCI_CHIP_SANDYBRIDGE_M_GT1: case PCI_CHIP_SANDYBRIDGE_S: - eu_info = >1; + eu_info = &gen6_gt1; break; case PCI_CHIP_SANDYBRIDGE_GT2: case PCI_CHIP_SANDYBRIDGE_GT2_PLUS: case PCI_CHIP_SANDYBRIDGE_M_GT2: case PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS: - eu_info = >2; + eu_info = &gen6_gt2; break; default: return 1; diff --git a/debugger/eudb.h b/debugger/eudb.h new file mode 100644 index 00000000..de5eee15 --- /dev/null +++ b/debugger/eudb.h @@ -0,0 +1,74 @@ +/* + * Copyright © 2011,2015 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. + */ + +#ifndef _EUDB_H_ +#define _EUDB_H_ + +#define EU_ATT 0x7810 +#define EU_ATT_CLR 0x7830 + +#define RSVD_EU -1 + +#define RSVD_THREAD -1 +#define RSVD_ID EUID(-1, -1, -1) + +/* + * This macro helps set up the table of mapping an <EU, thread> to an attention + * clear bit in the MMIO space. + * + * For GEN6, the docs are wrong about the attention clear bits. The clear bits + * are provided as part of the structure in case they change in future + * generations. + */ +#define EUID(eu, td, clear) \ + { .euid = eu, .tid = td, .reg = EU_ATT, .fd = -1, .clr = clear } +#define EUID2(eu, td, clear) \ + { .euid = eu, .tid = td, .reg = EU_ATT + 4, .fd = -1, .clr = clear } + + +enum { + EBAD_SHMEM, + EBAD_PROTOCOL, + EBAD_MAGIC, + EBAD_WRITE +}; + +struct debuggee { + const int euid; + const int tid; + int fd; + const int clr; + const uint32_t reg; +}; + +struct debugger { + struct debuggee *debuggees; + const int num_threads; + const int real_num_threads; + const int threads_per_eu; +}; + +extern struct debugger gen6_gt1; +extern struct debugger gen6_gt2; + +#endif diff --git a/debugger/gen6_eu.c b/debugger/gen6_eu.c new file mode 100644 index 00000000..ab268811 --- /dev/null +++ b/debugger/gen6_eu.c @@ -0,0 +1,66 @@ +/* + * Copyright © 2011,2015 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. + */ + +#include <stdint.h> +#include "eudb.h" + +static struct debuggee gt1_debug_ids[] = { + RSVD_ID, RSVD_ID, + RSVD_ID, EUID(6, 3, 28), EUID(6, 2, 27), EUID(6, 1, 26), EUID(6, 0, 25), + RSVD_ID, EUID(5, 3, 23), EUID(5, 2, 22), EUID(5, 1, 21), EUID(5, 0, 20), + RSVD_ID, EUID(4, 3, 18), EUID(4, 2, 17), EUID(4, 1, 16), EUID(4, 0, 15), + RSVD_ID, EUID(2, 3, 13), EUID(2, 2, 12), EUID(2, 1, 11), EUID(2, 0, 10), + RSVD_ID, EUID(1, 3, 8), EUID(1, 2, 7), EUID(1, 1, 6), EUID(1, 0, 5), + RSVD_ID, EUID(0, 3, 3), EUID(0, 2, 2), EUID(0, 1, 1), EUID(0, 0, 0) +}; + +static struct debuggee gt2_debug_ids[] = { + EUID(8, 1, 31), EUID(8, 0, 30), + EUID(6, 4, 29), EUID(6, 3, 28), EUID(6, 2, 27), EUID(6, 1, 26), EUID(6, 0, 25), + EUID(5, 4, 24), EUID(5, 3, 23), EUID(5, 2, 22), EUID(5, 1, 21), EUID(5, 0, 20), + EUID(4, 4, 19), EUID(4, 3, 18), EUID(4, 2, 17), EUID(4, 1, 16), EUID(4, 0, 15), + EUID(2, 4, 14), EUID(2, 3, 13), EUID(2, 2, 12), EUID(2, 1, 11), EUID(2, 0, 10), + EUID(1, 4, 9), EUID(1, 3, 8), EUID(1, 2, 7), EUID(1, 1, 6), EUID(1, 0, 5), + EUID(0, 4, 4), EUID(0, 3, 3), EUID(0, 2, 2), EUID(0, 1, 1), EUID(0, 0, 0), + RSVD_ID, RSVD_ID, RSVD_ID, RSVD_ID, + EUID2(14, 4, 27), EUID2(14, 3, 26), EUID2(14, 2, 25), EUID2(14, 1, 24), EUID2(14, 0, 23), + EUID2(13, 4, 22), EUID2(13, 3, 21), EUID2(13, 2, 20), EUID2(13, 1, 19), EUID2(13, 0, 18), + EUID2(12, 4, 17), EUID2(12, 3, 16), EUID2(12, 2, 15), EUID2(12, 1, 14), EUID2(12, 0, 13), + EUID2(10, 4, 12), EUID2(10, 3, 11), EUID2(10, 2, 10), EUID2(10, 1, 9), EUID2(10, 0, 8), + EUID2(9, 4, 7), EUID2(9, 3, 6), EUID2(9, 2, 5), EUID2(9, 1, 4), EUID2(9, 0, 3), + EUID2(8, 4, 2), EUID2(8, 3, 1), EUID2(8, 2, 0) +}; + +struct debugger gen6_gt1 = { + .debuggees = gt1_debug_ids, + .num_threads = 32, + .real_num_threads = 24, + .threads_per_eu = 4 +}; + +struct debugger gen6_gt2 = { + .debuggees = gt2_debug_ids, + .num_threads = 64, + .real_num_threads = 60, + .threads_per_eu = 5 +}; |