summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-11-24 11:00:53 +1000
committerBen Skeggs <bskeggs@redhat.com>2015-12-22 13:22:28 +1000
commit4283e3f656541c4533c89b2cdc501aa6dc7da3dc (patch)
treec6f7a1a0021b626b868e173871671cb8fca4b031
parentcdf9029f5f2d3d7c7b77eda2a5d3ef3b44a82cdf (diff)
downloaddrm-4283e3f656541c4533c89b2cdc501aa6dc7da3dc.tar.gz
nouveau: make use of nouveau_drm::fd instead of nouveau_device::fd
The latter is deprecated, and will not be valid for newer clients. v2. - split out nouveau_object_find removal Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--nouveau/abi16.c32
-rw-r--r--nouveau/nouveau.c32
-rw-r--r--nouveau/pushbuf.c7
3 files changed, 40 insertions, 31 deletions
diff --git a/nouveau/abi16.c b/nouveau/abi16.c
index f260bf95..46350b13 100644
--- a/nouveau/abi16.c
+++ b/nouveau/abi16.c
@@ -38,7 +38,7 @@
static int
abi16_chan_nv04(struct nouveau_object *obj)
{
- struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
+ struct nouveau_drm *drm = nouveau_drm(obj);
struct nv04_fifo *nv04 = obj->data;
struct drm_nouveau_channel_alloc req = {
.fb_ctxdma_handle = nv04->vram,
@@ -46,7 +46,7 @@ abi16_chan_nv04(struct nouveau_object *obj)
};
int ret;
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -62,12 +62,12 @@ abi16_chan_nv04(struct nouveau_object *obj)
static int
abi16_chan_nvc0(struct nouveau_object *obj)
{
- struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
+ struct nouveau_drm *drm = nouveau_drm(obj);
struct drm_nouveau_channel_alloc req = {};
struct nvc0_fifo *nvc0 = obj->data;
int ret;
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -83,7 +83,7 @@ abi16_chan_nvc0(struct nouveau_object *obj)
static int
abi16_chan_nve0(struct nouveau_object *obj)
{
- struct nouveau_device *dev = (struct nouveau_device *)obj->parent;
+ struct nouveau_drm *drm = nouveau_drm(obj);
struct drm_nouveau_channel_alloc req = {};
struct nve0_fifo *nve0 = obj->data;
int ret;
@@ -93,7 +93,7 @@ abi16_chan_nve0(struct nouveau_object *obj)
req.tt_ctxdma_handle = nve0->engine;
}
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_CHANNEL_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -109,12 +109,12 @@ abi16_chan_nve0(struct nouveau_object *obj)
static int
abi16_engobj(struct nouveau_object *obj)
{
+ struct nouveau_drm *drm = nouveau_drm(obj);
struct drm_nouveau_grobj_alloc req = {
.channel = obj->parent->handle,
.handle = obj->handle,
.class = obj->oclass,
};
- struct nouveau_device *dev;
int ret;
/* Older kernel versions did not have the concept of nouveau-
@@ -138,8 +138,7 @@ abi16_engobj(struct nouveau_object *obj)
break;
}
- dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
- ret = drmCommandWrite(dev->fd, DRM_NOUVEAU_GROBJ_ALLOC,
+ ret = drmCommandWrite(drm->fd, DRM_NOUVEAU_GROBJ_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -151,17 +150,16 @@ abi16_engobj(struct nouveau_object *obj)
static int
abi16_ntfy(struct nouveau_object *obj)
{
+ struct nouveau_drm *drm = nouveau_drm(obj);
struct nv04_notify *ntfy = obj->data;
struct drm_nouveau_notifierobj_alloc req = {
.channel = obj->parent->handle,
.handle = ntfy->object->handle,
.size = ntfy->length,
};
- struct nouveau_device *dev;
int ret;
- dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC,
&req, sizeof(req));
if (ret)
return ret;
@@ -223,18 +221,17 @@ abi16_sclass(struct nouveau_object *obj, struct nouveau_sclass **psclass)
drm_private void
abi16_delete(struct nouveau_object *obj)
{
- struct nouveau_device *dev =
- nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
+ struct nouveau_drm *drm = nouveau_drm(obj);
if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
struct drm_nouveau_channel_free req;
req.channel = obj->handle;
- drmCommandWrite(dev->fd, DRM_NOUVEAU_CHANNEL_FREE,
+ drmCommandWrite(drm->fd, DRM_NOUVEAU_CHANNEL_FREE,
&req, sizeof(req));
} else {
struct drm_nouveau_gpuobj_free req;
req.channel = obj->parent->handle;
req.handle = obj->handle;
- drmCommandWrite(dev->fd, DRM_NOUVEAU_GPUOBJ_FREE,
+ drmCommandWrite(drm->fd, DRM_NOUVEAU_GPUOBJ_FREE,
&req, sizeof(req));
}
}
@@ -314,6 +311,7 @@ abi16_bo_init(struct nouveau_bo *bo, uint32_t alignment,
union nouveau_bo_config *config)
{
struct nouveau_device *dev = bo->device;
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_gem_new req = {};
struct drm_nouveau_gem_info *info = &req.info;
int ret;
@@ -356,7 +354,7 @@ abi16_bo_init(struct nouveau_bo *bo, uint32_t alignment,
if (!nouveau_device(dev)->have_bo_usage)
info->tile_flags &= 0x0000ff00;
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_NEW,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_NEW,
&req, sizeof(req));
if (ret == 0)
abi16_bo_info(bo, &req.info);
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index d129ae82..b474c775 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -345,8 +345,9 @@ nouveau_device_del(struct nouveau_device **pdev)
int
nouveau_getparam(struct nouveau_device *dev, uint64_t param, uint64_t *value)
{
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_getparam r = { .param = param };
- int fd = dev->fd, ret =
+ int fd = drm->fd, ret =
drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &r, sizeof(r));
*value = r.value;
return ret;
@@ -355,8 +356,9 @@ nouveau_getparam(struct nouveau_device *dev, uint64_t param, uint64_t *value)
int
nouveau_setparam(struct nouveau_device *dev, uint64_t param, uint64_t value)
{
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_setparam r = { .param = param, .value = value };
- return drmCommandWrite(dev->fd, DRM_NOUVEAU_SETPARAM, &r, sizeof(r));
+ return drmCommandWrite(drm->fd, DRM_NOUVEAU_SETPARAM, &r, sizeof(r));
}
int
@@ -417,6 +419,7 @@ nouveau_client_del(struct nouveau_client **pclient)
static void
nouveau_bo_del(struct nouveau_bo *bo)
{
+ struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_device_priv *nvdev = nouveau_device(bo->device);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
struct drm_gem_close req = { .handle = bo->handle };
@@ -433,11 +436,11 @@ nouveau_bo_del(struct nouveau_bo *bo)
* might cause the bo to be closed accidentally while
* re-importing.
*/
- drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
+ drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
pthread_mutex_unlock(&nvdev->lock);
} else {
- drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
+ drmIoctl(drm->fd, DRM_IOCTL_GEM_CLOSE, &req);
}
if (bo->map)
drm_munmap(bo->map, bo->size);
@@ -474,6 +477,7 @@ static int
nouveau_bo_wrap_locked(struct nouveau_device *dev, uint32_t handle,
struct nouveau_bo **pbo, int name)
{
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct nouveau_device_priv *nvdev = nouveau_device(dev);
struct drm_nouveau_gem_info req = { .handle = handle };
struct nouveau_bo_priv *nvbo;
@@ -503,7 +507,7 @@ nouveau_bo_wrap_locked(struct nouveau_device *dev, uint32_t handle,
}
}
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_INFO,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_INFO,
&req, sizeof(req));
if (ret)
return ret;
@@ -550,6 +554,7 @@ int
nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name,
struct nouveau_bo **pbo)
{
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct nouveau_device_priv *nvdev = nouveau_device(dev);
struct nouveau_bo_priv *nvbo;
struct drm_gem_open req = { .name = name };
@@ -565,7 +570,7 @@ nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name,
}
}
- ret = drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req);
+ ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_OPEN, &req);
if (ret == 0) {
ret = nouveau_bo_wrap_locked(dev, req.handle, pbo, name);
}
@@ -578,11 +583,12 @@ int
nouveau_bo_name_get(struct nouveau_bo *bo, uint32_t *name)
{
struct drm_gem_flink req = { .handle = bo->handle };
+ struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
*name = nvbo->name;
if (!*name) {
- int ret = drmIoctl(bo->device->fd, DRM_IOCTL_GEM_FLINK, &req);
+ int ret = drmIoctl(drm->fd, DRM_IOCTL_GEM_FLINK, &req);
if (ret) {
*name = 0;
@@ -613,6 +619,7 @@ int
nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
struct nouveau_bo **bo)
{
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct nouveau_device_priv *nvdev = nouveau_device(dev);
int ret;
unsigned int handle;
@@ -620,7 +627,7 @@ nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
nouveau_bo_ref(NULL, bo);
pthread_mutex_lock(&nvdev->lock);
- ret = drmPrimeFDToHandle(dev->fd, prime_fd, &handle);
+ ret = drmPrimeFDToHandle(drm->fd, prime_fd, &handle);
if (ret == 0) {
ret = nouveau_bo_wrap_locked(dev, handle, bo, 0);
}
@@ -631,10 +638,11 @@ nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
int
nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd)
{
+ struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
int ret;
- ret = drmPrimeHandleToFD(bo->device->fd, nvbo->base.handle, DRM_CLOEXEC, prime_fd);
+ ret = drmPrimeHandleToFD(drm->fd, nvbo->base.handle, DRM_CLOEXEC, prime_fd);
if (ret)
return ret;
@@ -646,6 +654,7 @@ int
nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access,
struct nouveau_client *client)
{
+ struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
struct drm_nouveau_gem_cpu_prep req;
struct nouveau_pushbuf *push;
@@ -669,7 +678,7 @@ nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access,
if (access & NOUVEAU_BO_NOBLOCK)
req.flags |= NOUVEAU_GEM_CPU_PREP_NOWAIT;
- ret = drmCommandWrite(bo->device->fd, DRM_NOUVEAU_GEM_CPU_PREP,
+ ret = drmCommandWrite(drm->fd, DRM_NOUVEAU_GEM_CPU_PREP,
&req, sizeof(req));
if (ret == 0)
nvbo->access = 0;
@@ -680,10 +689,11 @@ int
nouveau_bo_map(struct nouveau_bo *bo, uint32_t access,
struct nouveau_client *client)
{
+ struct nouveau_drm *drm = nouveau_drm(&bo->device->object);
struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
if (bo->map == NULL) {
bo->map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE,
- MAP_SHARED, bo->device->fd, nvbo->map_handle);
+ MAP_SHARED, drm->fd, nvbo->map_handle);
if (bo->map == MAP_FAILED) {
bo->map = NULL;
return -errno;
diff --git a/nouveau/pushbuf.c b/nouveau/pushbuf.c
index 8e7dcdfa..035e3019 100644
--- a/nouveau/pushbuf.c
+++ b/nouveau/pushbuf.c
@@ -312,6 +312,7 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct nouveau_object *chan)
struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(push);
struct nouveau_pushbuf_krec *krec = nvpb->list;
struct nouveau_device *dev = push->client->device;
+ struct nouveau_drm *drm = nouveau_drm(&dev->object);
struct drm_nouveau_gem_pushbuf_bo_presumed *info;
struct drm_nouveau_gem_pushbuf_bo *kref;
struct drm_nouveau_gem_pushbuf req;
@@ -345,7 +346,7 @@ pushbuf_submit(struct nouveau_pushbuf *push, struct nouveau_object *chan)
pushbuf_dump(krec, krec_id++, fifo->channel);
#ifndef SIMULATE
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_PUSHBUF,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_PUSHBUF,
&req, sizeof(req));
nvpb->suffix0 = req.suffix0;
nvpb->suffix1 = req.suffix1;
@@ -536,7 +537,7 @@ nouveau_pushbuf_new(struct nouveau_client *client, struct nouveau_object *chan,
int nr, uint32_t size, bool immediate,
struct nouveau_pushbuf **ppush)
{
- struct nouveau_device *dev = client->device;
+ struct nouveau_drm *drm = nouveau_drm(&client->device->object);
struct nouveau_fifo *fifo = chan->data;
struct nouveau_pushbuf_priv *nvpb;
struct nouveau_pushbuf *push;
@@ -551,7 +552,7 @@ nouveau_pushbuf_new(struct nouveau_client *client, struct nouveau_object *chan,
*/
req.channel = fifo->channel;
req.nr_push = 0;
- ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_PUSHBUF,
+ ret = drmCommandWriteRead(drm->fd, DRM_NOUVEAU_GEM_PUSHBUF,
&req, sizeof(req));
if (ret)
return ret;