]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/nouveau: remove no_vm/mappable flags from nouveau_bo
authorBen Skeggs <bskeggs@redhat.com>
Tue, 15 Feb 2011 22:41:56 +0000 (08:41 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 24 Feb 2011 20:45:34 +0000 (06:45 +1000)
'mappable' isn't really used at all, nor is it necessary anymore as the
bo code is capable of moving buffers to mappable vram as required.

'no_vm' isn't necessary anymore either, any places that don't want to be
mapped into a GPU address space should allocate the VRAM directly instead.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
14 files changed:
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_channel.c
drivers/gpu/drm/nouveau/nouveau_dma.h
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_fbcon.c
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_mem.c
drivers/gpu/drm/nouveau/nouveau_notifier.c
drivers/gpu/drm/nouveau/nouveau_state.c
drivers/gpu/drm/nouveau/nv04_crtc.c
drivers/gpu/drm/nouveau/nv50_crtc.c
drivers/gpu/drm/nouveau/nv50_evo.c
drivers/gpu/drm/nouveau/nvc0_fifo.c

index bf260af18b31d8f5e8cda46cb2b6ce27080e1616..897c55509a6bcda381b46bc70ecd97b7e76be3e9 100644 (file)
@@ -98,8 +98,7 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, int *align, int *size,
 int
 nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
               int size, int align, uint32_t flags, uint32_t tile_mode,
-              uint32_t tile_flags, bool no_vm, bool mappable,
-              struct nouveau_bo **pnvbo)
+              uint32_t tile_flags, struct nouveau_bo **pnvbo)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct nouveau_bo *nvbo;
@@ -110,8 +109,6 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
                return -ENOMEM;
        INIT_LIST_HEAD(&nvbo->head);
        INIT_LIST_HEAD(&nvbo->entry);
-       nvbo->mappable = mappable;
-       nvbo->no_vm = no_vm;
        nvbo->tile_mode = tile_mode;
        nvbo->tile_flags = tile_flags;
        nvbo->bo.bdev = &dev_priv->ttm.bdev;
@@ -119,7 +116,7 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
        nouveau_bo_fixup_align(nvbo, &align, &size, &page_shift);
        align >>= PAGE_SHIFT;
 
