aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_ttm.c3
-rw-r--r--drivers/gpu/drm/nouveau/nv84_fence.c14
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/base.c10
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c26
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c10
7 files changed, 57 insertions, 17 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 860b0e2d4181..8670d90cdc11 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -869,13 +869,20 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
869 struct drm_mode_create_dumb *args) 869 struct drm_mode_create_dumb *args)
870{ 870{
871 struct nouveau_bo *bo; 871 struct nouveau_bo *bo;
872 uint32_t domain;
872 int ret; 873 int ret;
873 874
874 args->pitch = roundup(args->width * (args->bpp / 8), 256); 875 args->pitch = roundup(args->width * (args->bpp / 8), 256);
875 args->size = args->pitch * args->height; 876 args->size = args->pitch * args->height;
876 args->size = roundup(args->size, PAGE_SIZE); 877 args->size = roundup(args->size, PAGE_SIZE);
877 878
878 ret = nouveau_gem_new(dev, args->size, 0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0, &bo); 879 /* Use VRAM if there is any ; otherwise fallback to system memory */
880 if (nouveau_drm(dev)->device.info.ram_size != 0)
881 domain = NOUVEAU_GEM_DOMAIN_VRAM;
882 else
883 domain = NOUVEAU_GEM_DOMAIN_GART;
884
885 ret = nouveau_gem_new(dev, args->size, 0, domain, 0, 0, &bo);
879 if (ret) 886 if (ret)
880 return ret; 887 return ret;
881 888
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 273e50110ec3..18f449715788 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -82,6 +82,9 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
82 u32 size_nc = 0; 82 u32 size_nc = 0;
83 int ret; 83 int ret;
84 84
85 if (drm->device.info.ram_size == 0)
86 return -ENOMEM;
87
85 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) 88 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG)
86 size_nc = 1 << nvbo->page_shift; 89 size_nc = 1 << nvbo->page_shift;
87 90
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index bf429cabbaa8..a03db4368696 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -215,6 +215,7 @@ nv84_fence_create(struct nouveau_drm *drm)
215{ 215{
216 struct nvkm_fifo *pfifo = nvxx_fifo(&drm->device); 216 struct nvkm_fifo *pfifo = nvxx_fifo(&drm->device);
217 struct nv84_fence_priv *priv; 217 struct nv84_fence_priv *priv;
218 u32 domain;
218 int ret; 219 int ret;
219 220
220 priv = drm->fence = kzalloc(sizeof(*priv), GFP_KERNEL); 221 priv = drm->fence = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -231,10 +232,17 @@ nv84_fence_create(struct nouveau_drm *drm)
231 priv->base.context_base = fence_context_alloc(priv->base.contexts); 232 priv->base.context_base = fence_context_alloc(priv->base.contexts);
232 priv->base.uevent = true; 233 priv->base.uevent = true;
233 234
234 ret = nouveau_bo_new(drm->dev, 16 * priv->base.contexts, 0, 235 /* Use VRAM if there is any ; otherwise fallback to system memory */
235 TTM_PL_FLAG_VRAM, 0, 0, NULL, NULL, &priv->bo); 236 domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
237 /*
238 * fences created in sysmem must be non-cached or we
239 * will lose CPU/GPU coherency!
240 */
241 TTM_PL_FLAG_TT | TTM_PL_FLAG_UNCACHED;
242 ret = nouveau_bo_new(drm->dev, 16 * priv->base.contexts, 0, domain, 0,
243 0, NULL, NULL, &priv->bo);
236 if (ret == 0) { 244 if (ret == 0) {
237 ret = nouveau_bo_pin(priv->bo, TTM_PL_FLAG_VRAM, false); 245 ret = nouveau_bo_pin(priv->bo, domain, false);
238 if (ret == 0) { 246 if (ret == 0) {
239 ret = nouveau_bo_map(priv->bo); 247 ret = nouveau_bo_map(priv->bo);
240 if (ret) 248 if (ret)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
index 6efa8f38ff54..63d8e52f4b22 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -139,9 +139,13 @@ nvkm_devobj_info(struct nvkm_object *object, void *data, u32 size)
139 139
140 args->v0.chipset = device->chipset; 140 args->v0.chipset = device->chipset;
141 args->v0.revision = device->chiprev; 141 args->v0.revision = device->chiprev;
142 if (pfb) args->v0.ram_size = args->v0.ram_user = pfb->ram->size; 142 if (pfb && pfb->ram)
143 else args->v0.ram_size = args->v0.ram_user = 0; 143 args->v0.ram_size = args->v0.ram_user = pfb->ram->size;
144 if (imem) args->v0.ram_user = args->v0.ram_user - imem->reserved; 144 else
145 args->v0.ram_size = args->v0.ram_user = 0;
146 if (imem && args->v0.ram_size > 0)
147 args->v0.ram_user = args->v0.ram_user - imem->reserved;
148
145 return 0; 149 return 0;
146} 150}
147 151
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
index b24a9cc04b73..39a83d82e0cd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -184,7 +184,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
184 nv_debug(clk, "setting performance state %d\n", pstatei); 184 nv_debug(clk, "setting performance state %d\n", pstatei);
185 clk->pstate = pstatei; 185 clk->pstate = pstatei;
186 186
187 if (pfb->ram->calc) { 187 if (pfb->ram && pfb->ram->calc) {
188 int khz = pstate->base.domain[nv_clk_src_mem]; 188 int khz = pstate->base.domain[nv_clk_src_mem];
189 do { 189 do {
190 ret = pfb->ram->calc(pfb, khz); 190 ret = pfb->ram->calc(pfb, khz);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
index 16589fa613cd..61fde43dab71 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
@@ -55,9 +55,11 @@ _nvkm_fb_fini(struct nvkm_object *object, bool suspend)
55 struct nvkm_fb *pfb = (void *)object; 55 struct nvkm_fb *pfb = (void *)object;
56 int ret; 56 int ret;
57 57
58 ret = nv_ofuncs(pfb->ram)->fini(nv_object(pfb->ram), suspend); 58 if (pfb->ram) {
59 if (ret && suspend) 59 ret = nv_ofuncs(pfb->ram)->fini(nv_object(pfb->ram), suspend);
60 return ret; 60 if (ret && suspend)
61 return ret;
62 }
61 63
62 return nvkm_subdev_fini(&pfb->base, suspend); 64 return nvkm_subdev_fini(&pfb->base, suspend);
63} 65}
@@ -72,9 +74,11 @@ _nvkm_fb_init(struct nvkm_object *object)
72 if (ret) 74 if (ret)
73 return ret; 75 return ret;
74 76
75 ret = nv_ofuncs(pfb->ram)->init(nv_object(pfb->ram)); 77 if (pfb->ram) {
76 if (ret) 78 ret = nv_ofuncs(pfb->ram)->init(nv_object(pfb->ram));
77 return ret; 79 if (ret)
80 return ret;
81 }
78 82
79 for (i = 0; i < pfb->tile.regions; i++) 83 for (i = 0; i < pfb->tile.regions; i++)
80 pfb->tile.prog(pfb, i, &pfb->tile.region[i]); 84 pfb->tile.prog(pfb, i, &pfb->tile.region[i]);
@@ -91,9 +95,12 @@ _nvkm_fb_dtor(struct nvkm_object *object)
91 for (i = 0; i < pfb->tile.regions; i++) 95 for (i = 0; i < pfb->tile.regions; i++)
92 pfb->tile.fini(pfb, i, &pfb->tile.region[i]); 96 pfb->tile.fini(pfb, i, &pfb->tile.region[i]);
93 nvkm_mm_fini(&pfb->tags); 97 nvkm_mm_fini(&pfb->tags);
94 nvkm_mm_fini(&pfb->vram);
95 98
96 nvkm_object_ref(NULL, (struct nvkm_object **)&pfb->ram); 99 if (pfb->ram) {
100 nvkm_mm_fini(&pfb->vram);
101 nvkm_object_ref(NULL, (struct nvkm_object **)&pfb->ram);
102 }
103
97 nvkm_subdev_destroy(&pfb->base); 104 nvkm_subdev_destroy(&pfb->base);
98} 105}
99 106
@@ -127,6 +134,9 @@ nvkm_fb_create_(struct nvkm_object *parent, struct nvkm_object *engine,
127 134
128 pfb->memtype_valid = impl->memtype; 135 pfb->memtype_valid = impl->memtype;
129 136
137 if (!impl->ram)
138 return 0;
139
130 ret = nvkm_object_ctor(nv_object(pfb), NULL, impl->ram, NULL, 0, &ram); 140 ret = nvkm_object_ctor(nv_object(pfb), NULL, impl->ram, NULL, 0, &ram);
131 if (ret) { 141 if (ret) {
132 nv_fatal(pfb, "error detecting memory configuration!!\n"); 142 nv_fatal(pfb, "error detecting memory configuration!!\n");
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
index 8e7cc6200d60..7fb5ea0314cb 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
@@ -136,7 +136,8 @@ gf100_ltc_dtor(struct nvkm_object *object)
136 struct nvkm_ltc_priv *priv = (void *)object; 136 struct nvkm_ltc_priv *priv = (void *)object;
137 137
138 nvkm_mm_fini(&priv->tags); 138 nvkm_mm_fini(&priv->tags);
139 nvkm_mm_free(&pfb->vram, &priv->tag_ram); 139 if (pfb->ram)
140 nvkm_mm_free(&pfb->vram, &priv->tag_ram);
140 141
141 nvkm_ltc_destroy(priv); 142 nvkm_ltc_destroy(priv);
142} 143}
@@ -149,6 +150,12 @@ gf100_ltc_init_tag_ram(struct nvkm_fb *pfb, struct nvkm_ltc_priv *priv)
149 u32 tag_size, tag_margin, tag_align; 150 u32 tag_size, tag_margin, tag_align;
150 int ret; 151 int ret;
151 152
153 /* No VRAM, no tags for now. */
154 if (!pfb->ram) {
155 priv->num_tags = 0;
156 goto mm_init;
157 }
158
152 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */ 159 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */
153 priv->num_tags = (pfb->ram->size >> 17) / 4; 160 priv->num_tags = (pfb->ram->size >> 17) / 4;
154 if (priv->num_tags > (1 << 17)) 161 if (priv->num_tags > (1 << 17))
@@ -183,6 +190,7 @@ gf100_ltc_init_tag_ram(struct nvkm_fb *pfb, struct nvkm_ltc_priv *priv)
183 priv->tag_base = tag_base; 190 priv->tag_base = tag_base;
184 } 191 }
185 192
193mm_init:
186 ret = nvkm_mm_init(&priv->tags, 0, priv->num_tags, 1); 194 ret = nvkm_mm_init(&priv->tags, 0, priv->num_tags, 1);
187 return ret; 195 return ret;
188} 196}