From patchwork Fri Sep 9 11:16:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 12971580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DC94ECAAD3 for ; Fri, 9 Sep 2022 11:16:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEE118D0002; Fri, 9 Sep 2022 07:16:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC3C98D0006; Fri, 9 Sep 2022 07:16:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB21E8D0002; Fri, 9 Sep 2022 07:16:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9B4318D0006 for ; Fri, 9 Sep 2022 07:16:47 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7AA88C12AD for ; Fri, 9 Sep 2022 11:16:47 +0000 (UTC) X-FDA: 79892294454.13.0764627 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [85.220.165.71]) by imf04.hostedemail.com (Postfix) with ESMTP id 1AB5D40084 for ; Fri, 9 Sep 2022 11:16:46 +0000 (UTC) Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oWc05-0002dP-IW; Fri, 09 Sep 2022 13:16:45 +0200 From: Lucas Stach To: linux-mm@kvack.org, dri-devel@lists.freedesktop.org Cc: Daniel Vetter , David Airlie , Andrew Morton , Michal Hocko , =?utf-8?q?Christian_K=C3=B6nig?= , 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 Message-Id: <20220909111640.3789791-5-l.stach@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220909111640.3789791-1-l.stach@pengutronix.de> References: <20220909111640.3789791-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mm@kvack.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662722207; a=rsa-sha256; cv=none; b=Sc3x891p9d/5/tVDWnesic6yU/Xkp9GddoT5LZKaJbU+aImMlMKCv24hr2ELOX6KaAvboU w2qOczb6iIe93MzjT2CeHJfQr6ETM02fvm5VUA8xuYWgrUW6lpZ0mGdIypTKQ/ueqv4jg7 tZHDB3z9m34tkcSFi9THfU198GB1KXs= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of l.stach@pengutronix.de designates 85.220.165.71 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662722207; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vd2hnXVkt8PyL0zKx/WzK3ERGrir9HxLfSp7uQ67S7M=; b=Q4CisKEFZdUNfWEz0ci2AV9KLSdodf36ZnByPwFajIxbNNvD2pADq0N+6VsGBzIrnyZtKQ DbOtXfq0q3iTKlehsfV56jKwSTJ19iNJLQLJ2HMi8FJZU9c+eBq6LZLVy2YBFn61hq6DZK Xm5m9LEpXOhR409lTWuv2P+qGlvPTwA= Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of l.stach@pengutronix.de designates 85.220.165.71 as permitted sender) smtp.mailfrom=l.stach@pengutronix.de X-Rspam-User: X-Rspamd-Queue-Id: 1AB5D40084 X-Rspamd-Server: rspam09 X-Stat-Signature: 7swiiw6sapeity5hwo1natcnmyfeb8xr X-HE-Tag: 1662722206-820370 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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);