summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Glisse <glisse@freedesktop.org>2008-11-10 22:18:22 +0100
committerJerome Glisse <glisse@freedesktop.org>2008-11-10 22:18:22 +0100
commit72997fb3726b99b99c44e96e59abd8c70abbd8be (patch)
tree48bcd7528e100ed5e5c97725f1d2c64afd0cab66
parent7abb8416a7fd8d69f1f2317cdac2baa8e640671e (diff)
libdrm-radeon: be verbose on bo failure and cleanup cs a bit
-rw-r--r--libdrm/radeon/radeon_bo_gem.c11
-rw-r--r--libdrm/radeon/radeon_cs_gem.c75
2 files changed, 44 insertions, 42 deletions
diff --git a/libdrm/radeon/radeon_bo_gem.c b/libdrm/radeon/radeon_bo_gem.c
index fc198711..8ce82919 100644
--- a/libdrm/radeon/radeon_bo_gem.c
+++ b/libdrm/radeon/radeon_bo_gem.c
@@ -99,11 +99,15 @@ static struct radeon_bo *bo_open(struct radeon_bo_manager *bom,
&args, sizeof(args));
bo->base.handle = args.handle;
if (r) {
+ fprintf(stderr, "Failed to allocate :\n");
+ fprintf(stderr, " size : %d bytes\n", size);
+ fprintf(stderr, " alignment : %d bytes\n", alignment);
+ fprintf(stderr, " domains : %d\n", bo->base.domains);
free(bo);
return NULL;
}
}
- radeon_bo_ref(bo);
+ radeon_bo_ref((struct radeon_bo*)bo);
return (struct radeon_bo*)bo;
}
@@ -137,7 +141,6 @@ static int bo_map(struct radeon_bo *bo, int write)
struct radeon_bo_gem *bo_gem = (struct radeon_bo_gem*)bo;
struct drm_radeon_gem_mmap args;
int r;
- uint8_t *tt;
if (bo_gem->map_count++ != 0) {
return 0;
@@ -152,8 +155,10 @@ static int bo_map(struct radeon_bo *bo, int write)
sizeof(args));
if (!r) {
bo->ptr = (void *)(unsigned long)args.addr_ptr;
+ } else {
+ fprintf(stderr, "error mapping %p 0x%08X (error = %d)\n",
+ bo, bo->handle, r);
}
- tt = bo->ptr;
return r;
}
diff --git a/libdrm/radeon/radeon_cs_gem.c b/libdrm/radeon/radeon_cs_gem.c
index 00aa9086..6be1728f 100644
--- a/libdrm/radeon/radeon_cs_gem.c
+++ b/libdrm/radeon/radeon_cs_gem.c
@@ -58,8 +58,8 @@ struct cs_gem {
struct radeon_bo **relocs_bo;
};
-static struct radeon_cs *cs_create(struct radeon_cs_manager *csm,
- uint32_t ndw)
+static struct radeon_cs *cs_gem_create(struct radeon_cs_manager *csm,
+ uint32_t ndw)
{
struct cs_gem *csg;
@@ -104,7 +104,7 @@ static struct radeon_cs *cs_create(struct radeon_cs_manager *csm,
return (struct radeon_cs*)csg;
}
-static int cs_write_dword(struct radeon_cs *cs, uint32_t dword)
+static int cs_gem_write_dword(struct radeon_cs *cs, uint32_t dword)
{
struct cs_gem *csg = (struct cs_gem*)cs;
if (cs->cdw >= cs->ndw) {
@@ -123,11 +123,11 @@ static int cs_write_dword(struct radeon_cs *cs, uint32_t dword)
return 0;
}
-static int cs_write_reloc(struct radeon_cs *cs,
- struct radeon_bo *bo,
- uint32_t soffset,
- uint32_t eoffset,
- uint32_t domains)
+static int cs_gem_write_reloc(struct radeon_cs *cs,
+ struct radeon_bo *bo,
+ uint32_t soffset,
+ uint32_t eoffset,
+ uint32_t domains)
{
struct cs_gem *csg = (struct cs_gem*)cs;
struct cs_reloc_gem *reloc;
@@ -162,8 +162,8 @@ static int cs_write_reloc(struct radeon_cs *cs,
break;
}
reloc->cnt++;
- cs_write_dword(cs, 0xc0001000);
- cs_write_dword(cs, idx);
+ cs_gem_write_dword(cs, 0xc0001000);
+ cs_gem_write_dword(cs, idx);
return 0;
}
}
@@ -208,31 +208,31 @@ static int cs_write_reloc(struct radeon_cs *cs,
csg->chunks[1].length_dw += 4;
radeon_bo_ref(bo);
cs->relocs_total_size += bo->size;
- cs_write_dword(cs, 0xc0001000);
- cs_write_dword(cs, idx);
+ cs_gem_write_dword(cs, 0xc0001000);
+ cs_gem_write_dword(cs, idx);
return 0;
}
-static int cs_begin(struct radeon_cs *cs,
- uint32_t ndw,
- const char *file,
- const char *func,
- int line)
+static int cs_gem_begin(struct radeon_cs *cs,
+ uint32_t ndw,
+ const char *file,
+ const char *func,
+ int line)
{
return 0;
}
-static int cs_end(struct radeon_cs *cs,
- const char *file,
- const char *func,
- int line)
+static int cs_gem_end(struct radeon_cs *cs,
+ const char *file,
+ const char *func,
+ int line)
{
cs->section = 0;
return 0;
}
-static int cs_emit(struct radeon_cs *cs)
+static int cs_gem_emit(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
uint64_t chunk_array[2];
@@ -249,13 +249,10 @@ static int cs_emit(struct radeon_cs *cs)
if (r) {
return r;
}
- for(i = 0; i < cs->crelocs; i++) {
- radeon_bo_unref(csg->relocs_bo[i]);
- }
return 0;
}
-static int cs_destroy(struct radeon_cs *cs)
+static int cs_gem_destroy(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
@@ -266,7 +263,7 @@ static int cs_destroy(struct radeon_cs *cs)
return 0;
}
-static int cs_erase(struct radeon_cs *cs)
+static int cs_gem_erase(struct radeon_cs *cs)
{
struct cs_gem *csg = (struct cs_gem*)cs;
@@ -279,21 +276,21 @@ static int cs_erase(struct radeon_cs *cs)
return 0;
}
-static int cs_need_flush(struct radeon_cs *cs)
+static int cs_gem_need_flush(struct radeon_cs *cs)
{
return (cs->relocs_total_size > (16*1024*1024));
}
-struct radeon_cs_funcs radeon_cs_funcs = {
- cs_create,
- cs_write_dword,
- cs_write_reloc,
- cs_begin,
- cs_end,
- cs_emit,
- cs_destroy,
- cs_erase,
- cs_need_flush
+static struct radeon_cs_funcs radeon_cs_gem_funcs = {
+ cs_gem_create,
+ cs_gem_write_dword,
+ cs_gem_write_reloc,
+ cs_gem_begin,
+ cs_gem_end,
+ cs_gem_emit,
+ cs_gem_destroy,
+ cs_gem_erase,
+ cs_gem_need_flush
};
struct radeon_cs_manager *radeon_cs_manager_gem(int fd)
@@ -305,7 +302,7 @@ struct radeon_cs_manager *radeon_cs_manager_gem(int fd)
if (csm == NULL) {
return NULL;
}
- csm->funcs = &radeon_cs_funcs;
+ csm->funcs = &radeon_cs_gem_funcs;
csm->fd = fd;
return csm;
}