Lines Matching refs:drm

28 #include <drm/ttm/ttm_range_manager.h>
29 #include <drm/drm_cache.h>
70 struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
73 if (drm->client.device.info.ram_size == 0)
76 ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, res);
105 struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
108 ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, res);
131 struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
135 ret = nouveau_mem_new(&drm->master, nvbo->kind, nvbo->comp, res);
160 nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
162 struct nvif_mmu *mmu = &drm->client.mmu;
170 drm->ttm.type_host[!!kind] = typei;
176 drm->ttm.type_ncoh[!!kind] = typei;
181 nouveau_ttm_init_vram(struct nouveau_drm *drm)
183 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
191 ttm_resource_manager_init(man, &drm->ttm.bdev,
192 drm->gem.vram_available >> PAGE_SHIFT);
193 ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
197 return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM, false,
198 drm->gem.vram_available >> PAGE_SHIFT);
203 nouveau_ttm_fini_vram(struct nouveau_drm *drm)
205 struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
207 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
209 ttm_resource_manager_evict_all(&drm->ttm.bdev, man);
211 ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, NULL);
214 ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_VRAM);
218 nouveau_ttm_init_gtt(struct nouveau_drm *drm)
221 unsigned long size_pages = drm->gem.gart_available >> PAGE_SHIFT;
224 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA)
226 else if (!drm->agp.bridge)
229 return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT, true,
238 ttm_resource_manager_init(man, &drm->ttm.bdev, size_pages);
239 ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
245 nouveau_ttm_fini_gtt(struct nouveau_drm *drm)
247 struct ttm_resource_manager *man = ttm_manager_type(&drm->ttm.bdev, TTM_PL_TT);
249 if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA &&
250 drm->agp.bridge)
251 ttm_range_man_fini(&drm->ttm.bdev, TTM_PL_TT);
254 ttm_resource_manager_evict_all(&drm->ttm.bdev, man);
256 ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, NULL);
262 nouveau_ttm_init(struct nouveau_drm *drm)
264 struct nvkm_device *device = nvxx_device(&drm->client.device);
266 struct nvif_mmu *mmu = &drm->client.mmu;
267 struct drm_device *dev = drm->dev;
270 ret = nouveau_ttm_init_host(drm, 0);
274 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
275 drm->client.device.info.chipset != 0x50) {
276 ret = nouveau_ttm_init_host(drm, NVIF_MEM_KIND);
281 if (drm->client.device.info.platform != NV_DEVICE_INFO_V0_SOC &&
282 drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
290 drm->ttm.type_vram = typei;
292 drm->ttm.type_vram = -1;
296 drm->agp.bridge = pci->agp.bridge;
297 drm->agp.base = pci->agp.base;
298 drm->agp.size = pci->agp.size;
299 drm->agp.cma = pci->agp.cma;
302 ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev,
305 drm_need_swiotlb(drm->client.mmu.dmabits),
306 drm->client.mmu.dmabits <= 32);
308 NV_ERROR(drm, "error initialising bo driver, %d\n", ret);
313 drm->gem.vram_available = drm->client.device.info.ram_user;
318 ret = nouveau_ttm_init_vram(drm);
320 NV_ERROR(drm, "VRAM mm init failed, %d\n", ret);
324 drm->ttm.mtrr = arch_phys_wc_add(device->func->resource_addr(device, 1),
328 if (!drm->agp.bridge) {
329 drm->gem.gart_available = drm->client.vmm.vmm.limit;
331 drm->gem.gart_available = drm->agp.size;
334 ret = nouveau_ttm_init_gtt(drm);
336 NV_ERROR(drm, "GART mm init failed, %d\n", ret);
340 mutex_init(&drm->ttm.io_reserve_mutex);
341 INIT_LIST_HEAD(&drm->ttm.io_reserve_lru);
343 NV_INFO(drm, "VRAM: %d MiB\n", (u32)(drm->gem.vram_available >> 20));
344 NV_INFO(drm, "GART: %d MiB\n", (u32)(drm->gem.gart_available >> 20));
349 nouveau_ttm_fini(struct nouveau_drm *drm)
351 struct nvkm_device *device = nvxx_device(&drm->client.device);
353 nouveau_ttm_fini_vram(drm);
354 nouveau_ttm_fini_gtt(drm);
356 ttm_device_fini(&drm->ttm.bdev);
358 arch_phys_wc_del(drm->ttm.mtrr);
359 drm->ttm.mtrr = 0;