Commit f869ef88 authored by Ben Skeggs's avatar Ben Skeggs

drm/nv50: implement BAR1/BAR3 management on top of new VM code

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent a11c3198
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "nouveau_drm.h" #include "nouveau_drm.h"
#include "nouveau_drv.h" #include "nouveau_drv.h"
#include "nouveau_dma.h" #include "nouveau_dma.h"
#include "nouveau_mm.h"
#include "nouveau_vm.h"
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -386,10 +388,13 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, ...@@ -386,10 +388,13 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
man->default_caching = TTM_PL_FLAG_CACHED; man->default_caching = TTM_PL_FLAG_CACHED;
break; break;
case TTM_PL_VRAM: case TTM_PL_VRAM:
if (dev_priv->card_type == NV_50) if (dev_priv->card_type == NV_50) {
man->func = &nouveau_vram_manager; man->func = &nouveau_vram_manager;
else man->io_reserve_fastpath = false;
man->use_io_reserve_lru = true;
} else {
man->func = &ttm_bo_manager_func; man->func = &ttm_bo_manager_func;
}
man->flags = TTM_MEMTYPE_FLAG_FIXED | man->flags = TTM_MEMTYPE_FLAG_FIXED |
TTM_MEMTYPE_FLAG_MAPPABLE; TTM_MEMTYPE_FLAG_MAPPABLE;
man->available_caching = TTM_PL_FLAG_UNCACHED | man->available_caching = TTM_PL_FLAG_UNCACHED |
...@@ -858,6 +863,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) ...@@ -858,6 +863,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
struct drm_nouveau_private *dev_priv = nouveau_bdev(bdev); struct drm_nouveau_private *dev_priv = nouveau_bdev(bdev);
struct drm_device *dev = dev_priv->dev; struct drm_device *dev = dev_priv->dev;
int ret;
mem->bus.addr = NULL; mem->bus.addr = NULL;
mem->bus.offset = 0; mem->bus.offset = 0;
...@@ -880,10 +886,33 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) ...@@ -880,10 +886,33 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
#endif #endif
break; break;
case TTM_PL_VRAM: case TTM_PL_VRAM:
{
struct nouveau_vram *vram = mem->mm_node;
if (!dev_priv->bar1_vm) {
mem->bus.offset = mem->start << PAGE_SHIFT; mem->bus.offset = mem->start << PAGE_SHIFT;
mem->bus.base = pci_resource_start(dev->pdev, 1); mem->bus.base = pci_resource_start(dev->pdev, 1);
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
break; break;
}
ret = nouveau_vm_get(dev_priv->bar1_vm, mem->bus.size, 12,
NV_MEM_ACCESS_RW, &vram->bar_vma);
if (ret)
return ret;
nouveau_vm_map(&vram->bar_vma, vram);
if (ret) {
nouveau_vm_put(&vram->bar_vma);
return ret;
}
mem->bus.offset = vram->bar_vma.offset;
mem->bus.offset -= 0x0020000000ULL;
mem->bus.base = pci_resource_start(dev->pdev, 1);
mem->bus.is_iomem = true;
}
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -893,6 +922,17 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) ...@@ -893,6 +922,17 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
static void static void
nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
{ {
struct drm_nouveau_private *dev_priv = nouveau_bdev(bdev);
struct nouveau_vram *vram = mem->mm_node;
if (!dev_priv->bar1_vm || mem->mem_type != TTM_PL_VRAM)
return;
if (!vram->bar_vma.node)
return;
nouveau_vm_unmap(&vram->bar_vma);
nouveau_vm_put(&vram->bar_vma);
} }
static int static int
......
...@@ -55,7 +55,10 @@ struct nouveau_fpriv { ...@@ -55,7 +55,10 @@ struct nouveau_fpriv {
#include "nouveau_reg.h" #include "nouveau_reg.h"
#include "nouveau_bios.h" #include "nouveau_bios.h"
#include "nouveau_util.h" #include "nouveau_util.h"
struct nouveau_grctx; struct nouveau_grctx;
struct nouveau_vram;
#include "nouveau_vm.h"
#define MAX_NUM_DCB_ENTRIES 16 #define MAX_NUM_DCB_ENTRIES 16
...@@ -69,6 +72,8 @@ struct nouveau_grctx; ...@@ -69,6 +72,8 @@ struct nouveau_grctx;
struct nouveau_vram { struct nouveau_vram {
struct drm_device *dev; struct drm_device *dev;
struct nouveau_vma bar_vma;
struct list_head regions; struct list_head regions;
u32 memtype; u32 memtype;
u64 offset; u64 offset;
...@@ -244,6 +249,7 @@ struct nouveau_channel { ...@@ -244,6 +249,7 @@ struct nouveau_channel {
void *pgraph_ctx; void *pgraph_ctx;
/* NV50 VM */ /* NV50 VM */
struct nouveau_vm *vm;
struct nouveau_gpuobj *vm_pd; struct nouveau_gpuobj *vm_pd;
struct nouveau_gpuobj *vm_gart_pt; struct nouveau_gpuobj *vm_gart_pt;
struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR]; struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR];
...@@ -701,6 +707,10 @@ struct drm_nouveau_private { ...@@ -701,6 +707,10 @@ struct drm_nouveau_private {
uint64_t fb_aper_free; uint64_t fb_aper_free;
int fb_mtrr; int fb_mtrr;
/* BAR control (NV50-) */
struct nouveau_vm *bar1_vm;
struct nouveau_vm *bar3_vm;
/* G8x/G9x virtual address space */ /* G8x/G9x virtual address space */
uint64_t vm_gart_base; uint64_t vm_gart_base;
uint64_t vm_gart_size; uint64_t vm_gart_size;
......
This diff is collapsed.
...@@ -151,7 +151,6 @@ nv50_vm_flush(struct nouveau_vm *vm) ...@@ -151,7 +151,6 @@ nv50_vm_flush(struct nouveau_vm *vm)
struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem; struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem;
pinstmem->flush(vm->dev); pinstmem->flush(vm->dev);
nv50_vm_flush_engine(vm->dev, 6); nv50_vm_flush_engine(vm->dev, 6);
} }
......
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