]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/nouveau: fetch memory type indices that we care about for ttm
authorBen Skeggs <bskeggs@redhat.com>
Tue, 31 Oct 2017 17:56:20 +0000 (03:56 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 2 Nov 2017 03:32:32 +0000 (13:32 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_ttm.c

index ac5c66e60b2ab4832beddfff18e8c9c37fb8d029..6d6795b5b3efbc318357f5096fe671e77ac87543 100644 (file)
@@ -140,6 +140,9 @@ struct nouveau_drm {
                struct nouveau_channel *chan;
                struct nvif_object copy;
                int mtrr;
+               int type_vram;
+               int type_host;
+               int type_ncoh;
        } ttm;
 
        /* GEM interface support */
index 3211f78da4dd5525d33e0b44e95a5c58ad839caf..f64a55421a96464ec4fed1e8ce12cceaf55857a7 100644 (file)
@@ -252,8 +252,36 @@ nouveau_ttm_init(struct nouveau_drm *drm)
 {
        struct nvkm_device *device = nvxx_device(&drm->client.device);
        struct nvkm_pci *pci = device->pci;
+       struct nvif_mmu *mmu = &drm->client.mmu;
        struct drm_device *dev = drm->dev;
-       int ret;
+       int typei, ret;
+
+       typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE |
+                                                  NVIF_MEM_COHERENT);
+       if (typei < 0)
+               return -ENOSYS;
+
+       drm->ttm.type_host = typei;
+
+       typei = nvif_mmu_type(mmu, NVIF_MEM_HOST | NVIF_MEM_MAPPABLE);
+       if (typei < 0)
+               return -ENOSYS;
+
+       drm->ttm.type_ncoh = typei;
+
+       if (drm->client.device.info.platform != NV_DEVICE_INFO_V0_SOC &&
+           drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
+               typei = nvif_mmu_type(mmu, NVIF_MEM_VRAM | NVIF_MEM_MAPPABLE |
+                                          NVIF_MEM_KIND |
+                                          NVIF_MEM_COMP |
+                                          NVIF_MEM_DISP);
+               if (typei < 0)
+                       return -ENOSYS;
+
+               drm->ttm.type_vram = typei;
+       } else {
+               drm->ttm.type_vram = -1;
+       }
 
        if (pci && pci->agp.bridge) {
                drm->agp.bridge = pci->agp.bridge;