diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2017-06-06 17:41:20 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-06-07 00:04:35 -0400 |
commit | 378506a7e600a025131df947a15f9bc23b522690 (patch) | |
tree | ea8f7568e221efb57dfbbcfc82837b937cb11d8b /drivers | |
parent | 943c05bdb53da273c43ec44eec37c6a70409b5e9 (diff) |
drm/amdgpu/gfx: create a common bitmask function (v2)
The same function was duplicated in all the gfx IPs. Use
a single implementation for all.
v2: use static inline (Alex Xie)
Reviewed-by: Alex Xie <AlexBin.Xie@amd.com>
Suggested-by: Andres Rodriguez <andresx7@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 |
5 files changed, 25 insertions, 40 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h index e02044086445..2d846ef1c033 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | |||
@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg); | |||
30 | void amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se, | 30 | void amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se, |
31 | unsigned max_sh); | 31 | unsigned max_sh); |
32 | 32 | ||
33 | /** | ||
34 | * amdgpu_gfx_create_bitmask - create a bitmask | ||
35 | * | ||
36 | * @bit_width: length of the mask | ||
37 | * | ||
38 | * create a variable length bit mask. | ||
39 | * Returns the bitmask. | ||
40 | */ | ||
41 | static inline u32 amdgpu_gfx_create_bitmask(u32 bit_width) | ||
42 | { | ||
43 | return (u32)((1ULL << bit_width) - 1); | ||
44 | } | ||
45 | |||
33 | #endif | 46 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c index c2b4e9fbc616..7b0b3cf16334 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | |||
@@ -1114,11 +1114,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, | |||
1114 | WREG32(mmGRBM_GFX_INDEX, data); | 1114 | WREG32(mmGRBM_GFX_INDEX, data); |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | static u32 gfx_v6_0_create_bitmask(u32 bit_width) | ||
1118 | { | ||
1119 | return (u32)(((u64)1 << bit_width) - 1); | ||
1120 | } | ||
1121 | |||
1122 | static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) | 1117 | static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) |
1123 | { | 1118 | { |
1124 | u32 data, mask; | 1119 | u32 data, mask; |
@@ -1128,8 +1123,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) | |||
1128 | 1123 | ||
1129 | data = REG_GET_FIELD(data, GC_USER_RB_BACKEND_DISABLE, BACKEND_DISABLE); | 1124 | data = REG_GET_FIELD(data, GC_USER_RB_BACKEND_DISABLE, BACKEND_DISABLE); |
1130 | 1125 | ||
1131 | mask = gfx_v6_0_create_bitmask(adev->gfx.config.max_backends_per_se/ | 1126 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_backends_per_se/ |
1132 | adev->gfx.config.max_sh_per_se); | 1127 | adev->gfx.config.max_sh_per_se); |
1133 | 1128 | ||
1134 | return ~data & mask; | 1129 | return ~data & mask; |
1135 | } | 1130 | } |
@@ -1331,7 +1326,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) | |||
1331 | data = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG) | | 1326 | data = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG) | |
1332 | RREG32(mmGC_USER_SHADER_ARRAY_CONFIG); | 1327 | RREG32(mmGC_USER_SHADER_ARRAY_CONFIG); |
1333 | 1328 | ||
1334 | mask = gfx_v6_0_create_bitmask(adev->gfx.config.max_cu_per_sh); | 1329 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_cu_per_sh); |
1335 | return ~REG_GET_FIELD(data, CC_GC_SHADER_ARRAY_CONFIG, INACTIVE_CUS) & mask; | 1330 | return ~REG_GET_FIELD(data, CC_GC_SHADER_ARRAY_CONFIG, INACTIVE_CUS) & mask; |
1336 | } | 1331 | } |
1337 | 1332 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index ae9861134f8b..4c04e9dec28b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, | |||
1608 | } | 1608 | } |
1609 | 1609 | ||
1610 | /** | 1610 | /** |
1611 | * gfx_v7_0_create_bitmask - create a bitmask | ||
1612 | * | ||
1613 | * @bit_width: length of the mask | ||
1614 | * | ||
1615 | * create a variable length bit mask (CIK). | ||
1616 | * Returns the bitmask. | ||
1617 | */ | ||
1618 | static u32 gfx_v7_0_create_bitmask(u32 bit_width) | ||
1619 | { | ||
1620 | return (u32)((1ULL << bit_width) - 1); | ||
1621 | } | ||
1622 | |||
1623 | /** | ||
1624 | * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs | 1611 | * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs |
1625 | * | 1612 | * |
1626 | * @adev: amdgpu_device pointer | 1613 | * @adev: amdgpu_device pointer |
@@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) | |||
1638 | data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK; | 1625 | data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK; |
1639 | data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT; | 1626 | data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT; |
1640 | 1627 | ||
1641 | mask = gfx_v7_0_create_bitmask(adev->gfx.config.max_backends_per_se / | 1628 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_backends_per_se / |
1642 | adev->gfx.config.max_sh_per_se); | 1629 | adev->gfx.config.max_sh_per_se); |
1643 | 1630 | ||
1644 | return (~data) & mask; | 1631 | return (~data) & mask; |
1645 | } | 1632 | } |
@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) | |||
4157 | data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK; | 4144 | data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK; |
4158 | data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT; | 4145 | data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT; |
4159 | 4146 | ||
4160 | mask = gfx_v7_0_create_bitmask(adev->gfx.config.max_cu_per_sh); | 4147 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_cu_per_sh); |
4161 | 4148 | ||
4162 | return (~data) & mask; | 4149 | return (~data) & mask; |
4163 | } | 4150 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index afd7d6518aaa..ad2e0bba5c93 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev, | |||
3635 | WREG32(mmGRBM_GFX_INDEX, data); | 3635 | WREG32(mmGRBM_GFX_INDEX, data); |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | static u32 gfx_v8_0_create_bitmask(u32 bit_width) | ||
3639 | { | ||
3640 | return (u32)((1ULL << bit_width) - 1); | ||
3641 | } | ||
3642 | |||
3643 | static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) | 3638 | static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) |
3644 | { | 3639 | { |
3645 | u32 data, mask; | 3640 | u32 data, mask; |
@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) | |||
3649 | 3644 | ||
3650 | data = REG_GET_FIELD(data, GC_USER_RB_BACKEND_DISABLE, BACKEND_DISABLE); | 3645 | data = REG_GET_FIELD(data, GC_USER_RB_BACKEND_DISABLE, BACKEND_DISABLE); |
3651 | 3646 | ||
3652 | mask = gfx_v8_0_create_bitmask(adev->gfx.config.max_backends_per_se / | 3647 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_backends_per_se / |
3653 | adev->gfx.config.max_sh_per_se); | 3648 | adev->gfx.config.max_sh_per_se); |
3654 | 3649 | ||
3655 | return (~data) & mask; | 3650 | return (~data) & mask; |
3656 | } | 3651 | } |
@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) | |||
7150 | data = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG) | | 7145 | data = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG) | |
7151 | RREG32(mmGC_USER_SHADER_ARRAY_CONFIG); | 7146 | RREG32(mmGC_USER_SHADER_ARRAY_CONFIG); |
7152 | 7147 | ||
7153 | mask = gfx_v8_0_create_bitmask(adev->gfx.config.max_cu_per_sh); | 7148 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_cu_per_sh); |
7154 | 7149 | ||
7155 | return ~REG_GET_FIELD(data, CC_GC_SHADER_ARRAY_CONFIG, INACTIVE_CUS) & mask; | 7150 | return ~REG_GET_FIELD(data, CC_GC_SHADER_ARRAY_CONFIG, INACTIVE_CUS) & mask; |
7156 | } | 7151 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 276dc06345af..cf15a350d9bf 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh | |||
1698 | WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data); | 1698 | WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data); |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | static u32 gfx_v9_0_create_bitmask(u32 bit_width) | ||
1702 | { | ||
1703 | return (u32)((1ULL << bit_width) - 1); | ||
1704 | } | ||
1705 | |||
1706 | static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) | 1701 | static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) |
1707 | { | 1702 | { |
1708 | u32 data, mask; | 1703 | u32 data, mask; |
@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) | |||
1713 | data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK; | 1708 | data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK; |
1714 | data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT; | 1709 | data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT; |
1715 | 1710 | ||
1716 | mask = gfx_v9_0_create_bitmask(adev->gfx.config.max_backends_per_se / | 1711 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_backends_per_se / |
1717 | adev->gfx.config.max_sh_per_se); | 1712 | adev->gfx.config.max_sh_per_se); |
1718 | 1713 | ||
1719 | return (~data) & mask; | 1714 | return (~data) & mask; |
1720 | } | 1715 | } |
@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) | |||
4609 | data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK; | 4604 | data &= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK; |
4610 | data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT; | 4605 | data >>= CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT; |
4611 | 4606 | ||
4612 | mask = gfx_v9_0_create_bitmask(adev->gfx.config.max_cu_per_sh); | 4607 | mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_cu_per_sh); |
4613 | 4608 | ||
4614 | return (~data) & mask; | 4609 | return (~data) & mask; |
4615 | } | 4610 | } |