diff options
author | Christian König <deathsimple@vodafone.de> | 2012-05-09 15:34:53 +0200 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-05-09 17:22:35 +0100 |
commit | 2e0d99103e7b62ad27dcbc8c92337687dd8294e6 (patch) | |
tree | 694b08c575a0dbc36c3ac6be116e876ccee64c4d /drivers/gpu/drm/radeon/radeon_sa.c | |
parent | e6661a96647447aee83db976e8aad3d3a5c30cbd (diff) | |
download | linux-2e0d99103e7b62ad27dcbc8c92337687dd8294e6.tar.bz2 |
drm/radeon: make sa bo a stand alone object
Allocating and freeing it seperately.
Signed-off-by: Christian König <deathsimple@vodafone.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_sa.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_sa.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c index 3bea7ba1e488..625f2d4f638a 100644 --- a/drivers/gpu/drm/radeon/radeon_sa.c +++ b/drivers/gpu/drm/radeon/radeon_sa.c @@ -131,7 +131,7 @@ int radeon_sa_bo_manager_suspend(struct radeon_device *rdev, */ int radeon_sa_bo_new(struct radeon_device *rdev, struct radeon_sa_manager *sa_manager, - struct radeon_sa_bo *sa_bo, + struct radeon_sa_bo **sa_bo, unsigned size, unsigned align) { struct radeon_sa_bo *tmp; @@ -140,6 +140,9 @@ int radeon_sa_bo_new(struct radeon_device *rdev, BUG_ON(align > RADEON_GPU_PAGE_SIZE); BUG_ON(size > sa_manager->size); + + *sa_bo = kmalloc(sizeof(struct radeon_sa_bo), GFP_KERNEL); + spin_lock(&sa_manager->lock); /* no one ? */ @@ -175,23 +178,30 @@ int radeon_sa_bo_new(struct radeon_device *rdev, if ((sa_manager->size - offset) < size) { /* failed to find somethings big enough */ spin_unlock(&sa_manager->lock); + kfree(*sa_bo); + *sa_bo = NULL; return -ENOMEM; } out: - sa_bo->manager = sa_manager; - sa_bo->soffset = offset; - sa_bo->eoffset = offset + size; - list_add(&sa_bo->list, head); + (*sa_bo)->manager = sa_manager; + (*sa_bo)->soffset = offset; + (*sa_bo)->eoffset = offset + size; + list_add(&(*sa_bo)->list, head); spin_unlock(&sa_manager->lock); return 0; } -void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo *sa_bo) +void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo **sa_bo) { - spin_lock(&sa_bo->manager->lock); - list_del_init(&sa_bo->list); - spin_unlock(&sa_bo->manager->lock); + if (!sa_bo || !*sa_bo) + return; + + spin_lock(&(*sa_bo)->manager->lock); + list_del_init(&(*sa_bo)->list); + spin_unlock(&(*sa_bo)->manager->lock); + kfree(*sa_bo); + *sa_bo = NULL; } #if defined(CONFIG_DEBUG_FS) |