[Mesa-dev] [PATCH] winsys/svga: improve error/debug message output
Brian Paul
brianp at vmware.com
Tue Mar 19 09:04:16 PDT 2013
Use vmw_printf() just for extra debugging info (off by default).
Use vmw_error() for real errors/failures/etc that we definitely
want to report.
---
src/gallium/winsys/svga/drm/vmw_context.h | 10 +++++++
src/gallium/winsys/svga/drm/vmw_screen_dri.c | 34 ++++++++++++------------
src/gallium/winsys/svga/drm/vmw_screen_ioctl.c | 16 +++++-----
3 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/src/gallium/winsys/svga/drm/vmw_context.h b/src/gallium/winsys/svga/drm/vmw_context.h
index b27e0b8..3d383cc 100644
--- a/src/gallium/winsys/svga/drm/vmw_context.h
+++ b/src/gallium/winsys/svga/drm/vmw_context.h
@@ -31,6 +31,7 @@
#ifndef VMW_CONTEXT_H_
#define VMW_CONTEXT_H_
+#include <stdio.h>
#include "pipe/p_compiler.h"
struct svga_winsys_screen;
@@ -38,6 +39,8 @@ struct svga_winsys_context;
struct pipe_context;
struct pipe_screen;
+
+/** Set to 1 to get extra debug info/output */
#define VMW_DEBUG 0
#if VMW_DEBUG
@@ -49,6 +52,13 @@ struct pipe_screen;
#endif
+/**
+ * Called when an error/failure is encountered.
+ * We want these messages reported for all build types.
+ */
+#define vmw_error(...) fprintf(stderr, "VMware: " __VA_ARGS__)
+
+
struct svga_winsys_context *
vmw_svga_winsys_context_create(struct svga_winsys_screen *sws);
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
index 3c92bb9..511cca7 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_dri.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
@@ -28,8 +28,9 @@
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_format.h"
-#include "vmw_screen.h"
+#include "vmw_context.h"
+#include "vmw_screen.h"
#include "vmw_surface.h"
#include "svga_drm_public.h"
@@ -70,13 +71,12 @@ vmw_dri1_check_version(const struct dri1_api_version *cur,
if (cur->major == required->major && cur->minor >= required->minor)
return TRUE;
- fprintf(stderr, "%s version failure.\n", component);
- fprintf(stderr, "%s version is %d.%d.%d and this driver can only work\n"
- "with versions %d.%d.x through %d.x.x.\n",
- component,
- cur->major,
- cur->minor,
- cur->patch_level, required->major, required->minor, compat->major);
+ vmw_error("%s version failure.\n", component);
+ vmw_error("%s version is %d.%d.%d and this driver can only work\n"
+ "with versions %d.%d.x through %d.x.x.\n",
+ component,
+ cur->major, cur->minor, cur->patch_level,
+ required->major, required->minor, compat->major);
return FALSE;
}
@@ -175,24 +175,24 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
&arg, sizeof(arg));
if (ret) {
- fprintf(stderr, "Failed referencing shared surface. SID %d.\n"
- "Error %d (%s).\n",
- whandle->handle, ret, strerror(-ret));
+ vmw_error("Failed referencing shared surface. SID %d.\n"
+ "Error %d (%s).\n",
+ whandle->handle, ret, strerror(-ret));
return NULL;
}
if (rep->mip_levels[0] != 1) {
- fprintf(stderr, "Incorrect number of mipmap levels on shared surface."
- " SID %d, levels %d\n",
- whandle->handle, rep->mip_levels[0]);
+ vmw_error("Incorrect number of mipmap levels on shared surface."
+ " SID %d, levels %d\n",
+ whandle->handle, rep->mip_levels[0]);
goto out_mip;
}
for (i=1; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
if (rep->mip_levels[i] != 0) {
- fprintf(stderr, "Incorrect number of faces levels on shared surface."
- " SID %d, face %d present.\n",
- whandle->handle, i);
+ vmw_error("Incorrect number of faces levels on shared surface."
+ " SID %d, face %d present.\n",
+ whandle->handle, i);
goto out_mip;
}
}
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
index e3b183a..36888dc 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
@@ -226,7 +226,7 @@ vmw_ioctl_command(struct vmw_winsys_screen *vws, int32_t cid,
ret = drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
} while(ret == -ERESTART);
if (ret) {
- debug_printf("%s error %s.\n", __FUNCTION__, strerror(-ret));
+ vmw_error("%s error %s.\n", __FUNCTION__, strerror(-ret));
}
if (rep.error) {
@@ -275,7 +275,7 @@ vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size)
} while (ret == -ERESTART);
if (ret) {
- debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
+ vmw_error("IOCTL failed %d: %s\n", ret, strerror(-ret));
goto out_err1;
}
@@ -336,7 +336,7 @@ vmw_ioctl_region_map(struct vmw_region *region)
map = os_mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
region->drm_fd, region->map_handle);
if (map == MAP_FAILED) {
- debug_printf("%s: Map failed.\n", __FUNCTION__);
+ vmw_error("%s: Map failed.\n", __FUNCTION__);
return NULL;
}
@@ -369,7 +369,7 @@ vmw_ioctl_fence_unref(struct vmw_winsys_screen *vws,
ret = drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_FENCE_UNREF,
&arg, sizeof(arg));
if (ret != 0)
- debug_printf("%s Failed\n", __FUNCTION__);
+ vmw_error("%s Failed\n", __FUNCTION__);
}
static INLINE uint32_t
@@ -430,7 +430,7 @@ vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
&arg, sizeof(arg));
if (ret != 0)
- debug_printf("%s Failed\n", __FUNCTION__);
+ vmw_error("%s Failed\n", __FUNCTION__);
return 0;
}
@@ -451,7 +451,7 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
&gp_arg, sizeof(gp_arg));
if (ret || gp_arg.value == 0) {
- debug_printf("No 3D enabled (%i, %s).\n", ret, strerror(-ret));
+ vmw_error("No 3D enabled (%i, %s).\n", ret, strerror(-ret));
goto out_no_3d;
}
@@ -460,8 +460,8 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
&gp_arg, sizeof(gp_arg));
if (ret) {
- debug_printf("Failed to get fifo hw version"
- " (%i, %s).\n", ret, strerror(-ret));
+ vmw_error("Failed to get fifo hw version (%i, %s).\n",
+ ret, strerror(-ret));
goto out_no_3d;
}
vws->ioctl.hwversion = gp_arg.value;
--
1.7.3.4
More information about the mesa-dev
mailing list