Skip to contentSkip to conversation

drm/v3d: Fix BO stats accounting for dma-buf-imported buffers.

PATCH In review Eric Anholt 2 participants 3 messages Feb 7, 2019 – Feb 12, 2019

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

PATCH 1/1 drm/v3d: Fix BO stats accounting for dma-buf-imported buffers.

We always decrement at GEM free, so make sure we increment at GEM creation for dma-bufs.

---
 drivers/gpu/drm/v3d/v3d_bo.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/v3d/v3d_bo.c +6 -0
index a08766d39eab..b1766f096c4b 100644
@@ -282,6 +282,7 @@ v3d_prime_import_sg_table(struct drm_device *dev,
 			  struct dma_buf_attachment *attach,
 			  struct sg_table *sgt)
 {
+	struct v3d_dev *v3d = to_v3d_dev(dev);
 	struct drm_gem_object *obj;
 	struct v3d_bo *bo;
 
@@ -296,6 +297,11 @@ v3d_prime_import_sg_table(struct drm_device *dev,
 	obj->import_attach = attach;
 	v3d_bo_get_pages(bo);
 
+	mutex_lock(&v3d->bo_lock);
+	v3d->bo_stats.num_allocated++;
+	v3d->bo_stats.pages_allocated += obj->size >> PAGE_SHIFT;
+	mutex_unlock(&v3d->bo_lock);
+
 	v3d_mmu_insert_ptes(bo);
 
 	return obj;
Signature · 6 lines
2.20.0.rc1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 2 lines · Eric Anholt

We always decrement at GEM free, so make sure we increment at GEM creation for dma-bufs.

Indeed. Reviewed-by: Daniel Vetter <[email protected]>

Quoted 37 lines
---
 drivers/gpu/drm/v3d/v3d_bo.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/v3d/v3d_bo.c +6 -0
index a08766d39eab..b1766f096c4b 100644
@@ -282,6 +282,7 @@ v3d_prime_import_sg_table(struct drm_device *dev,
 			  struct dma_buf_attachment *attach,
 			  struct sg_table *sgt)
 {
+	struct v3d_dev *v3d = to_v3d_dev(dev);
 	struct drm_gem_object *obj;
 	struct v3d_bo *bo;
 
@@ -296,6 +297,11 @@ v3d_prime_import_sg_table(struct drm_device *dev,
 	obj->import_attach = attach;
 	v3d_bo_get_pages(bo);
 
+	mutex_lock(&v3d->bo_lock);
+	v3d->bo_stats.num_allocated++;
+	v3d->bo_stats.pages_allocated += obj->size >> PAGE_SHIFT;
+	mutex_unlock(&v3d->bo_lock);
+
 	v3d_mmu_insert_ptes(bo);
 
 	return obj;
Signature · 6 lines
2.20.0.rc1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author Applied
#2 lore raw
Quoted 5 lines · Daniel Vetter
Quoted 2 lines · Eric Anholt

We always decrement at GEM free, so make sure we increment at GEM creation for dma-bufs.

Indeed. Reviewed-by: Daniel Vetter <[email protected]>

Merged to drm-misc-next. Thanks!