summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/nouveau/nouveau_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nouveau_sync.c')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_sync.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
index 30e6696269..1d1eeede18 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
@@ -35,53 +35,51 @@
#include "nouveau_msg.h"
#include "nouveau_sync.h"
-nouveau_notifier *
+#define NOTIFIER(__v) \
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
+ volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset
+
+drm_nouveau_notifier_alloc_t *
nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- nouveau_notifier *notifier;
+ drm_nouveau_notifier_alloc_t *notifier;
+ int ret;
#ifdef NOUVEAU_RING_DEBUG
return NULL;
#endif
- notifier = CALLOC_STRUCT(nouveau_notifier_t);
+ notifier = CALLOC_STRUCT(drm_nouveau_notifier_alloc);
if (!notifier)
return NULL;
- notifier->mem = nouveau_mem_alloc(ctx,
- NOUVEAU_MEM_FB | NOUVEAU_MEM_MAPPED,
- count * NV_NOTIFIER_SIZE,
- 0);
- if (!notifier->mem) {
- FREE(notifier);
- return NULL;
- }
-
- if (!nouveauCreateDmaObjectFromMem(nmesa, handle, NV_DMA_IN_MEMORY,
- notifier->mem,
- NOUVEAU_MEM_ACCESS_RW)) {
- nouveau_mem_free(ctx, notifier->mem);
+ notifier->channel = nmesa->fifo.channel;
+ notifier->handle = handle;
+ notifier->count = count;
+ ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIER_ALLOC,
+ notifier, sizeof(*notifier));
+ if (ret) {
+ MESSAGE("Failed to create notifier 0x%08x: %d\n", handle, ret);
FREE(notifier);
return NULL;
}
- notifier->handle = handle;
return notifier;
}
void
-nouveau_notifier_destroy(GLcontext *ctx, nouveau_notifier *notifier)
+nouveau_notifier_destroy(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier)
{
- /*XXX: free DMA object.. */
- nouveau_mem_free(ctx, notifier->mem);
+ /*XXX: free notifier object.. */
FREE(notifier);
}
void
-nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id)
+nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
+ GLuint id)
{
- volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
+ NOTIFIER(n);
#ifdef NOUVEAU_RING_DEBUG
return;
@@ -95,26 +93,29 @@ nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id)
}
GLuint
-nouveau_notifier_status(nouveau_notifier *notifier, GLuint id)
+nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
+ GLuint id)
{
- volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
+ NOTIFIER(n);
return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT;
}
GLuint
-nouveau_notifier_return_val(nouveau_notifier *notifier, GLuint id)
+nouveau_notifier_return_val(GLcontext *ctx,
+ drm_nouveau_notifier_alloc_t *notifier, GLuint id)
{
- volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
+ NOTIFIER(n);
return n[NV_NOTIFY_RETURN_VALUE/4];
}
GLboolean
-nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id,
+nouveau_notifier_wait_status(GLcontext *ctx,
+ drm_nouveau_notifier_alloc_t *notifier, GLuint id,
GLuint status, GLuint timeout)
{
- volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
+ NOTIFIER(n);
unsigned int time = 0;
#ifdef NOUVEAU_RING_DEBUG
@@ -144,13 +145,13 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id,
}
void
-nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier,
- GLuint subc)
+nouveau_notifier_wait_nop(GLcontext *ctx,
+ drm_nouveau_notifier_alloc_t *notifier, GLuint subc)
{
- nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+ NOTIFIER(n);
GLboolean ret;
- nouveau_notifier_reset(notifier, 0);
+ nouveau_notifier_reset(ctx, notifier, 0);
BEGIN_RING_SIZE(subc, NV_NOTIFY, 1);
OUT_RING (NV_NOTIFY_STYLE_WRITE_ONLY);
@@ -158,7 +159,7 @@ nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier,
OUT_RING (0);
FIRE_RING();
- ret = nouveau_notifier_wait_status(notifier, 0,
+ ret = nouveau_notifier_wait_status(ctx, notifier, 0,
NV_NOTIFY_STATE_STATUS_COMPLETED,
0 /* no timeout */);
if (ret == GL_FALSE) MESSAGE("wait on notifier failed\n");