Commit 1cf65c45 authored by Christian König's avatar Christian König

drm/ttm: add caching state to ttm_bus_placement

And implement setting it up correctly in the drivers.

This allows getting rid of the placement flags for this.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Link: https://patchwork.freedesktop.org/patch/394254/
parent 1b4ea4c5
...@@ -769,6 +769,7 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso ...@@ -769,6 +769,7 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso
mem->bus.offset += adev->gmc.aper_base; mem->bus.offset += adev->gmc.aper_base;
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
mem->bus.caching = ttm_write_combined;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -981,6 +981,7 @@ static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev, ...@@ -981,6 +981,7 @@ static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
case TTM_PL_VRAM: case TTM_PL_VRAM:
mem->bus.offset = (mem->start << PAGE_SHIFT) + vmm->vram_base; mem->bus.offset = (mem->start << PAGE_SHIFT) + vmm->vram_base;
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
mem->bus.caching = ttm_write_combined;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -1134,6 +1134,8 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg) ...@@ -1134,6 +1134,8 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg)
struct nouveau_drm *drm = nouveau_bdev(bdev); struct nouveau_drm *drm = nouveau_bdev(bdev);
struct nvkm_device *device = nvxx_device(&drm->client.device); struct nvkm_device *device = nvxx_device(&drm->client.device);
struct nouveau_mem *mem = nouveau_mem(reg); struct nouveau_mem *mem = nouveau_mem(reg);
struct nvif_mmu *mmu = &drm->client.mmu;
const u8 type = mmu->type[drm->ttm.type_vram].type;
int ret; int ret;
mutex_lock(&drm->ttm.io_reserve_mutex); mutex_lock(&drm->ttm.io_reserve_mutex);
...@@ -1149,6 +1151,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg) ...@@ -1149,6 +1151,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg)
reg->bus.offset = (reg->start << PAGE_SHIFT) + reg->bus.offset = (reg->start << PAGE_SHIFT) +
drm->agp.base; drm->agp.base;
reg->bus.is_iomem = !drm->agp.cma; reg->bus.is_iomem = !drm->agp.cma;
reg->bus.caching = ttm_write_combined;
} }
#endif #endif
if (drm->client.mem->oclass < NVIF_CLASS_MEM_NV50 || if (drm->client.mem->oclass < NVIF_CLASS_MEM_NV50 ||
...@@ -1162,6 +1165,14 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg) ...@@ -1162,6 +1165,14 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *reg)
reg->bus.offset = (reg->start << PAGE_SHIFT) + reg->bus.offset = (reg->start << PAGE_SHIFT) +
device->func->resource_addr(device, 1); device->func->resource_addr(device, 1);
reg->bus.is_iomem = true; reg->bus.is_iomem = true;
/* Some BARs do not support being ioremapped WC */
if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA &&
type & NVIF_MEM_UNCACHED)
reg->bus.caching = ttm_uncached;
else
reg->bus.caching = ttm_write_combined;
if (drm->client.mem->oclass >= NVIF_CLASS_MEM_NV50) { if (drm->client.mem->oclass >= NVIF_CLASS_MEM_NV50) {
union { union {
struct nv50_mem_map_v0 nv50; struct nv50_mem_map_v0 nv50;
......
...@@ -83,11 +83,13 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev, ...@@ -83,11 +83,13 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
case TTM_PL_VRAM: case TTM_PL_VRAM:
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
mem->bus.offset = (mem->start << PAGE_SHIFT) + qdev->vram_base; mem->bus.offset = (mem->start << PAGE_SHIFT) + qdev->vram_base;
mem->bus.caching = ttm_cached;
break; break;
case TTM_PL_PRIV: case TTM_PL_PRIV:
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
mem->bus.offset = (mem->start << PAGE_SHIFT) + mem->bus.offset = (mem->start << PAGE_SHIFT) +
qdev->surfaceram_base; qdev->surfaceram_base;
mem->bus.caching = ttm_cached;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -372,6 +372,7 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso ...@@ -372,6 +372,7 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso
mem->bus.offset = (mem->start << PAGE_SHIFT) + mem->bus.offset = (mem->start << PAGE_SHIFT) +
rdev->mc.agp_base; rdev->mc.agp_base;
mem->bus.is_iomem = !rdev->ddev->agp->cant_use_aperture; mem->bus.is_iomem = !rdev->ddev->agp->cant_use_aperture;
mem->bus.caching = ttm_write_combined;
} }
#endif #endif
break; break;
...@@ -382,6 +383,7 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso ...@@ -382,6 +383,7 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso
return -EINVAL; return -EINVAL;
mem->bus.offset += rdev->mc.aper_base; mem->bus.offset += rdev->mc.aper_base;
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
mem->bus.caching = ttm_write_combined;
#ifdef __alpha__ #ifdef __alpha__
/* /*
* Alpha: use bus.addr to hold the ioremap() return, * Alpha: use bus.addr to hold the ioremap() return,
......
...@@ -688,6 +688,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resourc ...@@ -688,6 +688,7 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resourc
mem->bus.offset = (mem->start << PAGE_SHIFT) + mem->bus.offset = (mem->start << PAGE_SHIFT) +
dev_priv->vram_start; dev_priv->vram_start;
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
mem->bus.caching = ttm_cached;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/dma-fence.h> #include <linux/dma-fence.h>
#include <drm/drm_print.h> #include <drm/drm_print.h>
#include <drm/ttm/ttm_caching.h>
#define TTM_MAX_BO_PRIORITY 4U #define TTM_MAX_BO_PRIORITY 4U
...@@ -148,9 +149,10 @@ struct ttm_resource_manager { ...@@ -148,9 +149,10 @@ struct ttm_resource_manager {
* Structure indicating the bus placement of an object. * Structure indicating the bus placement of an object.
*/ */
struct ttm_bus_placement { struct ttm_bus_placement {
void *addr; void *addr;
phys_addr_t offset; phys_addr_t offset;
bool is_iomem; bool is_iomem;
enum ttm_caching caching;
}; };
/** /**
......
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