aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_bo.c
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2011-11-11 15:42:57 -0500
committerDave Airlie <airlied@redhat.com>2011-12-06 05:40:11 -0500
commit57de4ba959b290f0b8cf36ecd5e7f1b29d4b8a12 (patch)
tree8063f4dfaf1a22bf8cf7a5f0410d4e4929b250ec /drivers/gpu/drm/nouveau/nouveau_bo.c
parent8e7e70522d760c4ccd4cd370ebfa0ba69e006c6e (diff)
drm/ttm: simplify memory accounting for ttm user v2
Provide helper function to compute the kernel memory size needed for each buffer object. Move all the accounting inside ttm, simplifying driver and avoiding code duplication accross them. v2 fix accounting of ghost object, one would have thought that i would have run into the issue since a longtime but it seems ghost object are rare when you have plenty of vram ;) Signed-off-by: Jerome Glisse <jglisse@redhat.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bo.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index d6326af9fcc..7ac7bc3a8de 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -93,6 +93,7 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
93{ 93{
94 struct drm_nouveau_private *dev_priv = dev->dev_private; 94 struct drm_nouveau_private *dev_priv = dev->dev_private;
95 struct nouveau_bo *nvbo; 95 struct nouveau_bo *nvbo;
96 size_t acc_size;
96 int ret; 97 int ret;
97 98
98 nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL); 99 nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
@@ -115,9 +116,12 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
115 nvbo->bo.mem.num_pages = size >> PAGE_SHIFT; 116 nvbo->bo.mem.num_pages = size >> PAGE_SHIFT;
116 nouveau_bo_placement_set(nvbo, flags, 0); 117 nouveau_bo_placement_set(nvbo, flags, 0);
117 118
119 acc_size = ttm_bo_dma_acc_size(&dev_priv->ttm.bdev, size,
120 sizeof(struct nouveau_bo));
121
118 ret = ttm_bo_init(&dev_priv->ttm.bdev, &nvbo->bo, size, 122 ret = ttm_bo_init(&dev_priv->ttm.bdev, &nvbo->bo, size,
119 ttm_bo_type_device, &nvbo->placement, 123 ttm_bo_type_device, &nvbo->placement,
120 align >> PAGE_SHIFT, 0, false, NULL, size, 124 align >> PAGE_SHIFT, 0, false, NULL, acc_size,
121 nouveau_bo_del_ttm); 125 nouveau_bo_del_ttm);
122 if (ret) { 126 if (ret) {
123 /* ttm will call nouveau_bo_del_ttm if it fails.. */ 127 /* ttm will call nouveau_bo_del_ttm if it fails.. */