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

drm/nouveau/fifo: tidy up non-stall intr handling



- removes a layer of indirection in the intr handling
- prevents non-stall ctrl racing with unknown intrs

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 2fc71a05
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -44,13 +44,16 @@ struct nvkm_fifo {
	struct list_head runqs;
	struct list_head runls;

	struct {
#define NVKM_FIFO_NONSTALL_EVENT BIT(0)
		struct nvkm_event event;
	} nonstall;

	int nr;
	struct list_head chan;
	spinlock_t lock;
	struct mutex mutex;

#define NVKM_FIFO_EVENT_NON_STALL_INTR BIT(0)
	struct nvkm_event uevent; /* async user trigger */
#define NVKM_FIFO_EVENT_KILLED         BIT(0)
	struct nvkm_event kevent; /* channel killed */
};
+4 −30
Original line number Diff line number Diff line
@@ -129,32 +129,6 @@ static const struct nvkm_event_func
nvkm_fifo_kevent_func = {
};

static void
nvkm_fifo_uevent_fini(struct nvkm_event *event, int type, int index)
{
	struct nvkm_fifo *fifo = container_of(event, typeof(*fifo), uevent);
	fifo->func->uevent_fini(fifo);
}

static void
nvkm_fifo_uevent_init(struct nvkm_event *event, int type, int index)
{
	struct nvkm_fifo *fifo = container_of(event, typeof(*fifo), uevent);
	fifo->func->uevent_init(fifo);
}

static const struct nvkm_event_func
nvkm_fifo_uevent_func = {
	.init = nvkm_fifo_uevent_init,
	.fini = nvkm_fifo_uevent_fini,
};

void
nvkm_fifo_uevent(struct nvkm_fifo *fifo)
{
	nvkm_event_ntfy(&fifo->uevent, 0, NVKM_FIFO_EVENT_NON_STALL_INTR);
}

static int
nvkm_fifo_class_new(struct nvkm_device *device, const struct nvkm_oclass *oclass,
		    void *argv, u32 argc, struct nvkm_object **pobject)
@@ -365,7 +339,7 @@ nvkm_fifo_dtor(struct nvkm_engine *engine)
	if (fifo->func->dtor)
		data = fifo->func->dtor(fifo);
	nvkm_event_fini(&fifo->kevent);
	nvkm_event_fini(&fifo->uevent);
	nvkm_event_fini(&fifo->nonstall.event);
	mutex_destroy(&fifo->mutex);
	return data;
}
@@ -402,9 +376,9 @@ nvkm_fifo_ctor(const struct nvkm_fifo_func *func, struct nvkm_device *device,
	nr = func->chid_nr(fifo);
	fifo->nr = nr;

	if (func->uevent_init) {
		ret = nvkm_event_init(&nvkm_fifo_uevent_func, &fifo->engine.subdev, 1, 1,
				      &fifo->uevent);
	if (func->nonstall) {
		ret = nvkm_event_init(func->nonstall, &fifo->engine.subdev, 1, 1,
				      &fifo->nonstall.event);
		if (ret)
			return ret;
	}
+0 −3
Original line number Diff line number Diff line
@@ -223,9 +223,6 @@ nvkm_fifo_chan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct n
	union nvif_chan_event_args *args = argv;

	switch (args->v0.type) {
	case NVIF_CHAN_EVENT_V0_NON_STALL_INTR:
		return nvkm_uevent_add(uevent, &chan->fifo->uevent, 0,
				       NVKM_FIFO_EVENT_NON_STALL_INTR, NULL);
	case NVIF_CHAN_EVENT_V0_KILLED:
		return nvkm_uevent_add(uevent, &chan->fifo->kevent, chan->chid,
				       NVKM_FIFO_EVENT_KILLED, NULL);
+23 −10
Original line number Diff line number Diff line
@@ -37,20 +37,34 @@ const struct nvkm_engn_func
g84_engn = {
};

void
g84_fifo_uevent_fini(struct nvkm_fifo *fifo)
static void
g84_fifo_nonstall_block(struct nvkm_event *event, int type, int index)
{
	struct nvkm_device *device = fifo->engine.subdev.device;
	nvkm_mask(device, 0x002140, 0x40000000, 0x00000000);
	struct nvkm_fifo *fifo = container_of(event, typeof(*fifo), nonstall.event);
	unsigned long flags;

	spin_lock_irqsave(&fifo->lock, flags);
	nvkm_mask(fifo->engine.subdev.device, 0x002140, 0x40000000, 0x00000000);
	spin_unlock_irqrestore(&fifo->lock, flags);
}

void
g84_fifo_uevent_init(struct nvkm_fifo *fifo)
static void
g84_fifo_nonstall_allow(struct nvkm_event *event, int type, int index)
{
	struct nvkm_device *device = fifo->engine.subdev.device;
	nvkm_mask(device, 0x002140, 0x40000000, 0x40000000);
	struct nvkm_fifo *fifo = container_of(event, typeof(*fifo), nonstall.event);
	unsigned long flags;

	spin_lock_irqsave(&fifo->lock, flags);
	nvkm_mask(fifo->engine.subdev.device, 0x002140, 0x40000000, 0x40000000);
	spin_unlock_irqrestore(&fifo->lock, flags);
}

const struct nvkm_event_func
g84_fifo_nonstall = {
	.init = g84_fifo_nonstall_allow,
	.fini = g84_fifo_nonstall_block,
};

int
g84_fifo_engine_id(struct nvkm_fifo *base, struct nvkm_engine *engine)
{
@@ -105,8 +119,7 @@ g84_fifo = {
	.engine_id = g84_fifo_engine_id,
	.pause = nv04_fifo_pause,
	.start = nv04_fifo_start,
	.uevent_init = g84_fifo_uevent_init,
	.uevent_fini = g84_fifo_uevent_fini,
	.nonstall = &g84_fifo_nonstall,
	.runl = &nv50_runl,
	.engn = &g84_engn,
	.engn_sw = &nv50_engn_sw,
+1 −2
Original line number Diff line number Diff line
@@ -59,8 +59,7 @@ g98_fifo = {
	.engine_id = g84_fifo_engine_id,
	.pause = nv04_fifo_pause,
	.start = nv04_fifo_start,
	.uevent_init = g84_fifo_uevent_init,
	.uevent_fini = g84_fifo_uevent_fini,
	.nonstall = &g84_fifo_nonstall,
	.runl = &nv50_runl,
	.engn = &g84_engn,
	.engn_sw = &nv50_engn_sw,
Loading