[Nouveau] [libdrm 08/13] nouveau: make use of nouveau_drm::fd instead of nouveau_device::fd
Ben Skeggs
skeggsb at gmail.com
Wed Nov 25 23:14:05 PST 2015
From: Ben Skeggs <bskeggs at redhat.com>
The latter is deprecated, and will not be valid for newer clients.
Signed-off-by: Ben Skeggs <bskeggs at redhat.com>
---
nouveau/abi16.c | 32 +++++++++++++++-----------------
nouveau/nouveau-symbol-check | 1 -
nouveau/nouveau.c | 43 +++++++++++++++++++++----------------------
nouveau/nouveau.h | 1 -
nouveau/pushbuf.c | 7 ++++---
5 files changed, 40 insertions(+), 44 deletions(-)
diff --git a/nouveau/abi16.c b/nouveau/abi16.c
index 34e9fb1..5ba2690 100644
--- a/nouveau/abi16.c
+++ b/nouveau/abi16.c
@@ -37,7 +37,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,
@@ -45,7 +45,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;
@@ -61,12 +61,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;
@@ -82,7 +82,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;
@@ -92,7 +92,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;
@@ -108,16 +108,15 @@ 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;
- 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;
@@ -129,17 +128,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;
@@ -179,18 +177,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));
}
}
@@ -267,6 +264,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;
@@ -309,7 +307,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-symbol-check b/nouveau/nouveau-symbol-check
index e360b92..275b6e7 100755
--- a/nouveau/nouveau-symbol-check
+++ b/nouveau/nouveau-symbol-check
@@ -34,7 +34,6 @@ nouveau_drm_del
nouveau_drm_new
nouveau_getparam
nouveau_object_del
-nouveau_object_find
nouveau_object_mclass
nouveau_object_mthd
nouveau_object_new
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index e304a1b..06fdeed 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -184,17 +184,6 @@ nouveau_object_del(struct nouveau_object **pobj)
}
}
-void *
-nouveau_object_find(struct nouveau_object *obj, uint32_t pclass)
-{
- while (obj && obj->oclass != pclass) {
- obj = obj->parent;
- if (pclass == NOUVEAU_PARENT_CLASS)
- break;
- }
- return obj;
-}
-
void
nouveau_drm_del(struct nouveau_drm **pdrm)
{
@@ -345,8 +334,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 +345,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 +408,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 +425,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 +466,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 +496,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 +543,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 +559,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 +572,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 +608,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 +616,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 +627,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 +643,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 +667,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 +678,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/nouveau.h b/nouveau/nouveau.h
index 58e662f..86d7338 100644
--- a/nouveau/nouveau.h
+++ b/nouveau/nouveau.h
@@ -105,7 +105,6 @@ int nouveau_object_sclass_get(struct nouveau_object *,
void nouveau_object_sclass_put(struct nouveau_sclass **);
int nouveau_object_mclass(struct nouveau_object *,
const struct nouveau_mclass *);
-void *nouveau_object_find(struct nouveau_object *, uint32_t parent_class);
struct nouveau_device {
struct nouveau_object object;
diff --git a/nouveau/pushbuf.c b/nouveau/pushbuf.c
index 8e7dcdf..035e301 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;
--
2.6.3
More information about the Nouveau
mailing list