[Nouveau] [PATCH v2 2/6] instmem/gk20a: move memory allocation to instmem

Ilia Mirkin imirkin at alum.mit.edu
Tue Feb 10 23:55:47 PST 2015


On Wed, Feb 11, 2015 at 2:21 AM, Alexandre Courbot <gnurou at gmail.com> wrote:
> +static int
> +gk20a_instmem_fini(struct nvkm_object *object, bool suspend)
> +{
> +       struct gk20a_instmem_priv *priv = (void *)object;
> +       priv->addr = ~0ULL;
> +       return nvkm_instmem_fini(&priv->base, suspend);
> +}
> +
> +static int
> +gk20a_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
> +                  struct nvkm_oclass *oclass, void *data, u32 size,
> +                  struct nvkm_object **pobject)
> +{
> +       struct gk20a_instmem_priv *priv;
> +       int ret;
> +
> +       ret = nvkm_instmem_create(parent, engine, oclass, &priv);
> +       *pobject = nv_object(priv);
> +       if (ret)
> +               return ret;
> +
> +       spin_lock_init(&priv->lock);
> +
> +       return 0;
> +}
> +
> +struct nvkm_oclass *
> +gk20a_instmem_oclass = &(struct nvkm_instmem_impl) {
> +       .base.handle = NV_SUBDEV(INSTMEM, 0xea),
> +       .base.ofuncs = &(struct nvkm_ofuncs) {
> +               .ctor = gk20a_instmem_ctor,
> +               .dtor = _nvkm_instmem_dtor,
> +               .init = _nvkm_instmem_init,
> +               .fini = gk20a_instmem_fini,
> +       },
> +       .instobj = &gk20a_instobj_oclass.base,
> +}.base;

Minor point, but you could just reuse the nv50 functions here, instead
of redefining them (and get rid of gk20a_instmem_priv). Your call...
not like it's a ton of code being duplicated, and it would require
exposing the nv50_instmem_priv stuff.

Also, I know you're just copy/pasting the nv50 code for the instmem
stuff... but that open-coded ALIGN() is really painful to look at.

  -ilia


More information about the Nouveau mailing list