Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fbd58ebd authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/object: merge with handle



Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 68f3f702
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -12,8 +12,6 @@ struct nvkm_client {
	struct rb_root objroot;
	struct rb_root dmaroot;

	struct nvkm_handle *root;

	bool super;
	void *data;
	int (*ntfy)(const void *, u32, const void *, u32);
@@ -21,9 +19,9 @@ struct nvkm_client {
	struct nvkm_vm *vm;
};

bool nvkm_client_insert(struct nvkm_client *, struct nvkm_handle *);
void nvkm_client_remove(struct nvkm_client *, struct nvkm_handle *);
struct nvkm_handle *nvkm_client_search(struct nvkm_client *, u64 handle);
bool nvkm_client_insert(struct nvkm_client *, struct nvkm_object *);
void nvkm_client_remove(struct nvkm_client *, struct nvkm_object *);
struct nvkm_object *nvkm_client_search(struct nvkm_client *, u64 object);

int  nvkm_client_new(const char *name, u64 device, const char *cfg,
		     const char *dbg, struct nvkm_client **);
@@ -31,14 +29,6 @@ void nvkm_client_del(struct nvkm_client **);
int  nvkm_client_init(struct nvkm_client *);
int  nvkm_client_fini(struct nvkm_client *, bool suspend);

static inline struct nvkm_client *
nvkm_client(struct nvkm_object *object)
{
	while (object && object->parent)
		object = object->parent;
	return container_of(object, struct nvkm_client, object);
}

int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
			   void *data, u32 size);
int nvkm_client_notify_del(struct nvkm_client *, int index);
@@ -48,12 +38,15 @@ int nvkm_client_notify_put(struct nvkm_client *, int index);
/* logging for client-facing objects */
#define nvif_printk(o,l,p,f,a...) do {                                         \
	struct nvkm_object *_object = (o);                                     \
	struct nvkm_client *_client = nvkm_client(_object);                    \
	struct nvkm_client *_client = _object->client;                         \
	if (_client->debug >= NV_DBG_##l)                                      \
		printk(KERN_##p "nouveau: %s: "f, _client->name, ##a);         \
		printk(KERN_##p "nouveau: %s:%08x:%08x: "f, _client->name,     \
		       _object->handle, _object->oclass, ##a);                 \
} while(0)
#define nvif_fatal(o,f,a...) nvif_printk((o), FATAL, CRIT, f, ##a)
#define nvif_error(o,f,a...) nvif_printk((o), ERROR,  ERR, f, ##a)
#define nvif_debug(o,f,a...) nvif_printk((o), DEBUG, INFO, f, ##a)
#define nvif_trace(o,f,a...) nvif_printk((o), TRACE, INFO, f, ##a)
#define nvif_info(o,f,a...)  nvif_printk((o),  INFO, INFO, f, ##a)
#define nvif_ioctl(o,f,a...) nvif_trace((o), "ioctl: "f, ##a)
#endif
+0 −34
Original line number Diff line number Diff line
#ifndef __NVKM_HANDLE_H__
#define __NVKM_HANDLE_H__
#include <core/os.h>
struct nvkm_object;

struct nvkm_handle {
	struct list_head node;

	struct list_head head;
	struct list_head tree;
	u32 name;
	u32 priv;

	u8  route;
	u64 token;

	struct nvkm_handle *parent;
	struct nvkm_object *object;

	struct rb_node rb;
	u64 handle;
};

int  nvkm_handle_create(struct nvkm_handle *, u32 handle,
			struct nvkm_object *, struct nvkm_handle **);
void nvkm_handle_destroy(struct nvkm_handle *);
int  nvkm_handle_init(struct nvkm_handle *);
int  nvkm_handle_fini(struct nvkm_handle *, bool suspend);

struct nvkm_handle *nvkm_handle_get_class(struct nvkm_object *, u16);
struct nvkm_handle *nvkm_handle_get_vinst(struct nvkm_object *, u64);
struct nvkm_handle *nvkm_handle_get_cinst(struct nvkm_object *, u32);
void nvkm_handle_put(struct nvkm_handle *);
#endif
+13 −10
Original line number Diff line number Diff line
@@ -10,12 +10,15 @@ struct nvkm_object {
	const struct nvkm_object_func *func;
	struct nvkm_client *client;
	struct nvkm_engine *engine;
	u32 oclass;
	s32 oclass;
	u32 handle;
	struct nvkm_object *parent;
	u32 pclass;
	atomic_t refcount;
	atomic_t usecount;

	struct list_head head;
	struct list_head tree;
	u8  route;
	u64 token;
	u64 object;
	struct rb_node node;
};

struct nvkm_object_func {
@@ -43,6 +46,8 @@ int nvkm_object_new_(const struct nvkm_object_func *,
		     struct nvkm_object **);
int nvkm_object_new(const struct nvkm_oclass *, void *data, u32 size,
		    struct nvkm_object **);
void nvkm_object_del(struct nvkm_object **);
void *nvkm_object_dtor(struct nvkm_object *);
int nvkm_object_init(struct nvkm_object *);
int nvkm_object_fini(struct nvkm_object *, bool suspend);
int nvkm_object_mthd(struct nvkm_object *, u32 mthd, void *data, u32 size);
@@ -72,14 +77,12 @@ struct nvkm_oclass {
	struct nvkm_sclass base;
	const void *priv;
	const void *engn;
	s32 handle;
	u32 handle;
	u8  route;
	u64 token;
	u64 object;
	struct nvkm_client *client;
	struct nvkm_object *parent;
	struct nvkm_engine *engine;
};

void nvkm_object_ref(struct nvkm_object *, struct nvkm_object **);
int  nvkm_object_inc(struct nvkm_object *);
int  nvkm_object_dec(struct nvkm_object *, bool suspend);
#endif
+1 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,
	/* destroy channel object, all children will be killed too */
	if (chan->chan) {
		abi16->handles &= ~(1ULL << (chan->chan->user.handle & 0xffff));
		nouveau_channel_idle(chan->chan);
		nouveau_channel_del(&chan->chan);
	}

+19 −15
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
int
nouveau_channel_idle(struct nouveau_channel *chan)
{
	if (likely(chan && chan->fence)) {
		struct nouveau_cli *cli = (void *)chan->user.client;
		struct nouveau_fence *fence = NULL;
		int ret;
@@ -53,21 +54,24 @@ nouveau_channel_idle(struct nouveau_channel *chan)
			nouveau_fence_unref(&fence);
		}

	if (ret)
		NV_PRINTK(err, cli, "failed to idle channel 0x%08x [%s]\n",
			  chan->user.handle, nvxx_client(&cli->base)->name);
		if (ret) {
			NV_PRINTK(err, cli, "failed to idle channel "
					    "0x%08x [%s]\n",
				  chan->user.handle,
				  nvxx_client(&cli->base)->name);
			return ret;
		}
	}
	return 0;
}

void
nouveau_channel_del(struct nouveau_channel **pchan)
{
	struct nouveau_channel *chan = *pchan;
	if (chan) {
		if (chan->fence) {
			nouveau_channel_idle(chan);
		if (chan->fence)
			nouveau_fence(chan->drm)->context_del(chan);
		}
		nvif_object_fini(&chan->nvsw);
		nvif_object_fini(&chan->gart);
		nvif_object_fini(&chan->vram);
Loading