diff options
author | Dave Airlie <airlied@redhat.com> | 2012-02-22 09:40:28 +0000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-02-22 09:40:28 +0000 |
commit | 6efd34894c880b4ad9a56ba112631996b5ee97dc (patch) | |
tree | 9a1c56a7f53210de8bb5775831dc8fd31c72828f | |
parent | a38c43750e1ad9e0d85066748659e655e8b2f80d (diff) |
ttm: fix population on nouveau and radeondrm-dmabuf-wip
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 28 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_tt.c | 10 |
3 files changed, 38 insertions, 27 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 0b3ea671cac4..3e702487b0be 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1068,6 +1068,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) struct drm_device *dev; unsigned i; int r; + bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SLAVE); if (ttm->state != tt_unpopulated) return 0; @@ -1082,15 +1083,18 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) #endif #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { + if (!slave && swiotlb_nr_tbl()) { return ttm_dma_populate((void *)ttm, dev->dev); } #endif - r = ttm_pool_populate(ttm); - if (r) { - return r; - } + if (!slave) { + r = ttm_pool_populate(ttm); + if (r) { + return r; + } + } else + ttm->state = tt_unbound; for (i = 0; i < ttm->num_pages; i++) { ttm_dma->dma_address[i] = pci_map_page(dev->pdev, ttm->pages[i], @@ -1102,7 +1106,10 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); ttm_dma->dma_address[i] = 0; } - ttm_pool_unpopulate(ttm); + if (!slave) + ttm_pool_unpopulate(ttm); + else + ttm->state = tt_unpopulated; return -EFAULT; } } @@ -1116,6 +1123,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) struct drm_nouveau_private *dev_priv; struct drm_device *dev; unsigned i; + bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SLAVE); dev_priv = nouveau_bdev(ttm->bdev); dev = dev_priv->dev; @@ -1128,7 +1136,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) #endif #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { + if (!slave && swiotlb_nr_tbl()) { ttm_dma_unpopulate((void *)ttm, dev->dev); return; } @@ -1141,7 +1149,10 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) } } - ttm_pool_unpopulate(ttm); + if (!slave) + ttm_pool_unpopulate(ttm); + else + ttm->state = tt_unpopulated; } struct ttm_bo_driver nouveau_bo_driver = { diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index c421e77ace71..6fff21de9839 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -613,6 +613,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) struct radeon_ttm_tt *gtt = (void *)ttm; unsigned i; int r; + bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SLAVE); if (ttm->state != tt_unpopulated) return 0; @@ -625,15 +626,18 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) #endif #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { + if (!slave && swiotlb_nr_tbl()) { return ttm_dma_populate(>t->ttm, rdev->dev); } #endif - r = ttm_pool_populate(ttm); - if (r) { - return r; - } + if (!slave) { + r = ttm_pool_populate(ttm); + if (r) { + return r; + } + } else + ttm->state = tt_unbound; for (i = 0; i < ttm->num_pages; i++) { gtt->ttm.dma_address[i] = pci_map_page(rdev->pdev, ttm->pages[i], @@ -645,7 +649,10 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); gtt->ttm.dma_address[i] = 0; } - ttm_pool_unpopulate(ttm); + if (!slave) + ttm_pool_unpopulate(ttm); + else + ttm->state = tt_unpopulated; return -EFAULT; } } @@ -657,6 +664,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) struct radeon_device *rdev; struct radeon_ttm_tt *gtt = (void *)ttm; unsigned i; + bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SLAVE); rdev = radeon_get_rdev(ttm->bdev); #if __OS_HAS_AGP @@ -667,7 +675,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) #endif #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { + if (!slave && swiotlb_nr_tbl()) { ttm_dma_unpopulate(>t->ttm, rdev->dev); return; } @@ -679,8 +687,10 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); } } - - ttm_pool_unpopulate(ttm); + if (!slave) + ttm_pool_unpopulate(ttm); + else + ttm->state = tt_unpopulated; } static struct ttm_bo_driver radeon_bo_driver = { diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 73f5775e0de6..c251e6a9ff70 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -171,13 +171,6 @@ void ttm_tt_destroy(struct ttm_tt *ttm) if (likely(ttm->pages != NULL)) { ttm->bdev->driver->ttm_tt_unpopulate(ttm); - -#if 0 - else if (!(ttm->page_flags & TTM_PAGE_FLAG_SLAVE)) - ttm_tt_free_alloced_pages(ttm); - - ttm_tt_free_page_directory(ttm); -#endif } if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) && @@ -199,10 +192,7 @@ int ttm_tt_set_sg_pages(struct ttm_tt *ttm, for_each_sg(sg->sgl, sl, sg->nents, i) ttm->pages[i] = sg_page(sl); - ttm->be->func->populate(ttm->be, ttm->num_pages, ttm->pages, - ttm->dummy_read_page, ttm->dma_address); - ttm->state = tt_unbound; return 0; } |