From: Inki Dae <inki.dae@samsung.com>
To: airlied@linux.ie, dri-devel@lists.freedesktop.org
Cc: Inki Dae <inki.dae@samsung.com>,
kyungmin.park@samsung.com, sw0312.kim@samsung.com
Subject: [PATCH 1/4] drm/exynos: added cache attribute support for gem.
Date: Mon, 23 Apr 2012 22:43:11 +0900 [thread overview]
Message-ID: <1335188594-17454-2-git-send-email-inki.dae@samsung.com> (raw)
In-Reply-To: <1335188594-17454-1-git-send-email-inki.dae@samsung.com>
with this patch, user application can set cache attribute(such as
cachable, writecombime or non-cachable) of the memory region allocated
by gem framework.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/gpu/drm/exynos/exynos_drm_gem.c | 49 ++++++++++++++++++++++++------
include/drm/exynos_drm.h | 11 ++++++-
2 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 01139c8..c85f3a7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -66,6 +66,22 @@ static int check_gem_flags(unsigned int flags)
return 0;
}
+static void update_vm_cache_attr(struct exynos_drm_gem_obj *obj,
+ struct vm_area_struct *vma)
+{
+ DRM_DEBUG_KMS("flags = 0x%x\n", obj->flags);
+
+ /* non-cachable as default. */
+ if (obj->flags & EXYNOS_BO_CACHABLE)
+ vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+ else if (obj->flags & EXYNOS_BO_WC)
+ vma->vm_page_prot =
+ pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+ else
+ vma->vm_page_prot =
+ pgprot_noncached(vm_get_page_prot(vma->vm_flags));
+}
+
static unsigned long roundup_gem_size(unsigned long size, unsigned int flags)
{
if (!IS_NONCONTIG_BUFFER(flags)) {
@@ -262,24 +278,24 @@ static int exynos_drm_gem_handle_create(struct drm_gem_object *obj,
void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj)
{
struct drm_gem_object *obj;
+ struct exynos_drm_gem_buf *buf;
DRM_DEBUG_KMS("%s\n", __FILE__);
- if (!exynos_gem_obj)
- return;
-
obj = &exynos_gem_obj->base;
+ buf = exynos_gem_obj->buffer;
DRM_DEBUG_KMS("handle count = %d\n", atomic_read(&obj->handle_count));
- if ((exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) &&
- exynos_gem_obj->buffer->pages)
+ if (!buf->pages)
+ return;
+
+ if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG)
exynos_drm_gem_put_pages(obj);
else
- exynos_drm_free_buf(obj->dev, exynos_gem_obj->flags,
- exynos_gem_obj->buffer);
+ exynos_drm_free_buf(obj->dev, exynos_gem_obj->flags, buf);
- exynos_drm_fini_buf(obj->dev, exynos_gem_obj->buffer);
+ exynos_drm_fini_buf(obj->dev, buf);
exynos_gem_obj->buffer = NULL;
if (obj->map_list.map)
@@ -493,8 +509,7 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,
vma->vm_flags |= (VM_IO | VM_RESERVED);
- /* in case of direct mapping, always having non-cachable attribute */
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+ update_vm_cache_attr(exynos_gem_obj, vma);
vm_size = usize = vma->vm_end - vma->vm_start;
@@ -726,6 +741,8 @@ 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)
{
+ struct exynos_drm_gem_obj *exynos_gem_obj;
+ struct drm_gem_object *obj;
int ret;
DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -737,8 +754,20 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
return ret;
}
+ obj = vma->vm_private_data;
+ exynos_gem_obj = to_exynos_gem_obj(obj);
+
+ ret = check_gem_flags(exynos_gem_obj->flags);
+ if (ret) {
+ drm_gem_vm_close(vma);
+ drm_gem_free_mmap_offset(obj);
+ return ret;
+ }
+
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
+ update_vm_cache_attr(exynos_gem_obj, vma);
+
return ret;
}
diff --git a/include/drm/exynos_drm.h b/include/drm/exynos_drm.h
index e478de4..2d6eb06 100644
--- a/include/drm/exynos_drm.h
+++ b/include/drm/exynos_drm.h
@@ -95,9 +95,18 @@ struct drm_exynos_plane_set_zpos {
/* memory type definitions. */
enum e_drm_exynos_gem_mem_type {
+ /* Physically Continuous memory and used as default. */
+ EXYNOS_BO_CONTIG = 0 << 0,
/* Physically Non-Continuous memory. */
EXYNOS_BO_NONCONTIG = 1 << 0,
- EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG
+ /* non-cachable mapping and used as default. */
+ EXYNOS_BO_NONCACHABLE = 0 << 1,
+ /* cachable mapping. */
+ EXYNOS_BO_CACHABLE = 1 << 1,
+ /* write-combine mapping. */
+ EXYNOS_BO_WC = 1 << 2,
+ EXYNOS_BO_MASK = EXYNOS_BO_NONCONTIG | EXYNOS_BO_CACHABLE |
+ EXYNOS_BO_WC
};
#define DRM_EXYNOS_GEM_CREATE 0x00
--
1.7.4.1
next prev parent reply other threads:[~2012-04-23 13:43 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 13:43 [PATCH 0/4] updated exynos-drm-next Inki Dae
2012-04-23 13:43 ` Inki Dae [this message]
2012-04-23 13:43 ` [PATCH 2/4] drm/exynos: added drm prime feature Inki Dae
2012-04-23 13:43 ` [PATCH 3/4] drm/exynos: added userptr feature Inki Dae
2012-04-24 5:17 ` [PATCH v2 " Inki Dae
2012-04-25 10:15 ` Dave Airlie
2012-04-25 12:46 ` InKi Dae
2012-05-05 10:19 ` daeinki
2012-05-05 10:22 ` Dave Airlie
2012-05-07 18:18 ` Jerome Glisse
2012-05-08 7:59 ` Inki Dae
2012-05-08 15:05 ` Jerome Glisse
2012-05-08 6:48 ` Inki Dae
2012-05-09 6:17 ` [PATCH 0/2 v3] " Inki Dae
2012-05-09 6:17 ` [PATCH 1/2 v3] drm/exynos: added userptr limit ioctl Inki Dae
2012-05-09 6:17 ` [PATCH 2/2 v3] drm/exynos: added userptr feature Inki Dae
2012-05-09 14:45 ` Jerome Glisse
2012-05-09 18:32 ` Jerome Glisse
2012-05-10 2:44 ` Inki Dae
2012-05-10 15:05 ` Jerome Glisse
2012-05-10 15:31 ` Daniel Vetter
2012-05-10 15:52 ` Jerome Glisse
2012-05-11 1:47 ` Inki Dae
2012-05-11 2:08 ` Minchan Kim
2012-05-10 1:39 ` Inki Dae
2012-05-10 4:58 ` Minchan Kim
2012-05-10 6:53 ` KOSAKI Motohiro
2012-05-10 7:27 ` Minchan Kim
2012-05-10 7:31 ` Kyungmin Park
2012-05-10 7:56 ` Minchan Kim
2012-05-10 7:58 ` Minchan Kim
2012-05-10 6:57 ` Inki Dae
2012-05-10 7:05 ` Minchan Kim
2012-05-10 7:59 ` InKi Dae
2012-05-10 8:11 ` Minchan Kim
2012-05-10 8:44 ` Inki Dae
2012-05-10 17:53 ` KOSAKI Motohiro
2012-05-11 0:50 ` Minchan Kim
2012-05-11 2:51 ` KOSAKI Motohiro
2012-05-11 3:01 ` Jerome Glisse
2012-05-11 21:20 ` KOSAKI Motohiro
2012-05-11 22:22 ` Jerome Glisse
2012-05-11 22:59 ` KOSAKI Motohiro
2012-05-11 23:29 ` Jerome Glisse
2012-05-11 23:39 ` KOSAKI Motohiro
2012-05-12 4:48 ` InKi Dae
2012-05-14 4:29 ` Minchan Kim
2012-05-14 6:17 ` [PATCH 0/2 v4] " Inki Dae
2012-05-14 6:17 ` [PATCH 1/2 v4] drm/exynos: added userptr limit ioctl Inki Dae
2012-05-14 8:12 ` Inki Dae
2012-05-14 6:17 ` [PATCH 2/2 v4] drm/exynos: added userptr feature Inki Dae
2012-05-14 6:33 ` KOSAKI Motohiro
2012-05-14 6:52 ` Inki Dae
2012-05-14 7:04 ` KOSAKI Motohiro
2012-05-14 7:21 ` Inki Dae
2012-05-14 8:13 ` Inki Dae
2012-05-14 19:26 ` Jerome Glisse
2012-05-15 4:33 ` Inki Dae
2012-05-15 14:31 ` Jerome Glisse
2012-05-16 8:49 ` Inki Dae
2012-05-14 8:12 ` [PATCH 0/2 " Inki Dae
2012-05-15 7:34 ` [PATCH 3/4] " Rob Clark
2012-05-15 8:17 ` Inki Dae
2012-05-15 9:35 ` Rob Clark
2012-05-15 13:40 ` InKi Dae
2012-05-15 14:28 ` Rob Clark
2012-05-16 6:04 ` Inki Dae
2012-05-16 8:42 ` Rob Clark
2012-05-16 10:30 ` Inki Dae
2012-05-16 9:22 ` Dave Airlie
2012-05-16 10:20 ` Inki Dae
2012-05-16 12:12 ` Rob Clark
2012-05-16 13:27 ` Inki Dae
2012-04-23 13:43 ` [PATCH 4/4] drm/exynos: added a feature to get gem buffer information Inki Dae
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335188594-17454-2-git-send-email-inki.dae@samsung.com \
--to=inki.dae@samsung.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=kyungmin.park@samsung.com \
--cc=sw0312.kim@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox