drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c
Subsystems (2)
PATCH 1/1 drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c
In review, Christian would like to keep the logic inside amdgpu_vm.c with a cost of slightly slower. The loop is still optimized out with this patch.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 32 --------------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 35 +++++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +++ 5 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -2227,6 +2227,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->accel_working = true; +amdgpu_vm_check_compute_bug (adev); +/* Initialize the buffer migration limit. */ if (amdgpu_moverate >=0 ) max_MBps = amdgpu_moverate;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -32
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring) }/** -* amdgpu_ring_check_compute_vm_bug - check whether this ring has compute vm bug -* -* @adev: amdgpu_device pointer -* @ring: amdgpu_ring structure holding ring information -*/ -static void amdgpu_ring_check_compute_vm_bug (struct amdgpu_device *adev, -struct amdgpu_ring *ring) -{ -const struct amdgpu_ip_block *ip_block; - - ring->has_compute_vm_bug = false; - -if (ring->funcs->type !=AMDGPU_RING_TYPE_COMPUTE ) -/* only compute rings */ -return ; - - ip_block =amdgpu_get_ip_block (adev,AMD_IP_BLOCK_TYPE_GFX ); -if (!ip_block) -return ; - -/* Compute ring has a VM bug for GFX version < 7. -And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/ -if (ip_block->version->major <=7 ) { - ring->has_compute_vm_bug = true; - }else if (ip_block->version->major ==8 ) -if (adev->gfx.mec_fw_version <673 ) - ring->has_compute_vm_bug = true; -} - -/** * amdgpu_ring_init - init driver ring struct. * * @adev: amdgpu_device pointer
@@ -288,8 +258,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,DRM_ERROR ("Failed to register debugfs file for rings !\n" ); } -amdgpu_ring_check_compute_vm_bug (adev, ring); -return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -6
@@ -185,7 +185,6 @@ struct amdgpu_ring {u64 cond_exe_gpu_addr;volatile u32 *cond_exe_cpu_addr;unsigned vm_inv_eng; -bool has_compute_vm_bug;#if defined(CONFIG_DEBUG_FS )struct dentry *ent;#endif
@@ -208,9 +207,4 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring) } -static inline bool amdgpu_ring_has_compute_vm_bug (struct amdgpu_ring *ring) -{ -return ring->has_compute_vm_bug; -} -#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +34 -1
@@ -656,6 +656,39 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,return r; } +static bool amdgpu_vm_ring_has_compute_vm_bug (struct amdgpu_ring *ring) +{ +if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) +/* only compute rings */ +return ring->adev->vm_manager.has_compute_vm_bug; +else +return false; +} + +/** +* amdgpu_vm_check_compute_bug - check whether asic has compute vm bug +* +* @adev: amdgpu_device pointer +*/ +void amdgpu_vm_check_compute_bug (struct amdgpu_device *adev) +{ +const struct amdgpu_ip_block *ip_block; + + adev->vm_manager.has_compute_vm_bug = false; + + ip_block =amdgpu_get_ip_block (adev,AMD_IP_BLOCK_TYPE_GFX ); +if (!ip_block) +return ; + +/* Compute ring has a VM bug for GFX version < 7. +And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/ +if (ip_block->version->major <=7 ) { + adev->vm_manager.has_compute_vm_bug = true; + }else if (ip_block->version->major ==8 ) +if (adev->gfx.mec_fw_version <673 ) + adev->vm_manager.has_compute_vm_bug = true; +} +bool amdgpu_vm_need_pipeline_sync (struct amdgpu_ring *ring,struct amdgpu_job *job) {
@@ -665,7 +698,7 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,struct amdgpu_vm_id *id;bool gds_switch_needed;bool vm_flush_needed = job->vm_needs_flush || -amdgpu_ring_has_compute_vm_bug (ring); +amdgpu_vm_ring_has_compute_vm_bug (ring);if (job->vm_id ==0 )return false;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3 -0
@@ -184,6 +184,8 @@ struct amdgpu_vm_manager {/* partial resident texture handling */ spinlock_t prt_lock;atomic_t num_prt_users; + +bool has_compute_vm_bug; };void amdgpu_vm_manager_init (struct amdgpu_device *adev);
@@ -245,5 +247,6 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size);int amdgpu_vm_ioctl (struct drm_device *dev,void *data,struct drm_file *filp);bool amdgpu_vm_need_pipeline_sync (struct amdgpu_ring *ring,struct amdgpu_job *job); +void amdgpu_vm_check_compute_bug (struct amdgpu_device *adev);#endif
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1496254153-12583-1-git-send-email-AlexBin.Xie-5C7GfCeVMHo@public.gmane.org
Christian König
Reviewed-byAm 31.05.2017 um 20:09 schrieb Alex Xie:
Quoted 5 lines
In review, Christian would like to keep the logic inside
amdgpu_vm.cwith a cost of slightly slower. The loop is still optimized out with this patch.Signed-off-by Alex Xie <[email protected]>
Quoted 160 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 32 --------------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 35 +++++++++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +++ 5 files changed, 39 insertions(+), 39 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-0@@ -2227,6 +2227,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->accel_working = true; +amdgpu_vm_check_compute_bug (adev); +/* Initialize the buffer migration limit. */ if (amdgpu_moverate >=0 ) max_MBps = amdgpu_moverate;drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-32@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring) }/** -* amdgpu_ring_check_compute_vm_bug - check whether this ring has compute vm bug -* -* @adev: amdgpu_device pointer -* @ring: amdgpu_ring structure holding ring information -*/ -static void amdgpu_ring_check_compute_vm_bug (struct amdgpu_device *adev, -struct amdgpu_ring *ring) -{ -const struct amdgpu_ip_block *ip_block; - - ring->has_compute_vm_bug = false; - -if (ring->funcs->type !=AMDGPU_RING_TYPE_COMPUTE ) -/* only compute rings */ -return ; - - ip_block =amdgpu_get_ip_block (adev,AMD_IP_BLOCK_TYPE_GFX ); -if (!ip_block) -return ; - -/* Compute ring has a VM bug for GFX version < 7. -And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/ -if (ip_block->version->major <=7 ) { - ring->has_compute_vm_bug = true; - }else if (ip_block->version->major ==8 ) -if (adev->gfx.mec_fw_version <673 ) - ring->has_compute_vm_bug = true; -} - -/** * amdgpu_ring_init - init driver ring struct. * * @adev: amdgpu_device pointer @@ -288,8 +258,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,DRM_ERROR ("Failed to register debugfs file for rings !\n" ); } -amdgpu_ring_check_compute_vm_bug (adev, ring); -return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0
-6@@ -185,7 +185,6 @@ struct amdgpu_ring {u64 cond_exe_gpu_addr;volatile u32 *cond_exe_cpu_addr;unsigned vm_inv_eng; -bool has_compute_vm_bug;#if defined(CONFIG_DEBUG_FS )struct dentry *ent;#endif @@ -208,9 +207,4 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring) } -static inline bool amdgpu_ring_has_compute_vm_bug (struct amdgpu_ring *ring) -{ -return ring->has_compute_vm_bug; -} -#endif drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +34
-1@@ -656,6 +656,39 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,return r; } +static bool amdgpu_vm_ring_has_compute_vm_bug (struct amdgpu_ring *ring) +{ +if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) +/* only compute rings */ +return ring->adev->vm_manager.has_compute_vm_bug; +else +return false; +} + +/** +* amdgpu_vm_check_compute_bug - check whether asic has compute vm bug +* +* @adev: amdgpu_device pointer +*/ +void amdgpu_vm_check_compute_bug (struct amdgpu_device *adev) +{ +const struct amdgpu_ip_block *ip_block; + + adev->vm_manager.has_compute_vm_bug = false; + + ip_block =amdgpu_get_ip_block (adev,AMD_IP_BLOCK_TYPE_GFX ); +if (!ip_block) +return ; + +/* Compute ring has a VM bug for GFX version < 7. +And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/ +if (ip_block->version->major <=7 ) { + adev->vm_manager.has_compute_vm_bug = true; + }else if (ip_block->version->major ==8 ) +if (adev->gfx.mec_fw_version <673 ) + adev->vm_manager.has_compute_vm_bug = true; +} +bool amdgpu_vm_need_pipeline_sync (struct amdgpu_ring *ring,struct amdgpu_job *job) {@@ -665,7 +698,7 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,struct amdgpu_vm_id *id;bool gds_switch_needed;bool vm_flush_needed = job->vm_needs_flush || -amdgpu_ring_has_compute_vm_bug (ring); +amdgpu_vm_ring_has_compute_vm_bug (ring);if (job->vm_id ==0 )return false;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2
-0@@ -184,6 +184,8 @@ struct amdgpu_vm_manager {/* partial resident texture handling */ spinlock_t prt_lock;atomic_t num_prt_users; + +bool has_compute_vm_bug; };void amdgpu_vm_manager_init (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size); · line 252
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1
-0@@ -245,5 +247,6 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size);int amdgpu_vm_ioctl (struct drm_device *dev,void *data,struct drm_file *filp);bool amdgpu_vm_need_pipeline_sync (struct amdgpu_ring *ring,struct amdgpu_job *job); +void amdgpu_vm_check_compute_bug (struct amdgpu_device *adev);#endif
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx