From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: Martin Peres <martin.peres@labri.fr>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/7] drm/nouveau: embed gem object in nouveau_bo
Date: Wed, 14 Aug 2013 16:31:15 +0200 [thread overview]
Message-ID: <520B94B3.7060909@canonical.com> (raw)
In-Reply-To: <1376485640-711-7-git-send-email-dh.herrmann@gmail.com>
Op 14-08-13 15:07, David Herrmann schreef:
> There is no reason to keep the gem object separately allocated. nouveau is
> the last user of gem_obj->driver_private, so if we embed it, we can get
> rid of 8bytes per gem-object.
>
> The implementation follows the radeon driver. bo->gem is only valid, iff
> the bo was created via the gem helpers _and_ iff the user holds a valid
> gem reference. That is, as the gem object holds a reference to the
> nouveau_bo. If you use nouveau_ref() to gain a bo reference, you are not
> guaranteed to also hold a gem reference. The gem object might get
> destroyed after the last user drops the gem-ref via
> drm_gem_object_unreference(). Use drm_gem_object_reference() to gain a
> gem-reference.
>
> For debugging, we can use bo->gem.filp != NULL to test whether a gem-bo is
> valid. However, this shouldn't be used for real functionality to avoid
> gem-internal dependencies.
>
> Note that the implementation follows the previous style. However, we no
> longer can check for bo->gem != NULL to test for a valid gem object. This
> wasn't done before, so we should be safe now.
I'm all for getting rid of it, but I think it's not thorough enough. :P
There's still a separate refcount in ttm for the bo, and I think it doesn't make sense to keep it like that.
Instead of having that refcount in ttm, could it be put entirely in gem?
ttm_buffer_object_transfer is the only time ttm creates a bo, and it's immediately destroyed, so instead
of calling ttm_bo_unref it could call ttm_bo_release directly, in which case it doesn't matter that refcount
is managed by gem.
Oh except for vmwgfx of course, I always forget that 'special' case.
Maybe something like this in memory?
struct {
struct ttm_buffer_object bo;
struct drm_gem_object gem; // Can be anything, as long as first member is a refcount, and no hole between ttm and this..
};
This would allow ttm to do kref_put((kref_t*)(bo +1), driver->releasefn), where driver->releasefn has to call ttm_bo_release again.
Unfortunately unless drm is fixed dma-buf is still going to be as buggy as before, not much I can do about that. :/
But this is something for a future where dma-buf in drm doesn't suck..
~Maarten
next prev parent reply other threads:[~2013-08-14 14:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-14 13:07 [PATCH 0/7] DRM: Remove gem_init_object() and friends David Herrmann
2013-08-14 13:07 ` [PATCH 1/7] drm/ast: remove unused driver_private access David Herrmann
2013-08-14 13:07 ` [PATCH 2/7] drm/mgag200: " David Herrmann
2013-08-14 13:07 ` [PATCH 3/7] drm/cirrus: " David Herrmann
2013-08-14 13:07 ` [PATCH 4/7] drm/qxl: remove unused object_pin/unpin() helpers David Herrmann
2013-08-14 13:07 ` [PATCH 5/7] drm/radeon: remove stale gem->driver_private access David Herrmann
2013-08-14 13:23 ` Alex Deucher
2013-08-14 13:07 ` [PATCH 6/7] drm/nouveau: embed gem object in nouveau_bo David Herrmann
2013-08-14 14:31 ` Maarten Lankhorst [this message]
2013-08-15 12:32 ` David Herrmann
2013-08-15 12:44 ` Daniel Vetter
2013-08-15 13:09 ` Maarten Lankhorst
2013-09-23 23:15 ` Ben Skeggs
2013-08-14 13:07 ` [PATCH 7/7] drm: kill ->gem_init_object() and friends David Herrmann
2013-08-14 13:27 ` [PATCH 0/7] DRM: Remove gem_init_object() " Daniel Vetter
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=520B94B3.7060909@canonical.com \
--to=maarten.lankhorst@canonical.com \
--cc=dh.herrmann@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=martin.peres@labri.fr \
/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.