Skip to content

Commit

Permalink
gdev: modified unnecessary PGRAPH context for COMP subchannel
Browse files Browse the repository at this point in the history
  • Loading branch information
iwata-axe committed Mar 13, 2013
1 parent cfa19f8 commit 1bbbe16
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
12 changes: 11 additions & 1 deletion lib/user/nouveau/nouveau_gdev.c
Expand Up @@ -37,7 +37,9 @@
#define GDEV_DEVICE_MAX_COUNT 32

struct gdev_nouveau_ctx_objects {
#if 0 /* un-necessary */
struct nouveau_object *comp;
#endif
struct nouveau_object *m2mf;
};

Expand Down Expand Up @@ -243,10 +245,12 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
struct nouveau_client *client = (struct nouveau_client *)gdev->priv;
struct nouveau_device *dev = client->device;
struct gdev_nouveau_ctx_objects *ctx_objects;
struct nouveau_object *comp;
struct nouveau_object *m2mf;
uint32_t m2mf_class = 0;
#if 0 /* un-necessary */
struct nouveau_object *comp;
uint32_t comp_class = 0;
#endif

if (!(ctx = malloc(sizeof(*ctx))))
goto fail_ctx;
Expand Down Expand Up @@ -341,6 +345,7 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
if (nouveau_object_new(chan, 0xbeef323f, m2mf_class, NULL, 0, &m2mf))
goto fail_m2mf;
ctx_objects->m2mf = m2mf;
#if 0 /* un-necessary */
/* allocating PGRAPH context for COMPUTE */
if ((gdev->chipset & 0xf0) < 0xc0)
comp_class = 0x50c0;
Expand All @@ -351,6 +356,7 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
if (nouveau_object_new(chan, 0xbeef90c0, comp_class, NULL, 0, &comp))
goto fail_comp;
ctx_objects->comp = comp;
#endif

ctx->pdata = (void *)ctx_objects;

Expand All @@ -362,8 +368,10 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas

return ctx;

#if 0 /* un-necessary */
fail_comp:
nouveau_object_del(&m2mf);
#endif
fail_m2mf:
free(ctx_objects);
fail_ctx_objects:
Expand Down Expand Up @@ -401,7 +409,9 @@ void gdev_raw_ctx_free(struct gdev_ctx *ctx)
nouveau_bo_ref(NULL, &push_bo);
nouveau_bufctx_del(&bufctx);
nouveau_pushbuf_del(&push);
#if 0 /* un-necessary */
nouveau_object_del(&ctx_objects->comp);
#endif
nouveau_object_del(&ctx_objects->m2mf);
free(ctx_objects);
free(ctx);
Expand Down
30 changes: 19 additions & 11 deletions mod/gdev/gdev_drv_nvidia.c
Expand Up @@ -32,7 +32,7 @@
#include "gdev_sched.h"

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
struct gdev_drv_nv_ctx_objects {
struct gdev_drv_nvidia_pdata {
struct drm_device *drm;
};
#endif
Expand Down Expand Up @@ -97,12 +97,14 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
struct drm_device *drm = (struct drm_device *) gdev->priv;
uint32_t flags;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
struct gdev_drv_nv_ctx_objects *ctx_objects;
void *comp;
struct gdev_drv_nvidia_pdata *pdata;
void *m2mf;
uint32_t m2mf_class = 0;
#if 0 /* un-necessary */
void *comp;
uint32_t comp_class = 0;
#endif
#endif


if (!(ctx = kzalloc(sizeof(*ctx), GFP_KERNEL)))
Expand Down Expand Up @@ -154,10 +156,10 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
ctx->notify.addr = nbo.addr;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
if (!(ctx_objects = kzalloc(sizeof(*ctx_objects), GFP_KERNEL)))
if (!(pdata = kzalloc(sizeof(*pdata), GFP_KERNEL)))
goto fail_ctx_objects;

ctx_objects->drm = drm;
pdata->drm = drm;

/* allocating PGRAPH context for M2MF */
if ((gdev->chipset & 0xf0) < 0xc0)
Expand All @@ -168,6 +170,7 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
m2mf_class = 0xa040;
if (gdev_drv_subch_alloc(drm, ctx->pctx, 0xbeef323f, m2mf_class, &m2mf))
goto fail_m2mf;
#if 0 /* un-necessary */
/* allocating PGRAPH context for COMPUTE */
if ((gdev->chipset & 0xf0) < 0xc0)
comp_class = 0x50c0;
Expand All @@ -177,17 +180,20 @@ struct gdev_ctx *gdev_raw_ctx_new(struct gdev_device *gdev, struct gdev_vas *vas
comp_class = 0xa0c0;
if (gdev_drv_subch_alloc(drm, ctx->pctx, 0xbeef90c0, comp_class, &comp))
goto fail_comp;
#endif

ctx->pdata = (void *)ctx_objects;
ctx->pdata = (void *)pdata;
#endif

return ctx;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
#if 0 /* un-necessary */
fail_comp:
gdev_drv_subch_free(drm, ctx->pctx, 0xbeef323f);
#endif
fail_m2mf:
kfree(ctx_objects);
kfree(pdata);
fail_ctx_objects:
gdev_drv_bo_free(&vspace, &nbo);
#endif
Expand All @@ -209,7 +215,7 @@ void gdev_raw_ctx_free(struct gdev_ctx *ctx)
struct gdev_drv_bo fbo, nbo;
struct gdev_vas *vas = ctx->vas;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
struct gdev_drv_nv_ctx_objects *ctx_objects = (struct gdev_drv_nv_ctx_objects *)ctx->pdata;
struct gdev_drv_nvidia_pdata *pdata = (struct gdev_drv_nvidia_pdata *)ctx->pdata;
#endif

vspace.priv = vas->pvas;
Expand All @@ -224,9 +230,11 @@ void gdev_raw_ctx_free(struct gdev_ctx *ctx)
gdev_drv_bo_free(&vspace, &fbo);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
gdev_drv_subch_free(ctx_objects->drm, ctx->pctx, 0xbeef90c0);
gdev_drv_subch_free(ctx_objects->drm, ctx->pctx, 0xbeef323f);
kfree(ctx_objects);
#if 0 /* un-necessary */
gdev_drv_subch_free(pdata->drm, ctx->pctx, 0xbeef90c0);
#endif
gdev_drv_subch_free(pdata->drm, ctx->pctx, 0xbeef323f);
kfree(pdata);
#endif

chan.priv = ctx->pctx;
Expand Down

0 comments on commit 1bbbe16

Please sign in to comment.