Commit ab403ac9 authored by Ben Skeggs's avatar Ben Skeggs

drm/nv31/mpeg: remove need for separate refcnt on engine use

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent b449a43f
...@@ -137,18 +137,23 @@ nv31_mpeg_context_ctor(struct nouveau_object *parent, ...@@ -137,18 +137,23 @@ nv31_mpeg_context_ctor(struct nouveau_object *parent,
{ {
struct nv31_mpeg_priv *priv = (void *)engine; struct nv31_mpeg_priv *priv = (void *)engine;
struct nv31_mpeg_chan *chan; struct nv31_mpeg_chan *chan;
unsigned long flags;
int ret; int ret;
if (!atomic_add_unless(&priv->refcount, 1, 1))
return -EBUSY;
ret = nouveau_object_create(parent, engine, oclass, 0, &chan); ret = nouveau_object_create(parent, engine, oclass, 0, &chan);
*pobject = nv_object(chan); *pobject = nv_object(chan);
if (ret) if (ret)
return ret; return ret;
spin_lock_irqsave(&nv_engine(priv)->lock, flags);
if (priv->chan) {
spin_unlock_irqrestore(&nv_engine(priv)->lock, flags);
nouveau_object_destroy(&chan->base);
*pobject = NULL;
return -EBUSY;
}
priv->chan = chan; priv->chan = chan;
spin_unlock_irqrestore(&nv_engine(priv)->lock, flags);
return 0; return 0;
} }
...@@ -157,11 +162,12 @@ nv31_mpeg_context_dtor(struct nouveau_object *object) ...@@ -157,11 +162,12 @@ nv31_mpeg_context_dtor(struct nouveau_object *object)
{ {
struct nv31_mpeg_priv *priv = (void *)object->engine; struct nv31_mpeg_priv *priv = (void *)object->engine;
struct nv31_mpeg_chan *chan = (void *)object; struct nv31_mpeg_chan *chan = (void *)object;
unsigned long flags;
WARN_ON(priv->chan != chan); spin_lock_irqsave(&nv_engine(priv)->lock, flags);
priv->chan = NULL; priv->chan = NULL;
spin_unlock_irqrestore(&nv_engine(priv)->lock, flags);
nouveau_object_destroy(&chan->base); nouveau_object_destroy(&chan->base);
atomic_dec(&priv->refcount);
} }
struct nouveau_oclass struct nouveau_oclass
...@@ -193,20 +199,19 @@ nv31_mpeg_tile_prog(struct nouveau_engine *engine, int i) ...@@ -193,20 +199,19 @@ nv31_mpeg_tile_prog(struct nouveau_engine *engine, int i)
void void
nv31_mpeg_intr(struct nouveau_subdev *subdev) nv31_mpeg_intr(struct nouveau_subdev *subdev)
{ {
struct nv31_mpeg_priv *priv = (void *)subdev;
struct nouveau_fifo *pfifo = nouveau_fifo(subdev); struct nouveau_fifo *pfifo = nouveau_fifo(subdev);
struct nouveau_handle *handle; struct nouveau_handle *handle;
struct nv31_mpeg_priv *priv = (void *)subdev; struct nouveau_object *engctx;
struct nouveau_object *engctx = &priv->chan->base;
u32 stat = nv_rd32(priv, 0x00b100); u32 stat = nv_rd32(priv, 0x00b100);
u32 type = nv_rd32(priv, 0x00b230); u32 type = nv_rd32(priv, 0x00b230);
u32 mthd = nv_rd32(priv, 0x00b234); u32 mthd = nv_rd32(priv, 0x00b234);
u32 data = nv_rd32(priv, 0x00b238); u32 data = nv_rd32(priv, 0x00b238);
u32 show = stat; u32 show = stat;
int chid = pfifo->chid(pfifo, engctx); unsigned long flags;
if (engctx) spin_lock_irqsave(&nv_engine(priv)->lock, flags);
if (nouveau_object_inc(engctx)) engctx = nv_object(priv->chan);
engctx = NULL;
if (stat & 0x01000000) { if (stat & 0x01000000) {
/* happens on initial binding of the object */ /* happens on initial binding of the object */
...@@ -227,14 +232,12 @@ nv31_mpeg_intr(struct nouveau_subdev *subdev) ...@@ -227,14 +232,12 @@ nv31_mpeg_intr(struct nouveau_subdev *subdev)
nv_wr32(priv, 0x00b230, 0x00000001); nv_wr32(priv, 0x00b230, 0x00000001);
if (show) { if (show) {
nv_error(priv, nv_error(priv, "ch %d [%s] 0x%08x 0x%08x 0x%08x 0x%08x\n",
"ch %d [%s] 0x%08x 0x%08x 0x%08x 0x%08x\n", pfifo->chid(pfifo, engctx),
chid, nouveau_client_name(engctx), stat, nouveau_client_name(engctx), stat, type, mthd, data);
type, mthd, data);
} }
if (engctx) spin_unlock_irqrestore(&nv_engine(priv)->lock, flags);
WARN_ON(nouveau_object_dec(engctx, false));
} }
static int static int
......
...@@ -9,7 +9,6 @@ struct nv31_mpeg_chan { ...@@ -9,7 +9,6 @@ struct nv31_mpeg_chan {
struct nv31_mpeg_priv { struct nv31_mpeg_priv {
struct nouveau_mpeg base; struct nouveau_mpeg base;
atomic_t refcount;
struct nv31_mpeg_chan *chan; struct nv31_mpeg_chan *chan;
}; };
......
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