diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-10-02 04:15:17 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-10-09 00:37:55 -0400 |
commit | 55fb74adc628b99424360b0123f47ea4484c56fd (patch) | |
tree | 3c8b51cc6047af2a59a40989e18c4844afa0a23e /drivers/gpu/drm/nouveau/nouveau_bo.c | |
parent | 51bbd276015661a28b69450e104632bc2b633311 (diff) |
drm/nouveau: embed gem object in nouveau_bo
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.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bo.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bo.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 755c38d06271..4172854d4365 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -146,7 +146,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo) | |||
146 | struct drm_device *dev = drm->dev; | 146 | struct drm_device *dev = drm->dev; |
147 | struct nouveau_bo *nvbo = nouveau_bo(bo); | 147 | struct nouveau_bo *nvbo = nouveau_bo(bo); |
148 | 148 | ||
149 | if (unlikely(nvbo->gem)) | 149 | if (unlikely(nvbo->gem.filp)) |
150 | DRM_ERROR("bo %p still attached to GEM object\n", bo); | 150 | DRM_ERROR("bo %p still attached to GEM object\n", bo); |
151 | WARN_ON(nvbo->pin_refcnt > 0); | 151 | WARN_ON(nvbo->pin_refcnt > 0); |
152 | nv10_bo_put_tile_region(dev, nvbo->tile, NULL); | 152 | nv10_bo_put_tile_region(dev, nvbo->tile, NULL); |
@@ -1267,7 +1267,7 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp) | |||
1267 | { | 1267 | { |
1268 | struct nouveau_bo *nvbo = nouveau_bo(bo); | 1268 | struct nouveau_bo *nvbo = nouveau_bo(bo); |
1269 | 1269 | ||
1270 | return drm_vma_node_verify_access(&nvbo->gem->vma_node, filp); | 1270 | return drm_vma_node_verify_access(&nvbo->gem.vma_node, filp); |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | static int | 1273 | static int |