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

drm/nouveau/sw: remove dependence on namedb/engctx lookup



Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 590801c1
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ struct nvkm_sclass {
struct nvkm_oclass {
	s32 handle;
	struct nvkm_ofuncs * const ofuncs;
	struct nvkm_omthds * const omthds;

	int (*ctor)(const struct nvkm_oclass *, void *data, u32 size,
		    struct nvkm_object **);
@@ -135,12 +134,6 @@ nv_pclass(struct nvkm_object *parent, u32 oclass)
	return parent;
}

struct nvkm_omthds {
	u32 start;
	u32 limit;
	int (*call)(struct nvkm_object *, u32, void *, u32);
};

struct nvkm_ofuncs {
	int  (*ctor)(struct nvkm_object *, struct nvkm_object *,
		     struct nvkm_oclass *, void *data, u32 size,
@@ -171,24 +164,4 @@ int nvkm_object_old(struct nvkm_object *, struct nvkm_object *,
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);

static inline int
nv_exec(void *obj, u32 mthd, void *data, u32 size)
{
	struct nvkm_omthds *method = nv_oclass(obj)->omthds;

	while (method && method->call) {
		if (mthd >= method->start && mthd <= method->limit)
			return method->call(obj, mthd, data, size);
		method++;
	}

	return -EINVAL;
}

static inline int
nv_call(void *obj, u32 mthd, u32 data)
{
	return nv_exec(obj, mthd, &data, sizeof(data));
}
#endif
+7 −1
Original line number Diff line number Diff line
@@ -4,10 +4,16 @@

struct nvkm_sw {
	struct nvkm_engine engine;
	struct list_head chan;
};

bool nvkm_sw_mthd(struct nvkm_sw *sw, int chid, int subc, u32 mthd, u32 data);

#define nvkm_sw_create(p,e,c,d)                                       \
	nvkm_engine_create((p), (e), (c), true, "SW", "software", (d))
	nvkm_sw_ctor((p), (e), (c), sizeof(**d), (void **)d)
int
nvkm_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
	     struct nvkm_oclass *oclass, int length, void **pobject);
#define nvkm_sw_destroy(d)                                            \
	nvkm_engine_destroy(&(d)->engine)
#define nvkm_sw_init(d)                                               \
+0 −1
Original line number Diff line number Diff line
@@ -174,7 +174,6 @@ int nv50_disp_main_ctor(struct nvkm_object *, struct nvkm_object *,
			 struct nvkm_oclass *, void *, u32,
			 struct nvkm_object **);
void nv50_disp_main_dtor(struct nvkm_object *);
extern struct nvkm_omthds nv50_disp_main_omthds[];
extern struct nvkm_oclass nv50_disp_cclass;
void nv50_disp_mthd_chan(struct nv50_disp *, int debug, int head,
			 const struct nv50_disp_mthd_chan *);
+5 −28
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <subdev/fb.h>
#include <subdev/mmu.h>
#include <subdev/timer.h>
#include <engine/sw.h>

#include <nvif/class.h>
#include <nvif/ioctl.h>
@@ -474,32 +475,6 @@ gf100_fifo_recover(struct gf100_fifo *fifo, struct nvkm_engine *engine,
	schedule_work(&fifo->fault);
}

static int
gf100_fifo_swmthd(struct gf100_fifo *fifo, u32 chid, u32 mthd, u32 data)
{
	struct gf100_fifo_chan *chan = NULL;
	struct nvkm_handle *bind;
	unsigned long flags;
	int ret = -EINVAL;

	spin_lock_irqsave(&fifo->base.lock, flags);
	if (likely(chid >= fifo->base.min && chid <= fifo->base.max))
		chan = (void *)fifo->base.channel[chid];
	if (unlikely(!chan))
		goto out;

	bind = nvkm_namedb_get_class(nv_namedb(chan), NVIF_IOCTL_NEW_V0_SW_GF100);
	if (likely(bind)) {
		if (!mthd || !nv_call(bind->object, mthd, data))
			ret = 0;
		nvkm_namedb_put(bind);
	}

out:
	spin_unlock_irqrestore(&fifo->base.lock, flags);
	return ret;
}

static const struct nvkm_enum
gf100_fifo_sched_reason[] = {
	{ 0x0a, "CTXSW_TIMEOUT" },
@@ -701,9 +676,11 @@ gf100_fifo_intr_pbdma(struct gf100_fifo *fifo, int unit)
	char msg[128];

	if (stat & 0x00800000) {
		if (!gf100_fifo_swmthd(fifo, chid, mthd, data))
		if (device->sw) {
			if (nvkm_sw_mthd(device->sw, chid, subc, mthd, data))
				show &= ~0x00800000;
		}
	}

	if (show) {
		nvkm_snprintbf(msg, sizeof(msg), gf100_fifo_pbdma_intr, show);
+5 −28
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <subdev/fb.h>
#include <subdev/mmu.h>
#include <subdev/timer.h>
#include <engine/sw.h>

#include <nvif/class.h>
#include <nvif/ioctl.h>
@@ -520,32 +521,6 @@ gk104_fifo_recover(struct gk104_fifo *fifo, struct nvkm_engine *engine,
	schedule_work(&fifo->fault);
}

static int
gk104_fifo_swmthd(struct gk104_fifo *fifo, u32 chid, u32 mthd, u32 data)
{
	struct gk104_fifo_chan *chan = NULL;
	struct nvkm_handle *bind;
	unsigned long flags;
	int ret = -EINVAL;

	spin_lock_irqsave(&fifo->base.lock, flags);
	if (likely(chid >= fifo->base.min && chid <= fifo->base.max))
		chan = (void *)fifo->base.channel[chid];
	if (unlikely(!chan))
		goto out;

	bind = nvkm_namedb_get_class(nv_namedb(chan), NVIF_IOCTL_NEW_V0_SW_GF100);
	if (likely(bind)) {
		if (!mthd || !nv_call(bind->object, mthd, data))
			ret = 0;
		nvkm_namedb_put(bind);
	}

out:
	spin_unlock_irqrestore(&fifo->base.lock, flags);
	return ret;
}

static const struct nvkm_enum
gk104_fifo_bind_reason[] = {
	{ 0x01, "BIND_NOT_UNBOUND" },
@@ -864,8 +839,10 @@ gk104_fifo_intr_pbdma_0(struct gk104_fifo *fifo, int unit)
	char msg[128];

	if (stat & 0x00800000) {
		if (!gk104_fifo_swmthd(fifo, chid, mthd, data))
		if (device->sw) {
			if (nvkm_sw_mthd(device->sw, chid, subc, mthd, data))
				show &= ~0x00800000;
		}
		nvkm_wr32(device, 0x0400c0 + (unit * 0x2000), 0x80600008);
	}

Loading