Commit 6c9705f6 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fifo: expose channel killed in host channel event class

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent 8c880fd4
......@@ -10,6 +10,4 @@ struct fermi_channel_gpfifo_v0 {
__u64 ioffset;
__u64 vmm;
};
#define NV906F_V0_NTFY_KILLED 0x01
#endif
......@@ -12,6 +12,4 @@ struct kepler_channel_gpfifo_a_v0 {
__u64 vmm;
__u64 inst;
};
#define NVA06F_V0_NTFY_KILLED 0x01
#endif
......@@ -13,6 +13,4 @@ struct volta_channel_gpfifo_a_v0 {
__u64 inst;
__u32 token;
};
#define NVC36F_V0_NTFY_KILLED 0x01
#endif
......@@ -6,6 +6,7 @@ union nvif_chan_event_args {
struct nvif_chan_event_v0 {
__u8 version;
#define NVIF_CHAN_EVENT_V0_NON_STALL_INTR 0x00
#define NVIF_CHAN_EVENT_V0_KILLED 0x01
__u8 type;
} v0;
};
......
......@@ -44,6 +44,7 @@ struct nvkm_fifo {
#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 */
};
......
......@@ -30,6 +30,7 @@
#include <nvif/cl906f.h>
#include <nvif/cla06f.h>
#include <nvif/clc36f.h>
#include <nvif/if0020.h>
#include <nvif/ioctl.h>
#include "nouveau_drv.h"
......@@ -46,15 +47,17 @@ int nouveau_vram_pushbuf;
module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
static int
nouveau_channel_killed(struct nvif_notify *ntfy)
nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc)
{
struct nouveau_channel *chan = container_of(ntfy, typeof(*chan), kill);
struct nouveau_channel *chan = container_of(event, typeof(*chan), kill);
struct nouveau_cli *cli = (void *)chan->user.client;
NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid);
atomic_set(&chan->killed, 1);
if (chan->fence)
nouveau_fence_context_kill(chan->fence, -ENODEV);
return NVIF_NOTIFY_DROP;
return NVIF_EVENT_DROP;
}
int
......@@ -96,7 +99,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
nvif_object_dtor(&chan->nvsw);
nvif_object_dtor(&chan->gart);
nvif_object_dtor(&chan->vram);
nvif_notify_dtor(&chan->kill);
nvif_event_dtor(&chan->kill);
nvif_object_dtor(&chan->user);
nvif_object_dtor(&chan->push.ctxdma);
nouveau_vma_del(&chan->push.vma);
......@@ -391,12 +394,19 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
if (chan->user.oclass >= FERMI_CHANNEL_GPFIFO &&
chan->user.oclass < AMPERE_CHANNEL_GPFIFO_B) {
ret = nvif_notify_ctor(&chan->user, "abi16ChanKilled",
nouveau_channel_killed,
true, NV906F_V0_NTFY_KILLED,
NULL, 0, 0, &chan->kill);
struct {
struct nvif_event_v0 base;
struct nvif_chan_event_v0 host;
} args;
args.host.version = 0;
args.host.type = NVIF_CHAN_EVENT_V0_KILLED;
ret = nvif_event_ctor(&chan->user, "abi16ChanKilled", chan->chid,
nouveau_channel_killed, false,
&args.base, sizeof(args), &chan->kill);
if (ret == 0)
ret = nvif_notify_get(&chan->kill);
ret = nvif_event_allow(&chan->kill);
if (ret) {
NV_ERROR(drm, "Failed to request channel kill "
"notification: %d\n", ret);
......
......@@ -2,7 +2,7 @@
#ifndef __NOUVEAU_CHAN_H__
#define __NOUVEAU_CHAN_H__
#include <nvif/object.h>
#include <nvif/notify.h>
#include <nvif/event.h>
#include <nvif/push.h>
struct nvif_device;
......@@ -50,7 +50,7 @@ struct nouveau_channel {
struct nvif_object user;
struct nvif_notify kill;
struct nvif_event kill;
atomic_t killed;
};
......
......@@ -88,8 +88,9 @@ void
nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error)
{
struct nouveau_fence *fence;
unsigned long flags;
spin_lock_irq(&fctx->lock);
spin_lock_irqsave(&fctx->lock, flags);
while (!list_empty(&fctx->pending)) {
fence = list_entry(fctx->pending.next, typeof(*fence), head);
......@@ -99,7 +100,7 @@ nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error)
if (nouveau_fence_signal(fence))
nvif_event_block(&fctx->event);
}
spin_unlock_irq(&fctx->lock);
spin_unlock_irqrestore(&fctx->lock, flags);
}
void
......
......@@ -26,7 +26,6 @@
#include <core/client.h>
#include <core/gpuobj.h>
#include <core/notify.h>
#include <subdev/mc.h>
#include <nvif/event.h>
......@@ -122,26 +121,11 @@ nvkm_fifo_chan_chid(struct nvkm_fifo *fifo, int chid, unsigned long *rflags)
void
nvkm_fifo_kevent(struct nvkm_fifo *fifo, int chid)
{
nvkm_event_send(&fifo->kevent, 1, chid, NULL, 0);
}
static int
nvkm_fifo_kevent_ctor(struct nvkm_object *object, void *data, u32 size,
struct nvkm_notify *notify)
{
struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
if (size == 0) {
notify->size = 0;
notify->types = 1;
notify->index = chan->chid;
return 0;
}
return -ENOSYS;
nvkm_event_send(&fifo->kevent, NVKM_FIFO_EVENT_KILLED, chid, NULL, 0);
}
static const struct nvkm_event_func
nvkm_fifo_kevent_func = {
.ctor = nvkm_fifo_kevent_ctor,
};
static void
......
......@@ -267,6 +267,9 @@ nvkm_fifo_chan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct n
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);
default:
break;
}
......@@ -274,16 +277,6 @@ nvkm_fifo_chan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct n
return -ENOSYS;
}
static int
nvkm_fifo_chan_ntfy(struct nvkm_object *object, u32 type,
struct nvkm_event **pevent)
{
struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object);
if (chan->func->ntfy)
return chan->func->ntfy(chan, type, pevent);
return -ENODEV;
}
static int
nvkm_fifo_chan_map(struct nvkm_object *object, void *argv, u32 argc,
enum nvkm_object_map *type, u64 *addr, u64 *size)
......@@ -341,7 +334,6 @@ nvkm_fifo_chan_func = {
.dtor = nvkm_fifo_chan_dtor,
.init = nvkm_fifo_chan_init,
.fini = nvkm_fifo_chan_fini,
.ntfy = nvkm_fifo_chan_ntfy,
.map = nvkm_fifo_chan_map,
.sclass = nvkm_fifo_chan_child_get,
.uevent = nvkm_fifo_chan_uevent,
......
......@@ -8,7 +8,6 @@ struct nvkm_fifo_chan_func {
void *(*dtor)(struct nvkm_fifo_chan *);
void (*init)(struct nvkm_fifo_chan *);
void (*fini)(struct nvkm_fifo_chan *);
int (*ntfy)(struct nvkm_fifo_chan *, u32 type, struct nvkm_event **);
int (*engine_ctor)(struct nvkm_fifo_chan *, struct nvkm_engine *,
struct nvkm_object *);
void (*engine_dtor)(struct nvkm_fifo_chan *, struct nvkm_engine *);
......
......@@ -32,20 +32,6 @@
#include <nvif/cl906f.h>
#include <nvif/unpack.h>
int
gf100_fifo_chan_ntfy(struct nvkm_fifo_chan *chan, u32 type,
struct nvkm_event **pevent)
{
switch (type) {
case NV906F_V0_NTFY_KILLED:
*pevent = &chan->fifo->kevent;
return 0;
default:
break;
}
return -EINVAL;
}
static u32
gf100_fifo_gpfifo_engine_addr(struct nvkm_engine *engine)
{
......@@ -207,7 +193,6 @@ gf100_fifo_gpfifo_func = {
.dtor = gf100_fifo_gpfifo_dtor,
.init = gf100_fifo_gpfifo_init,
.fini = gf100_fifo_gpfifo_fini,
.ntfy = gf100_fifo_chan_ntfy,
.engine_ctor = gf100_fifo_gpfifo_engine_ctor,
.engine_dtor = gf100_fifo_gpfifo_engine_dtor,
.engine_init = gf100_fifo_gpfifo_engine_init,
......
......@@ -246,7 +246,6 @@ gk104_fifo_gpfifo_func = {
.dtor = gk104_fifo_gpfifo_dtor,
.init = gk104_fifo_gpfifo_init,
.fini = gk104_fifo_gpfifo_fini,
.ntfy = gf100_fifo_chan_ntfy,
.engine_ctor = gk104_fifo_gpfifo_engine_ctor,
.engine_dtor = gk104_fifo_gpfifo_engine_dtor,
.engine_init = gk104_fifo_gpfifo_engine_init,
......
......@@ -125,7 +125,6 @@ gv100_fifo_gpfifo = {
.dtor = gk104_fifo_gpfifo_dtor,
.init = gk104_fifo_gpfifo_init,
.fini = gk104_fifo_gpfifo_fini,
.ntfy = gf100_fifo_chan_ntfy,
.engine_ctor = gk104_fifo_gpfifo_engine_ctor,
.engine_dtor = gk104_fifo_gpfifo_engine_dtor,
.engine_init = gv100_fifo_gpfifo_engine_init,
......
......@@ -40,7 +40,6 @@ tu102_fifo_gpfifo = {
.dtor = gk104_fifo_gpfifo_dtor,
.init = gk104_fifo_gpfifo_init,
.fini = gk104_fifo_gpfifo_fini,
.ntfy = gf100_fifo_chan_ntfy,
.engine_ctor = gk104_fifo_gpfifo_engine_ctor,
.engine_dtor = gk104_fifo_gpfifo_engine_dtor,
.engine_init = gv100_fifo_gpfifo_engine_init,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment