forked from mirrors/linux
		
	drm/amdgpu: RCU protected amdgpu_fence_release
Fences must be freed RCU protected, otherwise the reservation_object_*_rcu() functions can run into problems. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
		
							parent
							
								
									ca08e04d56
								
							
						
					
					
						commit
						b44135351a
					
				
					 1 changed files with 22 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -638,12 +638,33 @@ static bool amdgpu_fence_enable_signaling(struct fence *f)
 | 
			
		|||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void amdgpu_fence_release(struct fence *f)
 | 
			
		||||
/**
 | 
			
		||||
 * amdgpu_fence_free - free up the fence memory
 | 
			
		||||
 *
 | 
			
		||||
 * @rcu: RCU callback head
 | 
			
		||||
 *
 | 
			
		||||
 * Free up the fence memory after the RCU grace period.
 | 
			
		||||
 */
 | 
			
		||||
static void amdgpu_fence_free(struct rcu_head *rcu)
 | 
			
		||||
{
 | 
			
		||||
	struct fence *f = container_of(rcu, struct fence, rcu);
 | 
			
		||||
	struct amdgpu_fence *fence = to_amdgpu_fence(f);
 | 
			
		||||
	kmem_cache_free(amdgpu_fence_slab, fence);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * amdgpu_fence_release - callback that fence can be freed
 | 
			
		||||
 *
 | 
			
		||||
 * @fence: fence
 | 
			
		||||
 *
 | 
			
		||||
 * This function is called when the reference count becomes zero.
 | 
			
		||||
 * It just RCU schedules freeing up the fence.
 | 
			
		||||
 */
 | 
			
		||||
static void amdgpu_fence_release(struct fence *f)
 | 
			
		||||
{
 | 
			
		||||
	call_rcu(&f->rcu, amdgpu_fence_free);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct fence_ops amdgpu_fence_ops = {
 | 
			
		||||
	.get_driver_name = amdgpu_fence_get_driver_name,
 | 
			
		||||
	.get_timeline_name = amdgpu_fence_get_timeline_name,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue