2019-02-07 23:27:43

by Eric Anholt

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Eric Anholt <[email protected]>
---
drivers/gpu/drm/v3d/v3d_bo.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
index a08766d39eab..b1766f096c4b 100644
--- a/drivers/gpu/drm/v3d/v3d_bo.c
+++ b/drivers/gpu/drm/v3d/v3d_bo.c
@@ -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;
--
2.20.0.rc1



2019-02-07 23:28:34

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH] drm/v3d: Fix BO stats accounting for dma-buf-imported buffers.

On Thu, Feb 07, 2019 at 03:26:13PM -0800, Eric Anholt wrote:
> We always decrement at GEM free, so make sure we increment at GEM
> creation for dma-bufs.

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

>
> Signed-off-by: Eric Anholt <[email protected]>
> ---
> drivers/gpu/drm/v3d/v3d_bo.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
> index a08766d39eab..b1766f096c4b 100644
> --- a/drivers/gpu/drm/v3d/v3d_bo.c
> +++ b/drivers/gpu/drm/v3d/v3d_bo.c
> @@ -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;
> --
> 2.20.0.rc1
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2019-02-12 20:13:00

by Eric Anholt

[permalink] [raw]
Subject: Re: [PATCH] drm/v3d: Fix BO stats accounting for dma-buf-imported buffers.

Daniel Vetter <[email protected]> writes:

> On Thu, Feb 07, 2019 at 03:26:13PM -0800, Eric Anholt wrote:
>> 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!


Attachments:
signature.asc (847.00 B)