summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2003-05-01 13:02:33 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2003-05-01 13:02:33 +0000
commit62299f69fd79528a1ce3c3544e2033846a107cf0 (patch)
treeeefe0f610c75e9c76e85f5a18e8b4c3a99e5ca10
parentb899261af6898835d230686304b055f301b3cd0d (diff)
Use mprotect() to protect the sarea when not in focus.
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c45
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.h3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_ioctl.c19
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_ioctl.h1
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_subset.h2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_subset_vtx.c22
-rw-r--r--src/mesa/drivers/dri/radeon/server/radeon_dri.c4
7 files changed, 63 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 7b325b6b31..130cecc622 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -61,7 +61,10 @@
#include "X86/common_x86_asm.h"
#endif
-#define RADEON_DATE "20021125"
+#include <sys/mman.h>
+
+
+#define RADEON_DATE "20030501"
#ifndef RADEON_DEBUG
int RADEON_DEBUG = (0);
@@ -517,6 +520,7 @@ radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
#endif
if (rmesa->dma.current.buf) {
+ assert(rmesa->radeonScreen->buffers);
radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
radeonFlushCmdBuf( rmesa, __FUNCTION__ );
}
@@ -715,6 +719,45 @@ radeonUnbindContext( __DRIcontextPrivate *driContextPriv )
}
+
+
+void radeonNotifyFocus( int have_focus )
+{
+#if !_HAVE_FULL_GL
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int SAREASize = rmesa->dri.screen->display->driverContext.shared.SAREASize;
+
+ if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1)
+ ctx->Exec->End();
+
+ if (have_focus && !rmesa->radeonScreen->buffers) {
+ rmesa->radeonScreen->buffers = drmMapBufs( rmesa->dri.fd );
+
+ /* Use mprotect rather than unmapping the framebuffer due to the
+ * large number of derived pointers into the sarea which would
+ * have to be updated if it changed its location on re-mapping.
+ */
+ mprotect(rmesa->dri.screen->pSAREA, SAREASize, PROT_READ|PROT_WRITE);
+ }
+ else if (!have_focus && rmesa->radeonScreen->buffers) {
+ if (rmesa->dma.current.buf)
+ radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
+ RADEON_FIREVERTICES( rmesa );
+
+ drmUnmapBufs( rmesa->radeonScreen->buffers );
+ rmesa->radeonScreen->buffers = 0;
+
+ mprotect(rmesa->dri.screen->pSAREA, SAREASize, PROT_NONE);
+
+ assert(!rmesa->dma.current.buf);
+ }
+
+ radeonVtxfmtInit( ctx );
+#endif
+}
+
+
/**
* \brief Open/close fullscreen mode.
*
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h
index 4f041e2d15..eacefb19a7 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_context.h
@@ -755,6 +755,9 @@ static __inline GLuint radeonPackColor( GLuint cpp,
}
+extern void radeonNotifyFocus( int have_focus );
+
+
/******************************************************************
* Debugging:
*/
diff --git a/src/mesa/drivers/dri/radeon/radeon_ioctl.c b/src/mesa/drivers/dri/radeon/radeon_ioctl.c
index 9b10fc1389..4e5650ac82 100644
--- a/src/mesa/drivers/dri/radeon/radeon_ioctl.c
+++ b/src/mesa/drivers/dri/radeon/radeon_ioctl.c
@@ -185,6 +185,7 @@ extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
assert(rmesa->dri.drmMinor >= 3);
assert(!(primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
+ assert(rmesa->radeonScreen->buffers );
radeonEmitState( rmesa );
@@ -248,6 +249,7 @@ GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
assert(rmesa->dri.drmMinor >= 3);
assert((primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
+ assert(rmesa->radeonScreen->buffers );
radeonEmitState( rmesa );
@@ -398,6 +400,7 @@ void radeonFlushCmdBuf( radeonContextPtr rmesa, const char *caller )
{
int ret;
assert (rmesa->dri.drmMinor >= 3);
+ assert (rmesa->radeonScreen->buffers);
LOCK_HARDWARE( rmesa );
ret = radeonFlushCmdBufLocked( rmesa, caller );
@@ -442,9 +445,10 @@ void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa )
if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
fprintf(stderr, "%s\n", __FUNCTION__);
- if (rmesa->dma.flush) {
+ assert( rmesa->radeonScreen->buffers );
+
+ if (rmesa->dma.flush)
rmesa->dma.flush( rmesa );
- }
if (rmesa->dma.current.buf)
radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
@@ -750,6 +754,8 @@ static void radeonWaitForFrameCompletion( radeonContextPtr rmesa )
{
RADEONSAREAPrivPtr sarea = rmesa->sarea;
+ assert (rmesa->radeonScreen->buffers);
+
if (rmesa->do_irqs) {
if (radeonGetLastFrame(rmesa) < sarea->last_frame) {
if (!rmesa->irqsEmitted) {
@@ -773,7 +779,7 @@ static void radeonWaitForFrameCompletion( radeonContextPtr rmesa )
while (radeonGetLastFrame (rmesa) < sarea->last_frame) {
UNLOCK_HARDWARE( rmesa );
if (rmesa->do_usleeps)
- usleep(1);
+ usleep(1);
LOCK_HARDWARE( rmesa );
}
}
@@ -1160,9 +1166,10 @@ void radeonWaitForIdleLocked( radeonContextPtr rmesa )
*/
static void radeonWaitForIdle( radeonContextPtr rmesa )
{
- LOCK_HARDWARE(rmesa);
- radeonWaitForIdleLocked( rmesa );
- UNLOCK_HARDWARE(rmesa);
+ assert(rmesa->radeonScreen->buffers);
+ LOCK_HARDWARE(rmesa);
+ radeonWaitForIdleLocked( rmesa );
+ UNLOCK_HARDWARE(rmesa);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_ioctl.h b/src/mesa/drivers/dri/radeon/radeon_ioctl.h
index 0adb182b2b..23e64bb442 100644
--- a/src/mesa/drivers/dri/radeon/radeon_ioctl.h
+++ b/src/mesa/drivers/dri/radeon/radeon_ioctl.h
@@ -179,6 +179,7 @@ static __inline char *radeonAllocCmdBuf( radeonContextPtr rmesa,
radeonFlushCmdBuf( rmesa, __FUNCTION__ );
assert(rmesa->dri.drmMinor >= 3);
+ assert(rmesa->radeonScreen->buffers);
{
char *head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
diff --git a/src/mesa/drivers/dri/radeon/radeon_subset.h b/src/mesa/drivers/dri/radeon/radeon_subset.h
index c7f169281e..1b6e7bd432 100644
--- a/src/mesa/drivers/dri/radeon/radeon_subset.h
+++ b/src/mesa/drivers/dri/radeon/radeon_subset.h
@@ -72,6 +72,4 @@ extern void radeonAgeTextures( radeonContextPtr rmesa, int heap );
extern void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t );
-extern void radeonVtxfmtNotifyFocus( int have_focus );
-
#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c b/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c
index 8533f7be68..235f4acea3 100644
--- a/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c
+++ b/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c
@@ -50,7 +50,6 @@
#include "radeon_ioctl.h"
#include "radeon_subset.h"
-
/**
* \brief Union for vertex data.
*/
@@ -988,24 +987,3 @@ void radeonVtxfmtInit( GLcontext *ctx )
/*@}*/
-void radeonVtxfmtNotifyFocus( int have_focus )
-{
- GET_CURRENT_CONTEXT(ctx);
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1)
- radeon_End();
-
- if (have_focus && !rmesa->radeonScreen->buffers) {
- rmesa->radeonScreen->buffers = drmMapBufs( rmesa->dri.fd );
- }
- else if (!have_focus && rmesa->radeonScreen->buffers) {
- RADEON_FIREVERTICES( rmesa );
- drmUnmapBufs( rmesa->radeonScreen->buffers );
- rmesa->radeonScreen->buffers = 0;
-/* assert(!rmesa->dma.current.buf); */
- }
-
- radeonVtxfmtInit( ctx );
-}
-
diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/src/mesa/drivers/dri/radeon/server/radeon_dri.c
index dc467f9669..298f646773 100644
--- a/src/mesa/drivers/dri/radeon/server/radeon_dri.c
+++ b/src/mesa/drivers/dri/radeon/server/radeon_dri.c
@@ -1228,7 +1228,7 @@ static void radeonHaltFBDev( struct DRIDriverContextRec *ctx )
}
-extern void radeonVtxfmtNotifyFocus( int );
+extern void radeonNotifyFocus( int );
/**
* \brief Exported driver interface for Mini GLX.
@@ -1246,6 +1246,6 @@ struct DRIDriverRec __driDriver = {
#if _HAVE_FULL_GL
0,
#else
- radeonVtxfmtNotifyFocus,
+ radeonNotifyFocus,
#endif
};