aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
diff options
context:
space:
mode:
authorJerome Glisse <[email protected]>2013-03-27 11:04:29 -0400
committerJerome Glisse <[email protected]>2013-04-05 10:22:05 -0400
commitb8998f976ee11e5bdffa78cd78278deeed2789c1 (patch)
treef1fdec4f496175d350133914b5890963d6ee3d5e /src/gallium/winsys/radeon/drm/radeon_drm_bo.c
parent5192262833c08903b0e27b991f4b9995c187a8ce (diff)
winsys/radeon: add command stream replay dump for faulty lockup v3
Build time option, set RADEON_CS_DUMP_ON_LOCKUP to 1 in radeon_drm_cs.h to enable it. When enabled after each cs submission the code will try to detect lockup by waiting on one of the buffer of the cs to become idle, after a timeout it will consider that the cs triggered a lockup and will write a radeon_lockup.c file in current directory that have all information for replaying the cs. To build this file : gcc -O0 -g radeon_lockup.c -ldrm -o radeon_lockup -I/usr/include/libdrm v2: Add radeon_ctx.h file to mesa git tree v3: Slightly improve dumped file for easier editing, only dump first faulty cs Signed-off-by: Jerome Glisse <[email protected]>
Diffstat (limited to 'src/gallium/winsys/radeon/drm/radeon_drm_bo.c')
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.c80
1 files changed, 43 insertions, 37 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 61570d0ee76..9e45dcc031c 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -396,14 +396,54 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
FREE(bo);
}
+void *radeon_bo_do_map(struct radeon_bo *bo)
+{
+ struct drm_radeon_gem_mmap args = {0};
+ void *ptr;
+
+ /* Return the pointer if it's already mapped. */
+ if (bo->ptr)
+ return bo->ptr;
+
+ /* Map the buffer. */
+ pipe_mutex_lock(bo->map_mutex);
+ /* Return the pointer if it's already mapped (in case of a race). */
+ if (bo->ptr) {
+ pipe_mutex_unlock(bo->map_mutex);
+ return bo->ptr;
+ }
+ args.handle = bo->handle;
+ args.offset = 0;
+ args.size = (uint64_t)bo->base.size;
+ if (drmCommandWriteRead(bo->rws->fd,
+ DRM_RADEON_GEM_MMAP,
+ &args,
+ sizeof(args))) {
+ pipe_mutex_unlock(bo->map_mutex);
+ fprintf(stderr, "radeon: gem_mmap failed: %p 0x%08X\n",
+ bo, bo->handle);
+ return NULL;
+ }
+
+ ptr = os_mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED,
+ bo->rws->fd, args.addr_ptr);
+ if (ptr == MAP_FAILED) {
+ pipe_mutex_unlock(bo->map_mutex);
+ fprintf(stderr, "radeon: mmap failed, errno: %i\n", errno);
+ return NULL;
+ }
+ bo->ptr = ptr;
+ pipe_mutex_unlock(bo->map_mutex);
+
+ return bo->ptr;
+}
+
static void *radeon_bo_map(struct radeon_winsys_cs_handle *buf,
struct radeon_winsys_cs *rcs,
enum pipe_transfer_usage usage)
{
struct radeon_bo *bo = (struct radeon_bo*)buf;
struct radeon_drm_cs *cs = (struct radeon_drm_cs*)rcs;
- struct drm_radeon_gem_mmap args = {0};
- void *ptr;
/* If it's not unsynchronized bo_map, flush CS if needed and then wait. */
if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
@@ -466,41 +506,7 @@ static void *radeon_bo_map(struct radeon_winsys_cs_handle *buf,
}
}
- /* Return the pointer if it's already mapped. */
- if (bo->ptr)
- return bo->ptr;
-
- /* Map the buffer. */
- pipe_mutex_lock(bo->map_mutex);
- /* Return the pointer if it's already mapped (in case of a race). */
- if (bo->ptr) {
- pipe_mutex_unlock(bo->map_mutex);
- return bo->ptr;
- }
- args.handle = bo->handle;
- args.offset = 0;
- args.size = (uint64_t)bo->base.size;
- if (drmCommandWriteRead(bo->rws->fd,
- DRM_RADEON_GEM_MMAP,
- &args,
- sizeof(args))) {
- pipe_mutex_unlock(bo->map_mutex);
- fprintf(stderr, "radeon: gem_mmap failed: %p 0x%08X\n",
- bo, bo->handle);
- return NULL;
- }
-
- ptr = os_mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED,
- bo->rws->fd, args.addr_ptr);
- if (ptr == MAP_FAILED) {
- pipe_mutex_unlock(bo->map_mutex);
- fprintf(stderr, "radeon: mmap failed, errno: %i\n", errno);
- return NULL;
- }
- bo->ptr = ptr;
- pipe_mutex_unlock(bo->map_mutex);
-
- return bo->ptr;
+ return radeon_bo_do_map(bo);
}
static void radeon_bo_unmap(struct radeon_winsys_cs_handle *_buf)