[PATCH 2/3] drm/amdgpu: Keep track of the number of KMS FBs using an amdgpu_bo
Michel Dänzer
michel at daenzer.net
Thu Feb 22 17:28:19 UTC 2024
From: Michel Dänzer <mdaenzer at redhat.com>
Signed-off-by: Michel Dänzer <mdaenzer at 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
More information about the amd-gfx
mailing list