From: Huang Rui <ray.huang@amd.com>
To: "Zhang, Julia" <Julia.Zhang@amd.com>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Chen, Jiqian" <Jiqian.Chen@amd.com>,
"Zhu, Lingshan" <Lingshan.Zhu@amd.com>
Subject: Re: [PATCH v2] drm/amdgpu: avoid using null object of framebuffer
Date: Wed, 19 Jun 2024 12:46:07 +0800 [thread overview]
Message-ID: <ZnJijxTr65XMEXki@amd.com> (raw)
In-Reply-To: <20240619042924.1489294-1-julia.zhang@amd.com>
On Wed, Jun 19, 2024 at 12:29:24PM +0800, Zhang, Julia wrote:
> Instead of using state->fb->obj[0] directly, get object from framebuffer
> by calling drm_gem_fb_get_obj() and return error code when object is
> null to avoid using null object of framebuffer.
>
> v2: Call drm_gem_fb_get_obj after check old_state->fb for NULL.
>
> Signed-off-by: Julia Zhang <Julia.Zhang@amd.com>
> ---
Julia, you can add my RB during V1 in the next submission.
Reviewed-by: Huang Rui <ray.huang@amd.com>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
> index d60c4a2eeb0c..212f6522859d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c
> @@ -2,6 +2,7 @@
>
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_simple_kms_helper.h>
> +#include <drm/drm_gem_framebuffer_helper.h>
> #include <drm/drm_vblank.h>
>
> #include "amdgpu.h"
> @@ -311,7 +312,13 @@ static int amdgpu_vkms_prepare_fb(struct drm_plane *plane,
> return 0;
> }
> afb = to_amdgpu_framebuffer(new_state->fb);
> - obj = new_state->fb->obj[0];
> +
> + obj = drm_gem_fb_get_obj(new_state->fb, 0);
> + if (!obj) {
> + DRM_ERROR("Failed to get obj from framebuffer\n");
> + return -EINVAL;
> + }
> +
> rbo = gem_to_amdgpu_bo(obj);
> adev = amdgpu_ttm_adev(rbo->tbo.bdev);
>
> @@ -365,12 +372,19 @@ static void amdgpu_vkms_cleanup_fb(struct drm_plane *plane,
> struct drm_plane_state *old_state)
> {
> struct amdgpu_bo *rbo;
> + struct drm_gem_object *obj;
> int r;
>
> if (!old_state->fb)
> return;
>
> - rbo = gem_to_amdgpu_bo(old_state->fb->obj[0]);
> + obj = drm_gem_fb_get_obj(old_state->fb, 0);
> + if (!obj) {
> + DRM_ERROR("Failed to get obj from framebuffer\n");
> + return;
> + }
> +
> + rbo = gem_to_amdgpu_bo(obj);
> r = amdgpu_bo_reserve(rbo, false);
> if (unlikely(r)) {
> DRM_ERROR("failed to reserve rbo before unpin\n");
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-06-19 4:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 4:29 [PATCH v2] drm/amdgpu: avoid using null object of framebuffer Julia Zhang
2024-06-19 4:46 ` Huang Rui [this message]
2024-06-19 4:53 ` Huang Rui
2024-06-19 5:00 ` Zhang, Julia
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=ZnJijxTr65XMEXki@amd.com \
--to=ray.huang@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Jiqian.Chen@amd.com \
--cc=Julia.Zhang@amd.com \
--cc=Lingshan.Zhu@amd.com \
--cc=amd-gfx@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.