aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-04-09 08:39:25 -0400
committerDave Airlie <airlied@redhat.com>2010-04-20 00:12:34 -0400
commitf32f02fd81f3177cce0c16cc7d210fcc9cad953c (patch)
treeed5b345f68e4c05fdd311cc931f4d5004167adba
parent0a2d50e3a8faaf36cde36920431586090411ea15 (diff)
drm/nouveau/kms: add support for new TTM fault callback V5
This add the support for the new fault callback, does change anything from driver point of view, thought it should allow nouveau to add support for unmappable VRAM. Improvement: store the aperture base in a variable so that we don't call a function to get it on each fault. Patch hasn't been tested on any hw. V2 don't derefence bo->mem.mm_node as it's not NULL only for VRAM or GTT V3 update after io_mem_reserve/io_mem_free callback balancing V4 callback has to ioremap V5 ioremap is done by ttm Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 5a167de895c6..288c2ecd937a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -386,8 +386,7 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
386 break; 386 break;
387 case TTM_PL_VRAM: 387 case TTM_PL_VRAM:
388 man->flags = TTM_MEMTYPE_FLAG_FIXED | 388 man->flags = TTM_MEMTYPE_FLAG_FIXED |
389 TTM_MEMTYPE_FLAG_MAPPABLE | 389 TTM_MEMTYPE_FLAG_MAPPABLE;
390 TTM_MEMTYPE_FLAG_NEEDS_IOREMAP;
391 man->available_caching = TTM_PL_FLAG_UNCACHED | 390 man->available_caching = TTM_PL_FLAG_UNCACHED |
392 TTM_PL_FLAG_WC; 391 TTM_PL_FLAG_WC;
393 man->default_caching = TTM_PL_FLAG_WC; 392 man->default_caching = TTM_PL_FLAG_WC;
@@ -403,8 +402,7 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
403 case TTM_PL_TT: 402 case TTM_PL_TT:
404 switch (dev_priv->gart_info.type) { 403 switch (dev_priv->gart_info.type) {
405 case NOUVEAU_GART_AGP: 404 case NOUVEAU_GART_AGP:
406 man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | 405 man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
407 TTM_MEMTYPE_FLAG_NEEDS_IOREMAP;
408 man->available_caching = TTM_PL_FLAG_UNCACHED; 406 man->available_caching = TTM_PL_FLAG_UNCACHED;
409 man->default_caching = TTM_PL_FLAG_UNCACHED; 407 man->default_caching = TTM_PL_FLAG_UNCACHED;
410 break; 408 break;
@@ -761,6 +759,55 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)
761 return 0; 759 return 0;
762} 760}
763 761
762static int
763nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
764{
765 struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
766 struct drm_nouveau_private *dev_priv = nouveau_bdev(bdev);
767 struct drm_device *dev = dev_priv->dev;
768
769 mem->bus.addr = NULL;
770 mem->bus.offset = 0;
771 mem->bus.size = mem->num_pages << PAGE_SHIFT;
772 mem->bus.base = 0;
773 mem->bus.is_iomem = false;
774 if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
775 return -EINVAL;
776 switch (mem->mem_type) {
777 case TTM_PL_SYSTEM:
778 /* System memory */
779 return 0;
780 case TTM_PL_TT:
781#if __OS_HAS_AGP
782 if (dev_priv->gart_info.type == NOUVEAU_GART_AGP) {
783 mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
784 mem->bus.base = dev_priv->gart_info.aper_base;
785 mem->bus.is_iomem = true;
786 }
787#endif
788 break;
789 case TTM_PL_VRAM:
790 mem->bus.offset = mem->mm_node->start << PAGE_SHIFT;
791 mem->bus.base = drm_get_resource_start(dev, 1);
792 mem->bus.is_iomem = true;
793 break;
794 default:
795 return -EINVAL;
796 }
797 return 0;
798}
799
800static void
801nouveau_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
802{
803}
804
805static int
806nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
807{
808 return 0;
809}
810
764struct ttm_bo_driver nouveau_bo_driver = { 811struct ttm_bo_driver nouveau_bo_driver = {
765 .create_ttm_backend_entry = nouveau_bo_create_ttm_backend_entry, 812 .create_ttm_backend_entry = nouveau_bo_create_ttm_backend_entry,
766 .invalidate_caches = nouveau_bo_invalidate_caches, 813 .invalidate_caches = nouveau_bo_invalidate_caches,
@@ -773,5 +820,8 @@ struct ttm_bo_driver nouveau_bo_driver = {
773 .sync_obj_flush = nouveau_fence_flush, 820 .sync_obj_flush = nouveau_fence_flush,
774 .sync_obj_unref = nouveau_fence_unref, 821 .sync_obj_unref = nouveau_fence_unref,
775 .sync_obj_ref = nouveau_fence_ref, 822 .sync_obj_ref = nouveau_fence_ref,
823 .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify,
824 .io_mem_reserve = &nouveau_ttm_io_mem_reserve,
825 .io_mem_free = &nouveau_ttm_io_mem_free,
776}; 826};
777 827