Commit 813fd67b authored by Joonyoung Shim's avatar Joonyoung Shim Committed by Inki Dae

drm/exynos: cleanup name of gem object for exynos_drm

Struct of gem object in exynos_drm driver is struct exynos_drm_gem_obj.
It's too long and we can know its meaning of name without _obj postfix.

We use several names to variable name of gem object for exynos_drm -
exynos_gem_obj, gem_obj and obj. Especially "obj" name can cause
misunderstanding with variable name "obj" of struct drm_gem_object.

This will clean about name of gem object for exynos_drm as follows.
s/struct exynos_drm_gem_obj/struct exynos_drm_gem
s/exynos_gem_obj or gem_obj or obj/exynos_gem
Signed-off-by: default avatarJoonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent 4d91a855
...@@ -32,15 +32,15 @@ ...@@ -32,15 +32,15 @@
* exynos specific framebuffer structure. * exynos specific framebuffer structure.
* *
* @fb: drm framebuffer obejct. * @fb: drm framebuffer obejct.
* @exynos_gem_obj: array of exynos specific gem object containing a gem object. * @exynos_gem: array of exynos specific gem object containing a gem object.
*/ */
struct exynos_drm_fb { struct exynos_drm_fb {
struct drm_framebuffer fb; struct drm_framebuffer fb;
struct exynos_drm_gem_obj *exynos_gem_obj[MAX_FB_BUFFER]; struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
}; };
static int check_fb_gem_memory_type(struct drm_device *drm_dev, static int check_fb_gem_memory_type(struct drm_device *drm_dev,
struct exynos_drm_gem_obj *exynos_gem_obj) struct exynos_drm_gem *exynos_gem)
{ {
unsigned int flags; unsigned int flags;
...@@ -51,7 +51,7 @@ static int check_fb_gem_memory_type(struct drm_device *drm_dev, ...@@ -51,7 +51,7 @@ static int check_fb_gem_memory_type(struct drm_device *drm_dev,
if (is_drm_iommu_supported(drm_dev)) if (is_drm_iommu_supported(drm_dev))
return 0; return 0;
flags = exynos_gem_obj->flags; flags = exynos_gem->flags;
/* /*
* without iommu support, not support physically non-continuous memory * without iommu support, not support physically non-continuous memory
...@@ -75,13 +75,13 @@ static void exynos_drm_fb_destroy(struct drm_framebuffer *fb) ...@@ -75,13 +75,13 @@ static void exynos_drm_fb_destroy(struct drm_framebuffer *fb)
drm_framebuffer_cleanup(fb); drm_framebuffer_cleanup(fb);
for (i = 0; i < ARRAY_SIZE(exynos_fb->exynos_gem_obj); i++) { for (i = 0; i < ARRAY_SIZE(exynos_fb->exynos_gem); i++) {
struct drm_gem_object *obj; struct drm_gem_object *obj;
if (exynos_fb->exynos_gem_obj[i] == NULL) if (exynos_fb->exynos_gem[i] == NULL)
continue; continue;
obj = &exynos_fb->exynos_gem_obj[i]->base; obj = &exynos_fb->exynos_gem[i]->base;
drm_gem_object_unreference_unlocked(obj); drm_gem_object_unreference_unlocked(obj);
} }
...@@ -96,7 +96,7 @@ static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb, ...@@ -96,7 +96,7 @@ static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb,
struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb); struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
return drm_gem_handle_create(file_priv, return drm_gem_handle_create(file_priv,
&exynos_fb->exynos_gem_obj[0]->base, handle); &exynos_fb->exynos_gem[0]->base, handle);
} }
static int exynos_drm_fb_dirty(struct drm_framebuffer *fb, static int exynos_drm_fb_dirty(struct drm_framebuffer *fb,
...@@ -118,7 +118,7 @@ static struct drm_framebuffer_funcs exynos_drm_fb_funcs = { ...@@ -118,7 +118,7 @@ static struct drm_framebuffer_funcs exynos_drm_fb_funcs = {
struct drm_framebuffer * struct drm_framebuffer *
exynos_drm_framebuffer_init(struct drm_device *dev, exynos_drm_framebuffer_init(struct drm_device *dev,
struct drm_mode_fb_cmd2 *mode_cmd, struct drm_mode_fb_cmd2 *mode_cmd,
struct exynos_drm_gem_obj **gem_obj, struct exynos_drm_gem **exynos_gem,
int count) int count)
{ {
struct exynos_drm_fb *exynos_fb; struct exynos_drm_fb *exynos_fb;
...@@ -130,11 +130,11 @@ exynos_drm_framebuffer_init(struct drm_device *dev, ...@@ -130,11 +130,11 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
ret = check_fb_gem_memory_type(dev, gem_obj[i]); ret = check_fb_gem_memory_type(dev, exynos_gem[i]);
if (ret < 0) if (ret < 0)
goto err; goto err;
exynos_fb->exynos_gem_obj[i] = gem_obj[i]; exynos_fb->exynos_gem[i] = exynos_gem[i];
} }
drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd);
...@@ -156,7 +156,7 @@ static struct drm_framebuffer * ...@@ -156,7 +156,7 @@ static struct drm_framebuffer *
exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
struct drm_mode_fb_cmd2 *mode_cmd) struct drm_mode_fb_cmd2 *mode_cmd)
{ {
struct exynos_drm_gem_obj *gem_objs[MAX_FB_BUFFER]; struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
int i; int i;
...@@ -171,10 +171,10 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, ...@@ -171,10 +171,10 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
goto err; goto err;
} }
gem_objs[i] = to_exynos_gem_obj(obj); exynos_gem[i] = to_exynos_gem(obj);
} }
fb = exynos_drm_framebuffer_init(dev, mode_cmd, gem_objs, i); fb = exynos_drm_framebuffer_init(dev, mode_cmd, exynos_gem, i);
if (IS_ERR(fb)) { if (IS_ERR(fb)) {
ret = PTR_ERR(fb); ret = PTR_ERR(fb);
goto err; goto err;
...@@ -184,27 +184,26 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, ...@@ -184,27 +184,26 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
err: err:
while (i--) while (i--)
drm_gem_object_unreference_unlocked(&gem_objs[i]->base); drm_gem_object_unreference_unlocked(&exynos_gem[i]->base);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
struct exynos_drm_gem_obj *exynos_drm_fb_gem_obj(struct drm_framebuffer *fb, struct exynos_drm_gem *exynos_drm_fb_gem(struct drm_framebuffer *fb, int index)
int index)
{ {
struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb); struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb);
struct exynos_drm_gem_obj *obj; struct exynos_drm_gem *exynos_gem;
if (index >= MAX_FB_BUFFER) if (index >= MAX_FB_BUFFER)
return NULL; return NULL;
obj = exynos_fb->exynos_gem_obj[index]; exynos_gem = exynos_fb->exynos_gem[index];
if (!obj) if (!exynos_gem)
return NULL; return NULL;
DRM_DEBUG_KMS("dma_addr = 0x%lx\n", (unsigned long)obj->dma_addr); DRM_DEBUG_KMS("dma_addr: 0x%lx\n", (unsigned long)exynos_gem->dma_addr);
return obj; return exynos_gem;
} }
static void exynos_drm_output_poll_changed(struct drm_device *dev) static void exynos_drm_output_poll_changed(struct drm_device *dev)
......
...@@ -19,12 +19,11 @@ ...@@ -19,12 +19,11 @@
struct drm_framebuffer * struct drm_framebuffer *
exynos_drm_framebuffer_init(struct drm_device *dev, exynos_drm_framebuffer_init(struct drm_device *dev,
struct drm_mode_fb_cmd2 *mode_cmd, struct drm_mode_fb_cmd2 *mode_cmd,
struct exynos_drm_gem_obj **gem_obj, struct exynos_drm_gem **exynos_gem,
int count); int count);
/* get gem object of a drm framebuffer */ /* get gem object of a drm framebuffer */
struct exynos_drm_gem_obj *exynos_drm_fb_gem_obj(struct drm_framebuffer *fb, struct exynos_drm_gem *exynos_drm_fb_gem(struct drm_framebuffer *fb, int index);
int index);
void exynos_drm_mode_config_init(struct drm_device *dev); void exynos_drm_mode_config_init(struct drm_device *dev);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
struct exynos_drm_fbdev { struct exynos_drm_fbdev {
struct drm_fb_helper drm_fb_helper; struct drm_fb_helper drm_fb_helper;
struct exynos_drm_gem_obj *obj; struct exynos_drm_gem *exynos_gem;
}; };
static int exynos_drm_fb_mmap(struct fb_info *info, static int exynos_drm_fb_mmap(struct fb_info *info,
...@@ -39,7 +39,7 @@ static int exynos_drm_fb_mmap(struct fb_info *info, ...@@ -39,7 +39,7 @@ static int exynos_drm_fb_mmap(struct fb_info *info,
{ {
struct drm_fb_helper *helper = info->par; struct drm_fb_helper *helper = info->par;
struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper); struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper);
struct exynos_drm_gem_obj *obj = exynos_fbd->obj; struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;
unsigned long vm_size; unsigned long vm_size;
int ret; int ret;
...@@ -47,11 +47,12 @@ static int exynos_drm_fb_mmap(struct fb_info *info, ...@@ -47,11 +47,12 @@ static int exynos_drm_fb_mmap(struct fb_info *info,
vm_size = vma->vm_end - vma->vm_start; vm_size = vma->vm_end - vma->vm_start;
if (vm_size > obj->size) if (vm_size > exynos_gem->size)
return -EINVAL; return -EINVAL;
ret = dma_mmap_attrs(helper->dev->dev, vma, obj->pages, obj->dma_addr, ret = dma_mmap_attrs(helper->dev->dev, vma, exynos_gem->pages,
obj->size, &obj->dma_attrs); exynos_gem->dma_addr, exynos_gem->size,
&exynos_gem->dma_attrs);
if (ret < 0) { if (ret < 0) {
DRM_ERROR("failed to mmap.\n"); DRM_ERROR("failed to mmap.\n");
return ret; return ret;
...@@ -75,7 +76,7 @@ static struct fb_ops exynos_drm_fb_ops = { ...@@ -75,7 +76,7 @@ static struct fb_ops exynos_drm_fb_ops = {
static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes, struct drm_fb_helper_surface_size *sizes,
struct exynos_drm_gem_obj *obj) struct exynos_drm_gem *exynos_gem)
{ {
struct fb_info *fbi; struct fb_info *fbi;
struct drm_framebuffer *fb = helper->fb; struct drm_framebuffer *fb = helper->fb;
...@@ -96,11 +97,11 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, ...@@ -96,11 +97,11 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth); drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height); drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
nr_pages = obj->size >> PAGE_SHIFT; nr_pages = exynos_gem->size >> PAGE_SHIFT;
obj->kvaddr = (void __iomem *) vmap(obj->pages, nr_pages, VM_MAP, exynos_gem->kvaddr = (void __iomem *) vmap(exynos_gem->pages, nr_pages,
pgprot_writecombine(PAGE_KERNEL)); VM_MAP, pgprot_writecombine(PAGE_KERNEL));
if (!obj->kvaddr) { if (!exynos_gem->kvaddr) {
DRM_ERROR("failed to map pages to kernel space.\n"); DRM_ERROR("failed to map pages to kernel space.\n");
drm_fb_helper_release_fbi(helper); drm_fb_helper_release_fbi(helper);
return -EIO; return -EIO;
...@@ -109,7 +110,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, ...@@ -109,7 +110,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
offset = fbi->var.xoffset * (fb->bits_per_pixel >> 3); offset = fbi->var.xoffset * (fb->bits_per_pixel >> 3);
offset += fbi->var.yoffset * fb->pitches[0]; offset += fbi->var.yoffset * fb->pitches[0];
fbi->screen_base = obj->kvaddr + offset; fbi->screen_base = exynos_gem->kvaddr + offset;
fbi->screen_size = size; fbi->screen_size = size;
fbi->fix.smem_len = size; fbi->fix.smem_len = size;
...@@ -120,7 +121,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -120,7 +121,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes) struct drm_fb_helper_surface_size *sizes)
{ {
struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper); struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper);
struct exynos_drm_gem_obj *obj; struct exynos_drm_gem *exynos_gem;
struct drm_device *dev = helper->dev; struct drm_device *dev = helper->dev;
struct drm_mode_fb_cmd2 mode_cmd = { 0 }; struct drm_mode_fb_cmd2 mode_cmd = { 0 };
struct platform_device *pdev = dev->platformdev; struct platform_device *pdev = dev->platformdev;
...@@ -141,32 +142,34 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -141,32 +142,34 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
size = mode_cmd.pitches[0] * mode_cmd.height; size = mode_cmd.pitches[0] * mode_cmd.height;
obj = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG, size); exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG, size);
/* /*
* If physically contiguous memory allocation fails and if IOMMU is * If physically contiguous memory allocation fails and if IOMMU is
* supported then try to get buffer from non physically contiguous * supported then try to get buffer from non physically contiguous
* memory area. * memory area.
*/ */
if (IS_ERR(obj) && is_drm_iommu_supported(dev)) { if (IS_ERR(exynos_gem) && is_drm_iommu_supported(dev)) {
dev_warn(&pdev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n"); dev_warn(&pdev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n");
obj = exynos_drm_gem_create(dev, EXYNOS_BO_NONCONTIG, size); exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_NONCONTIG,
size);
} }
if (IS_ERR(obj)) { if (IS_ERR(exynos_gem)) {
ret = PTR_ERR(obj); ret = PTR_ERR(exynos_gem);
goto out; goto out;
} }
exynos_fbdev->obj = obj; exynos_fbdev->exynos_gem = exynos_gem;
helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd, &obj, 1); helper->fb =
exynos_drm_framebuffer_init(dev, &mode_cmd, &exynos_gem, 1);
if (IS_ERR(helper->fb)) { if (IS_ERR(helper->fb)) {
DRM_ERROR("failed to create drm framebuffer.\n"); DRM_ERROR("failed to create drm framebuffer.\n");
ret = PTR_ERR(helper->fb); ret = PTR_ERR(helper->fb);
goto err_destroy_gem; goto err_destroy_gem;
} }
ret = exynos_drm_fbdev_update(helper, sizes, obj); ret = exynos_drm_fbdev_update(helper, sizes, exynos_gem);
if (ret < 0) if (ret < 0)
goto err_destroy_framebuffer; goto err_destroy_framebuffer;
...@@ -176,7 +179,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, ...@@ -176,7 +179,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
err_destroy_framebuffer: err_destroy_framebuffer:
drm_framebuffer_cleanup(helper->fb); drm_framebuffer_cleanup(helper->fb);
err_destroy_gem: err_destroy_gem:
exynos_drm_gem_destroy(obj); exynos_drm_gem_destroy(exynos_gem);
/* /*
* if failed, all resources allocated above would be released by * if failed, all resources allocated above would be released by
...@@ -269,11 +272,11 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev, ...@@ -269,11 +272,11 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
struct drm_fb_helper *fb_helper) struct drm_fb_helper *fb_helper)
{ {
struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(fb_helper); struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(fb_helper);
struct exynos_drm_gem_obj *obj = exynos_fbd->obj; struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
if (obj->kvaddr) if (exynos_gem->kvaddr)
vunmap(obj->kvaddr); vunmap(exynos_gem->kvaddr);
/* release drm framebuffer and real buffer */ /* release drm framebuffer and real buffer */
if (fb_helper->fb && fb_helper->fb->funcs) { if (fb_helper->fb && fb_helper->fb->funcs) {
......
...@@ -20,97 +20,100 @@ ...@@ -20,97 +20,100 @@
#include "exynos_drm_gem.h" #include "exynos_drm_gem.h"
#include "exynos_drm_iommu.h" #include "exynos_drm_iommu.h"
static int exynos_drm_alloc_buf(struct exynos_drm_gem_obj *obj) static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)
{ {
struct drm_device *dev = obj->base.dev; struct drm_device *dev = exynos_gem->base.dev;
enum dma_attr attr; enum dma_attr attr;
unsigned int nr_pages; unsigned int nr_pages;
if (obj->dma_addr) { if (exynos_gem->dma_addr) {
DRM_DEBUG_KMS("already allocated.\n"); DRM_DEBUG_KMS("already allocated.\n");
return 0; return 0;
} }
init_dma_attrs(&obj->dma_attrs); init_dma_attrs(&exynos_gem->dma_attrs);
/* /*
* if EXYNOS_BO_CONTIG, fully physically contiguous memory * if EXYNOS_BO_CONTIG, fully physically contiguous memory
* region will be allocated else physically contiguous * region will be allocated else physically contiguous
* as possible. * as possible.
*/ */
if (!(obj->flags & EXYNOS_BO_NONCONTIG)) if (!(exynos_gem->flags & EXYNOS_BO_NONCONTIG))
dma_set_attr(DMA_ATTR_FORCE_CONTIGUOUS, &obj->dma_attrs); dma_set_attr(DMA_ATTR_FORCE_CONTIGUOUS, &exynos_gem->dma_attrs);
/* /*
* if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping * if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping
* else cachable mapping. * else cachable mapping.
*/ */
if (obj->flags & EXYNOS_BO_WC || !(obj->flags & EXYNOS_BO_CACHABLE)) if (exynos_gem->flags & EXYNOS_BO_WC ||
!(exynos_gem->flags & EXYNOS_BO_CACHABLE))
attr = DMA_ATTR_WRITE_COMBINE; attr = DMA_ATTR_WRITE_COMBINE;
else else
attr = DMA_ATTR_NON_CONSISTENT; attr = DMA_ATTR_NON_CONSISTENT;
dma_set_attr(attr, &obj->dma_attrs); dma_set_attr(attr, &exynos_gem->dma_attrs);
dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &obj->dma_attrs); dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &exynos_gem->dma_attrs);
nr_pages = obj->size >> PAGE_SHIFT; nr_pages = exynos_gem->size >> PAGE_SHIFT;
if (!is_drm_iommu_supported(dev)) { if (!is_drm_iommu_supported(dev)) {
obj->pages = drm_calloc_large(nr_pages, sizeof(struct page *)); exynos_gem->pages = drm_calloc_large(nr_pages,
if (!obj->pages) { sizeof(struct page *));
if (!exynos_gem->pages) {
DRM_ERROR("failed to allocate pages.\n"); DRM_ERROR("failed to allocate pages.\n");
return -ENOMEM; return -ENOMEM;
} }
} }
obj->cookie = dma_alloc_attrs(dev->dev, obj->size, &obj->dma_addr, exynos_gem->cookie = dma_alloc_attrs(dev->dev, exynos_gem->size,
GFP_KERNEL, &obj->dma_attrs); &exynos_gem->dma_addr, GFP_KERNEL,
if (!obj->cookie) { &exynos_gem->dma_attrs);
if (!exynos_gem->cookie) {
DRM_ERROR("failed to allocate buffer.\n"); DRM_ERROR("failed to allocate buffer.\n");
if (obj->pages) if (exynos_gem->pages)
drm_free_large(obj->pages); drm_free_large(exynos_gem->pages);
return -ENOMEM; return -ENOMEM;
} }
if (obj->pages) { if (exynos_gem->pages) {
dma_addr_t start_addr; dma_addr_t start_addr;
unsigned int i = 0; unsigned int i = 0;
start_addr = obj->dma_addr; start_addr = exynos_gem->dma_addr;
while (i < nr_pages) { while (i < nr_pages) {
obj->pages[i] = pfn_to_page(dma_to_pfn(dev->dev, exynos_gem->pages[i] =
start_addr)); pfn_to_page(dma_to_pfn(dev->dev, start_addr));
start_addr += PAGE_SIZE; start_addr += PAGE_SIZE;
i++; i++;
} }
} else { } else {
obj->pages = obj->cookie; exynos_gem->pages = exynos_gem->cookie;
} }
DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n", DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n",
(unsigned long)obj->dma_addr, (unsigned long)exynos_gem->dma_addr, exynos_gem->size);
obj->size);
return 0; return 0;
} }
static void exynos_drm_free_buf(struct exynos_drm_gem_obj *obj) static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)
{ {
struct drm_device *dev = obj->base.dev; struct drm_device *dev = exynos_gem->base.dev;
if (!obj->dma_addr) { if (!exynos_gem->dma_addr) {
DRM_DEBUG_KMS("dma_addr is invalid.\n"); DRM_DEBUG_KMS("dma_addr is invalid.\n");
return; return;
} }
DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n", DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n",
(unsigned long)obj->dma_addr, obj->size); (unsigned long)exynos_gem->dma_addr, exynos_gem->size);
dma_free_attrs(dev->dev, obj->size, obj->cookie, dma_free_attrs(dev->dev, exynos_gem->size, exynos_gem->cookie,
(dma_addr_t)obj->dma_addr, &obj->dma_attrs); (dma_addr_t)exynos_gem->dma_addr,
&exynos_gem->dma_attrs);
if (!is_drm_iommu_supported(dev)) if (!is_drm_iommu_supported(dev))
drm_free_large(obj->pages); drm_free_large(exynos_gem->pages);
} }
static int exynos_drm_gem_handle_create(struct drm_gem_object *obj, static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,
...@@ -135,9 +138,9 @@ static int exynos_drm_gem_handle_create(struct drm_gem_object *obj, ...@@ -135,9 +138,9 @@ static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,
return 0; return 0;
} }
void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj) void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem)
{ {
struct drm_gem_object *obj = &exynos_gem_obj->base; struct drm_gem_object *obj = &exynos_gem->base;
DRM_DEBUG_KMS("handle count = %d\n", obj->handle_count); DRM_DEBUG_KMS("handle count = %d\n", obj->handle_count);
...@@ -148,21 +151,21 @@ void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj) ...@@ -148,21 +151,21 @@ void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj)
* once dmabuf's refcount becomes 0. * once dmabuf's refcount becomes 0.
*/ */
if (obj->import_attach) if (obj->import_attach)
drm_prime_gem_destroy(obj, exynos_gem_obj->sgt); drm_prime_gem_destroy(obj, exynos_gem->sgt);
else else
exynos_drm_free_buf(exynos_gem_obj); exynos_drm_free_buf(exynos_gem);
/* release file pointer to gem object. */ /* release file pointer to gem object. */
drm_gem_object_release(obj); drm_gem_object_release(obj);
kfree(exynos_gem_obj); kfree(exynos_gem);
} }
unsigned long exynos_drm_gem_get_size(struct drm_device *dev, unsigned long exynos_drm_gem_get_size(struct drm_device *dev,
unsigned int gem_handle, unsigned int gem_handle,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
struct drm_gem_object *obj; struct drm_gem_object *obj;
obj = drm_gem_object_lookup(dev, file_priv, gem_handle); obj = drm_gem_object_lookup(dev, file_priv, gem_handle);
...@@ -171,51 +174,51 @@ unsigned long exynos_drm_gem_get_size(struct drm_device *dev, ...@@ -171,51 +174,51 @@ unsigned long exynos_drm_gem_get_size(struct drm_device *dev,
return 0; return 0;
} }
exynos_gem_obj = to_exynos_gem_obj(obj); exynos_gem = to_exynos_gem(obj);
drm_gem_object_unreference_unlocked(obj); drm_gem_object_unreference_unlocked(obj);
return exynos_gem_obj->size; return exynos_gem->size;
} }
static struct exynos_drm_gem_obj *exynos_drm_gem_init(struct drm_device *dev, static struct exynos_drm_gem *exynos_drm_gem_init(struct drm_device *dev,
unsigned long size) unsigned long size)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
struct drm_gem_object *obj; struct drm_gem_object *obj;
int ret; int ret;
exynos_gem_obj = kzalloc(sizeof(*exynos_gem_obj), GFP_KERNEL); exynos_gem = kzalloc(sizeof(*exynos_gem), GFP_KERNEL);
if (!exynos_gem_obj) if (!exynos_gem)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
exynos_gem_obj->size = size; exynos_gem->size = size;
obj = &exynos_gem_obj->base; obj = &exynos_gem->base;
ret = drm_gem_object_init(dev, obj, size); ret = drm_gem_object_init(dev, obj, size);
if (ret < 0) { if (ret < 0) {
DRM_ERROR("failed to initialize gem object\n"); DRM_ERROR("failed to initialize gem object\n");
kfree(exynos_gem_obj); kfree(exynos_gem);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
ret = drm_gem_create_mmap_offset(obj); ret = drm_gem_create_mmap_offset(obj);
if (ret < 0) { if (ret < 0) {
drm_gem_object_release(obj); drm_gem_object_release(obj);
kfree(exynos_gem_obj); kfree(exynos_gem);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp); DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp);
return exynos_gem_obj; return exynos_gem;
} }
struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev, struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
unsigned int flags, unsigned int flags,
unsigned long size) unsigned long size)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
int ret; int ret;
if (flags & ~(EXYNOS_BO_MASK)) { if (flags & ~(EXYNOS_BO_MASK)) {
...@@ -230,38 +233,38 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev, ...@@ -230,38 +233,38 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
size = roundup(size, PAGE_SIZE); size = roundup(size, PAGE_SIZE);
exynos_gem_obj = exynos_drm_gem_init(dev, size); exynos_gem = exynos_drm_gem_init(dev, size);
if (IS_ERR(exynos_gem_obj)) if (IS_ERR(exynos_gem))
return exynos_gem_obj; return exynos_gem;
/* set memory type and cache attribute from user side. */ /* set memory type and cache attribute from user side. */
exynos_gem_obj->flags = flags; exynos_gem->flags = flags;
ret = exynos_drm_alloc_buf(exynos_gem_obj); ret = exynos_drm_alloc_buf(exynos_gem);
if (ret < 0) { if (ret < 0) {
drm_gem_object_release(&exynos_gem_obj->base); drm_gem_object_release(&exynos_gem->base);
kfree(exynos_gem_obj); kfree(exynos_gem);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
return exynos_gem_obj; return exynos_gem;
} }
int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data, int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
struct drm_exynos_gem_create *args = data; struct drm_exynos_gem_create *args = data;
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
int ret; int ret;
exynos_gem_obj = exynos_drm_gem_create(dev, args->flags, args->size); exynos_gem = exynos_drm_gem_create(dev, args->flags, args->size);
if (IS_ERR(exynos_gem_obj)) if (IS_ERR(exynos_gem))
return PTR_ERR(exynos_gem_obj); return PTR_ERR(exynos_gem);
ret = exynos_drm_gem_handle_create(&exynos_gem_obj->base, file_priv, ret = exynos_drm_gem_handle_create(&exynos_gem->base, file_priv,
&args->handle); &args->handle);
if (ret) { if (ret) {
exynos_drm_gem_destroy(exynos_gem_obj); exynos_drm_gem_destroy(exynos_gem);
return ret; return ret;
} }
...@@ -272,7 +275,7 @@ dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev, ...@@ -272,7 +275,7 @@ dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
unsigned int gem_handle, unsigned int gem_handle,
struct drm_file *filp) struct drm_file *filp)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
struct drm_gem_object *obj; struct drm_gem_object *obj;
obj = drm_gem_object_lookup(dev, filp, gem_handle); obj = drm_gem_object_lookup(dev, filp, gem_handle);
...@@ -281,9 +284,9 @@ dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev, ...@@ -281,9 +284,9 @@ dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
exynos_gem_obj = to_exynos_gem_obj(obj); exynos_gem = to_exynos_gem(obj);
return &exynos_gem_obj->dma_addr; return &exynos_gem->dma_addr;
} }
void exynos_drm_gem_put_dma_addr(struct drm_device *dev, void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
...@@ -307,10 +310,10 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev, ...@@ -307,10 +310,10 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
drm_gem_object_unreference_unlocked(obj); drm_gem_object_unreference_unlocked(obj);
} }
static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem_obj *exynos_gem_obj, static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem *exynos_gem,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
struct drm_device *drm_dev = exynos_gem_obj->base.dev; struct drm_device *drm_dev = exynos_gem->base.dev;
unsigned long vm_size; unsigned long vm_size;
int ret; int ret;
...@@ -320,12 +323,12 @@ static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem_obj *exynos_gem_obj, ...@@ -320,12 +323,12 @@ static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem_obj *exynos_gem_obj,
vm_size = vma->vm_end - vma->vm_start; vm_size = vma->vm_end - vma->vm_start;
/* check if user-requested size is valid. */ /* check if user-requested size is valid. */
if (vm_size > exynos_gem_obj->size) if (vm_size > exynos_gem->size)
return -EINVAL; return -EINVAL;
ret = dma_mmap_attrs(drm_dev->dev, vma, exynos_gem_obj->pages, ret = dma_mmap_attrs(drm_dev->dev, vma, exynos_gem->pages,
exynos_gem_obj->dma_addr, exynos_gem_obj->size, exynos_gem->dma_addr, exynos_gem->size,
&exynos_gem_obj->dma_attrs); &exynos_gem->dma_attrs);
if (ret < 0) { if (ret < 0) {
DRM_ERROR("failed to mmap.\n"); DRM_ERROR("failed to mmap.\n");
return ret; return ret;
...@@ -337,7 +340,7 @@ static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem_obj *exynos_gem_obj, ...@@ -337,7 +340,7 @@ static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem_obj *exynos_gem_obj,
int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data, int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
struct drm_exynos_gem_info *args = data; struct drm_exynos_gem_info *args = data;
struct drm_gem_object *obj; struct drm_gem_object *obj;
...@@ -350,10 +353,10 @@ int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data, ...@@ -350,10 +353,10 @@ int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
} }
exynos_gem_obj = to_exynos_gem_obj(obj); exynos_gem = to_exynos_gem(obj);
args->flags = exynos_gem_obj->flags; args->flags = exynos_gem->flags;
args->size = exynos_gem_obj->size; args->size = exynos_gem->size;
drm_gem_object_unreference(obj); drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
...@@ -389,14 +392,14 @@ void exynos_gem_unmap_sgt_from_dma(struct drm_device *drm_dev, ...@@ -389,14 +392,14 @@ void exynos_gem_unmap_sgt_from_dma(struct drm_device *drm_dev,
void exynos_drm_gem_free_object(struct drm_gem_object *obj) void exynos_drm_gem_free_object(struct drm_gem_object *obj)
{ {
exynos_drm_gem_destroy(to_exynos_gem_obj(obj)); exynos_drm_gem_destroy(to_exynos_gem(obj));
} }
int exynos_drm_gem_dumb_create(struct drm_file *file_priv, int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
struct drm_device *dev, struct drm_device *dev,
struct drm_mode_create_dumb *args) struct drm_mode_create_dumb *args)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
unsigned int flags; unsigned int flags;
int ret; int ret;
...@@ -414,16 +417,16 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv, ...@@ -414,16 +417,16 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
else else
flags = EXYNOS_BO_CONTIG | EXYNOS_BO_WC; flags = EXYNOS_BO_CONTIG | EXYNOS_BO_WC;
exynos_gem_obj = exynos_drm_gem_create(dev, flags, args->size); exynos_gem = exynos_drm_gem_create(dev, flags, args->size);
if (IS_ERR(exynos_gem_obj)) { if (IS_ERR(exynos_gem)) {
dev_warn(dev->dev, "FB allocation failed.\n"); dev_warn(dev->dev, "FB allocation failed.\n");
return PTR_ERR(exynos_gem_obj); return PTR_ERR(exynos_gem);
} }
ret = exynos_drm_gem_handle_create(&exynos_gem_obj->base, file_priv, ret = exynos_drm_gem_handle_create(&exynos_gem->base, file_priv,
&args->handle); &args->handle);
if (ret) { if (ret) {
exynos_drm_gem_destroy(exynos_gem_obj); exynos_drm_gem_destroy(exynos_gem);
return ret; return ret;
} }
...@@ -464,7 +467,7 @@ int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv, ...@@ -464,7 +467,7 @@ int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{ {
struct drm_gem_object *obj = vma->vm_private_data; struct drm_gem_object *obj = vma->vm_private_data;
struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj); struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj);
unsigned long pfn; unsigned long pfn;
pgoff_t page_offset; pgoff_t page_offset;
int ret; int ret;
...@@ -472,13 +475,13 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -472,13 +475,13 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
page_offset = ((unsigned long)vmf->virtual_address - page_offset = ((unsigned long)vmf->virtual_address -
vma->vm_start) >> PAGE_SHIFT; vma->vm_start) >> PAGE_SHIFT;
if (page_offset >= (exynos_gem_obj->size >> PAGE_SHIFT)) { if (page_offset >= (exynos_gem->size >> PAGE_SHIFT)) {
DRM_ERROR("invalid page offset\n"); DRM_ERROR("invalid page offset\n");
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
pfn = page_to_pfn(exynos_gem_obj->pages[page_offset]); pfn = page_to_pfn(exynos_gem->pages[page_offset]);
ret = vm_insert_mixed(vma, (unsigned long)vmf->virtual_address, pfn); ret = vm_insert_mixed(vma, (unsigned long)vmf->virtual_address, pfn);
out: out:
...@@ -496,7 +499,7 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -496,7 +499,7 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
struct drm_gem_object *obj; struct drm_gem_object *obj;
int ret; int ret;
...@@ -508,21 +511,21 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -508,21 +511,21 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
} }
obj = vma->vm_private_data; obj = vma->vm_private_data;
exynos_gem_obj = to_exynos_gem_obj(obj); exynos_gem = to_exynos_gem(obj);
DRM_DEBUG_KMS("flags = 0x%x\n", exynos_gem_obj->flags); DRM_DEBUG_KMS("flags = 0x%x\n", exynos_gem->flags);
/* non-cachable as default. */ /* non-cachable as default. */
if (exynos_gem_obj->flags & EXYNOS_BO_CACHABLE) if (exynos_gem->flags & EXYNOS_BO_CACHABLE)
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
else if (exynos_gem_obj->flags & EXYNOS_BO_WC) else if (exynos_gem->flags & EXYNOS_BO_WC)
vma->vm_page_prot = vma->vm_page_prot =
pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
else else
vma->vm_page_prot = vma->vm_page_prot =
pgprot_noncached(vm_get_page_prot(vma->vm_flags)); pgprot_noncached(vm_get_page_prot(vma->vm_flags));
ret = exynos_drm_gem_mmap_buffer(exynos_gem_obj, vma); ret = exynos_drm_gem_mmap_buffer(exynos_gem, vma);
if (ret) if (ret)
goto err_close_vm; goto err_close_vm;
...@@ -537,12 +540,12 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -537,12 +540,12 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
/* low-level interface prime helpers */ /* low-level interface prime helpers */
struct sg_table *exynos_drm_gem_prime_get_sg_table(struct drm_gem_object *obj) struct sg_table *exynos_drm_gem_prime_get_sg_table(struct drm_gem_object *obj)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj); struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj);
int npages; int npages;
npages = exynos_gem_obj->size >> PAGE_SHIFT; npages = exynos_gem->size >> PAGE_SHIFT;
return drm_prime_pages_to_sg(exynos_gem_obj->pages, npages); return drm_prime_pages_to_sg(exynos_gem->pages, npages);
} }
struct drm_gem_object * struct drm_gem_object *
...@@ -550,35 +553,35 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, ...@@ -550,35 +553,35 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct dma_buf_attachment *attach,
struct sg_table *sgt) struct sg_table *sgt)
{ {
struct exynos_drm_gem_obj *exynos_gem_obj; struct exynos_drm_gem *exynos_gem;
int npages; int npages;
int ret; int ret;
exynos_gem_obj = exynos_drm_gem_init(dev, attach->dmabuf->size); exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size);
if (IS_ERR(exynos_gem_obj)) { if (IS_ERR(exynos_gem)) {
ret = PTR_ERR(exynos_gem_obj); ret = PTR_ERR(exynos_gem);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
exynos_gem_obj->dma_addr = sg_dma_address(sgt->sgl); exynos_gem->dma_addr = sg_dma_address(sgt->sgl);
npages = exynos_gem_obj->size >> PAGE_SHIFT; npages = exynos_gem->size >> PAGE_SHIFT;
exynos_gem_obj->pages = drm_malloc_ab(npages, sizeof(struct page *)); exynos_gem->pages = drm_malloc_ab(npages, sizeof(struct page *));
if (!exynos_gem_obj->pages) { if (!exynos_gem->pages) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
ret = drm_prime_sg_to_page_addr_arrays(sgt, exynos_gem_obj->pages, NULL, ret = drm_prime_sg_to_page_addr_arrays(sgt, exynos_gem->pages, NULL,
npages); npages);
if (ret < 0) if (ret < 0)
goto err_free_large; goto err_free_large;
exynos_gem_obj->sgt = sgt; exynos_gem->sgt = sgt;
if (sgt->nents == 1) { if (sgt->nents == 1) {
/* always physically continuous memory if sgt->nents is 1. */ /* always physically continuous memory if sgt->nents is 1. */
exynos_gem_obj->flags |= EXYNOS_BO_CONTIG; exynos_gem->flags |= EXYNOS_BO_CONTIG;
} else { } else {
/* /*
* this case could be CONTIG or NONCONTIG type but for now * this case could be CONTIG or NONCONTIG type but for now
...@@ -586,16 +589,16 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev, ...@@ -586,16 +589,16 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
* TODO. we have to find a way that exporter can notify * TODO. we have to find a way that exporter can notify
* the type of its own buffer to importer. * the type of its own buffer to importer.
*/ */
exynos_gem_obj->flags |= EXYNOS_BO_NONCONTIG; exynos_gem->flags |= EXYNOS_BO_NONCONTIG;
} }
return &exynos_gem_obj->base; return &exynos_gem->base;
err_free_large: err_free_large:
drm_free_large(exynos_gem_obj->pages); drm_free_large(exynos_gem->pages);
err: err:
drm_gem_object_release(&exynos_gem_obj->base); drm_gem_object_release(&exynos_gem->base);
kfree(exynos_gem_obj); kfree(exynos_gem);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
#define to_exynos_gem_obj(x) container_of(x,\ #define to_exynos_gem(x) container_of(x, struct exynos_drm_gem, base)
struct exynos_drm_gem_obj, base)
#define IS_NONCONTIG_BUFFER(f) (f & EXYNOS_BO_NONCONTIG) #define IS_NONCONTIG_BUFFER(f) (f & EXYNOS_BO_NONCONTIG)
...@@ -44,7 +43,7 @@ ...@@ -44,7 +43,7 @@
* P.S. this object would be transferred to user as kms_bo.handle so * P.S. this object would be transferred to user as kms_bo.handle so
* user can access the buffer through kms_bo.handle. * user can access the buffer through kms_bo.handle.
*/ */
struct exynos_drm_gem_obj { struct exynos_drm_gem {
struct drm_gem_object base; struct drm_gem_object base;
unsigned int flags; unsigned int flags;
unsigned long size; unsigned long size;
...@@ -59,10 +58,10 @@ struct exynos_drm_gem_obj { ...@@ -59,10 +58,10 @@ struct exynos_drm_gem_obj {
struct page **exynos_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask); struct page **exynos_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask);
/* destroy a buffer with gem object */ /* destroy a buffer with gem object */
void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj); void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem);
/* create a new buffer with gem object */ /* create a new buffer with gem object */
struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev, struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
unsigned int flags, unsigned int flags,
unsigned long size); unsigned long size);
...@@ -106,7 +105,7 @@ unsigned long exynos_drm_gem_get_size(struct drm_device *dev, ...@@ -106,7 +105,7 @@ unsigned long exynos_drm_gem_get_size(struct drm_device *dev,
struct drm_file *file_priv); struct drm_file *file_priv);
/* free gem object. */ /* free gem object. */
void exynos_drm_gem_free_object(struct drm_gem_object *gem_obj); void exynos_drm_gem_free_object(struct drm_gem_object *obj);
/* create memory region for drm framebuffer. */ /* create memory region for drm framebuffer. */
int exynos_drm_gem_dumb_create(struct drm_file *file_priv, int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
......
...@@ -128,15 +128,14 @@ static int exynos_plane_atomic_check(struct drm_plane *plane, ...@@ -128,15 +128,14 @@ static int exynos_plane_atomic_check(struct drm_plane *plane,
nr = drm_format_num_planes(state->fb->pixel_format); nr = drm_format_num_planes(state->fb->pixel_format);
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
struct exynos_drm_gem_obj *obj = struct exynos_drm_gem *exynos_gem =
exynos_drm_fb_gem_obj(state->fb, i); exynos_drm_fb_gem(state->fb, i);
if (!exynos_gem) {
if (!obj) {
DRM_DEBUG_KMS("gem object is null\n"); DRM_DEBUG_KMS("gem object is null\n");
return -EFAULT; return -EFAULT;
} }
exynos_plane->dma_addr[i] = obj->dma_addr + exynos_plane->dma_addr[i] = exynos_gem->dma_addr +
state->fb->offsets[i]; state->fb->offsets[i];
DRM_DEBUG_KMS("buffer: %d, dma_addr = 0x%lx\n", DRM_DEBUG_KMS("buffer: %d, dma_addr = 0x%lx\n",
......
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