drm/nouveau/nvif: simplify and tidy library interfaces

A variety of tweaks to the NVIF library interfaces, mostly ripping out
things that turned out to be not so useful.

- Removed refcounting from nvif_object, callers are expected to not be
  stupid instead.
- nvif_client is directly reachable from anything derived from nvif_object,
  removing the need for heuristics to locate it
- _new() versions of interfaces, that allocate memory for the object
  they construct, have been removed.  The vast majority of callers used
  the embedded _init() interfaces.
- No longer storing constructor arguments (and the data returned from
  nvkm) inside nvif_object, it's more or less unused and just wastes
  memory.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
Ben Skeggs
2015-08-20 14:54:15 +10:00
parent 4e7e62d607
commit a01ca78c8f
42 changed files with 364 additions and 573 deletions

View File

@@ -124,7 +124,7 @@ nvif_notify(const void *header, u32 length, const void *data, u32 size)
}
if (!WARN_ON(notify == NULL)) {
struct nvif_client *client = nvif_client(notify->object);
struct nvif_client *client = notify->object->client;
if (!WARN_ON(notify->size != size)) {
atomic_inc(&notify->putcnt);
if (test_bit(NVIF_NOTIFY_WORK, &notify->flags)) {
@@ -156,7 +156,7 @@ nvif_notify_fini(struct nvif_notify *notify)
if (ret >= 0 && object) {
ret = nvif_object_ioctl(object, &args, sizeof(args), NULL);
if (ret == 0) {
nvif_object_ref(NULL, &notify->object);
notify->object = NULL;
kfree((void *)notify->data);
}
}
@@ -164,9 +164,9 @@ nvif_notify_fini(struct nvif_notify *notify)
}
int
nvif_notify_init(struct nvif_object *object, void (*dtor)(struct nvif_notify *),
int (*func)(struct nvif_notify *), bool work, u8 event,
void *data, u32 size, u32 reply, struct nvif_notify *notify)
nvif_notify_init(struct nvif_object *object, int (*func)(struct nvif_notify *),
bool work, u8 event, void *data, u32 size, u32 reply,
struct nvif_notify *notify)
{
struct {
struct nvif_ioctl_v0 ioctl;
@@ -175,11 +175,9 @@ nvif_notify_init(struct nvif_object *object, void (*dtor)(struct nvif_notify *),
} *args;
int ret = -ENOMEM;
notify->object = NULL;
nvif_object_ref(object, &notify->object);
notify->object = object;
notify->flags = 0;
atomic_set(&notify->putcnt, 1);
notify->dtor = dtor;
notify->func = func;
notify->data = NULL;
notify->size = reply;
@@ -211,38 +209,3 @@ done:
nvif_notify_fini(notify);
return ret;
}
static void
nvif_notify_del(struct nvif_notify *notify)
{
nvif_notify_fini(notify);
kfree(notify);
}
void
nvif_notify_ref(struct nvif_notify *notify, struct nvif_notify **pnotify)
{
BUG_ON(notify != NULL);
if (*pnotify)
(*pnotify)->dtor(*pnotify);
*pnotify = notify;
}
int
nvif_notify_new(struct nvif_object *object, int (*func)(struct nvif_notify *),
bool work, u8 type, void *data, u32 size, u32 reply,
struct nvif_notify **pnotify)
{
struct nvif_notify *notify = kzalloc(sizeof(*notify), GFP_KERNEL);
if (notify) {
int ret = nvif_notify_init(object, nvif_notify_del, func, work,
type, data, size, reply, notify);
if (ret) {
kfree(notify);
notify = NULL;
}
*pnotify = notify;
return ret;
}
return -ENOMEM;
}