All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: "Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Xinhui Pan" <Xinhui.Pan@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 2/3] drm/amdgpu: Keep track of the number of KMS FBs using an amdgpu_bo
Date: Thu, 22 Feb 2024 18:28:19 +0100	[thread overview]
Message-ID: <20240222172821.16901-2-michel@daenzer.net> (raw)
In-Reply-To: <20240222172821.16901-1-michel@daenzer.net>

From: Michel Dänzer <mdaenzer@redhat.com>

Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 14 ++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h  |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 514a5b2159815..89bda2a2baf58 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -531,6 +531,15 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector,
 	return true;
 }
 
+static void
+amdgpu_fb_destroy(struct drm_framebuffer *fb)
+{
+	struct amdgpu_bo *bo = gem_to_amdgpu_bo(fb->obj[0]);
+
+	atomic_dec(&bo->num_fbs);
+	drm_gem_fb_destroy(fb);
+}
+
 static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file *file,
 			  unsigned int flags, unsigned int color,
 			  struct drm_clip_rect *clips, unsigned int num_clips)
@@ -544,12 +553,12 @@ static int amdgpu_dirtyfb(struct drm_framebuffer *fb, struct drm_file *file,
 }
 
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs = {
-	.destroy = drm_gem_fb_destroy,
+	.destroy = amdgpu_fb_destroy,
 	.create_handle = drm_gem_fb_create_handle,
 };
 
 static const struct drm_framebuffer_funcs amdgpu_fb_funcs_atomic = {
-	.destroy = drm_gem_fb_destroy,
+	.destroy = amdgpu_fb_destroy,
 	.create_handle = drm_gem_fb_create_handle,
 	.dirty = amdgpu_dirtyfb
 };
@@ -1306,6 +1315,7 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
 		return ERR_PTR(ret);
 	}
 
+	atomic_inc(&bo->num_fbs);
 	drm_gem_object_put(obj);
 	return &amdgpu_fb->base;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index a3ea8a82db23a..47579a6eb2ae8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -117,6 +117,9 @@ struct amdgpu_bo {
 	 * for memory accounting.
 	 */
 	int8_t				xcp_id;
+
+	/* Number of KMS FBs using this BO */
+	atomic_t			num_fbs;
 };
 
 struct amdgpu_bo_user {
-- 
2.43.0


  reply	other threads:[~2024-02-22 17:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 17:28 [PATCH 1/3] drm/amdgpu: Refuse to create a KMS FB for non-P2P exported dma-bufs Michel Dänzer
2024-02-22 17:28 ` Michel Dänzer [this message]
2024-02-22 17:28 ` [PATCH 3/3] drm/amdgpu: Refuse non-P2P dma-buf attachments for BOs with KMS FBs Michel Dänzer
2024-02-23  7:06 ` [PATCH 1/3] drm/amdgpu: Refuse to create a KMS FB for non-P2P exported dma-bufs Christian König
2024-02-23  8:11   ` Michel Dänzer
2024-02-23  8:41     ` Michel Dänzer
2024-02-23  9:34     ` Christian König
2024-02-23 10:04       ` Michel Dänzer
2024-02-23 16:43         ` Michel Dänzer
2024-02-26 15:58           ` Christian König
2024-02-26 16:27             ` Michel Dänzer
2024-02-26 16:34               ` Christian König
2024-02-26 16:46                 ` Michel Dänzer
2024-02-26 16:50                   ` Michel Dänzer
2024-02-26 16:53                     ` Christian König
2024-02-26 18:01                       ` Michel Dänzer

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=20240222172821.16901-2-michel@daenzer.net \
    --to=michel@daenzer.net \
    --cc=Xinhui.Pan@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.