diff mbox

[v2] drm/exynos: add exynos drm specific fb_mmap function

Message ID 1353052349-17053-1-git-send-email-prathyush.k@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Prathyush K Nov. 16, 2012, 7:52 a.m. UTC
This patch adds a exynos drm specific implementation of fb_mmap.
The root framebuffer is allocated using dma_alloc_attrs which can
allocate a contig or noncontig buffer depending on whether an iommu
is attached to drm device or not. The default fb_mmap function
always assumes the root fb to be contiguous thus failing in case of
a non-contig buffer.

The exynos drm specific implementation of fb_mmap extracts the private
data from the fb_info and calls dma_mmap_attrs with the parameters
used while allocating the buffer.

Signed-off-by: Prathyush K <prathyush.k@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |   30 +++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

Comments

Inki Dae Nov. 16, 2012, 3:55 p.m. UTC | #1
2012/11/15 Prathyush K <prathyush.k@samsung.com>

> This patch adds a exynos drm specific implementation of fb_mmap.
> The root framebuffer is allocated using dma_alloc_attrs which can
> allocate a contig or noncontig buffer depending on whether an iommu
> is attached to drm device or not. The default fb_mmap function
> always assumes the root fb to be contiguous thus failing in case of
> a non-contig buffer.
>
> The exynos drm specific implementation of fb_mmap extracts the private
> data from the fb_info and calls dma_mmap_attrs with the parameters
> used while allocating the buffer.
>
> Signed-off-by: Prathyush K <prathyush.k@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c |   30
> +++++++++++++++++++++++++++++
>  1 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index 67eb6ba..62314ca 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -46,8 +46,38 @@ struct exynos_drm_fbdev {
>         struct exynos_drm_gem_obj       *exynos_gem_obj;
>  };
>
> +static int exynos_drm_fb_mmap(struct fb_info *info,
> +                       struct vm_area_struct *vma)
> +{
> +       struct drm_fb_helper *helper = info->par;
> +       struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper);
> +       struct exynos_drm_gem_obj *exynos_gem_obj =
> exynos_fbd->exynos_gem_obj;
> +       struct exynos_drm_gem_buf *buffer = exynos_gem_obj->buffer;
> +       unsigned long vm_size;
> +       int ret;
> +
> +       DRM_DEBUG_KMS("%s\n", __func__);
> +
> +       vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
> +
> +       vm_size = vma->vm_end - vma->vm_start;
> +
> +       if (vm_size > buffer->size)
> +               return -EINVAL;
> +
> +       ret = dma_mmap_attrs(helper->dev->dev, vma, buffer->kvaddr,
> +               buffer->dma_addr, vm_size, &buffer->dma_attrs);
>

use original size requested in dma_alloc_attrs instead of vm_size. And
please, leave previous history like below,

For example,

Changelog v2:
new comments such as what is changed, what is added and so on.

Changelog v1:
origin comments.


> +       if (ret < 0) {
> +               DRM_ERROR("failed to mmap.\n");
> +               return ret;
> +       }
> +
> +       return 0;
> +}
> +
>  static struct fb_ops exynos_drm_fb_ops = {
>         .owner          = THIS_MODULE,
> +       .fb_mmap        = exynos_drm_fb_mmap,
>         .fb_fillrect    = cfb_fillrect,
>         .fb_copyarea    = cfb_copyarea,
>         .fb_imageblit   = cfb_imageblit,
> --
> 1.7.0.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 67eb6ba..62314ca 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -46,8 +46,38 @@  struct exynos_drm_fbdev {
 	struct exynos_drm_gem_obj	*exynos_gem_obj;
 };
 
+static int exynos_drm_fb_mmap(struct fb_info *info,
+			struct vm_area_struct *vma)
+{
+	struct drm_fb_helper *helper = info->par;
+	struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper);
+	struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
+	struct exynos_drm_gem_buf *buffer = exynos_gem_obj->buffer;
+	unsigned long vm_size;
+	int ret;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
+
+	vm_size = vma->vm_end - vma->vm_start;
+
+	if (vm_size > buffer->size)
+		return -EINVAL;
+
+	ret = dma_mmap_attrs(helper->dev->dev, vma, buffer->kvaddr,
+		buffer->dma_addr, vm_size, &buffer->dma_attrs);
+	if (ret < 0) {
+		DRM_ERROR("failed to mmap.\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 static struct fb_ops exynos_drm_fb_ops = {
 	.owner		= THIS_MODULE,
+	.fb_mmap        = exynos_drm_fb_mmap,
 	.fb_fillrect	= cfb_fillrect,
 	.fb_copyarea	= cfb_copyarea,
 	.fb_imageblit	= cfb_imageblit,