drm/amdgpu/gfx: create a common bitmask function (v2)
Subsystems (2)
PATCH 1/1 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)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 +++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 +++-------- 5 files changed, 25 insertions(+), 40 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +13 -0
@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);void amdgpu_gfx_parse_disable_cu (unsigned *mask,unsigned max_se,unsigned max_sh); +/** +* amdgpu_gfx_create_bitmask - create a bitmask +* +* @bit_width: length of the mask +* +* create a variable length bit mask. +* Returns the bitmask. +*/ +static inline u32 amdgpu_gfx_create_bitmask (u32 bit_width) +{ +return (u32)((1ULL << bit_width) -1 ); +} +#endif
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3 -8
@@ -1116,11 +1116,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v6_0_create_bitmask (u32 bit_width) -{ -return (u32)(((u64 )1 << bit_width) -1 ); -} -static u32 gfx_v6_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;
@@ -1130,8 +1125,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_backends_per_se/ - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se/ + adev->gfx.config.max_sh_per_se);return ~data & mask; }
@@ -1333,7 +1328,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +3 -16
@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, }/** -* gfx_v7_0_create_bitmask - create a bitmask -* -* @bit_width: length of the mask -* -* create a variable length bit mask (CIK). -* Returns the bitmask. -*/ -static u32 gfx_v7_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} - -/** * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs * * @adev: amdgpu_device pointer
@@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }
@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -8
@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v8_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;
@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }
@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -8
@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 shWREG32_SOC15 (GC ,0 , mmGRBM_GFX_INDEX, data); } -static u32 gfx_v9_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v9_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;
@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }
@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1496787583-2883-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org
axie
Reviewed-by Alex XieThanks for the change. "static inline" may improve speed, though this patch is not a critical code path. Perhaps it will be true in future...
Quoted 181 lines · Alex Deucher
The same function was duplicated in all the gfx IPs. Use a single implementation for all.
v2: use static inline (Alex Xie)
Suggested-by Andres Rodriguez <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 +++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 +++-------- 5 files changed, 25 insertions(+), 40 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +13
-0@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);void amdgpu_gfx_parse_disable_cu (unsigned *mask,unsigned max_se,unsigned max_sh); +/** +* amdgpu_gfx_create_bitmask - create a bitmask +* +* @bit_width: length of the mask +* +* create a variable length bit mask. +* Returns the bitmask. +*/ +static inline u32 amdgpu_gfx_create_bitmask (u32 bit_width) +{ +return (u32)((1ULL << bit_width) -1 ); +} +#endif drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3
-8@@ -1116,11 +1116,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v6_0_create_bitmask (u32 bit_width) -{ -return (u32)(((u64 )1 << bit_width) -1 ); -} -static u32 gfx_v6_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1130,8 +1125,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_backends_per_se/ - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se/ + adev->gfx.config.max_sh_per_se);return ~data & mask; }@@ -1333,7 +1328,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +3
-16@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, }/** -* gfx_v7_0_create_bitmask - create a bitmask -* -* @bit_width: length of the mask -* -* create a variable length bit mask (CIK). -* Returns the bitmask. -*/ -static u32 gfx_v7_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} - -/** * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs * * @adev: amdgpu_device pointer @@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-8@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v8_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-7@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 shWREG32_SOC15 (GC ,0 , mmGRBM_GFX_INDEX, data); } -static u32 gfx_v9_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v9_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) · line 4610
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 2e78fcdb-42d8-625b-f1cb-ac92eff8bec9-5C7GfCeVMHo@public.gmane.org
Actually we should only use static inline if we have to, see "15) The inline disease" in the coding style document, but for this case it actually looks valid to me as well.
But wasn't there a macro for this in the Linux kernel headers we should use?
Regards,
Christian.
Am 07.06.2017 um 00:36 schrieb axie:
Quoted 194 lines
Thanks for the change. "static inline" may improve speed, though this patch is not a critical code path. Perhaps it will be true in future...
Reviewed-by Alex Xie <[email protected]>Quoted 187 lines · Alex Deucher
The same function was duplicated in all the gfx IPs. Use a single implementation for all.
v2: use static inline (Alex Xie)
Suggested-by Andres Rodriguez<[email protected]>Signed-off-by Alex Deucher<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 +++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 +++-------- 5 files changed, 25 insertions(+), 40 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +13
-0@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);void amdgpu_gfx_parse_disable_cu (unsigned *mask,unsigned max_se,unsigned max_sh); +/** +* amdgpu_gfx_create_bitmask - create a bitmask +* +* @bit_width: length of the mask +* +* create a variable length bit mask. +* Returns the bitmask. +*/ +static inline u32 amdgpu_gfx_create_bitmask (u32 bit_width) +{ +return (u32)((1ULL << bit_width) -1 ); +} +#endif drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3
-8@@ -1116,11 +1116,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v6_0_create_bitmask (u32 bit_width) -{ -return (u32)(((u64 )1 << bit_width) -1 ); -} -static u32 gfx_v6_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1130,8 +1125,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_backends_per_se/ - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se/ + adev->gfx.config.max_sh_per_se);return ~data & mask; }@@ -1333,7 +1328,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +3
-16@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, }/** -* gfx_v7_0_create_bitmask - create a bitmask -* -* @bit_width: length of the mask -* -* create a variable length bit mask (CIK). -* Returns the bitmask. -*/ -static u32 gfx_v7_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} - -/** * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs * * @adev: amdgpu_device pointer @@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-8@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v8_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3
-8@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 shWREG32_SOC15 (GC ,0 , mmGRBM_GFX_INDEX, data); } -static u32 gfx_v9_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v9_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) · line 4610
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0return (~data) & mask; }_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): ff35985a-bfb4-768d-5c26-b5bbb23e2249-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Hi Christian,
Which macro do you want to use to replace this function?
The function is small so that we use a "static inline". I agree that large function should not use "static inline". Thanks for point that out.
Alex Bin Xie
Quoted 213 lines · Christian König
Actually we should only use static inline if we have to, see "15) The inline disease" in the coding style document, but for this case it actually looks valid to me as well.
But wasn't there a macro for this in the Linux kernel headers we should use?
Regards,
Christian.Am 07.06.2017 um 00:36 schrieb axie:
Quoted 203 lines
Thanks for the change. "static inline" may improve speed, though this patch is not a critical code path. Perhaps it will be true in future...
Reviewed-by Alex Xie <[email protected]>Quoted 181 lines · Alex Deucher
The same function was duplicated in all the gfx IPs. Use a single implementation for all.
v2: use static inline (Alex Xie)
Suggested-by Andres Rodriguez<[email protected]>Signed-off-by Alex Deucher<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 +++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 +++-------- 5 files changed, 25 insertions(+), 40 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +13
-0@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);void amdgpu_gfx_parse_disable_cu (unsigned *mask,unsigned max_se,unsigned max_sh); +/** +* amdgpu_gfx_create_bitmask - create a bitmask +* +* @bit_width: length of the mask +* +* create a variable length bit mask. +* Returns the bitmask. +*/ +static inline u32 amdgpu_gfx_create_bitmask (u32 bit_width) +{ +return (u32)((1ULL << bit_width) -1 ); +} +#endif drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3
-8@@ -1116,11 +1116,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v6_0_create_bitmask (u32 bit_width) -{ -return (u32)(((u64 )1 << bit_width) -1 ); -} -static u32 gfx_v6_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1130,8 +1125,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_backends_per_se/ - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se/ + adev->gfx.config.max_sh_per_se);return ~data & mask; }@@ -1333,7 +1328,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +3
-16@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, }/** -* gfx_v7_0_create_bitmask - create a bitmask -* -* @bit_width: length of the mask -* -* create a variable length bit mask (CIK). -* Returns the bitmask. -*/ -static u32 gfx_v7_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} - -/** * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs * * @adev: amdgpu_device pointer @@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-8@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v8_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-7@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 shWREG32_SOC15 (GC ,0 , mmGRBM_GFX_INDEX, data); } -static u32 gfx_v9_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v9_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) · line 4610
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a12e2a24-5b59-1214-0411-eb487630afcc-5C7GfCeVMHo@public.gmane.org
Quoted 1 line
Which macro do you want to use to replace this function?
I thought about using GENMASK() here, but that's not a must have.
On the other hand we should probably consider using GENMASK() for our register headers.
The parameters of the marco matches how our internal register database works, so that looks like a perfect fit.
Regards,
Christian.
Am 08.06.2017 um 16:42 schrieb axie:
Quoted 7 lines
Hi Christian,
Which macro do you want to use to replace this function?
Quoted 221 lines
The function is small so that we use a "static inline". I agree that large function should not use "static inline". Thanks for point that out.
Alex Bin Xie
Quoted 213 lines · Christian König
Actually we should only use static inline if we have to, see "15) The inline disease" in the coding style document, but for this case it actually looks valid to me as well.
But wasn't there a macro for this in the Linux kernel headers we should use?
Regards,
Christian.Am 07.06.2017 um 00:36 schrieb axie:
Quoted 203 lines
Thanks for the change. "static inline" may improve speed, though this patch is not a critical code path. Perhaps it will be true in future...
Reviewed-by Alex Xie <[email protected]>Quoted 181 lines · Alex Deucher
The same function was duplicated in all the gfx IPs. Use a single implementation for all.
v2: use static inline (Alex Xie)
Suggested-by Andres Rodriguez<[email protected]>Signed-off-by Alex Deucher<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 +++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 +++-------- 5 files changed, 25 insertions(+), 40 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +13
-0@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);void amdgpu_gfx_parse_disable_cu (unsigned *mask,unsigned max_se,unsigned max_sh); +/** +* amdgpu_gfx_create_bitmask - create a bitmask +* +* @bit_width: length of the mask +* +* create a variable length bit mask. +* Returns the bitmask. +*/ +static inline u32 amdgpu_gfx_create_bitmask (u32 bit_width) +{ +return (u32)((1ULL << bit_width) -1 ); +} +#endif drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3
-8@@ -1116,11 +1116,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v6_0_create_bitmask (u32 bit_width) -{ -return (u32)(((u64 )1 << bit_width) -1 ); -} -static u32 gfx_v6_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1130,8 +1125,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_backends_per_se/ - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se/ + adev->gfx.config.max_sh_per_se);return ~data & mask; }@@ -1333,7 +1328,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +3
-16@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, }/** -* gfx_v7_0_create_bitmask - create a bitmask -* -* @bit_width: length of the mask -* -* create a variable length bit mask (CIK). -* Returns the bitmask. -*/ -static u32 gfx_v7_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} - -/** * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs * * @adev: amdgpu_device pointer @@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-8@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v8_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-7@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 shWREG32_SOC15 (GC ,0 , mmGRBM_GFX_INDEX, data); } -static u32 gfx_v9_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v9_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) · line 4610
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): b588db42-2d15-8d9d-f636-3b8ab246d38c-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
#define GENMASK <http://elixir.free-electrons.com/linux/v4.0.9/ident/GENMASK>(h, l) \
(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG <http://elixir.free-electrons.com/linux/v4.0.9/ident/BITS_PER_LONG> - 1 - (h)))) I think we can use GENMASK though it is slightly overkill and slower (Three more operations in total). We also need to generate two parameters for the macro. If we don't use GENMASK. We can use its method on how to generate the bitmask, which is easier to understand. New: (~0UL >> (BITS_PER_LONG <http://elixir.free-electrons.com/linux/v4.0.9/ident/BITS_PER_LONG> - bit_width) //note that bit_width is different from h parameter in the GENMASK.
Old:
(u32)((1ULL << bit_width) - 1);
Thanks,
Alex Bin
Quoted 240 lines · Christian König
Quoted 1 line
Which macro do you want to use to replace this function?
I thought about using
GENMASK()here, but that's not a must have.On the other hand we should probably consider using
GENMASK()for our register headers.The parameters of the marco matches how our internal register database works, so that looks like a perfect fit.
Regards,
Christian.Am 08.06.2017 um 16:42 schrieb axie:
Quoted 228 lines
Hi Christian,
Which macro do you want to use to replace this function?
The function is small so that we use a "static inline". I agree that large function should not use "static inline". Thanks for point that out.
Alex Bin Xie
Quoted 213 lines · Christian König
Actually we should only use static inline if we have to, see "15) The inline disease" in the coding style document, but for this case it actually looks valid to me as well.
But wasn't there a macro for this in the Linux kernel headers we should use?
Regards,
Christian.Am 07.06.2017 um 00:36 schrieb axie:
Quoted 203 lines
Thanks for the change. "static inline" may improve speed, though this patch is not a critical code path. Perhaps it will be true in future...
Reviewed-by Alex Xie <[email protected]>Quoted 181 lines · Alex Deucher
The same function was duplicated in all the gfx IPs. Use a single implementation for all.
v2: use static inline (Alex Xie)
Suggested-by Andres Rodriguez<[email protected]>Signed-off-by Alex Deucher<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 19 +++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 11 +++-------- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 11 +++-------- 5 files changed, 25 insertions(+), 40 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +13
-0@@ -30,4 +30,17 @@ void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);void amdgpu_gfx_parse_disable_cu (unsigned *mask,unsigned max_se,unsigned max_sh); +/** +* amdgpu_gfx_create_bitmask - create a bitmask +* +* @bit_width: length of the mask +* +* create a variable length bit mask. +* Returns the bitmask. +*/ +static inline u32 amdgpu_gfx_create_bitmask (u32 bit_width) +{ +return (u32)((1ULL << bit_width) -1 ); +} +#endif drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3
-8@@ -1116,11 +1116,6 @@ static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v6_0_create_bitmask (u32 bit_width) -{ -return (u32)(((u64 )1 << bit_width) -1 ); -} -static u32 gfx_v6_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1130,8 +1125,8 @@ static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_backends_per_se/ - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se/ + adev->gfx.config.max_sh_per_se);return ~data & mask; }@@ -1333,7 +1328,7 @@ static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v6_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +3
-16@@ -1608,19 +1608,6 @@ static void gfx_v7_0_select_se_sh(struct amdgpu_device *adev, }/** -* gfx_v7_0_create_bitmask - create a bitmask -* -* @bit_width: length of the mask -* -* create a variable length bit mask (CIK). -* Returns the bitmask. -*/ -static u32 gfx_v7_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} - -/** * gfx_v7_0_get_rb_active_bitmap - computes the mask of enabled RBs * * @adev: amdgpu_device pointer @@ -1638,8 +1625,8 @@ static u32 gfx_v7_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -4157,7 +4144,7 @@ static u32 gfx_v7_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v7_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3
-8@@ -3635,11 +3635,6 @@ static void gfx_v8_0_select_se_sh(struct amdgpu_device *adev,WREG32 (mmGRBM_GFX_INDEX, data); } -static u32 gfx_v8_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v8_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -3649,8 +3644,8 @@ static u32 gfx_v8_0_get_rb_active_bitmap(struct amdgpu_device *adev) data =REG_GET_FIELD (data,GC_USER_RB_BACKEND_DISABLE ,BACKEND_DISABLE ); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }@@ -7150,7 +7145,7 @@ static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev) data =RREG32 (mmCC_GC_SHADER_ARRAY_CONFIG) |RREG32 (mmGC_USER_SHADER_ARRAY_CONFIG); - mask =gfx_v8_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return ~REG_GET_FIELD (data,CC_GC_SHADER_ARRAY_CONFIG ,INACTIVE_CUS ) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-7@@ -1698,11 +1698,6 @@ static void gfx_v9_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 shWREG32_SOC15 (GC ,0 , mmGRBM_GFX_INDEX, data); } -static u32 gfx_v9_0_create_bitmask (u32 bit_width) -{ -return (u32)((1ULL << bit_width) -1 ); -} -static u32 gfx_v9_0_get_rb_active_bitmap (struct amdgpu_device *adev) {u32 data, mask;@@ -1713,8 +1708,8 @@ static u32 gfx_v9_0_get_rb_active_bitmap(struct amdgpu_device *adev) data &=CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK ; data >>=GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_backends_per_se / - adev->gfx.config.max_sh_per_se); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_backends_per_se / + adev->gfx.config.max_sh_per_se);return (~data) & mask; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) · line 4610
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -4609,7 +4604,7 @@ static u32 gfx_v9_0_get_cu_active_bitmap(struct amdgpu_device *adev) data &=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK ; data >>=CC_GC_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT ; - mask =gfx_v9_0_create_bitmask (adev->gfx.config.max_cu_per_sh); + mask =amdgpu_gfx_create_bitmask (adev->gfx.config.max_cu_per_sh);return (~data) & mask; }_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx