aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/omap_gem.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-01-03 08:24:19 -0500
committerDavid Herrmann <dh.herrmann@gmail.com>2014-03-16 07:23:33 -0400
commit6796cb16c088905bf3af40548fda68c09e6f6ee5 (patch)
treed40162f17dad7b54ac63feaf62b7c84493556f5a /drivers/gpu/drm/omapdrm/omap_gem.c
parent31bbe16f6d88622d6731fa2cb4ab38d57d844ac1 (diff)
drm: use anon-inode instead of relying on cdevs
DRM drivers share a common address_space across all character-devices of a single DRM device. This allows simple buffer eviction and mapping-control. However, DRM core currently waits for the first ->open() on any char-dev to mark the underlying inode as backing inode of the device. This delayed initialization causes ugly conditions all over the place: if (dev->dev_mapping) do_sth(); To avoid delayed initialization and to stop reusing the inode of the char-dev, we allocate an anonymous inode for each DRM device and reset filp->f_mapping to it on ->open(). Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_gem.c')
-rw-r--r--drivers/gpu/drm/omapdrm/omap_gem.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 5aec3e81fe24..c8d972763889 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -153,24 +153,24 @@ static struct {
153static void evict_entry(struct drm_gem_object *obj, 153static void evict_entry(struct drm_gem_object *obj,
154 enum tiler_fmt fmt, struct usergart_entry *entry) 154 enum tiler_fmt fmt, struct usergart_entry *entry)
155{ 155{
156 if (obj->dev->dev_mapping) { 156 struct omap_gem_object *omap_obj = to_omap_bo(obj);
157 struct omap_gem_object *omap_obj = to_omap_bo(obj); 157 int n = usergart[fmt].height;
158 int n = usergart[fmt].height; 158 size_t size = PAGE_SIZE * n;
159 size_t size = PAGE_SIZE * n; 159 loff_t off = mmap_offset(obj) +
160 loff_t off = mmap_offset(obj) + 160 (entry->obj_pgoff << PAGE_SHIFT);
161 (entry->obj_pgoff << PAGE_SHIFT); 161 const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
162 const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE); 162
163 if (m > 1) { 163 if (m > 1) {
164 int i; 164 int i;
165 /* if stride > than PAGE_SIZE then sparse mapping: */ 165 /* if stride > than PAGE_SIZE then sparse mapping: */
166 for (i = n; i > 0; i--) { 166 for (i = n; i > 0; i--) {
167 unmap_mapping_range(obj->dev->dev_mapping, 167 unmap_mapping_range(obj->dev->anon_inode->i_mapping,
168 off, PAGE_SIZE, 1); 168 off, PAGE_SIZE, 1);
169 off += PAGE_SIZE * m; 169 off += PAGE_SIZE * m;
170 }
171 } else {
172 unmap_mapping_range(obj->dev->dev_mapping, off, size, 1);
173 } 170 }
171 } else {
172 unmap_mapping_range(obj->dev->anon_inode->i_mapping,
173 off, size, 1);
174 } 174 }
175 175
176 entry->obj = NULL; 176 entry->obj = NULL;