Commit a0724fcf authored by Pekka Paalanen's avatar Pekka Paalanen Committed by Dave Airlie

drm/ttm: optimize bo_kmap_type values

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: default avatarPekka Paalanen <pq@iki.fi>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 949ef70e
...@@ -245,14 +245,15 @@ struct ttm_buffer_object { ...@@ -245,14 +245,15 @@ struct ttm_buffer_object {
* premapped region. * premapped region.
*/ */
#define TTM_BO_MAP_IOMEM_MASK 0x80
struct ttm_bo_kmap_obj { struct ttm_bo_kmap_obj {
void *virtual; void *virtual;
struct page *page; struct page *page;
enum { enum {
ttm_bo_map_iomap, ttm_bo_map_iomap = 1 | TTM_BO_MAP_IOMEM_MASK,
ttm_bo_map_vmap, ttm_bo_map_vmap = 2,
ttm_bo_map_kmap, ttm_bo_map_kmap = 3,
ttm_bo_map_premapped, ttm_bo_map_premapped = 4 | TTM_BO_MAP_IOMEM_MASK,
} bo_kmap_type; } bo_kmap_type;
}; };
...@@ -522,8 +523,7 @@ extern int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_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, static inline void *ttm_kmap_obj_virtual(struct ttm_bo_kmap_obj *map,
bool *is_iomem) bool *is_iomem)
{ {
*is_iomem = (map->bo_kmap_type == ttm_bo_map_iomap || *is_iomem = !!(map->bo_kmap_type & TTM_BO_MAP_IOMEM_MASK);
map->bo_kmap_type == ttm_bo_map_premapped);
return map->virtual; return map->virtual;
} }
......
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