Skip to content

Commit

Permalink
drm/nouveau/mc: fix race condition between constructor and request_irq()
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed Aug 21, 2013
1 parent 0ff42c5 commit 6ff8c76
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions drivers/gpu/drm/nouveau/core/include/subdev/mc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ nouveau_mc(void *obj)
return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_MC];
}

#define nouveau_mc_create(p,e,o,d) \
nouveau_mc_create_((p), (e), (o), sizeof(**d), (void **)d)
#define nouveau_mc_create(p,e,o,m,d) \
nouveau_mc_create_((p), (e), (o), (m), sizeof(**d), (void **)d)
#define nouveau_mc_destroy(p) ({ \
struct nouveau_mc *pmc = (p); _nouveau_mc_dtor(nv_object(pmc)); \
})
Expand All @@ -33,7 +33,8 @@ nouveau_mc(void *obj)
})

int nouveau_mc_create_(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, int, void **);
struct nouveau_oclass *, const struct nouveau_mc_intr *,
int, void **);
void _nouveau_mc_dtor(struct nouveau_object *);
int _nouveau_mc_init(struct nouveau_object *);
int _nouveau_mc_fini(struct nouveau_object *, bool);
Expand Down
6 changes: 5 additions & 1 deletion drivers/gpu/drm/nouveau/core/subdev/mc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ _nouveau_mc_dtor(struct nouveau_object *object)

int
nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,
struct nouveau_oclass *oclass, int length, void **pobject)
struct nouveau_oclass *oclass,
const struct nouveau_mc_intr *intr_map,
int length, void **pobject)
{
struct nouveau_device *device = nv_device(parent);
struct nouveau_mc *pmc;
Expand All @@ -92,6 +94,8 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,
if (ret)
return ret;

pmc->intr_map = intr_map;

ret = request_irq(device->pdev->irq, nouveau_mc_intr,
IRQF_SHARED, "nouveau", pmc);
if (ret < 0)
Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/nouveau/core/subdev/mc/nv04.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ nv04_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv04_mc_priv *priv;
int ret;

ret = nouveau_mc_create(parent, engine, oclass, &priv);
ret = nouveau_mc_create(parent, engine, oclass, nv04_mc_intr, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

priv->base.intr_map = nv04_mc_intr;
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ nv44_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv44_mc_priv *priv;
int ret;

ret = nouveau_mc_create(parent, engine, oclass, &priv);
ret = nouveau_mc_create(parent, engine, oclass, nv04_mc_intr, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

priv->base.intr_map = nv04_mc_intr;
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ nv50_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv50_mc_priv *priv;
int ret;

ret = nouveau_mc_create(parent, engine, oclass, &priv);
ret = nouveau_mc_create(parent, engine, oclass, nv50_mc_intr, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

priv->base.intr_map = nv50_mc_intr;
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ nv98_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nv98_mc_priv *priv;
int ret;

ret = nouveau_mc_create(parent, engine, oclass, &priv);
ret = nouveau_mc_create(parent, engine, oclass, nv98_mc_intr, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

priv->base.intr_map = nv98_mc_intr;
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ nvc0_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nvc0_mc_priv *priv;
int ret;

ret = nouveau_mc_create(parent, engine, oclass, &priv);
ret = nouveau_mc_create(parent, engine, oclass, nvc0_mc_intr, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

priv->base.intr_map = nvc0_mc_intr;
return 0;
}

Expand Down

0 comments on commit 6ff8c76

Please sign in to comment.