mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm/amdgpu: store userq_managers in a list in adev
So we can iterate across them when we need to manage all user queues. v2: add uq_mgr to adev list in amdgpu_userq_mgr_init Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
		
							parent
							
								
									100b6010d7
								
							
						
					
					
						commit
						4ce60dbada
					
				
					 4 changed files with 22 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1237,6 +1237,9 @@ struct amdgpu_device {
 | 
			
		|||
	 * in KFD: VRAM or GTT.
 | 
			
		||||
	 */
 | 
			
		||||
	bool                            apu_prefer_gtt;
 | 
			
		||||
 | 
			
		||||
	struct list_head		userq_mgr_list;
 | 
			
		||||
	struct mutex                    userq_mutex;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4317,6 +4317,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 | 
			
		|||
	mutex_init(&adev->gfx.kfd_sch_mutex);
 | 
			
		||||
	mutex_init(&adev->gfx.workload_profile_mutex);
 | 
			
		||||
	mutex_init(&adev->vcn.workload_profile_mutex);
 | 
			
		||||
	mutex_init(&adev->userq_mutex);
 | 
			
		||||
 | 
			
		||||
	amdgpu_device_init_apu_flags(adev);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4344,6 +4345,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 | 
			
		|||
 | 
			
		||||
	INIT_LIST_HEAD(&adev->pm.od_kobj_list);
 | 
			
		||||
 | 
			
		||||
	INIT_LIST_HEAD(&adev->userq_mgr_list);
 | 
			
		||||
 | 
			
		||||
	INIT_DELAYED_WORK(&adev->delayed_init_work,
 | 
			
		||||
			  amdgpu_device_delayed_init_work_handler);
 | 
			
		||||
	INIT_DELAYED_WORK(&adev->gfx.gfx_off_delay_work,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -658,20 +658,34 @@ int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct amdgpu_devi
 | 
			
		|||
	idr_init_base(&userq_mgr->userq_idr, 1);
 | 
			
		||||
	userq_mgr->adev = adev;
 | 
			
		||||
 | 
			
		||||
	mutex_lock(&adev->userq_mutex);
 | 
			
		||||
	list_add(&userq_mgr->list, &adev->userq_mgr_list);
 | 
			
		||||
	mutex_unlock(&adev->userq_mutex);
 | 
			
		||||
 | 
			
		||||
	INIT_DELAYED_WORK(&userq_mgr->resume_work, amdgpu_userqueue_resume_worker);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t queue_id;
 | 
			
		||||
	struct amdgpu_device *adev = userq_mgr->adev;
 | 
			
		||||
	struct amdgpu_usermode_queue *queue;
 | 
			
		||||
	struct amdgpu_userq_mgr *uqm, *tmp;
 | 
			
		||||
	uint32_t queue_id;
 | 
			
		||||
 | 
			
		||||
	cancel_delayed_work(&userq_mgr->resume_work);
 | 
			
		||||
 | 
			
		||||
	mutex_lock(&userq_mgr->userq_mutex);
 | 
			
		||||
	idr_for_each_entry(&userq_mgr->userq_idr, queue, queue_id)
 | 
			
		||||
		amdgpu_userqueue_cleanup(userq_mgr, queue, queue_id);
 | 
			
		||||
	mutex_lock(&adev->userq_mutex);
 | 
			
		||||
	list_for_each_entry_safe(uqm, tmp, &adev->userq_mgr_list, list) {
 | 
			
		||||
		if (uqm == userq_mgr) {
 | 
			
		||||
			list_del(&uqm->list);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	mutex_unlock(&adev->userq_mutex);
 | 
			
		||||
	idr_destroy(&userq_mgr->userq_idr);
 | 
			
		||||
	mutex_unlock(&userq_mgr->userq_mutex);
 | 
			
		||||
	mutex_destroy(&userq_mgr->userq_mutex);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,6 +76,7 @@ struct amdgpu_userq_mgr {
 | 
			
		|||
	struct mutex			userq_mutex;
 | 
			
		||||
	struct amdgpu_device		*adev;
 | 
			
		||||
	struct delayed_work		resume_work;
 | 
			
		||||
	struct list_head		list;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct amdgpu_db_info {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue