A micro-optimization on the function ttm_kmap_obj_virtual().

By defining the values of enum ttm_bo_kmap_obj::bo_kmap_type to have a
bit indicating iomem, size of the function ttm_kmap_obj_virtual() will be
reduced by 16 bytes on x86_64 (gcc 4.1.2).

ttm_kmap_obj_virtual() may be heavily used, when buffer objects are
accessed via wrappers, that work for both kinds of memory addresses:
iomem cookies and kernel virtual.

Signed-off-by: Pekka Paalanen <[email protected]>
---
 include/drm/ttm/ttm_bo_api.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index cd22ab4..99dc521 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -245,14 +245,15 @@ struct ttm_buffer_object {
  * premapped region.
  */
 
+#define TTM_BO_MAP_IOMEM_MASK 0x80
 struct ttm_bo_kmap_obj {
        void *virtual;
        struct page *page;
        enum {
-               ttm_bo_map_iomap,
-               ttm_bo_map_vmap,
-               ttm_bo_map_kmap,
-               ttm_bo_map_premapped,
+               ttm_bo_map_iomap        = 1 | TTM_BO_MAP_IOMEM_MASK,
+               ttm_bo_map_vmap         = 2,
+               ttm_bo_map_kmap         = 3,
+               ttm_bo_map_premapped    = 4 | TTM_BO_MAP_IOMEM_MASK,
        } bo_kmap_type;
 };
 
@@ -522,8 +523,7 @@ extern int ttm_bo_evict_mm(struct ttm_bo_device *bdev, 
unsigned mem_type);
 static inline void *ttm_kmap_obj_virtual(struct ttm_bo_kmap_obj *map,
                                         bool *is_iomem)
 {
-       *is_iomem = (map->bo_kmap_type == ttm_bo_map_iomap ||
-                    map->bo_kmap_type == ttm_bo_map_premapped);
+       *is_iomem = !!(map->bo_kmap_type & TTM_BO_MAP_IOMEM_MASK);
        return map->virtual;
 }
 
-- 
1.6.3.3


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to