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

drm/nouveau/core: kill some (now) dead code



Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 07b9e6cc
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
#ifndef __NVKM_ENGCTX_H__
#define __NVKM_ENGCTX_H__
#include <core/gpuobj.h>
#include <core/parent.h>

#include <subdev/mmu.h>

#define NV_ENGCTX_(eng,var) (((var) << 8) | (eng))
#define NV_ENGCTX(name,var)  NV_ENGCTX_(NVDEV_ENGINE_##name, (var))

struct nvkm_engctx {
	struct nvkm_gpuobj gpuobj;
	struct nvkm_vma vma;
	struct list_head head;
	unsigned long save;
	u64 addr;
};

static inline struct nvkm_engctx *
nv_engctx(void *obj)
{
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
	BUG_ON(!nv_iclass(obj, NV_ENGCTX_CLASS));
#endif
	return obj;
}

#define nvkm_engctx_create(p,e,c,g,s,a,f,d)                                 \
	nvkm_engctx_create_((p), (e), (c), (g), (s), (a), (f),              \
			       sizeof(**d), (void **)d)

int  nvkm_engctx_create_(struct nvkm_object *, struct nvkm_object *,
			    struct nvkm_oclass *, struct nvkm_object *,
			    u32 size, u32 align, u32 flags,
			    int length, void **data);
void nvkm_engctx_destroy(struct nvkm_engctx *);
int  nvkm_engctx_init(struct nvkm_engctx *);
int  nvkm_engctx_fini(struct nvkm_engctx *, bool suspend);

int  _nvkm_engctx_ctor(struct nvkm_object *, struct nvkm_object *,
			  struct nvkm_oclass *, void *, u32,
			  struct nvkm_object **);
void _nvkm_engctx_dtor(struct nvkm_object *);
int  _nvkm_engctx_init(struct nvkm_object *);
int  _nvkm_engctx_fini(struct nvkm_object *, bool suspend);
#define _nvkm_engctx_rd32 _nvkm_gpuobj_rd32
#define _nvkm_engctx_wr32 _nvkm_gpuobj_wr32
#endif
+0 −51
Original line number Diff line number Diff line
#ifndef __NVKM_PARENT_H__
#define __NVKM_PARENT_H__
#include <core/object.h>

struct nvkm_parent {
	struct nvkm_object object;

	struct nvkm_oclass *sclass;
	u64 engine;

	int  (*context_attach)(struct nvkm_object *, struct nvkm_object *);
	int  (*context_detach)(struct nvkm_object *, bool suspend,
			       struct nvkm_object *);

	int  (*object_attach)(struct nvkm_object *parent,
			      struct nvkm_object *object, u32 name);
	void (*object_detach)(struct nvkm_object *parent, int cookie);
};

static inline struct nvkm_parent *
nv_parent(void *obj)
{
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
	BUG_ON(!(nv_iclass(obj, NV_PARENT_CLASS)));
#endif
	return obj;
}

#define nvkm_parent_create(p,e,c,v,s,m,d)                                   \
	nvkm_parent_create_((p), (e), (c), (v), (s), (m),                   \
			       sizeof(**d), (void **)d)
#define nvkm_parent_init(p)                                                 \
	_nvkm_object_init(&(p)->object)
#define nvkm_parent_fini(p,s)                                               \
	_nvkm_object_fini(&(p)->object, (s))

int  nvkm_parent_create_(struct nvkm_object *, struct nvkm_object *,
			    struct nvkm_oclass *, u32 pclass,
			    struct nvkm_oclass *, u64 engcls,
			    int size, void **);
void nvkm_parent_destroy(struct nvkm_parent *);

void _nvkm_parent_dtor(struct nvkm_object *);
#define _nvkm_parent_init _nvkm_object_init
#define _nvkm_parent_fini _nvkm_object_fini

int nvkm_parent_sclass(struct nvkm_object *, s32 handle,
		       struct nvkm_object **pengine,
		       struct nvkm_oclass **poclass);
int nvkm_parent_lclass(struct nvkm_object *, void *, int);
#endif
+0 −2
Original line number Diff line number Diff line
nvkm-y := nvkm/core/client.o
nvkm-y += nvkm/core/engctx.o
nvkm-y += nvkm/core/engine.o
nvkm-y += nvkm/core/enum.o
nvkm-y += nvkm/core/event.o
@@ -12,6 +11,5 @@ nvkm-y += nvkm/core/notify.o
nvkm-y += nvkm/core/object.o
nvkm-y += nvkm/core/oproxy.o
nvkm-y += nvkm/core/option.o
nvkm-y += nvkm/core/parent.o
nvkm-y += nvkm/core/ramht.o
nvkm-y += nvkm/core/subdev.o
+0 −166
Original line number Diff line number Diff line
/*
 * Copyright 2012 Red Hat Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: Ben Skeggs
 */
#include <core/engctx.h>
#include <core/engine.h>
#include <core/client.h>

static inline int
nvkm_engctx_exists(struct nvkm_object *parent,
		   struct nvkm_engine *engine, void **pobject)
{
	struct nvkm_engctx *engctx;
	struct nvkm_object *parctx;

	list_for_each_entry(engctx, &engine->contexts, head) {
		parctx = nv_pclass(nv_object(engctx), NV_PARENT_CLASS);
		if (parctx == parent) {
			atomic_inc(&nv_object(engctx)->refcount);
			*pobject = engctx;
			return 1;
		}
	}

	return 0;
}

