]> Pileus Git - ~andy/linux/blobdiff - drivers/gpu/drm/nouveau/nouveau_chan.c
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[~andy/linux] / drivers / gpu / drm / nouveau / nouveau_chan.c
index b1eea19d99a61865573b9fe5d3e5f727adb152bc..c1d7301c0e9c0b48c96b72613e4536c1ada9b1e8 100644 (file)
@@ -47,7 +47,7 @@ module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
 int
 nouveau_channel_idle(struct nouveau_channel *chan)
 {
-       struct nouveau_drm *drm = chan->drm;
+       struct nouveau_cli *cli = chan->cli;
        struct nouveau_fence *fence = NULL;
        int ret;
 
@@ -58,7 +58,7 @@ nouveau_channel_idle(struct nouveau_channel *chan)
        }
 
        if (ret)
-               NV_ERROR(drm, "failed to idle channel 0x%08x\n", chan->handle);
+               NV_ERROR(cli, "failed to idle channel 0x%08x\n", chan->handle);
        return ret;
 }
 
@@ -182,11 +182,16 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli,
        return 0;
 }
 
-int
+static int
 nouveau_channel_ind(struct nouveau_drm *drm, struct nouveau_cli *cli,
-                   u32 parent, u32 handle, struct nouveau_channel **pchan)
+                   u32 parent, u32 handle, u32 engine,
+                   struct nouveau_channel **pchan)
 {
-       static const u16 oclasses[] = { 0xa06f, 0x906f, 0x826f, 0x506f, 0 };
+       static const u16 oclasses[] = { NVE0_CHANNEL_IND_CLASS,
+                                       NVC0_CHANNEL_IND_CLASS,
+                                       NV84_CHANNEL_IND_CLASS,
+                                       NV50_CHANNEL_IND_CLASS,
+                                       0 };
        const u16 *oclass = oclasses;
        struct nve0_channel_ind_class args;
        struct nouveau_channel *chan;
@@ -202,7 +207,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nouveau_cli *cli,
        args.pushbuf = chan->push.handle;
        args.ioffset = 0x10000 + chan->push.vma.offset;
        args.ilength = 0x02000;
-       args.engine  = NVE0_CHANNEL_IND_ENGINE_GR;
+       args.engine  = engine;
 
        do {
                ret = nouveau_object_new(nv_object(cli), parent, handle,
@@ -220,9 +225,13 @@ static int
 nouveau_channel_dma(struct nouveau_drm *drm, struct nouveau_cli *cli,
                    u32 parent, u32 handle, struct nouveau_channel **pchan)
 {
-       static const u16 oclasses[] = { 0x006e, 0 };
+       static const u16 oclasses[] = { NV40_CHANNEL_DMA_CLASS,
+                                       NV17_CHANNEL_DMA_CLASS,
+                                       NV10_CHANNEL_DMA_CLASS,
+                                       NV03_CHANNEL_DMA_CLASS,
+                                       0 };
        const u16 *oclass = oclasses;
-       struct nv_channel_dma_class args;
+       struct nv03_channel_dma_class args;
        struct nouveau_channel *chan;
        int ret;
 
@@ -261,9 +270,6 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
        struct nv_dma_class args;
        int ret, i;
 
-       chan->vram = vram;
-       chan->gart = gart;
-
        /* allocate dma objects to cover all allowed vram, and gart */
        if (device->card_type < NV_C0) {
                if (device->card_type >= NV_50) {
@@ -301,10 +307,14 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
                                         0x003d, &args, sizeof(args), &object);
                if (ret)
                        return ret;
+
+               chan->vram = vram;
+               chan->gart = gart;
        }
 
        /* initialise dma tracking parameters */
-       switch (nv_hclass(chan->object) & 0xffff) {
+       switch (nv_hclass(chan->object) & 0x00ff) {
+       case 0x006b:
        case 0x006e:
                chan->user_put = 0x40;
                chan->user_get = 0x44;
@@ -336,15 +346,17 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
        /* allocate software object class (used for fences on <= nv05, and
         * to signal flip completion), bind it to a subchannel.
         */
-       ret = nouveau_object_new(nv_object(client), chan->handle,
-                                NvSw, nouveau_abi16_swclass(chan->drm),
-                                NULL, 0, &object);
-       if (ret)
-               return ret;
+       if (chan != chan->drm->cechan) {
+               ret = nouveau_object_new(nv_object(client), chan->handle,
+                                        NvSw, nouveau_abi16_swclass(chan->drm),
+                                        NULL, 0, &object);
+               if (ret)
+                       return ret;
 
-       swch = (void *)object->parent;
-       swch->flip = nouveau_flip_complete;
-       swch->flip_data = chan;
+               swch = (void *)object->parent;
+               swch->flip = nouveau_flip_complete;
+               swch->flip_data = chan;
+       }
 
        if (device->card_type < NV_C0) {
                ret = RING_SPACE(chan, 2);
@@ -362,24 +374,24 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
 
 int
 nouveau_channel_new(struct nouveau_drm *drm, struct nouveau_cli *cli,
-                   u32 parent, u32 handle, u32 vram, u32 gart,
+                   u32 parent, u32 handle, u32 arg0, u32 arg1,
                    struct nouveau_channel **pchan)
 {
        int ret;
 
-       ret = nouveau_channel_ind(drm, cli, parent, handle, pchan);
+       ret = nouveau_channel_ind(drm, cli, parent, handle, arg0, pchan);
        if (ret) {
-               NV_DEBUG(drm, "ib channel create, %d\n", ret);
+               NV_DEBUG(cli, "ib channel create, %d\n", ret);
                ret = nouveau_channel_dma(drm, cli, parent, handle, pchan);
                if (ret) {
-                       NV_DEBUG(drm, "dma channel create, %d\n", ret);
+                       NV_DEBUG(cli, "dma channel create, %d\n", ret);
                        return ret;
                }
        }
 
-       ret = nouveau_channel_init(*pchan, vram, gart);
+       ret = nouveau_channel_init(*pchan, arg0, arg1);
        if (ret) {
-               NV_ERROR(drm, "channel failed to initialise, %d\n", ret);
+               NV_ERROR(cli, "channel failed to initialise, %d\n", ret);
                nouveau_channel_del(pchan);
                return ret;
        }