diff options
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 11 | ||||
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_mem.c | 6 | ||||
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_ttm.c | 39 |
4 files changed, 42 insertions, 16 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 42c1827bbb8e..435ff8662cfa 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
| @@ -224,7 +224,7 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align, | |||
| 224 | /* Determine if we can get a cache-coherent map, forcing | 224 | /* Determine if we can get a cache-coherent map, forcing |
| 225 | * uncached mapping if we can't. | 225 | * uncached mapping if we can't. |
| 226 | */ | 226 | */ |
| 227 | if (mmu->type[drm->ttm.type_host].type & NVIF_MEM_UNCACHED) | 227 | if (!nouveau_drm_use_coherent_gpu_mapping(drm)) |
| 228 | nvbo->force_coherent = true; | 228 | nvbo->force_coherent = true; |
| 229 | } | 229 | } |
| 230 | 230 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index e86b8220a4bb..6a1b1debe5b8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
| @@ -156,8 +156,8 @@ struct nouveau_drm { | |||
| 156 | struct nvif_object copy; | 156 | struct nvif_object copy; |
| 157 | int mtrr; | 157 | int mtrr; |
| 158 | int type_vram; | 158 | int type_vram; |
| 159 | int type_host; | 159 | int type_host[2]; |
| 160 | int type_ncoh; | 160 | int type_ncoh[2]; |
| 161 | } ttm; | 161 | } ttm; |
| 162 | 162 | ||
| 163 | /* GEM interface support */ | 163 | /* GEM interface support */ |
| @@ -216,6 +216,13 @@ nouveau_drm(struct drm_device *dev) | |||
| 216 | return dev->dev_private; | 216 | return dev->dev_private; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | static inline bool | ||
| 220 | nouveau_drm_use_coherent_gpu_mapping(struct nouveau_drm *drm) | ||
| 221 | { | ||
| 222 | struct nvif_mmu *mmu = &drm->client.mmu; | ||
| 223 | return !(mmu->type[drm->ttm.type_host[0]].type & NVIF_MEM_UNCACHED); | ||
| 224 | } | ||
| 225 | |||
| 219 | int nouveau_pmops_suspend(struct device *); | 226 | int nouveau_pmops_suspend(struct device *); |
| 220 | int nouveau_pmops_resume(struct device *); | 227 | int nouveau_pmops_resume(struct device *); |
| 221 | bool nouveau_pmops_runtime(void); | 228 | bool nouveau_pmops_runtime(void); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c index 589a9621db76..c002f8968507 100644 --- a/drivers/gpu/drm/nouveau/nouveau_mem.c +++ b/drivers/gpu/drm/nouveau/nouveau_mem.c | |||
| @@ -103,10 +103,10 @@ nouveau_mem_host(struct ttm_mem_reg *reg, struct ttm_dma_tt *tt) | |||
| 103 | u8 type; | 103 | u8 type; |
| 104 | int ret; | 104 | int ret; |
| 105 | 105 | ||
| 106 | if (mmu->type[drm->ttm.type_host].type & NVIF_MEM_UNCACHED) | 106 | if (!nouveau_drm_use_coherent_gpu_mapping(drm)) |
| 107 | type = drm->ttm.type_ncoh; | 107 | type = drm->ttm.type_ncoh[!!mem->kind]; |
| 108 | else | 108 | else |
| 109 | type = drm->ttm.type_host; | 109 | type = drm->ttm.type_host[0]; |
| 110 | 110 | ||
| 111 | if (mem->kind && !(mmu->type[type].type & NVIF_MEM_KIND)) | 111 | if (mem->kind && !(mmu->type[type].type & NVIF_MEM_KIND)) |
| 112 | mem->comp = mem->kind = 0; | 112 | mem->comp = mem->kind = 0; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index 08b974b30482..dff51a0ee028 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c | |||
| @@ -235,27 +235,46 @@ nouveau_ttm_global_release(struct nouveau_drm *drm) | |||
| 235 | drm->ttm.mem_global_ref.release = NULL; | 235 | drm->ttm.mem_global_ref.release = NULL; |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | int | 238 | static int |
| 239 | nouveau_ttm_init(struct nouveau_drm *drm) | 239 | nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind) |
| 240 | { | 240 | { |
| 241 | struct nvkm_device *device = nvxx_device(&drm->client.device); | ||
| 242 | struct nvkm_pci *pci = device->pci; | ||
| 243 | struct nvif_mmu *mmu = &drm->client.mmu; | 241 | struct nvif_mmu *mmu = &drm->client.mmu; |
| 244 | struct drm_device *dev = drm->dev; | 242 | int typei; |
| 245 | int typei, ret; | ||
| 246 | 243 | ||
| 247 | typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE | | 244 | typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE | |
| 248 | NVIF_MEM_COHERENT); | 245 | kind | NVIF_MEM_COHERENT); |
| 249 | if (typei < 0) | 246 | if (typei < 0) |
| 250 | return -ENOSYS; | 247 | return -ENOSYS; |
| 251 | 248 | ||
| 252 | drm->ttm.type_host = typei; | 249 | drm->ttm.type_host[!!kind] = typei; |
| 253 | 250 | ||
| 254 | typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE); | 251 | typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE | kind); |
| 255 | if (typei < 0) | 252 | if (typei < 0) |
| 256 | return -ENOSYS; | 253 | return -ENOSYS; |
| 257 | 254 | ||
| 258 | drm->ttm.type_ncoh = typei; | 255 | drm->ttm.type_ncoh[!!kind] = typei; |
| 256 | return 0; | ||
| 257 | } | ||
| 258 | |||
| 259 | int | ||
| 260 | nouveau_ttm_init(struct nouveau_drm *drm) | ||
| 261 | { | ||
| 262 | struct nvkm_device *device = nvxx_device(&drm->client.device); | ||
| 263 | struct nvkm_pci *pci = device->pci; | ||
| 264 | struct nvif_mmu *mmu = &drm->client.mmu; | ||
| 265 | struct drm_device *dev = drm->dev; | ||
| 266 | int typei, ret; | ||
| 267 | |||
| 268 | ret = nouveau_ttm_init_host(drm, 0); | ||
| 269 | if (ret) | ||
| 270 | return ret; | ||
| 271 | |||
| 272 | if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA && | ||
| 273 | drm->client.device.info.chipset != 0x50) { | ||
| 274 | ret = nouveau_ttm_init_host(drm, NVIF_MEM_KIND); | ||
| 275 | if (ret) | ||
| 276 | return ret; | ||
| 277 | } | ||
| 259 | 278 | ||
| 260 | if (drm->client.device.info.platform != NV_DEVICE_INFO_V0_SOC && | 279 | if (drm->client.device.info.platform != NV_DEVICE_INFO_V0_SOC && |
| 261 | drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { | 280 | drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) { |
