From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: puck.chen@hisilicon.com, dri-devel@lists.freedesktop.org,
kong.kongxinwei@hisilicon.com, kraxel@redhat.com,
zourongrong@gmail.com, airlied@redhat.com, sam@ravnborg.org
Subject: Re: [PATCH v2 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object
Date: Fri, 13 Dec 2019 11:27:48 +0100 [thread overview]
Message-ID: <20191213102748.GG624164@phenom.ffwll.local> (raw)
In-Reply-To: <20191212074117.29283-4-tzimmermann@suse.de>
On Thu, Dec 12, 2019 at 08:41:17AM +0100, Thomas Zimmermann wrote:
> Drivers that what to allocate VRAM GEM objects with additional fields
> can now do this by implementing struct drm_driver.gem_create_object.
>
> v2:
> * only cast to gbo within if branch; set gbo directly
> in else branch
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/drm_gem_vram_helper.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index b760fd27f3c0..baa49d1e9538 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -2,6 +2,7 @@
>
> #include <drm/drm_debugfs.h>
> #include <drm/drm_device.h>
> +#include <drm/drm_drv.h>
> #include <drm/drm_file.h>
> #include <drm/drm_framebuffer.h>
> #include <drm/drm_gem_ttm_helper.h>
> @@ -145,7 +146,13 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
> struct drm_gem_vram_object *gbo;
> int ret;
>
> - gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
> + if (dev->driver->gem_create_object) {
> + struct drm_gem_object *gem =
> + dev->driver->gem_create_object(dev, size);
> + gbo = drm_gem_vram_of_gem(gem);
> + } else {
> + gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
> + }
> if (!gbo)
See my other mail, I'd move the check too into if/else blocks. ERR_PTR
after an upcast is always a bit scary.
-Daniel
> return ERR_PTR(-ENOMEM);
>
> --
> 2.24.0
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-12-13 10:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 7:41 [PATCH v2 0/3] drm/vram-helper: Various cleanups Thomas Zimmermann
2019-12-12 7:41 ` [PATCH v2 1/3] drm/vram-helper: Remove interruptible flag from public interface Thomas Zimmermann
2019-12-12 7:41 ` [PATCH v2 2/3] drm/vram-helper: Remove BO device " Thomas Zimmermann
2019-12-12 7:41 ` [PATCH v2 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object Thomas Zimmermann
2019-12-13 10:27 ` Daniel Vetter [this message]
2020-01-06 10:20 ` Thomas Zimmermann
2019-12-12 9:49 ` [PATCH v2 0/3] drm/vram-helper: Various cleanups Sam Ravnborg
2019-12-12 10:26 ` Thomas Zimmermann
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=20191213102748.GG624164@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kong.kongxinwei@hisilicon.com \
--cc=kraxel@redhat.com \
--cc=puck.chen@hisilicon.com \
--cc=sam@ravnborg.org \
--cc=tzimmermann@suse.de \
--cc=zourongrong@gmail.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