summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nvc0_fence.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-07-19 02:51:42 +0200
committerBen Skeggs <bskeggs@redhat.com>2012-10-03 05:12:54 +0200
commite193b1d42c390bf1bff7fa02a5a1202b98e75601 (patch)
treec31143ea95c00e8b49c12571b10a1b9a200bd490 /drivers/gpu/drm/nouveau/nvc0_fence.c
parentdrm/nouveau: pull nouveau_gem definitions into their own header (diff)
downloadlinux-e193b1d42c390bf1bff7fa02a5a1202b98e75601.tar.xz
linux-e193b1d42c390bf1bff7fa02a5a1202b98e75601.zip
drm/nouveau/fence: un-port from nouveau_exec_engine interfaces
Still the same code, but not an "engine" anymore. The fence code is more of a policy decision rather than exposing mechanisms, so it's not appropriate to port it to the new engine subsystem. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvc0_fence.c')
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_fence.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/drivers/gpu/drm/nouveau/nvc0_fence.c b/drivers/gpu/drm/nouveau/nvc0_fence.c
index 79bb31ed6c8b..d53ae32caea3 100644
--- a/drivers/gpu/drm/nouveau/nvc0_fence.c
+++ b/drivers/gpu/drm/nouveau/nvc0_fence.c
@@ -44,7 +44,7 @@ static int
nvc0_fence_emit(struct nouveau_fence *fence)
{
struct nouveau_channel *chan = fence->channel;
- struct nvc0_fence_chan *fctx = chan->engctx[NVOBJ_ENGINE_FENCE];
+ struct nvc0_fence_chan *fctx = chan->fence;
u64 addr = fctx->vma.offset + chan->id * 16;
int ret;
@@ -65,7 +65,7 @@ static int
nvc0_fence_sync(struct nouveau_fence *fence,
struct nouveau_channel *prev, struct nouveau_channel *chan)
{
- struct nvc0_fence_chan *fctx = chan->engctx[NVOBJ_ENGINE_FENCE];
+ struct nvc0_fence_chan *fctx = chan->fence;
u64 addr = fctx->vma.offset + prev->id * 16;
int ret;
@@ -86,30 +86,33 @@ nvc0_fence_sync(struct nouveau_fence *fence,
static u32
nvc0_fence_read(struct nouveau_channel *chan)
{
- struct nvc0_fence_priv *priv = nv_engine(chan->dev, NVOBJ_ENGINE_FENCE);
+ struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
+ struct nvc0_fence_priv *priv = dev_priv->fence.func;
return nouveau_bo_rd32(priv->bo, chan->id * 16/4);
}
static void
-nvc0_fence_context_del(struct nouveau_channel *chan, int engine)
+nvc0_fence_context_del(struct nouveau_channel *chan)
{
- struct nvc0_fence_priv *priv = nv_engine(chan->dev, engine);
- struct nvc0_fence_chan *fctx = chan->engctx[engine];
+ struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
+ struct nvc0_fence_priv *priv = dev_priv->fence.func;
+ struct nvc0_fence_chan *fctx = chan->fence;
nouveau_bo_vma_del(priv->bo, &fctx->vma);
nouveau_fence_context_del(&fctx->base);
- chan->engctx[engine] = NULL;
+ chan->fence = NULL;
kfree(fctx);
}
static int
-nvc0_fence_context_new(struct nouveau_channel *chan, int engine)
+nvc0_fence_context_new(struct nouveau_channel *chan)
{
- struct nvc0_fence_priv *priv = nv_engine(chan->dev, engine);
+ struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
+ struct nvc0_fence_priv *priv = dev_priv->fence.func;
struct nvc0_fence_chan *fctx;
int ret;
- fctx = chan->engctx[engine] = kzalloc(sizeof(*fctx), GFP_KERNEL);
+ fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
if (!fctx)
return -ENOMEM;
@@ -117,36 +120,35 @@ nvc0_fence_context_new(struct nouveau_channel *chan, int engine)
ret = nouveau_bo_vma_add(priv->bo, chan->vm, &fctx->vma);
if (ret)
- nvc0_fence_context_del(chan, engine);
+ nvc0_fence_context_del(chan);
nouveau_bo_wr32(priv->bo, chan->id * 16/4, 0x00000000);
return ret;
}
-static int
-nvc0_fence_fini(struct drm_device *dev, int engine, bool suspend)
+static bool
+nvc0_fence_suspend(struct drm_device *dev)
{
struct nouveau_fifo_priv *pfifo = nv_engine(dev, NVOBJ_ENGINE_FIFO);
- struct nvc0_fence_priv *priv = nv_engine(dev, engine);
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nvc0_fence_priv *priv = dev_priv->fence.func;
int i;
- if (suspend) {
- priv->suspend = vmalloc(pfifo->channels * sizeof(u32));
- if (!priv->suspend)
- return -ENOMEM;
-
+ priv->suspend = vmalloc(pfifo->channels * sizeof(u32));
+ if (priv->suspend) {
for (i = 0; i < pfifo->channels; i++)
priv->suspend[i] = nouveau_bo_rd32(priv->bo, i);
}
- return 0;
+ return priv->suspend != NULL;
}
-static int
-nvc0_fence_init(struct drm_device *dev, int engine)
+static void
+nvc0_fence_resume(struct drm_device *dev)
{
struct nouveau_fifo_priv *pfifo = nv_engine(dev, NVOBJ_ENGINE_FIFO);
- struct nvc0_fence_priv *priv = nv_engine(dev, engine);
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nvc0_fence_priv *priv = dev_priv->fence.func;
int i;
if (priv->suspend) {
@@ -155,19 +157,17 @@ nvc0_fence_init(struct drm_device *dev, int engine)
vfree(priv->suspend);
priv->suspend = NULL;
}
-
- return 0;
}
static void
-nvc0_fence_destroy(struct drm_device *dev, int engine)
+nvc0_fence_destroy(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct nvc0_fence_priv *priv = nv_engine(dev, engine);
+ struct nvc0_fence_priv *priv = dev_priv->fence.func;
nouveau_bo_unmap(priv->bo);
nouveau_bo_ref(NULL, &priv->bo);
- dev_priv->eng[engine] = NULL;
+ dev_priv->fence.func = NULL;
kfree(priv);
}
@@ -183,15 +183,15 @@ nvc0_fence_create(struct drm_device *dev)
if (!priv)
return -ENOMEM;
- priv->base.engine.destroy = nvc0_fence_destroy;
- priv->base.engine.init = nvc0_fence_init;
- priv->base.engine.fini = nvc0_fence_fini;
- priv->base.engine.context_new = nvc0_fence_context_new;
- priv->base.engine.context_del = nvc0_fence_context_del;
+ priv->base.dtor = nvc0_fence_destroy;
+ priv->base.suspend = nvc0_fence_suspend;
+ priv->base.resume = nvc0_fence_resume;
+ priv->base.context_new = nvc0_fence_context_new;
+ priv->base.context_del = nvc0_fence_context_del;
priv->base.emit = nvc0_fence_emit;
priv->base.sync = nvc0_fence_sync;
priv->base.read = nvc0_fence_read;
- dev_priv->eng[NVOBJ_ENGINE_FENCE] = &priv->base.engine;
+ dev_priv->fence.func = priv;
ret = nouveau_bo_new(dev, 16 * pfifo->channels, 0, TTM_PL_FLAG_VRAM,
0, 0, NULL, &priv->bo);
@@ -204,6 +204,6 @@ nvc0_fence_create(struct drm_device *dev)
}
if (ret)
- nvc0_fence_destroy(dev, NVOBJ_ENGINE_FENCE);
+ nvc0_fence_destroy(dev);
return ret;
}