From: Lucas Stach <l.stach@pengutronix.de>
To: linux-mm@kvack.org, dri-devel@lists.freedesktop.org
Cc: "Daniel Vetter" <daniel@ffwll.ch>,
"David Airlie" <airlied@linux.ie>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Michal Hocko" <mhocko@suse.com>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
linux-fsdevel@vger.kernel.org, kernel@pengutronix.de
Subject: [RFC PATCH 4/5] drm/cma-helper: account memory used by CMA GEM objects
Date: Fri, 9 Sep 2022 13:16:39 +0200 [thread overview]
Message-ID: <20220909111640.3789791-5-l.stach@pengutronix.de> (raw)
In-Reply-To: <20220909111640.3789791-1-l.stach@pengutronix.de>
CMA buffer are pinned into system memory as soon as they are allocated
and will only disappear when they are freed.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index 42abee9a0f4f..f0c4e7e6cc33 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -162,6 +162,8 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
goto error;
}
+ drm_gem_add_resident(&cma_obj->base);
+
return cma_obj;
error:
@@ -230,6 +232,8 @@ void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj)
struct drm_gem_object *gem_obj = &cma_obj->base;
struct iosys_map map = IOSYS_MAP_INIT_VADDR(cma_obj->vaddr);
+ drm_gem_dec_resident(gem_obj);
+
if (gem_obj->import_attach) {
if (cma_obj->vaddr)
dma_buf_vunmap(gem_obj->import_attach->dmabuf, &map);
--
2.30.2
next prev parent reply other threads:[~2022-09-09 11:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 11:16 [RFC PATCH 0/5] GEM buffer memory tracking Lucas Stach
2022-09-09 11:16 ` [RFC PATCH 1/5] mm: add MM_DRIVERPAGES Lucas Stach
2022-09-09 11:16 ` [RFC PATCH 2/5] drm/gem: track mm struct of allocating process in gem object Lucas Stach
2022-09-09 11:16 ` [RFC PATCH 3/5] drm/gem: add functions to account GEM object memory usage Lucas Stach
2022-09-09 11:16 ` Lucas Stach [this message]
2022-09-09 11:16 ` [RFC PATCH 5/5] drm/etnaviv: account memory used by GEM buffers Lucas Stach
2022-09-09 11:32 ` [RFC PATCH 0/5] GEM buffer memory tracking Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220909111640.3789791-5-l.stach@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@pengutronix.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox