Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/drivers: add support for using the arch wc mapping API.

This fixes a regression in all these drivers since the cache
mode tracking was fixed for mixed mappings. It uses the new
arch API to add the VRAM range to the PAT mapping tracking
tables.

Fixes: 87744ab3832 (mm: fix cache mode tracking in vm_insert_mixed())
Reviewed-by: Christian König <christian.koenig@amd.com>.
Signed-off-by: Dave Airlie <airlied@redhat.com>

+38
+5
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 754 754 755 755 int amdgpu_bo_init(struct amdgpu_device *adev) 756 756 { 757 + /* reserve PAT memory space to WC for VRAM */ 758 + arch_io_reserve_memtype_wc(adev->mc.aper_base, 759 + adev->mc.aper_size); 760 + 757 761 /* Add an MTRR for the VRAM */ 758 762 adev->mc.vram_mtrr = arch_phys_wc_add(adev->mc.aper_base, 759 763 adev->mc.aper_size); ··· 773 769 { 774 770 amdgpu_ttm_fini(adev); 775 771 arch_phys_wc_del(adev->mc.vram_mtrr); 772 + arch_io_free_memtype_wc(adev->mc.aper_base, adev->mc.aper_size); 776 773 } 777 774 778 775 int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
+6
drivers/gpu/drm/ast/ast_ttm.c
··· 267 267 return ret; 268 268 } 269 269 270 + arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0), 271 + pci_resource_len(dev->pdev, 0)); 270 272 ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), 271 273 pci_resource_len(dev->pdev, 0)); 272 274 ··· 277 275 278 276 void ast_mm_fini(struct ast_private *ast) 279 277 { 278 + struct drm_device *dev = ast->dev; 279 + 280 280 ttm_bo_device_release(&ast->ttm.bdev); 281 281 282 282 ast_ttm_global_release(ast); 283 283 284 284 arch_phys_wc_del(ast->fb_mtrr); 285 + arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0), 286 + pci_resource_len(dev->pdev, 0)); 285 287 } 286 288 287 289 void ast_ttm_placement(struct ast_bo *bo, int domain)
+7
drivers/gpu/drm/cirrus/cirrus_ttm.c
··· 267 267 return ret; 268 268 } 269 269 270 + arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0), 271 + pci_resource_len(dev->pdev, 0)); 272 + 270 273 cirrus->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), 271 274 pci_resource_len(dev->pdev, 0)); 272 275 ··· 279 276 280 277 void cirrus_mm_fini(struct cirrus_device *cirrus) 281 278 { 279 + struct drm_device *dev = cirrus->dev; 280 + 282 281 if (!cirrus->mm_inited) 283 282 return; 284 283 ··· 290 285 291 286 arch_phys_wc_del(cirrus->fb_mtrr); 292 287 cirrus->fb_mtrr = 0; 288 + arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0), 289 + pci_resource_len(dev->pdev, 0)); 293 290 } 294 291 295 292 void cirrus_ttm_placement(struct cirrus_bo *bo, int domain)
+7
drivers/gpu/drm/mgag200/mgag200_ttm.c
··· 266 266 return ret; 267 267 } 268 268 269 + arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0), 270 + pci_resource_len(dev->pdev, 0)); 271 + 269 272 mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), 270 273 pci_resource_len(dev->pdev, 0)); 271 274 ··· 277 274 278 275 void mgag200_mm_fini(struct mga_device *mdev) 279 276 { 277 + struct drm_device *dev = mdev->dev; 278 + 280 279 ttm_bo_device_release(&mdev->ttm.bdev); 281 280 282 281 mgag200_ttm_global_release(mdev); 283 282 283 + arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0), 284 + pci_resource_len(dev->pdev, 0)); 284 285 arch_phys_wc_del(mdev->fb_mtrr); 285 286 mdev->fb_mtrr = 0; 286 287 }
+8
drivers/gpu/drm/nouveau/nouveau_ttm.c
··· 398 398 /* VRAM init */ 399 399 drm->gem.vram_available = drm->device.info.ram_user; 400 400 401 + arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1), 402 + device->func->resource_size(device, 1)); 403 + 401 404 ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, 402 405 drm->gem.vram_available >> PAGE_SHIFT); 403 406 if (ret) { ··· 433 430 void 434 431 nouveau_ttm_fini(struct nouveau_drm *drm) 435 432 { 433 + struct nvkm_device *device = nvxx_device(&drm->device); 434 + 436 435 ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM); 437 436 ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT); 438 437 ··· 444 439 445 440 arch_phys_wc_del(drm->ttm.mtrr); 446 441 drm->ttm.mtrr = 0; 442 + arch_io_free_memtype_wc(device->func->resource_addr(device, 1), 443 + device->func->resource_size(device, 1)); 444 + 447 445 }
+5
drivers/gpu/drm/radeon/radeon_object.c
··· 446 446 447 447 int radeon_bo_init(struct radeon_device *rdev) 448 448 { 449 + /* reserve PAT memory space to WC for VRAM */ 450 + arch_io_reserve_memtype_wc(rdev->mc.aper_base, 451 + rdev->mc.aper_size); 452 + 449 453 /* Add an MTRR for the VRAM */ 450 454 if (!rdev->fastfb_working) { 451 455 rdev->mc.vram_mtrr = arch_phys_wc_add(rdev->mc.aper_base, ··· 467 463 { 468 464 radeon_ttm_fini(rdev); 469 465 arch_phys_wc_del(rdev->mc.vram_mtrr); 466 + arch_io_free_memtype_wc(rdev->mc.aper_base, rdev->mc.aper_size); 470 467 } 471 468 472 469 /* Returns how many bytes TTM can move per IB.