Commit f91bac5b authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau: store bo's page size in nouveau_bo

Was previously assuming a page size of 4KiB unless a VMA was present to
override it.  Eventually, a buffer won't necessarily have a VMA at all at
some stages of its life, so we need to store this info elsewhere.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 111af5c1
...@@ -58,7 +58,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo) ...@@ -58,7 +58,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
static void static void
nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags, nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags,
int *align, int *size, int *page_shift) int *align, int *size)
{ {
struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev); struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev);
...@@ -82,17 +82,8 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags, ...@@ -82,17 +82,8 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags,
} }
} }
} else { } else {
if (likely(dev_priv->chan_vm)) { *size = roundup(*size, (1 << nvbo->page_shift));
if (!(flags & TTM_PL_FLAG_TT) && *size > 256 * 1024) *align = max((1 << nvbo->page_shift), *align);
*page_shift = dev_priv->chan_vm->lpg_shift;
else
*page_shift = dev_priv->chan_vm->spg_shift;
} else {
*page_shift = 12;
}
*size = roundup(*size, (1 << *page_shift));
*align = max((1 << *page_shift), *align);
} }
*size = roundup(*size, PAGE_SIZE); *size = roundup(*size, PAGE_SIZE);
...@@ -105,7 +96,7 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan, ...@@ -105,7 +96,7 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
int ret = 0, page_shift = 0; int ret;
nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL); nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
if (!nvbo) if (!nvbo)
...@@ -116,11 +107,17 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan, ...@@ -116,11 +107,17 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
nvbo->tile_flags = tile_flags; nvbo->tile_flags = tile_flags;
nvbo->bo.bdev = &dev_priv->ttm.bdev; nvbo->bo.bdev = &dev_priv->ttm.bdev;
nouveau_bo_fixup_align(nvbo, flags, &align, &size, &page_shift); nvbo->page_shift = 12;
if (dev_priv->bar1_vm) {
if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024)
nvbo->page_shift = dev_priv->bar1_vm->lpg_shift;
}
nouveau_bo_fixup_align(nvbo, flags, &align, &size);
align >>= PAGE_SHIFT; align >>= PAGE_SHIFT;
if (dev_priv->chan_vm) { if (dev_priv->chan_vm) {
ret = nouveau_vm_get(dev_priv->chan_vm, size, page_shift, ret = nouveau_vm_get(dev_priv->chan_vm, size, nvbo->page_shift,
NV_MEM_ACCESS_RW, &nvbo->vma); NV_MEM_ACCESS_RW, &nvbo->vma);
if (ret) { if (ret) {
kfree(nvbo); kfree(nvbo);
......
...@@ -116,6 +116,7 @@ struct nouveau_bo { ...@@ -116,6 +116,7 @@ struct nouveau_bo {
struct nouveau_channel *channel; struct nouveau_channel *channel;
struct nouveau_vma vma; struct nouveau_vma vma;
unsigned page_shift;
uint32_t tile_mode; uint32_t tile_mode;
uint32_t tile_flags; uint32_t tile_flags;
......
...@@ -794,7 +794,7 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, ...@@ -794,7 +794,7 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
int ret; int ret;
if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG) if (nvbo->tile_flags & NOUVEAU_GEM_TILE_NONCONTIG)
size_nc = 1 << nvbo->vma.node->type; size_nc = 1 << nvbo->page_shift;
ret = vram->get(dev, mem->num_pages << PAGE_SHIFT, ret = vram->get(dev, mem->num_pages << PAGE_SHIFT,
mem->page_alignment << PAGE_SHIFT, size_nc, mem->page_alignment << PAGE_SHIFT, size_nc,
...@@ -804,9 +804,7 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, ...@@ -804,9 +804,7 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
return (ret == -ENOSPC) ? 0 : ret; return (ret == -ENOSPC) ? 0 : ret;
} }
node->page_shift = 12; node->page_shift = nvbo->page_shift;
if (nvbo->vma.node)
node->page_shift = nvbo->vma.node->type;
mem->mm_node = node; mem->mm_node = node;
mem->start = node->offset >> PAGE_SHIFT; mem->start = node->offset >> PAGE_SHIFT;
......
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