Commit af51a5e7 authored by YoungJun Cho's avatar YoungJun Cho Committed by Inki Dae

drm/exynos: use drm_calloc_large when allocates pointer array

If the type of object is pointer array, the drm_calloc_large() is
more suitable than kzalloc() for its allocation function. And uses
drm_free_large() instead of kfree() also.
Signed-off-by: default avatarYoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: default avatarSeung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent ba3706c0
...@@ -57,8 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev, ...@@ -57,8 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
dma_addr_t start_addr; dma_addr_t start_addr;
unsigned int i = 0; unsigned int i = 0;
buf->pages = kzalloc(sizeof(struct page) * nr_pages, buf->pages = drm_calloc_large(nr_pages, sizeof(struct page));
GFP_KERNEL);
if (!buf->pages) { if (!buf->pages) {
DRM_ERROR("failed to allocate pages.\n"); DRM_ERROR("failed to allocate pages.\n");
return -ENOMEM; return -ENOMEM;
...@@ -69,7 +68,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev, ...@@ -69,7 +68,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
&buf->dma_attrs); &buf->dma_attrs);
if (!buf->kvaddr) { if (!buf->kvaddr) {
DRM_ERROR("failed to allocate buffer.\n"); DRM_ERROR("failed to allocate buffer.\n");
kfree(buf->pages); drm_free_large(buf->pages);
return -ENOMEM; return -ENOMEM;
} }
...@@ -109,7 +108,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev, ...@@ -109,7 +108,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
buf->dma_addr = (dma_addr_t)NULL; buf->dma_addr = (dma_addr_t)NULL;
if (!is_drm_iommu_supported(dev)) if (!is_drm_iommu_supported(dev))
kfree(buf->pages); drm_free_large(buf->pages);
return ret; return ret;
} }
...@@ -134,7 +133,7 @@ static void lowlevel_buffer_deallocate(struct drm_device *dev, ...@@ -134,7 +133,7 @@ static void lowlevel_buffer_deallocate(struct drm_device *dev,
if (!is_drm_iommu_supported(dev)) { if (!is_drm_iommu_supported(dev)) {
dma_free_attrs(dev->dev, buf->size, buf->kvaddr, dma_free_attrs(dev->dev, buf->size, buf->kvaddr,
(dma_addr_t)buf->dma_addr, &buf->dma_attrs); (dma_addr_t)buf->dma_addr, &buf->dma_attrs);
kfree(buf->pages); drm_free_large(buf->pages);
} else } else
dma_free_attrs(dev->dev, buf->size, buf->pages, dma_free_attrs(dev->dev, buf->size, buf->pages,
(dma_addr_t)buf->dma_addr, &buf->dma_attrs); (dma_addr_t)buf->dma_addr, &buf->dma_attrs);
......
...@@ -390,7 +390,7 @@ static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev, ...@@ -390,7 +390,7 @@ static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev,
kfree(g2d_userptr->sgt); kfree(g2d_userptr->sgt);
g2d_userptr->sgt = NULL; g2d_userptr->sgt = NULL;
kfree(g2d_userptr->pages); drm_free_large(g2d_userptr->pages);
g2d_userptr->pages = NULL; g2d_userptr->pages = NULL;
kfree(g2d_userptr); kfree(g2d_userptr);
g2d_userptr = NULL; g2d_userptr = NULL;
...@@ -463,7 +463,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, ...@@ -463,7 +463,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
npages = (end - start) >> PAGE_SHIFT; npages = (end - start) >> PAGE_SHIFT;
g2d_userptr->npages = npages; g2d_userptr->npages = npages;
pages = kzalloc(npages * sizeof(struct page *), GFP_KERNEL); pages = drm_calloc_large(npages, sizeof(struct page *));
if (!pages) { if (!pages) {
DRM_ERROR("failed to allocate pages.\n"); DRM_ERROR("failed to allocate pages.\n");
kfree(g2d_userptr); kfree(g2d_userptr);
...@@ -554,7 +554,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, ...@@ -554,7 +554,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
exynos_gem_put_vma(g2d_userptr->vma); exynos_gem_put_vma(g2d_userptr->vma);
err_free_pages: err_free_pages:
kfree(pages); drm_free_large(pages);
kfree(g2d_userptr); kfree(g2d_userptr);
pages = NULL; pages = NULL;
g2d_userptr = NULL; g2d_userptr = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment