All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Glisse <jglisse@redhat.com>
To: airlied@gmail.com
Cc: thellstrom@vmware.com, skeggsb@gmail.com,
	Jerome Glisse <jglisse@redhat.com>,
	dri-devel@lists.sf.net
Subject: [PATCH 2/9] drm/radeon/kms: add support for new fault callback V2
Date: Mon, 22 Feb 2010 18:11:31 +0100	[thread overview]
Message-ID: <1266858699-23337-5-git-send-email-jglisse@redhat.com> (raw)
In-Reply-To: <1266858699-23337-4-git-send-email-jglisse@redhat.com>

This add the support for the new fault callback and also the
infrastructure for supporting unmappable VRAM.

V2 validate BO with no_wait = true

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
---
 drivers/gpu/drm/radeon/radeon_ttm.c |   99 ++++++++++++++++++++++++++++++++++-
 1 files changed, 98 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 1157e0f..2ceb5f1 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -434,10 +434,104 @@ static int radeon_bo_move(struct ttm_buffer_object *bo,
 memcpy:
 		r = ttm_bo_move_memcpy(bo, evict, no_wait, new_mem);
 	}
-
 	return r;
 }
 
+static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem, struct ttm_bus_placement *pl)
+{
+	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
+	struct radeon_device *rdev = radeon_get_rdev(bdev);
+
+	pl->offset = mem->mm_node->start << PAGE_SHIFT;
+	pl->size = mem->num_pages << PAGE_SHIFT;
+	pl->base = 0;
+	pl->is_iomem = false;
+	if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
+		return -EINVAL;
+	switch (mem->mem_type) {
+	case TTM_PL_SYSTEM:
+		/* system memory */
+		return 0;
+	case TTM_PL_TT:
+#if __OS_HAS_AGP
+		if (rdev->flags & RADEON_IS_AGP) {
+			/* RADEON_IS_AGP is set only if AGP is active */
+			pl->base = rdev->mc.agp_base;
+			pl->is_iomem = true;
+		}
+#endif
+		return 0;
+	case TTM_PL_VRAM:
+		/* check if it's visible */
+		if ((pl->offset + pl->size) > rdev->mc.visible_vram_size)
+			return -EINVAL;
+		pl->base = rdev->mc.aper_base;
+		pl->is_iomem = true;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static void radeon_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
+{
+	/* hopefully will be usefull soon */
+}
+
+static int radeon_ttm_fault_callback(struct ttm_buffer_object *bo, struct ttm_bus_placement *pl)
+{
+	struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type];
+	struct radeon_bo *rbo;
+	struct radeon_device *rdev;
+	int r;
+
+	pl->offset = bo->mem.mm_node->start << PAGE_SHIFT;
+	pl->size = bo->mem.num_pages << PAGE_SHIFT;
+	pl->base = 0;
+	pl->is_iomem = false;
+	if (!radeon_ttm_bo_is_radeon_bo(bo))
+		/* FIXME should we return 0 ? we don't know about this BO */
+		return -EINVAL;
+	if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
+		return -EINVAL;
+	rbo = container_of(bo, struct radeon_bo, tbo);
+	rdev = rbo->rdev;
+	switch (bo->mem.mem_type) {
+	case TTM_PL_SYSTEM:
+		/* System memory */
+		return 0;
+	case TTM_PL_TT:
+#if __OS_HAS_AGP
+		if (rdev->flags & RADEON_IS_AGP) {
+			/* RADEON_IS_AGP is set only if AGP is active */
+			pl->base = rdev->mc.agp_base;
+			pl->is_iomem = true;
+		}
+#endif
+		return 0;
+	case TTM_PL_VRAM:
+		if ((pl->offset + pl->size) > rdev->mc.visible_vram_size) {
+			/* hurrah the memory is not visible ! */
+			radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM);
+			rbo->placement.lpfn = rdev->mc.visible_vram_size >> PAGE_SHIFT;
+			r = ttm_bo_validate(bo, &rbo->placement, false, true);
+			if (unlikely(r != 0))
+				return r;
+			pl->offset = bo->mem.mm_node->start << PAGE_SHIFT;
+			/* this should not happen */
+			if ((pl->offset + pl->size) > rdev->mc.visible_vram_size)
+				return -EINVAL;
+		}
+		pl->base = rdev->mc.aper_base;
+		pl->is_iomem = true;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static int radeon_sync_obj_wait(void *sync_obj, void *sync_arg,
 				bool lazy, bool interruptible)
 {
@@ -478,6 +572,9 @@ static struct ttm_bo_driver radeon_bo_driver = {
 	.sync_obj_ref = &radeon_sync_obj_ref,
 	.move_notify = &radeon_bo_move_notify,
 	.fault_reserve_notify = &radeon_bo_fault_reserve_notify,
+	.fault_reserve = &radeon_ttm_fault_callback,
+	.io_mem_reserve = &radeon_ttm_io_mem_reserve,
+	.io_mem_free = &radeon_ttm_io_mem_free,
 };
 
 int radeon_ttm_init(struct radeon_device *rdev)
-- 
1.6.6


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

  reply	other threads:[~2010-02-22 17:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-22 17:11 Unmappable VRAM patchset V3 Jerome Glisse
2010-02-22 17:11 ` [PATCH 1/9] drm/ttm: add ttm_fault callback to allow driver to handle bo placement Jerome Glisse
2010-02-22 17:11   ` [PATCH 1/9] drm/ttm: ttm_fault callback to allow driver to handle bo placement V2 Jerome Glisse
2010-02-22 17:11     ` [PATCH 2/9] drm/radeon/kms: add support for new fault callback Jerome Glisse
2010-02-22 17:11       ` Jerome Glisse [this message]
2010-02-22 17:11         ` [PATCH 3/9] drm/nouveau/kms: add support for new TTM " Jerome Glisse
2010-02-22 17:11           ` [PATCH 4/9] drm/vmwgfx: " Jerome Glisse
2010-02-22 17:11             ` [PATCH 5/9] drm/radeon/kms: don't initialize TTM io memory manager field Jerome Glisse
2010-02-22 17:11               ` [PATCH 6/9] drm/nouveau/kms: " Jerome Glisse
2010-02-22 17:11                 ` [PATCH 7/9] drm/vmwgfx: " Jerome Glisse
2010-02-22 17:11                   ` [PATCH 8/9] drm/ttm: remove io_ field from TTM Jerome Glisse
2010-02-22 17:11                     ` [PATCH 8/9] drm/ttm: remove io_ field from TTM V2 Jerome Glisse
2010-02-22 17:11                       ` [PATCH 9/9] drm/radeon/kms: enable use of unmappable VRAM Jerome Glisse
2010-03-17 12:57     ` [PATCH 1/9] drm/ttm: ttm_fault callback to allow driver to handle bo placement V2 Thomas Hellstrom
2010-02-22 17:30 ` Unmappable VRAM patchset V3 Thomas Hellstrom
2010-02-22 19:09   ` Jerome Glisse
     [not found]     ` <4B82E1E4.40909@vmware.com>
2010-02-23  9:59       ` Jerome Glisse
2010-02-23 13:05         ` Thomas Hellstrom
2010-02-24  9:57           ` Jerome Glisse
2010-02-24 12:37             ` Thomas Hellstrom
2010-02-24 15:58               ` Jerome Glisse
2010-02-24 17:04                 ` Thomas Hellstrom
2010-02-25  9:39                   ` Jerome Glisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266858699-23337-5-git-send-email-jglisse@redhat.com \
    --to=jglisse@redhat.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.sf.net \
    --cc=skeggsb@gmail.com \
    --cc=thellstrom@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.