summaryrefslogtreecommitdiff
path: root/shared-core/nouveau_notifier.c
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-08-06 03:40:43 +1000
committerBen Skeggs <skeggsb@gmail.com>2007-08-06 03:40:43 +1000
commitbeaa0c9a28b30a6ba3292184d04875b6a597e433 (patch)
tree95bf8cb4538ebab2663849b42101c143708c7e12 /shared-core/nouveau_notifier.c
parent2453ba19b6f9956ea5d412a66d5d33c8a8b301b2 (diff)
nouveau: Pass channel struct around instead of channel id.
Diffstat (limited to 'shared-core/nouveau_notifier.c')
-rw-r--r--shared-core/nouveau_notifier.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/shared-core/nouveau_notifier.c b/shared-core/nouveau_notifier.c
index 7a982ba4..b1090587 100644
--- a/shared-core/nouveau_notifier.c
+++ b/shared-core/nouveau_notifier.c
@@ -30,11 +30,10 @@
#include "nouveau_drv.h"
int
-nouveau_notifier_init_channel(struct drm_device *dev, int channel,
- struct drm_file *file_priv)
+nouveau_notifier_init_channel(struct nouveau_channel *chan)
{
+ struct drm_device *dev = chan->dev;
struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct nouveau_fifo *chan = dev_priv->fifos[channel];
int flags, ret;
/*TODO: PCI notifier blocks */
@@ -47,9 +46,9 @@ nouveau_notifier_init_channel(struct drm_device *dev, int channel,
flags = NOUVEAU_MEM_FB;
flags |= NOUVEAU_MEM_MAPPED;
-DRM_DEBUG("Allocating notifier block in %d\n", flags);
+ DRM_DEBUG("Allocating notifier block in %d\n", flags);
chan->notifier_block = nouveau_mem_alloc(dev, 0, PAGE_SIZE, flags,
- file_priv);
+ (struct drm_file *)-2);
if (!chan->notifier_block)
return -ENOMEM;
@@ -62,25 +61,23 @@ DRM_DEBUG("Allocating notifier block in %d\n", flags);
}
void
-nouveau_notifier_takedown_channel(struct drm_device *dev, int channel)
+nouveau_notifier_takedown_channel(struct nouveau_channel *chan)
{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct nouveau_fifo *chan = dev_priv->fifos[channel];
+ struct drm_device *dev = chan->dev;
if (chan->notifier_block) {
nouveau_mem_free(dev, chan->notifier_block);
chan->notifier_block = NULL;
}
- /*XXX: heap destroy */
+ nouveau_mem_takedown(&chan->notifier_heap);
}
int
-nouveau_notifier_alloc(struct drm_device *dev, int channel, uint32_t handle,
+nouveau_notifier_alloc(struct nouveau_channel *chan, uint32_t handle,
int count, uint32_t *b_offset)
{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct nouveau_fifo *chan = dev_priv->fifos[channel];
+ struct drm_device *dev = chan->dev;
struct nouveau_gpuobj *nobj = NULL;
struct mem_block *mem;
uint32_t offset;
@@ -88,14 +85,14 @@ nouveau_notifier_alloc(struct drm_device *dev, int channel, uint32_t handle,
if (!chan->notifier_heap) {
DRM_ERROR("Channel %d doesn't have a notifier heap!\n",
- channel);
+ chan->id);
return -EINVAL;
}
mem = nouveau_mem_alloc_block(chan->notifier_heap, 32, 0,
chan->file_priv);
if (!mem) {
- DRM_ERROR("Channel %d notifier block full\n", channel);
+ DRM_ERROR("Channel %d notifier block full\n", chan->id);
return -ENOMEM;
}
mem->flags = NOUVEAU_MEM_NOTIFIER;
@@ -113,7 +110,7 @@ nouveau_notifier_alloc(struct drm_device *dev, int channel, uint32_t handle,
return -EINVAL;
}
- if ((ret = nouveau_gpuobj_dma_new(dev, channel, NV_CLASS_DMA_IN_MEMORY,
+ if ((ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY,
offset, mem->size,
NV_DMA_ACCESS_RW, target, &nobj))) {
nouveau_mem_free_block(mem);
@@ -121,7 +118,7 @@ nouveau_notifier_alloc(struct drm_device *dev, int channel, uint32_t handle,
return ret;
}
- if ((ret = nouveau_gpuobj_ref_add(dev, channel, handle, nobj, NULL))) {
+ if ((ret = nouveau_gpuobj_ref_add(dev, chan, handle, nobj, NULL))) {
nouveau_gpuobj_del(dev, &nobj);
nouveau_mem_free_block(mem);
DRM_ERROR("Error referencing notifier ctxdma: %d\n", ret);
@@ -133,19 +130,16 @@ nouveau_notifier_alloc(struct drm_device *dev, int channel, uint32_t handle,
}
int
-nouveau_ioctl_notifier_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
+nouveau_ioctl_notifier_alloc(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
{
struct drm_nouveau_notifier_alloc *na = data;
+ struct nouveau_channel *chan;
int ret;
- if (!nouveau_fifo_owner(dev, file_priv, na->channel)) {
- DRM_ERROR("pid %d doesn't own channel %d\n",
- DRM_CURRENTPID, na->channel);
- return -EPERM;
- }
+ NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(na->channel, file_priv, chan);
- ret = nouveau_notifier_alloc(dev, na->channel, na->handle,
- na->count, &na->offset);
+ ret = nouveau_notifier_alloc(chan, na->handle, na->count, &na->offset);
if (ret)
return ret;