aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_bo.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2013-11-12 07:34:09 -0500
committerBen Skeggs <bskeggs@redhat.com>2014-01-22 22:38:26 -0500
commita554090664728384c94b027ba15bc7df87f9ac09 (patch)
treed45d393740f003efeaba661f5ca9caf31549fad0 /drivers/gpu/drm/nouveau/nouveau_bo.c
parentce8f7699f2b6ffe4aa8368b8d9d370875accaa5f (diff)
drm/nv50-: map TTM_PL_SYSTEM through a BAR for CPU access
Moves bo's to TTM_PL_TT for BAR mapping, to hide tiling from user. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bo.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index e4623e9a7be3..39ca36c7e455 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1241,6 +1241,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
1241{ 1241{
1242 struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; 1242 struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
1243 struct nouveau_drm *drm = nouveau_bdev(bdev); 1243 struct nouveau_drm *drm = nouveau_bdev(bdev);
1244 struct nouveau_mem *node = mem->mm_node;
1244 struct drm_device *dev = drm->dev; 1245 struct drm_device *dev = drm->dev;
1245 int ret; 1246 int ret;
1246 1247
@@ -1263,14 +1264,16 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
1263 mem->bus.is_iomem = !dev->agp->cant_use_aperture; 1264 mem->bus.is_iomem = !dev->agp->cant_use_aperture;
1264 } 1265 }
1265#endif 1266#endif
1266 break; 1267 if (!node->memtype)
1268 /* untiled */
1269 break;
1270 /* fallthrough, tiled memory */
1267 case TTM_PL_VRAM: 1271 case TTM_PL_VRAM:
1268 mem->bus.offset = mem->start << PAGE_SHIFT; 1272 mem->bus.offset = mem->start << PAGE_SHIFT;
1269 mem->bus.base = pci_resource_start(dev->pdev, 1); 1273 mem->bus.base = pci_resource_start(dev->pdev, 1);
1270 mem->bus.is_iomem = true; 1274 mem->bus.is_iomem = true;
1271 if (nv_device(drm->device)->card_type >= NV_50) { 1275 if (nv_device(drm->device)->card_type >= NV_50) {
1272 struct nouveau_bar *bar = nouveau_bar(drm->device); 1276 struct nouveau_bar *bar = nouveau_bar(drm->device);
1273 struct nouveau_mem *node = mem->mm_node;
1274 1277
1275 ret = bar->umap(bar, node, NV_MEM_ACCESS_RW, 1278 ret = bar->umap(bar, node, NV_MEM_ACCESS_RW,
1276 &node->bar_vma); 1279 &node->bar_vma);
@@ -1306,6 +1309,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
1306 struct nouveau_bo *nvbo = nouveau_bo(bo); 1309 struct nouveau_bo *nvbo = nouveau_bo(bo);
1307 struct nouveau_device *device = nv_device(drm->device); 1310 struct nouveau_device *device = nv_device(drm->device);
1308 u32 mappable = pci_resource_len(device->pdev, 1) >> PAGE_SHIFT; 1311 u32 mappable = pci_resource_len(device->pdev, 1) >> PAGE_SHIFT;
1312 int ret;
1309 1313
1310 /* as long as the bo isn't in vram, and isn't tiled, we've got 1314 /* as long as the bo isn't in vram, and isn't tiled, we've got
1311 * nothing to do here. 1315 * nothing to do here.
@@ -1314,10 +1318,20 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
1314 if (nv_device(drm->device)->card_type < NV_50 || 1318 if (nv_device(drm->device)->card_type < NV_50 ||
1315 !nouveau_bo_tile_layout(nvbo)) 1319 !nouveau_bo_tile_layout(nvbo))
1316 return 0; 1320 return 0;
1321
1322 if (bo->mem.mem_type == TTM_PL_SYSTEM) {
1323 nouveau_bo_placement_set(nvbo, TTM_PL_TT, 0);
1324
1325 ret = nouveau_bo_validate(nvbo, false, false);
1326 if (ret)
1327 return ret;
1328 }
1329 return 0;
1317 } 1330 }
1318 1331
1319 /* make sure bo is in mappable vram */ 1332 /* make sure bo is in mappable vram */
1320 if (bo->mem.start + bo->mem.num_pages < mappable) 1333 if (nv_device(drm->device)->card_type >= NV_50 ||
1334 bo->mem.start + bo->mem.num_pages < mappable)
1321 return 0; 1335 return 0;
1322 1336
1323 1337