6dd89a9ed374ca39389288b5b45eec63dbf23c5e
[openwrt/staging/chunkeey.git] /
1 From f91d0382b735a3d7711f6b160d80627cd4be54af Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Thu, 7 Feb 2019 15:26:13 -0800
4 Subject: [PATCH 572/806] drm/v3d: Fix BO stats accounting for dma-buf-imported
5 buffers.
6
7 We always decrement at GEM free, so make sure we increment at GEM
8 creation for dma-bufs.
9
10 Signed-off-by: Eric Anholt <eric@anholt.net>
11 Link: https://patchwork.freedesktop.org/patch/msgid/20190207232613.24981-1-eric@anholt.net
12 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
13 Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
14 (cherry picked from commit cc3f60cfd4f2752f1bad7eaa3839855c15347abc)
15 ---
16 drivers/gpu/drm/v3d/v3d_bo.c | 6 ++++++
17 1 file changed, 6 insertions(+)
18
19 --- a/drivers/gpu/drm/v3d/v3d_bo.c
20 +++ b/drivers/gpu/drm/v3d/v3d_bo.c
21 @@ -282,6 +282,7 @@ v3d_prime_import_sg_table(struct drm_dev
22 struct dma_buf_attachment *attach,
23 struct sg_table *sgt)
24 {
25 + struct v3d_dev *v3d = to_v3d_dev(dev);
26 struct drm_gem_object *obj;
27 struct v3d_bo *bo;
28
29 @@ -296,6 +297,11 @@ v3d_prime_import_sg_table(struct drm_dev
30 obj->import_attach = attach;
31 v3d_bo_get_pages(bo);
32
33 + mutex_lock(&v3d->bo_lock);
34 + v3d->bo_stats.num_allocated++;
35 + v3d->bo_stats.pages_allocated += obj->size >> PAGE_SHIFT;
36 + mutex_unlock(&v3d->bo_lock);
37 +
38 v3d_mmu_insert_ptes(bo);
39
40 return obj;