Commit 7dc6a446 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau: improve selection of GPU page size

Enables the use of Pascal's 2MiB pages for larger buffers.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent d7722134
...@@ -194,9 +194,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align, ...@@ -194,9 +194,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,
struct nouveau_drm *drm = cli->drm; struct nouveau_drm *drm = cli->drm;
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
struct nvif_mmu *mmu = &cli->mmu; struct nvif_mmu *mmu = &cli->mmu;
struct nvif_vmm *vmm = &cli->vmm.vmm;
size_t acc_size; size_t acc_size;
int ret;
int type = ttm_bo_type_device; int type = ttm_bo_type_device;
int ret, i, pi = -1;
if (!size) { if (!size) {
NV_WARN(drm, "skipped size %016llx\n", size); NV_WARN(drm, "skipped size %016llx\n", size);
...@@ -249,16 +250,43 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align, ...@@ -249,16 +250,43 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,
nvbo->mode = tile_mode; nvbo->mode = tile_mode;
nvbo->contig = !(tile_flags & NOUVEAU_GEM_TILE_NONCONTIG); nvbo->contig = !(tile_flags & NOUVEAU_GEM_TILE_NONCONTIG);
nvbo->page = 12; /* Determine the desirable target GPU page size for the buffer. */
if (drm->client.vm) { for (i = 0; i < vmm->page_nr; i++) {
if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024) /* Because we cannot currently allow VMM maps to fail
nvbo->page = drm->client.vm->mmu->lpg_shift; * during buffer migration, we need to determine page
else { * size for the buffer up-front, and pre-allocate its
if (cli->device.info.family >= NV_DEVICE_INFO_V0_FERMI) * page tables.
*
* Skip page sizes that can't support needed domains.
*/
if (cli->device.info.family > NV_DEVICE_INFO_V0_CURIE &&
(flags & TTM_PL_FLAG_VRAM) && !vmm->page[i].vram)
continue;
if ((flags & TTM_PL_FLAG_TT ) && !vmm->page[i].host)
continue;
/* Select this page size if it's the first that supports
* the potential memory domains, or when it's compatible
* with the requested compression settings.
*/
if (pi < 0 || !nvbo->comp || vmm->page[i].comp)
pi = i;
/* Stop once the buffer is larger than the current page size. */
if (size >= 1ULL << vmm->page[i].shift)
break;
}
if (WARN_ON(pi < 0))
return -EINVAL;
/* Disable compression if suitable settings couldn't be found. */
if (nvbo->comp && !vmm->page[pi].comp) {
if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
nvbo->kind = mmu->kind[nvbo->kind]; nvbo->kind = mmu->kind[nvbo->kind];
nvbo->comp = 0; nvbo->comp = 0;
} }
} nvbo->page = vmm->page[pi].shift;
nouveau_bo_fixup_align(nvbo, flags, &align, &size); nouveau_bo_fixup_align(nvbo, flags, &align, &size);
nvbo->bo.mem.num_pages = size >> PAGE_SHIFT; nvbo->bo.mem.num_pages = size >> 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