-       if (!nvbo->no_vm && dev_priv->chan_vm) {
+       if (dev_priv->chan_vm) {
                ret = nouveau_vm_get(dev_priv->chan_vm, size, page_shift,
                                     NV_MEM_ACCESS_RW, &nvbo->vma);
                if (ret) {
@@ -504,14 +501,6 @@ static inline uint32_t
 nouveau_bo_mem_ctxdma(struct ttm_buffer_object *bo,
                      struct nouveau_channel *chan, struct ttm_mem_reg *mem)
 {
-       struct nouveau_bo *nvbo = nouveau_bo(bo);
-
-       if (nvbo->no_vm) {
-               if (mem->mem_type == TTM_PL_TT)
-                       return NvDmaGART;
-               return NvDmaVRAM;
-       }
-
        if (mem->mem_type == TTM_PL_TT)
                return chan->gart_handle;
        return chan->vram_handle;
@@ -523,22 +512,21 @@ nvc0_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
 {
        struct drm_nouveau_private *dev_priv = nouveau_bdev(bo->bdev);
        struct nouveau_bo *nvbo = nouveau_bo(bo);
-       u64 src_offset = old_mem->start << PAGE_SHIFT;
-       u64 dst_offset = new_mem->start << PAGE_SHIFT;
        u32 page_count = new_mem->num_pages;
+       u64 src_offset, dst_offset;
        int ret;
 
-       if (!nvbo->no_vm) {
-               if (old_mem->mem_type == TTM_PL_VRAM)
-                       src_offset  = nvbo->vma.offset;
-               else
-                       src_offset += dev_priv->gart_info.aper_base;
+       src_offset = old_mem->start << PAGE_SHIFT;
+       if (old_mem->mem_type == TTM_PL_VRAM)
+               src_offset  = nvbo->vma.offset;
+       else
+               src_offset += dev_priv->gart_info.aper_base;
 
-               if (new_mem->mem_type == TTM_PL_VRAM)
-                       dst_offset  = nvbo->vma.offset;
-               else
-                       dst_offset += dev_priv->gart_info.aper_base;
-       }
+       dst_offset = new_mem->start << PAGE_SHIFT;
+       if (new_mem->mem_type == TTM_PL_VRAM)
+               dst_offset  = nvbo->vma.offset;
+       else
+               dst_offset += dev_priv->gart_info.aper_base;
 
        page_count = new_mem->num_pages;
        while (page_count) {
@@ -580,18 +568,16 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
        int ret;
 
        src_offset = old_mem->start << PAGE_SHIFT;
-       dst_offset = new_mem->start << PAGE_SHIFT;
-       if (!nvbo->no_vm) {
-               if (old_mem->mem_type == TTM_PL_VRAM)
-                       src_offset  = nvbo->vma.offset;
-               else
-                       src_offset += dev_priv->gart_info.aper_base;
+       if (old_mem->mem_type == TTM_PL_VRAM)
+               src_offset  = nvbo->vma.offset;
+       else
+               src_offset += dev_priv->gart_info.aper_base;
 
-               if (new_mem->mem_type == TTM_PL_VRAM)
-                       dst_offset  = nvbo->vma.offset;
-               else
-                       dst_offset += dev_priv->gart_info.aper_base;
-       }
+       dst_offset = new_mem->start << PAGE_SHIFT;
+       if (new_mem->mem_type == TTM_PL_VRAM)
+               dst_offset  = nvbo->vma.offset;
+       else
+               dst_offset += dev_priv->gart_info.aper_base;
 
        ret = RING_SPACE(chan, 3);
        if (ret)
@@ -737,7 +723,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
        int ret;
 
        chan = nvbo->channel;
-       if (!chan || nvbo->no_vm) {
+       if (!chan) {
                chan = dev_priv->channel;
                mutex_lock_nested(&chan->mutex, NOUVEAU_KCHANNEL_MUTEX);
        }
@@ -836,7 +822,7 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem,
        struct nouveau_bo *nvbo = nouveau_bo(bo);
        uint64_t offset;
 
-       if (nvbo->no_vm || new_mem->mem_type != TTM_PL_VRAM) {
+       if (new_mem->mem_type != TTM_PL_VRAM) {
                /* Nothing to do. */
                *new_tile = NULL;
                return 0;
index 3d7b316c3bbdb7678754ea35e63decd563da0e36..3837090d66af71bfab695a06ef8d11640c4121c2 100644 (file)
@@ -90,8 +90,7 @@ nouveau_channel_user_pushbuf_alloc(struct drm_device *dev)
        else
                location = TTM_PL_FLAG_TT;
 
-       ret = nouveau_bo_new(dev, NULL, 65536, 0, location, 0, 0x0000, false,
-                            true, &pushbuf);
+       ret = nouveau_bo_new(dev, NULL, 65536, 0, location, 0, 0x0000, &pushbuf);
        if (ret) {
                NV_ERROR(dev, "error allocating DMA push buffer: %d\n", ret);
                return NULL;
index 6f0f4bb93796dbae232e1574ecd040dda5e4dbe0..23d4edf992b7d20440eb53ce8273231ccfe487e1 100644 (file)
@@ -61,8 +61,6 @@ enum {
        NvM2MF          = 0x80000001,
        NvDmaFB         = 0x80000002,
        NvDmaTT         = 0x80000003,
-       NvDmaVRAM       = 0x80000004,
-       NvDmaGART       = 0x80000005,
        NvNotify0       = 0x80000006,
        Nv2D            = 0x80000007,
        NvCtxSurf2D     = 0x80000008,
index 8f6491845692ec68f798a32fcc39c769fd393e6d..f591c84a2792e76607fa074621548f1bd2ea819a 100644 (file)
@@ -104,8 +104,6 @@ struct nouveau_bo {
        struct nouveau_channel *channel;
 
        struct nouveau_vma vma;
-       bool mappable;
-       bool no_vm;
 
        uint32_t tile_mode;
        uint32_t tile_flags;
@@ -1293,7 +1291,7 @@ extern struct ttm_bo_driver nouveau_bo_driver;
 extern int nouveau_bo_new(struct drm_device *, struct nouveau_channel *,
                          int size, int align, uint32_t flags,
                          uint32_t tile_mode, uint32_t tile_flags,
-                         bool no_vm, bool mappable, struct nouveau_bo **);
+                         struct nouveau_bo **);
 extern int nouveau_bo_pin(struct nouveau_bo *, uint32_t flags);
 extern int nouveau_bo_unpin(struct nouveau_bo *);
 extern int nouveau_bo_map(struct nouveau_bo *);
@@ -1356,7 +1354,7 @@ static inline struct nouveau_fence *nouveau_fence_ref(struct nouveau_fence *obj)
 extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *,
                           int size, int align, uint32_t flags,
                           uint32_t tile_mode, uint32_t tile_flags,
-                          bool no_vm, bool mappable, struct nouveau_bo **);
+                          struct nouveau_bo **);
 extern int nouveau_gem_object_new(struct drm_gem_object *);
 extern void nouveau_gem_object_del(struct drm_gem_object *);
 extern int nouveau_gem_ioctl_new(struct drm_device *, void *,
index 60769d2f9a6683b28f90551a0c0e1e6908814833..9d7a9887607443dc97af6cfadbef4a532053e450 100644 (file)
@@ -297,7 +297,7 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
        size = roundup(size, PAGE_SIZE);
 
        ret = nouveau_gem_new(dev, dev_priv->channel, size, 0, TTM_PL_FLAG_VRAM,
-                             0, 0x0000, false, true, &nvbo);
+                             0, 0x0000, &nvbo);
        if (ret) {
                NV_ERROR(dev, "failed to allocate framebuffer\n");
                goto out;
index 8b46392b0ca9e3594146c057dd8da2515c99d315..a244702bb2276983f37304fa2946d5c82c450ee9 100644 (file)
@@ -578,7 +578,7 @@ nouveau_fence_init(struct drm_device *dev)
        /* Create a shared VRAM heap for cross-channel sync. */
        if (USE_SEMA(dev)) {
                ret = nouveau_bo_new(dev, NULL, size, 0, TTM_PL_FLAG_VRAM,
-                                    0, 0, false, true, &dev_priv->fence.bo);
+                                    0, 0, &dev_priv->fence.bo);
                if (ret)
                        return ret;
 
index 506c508b7edaa43821ad64d8155d0520cb794158..29ededdee98010f39cda0e909daa7a45d75e993c 100644 (file)
@@ -62,14 +62,13 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
 int
 nouveau_gem_new(struct drm_device *dev, struct nouveau_channel *chan,
                int size, int align, uint32_t flags, uint32_t tile_mode,
-               uint32_t tile_flags, bool no_vm, bool mappable,
-               struct nouveau_bo **pnvbo)
+               uint32_t tile_flags, struct nouveau_bo **pnvbo)
 {
        struct nouveau_bo *nvbo;
        int ret;
 
        ret = nouveau_bo_new(dev, chan, size, align, flags, tile_mode,
-                            tile_flags, no_vm, mappable, pnvbo);
+                            tile_flags, pnvbo);
        if (ret)
                return ret;
        nvbo = *pnvbo;
@@ -97,7 +96,7 @@ nouveau_gem_info(struct drm_gem_object *gem, struct drm_nouveau_gem_info *rep)
 
        rep->size = nvbo->bo.mem.num_pages << PAGE_SHIFT;
        rep->offset = nvbo->bo.offset;
-       rep->map_handle = nvbo->mappable ? nvbo->bo.addr_space_offset : 0;
+       rep->map_handle = nvbo->bo.addr_space_offset;
        rep->tile_mode = nvbo->tile_mode;
        rep->tile_flags = nvbo->tile_flags;
        return 0;
@@ -136,9 +135,7 @@ nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
        }
 
        ret = nouveau_gem_new(dev, chan, req->info.size, req->align, flags,
-                             req->info.tile_mode, req->info.tile_flags, false,
-                             (req->info.domain & NOUVEAU_GEM_DOMAIN_MAPPABLE),
-                             &nvbo);
+                             req->info.tile_mode, req->info.tile_flags, &nvbo);
        if (chan)
                nouveau_channel_put(&chan);
        if (ret)
index 5cf924ed4ac63be9bb1b16228aabf17c88f5f921..16eee50a0572ac40e00c3bd8c4773aa1f3b727ac 100644 (file)
@@ -152,7 +152,6 @@ nouveau_mem_vram_fini(struct drm_device *dev)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
-       nouveau_bo_unpin(dev_priv->vga_ram);
        nouveau_bo_ref(NULL, &dev_priv->vga_ram);
 
        ttm_bo_device_release(&dev_priv->ttm.bdev);
@@ -461,13 +460,17 @@ nouveau_mem_vram_init(struct drm_device *dev)
                return ret;
        }
 
-       ret = nouveau_bo_new(dev, NULL, 256*1024, 0, TTM_PL_FLAG_VRAM,
-                            0, 0, true, true, &dev_priv->vga_ram);
-       if (ret == 0)
-               ret = nouveau_bo_pin(dev_priv->vga_ram, TTM_PL_FLAG_VRAM);
-       if (ret) {
-               NV_WARN(dev, "failed to reserve VGA memory\n");
-               nouveau_bo_ref(NULL, &dev_priv->vga_ram);
+       if (dev_priv->card_type < NV_50) {
+               ret = nouveau_bo_new(dev, NULL, 256*1024, 0, TTM_PL_FLAG_VRAM,
+                                    0, 0, &dev_priv->vga_ram);
+               if (ret == 0)
+                       ret = nouveau_bo_pin(dev_priv->vga_ram,
+                                            TTM_PL_FLAG_VRAM);
+
+               if (ret) {
+                       NV_WARN(dev, "failed to reserve VGA memory\n");
+                       nouveau_bo_ref(NULL, &dev_priv->vga_ram);
+               }
        }
 
        dev_priv->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
@@ -672,13 +675,14 @@ nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long p_size
 {
        struct drm_nouveau_private *dev_priv = nouveau_bdev(man->bdev);
        struct nouveau_mm *mm;
-       u32 b_size;
+       u64 size, block, rsvd;
        int ret;
 
-       p_size = (p_size << PAGE_SHIFT) >> 12;
-       b_size = dev_priv->vram_rblock_size >> 12;
+       rsvd  = (256 * 1024); /* vga memory */
+       size  = (p_size << PAGE_SHIFT) - rsvd;
+       block = dev_priv->vram_rblock_size;
 
-       ret = nouveau_mm_init(&mm, 0, p_size, b_size);
+       ret = nouveau_mm_init(&mm, rsvd >> 12, size >> 12, block >> 12);
        if (ret)
                return ret;
 
index fe29d604b820cf2f5c82d27738bdb1c77f840a94..92c029920efe122b6781be542c1abfd7c5ae3c74 100644 (file)
@@ -43,8 +43,7 @@ nouveau_notifier_init_channel(struct nouveau_channel *chan)
        else
                flags = TTM_PL_FLAG_TT;
 
-       ret = nouveau_gem_new(dev, NULL, PAGE_SIZE, 0, flags,
-                             0, 0x0000, false, true, &ntfy);
+       ret = nouveau_gem_new(dev, NULL, PAGE_SIZE, 0, flags, 0, 0, &ntfy);
        if (ret)
                return ret;
 
index 43acfc2aded5237db7ed75022c5e532632754908..05294910e135630ca7516e34a4dfea4076883c22 100644 (file)
@@ -544,7 +544,6 @@ static int
 nouveau_card_init_channel(struct drm_device *dev)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_gpuobj *gpuobj = NULL;
        int ret;
 
        ret = nouveau_channel_alloc(dev, &dev_priv->channel,
@@ -552,41 +551,8 @@ nouveau_card_init_channel(struct drm_device *dev)
        if (ret)
                return ret;
 
-       /* no dma objects on fermi... */
-       if (dev_priv->card_type >= NV_C0)
-               goto out_done;
-
-       ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
-                                    0, dev_priv->vram_size,
-                                    NV_MEM_ACCESS_RW, NV_MEM_TARGET_VRAM,
-                                    &gpuobj);
-       if (ret)
-               goto out_err;
-
-       ret = nouveau_ramht_insert(dev_priv->channel, NvDmaVRAM, gpuobj);
-       nouveau_gpuobj_ref(NULL, &gpuobj);
-       if (ret)
-               goto out_err;
-
-       ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
-                                    0, dev_priv->gart_info.aper_size,
-                                    NV_MEM_ACCESS_RW, NV_MEM_TARGET_GART,
-                                    &gpuobj);
-       if (ret)
-               goto out_err;
-
-       ret = nouveau_ramht_insert(dev_priv->channel, NvDmaGART, gpuobj);
-       nouveau_gpuobj_ref(NULL, &gpuobj);
-       if (ret)
-               goto out_err;
-
-out_done:
        mutex_unlock(&dev_priv->channel->mutex);
        return 0;
-
-out_err:
-       nouveau_channel_put(&dev_priv->channel);
-       return ret;
 }
 
 static void nouveau_switcheroo_set_state(struct pci_dev *pdev,
index 297505eb98d5802f141e9c8dd06d6e6f7f1191b8..a260fbbe3d9b8230e52960de6d56281f1ebf4589 100644 (file)
@@ -1031,7 +1031,7 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
        drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
 
        ret = nouveau_bo_new(dev, NULL, 64*64*4, 0x100, TTM_PL_FLAG_VRAM,
-                            0, 0x0000, false, true, &nv_crtc->cursor.nvbo);
+                            0, 0x0000, &nv_crtc->cursor.nvbo);
        if (!ret) {
                ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
                if (!ret)
index 568fb47041669ab8b6a3281137be86999432fdc0..2b9984027f417702af0ce5ec9b6d03326cb4f32a 100644 (file)
@@ -752,7 +752,7 @@ nv50_crtc_create(struct drm_device *dev, int index)
        nv_crtc->lut.depth = 0;
 
        ret = nouveau_bo_new(dev, NULL, 4096, 0x100, TTM_PL_FLAG_VRAM,
-                            0, 0x0000, false, true, &nv_crtc->lut.nvbo);
+                            0, 0x0000, &nv_crtc->lut.nvbo);
        if (!ret) {
                ret = nouveau_bo_pin(nv_crtc->lut.nvbo, TTM_PL_FLAG_VRAM);
                if (!ret)
@@ -778,7 +778,7 @@ nv50_crtc_create(struct drm_device *dev, int index)
        drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
 
        ret = nouveau_bo_new(dev, NULL, 64*64*4, 0x100, TTM_PL_FLAG_VRAM,
-                            0, 0x0000, false, true, &nv_crtc->cursor.nvbo);
+                            0, 0x0000, &nv_crtc->cursor.nvbo);
        if (!ret) {
                ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
                if (!ret)
index 18fbf27376c1a4ebfddd47616f2355313a770bb8..a2cfaa691e9bb3968d7e12f41cc5c5e226a4008a 100644 (file)
@@ -117,7 +117,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
        evo->user_put = 0;
 
        ret = nouveau_bo_new(dev, NULL, 4096, 0, TTM_PL_FLAG_VRAM, 0, 0,
-                            false, true, &evo->pushbuf_bo);
+                            &evo->pushbuf_bo);
        if (ret == 0)
                ret = nouveau_bo_pin(evo->pushbuf_bo, TTM_PL_FLAG_VRAM);
        if (ret) {
@@ -331,7 +331,7 @@ nv50_evo_create(struct drm_device *dev)
                        goto err;
 
                ret = nouveau_bo_new(dev, NULL, 4096, 0x1000, TTM_PL_FLAG_VRAM,
-                                    0, 0x0000, false, true, &dispc->sem.bo);
+                                    0, 0x0000, &dispc->sem.bo);
                if (!ret) {
                        offset = dispc->sem.bo->bo.mem.start << PAGE_SHIFT;
 
index e9f8643bed9be2350ed9d9f0b971fec672b722f8..2886f2726a9e07ebe25eddb484a061fa2990a503 100644 (file)
@@ -116,7 +116,7 @@ nvc0_fifo_create_context(struct nouveau_channel *chan)
 
        /* allocate vram for control regs, map into polling area */
        ret = nouveau_bo_new(dev, NULL, 0x1000, 0, TTM_PL_FLAG_VRAM,
-                            0, 0, true, true, &fifoch->user);
+                            0, 0, &fifoch->user);
        if (ret)
                goto error;