diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 10 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/atombios_crtc.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 6 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 15 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 15 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 15 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 16 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 95 | 
17 files changed, 143 insertions, 98 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 1cf78f4dd339..1e8e1123ddf4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c @@ -693,6 +693,10 @@ int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev)  			DRM_INFO("Changing default dispclk from %dMhz to 600Mhz\n",  				 adev->clock.default_dispclk / 100);  			adev->clock.default_dispclk = 60000; +		} else if (adev->clock.default_dispclk <= 60000) { +			DRM_INFO("Changing default dispclk from %dMhz to 625Mhz\n", +				 adev->clock.default_dispclk / 100); +			adev->clock.default_dispclk = 62500;  		}  		adev->clock.dp_extclk =  			le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index f2d705e6a75a..ab6b0d0febab 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -449,6 +449,7 @@ static const struct pci_device_id pciidlist[] = {  	{0x1002, 0x6986, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},  	{0x1002, 0x6987, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},  	{0x1002, 0x6995, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12}, +	{0x1002, 0x6997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},  	{0x1002, 0x699F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS12},  	/* Vega 10 */  	{0x1002, 0x6860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VEGA10|AMD_EXP_HW_SUPPORT}, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c index 236d9950221b..c0d8c6ff6380 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c @@ -425,10 +425,15 @@ bool amdgpu_fbdev_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj)  void amdgpu_fbdev_restore_mode(struct amdgpu_device *adev)  { -	struct amdgpu_fbdev *afbdev = adev->mode_info.rfbdev; +	struct amdgpu_fbdev *afbdev;  	struct drm_fb_helper *fb_helper;  	int ret; +	if (!adev) +		return; + +	afbdev = adev->mode_info.rfbdev; +  	if (!afbdev)  		return; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 07ff3b1514f1..8ecf82c5fe74 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -634,7 +634,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)  		mutex_unlock(&id_mgr->lock);  	} -	if (gds_switch_needed) { +	if (ring->funcs->emit_gds_switch && gds_switch_needed) {  		id->gds_base = job->gds_base;  		id->gds_size = job->gds_size;  		id->gws_base = job->gws_base; @@ -672,6 +672,7 @@ void amdgpu_vm_reset_id(struct amdgpu_device *adev, unsigned vmhub,  	struct amdgpu_vm_id_manager *id_mgr = &adev->vm_manager.id_mgr[vmhub];  	struct amdgpu_vm_id *id = &id_mgr->ids[vmid]; +	atomic64_set(&id->owner, 0);  	id->gds_base = 0;  	id->gds_size = 0;  	id->gws_base = 0; @@ -681,6 +682,26 @@ void amdgpu_vm_reset_id(struct amdgpu_device *adev, unsigned vmhub,  }  /** + * amdgpu_vm_reset_all_id - reset VMID to zero + * + * @adev: amdgpu device structure + * + * Reset VMID to force flush on next use + */ +void amdgpu_vm_reset_all_ids(struct amdgpu_device *adev) +{ +	unsigned i, j; + +	for (i = 0; i < AMDGPU_MAX_VMHUBS; ++i) { +		struct amdgpu_vm_id_manager *id_mgr = +			&adev->vm_manager.id_mgr[i]; + +		for (j = 1; j < id_mgr->num_ids; ++j) +			amdgpu_vm_reset_id(adev, i, j); +	} +} + +/**   * amdgpu_vm_bo_find - find the bo_va for a specific vm & bo   *   * @vm: requested vm @@ -2270,7 +2291,6 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)  	for (i = 0; i < AMDGPU_MAX_RINGS; ++i)  		adev->vm_manager.seqno[i] = 0; -  	atomic_set(&adev->vm_manager.vm_pte_next_ring, 0);  	atomic64_set(&adev->vm_manager.client_counter, 0);  	spin_lock_init(&adev->vm_manager.prt_lock); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index d97e28b4bdc4..e1d951ece433 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -204,6 +204,7 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,  int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job);  void amdgpu_vm_reset_id(struct amdgpu_device *adev, unsigned vmhub,  			unsigned vmid); +void amdgpu_vm_reset_all_ids(struct amdgpu_device *adev);  int amdgpu_vm_update_directories(struct amdgpu_device *adev,  				 struct amdgpu_vm *vm);  int amdgpu_vm_clear_freed(struct amdgpu_device *adev, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index a4831fe0223b..a2c59a08b2bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -220,9 +220,9 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man,  }  const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { -	amdgpu_vram_mgr_init, -	amdgpu_vram_mgr_fini, -	amdgpu_vram_mgr_new, -	amdgpu_vram_mgr_del, -	amdgpu_vram_mgr_debug +	.init		= amdgpu_vram_mgr_init, +	.takedown	= amdgpu_vram_mgr_fini, +	.get_node	= amdgpu_vram_mgr_new, +	.put_node	= amdgpu_vram_mgr_del, +	.debug		= amdgpu_vram_mgr_debug  }; diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c b/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c index 8c9bc75a9c2d..8a0818b23ea4 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_crtc.c @@ -165,7 +165,7 @@ void amdgpu_atombios_crtc_powergate(struct drm_crtc *crtc, int state)  	struct drm_device *dev = crtc->dev;  	struct amdgpu_device *adev = dev->dev_private;  	int index = GetIndexIntoMasterTable(COMMAND, EnableDispPowerGating); -	ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1 args; +	ENABLE_DISP_POWER_GATING_PS_ALLOCATION args;  	memset(&args, 0, sizeof(args)); @@ -178,7 +178,7 @@ void amdgpu_atombios_crtc_powergate(struct drm_crtc *crtc, int state)  void amdgpu_atombios_crtc_powergate_init(struct amdgpu_device *adev)  {  	int index = GetIndexIntoMasterTable(COMMAND, EnableDispPowerGating); -	ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1 args; +	ENABLE_DISP_POWER_GATING_PS_ALLOCATION args;  	memset(&args, 0, sizeof(args)); diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index 6dc1410b380f..ec93714e4524 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c @@ -906,6 +906,12 @@ static bool ci_dpm_vblank_too_short(struct amdgpu_device *adev)  	u32 vblank_time = amdgpu_dpm_get_vblank_time(adev);  	u32 switch_limit = adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5 ? 450 : 300; +	/* disable mclk switching if the refresh is >120Hz, even if the +	 * blanking period would allow it +	 */ +	if (amdgpu_dpm_get_vrefresh(adev) > 120) +		return true; +  	if (vblank_time < switch_limit)  		return true;  	else diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index 0cdeb6a2e4a0..5dffa27afa45 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c @@ -1207,8 +1207,11 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev,  	u32 tmp, wm_mask, lb_vblank_lead_lines = 0;  	if (amdgpu_crtc->base.enabled && num_heads && mode) { -		active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; -		line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); +		active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000, +					    (u32)mode->clock); +		line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000, +					  (u32)mode->clock); +		line_time = min(line_time, (u32)65535);  		/* watermark for high clocks */  		if (adev->pm.dpm_enabled) { diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 773654a19749..47bbc87f96d2 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c @@ -1176,8 +1176,11 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev,  	u32 tmp, wm_mask, lb_vblank_lead_lines = 0;  	if (amdgpu_crtc->base.enabled && num_heads && mode) { -		active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; -		line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); +		active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000, +					    (u32)mode->clock); +		line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000, +					  (u32)mode->clock); +		line_time = min(line_time, (u32)65535);  		/* watermark for high clocks */  		if (adev->pm.dpm_enabled) { diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index 1f3552967ba3..d8c9a959493e 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c @@ -983,8 +983,11 @@ static void dce_v6_0_program_watermarks(struct amdgpu_device *adev,  	fixed20_12 a, b, c;  	if (amdgpu_crtc->base.enabled && num_heads && mode) { -		active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; -		line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); +		active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000, +					    (u32)mode->clock); +		line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000, +					  (u32)mode->clock); +		line_time = min(line_time, (u32)65535);  		priority_a_cnt = 0;  		priority_b_cnt = 0; diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index 3c558c170e5e..db30c6ba563a 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c @@ -1091,8 +1091,11 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev,  	u32 tmp, wm_mask, lb_vblank_lead_lines = 0;  	if (amdgpu_crtc->base.enabled && num_heads && mode) { -		active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; -		line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); +		active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000, +					    (u32)mode->clock); +		line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000, +					  (u32)mode->clock); +		line_time = min(line_time, (u32)65535);  		/* watermark for high clocks */  		if (adev->pm.dpm_enabled) { diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c index a572979f186c..d860939152df 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c @@ -950,10 +950,6 @@ static int gmc_v6_0_suspend(void *handle)  {  	struct amdgpu_device *adev = (struct amdgpu_device *)handle; -	if (adev->vm_manager.enabled) { -		gmc_v6_0_vm_fini(adev); -		adev->vm_manager.enabled = false; -	}  	gmc_v6_0_hw_fini(adev);  	return 0; @@ -968,16 +964,9 @@ static int gmc_v6_0_resume(void *handle)  	if (r)  		return r; -	if (!adev->vm_manager.enabled) { -		r = gmc_v6_0_vm_init(adev); -		if (r) { -			dev_err(adev->dev, "vm manager initialization failed (%d).\n", r); -			return r; -		} -		adev->vm_manager.enabled = true; -	} +	amdgpu_vm_reset_all_ids(adev); -	return r; +	return 0;  }  static bool gmc_v6_0_is_idle(void *handle) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index a9083a16a250..2750e5c23813 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c @@ -1117,10 +1117,6 @@ static int gmc_v7_0_suspend(void *handle)  {  	struct amdgpu_device *adev = (struct amdgpu_device *)handle; -	if (adev->vm_manager.enabled) { -		gmc_v7_0_vm_fini(adev); -		adev->vm_manager.enabled = false; -	}  	gmc_v7_0_hw_fini(adev);  	return 0; @@ -1135,16 +1131,9 @@ static int gmc_v7_0_resume(void *handle)  	if (r)  		return r; -	if (!adev->vm_manager.enabled) { -		r = gmc_v7_0_vm_init(adev); -		if (r) { -			dev_err(adev->dev, "vm manager initialization failed (%d).\n", r); -			return r; -		} -		adev->vm_manager.enabled = true; -	} +	amdgpu_vm_reset_all_ids(adev); -	return r; +	return 0;  }  static bool gmc_v7_0_is_idle(void *handle) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 4ac99784160a..f56b4089ee9f 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -1209,10 +1209,6 @@ static int gmc_v8_0_suspend(void *handle)  {  	struct amdgpu_device *adev = (struct amdgpu_device *)handle; -	if (adev->vm_manager.enabled) { -		gmc_v8_0_vm_fini(adev); -		adev->vm_manager.enabled = false; -	}  	gmc_v8_0_hw_fini(adev);  	return 0; @@ -1227,16 +1223,9 @@ static int gmc_v8_0_resume(void *handle)  	if (r)  		return r; -	if (!adev->vm_manager.enabled) { -		r = gmc_v8_0_vm_init(adev); -		if (r) { -			dev_err(adev->dev, "vm manager initialization failed (%d).\n", r); -			return r; -		} -		adev->vm_manager.enabled = true; -	} +	amdgpu_vm_reset_all_ids(adev); -	return r; +	return 0;  }  static bool gmc_v8_0_is_idle(void *handle) diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index dc1e1c1d6b24..f936332a069d 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c @@ -791,10 +791,6 @@ static int gmc_v9_0_suspend(void *handle)  {  	struct amdgpu_device *adev = (struct amdgpu_device *)handle; -	if (adev->vm_manager.enabled) { -		gmc_v9_0_vm_fini(adev); -		adev->vm_manager.enabled = false; -	}  	gmc_v9_0_hw_fini(adev);  	return 0; @@ -809,17 +805,9 @@ static int gmc_v9_0_resume(void *handle)  	if (r)  		return r; -	if (!adev->vm_manager.enabled) { -		r = gmc_v9_0_vm_init(adev); -		if (r) { -			dev_err(adev->dev, -				"vm manager initialization failed (%d).\n", r); -			return r; -		} -		adev->vm_manager.enabled = true; -	} +	amdgpu_vm_reset_all_ids(adev); -	return r; +	return 0;  }  static bool gmc_v9_0_is_idle(void *handle) diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c index fb0819359909..90332f55cfba 100644 --- a/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v3_0.c @@ -77,13 +77,26 @@ static int vce_v3_0_set_clockgating_state(void *handle,  static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)  {  	struct amdgpu_device *adev = ring->adev; +	u32 v; + +	mutex_lock(&adev->grbm_idx_mutex); +	if (adev->vce.harvest_config == 0 || +		adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE1) +		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(0)); +	else if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) +		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));  	if (ring == &adev->vce.ring[0]) -		return RREG32(mmVCE_RB_RPTR); +		v = RREG32(mmVCE_RB_RPTR);  	else if (ring == &adev->vce.ring[1]) -		return RREG32(mmVCE_RB_RPTR2); +		v = RREG32(mmVCE_RB_RPTR2);  	else -		return RREG32(mmVCE_RB_RPTR3); +		v = RREG32(mmVCE_RB_RPTR3); + +	WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT); +	mutex_unlock(&adev->grbm_idx_mutex); + +	return v;  }  /** @@ -96,13 +109,26 @@ static uint64_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)  static uint64_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)  {  	struct amdgpu_device *adev = ring->adev; +	u32 v; + +	mutex_lock(&adev->grbm_idx_mutex); +	if (adev->vce.harvest_config == 0 || +		adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE1) +		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(0)); +	else if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) +		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1));  	if (ring == &adev->vce.ring[0]) -		return RREG32(mmVCE_RB_WPTR); +		v = RREG32(mmVCE_RB_WPTR);  	else if (ring == &adev->vce.ring[1]) -		return RREG32(mmVCE_RB_WPTR2); +		v = RREG32(mmVCE_RB_WPTR2);  	else -		return RREG32(mmVCE_RB_WPTR3); +		v = RREG32(mmVCE_RB_WPTR3); + +	WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT); +	mutex_unlock(&adev->grbm_idx_mutex); + +	return v;  }  /** @@ -116,12 +142,22 @@ static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)  {  	struct amdgpu_device *adev = ring->adev; +	mutex_lock(&adev->grbm_idx_mutex); +	if (adev->vce.harvest_config == 0 || +		adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE1) +		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(0)); +	else if (adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) +		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(1)); +  	if (ring == &adev->vce.ring[0])  		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));  	else if (ring == &adev->vce.ring[1])  		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));  	else  		WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr)); + +	WREG32(mmGRBM_GFX_INDEX, mmGRBM_GFX_INDEX_DEFAULT); +	mutex_unlock(&adev->grbm_idx_mutex);  }  static void vce_v3_0_override_vce_clock_gating(struct amdgpu_device *adev, bool override) @@ -231,33 +267,38 @@ static int vce_v3_0_start(struct amdgpu_device *adev)  	struct amdgpu_ring *ring;  	int idx, r; -	ring = &adev->vce.ring[0]; -	WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr)); -	WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr)); -	WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr); -	WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); -	WREG32(mmVCE_RB_SIZE, ring->ring_size / 4); - -	ring = &adev->vce.ring[1]; -	WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr)); -	WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr)); -	WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr); -	WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); -	WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4); - -	ring = &adev->vce.ring[2]; -	WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr)); -	WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr)); -	WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr); -	WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr)); -	WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4); -  	mutex_lock(&adev->grbm_idx_mutex);  	for (idx = 0; idx < 2; ++idx) {  		if (adev->vce.harvest_config & (1 << idx))  			continue;  		WREG32(mmGRBM_GFX_INDEX, GET_VCE_INSTANCE(idx)); + +		/* Program instance 0 reg space for two instances or instance 0 case +		program instance 1 reg space for only instance 1 available case */ +		if (idx != 1 || adev->vce.harvest_config == AMDGPU_VCE_HARVEST_VCE0) { +			ring = &adev->vce.ring[0]; +			WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr)); +			WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr)); +			WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr); +			WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); +			WREG32(mmVCE_RB_SIZE, ring->ring_size / 4); + +			ring = &adev->vce.ring[1]; +			WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr)); +			WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr)); +			WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr); +			WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); +			WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4); + +			ring = &adev->vce.ring[2]; +			WREG32(mmVCE_RB_RPTR3, lower_32_bits(ring->wptr)); +			WREG32(mmVCE_RB_WPTR3, lower_32_bits(ring->wptr)); +			WREG32(mmVCE_RB_BASE_LO3, ring->gpu_addr); +			WREG32(mmVCE_RB_BASE_HI3, upper_32_bits(ring->gpu_addr)); +			WREG32(mmVCE_RB_SIZE3, ring->ring_size / 4); +		} +  		vce_v3_0_mc_resume(adev, idx);  		WREG32_FIELD(VCE_STATUS, JOB_BUSY, 1); | 
