Skip to contentSkip to conversation

drm/radeon: Only flush HDP cache from idle ioctl if BO is in VRAM

PATCH Applied Michel Dänzer 4 participants 6 messages Aug 1, 2014 – Aug 5, 2014

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

PATCH 1/1 drm/radeon: Only flush HDP cache from idle ioctl if BO is in VRAM

From: Michel Dänzer <[email protected]>

The HDP cache only applies to CPU access to VRAM.

---
 drivers/gpu/drm/radeon/radeon_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +4 -2
index a350cf9..8f2cb58 100644
@@ -359,15 +359,17 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
 	struct drm_gem_object *gobj;
 	struct radeon_bo *robj;
 	int r;
+	uint32_t cur_placement = 0;
 
 	gobj = drm_gem_object_lookup(dev, filp, args->handle);
 	if (gobj == NULL) {
 		return -ENOENT;
 	}
 	robj = gem_to_radeon_bo(gobj);
-	r = radeon_bo_wait(robj, NULL, false);
+	r = radeon_bo_wait(robj, &cur_placement, false);
 	/* Flush HDP cache via MMIO if necessary */
-	if (rdev->asic->mmio_hdp_flush)
+	if (rdev->asic->mmio_hdp_flush &&
+	    radeon_mem_type_to_domain(cur_placement) == RADEON_GEM_DOMAIN_VRAM)
 		robj->rdev->asic->mmio_hdp_flush(rdev);
 	drm_gem_object_unreference_unlocked(gobj);
 	r = radeon_gem_handle_lockup(rdev, r);
Signature · 6 lines
2.0.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Am 01.08.2014 um 10:22 schrieb Michel Dänzer:

Quoted 5 lines

From: Michel Dänzer <[email protected]>

The HDP cache only applies to CPU access to VRAM.

Wanted to suggest the same thing already, looks like a valid optimization to me.

Patch is Reviewed-by: Christian König <[email protected]>

Quoted 18 lines
---
  drivers/gpu/drm/radeon/radeon_gem.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -0
index a350cf9..8f2cb58 100644
@@ -359,15 +359,17 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
  	struct drm_gem_object *gobj;
  	struct radeon_bo *robj;
  	int r;
+	uint32_t cur_placement = 0;
 
  	gobj = drm_gem_object_lookup(dev, filp, args->handle);
  	if (gobj == NULL) {
  		return -ENOENT;
  	}

drivers/gpu/drm/radeon/radeon_gem.c int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, · line 375

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_gem.c +3 -2
  	robj = gem_to_radeon_bo(gobj);
-	r = radeon_bo_wait(robj, NULL, false);
+	r = radeon_bo_wait(robj, &cur_placement, false);
  	/* Flush HDP cache via MMIO if necessary */
-	if (rdev->asic->mmio_hdp_flush)
+	if (rdev->asic->mmio_hdp_flush &&
+	    radeon_mem_type_to_domain(cur_placement) == RADEON_GEM_DOMAIN_VRAM)
  		robj->rdev->asic->mmio_hdp_flush(rdev);
  	drm_gem_object_unreference_unlocked(gobj);
  	r = radeon_gem_handle_lockup(rdev, r);

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Applied
#2 lore raw
In reply to Michel Dänzer
Quoted 5 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

The HDP cache only applies to CPU access to VRAM.

Applied to my 3.17 branch.

Thanks!

Quoted 31 lines
---
 drivers/gpu/drm/radeon/radeon_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +4 -3
index a350cf9..8f2cb58 100644
@@ -359,15 +359,17 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
        struct drm_gem_object *gobj;
        struct radeon_bo *robj;
        int r;
+       uint32_t cur_placement = 0;
 
        gobj = drm_gem_object_lookup(dev, filp, args->handle);
        if (gobj == NULL) {
                return -ENOENT;
        }
        robj = gem_to_radeon_bo(gobj);
-       r = radeon_bo_wait(robj, NULL, false);
+       r = radeon_bo_wait(robj, &cur_placement, false);
        /* Flush HDP cache via MMIO if necessary */
-       if (rdev->asic->mmio_hdp_flush)
+       if (rdev->asic->mmio_hdp_flush &&
+           radeon_mem_type_to_domain(cur_placement) == RADEON_GEM_DOMAIN_VRAM)
                robj->rdev->asic->mmio_hdp_flush(rdev);
        drm_gem_object_unreference_unlocked(gobj);
        r = radeon_gem_handle_lockup(rdev, r);
--

2.0.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Michel Dänzer

I'm afraid this won't always work and it can be a source of bugs.

Userspace doesn't have to call GEM_WAIT_IDLE before a CPU access to a VRAM buffer. For example, consider a wait-idle request with a non-zero timeout, which is implemented as a loop which calls GEM_BUSY. Also, userspace can use fences (alright they are backed by 1-page-sized VRAM buffers at the moment) and it may use real fences in the future which are not tied to a buffer object.

If the HDP flush isn't allowed in userspace IBs, I think we will have to expose it as an ioctl and call it explicitly from userspace.

Marek

Quoted 36 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

The HDP cache only applies to CPU access to VRAM.

---
 drivers/gpu/drm/radeon/radeon_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +4 -3
index a350cf9..8f2cb58 100644
@@ -359,15 +359,17 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
        struct drm_gem_object *gobj;
        struct radeon_bo *robj;
        int r;
+       uint32_t cur_placement = 0;
 
        gobj = drm_gem_object_lookup(dev, filp, args->handle);
        if (gobj == NULL) {
                return -ENOENT;
        }
        robj = gem_to_radeon_bo(gobj);
-       r = radeon_bo_wait(robj, NULL, false);
+       r = radeon_bo_wait(robj, &cur_placement, false);
        /* Flush HDP cache via MMIO if necessary */
-       if (rdev->asic->mmio_hdp_flush)
+       if (rdev->asic->mmio_hdp_flush &&
+           radeon_mem_type_to_domain(cur_placement) == RADEON_GEM_DOMAIN_VRAM)
                robj->rdev->asic->mmio_hdp_flush(rdev);
        drm_gem_object_unreference_unlocked(gobj);
        r = radeon_gem_handle_lockup(rdev, r);
--

2.0.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 11 lines · Marek Olšák

I'm afraid this won't always work and it can be a source of bugs.

Userspace doesn't have to call GEM_WAIT_IDLE before a CPU access to a VRAM buffer. For example, consider a wait-idle request with a non-zero timeout, which is implemented as a loop which calls GEM_BUSY. Also, userspace can use fences (alright they are backed by 1-page-sized VRAM buffers at the moment) and it may use real fences in the future which are not tied to a buffer object.

If the HDP flush isn't allowed in userspace IBs, I think we will have to expose it as an ioctl and call it explicitly from userspace.

I understand your concerns, but my patch doesn't change anything wrt them, does it?

Signature · 6 lines
Earthling Michel Dänzer            |                  http://www.amd.com
Libre software enthusiast          |                Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

No, it doesn't.

Marek

Quoted 13 lines · Michel Dänzer
Quoted 11 lines · Marek Olšák

I'm afraid this won't always work and it can be a source of bugs.

Userspace doesn't have to call GEM_WAIT_IDLE before a CPU access to a VRAM buffer. For example, consider a wait-idle request with a non-zero timeout, which is implemented as a loop which calls GEM_BUSY. Also, userspace can use fences (alright they are backed by 1-page-sized VRAM buffers at the moment) and it may use real fences in the future which are not tied to a buffer object.

If the HDP flush isn't allowed in userspace IBs, I think we will have to expose it as an ioctl and call it explicitly from userspace.

Quoted 7 lines

I understand your concerns, but my patch doesn't change anything wrt them, does it?

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel