[PATCH] drm/ttm: Pass the buffer object on backend creation

j.glisse at gmail.com j.glisse at gmail.com
Mon Oct 10 13:04:25 PDT 2011


From: Jerome Glisse <jglisse at redhat.com>

In case of multiple page table for GART, driver want to know which
buffer object is being bind/unbind. This allow driver to bind/unbind
buffer object from several different GART.

Signed-off-by: Jerome Glisse <jglisse at redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_bo.c   |    3 ++-
 drivers/gpu/drm/radeon/radeon_ttm.c    |   11 +++++++----
 drivers/gpu/drm/ttm/ttm_bo.c           |    4 ++--
 drivers/gpu/drm/ttm/ttm_tt.c           |    9 ++++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c |    3 ++-
 include/drm/ttm/ttm_bo_driver.h        |    5 ++++-
 6 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 890d50e..9f65371 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -344,7 +344,8 @@ nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val)
 }
 
 static struct ttm_backend *
-nouveau_bo_create_ttm_backend_entry(struct ttm_bo_device *bdev)
+nouveau_bo_create_ttm_backend_entry(struct ttm_bo_device *bdev,
+				    struct ttm_buffer_object *bo)
 {
 	struct drm_nouveau_private *dev_priv = nouveau_bdev(bdev);
 	struct drm_device *dev = dev_priv->dev;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 0b5468b..0bad266 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -114,10 +114,12 @@ static void radeon_ttm_global_fini(struct radeon_device *rdev)
 	}
 }
 
-struct ttm_backend *radeon_ttm_backend_create(struct radeon_device *rdev);
+struct ttm_backend *radeon_ttm_backend_create(struct radeon_device *rdev,
+					      struct ttm_buffer_object *bo);
 
 static struct ttm_backend*
-radeon_create_ttm_backend_entry(struct ttm_bo_device *bdev)
+radeon_create_ttm_backend_entry(struct ttm_bo_device *bdev,
+				struct ttm_buffer_object *bo)
 {
 	struct radeon_device *rdev;
 
@@ -128,7 +130,7 @@ radeon_create_ttm_backend_entry(struct ttm_bo_device *bdev)
 	} else
 #endif
 	{
-		return radeon_ttm_backend_create(rdev);
+		return radeon_ttm_backend_create(rdev, bo);
 	}
 }
 
@@ -778,7 +780,8 @@ static struct ttm_backend_func radeon_backend_func = {
 	.destroy = &radeon_ttm_backend_destroy,
 };
 
-struct ttm_backend *radeon_ttm_backend_create(struct radeon_device *rdev)
+struct ttm_backend *radeon_ttm_backend_create(struct radeon_device *rdev,
+					      struct ttm_buffer_object *bo)
 {
 	struct radeon_ttm_backend *gtt;
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index ef06194..fe957e7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -337,13 +337,13 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
 		if (zero_alloc)
 			page_flags |= TTM_PAGE_FLAG_ZERO_ALLOC;
 	case ttm_bo_type_kernel:
-		bo->ttm = ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT,
+		bo->ttm = ttm_tt_create(bdev, bo, bo->num_pages << PAGE_SHIFT,
 					page_flags, glob->dummy_read_page);
 		if (unlikely(bo->ttm == NULL))
 			ret = -ENOMEM;
 		break;
 	case ttm_bo_type_user:
-		bo->ttm = ttm_tt_create(bdev, bo->num_pages << PAGE_SHIFT,
+		bo->ttm = ttm_tt_create(bdev, bo, bo->num_pages << PAGE_SHIFT,
 					page_flags | TTM_PAGE_FLAG_USER,
 					glob->dummy_read_page);
 		if (unlikely(bo->ttm == NULL)) {
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 58c271e..202e16e 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -379,8 +379,11 @@ int ttm_tt_set_user(struct ttm_tt *ttm,
 	return 0;
 }
 
-struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
-			     uint32_t page_flags, struct page *dummy_read_page)
+struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev,
+			     struct ttm_buffer_object *bo,
+			     unsigned long size,
+			     uint32_t page_flags,
+			     struct page *dummy_read_page)
 {
 	struct ttm_bo_driver *bo_driver = bdev->driver;
 	struct ttm_tt *ttm;
@@ -407,7 +410,7 @@ struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
 		printk(KERN_ERR TTM_PFX "Failed allocating page table\n");
 		return NULL;
 	}
-	ttm->be = bo_driver->create_ttm_backend_entry(bdev);
+	ttm->be = bo_driver->create_ttm_backend_entry(bdev, bo);
 	if (!ttm->be) {
 		ttm_tt_destroy(ttm);
 		printk(KERN_ERR TTM_PFX "Failed creating ttm backend entry\n");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
index 87e43e0..5376285 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
@@ -159,7 +159,8 @@ static struct ttm_backend_func vmw_ttm_func = {
 	.destroy = vmw_ttm_destroy,
 };
 
-struct ttm_backend *vmw_ttm_backend_init(struct ttm_bo_device *bdev)
+struct ttm_backend *vmw_ttm_backend_init(struct ttm_bo_device *bdev,
+					 struct ttm_buffer_object *bo)
 {
 	struct vmw_ttm_backend *vmw_be;
 
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 94eb143..256a8ae 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -354,12 +354,14 @@ struct ttm_bo_driver {
 	 * struct ttm_bo_driver member create_ttm_backend_entry
 	 *
 	 * @bdev: The buffer object device.
+	 * @bo: The buffer object for which this backend is created
 	 *
 	 * Create a driver specific struct ttm_backend.
 	 */
 
 	struct ttm_backend *(*create_ttm_backend_entry)
-	 (struct ttm_bo_device *bdev);
+						(struct ttm_bo_device *bdev,
+						 struct ttm_buffer_object *bo);
 
 	/**
 	 * struct ttm_bo_driver member invalidate_caches
@@ -613,6 +615,7 @@ ttm_flag_masked(uint32_t *old, uint32_t new, uint32_t mask)
  * NULL: Out of memory.
  */
 extern struct ttm_tt *ttm_tt_create(struct ttm_bo_device *bdev,
+				    struct ttm_buffer_object *bo,
 				    unsigned long size,
 				    uint32_t page_flags,
 				    struct page *dummy_read_page);
-- 
1.7.1



More information about the dri-devel mailing list