]> Pileus Git - ~andy/linux/blobdiff - drivers/gpu/drm/nouveau/nouveau_bo.c
Merge tag 'v3.2-rc6' of /home/airlied/devel/kernel/linux-2.6 into drm-core-next
[~andy/linux] / drivers / gpu / drm / nouveau / nouveau_bo.c
index 2dc0d8303cb7c4abdd68e00f4f2dab609efabdba..f12dd0f39211869184cc7b4ad21fdd6132aa3ad8 100644 (file)
@@ -93,6 +93,7 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct nouveau_bo *nvbo;
+       size_t acc_size;
        int ret;
 
        nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
@@ -115,9 +116,12 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
        nvbo->bo.mem.num_pages = size >> PAGE_SHIFT;
        nouveau_bo_placement_set(nvbo, flags, 0);
 
+       acc_size = ttm_bo_dma_acc_size(&dev_priv->ttm.bdev, size,
+                                      sizeof(struct nouveau_bo));
+
        ret = ttm_bo_init(&dev_priv->ttm.bdev, &nvbo->bo, size,
                          ttm_bo_type_device, &nvbo->placement,
-                         align >> PAGE_SHIFT, 0, false, NULL, size,
+                         align >> PAGE_SHIFT, 0, false, NULL, acc_size,
                          nouveau_bo_del_ttm);
        if (ret) {
                /* ttm will call nouveau_bo_del_ttm if it fails.. */
@@ -149,7 +153,7 @@ set_placement_range(struct nouveau_bo *nvbo, uint32_t type)
 
        if (dev_priv->card_type == NV_10 &&
            nvbo->tile_mode && (type & TTM_PL_FLAG_VRAM) &&
-           nvbo->bo.mem.num_pages < vram_pages / 2) {
+           nvbo->bo.mem.num_pages < vram_pages / 4) {
                /*
                 * Make sure that the color and depth buffers are handled
                 * by independent memory controller units. Up to a 9x
@@ -811,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
        struct nouveau_vma *vma;
 
        list_for_each_entry(vma, &nvbo->vma_list, head) {
-               if (new_mem->mem_type == TTM_PL_VRAM) {
+               if (new_mem && new_mem->mem_type == TTM_PL_VRAM) {
                        nouveau_vm_map(vma, new_mem->mm_node);
                } else
-               if (new_mem->mem_type == TTM_PL_TT &&
+               if (new_mem && new_mem->mem_type == TTM_PL_TT &&
                    nvbo->page_shift == vma->vm->spg_shift) {
                        nouveau_vm_map_sg(vma, 0, new_mem->
                                          num_pages << PAGE_SHIFT,
@@ -1052,6 +1056,7 @@ nouveau_bo_fence(struct nouveau_bo *nvbo, struct nouveau_fence *fence)
 static int
 nouveau_ttm_tt_populate(struct ttm_tt *ttm)
 {
+       struct ttm_dma_tt *ttm_dma = (void *)ttm;
        struct drm_nouveau_private *dev_priv;
        struct drm_device *dev;
        unsigned i;
@@ -1065,7 +1070,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
 
 #ifdef CONFIG_SWIOTLB
        if (swiotlb_nr_tbl()) {
-               return ttm_dma_populate(ttm, dev->dev);
+               return ttm_dma_populate((void *)ttm, dev->dev);
        }
 #endif
 
@@ -1075,14 +1080,14 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
        }
 
        for (i = 0; i < ttm->num_pages; i++) {
-               ttm->dma_address[i] = pci_map_page(dev->pdev, ttm->pages[i],
+               ttm_dma->dma_address[i] = pci_map_page(dev->pdev, ttm->pages[i],
                                                   0, PAGE_SIZE,
                                                   PCI_DMA_BIDIRECTIONAL);
-               if (pci_dma_mapping_error(dev->pdev, ttm->dma_address[i])) {
+               if (pci_dma_mapping_error(dev->pdev, ttm_dma->dma_address[i])) {
                        while (--i) {
-                               pci_unmap_page(dev->pdev, ttm->dma_address[i],
+                               pci_unmap_page(dev->pdev, ttm_dma->dma_address[i],
                                               PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
-                               ttm->dma_address[i] = 0;
+                               ttm_dma->dma_address[i] = 0;
                        }
                        ttm_pool_unpopulate(ttm);
                        return -EFAULT;
@@ -1094,6 +1099,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
 static void
 nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
 {
+       struct ttm_dma_tt *ttm_dma = (void *)ttm;
        struct drm_nouveau_private *dev_priv;
        struct drm_device *dev;
        unsigned i;
@@ -1103,14 +1109,14 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
 
 #ifdef CONFIG_SWIOTLB
        if (swiotlb_nr_tbl()) {
-               ttm_dma_unpopulate(ttm, dev->dev);
+               ttm_dma_unpopulate((void *)ttm, dev->dev);
                return;
        }
 #endif
 
        for (i = 0; i < ttm->num_pages; i++) {
-               if (ttm->dma_address[i]) {
-                       pci_unmap_page(dev->pdev, ttm->dma_address[i],
+               if (ttm_dma->dma_address[i]) {
+                       pci_unmap_page(dev->pdev, ttm_dma->dma_address[i],
                                       PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
                }
        }