Skip to content

Commit

Permalink
drm/ttm: optimize bo_kmap_type values
Browse files Browse the repository at this point in the history
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 <pq@iki.fi>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Pekka Paalanen authored and Dave Airlie committed Aug 19, 2009
1 parent 949ef70 commit a0724fc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/drm/ttm/ttm_bo_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a0724fc

Please sign in to comment.