diff options
author | Imre Deak <imre.deak@intel.com> | 2013-01-07 14:47:33 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-01-17 16:07:54 -0500 |
commit | d865110cc2345d67752cd7e1350b391c34feb2aa (patch) | |
tree | 1b2312cf70ccf77cdb6de2ac2b4c0f8f241051b1 /drivers/gpu/drm/i915/i915_gem.c | |
parent | af5163acd8319dbc901bb59a8d503d8bb774d88b (diff) |
drm/i915: merge get_gtt_alignment/get_unfenced_gtt_alignment()
The two functions are rather similar, so merge them.
Signed-off-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index e6cc020ea32c..2166b61053c6 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1463,16 +1463,15 @@ i915_gem_get_gtt_size(struct drm_device *dev, uint32_t size, int tiling_mode) | |||
1463 | * Return the required GTT alignment for an object, taking into account | 1463 | * Return the required GTT alignment for an object, taking into account |
1464 | * potential fence register mapping. | 1464 | * potential fence register mapping. |
1465 | */ | 1465 | */ |
1466 | static uint32_t | 1466 | uint32_t |
1467 | i915_gem_get_gtt_alignment(struct drm_device *dev, | 1467 | i915_gem_get_gtt_alignment(struct drm_device *dev, uint32_t size, |
1468 | uint32_t size, | 1468 | int tiling_mode, bool fenced) |
1469 | int tiling_mode) | ||
1470 | { | 1469 | { |
1471 | /* | 1470 | /* |
1472 | * Minimum alignment is 4k (GTT page size), but might be greater | 1471 | * Minimum alignment is 4k (GTT page size), but might be greater |
1473 | * if a fence register is needed for the object. | 1472 | * if a fence register is needed for the object. |
1474 | */ | 1473 | */ |
1475 | if (INTEL_INFO(dev)->gen >= 4 || | 1474 | if (INTEL_INFO(dev)->gen >= 4 || (!fenced && IS_G33(dev)) || |
1476 | tiling_mode == I915_TILING_NONE) | 1475 | tiling_mode == I915_TILING_NONE) |
1477 | return 4096; | 1476 | return 4096; |
1478 | 1477 | ||
@@ -1483,35 +1482,6 @@ i915_gem_get_gtt_alignment(struct drm_device *dev, | |||
1483 | return i915_gem_get_gtt_size(dev, size, tiling_mode); | 1482 | return i915_gem_get_gtt_size(dev, size, tiling_mode); |
1484 | } | 1483 | } |
1485 | 1484 | ||
1486 | /** | ||
1487 | * i915_gem_get_unfenced_gtt_alignment - return required GTT alignment for an | ||
1488 | * unfenced object | ||
1489 | * @dev: the device | ||
1490 | * @size: size of the object | ||
1491 | * @tiling_mode: tiling mode of the object | ||
1492 | * | ||
1493 | * Return the required GTT alignment for an object, only taking into account | ||
1494 | * unfenced tiled surface requirements. | ||
1495 | */ | ||
1496 | uint32_t | ||
1497 | i915_gem_get_unfenced_gtt_alignment(struct drm_device *dev, | ||
1498 | uint32_t size, | ||
1499 | int tiling_mode) | ||
1500 | { | ||
1501 | /* | ||
1502 | * Minimum alignment is 4k (GTT page size) for sane hw. | ||
1503 | */ | ||
1504 | if (INTEL_INFO(dev)->gen >= 4 || IS_G33(dev) || | ||
1505 | tiling_mode == I915_TILING_NONE) | ||
1506 | return 4096; | ||
1507 | |||
1508 | /* Previous hardware however needs to be aligned to a power-of-two | ||
1509 | * tile height. The simplest method for determining this is to reuse | ||
1510 | * the power-of-tile object size. | ||
1511 | */ | ||
1512 | return i915_gem_get_gtt_size(dev, size, tiling_mode); | ||
1513 | } | ||
1514 | |||
1515 | static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj) | 1485 | static int i915_gem_object_create_mmap_offset(struct drm_i915_gem_object *obj) |
1516 | { | 1486 | { |
1517 | struct drm_i915_private *dev_priv = obj->base.dev->dev_private; | 1487 | struct drm_i915_private *dev_priv = obj->base.dev->dev_private; |
@@ -2934,11 +2904,11 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj, | |||
2934 | obj->tiling_mode); | 2904 | obj->tiling_mode); |
2935 | fence_alignment = i915_gem_get_gtt_alignment(dev, | 2905 | fence_alignment = i915_gem_get_gtt_alignment(dev, |
2936 | obj->base.size, | 2906 | obj->base.size, |
2937 | obj->tiling_mode); | 2907 | obj->tiling_mode, true); |
2938 | unfenced_alignment = | 2908 | unfenced_alignment = |
2939 | i915_gem_get_unfenced_gtt_alignment(dev, | 2909 | i915_gem_get_gtt_alignment(dev, |
2940 | obj->base.size, | 2910 | obj->base.size, |
2941 | obj->tiling_mode); | 2911 | obj->tiling_mode, false); |
2942 | 2912 | ||
2943 | if (alignment == 0) | 2913 | if (alignment == 0) |
2944 | alignment = map_and_fenceable ? fence_alignment : | 2914 | alignment = map_and_fenceable ? fence_alignment : |