int
nvkm_engctx_create_(struct nvkm_object *parent, struct nvkm_object *engobj,
		    struct nvkm_oclass *oclass, struct nvkm_object *pargpu,
		    u32 size, u32 align, u32 flags, int length, void **pobject)
{
	struct nvkm_client *client = nvkm_client(parent);
	struct nvkm_engine *engine = nv_engine(engobj);
	struct nvkm_object *engctx;
	unsigned long save;
	int ret;

	/* check if this engine already has a context for the parent object,
	 * and reference it instead of creating a new one
	 */
	spin_lock_irqsave(&engine->lock, save);
	ret = nvkm_engctx_exists(parent, engine, pobject);
	spin_unlock_irqrestore(&engine->lock, save);
	if (ret)
		return ret;

	/* create the new context, supports creating both raw objects and
	 * objects backed by instance memory
	 */
	if (size) {
		ret = nvkm_gpuobj_create_(parent, engobj, oclass,
					  NV_ENGCTX_CLASS, pargpu, size,
					  align, flags, length, pobject);
	} else {
		ret = nvkm_object_create_(parent, engobj, oclass,
					  NV_ENGCTX_CLASS, length, pobject);
	}

	engctx = *pobject;
	if (ret)
		return ret;

	/* must take the lock again and re-check a context doesn't already
	 * exist (in case of a race) - the lock had to be dropped before as
	 * it's not possible to allocate the object with it held.
	 */
	spin_lock_irqsave(&engine->lock, save);
	ret = nvkm_engctx_exists(parent, engine, pobject);
	if (ret) {
		spin_unlock_irqrestore(&engine->lock, save);
		nvkm_object_ref(NULL, &engctx);
		return ret;
	}

	if (client->vm)
		atomic_inc(&client->vm->engref[nv_engidx(engine)]);
	list_add(&nv_engctx(engctx)->head, &engine->contexts);
	nv_engctx(engctx)->addr = ~0ULL;
	spin_unlock_irqrestore(&engine->lock, save);
	return 0;
}

void
nvkm_engctx_destroy(struct nvkm_engctx *engctx)
{
	struct nvkm_engine *engine = engctx->gpuobj.object.engine;
	struct nvkm_client *client = nvkm_client(&engctx->gpuobj.object);
	unsigned long save;

	nvkm_gpuobj_unmap(&engctx->vma);
	spin_lock_irqsave(&engine->lock, save);
	list_del(&engctx->head);
	spin_unlock_irqrestore(&engine->lock, save);

	if (client->vm)
		atomic_dec(&client->vm->engref[nv_engidx(engine)]);

	if (engctx->gpuobj.size)
		nvkm_gpuobj_destroy(&engctx->gpuobj);
	else
		nvkm_object_destroy(&engctx->gpuobj.object);
}

int
nvkm_engctx_init(struct nvkm_engctx *engctx)
{
	return nvkm_gpuobj_init(&engctx->gpuobj);
}

int
nvkm_engctx_fini(struct nvkm_engctx *engctx, bool suspend)
{
	return nvkm_gpuobj_fini(&engctx->gpuobj, suspend);
}

int
_nvkm_engctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
		  struct nvkm_oclass *oclass, void *data, u32 size,
		  struct nvkm_object **pobject)
{
	struct nvkm_engctx *engctx;
	int ret;

	ret = nvkm_engctx_create(parent, engine, oclass, NULL, 256, 256,
				 NVOBJ_FLAG_ZERO_ALLOC, &engctx);
	*pobject = nv_object(engctx);
	return ret;
}

void
_nvkm_engctx_dtor(struct nvkm_object *object)
{
	nvkm_engctx_destroy(nv_engctx(object));
}

int
_nvkm_engctx_init(struct nvkm_object *object)
{
	return nvkm_engctx_init(nv_engctx(object));
}

int
_nvkm_engctx_fini(struct nvkm_object *object, bool suspend)
{
	return nvkm_engctx_fini(nv_engctx(object), suspend);
}
+1 −21
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
 */
#include <core/handle.h>
#include <core/client.h>
#include <core/parent.h>

#define hprintk(h,l,f,a...) do {                                               \
	struct nvkm_handle *p = (h)->parent; u32 n = p ? p->name : ~0;         \
@@ -99,7 +98,6 @@ nvkm_handle_create(struct nvkm_handle *parent, u32 _handle,
		   struct nvkm_object *object, struct nvkm_handle **phandle)
{
	struct nvkm_handle *handle;
	int ret;

	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
	if (!handle)
@@ -113,21 +111,8 @@ nvkm_handle_create(struct nvkm_handle *parent, u32 _handle,
	handle->parent = parent;
	nvkm_object_ref(object, &handle->object);

	if (parent) {
		if (nv_iclass(parent->object, NV_PARENT_CLASS) &&
		    nv_parent(parent->object)->object_attach) {
			ret = nv_parent(parent->object)->
				object_attach(parent->object, object, _handle);
			if (ret < 0) {
				nvkm_handle_destroy(handle);
				return ret;
			}

			handle->priv = ret;
		}

	if (parent)
		list_add(&handle->head, &handle->parent->tree);
	}

	hprintk(handle, TRACE, "created\n");
	*phandle = handle;
@@ -148,11 +133,6 @@ nvkm_handle_destroy(struct nvkm_handle *handle)
	nvkm_client_remove(client, handle);
	list_del(&handle->head);

	if (handle->priv != ~0) {
		struct nvkm_object *parent = handle->parent->object;
		nv_parent(parent)->object_detach(parent, handle->priv);
	}

	hprintk(handle, TRACE, "destroy completed\n");
	nvkm_object_ref(NULL, &handle->object);
	kfree(handle);
Loading