Commit 7cf321d1 authored by Dave Airlie's avatar Dave Airlie

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: 87744ab3 (mm: fix cache mode tracking in vm_insert_mixed())
Reviewed-by: Christian König <christian.koenig@amd.com>.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 8ef42276
...@@ -754,6 +754,10 @@ static const char *amdgpu_vram_names[] = { ...@@ -754,6 +754,10 @@ static const char *amdgpu_vram_names[] = {
int amdgpu_bo_init(struct amdgpu_device *adev) int amdgpu_bo_init(struct amdgpu_device *adev)
{ {
/* reserve PAT memory space to WC for VRAM */
arch_io_reserve_memtype_wc(adev->mc.aper_base,
adev->mc.aper_size);
/* Add an MTRR for the VRAM */ /* Add an MTRR for the VRAM */
adev->mc.vram_mtrr = arch_phys_wc_add(adev->mc.aper_base, adev->mc.vram_mtrr = arch_phys_wc_add(adev->mc.aper_base,
adev->mc.aper_size); adev->mc.aper_size);
...@@ -769,6 +773,7 @@ void amdgpu_bo_fini(struct amdgpu_device *adev) ...@@ -769,6 +773,7 @@ void amdgpu_bo_fini(struct amdgpu_device *adev)
{ {
amdgpu_ttm_fini(adev); amdgpu_ttm_fini(adev);
arch_phys_wc_del(adev->mc.vram_mtrr); arch_phys_wc_del(adev->mc.vram_mtrr);
arch_io_free_memtype_wc(adev->mc.aper_base, adev->mc.aper_size);
} }
int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo, int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo,
......
...@@ -267,6 +267,8 @@ int ast_mm_init(struct ast_private *ast) ...@@ -267,6 +267,8 @@ int ast_mm_init(struct ast_private *ast)
return ret; return ret;
} }
arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0));
ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0)); pci_resource_len(dev->pdev, 0));
...@@ -275,11 +277,15 @@ int ast_mm_init(struct ast_private *ast) ...@@ -275,11 +277,15 @@ int ast_mm_init(struct ast_private *ast)
void ast_mm_fini(struct ast_private *ast) void ast_mm_fini(struct ast_private *ast)
{ {
struct drm_device *dev = ast->dev;
ttm_bo_device_release(&ast->ttm.bdev); ttm_bo_device_release(&ast->ttm.bdev);
ast_ttm_global_release(ast); ast_ttm_global_release(ast);
arch_phys_wc_del(ast->fb_mtrr); arch_phys_wc_del(ast->fb_mtrr);
arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0));
} }
void ast_ttm_placement(struct ast_bo *bo, int domain) void ast_ttm_placement(struct ast_bo *bo, int domain)
......
...@@ -267,6 +267,9 @@ int cirrus_mm_init(struct cirrus_device *cirrus) ...@@ -267,6 +267,9 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
return ret; return ret;
} }
arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0));
cirrus->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), cirrus->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0)); pci_resource_len(dev->pdev, 0));
...@@ -276,6 +279,8 @@ int cirrus_mm_init(struct cirrus_device *cirrus) ...@@ -276,6 +279,8 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
void cirrus_mm_fini(struct cirrus_device *cirrus) void cirrus_mm_fini(struct cirrus_device *cirrus)
{ {
struct drm_device *dev = cirrus->dev;
if (!cirrus->mm_inited) if (!cirrus->mm_inited)
return; return;
...@@ -285,6 +290,8 @@ void cirrus_mm_fini(struct cirrus_device *cirrus) ...@@ -285,6 +290,8 @@ void cirrus_mm_fini(struct cirrus_device *cirrus)
arch_phys_wc_del(cirrus->fb_mtrr); arch_phys_wc_del(cirrus->fb_mtrr);
cirrus->fb_mtrr = 0; cirrus->fb_mtrr = 0;
arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0));
} }
void cirrus_ttm_placement(struct cirrus_bo *bo, int domain) void cirrus_ttm_placement(struct cirrus_bo *bo, int domain)
......
...@@ -266,6 +266,9 @@ int mgag200_mm_init(struct mga_device *mdev) ...@@ -266,6 +266,9 @@ int mgag200_mm_init(struct mga_device *mdev)
return ret; return ret;
} }
arch_io_reserve_memtype_wc(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0));
mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0), mdev->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0)); pci_resource_len(dev->pdev, 0));
...@@ -274,10 +277,14 @@ int mgag200_mm_init(struct mga_device *mdev) ...@@ -274,10 +277,14 @@ int mgag200_mm_init(struct mga_device *mdev)
void mgag200_mm_fini(struct mga_device *mdev) void mgag200_mm_fini(struct mga_device *mdev)
{ {
struct drm_device *dev = mdev->dev;
ttm_bo_device_release(&mdev->ttm.bdev); ttm_bo_device_release(&mdev->ttm.bdev);
mgag200_ttm_global_release(mdev); mgag200_ttm_global_release(mdev);
arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
pci_resource_len(dev->pdev, 0));
arch_phys_wc_del(mdev->fb_mtrr); arch_phys_wc_del(mdev->fb_mtrr);
mdev->fb_mtrr = 0; mdev->fb_mtrr = 0;
} }
......
...@@ -398,6 +398,9 @@ nouveau_ttm_init(struct nouveau_drm *drm) ...@@ -398,6 +398,9 @@ nouveau_ttm_init(struct nouveau_drm *drm)
/* VRAM init */ /* VRAM init */
drm->gem.vram_available = drm->device.info.ram_user; drm->gem.vram_available = drm->device.info.ram_user;
arch_io_reserve_memtype_wc(device->func->resource_addr(device, 1),
device->func->resource_size(device, 1));
ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM, ret = ttm_bo_init_mm(&drm->ttm.bdev, TTM_PL_VRAM,
drm->gem.vram_available >> PAGE_SHIFT); drm->gem.vram_available >> PAGE_SHIFT);
if (ret) { if (ret) {
...@@ -430,6 +433,8 @@ nouveau_ttm_init(struct nouveau_drm *drm) ...@@ -430,6 +433,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)
void void
nouveau_ttm_fini(struct nouveau_drm *drm) nouveau_ttm_fini(struct nouveau_drm *drm)
{ {
struct nvkm_device *device = nvxx_device(&drm->device);
ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM); ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_VRAM);
ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT); ttm_bo_clean_mm(&drm->ttm.bdev, TTM_PL_TT);
...@@ -439,4 +444,7 @@ nouveau_ttm_fini(struct nouveau_drm *drm) ...@@ -439,4 +444,7 @@ nouveau_ttm_fini(struct nouveau_drm *drm)
arch_phys_wc_del(drm->ttm.mtrr); arch_phys_wc_del(drm->ttm.mtrr);
drm->ttm.mtrr = 0; drm->ttm.mtrr = 0;
arch_io_free_memtype_wc(device->func->resource_addr(device, 1),
device->func->resource_size(device, 1));
} }
...@@ -446,6 +446,10 @@ void radeon_bo_force_delete(struct radeon_device *rdev) ...@@ -446,6 +446,10 @@ void radeon_bo_force_delete(struct radeon_device *rdev)
int radeon_bo_init(struct radeon_device *rdev) int radeon_bo_init(struct radeon_device *rdev)
{ {
/* reserve PAT memory space to WC for VRAM */
arch_io_reserve_memtype_wc(rdev->mc.aper_base,
rdev->mc.aper_size);
/* Add an MTRR for the VRAM */ /* Add an MTRR for the VRAM */
if (!rdev->fastfb_working) { if (!rdev->fastfb_working) {
rdev->mc.vram_mtrr = arch_phys_wc_add(rdev->mc.aper_base, rdev->mc.vram_mtrr = arch_phys_wc_add(rdev->mc.aper_base,
...@@ -463,6 +467,7 @@ void radeon_bo_fini(struct radeon_device *rdev) ...@@ -463,6 +467,7 @@ void radeon_bo_fini(struct radeon_device *rdev)
{ {
radeon_ttm_fini(rdev); radeon_ttm_fini(rdev);
arch_phys_wc_del(rdev->mc.vram_mtrr); arch_phys_wc_del(rdev->mc.vram_mtrr);
arch_io_free_memtype_wc(rdev->mc.aper_base, rdev->mc.aper_size);
} }
/* Returns how many bytes TTM can move per IB. /* Returns how many bytes TTM can move per IB.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment