Skip to content

Commit

Permalink
drm/nouveau/core: implement shortcut for simple engctx construction
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 Nov 28, 2012
1 parent e5e454f commit 4359887
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 115 deletions.
15 changes: 15 additions & 0 deletions drivers/gpu/drm/nouveau/core/core/engctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ nouveau_engctx_fini(struct nouveau_engctx *engctx, bool suspend)
return nouveau_gpuobj_fini(&engctx->base, suspend);
}

int
_nouveau_engctx_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nouveau_engctx *engctx;
int ret;

ret = nouveau_engctx_create(parent, engine, oclass, NULL, 256, 256,
NVOBJ_FLAG_ZERO_ALLOC, &engctx);
*pobject = nv_object(engctx);
return ret;
}

void
_nouveau_engctx_dtor(struct nouveau_object *object)
{
Expand Down
24 changes: 1 addition & 23 deletions drivers/gpu/drm/nouveau/core/engine/copy/nva3.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ struct nva3_copy_priv {
struct nouveau_falcon base;
};

struct nva3_copy_chan {
struct nouveau_falcon_chan base;
};

/*******************************************************************************
* Copy object classes
******************************************************************************/
Expand All @@ -56,29 +52,11 @@ nva3_copy_sclass[] = {
* PCOPY context
******************************************************************************/

static int
nva3_copy_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nva3_copy_chan *priv;
int ret;

ret = nouveau_falcon_context_create(parent, engine, oclass, NULL, 256,
0, NVOBJ_FLAG_ZERO_ALLOC, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

return 0;
}

static struct nouveau_oclass
nva3_copy_cclass = {
.handle = NV_ENGCTX(COPY0, 0xa3),
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nva3_copy_context_ctor,
.ctor = _nouveau_falcon_context_ctor,
.dtor = _nouveau_falcon_context_dtor,
.init = _nouveau_falcon_context_init,
.fini = _nouveau_falcon_context_fini,
Expand Down
24 changes: 1 addition & 23 deletions drivers/gpu/drm/nouveau/core/engine/copy/nvc0.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ struct nvc0_copy_priv {
struct nouveau_falcon base;
};

struct nvc0_copy_chan {
struct nouveau_falcon_chan base;
};

/*******************************************************************************
* Copy object classes
******************************************************************************/
Expand All @@ -59,27 +55,9 @@ nvc0_copy1_sclass[] = {
* PCOPY context
******************************************************************************/

static int
nvc0_copy_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nvc0_copy_chan *priv;
int ret;

ret = nouveau_falcon_context_create(parent, engine, oclass, NULL, 256,
256, NVOBJ_FLAG_ZERO_ALLOC, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

return 0;
}

static struct nouveau_ofuncs
nvc0_copy_context_ofuncs = {
.ctor = nvc0_copy_context_ctor,
.ctor = _nouveau_falcon_context_ctor,
.dtor = _nouveau_falcon_context_dtor,
.init = _nouveau_falcon_context_init,
.fini = _nouveau_falcon_context_fini,
Expand Down
24 changes: 1 addition & 23 deletions drivers/gpu/drm/nouveau/core/engine/copy/nve0.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ struct nve0_copy_priv {
struct nouveau_engine base;
};

struct nve0_copy_chan {
struct nouveau_engctx base;
};

/*******************************************************************************
* Copy object classes
******************************************************************************/
Expand All @@ -51,27 +47,9 @@ nve0_copy_sclass[] = {
* PCOPY context
******************************************************************************/

static int
nve0_copy_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nve0_copy_chan *priv;
int ret;

ret = nouveau_engctx_create(parent, engine, oclass, NULL, 256,
256, NVOBJ_FLAG_ZERO_ALLOC, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

return 0;
}

static struct nouveau_ofuncs
nve0_copy_context_ofuncs = {
.ctor = nve0_copy_context_ctor,
.ctor = _nouveau_engctx_ctor,
.dtor = _nouveau_engctx_dtor,
.init = _nouveau_engctx_init,
.fini = _nouveau_engctx_fini,
Expand Down
24 changes: 1 addition & 23 deletions drivers/gpu/drm/nouveau/core/engine/crypt/nv84.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ struct nv84_crypt_priv {
struct nouveau_engine base;
};

struct nv84_crypt_chan {
struct nouveau_engctx base;
};

/*******************************************************************************
* Crypt object classes
******************************************************************************/
Expand Down Expand Up @@ -87,29 +83,11 @@ nv84_crypt_sclass[] = {
* PCRYPT context
******************************************************************************/

static int
nv84_crypt_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv84_crypt_chan *priv;
int ret;

ret = nouveau_engctx_create(parent, engine, oclass, NULL, 256,
0, NVOBJ_FLAG_ZERO_ALLOC, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

return 0;
}

static struct nouveau_oclass
nv84_crypt_cclass = {
.handle = NV_ENGCTX(CRYPT, 0x84),
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nv84_crypt_context_ctor,
.ctor = _nouveau_engctx_ctor,
.dtor = _nouveau_engctx_dtor,
.init = _nouveau_engctx_init,
.fini = _nouveau_engctx_fini,
Expand Down
24 changes: 1 addition & 23 deletions drivers/gpu/drm/nouveau/core/engine/crypt/nv98.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ struct nv98_crypt_priv {
struct nouveau_falcon base;
};

struct nv98_crypt_chan {
struct nouveau_falcon_chan base;
};

/*******************************************************************************
* Crypt object classes
******************************************************************************/
Expand All @@ -58,29 +54,11 @@ nv98_crypt_sclass[] = {
* PCRYPT context
******************************************************************************/

static int
nv98_crypt_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv98_crypt_chan *priv;
int ret;

ret = nouveau_falcon_context_create(parent, engine, oclass, NULL, 256,
256, NVOBJ_FLAG_ZERO_ALLOC, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;

return 0;
}

static struct nouveau_oclass
nv98_crypt_cclass = {
.handle = NV_ENGCTX(CRYPT, 0x98),
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nv98_crypt_context_ctor,
.ctor = _nouveau_falcon_context_ctor,
.dtor = _nouveau_falcon_context_dtor,
.init = _nouveau_falcon_context_init,
.fini = _nouveau_falcon_context_fini,
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/nouveau/core/include/core/engctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void nouveau_engctx_destroy(struct nouveau_engctx *);
int nouveau_engctx_init(struct nouveau_engctx *);
int nouveau_engctx_fini(struct nouveau_engctx *, bool suspend);

int _nouveau_engctx_ctor(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, void *, u32,
struct nouveau_object **);
void _nouveau_engctx_dtor(struct nouveau_object *);
int _nouveau_engctx_init(struct nouveau_object *);
int _nouveau_engctx_fini(struct nouveau_object *, bool suspend);
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/core/include/core/falcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct nouveau_falcon_chan {
#define nouveau_falcon_context_fini(d,s) \
nouveau_engctx_fini(&(d)->base, (s))

#define _nouveau_falcon_context_ctor _nouveau_engctx_ctor
#define _nouveau_falcon_context_dtor _nouveau_engctx_dtor
#define _nouveau_falcon_context_init _nouveau_engctx_init
#define _nouveau_falcon_context_fini _nouveau_engctx_fini
Expand Down

0 comments on commit 4359887

Please sign in to comment.