Skip to contentSkip to conversation

drm/radeon: delay virtual address destruction to bo destruction

PATCH In review [email protected] 2 participants 4 messages Aug 8, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: delay virtual address destruction to bo destruction

From: Jerome Glisse <[email protected]>

Use the ttm bo delayed destruction queue so that we don't block userspace when destroying bo. The virtual address destruction will happen at same time as the real bo destruction when everythings using the bo is done.

---
 drivers/gpu/drm/radeon/radeon_drv.c |    2 +-
 drivers/gpu/drm/radeon/radeon_gem.c |   20 --------------------
 2 files changed, 1 insertion(+), 21 deletions(-)
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
index dcea6f0..38443e7 100644
@@ -368,7 +368,7 @@ static struct drm_driver kms_driver = {
 	.gem_init_object = radeon_gem_object_init,
 	.gem_free_object = radeon_gem_object_free,
 	.gem_open_object = radeon_gem_object_open,
-	.gem_close_object = radeon_gem_object_close,
+	.gem_close_object = NULL,
 	.dma_ioctl = radeon_dma_ioctl_kms,
 	.dumb_create = radeon_mode_dumb_create,
 	.dumb_map_offset = radeon_mode_dumb_mmap,
drivers/gpu/drm/radeon/radeon_gem.c +0 -20
index 1b57b00..b5835c8 100644
@@ -127,26 +127,6 @@ int radeon_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_pri
 	return 0;
 }
 
-void radeon_gem_object_close(struct drm_gem_object *obj,
-			     struct drm_file *file_priv)
-{
-	struct radeon_bo *rbo = gem_to_radeon_bo(obj);
-	struct radeon_device *rdev = rbo->rdev;
-	struct radeon_fpriv *fpriv = file_priv->driver_priv;
-	struct radeon_vm *vm = &fpriv->vm;
-
-	if (rdev->family < CHIP_CAYMAN) {
-		return;
-	}
-
-	if (radeon_bo_reserve(rbo, false)) {
-		dev_err(rdev->dev, "leaking bo va because we fail to reserve bo\n");
-		return;
-	}
-	radeon_vm_bo_rmv(rdev, vm, rbo);
-	radeon_bo_unreserve(rbo);
-}
-
 static int radeon_gem_handle_lockup(struct radeon_device *rdev, int r)
 {
 	if (r == -EDEADLK) {
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 6 lines · On Wed, Aug 8, 2012 at 10:36 AM, <[email protected]> wrote:

From: Jerome Glisse <[email protected]>

Use the ttm bo delayed destruction queue so that we don't block userspace when destroying bo. The virtual address destruction will happen at same time as the real bo destruction when everythings using the bo is done.

Haven't had time to test this extensively. Probably won't have time to seriously test this before next week. This is mostly an optimization to avoid stalling userspace when destroying bo.

Cheers,
Jerome

Quoted 54 lines
---
 drivers/gpu/drm/radeon/radeon_drv.c |    2 +-
 drivers/gpu/drm/radeon/radeon_gem.c |   20 --------------------
 2 files changed, 1 insertion(+), 21 deletions(-)
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
index dcea6f0..38443e7 100644
@@ -368,7 +368,7 @@ static struct drm_driver kms_driver = {
        .gem_init_object = radeon_gem_object_init,
        .gem_free_object = radeon_gem_object_free,
        .gem_open_object = radeon_gem_object_open,
-       .gem_close_object = radeon_gem_object_close,
+       .gem_close_object = NULL,
        .dma_ioctl = radeon_dma_ioctl_kms,
        .dumb_create = radeon_mode_dumb_create,
        .dumb_map_offset = radeon_mode_dumb_mmap,
drivers/gpu/drm/radeon/radeon_gem.c +0 -21
index 1b57b00..b5835c8 100644
@@ -127,26 +127,6 @@ int radeon_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_pri
        return 0;
 }
 
-void radeon_gem_object_close(struct drm_gem_object *obj,
-                            struct drm_file *file_priv)
-{
-       struct radeon_bo *rbo = gem_to_radeon_bo(obj);
-       struct radeon_device *rdev = rbo->rdev;
-       struct radeon_fpriv *fpriv = file_priv->driver_priv;
-       struct radeon_vm *vm = &fpriv->vm;
-
-       if (rdev->family < CHIP_CAYMAN) {
-               return;
-       }
-
-       if (radeon_bo_reserve(rbo, false)) {
-               dev_err(rdev->dev, "leaking bo va because we fail to reserve bo\n");
-               return;
-       }
-       radeon_vm_bo_rmv(rdev, vm, rbo);
-       radeon_bo_unreserve(rbo);
-}
-
 static int radeon_gem_handle_lockup(struct radeon_device *rdev, int r)
 {
        if (r == -EDEADLK) {
--

1.7.10.4

#2 lore raw
In reply to [email protected]
Quoted 6 lines · On Mit, 2012-08-08 at 10:36 -0400, [email protected] wrote:

From: Jerome Glisse <[email protected]>

Use the ttm bo delayed destruction queue so that we don't block userspace when destroying bo. The virtual address destruction will happen at same time as the real bo destruction when everythings using the bo is done.

I'm on the fence about whether it's better to block or not here. If we don't, userspace will still need to defer at least the virtual address space deallocation. It might be easier (and less prone to subtle bugs) to just defer the BO destruction in userspace to avoid blocking here.

Signature · 2 lines
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer
#3 lore raw
Quoted 8 lines · Michel Dänzer
Quoted 6 lines · On Mit, 2012-08-08 at 10:36 -0400, [email protected] wrote:

From: Jerome Glisse <[email protected]>

Use the ttm bo delayed destruction queue so that we don't block userspace when destroying bo. The virtual address destruction will happen at same time as the real bo destruction when everythings using the bo is done.

Quoted 5 lines

I'm on the fence about whether it's better to block or not here. If we don't, userspace will still need to defer at least the virtual address space deallocation. It might be easier (and less prone to subtle bugs) to just defer the BO destruction in userspace to avoid blocking here.

Doesn't mean user space should not do thing properly like using pool of bo or sub allocation. User space might get the wrong impression with that patch. Anyway just proposing it as it might be usefull in some case to not force user space to wait on bo idle when destroying bo.

Cheers,
Jerome