r600g,radeonsi: implement get_device_reset_status
authorMarek Olšák <marek.olsak@amd.com>
Wed, 29 Apr 2015 13:27:50 +0000 (15:27 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 3 Jul 2015 14:23:28 +0000 (16:23 +0200)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index e122b607b863170c6111fa3db771e2d79d54586e..143e98ea0af3899c37d8a70d4ea5538751277b5f 100644 (file)
@@ -270,6 +270,9 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_POLYGON_OFFSET_CLAMP:
                return 1;
 
+       case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
+               return rscreen->b.info.drm_major == 2 && rscreen->b.info.drm_minor >= 43;
+
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
                return !R600_BIG_ENDIAN && rscreen->b.info.has_userptr;
 
@@ -332,7 +335,6 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
        case PIPE_CAP_SAMPLER_VIEW_TARGET:
        case PIPE_CAP_VERTEXID_NOBASE:
-       case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
                return 0;
 
        /* Stream output. */
index 775cf53ba88aaaf53e02abf7f0332fa910b5a4d8..5dd28df5d5ff7f859debd95654e082f81cd5693e 100644 (file)
@@ -196,6 +196,19 @@ static void r600_flush_dma_ring(void *ctx, unsigned flags,
        rctx->rings.dma.flushing = false;
 }
 
+static enum pipe_reset_status r600_get_reset_status(struct pipe_context *ctx)
+{
+       struct r600_common_context *rctx = (struct r600_common_context *)ctx;
+       unsigned latest = rctx->ws->query_value(rctx->ws,
+                                               RADEON_GPU_RESET_COUNTER);
+
+       if (rctx->gpu_reset_counter == latest)
+               return PIPE_NO_RESET;
+
+       rctx->gpu_reset_counter = latest;
+       return PIPE_UNKNOWN_CONTEXT_RESET;
+}
+
 bool r600_common_context_init(struct r600_common_context *rctx,
                              struct r600_common_screen *rscreen)
 {
@@ -222,6 +235,13 @@ bool r600_common_context_init(struct r600_common_context *rctx,
         rctx->b.memory_barrier = r600_memory_barrier;
        rctx->b.flush = r600_flush_from_st;
 
+       if (rscreen->info.drm_major == 2 && rscreen->info.drm_minor >= 43) {
+               rctx->b.get_device_reset_status = r600_get_reset_status;
+               rctx->gpu_reset_counter =
+                       rctx->ws->query_value(rctx->ws,
+                                             RADEON_GPU_RESET_COUNTER);
+       }
+
        LIST_INITHEAD(&rctx->texture_buffers);
 
        r600_init_context_texture_functions(rctx);
index 51fd016229ca061759cd3766a638dfa3ec58a42b..2b27e58e0e2e91f20f858d3771f175c24873986a 100644 (file)
@@ -356,6 +356,7 @@ struct r600_common_context {
        enum chip_class                 chip_class;
        struct r600_rings               rings;
        unsigned                        initial_gfx_cs_size;
+       unsigned                        gpu_reset_counter;
 
        struct u_upload_mgr             *uploader;
        struct u_suballocator           *allocator_so_filled_size;
index 3bfbb6d75b7047f7e0c180c51a77af645d610d0c..48342c063c164e5690b0f9a8959f6a7b71a922be 100644 (file)
@@ -169,9 +169,10 @@ enum radeon_value_id {
     RADEON_NUM_BYTES_MOVED,
     RADEON_VRAM_USAGE,
     RADEON_GTT_USAGE,
-    RADEON_GPU_TEMPERATURE,
+    RADEON_GPU_TEMPERATURE, /* DRM 2.42.0 */
     RADEON_CURRENT_SCLK,
-    RADEON_CURRENT_MCLK
+    RADEON_CURRENT_MCLK,
+    RADEON_GPU_RESET_COUNTER, /* DRM 2.43.0 */
 };
 
 enum radeon_bo_priority {
index 480a3010d31a661780b97f68e8b2de344a019188..77b8d7d3a6abde07efbefc258d414a4f7054bf48 100644 (file)
@@ -257,6 +257,9 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
                return !SI_BIG_ENDIAN && sscreen->b.info.has_userptr;
 
+       case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
+               return sscreen->b.info.drm_major == 2 && sscreen->b.info.drm_minor >= 43;
+
        case PIPE_CAP_TEXTURE_MULTISAMPLE:
                /* 2D tiling on CIK is supported since DRM 2.35.0 */
                return sscreen->b.chip_class < CIK ||
@@ -293,7 +296,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
        case PIPE_CAP_SAMPLER_VIEW_TARGET:
        case PIPE_CAP_VERTEXID_NOBASE:
-       case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
                return 0;
 
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
index d8bb353df9d79d7185ca9c0e03853d74ead08e90..e7b77283b8a8979348c75869e65abd71d24eb2d4 100644 (file)
 
 #define RADEON_INFO_VA_UNMAP_WORKING   0x25
 
+#ifndef RADEON_INFO_GPU_RESET_COUNTER
+#define RADEON_INFO_GPU_RESET_COUNTER   0x26
+#endif
+
 static struct util_hash_table *fd_tab = NULL;
 pipe_static_mutex(fd_tab_mutex);
 
@@ -567,6 +571,10 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
         radeon_get_drm_value(ws->fd, RADEON_INFO_CURRENT_GPU_MCLK,
                              "current-gpu-mclk", (uint32_t*)&retval);
         return retval;
+    case RADEON_GPU_RESET_COUNTER:
+        radeon_get_drm_value(ws->fd, RADEON_INFO_GPU_RESET_COUNTER,
+                             "gpu-reset-counter", (uint32_t*)&retval);
+        return retval;
     }
     return 0;
 }