diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
24 files changed, 166 insertions, 164 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index d5a2eefd6c3e..74edba18b159 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1156,7 +1156,7 @@ static inline void amdgpu_set_ib_value(struct amdgpu_cs_parser *p,  /*   * Writeback   */ -#define AMDGPU_MAX_WB 512	/* Reserve at most 512 WB slots for amdgpu-owned rings. */ +#define AMDGPU_MAX_WB 128	/* Reserve at most 128 WB slots for amdgpu-owned rings. */  struct amdgpu_wb {  	struct amdgpu_bo	*wb_obj; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index 57afad79f55d..8fa850a070e0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -540,6 +540,9 @@ int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,  	size_t size;  	u32 retry = 3; +	if (amdgpu_acpi_pcie_notify_device_ready(adev)) +		return -EINVAL; +  	/* Get the device handle */  	handle = ACPI_HANDLE(&adev->pdev->dev);  	if (!handle) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c index e2c3c5ec42d1..c53095b3b0fb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c @@ -568,6 +568,7 @@ static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = {  	/* HG _PR3 doesn't seem to work on this A+A weston board */  	{ 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX },  	{ 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX }, +	{ 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX },  	{ 0, 0, 0, 0, 0 },  }; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c index 8ca3783f2deb..7a073ac5f9c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c @@ -69,25 +69,18 @@ void amdgpu_connector_hotplug(struct drm_connector *connector)  		/* don't do anything if sink is not display port, i.e.,  		 * passive dp->(dvi|hdmi) adaptor  		 */ -		if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { -			int saved_dpms = connector->dpms; -			/* Only turn off the display if it's physically disconnected */ -			if (!amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd)) { -				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); -			} else if (amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) { -				/* Don't try to start link training before we -				 * have the dpcd */ -				if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector)) -					return; - -				/* set it to OFF so that drm_helper_connector_dpms() -				 * won't return immediately since the current state -				 * is ON at this point. -				 */ -				connector->dpms = DRM_MODE_DPMS_OFF; -				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); -			} -			connector->dpms = saved_dpms; +		if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT && +		    amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd) && +		    amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) { +			/* Don't start link training before we have the DPCD */ +			if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector)) +				return; + +			/* Turn the connector off and back on immediately, which +			 * will trigger link training +			 */ +			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); +			drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);  		}  	}  } @@ -736,9 +729,11 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)  	enum drm_connector_status ret = connector_status_disconnected;  	int r; -	r = pm_runtime_get_sync(connector->dev->dev); -	if (r < 0) -		return connector_status_disconnected; +	if (!drm_kms_helper_is_poll_worker()) { +		r = pm_runtime_get_sync(connector->dev->dev); +		if (r < 0) +			return connector_status_disconnected; +	}  	if (encoder) {  		struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); @@ -757,8 +752,12 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)  	/* check acpi lid status ??? */  	amdgpu_connector_update_scratch_regs(connector, ret); -	pm_runtime_mark_last_busy(connector->dev->dev); -	pm_runtime_put_autosuspend(connector->dev->dev); + +	if (!drm_kms_helper_is_poll_worker()) { +		pm_runtime_mark_last_busy(connector->dev->dev); +		pm_runtime_put_autosuspend(connector->dev->dev); +	} +  	return ret;  } @@ -868,9 +867,11 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)  	enum drm_connector_status ret = connector_status_disconnected;  	int r; -	r = pm_runtime_get_sync(connector->dev->dev); -	if (r < 0) -		return connector_status_disconnected; +	if (!drm_kms_helper_is_poll_worker()) { +		r = pm_runtime_get_sync(connector->dev->dev); +		if (r < 0) +			return connector_status_disconnected; +	}  	encoder = amdgpu_connector_best_single_encoder(connector);  	if (!encoder) @@ -924,8 +925,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)  	amdgpu_connector_update_scratch_regs(connector, ret);  out: -	pm_runtime_mark_last_busy(connector->dev->dev); -	pm_runtime_put_autosuspend(connector->dev->dev); +	if (!drm_kms_helper_is_poll_worker()) { +		pm_runtime_mark_last_busy(connector->dev->dev); +		pm_runtime_put_autosuspend(connector->dev->dev); +	}  	return ret;  } @@ -988,9 +991,11 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)  	enum drm_connector_status ret = connector_status_disconnected;  	bool dret = false, broken_edid = false; -	r = pm_runtime_get_sync(connector->dev->dev); -	if (r < 0) -		return connector_status_disconnected; +	if (!drm_kms_helper_is_poll_worker()) { +		r = pm_runtime_get_sync(connector->dev->dev); +		if (r < 0) +			return connector_status_disconnected; +	}  	if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {  		ret = connector->status; @@ -1115,8 +1120,10 @@ out:  	amdgpu_connector_update_scratch_regs(connector, ret);  exit: -	pm_runtime_mark_last_busy(connector->dev->dev); -	pm_runtime_put_autosuspend(connector->dev->dev); +	if (!drm_kms_helper_is_poll_worker()) { +		pm_runtime_mark_last_busy(connector->dev->dev); +		pm_runtime_put_autosuspend(connector->dev->dev); +	}  	return ret;  } @@ -1359,9 +1366,11 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)  	struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector);  	int r; -	r = pm_runtime_get_sync(connector->dev->dev); -	if (r < 0) -		return connector_status_disconnected; +	if (!drm_kms_helper_is_poll_worker()) { +		r = pm_runtime_get_sync(connector->dev->dev); +		if (r < 0) +			return connector_status_disconnected; +	}  	if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {  		ret = connector->status; @@ -1429,8 +1438,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)  	amdgpu_connector_update_scratch_regs(connector, ret);  out: -	pm_runtime_mark_last_busy(connector->dev->dev); -	pm_runtime_put_autosuspend(connector->dev->dev); +	if (!drm_kms_helper_is_poll_worker()) { +		pm_runtime_mark_last_busy(connector->dev->dev); +		pm_runtime_put_autosuspend(connector->dev->dev); +	}  	return ret;  } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 00a50cc5ec9a..66cb10cdc7c3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -492,7 +492,7 @@ static int amdgpu_device_wb_init(struct amdgpu_device *adev)  		memset(&adev->wb.used, 0, sizeof(adev->wb.used));  		/* clear wb memory */ -		memset((char *)adev->wb.wb, 0, AMDGPU_MAX_WB * sizeof(uint32_t)); +		memset((char *)adev->wb.wb, 0, AMDGPU_MAX_WB * sizeof(uint32_t) * 8);  	}  	return 0; @@ -530,8 +530,9 @@ int amdgpu_device_wb_get(struct amdgpu_device *adev, u32 *wb)   */  void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb)  { +	wb >>= 3;  	if (wb < adev->wb.num_wb) -		__clear_bit(wb >> 3, adev->wb.used); +		__clear_bit(wb, adev->wb.used);  }  /** @@ -1455,11 +1456,6 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)  	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {  		if (!adev->ip_blocks[i].status.hw)  			continue; -		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { -			amdgpu_free_static_csa(adev); -			amdgpu_device_wb_fini(adev); -			amdgpu_device_vram_scratch_fini(adev); -		}  		if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD &&  			adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE) { @@ -1486,6 +1482,13 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)  	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {  		if (!adev->ip_blocks[i].status.sw)  			continue; + +		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { +			amdgpu_free_static_csa(adev); +			amdgpu_device_wb_fini(adev); +			amdgpu_device_vram_scratch_fini(adev); +		} +  		r = adev->ip_blocks[i].version->funcs->sw_fini((void *)adev);  		/* XXX handle errors */  		if (r) { @@ -2060,9 +2063,12 @@ void amdgpu_device_fini(struct amdgpu_device *adev)  	DRM_INFO("amdgpu: finishing device.\n");  	adev->shutdown = true; -	if (adev->mode_info.mode_config_initialized) -		drm_crtc_force_disable_all(adev->ddev); - +	if (adev->mode_info.mode_config_initialized){ +		if (!amdgpu_device_has_dc_support(adev)) +			drm_crtc_force_disable_all(adev->ddev); +		else +			drm_atomic_helper_shutdown(adev->ddev); +	}  	amdgpu_ib_pool_fini(adev);  	amdgpu_fence_driver_fini(adev);  	amdgpu_fbdev_fini(adev); @@ -2284,14 +2290,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)  				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);  			}  			drm_modeset_unlock_all(dev); -		} else { -			/* -			 * There is no equivalent atomic helper to turn on -			 * display, so we defined our own function for this, -			 * once suspend resume is supported by the atomic -			 * framework this will be reworked -			 */ -			amdgpu_dm_display_resume(adev);  		}  	} @@ -2726,7 +2724,6 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,  	if (amdgpu_device_has_dc_support(adev)) {  		if (drm_atomic_helper_resume(adev->ddev, state))  			dev_info(adev->dev, "drm resume failed:%d\n", r); -		amdgpu_dm_display_resume(adev);  	} else {  		drm_helper_resume_force_mode(adev->ddev);  	} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index e48b4ec88c8c..ca6c931dabfa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -36,8 +36,6 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj)  	struct amdgpu_bo *robj = gem_to_amdgpu_bo(gobj);  	if (robj) { -		if (robj->gem_base.import_attach) -			drm_prime_gem_destroy(&robj->gem_base, robj->tbo.sg);  		amdgpu_mn_unregister(robj);  		amdgpu_bo_unref(&robj);  	} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index e14ab34d8262..7c2be32c5aea 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c @@ -75,7 +75,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,  static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)  {  	struct amdgpu_gtt_mgr *mgr = man->priv; - +	spin_lock(&mgr->lock);  	drm_mm_takedown(&mgr->mm);  	spin_unlock(&mgr->lock);  	kfree(mgr); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index 56bcd59c3399..36483e0d3c97 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c @@ -257,7 +257,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev)  	r = drm_irq_install(adev->ddev, adev->ddev->pdev->irq);  	if (r) {  		adev->irq.installed = false; -		flush_work(&adev->hotplug_work); +		if (!amdgpu_device_has_dc_support(adev)) +			flush_work(&adev->hotplug_work);  		cancel_work_sync(&adev->reset_work);  		return r;  	} @@ -282,7 +283,8 @@ void amdgpu_irq_fini(struct amdgpu_device *adev)  		adev->irq.installed = false;  		if (adev->irq.msi_enabled)  			pci_disable_msi(adev->pdev); -		flush_work(&adev->hotplug_work); +		if (!amdgpu_device_has_dc_support(adev)) +			flush_work(&adev->hotplug_work);  		cancel_work_sync(&adev->reset_work);  	} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h index 54f06c959340..2264c5c97009 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h @@ -352,6 +352,7 @@ struct amdgpu_mode_info {  	u16 firmware_flags;  	/* pointer to backlight encoder */  	struct amdgpu_encoder *bl_encoder; +	u8 bl_level; /* saved backlight level */  	struct amdgpu_audio	audio; /* audio stuff */  	int			num_crtc; /* number of crtcs */  	int			num_hpd; /* number of hpd pins */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 5c4c3e0d527b..1220322c1680 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -56,6 +56,8 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)  	amdgpu_bo_kunmap(bo); +	if (bo->gem_base.import_attach) +		drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg);  	drm_gem_object_release(&bo->gem_base);  	amdgpu_bo_unref(&bo->parent);  	if (!list_empty(&bo->shadow_list)) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 13044e66dcaf..561d3312af32 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -481,7 +481,7 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,  	result = 0;  	if (*pos < 12) { -		early[0] = amdgpu_ring_get_rptr(ring); +		early[0] = amdgpu_ring_get_rptr(ring) & ring->buf_mask;  		early[1] = amdgpu_ring_get_wptr(ring) & ring->buf_mask;  		early[2] = ring->wptr & ring->buf_mask;  		for (i = *pos / 4; i < 3 && size; i++) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index b2eae86bf906..5c26a8e806b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c @@ -299,12 +299,15 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)  	cancel_delayed_work_sync(&adev->uvd.idle_work); -	for (i = 0; i < adev->uvd.max_handles; ++i) -		if (atomic_read(&adev->uvd.handles[i])) -			break; +	/* only valid for physical mode */ +	if (adev->asic_type < CHIP_POLARIS10) { +		for (i = 0; i < adev->uvd.max_handles; ++i) +			if (atomic_read(&adev->uvd.handles[i])) +				break; -	if (i == AMDGPU_MAX_UVD_HANDLES) -		return 0; +		if (i == adev->uvd.max_handles) +			return 0; +	}  	size = amdgpu_bo_size(adev->uvd.vcpu_bo);  	ptr = adev->uvd.cpu_addr; diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c index 2af26d2da127..d702fb8e3427 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c @@ -34,7 +34,7 @@  #include <linux/backlight.h>  #include "bif/bif_4_1_d.h" -static u8 +u8  amdgpu_atombios_encoder_get_backlight_level_from_reg(struct amdgpu_device *adev)  {  	u8 backlight_level; @@ -48,7 +48,7 @@ amdgpu_atombios_encoder_get_backlight_level_from_reg(struct amdgpu_device *adev)  	return backlight_level;  } -static void +void  amdgpu_atombios_encoder_set_backlight_level_to_reg(struct amdgpu_device *adev,  					    u8 backlight_level)  { diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h index 2bdec40515ce..f77cbdef679e 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h @@ -25,6 +25,11 @@  #define __ATOMBIOS_ENCODER_H__  u8 +amdgpu_atombios_encoder_get_backlight_level_from_reg(struct amdgpu_device *adev); +void +amdgpu_atombios_encoder_set_backlight_level_to_reg(struct amdgpu_device *adev, +						   u8 backlight_level); +u8  amdgpu_atombios_encoder_get_backlight_level(struct amdgpu_encoder *amdgpu_encoder);  void  amdgpu_atombios_encoder_set_backlight_level(struct amdgpu_encoder *amdgpu_encoder, diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index f34bc68aadfb..022f303463fc 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c @@ -2921,6 +2921,11 @@ static int dce_v10_0_hw_fini(void *handle)  static int dce_v10_0_suspend(void *handle)  { +	struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +	adev->mode_info.bl_level = +		amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); +  	return dce_v10_0_hw_fini(handle);  } @@ -2929,6 +2934,9 @@ static int dce_v10_0_resume(void *handle)  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;  	int ret; +	amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, +							   adev->mode_info.bl_level); +  	ret = dce_v10_0_hw_init(handle);  	/* turn on the BL */ diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 26378bd6aba4..800a9f36ab4f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c @@ -3047,6 +3047,11 @@ static int dce_v11_0_hw_fini(void *handle)  static int dce_v11_0_suspend(void *handle)  { +	struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +	adev->mode_info.bl_level = +		amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); +  	return dce_v11_0_hw_fini(handle);  } @@ -3055,6 +3060,9 @@ static int dce_v11_0_resume(void *handle)  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;  	int ret; +	amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, +							   adev->mode_info.bl_level); +  	ret = dce_v11_0_hw_init(handle);  	/* turn on the BL */ diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index bd2c4f727df6..b8368f69ce1f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c @@ -2787,6 +2787,11 @@ static int dce_v6_0_hw_fini(void *handle)  static int dce_v6_0_suspend(void *handle)  { +	struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +	adev->mode_info.bl_level = +		amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); +  	return dce_v6_0_hw_fini(handle);  } @@ -2795,6 +2800,9 @@ static int dce_v6_0_resume(void *handle)  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;  	int ret; +	amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, +							   adev->mode_info.bl_level); +  	ret = dce_v6_0_hw_init(handle);  	/* turn on the BL */ @@ -3093,7 +3101,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,  		tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK;  		WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp);  		schedule_work(&adev->hotplug_work); -		DRM_INFO("IH: HPD%d\n", hpd + 1); +		DRM_DEBUG("IH: HPD%d\n", hpd + 1);  	}  	return 0; diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index c008dc030687..012e0a9ae0ff 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c @@ -2819,6 +2819,11 @@ static int dce_v8_0_hw_fini(void *handle)  static int dce_v8_0_suspend(void *handle)  { +	struct amdgpu_device *adev = (struct amdgpu_device *)handle; + +	adev->mode_info.bl_level = +		amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); +  	return dce_v8_0_hw_fini(handle);  } @@ -2827,6 +2832,9 @@ static int dce_v8_0_resume(void *handle)  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;  	int ret; +	amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, +							   adev->mode_info.bl_level); +  	ret = dce_v8_0_hw_init(handle);  	/* turn on the BL */ diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index a066c5eda135..a4309698e76c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c @@ -4384,34 +4384,8 @@ static void gfx_v7_0_gpu_early_init(struct amdgpu_device *adev)  	case CHIP_KAVERI:  		adev->gfx.config.max_shader_engines = 1;  		adev->gfx.config.max_tile_pipes = 4; -		if ((adev->pdev->device == 0x1304) || -		    (adev->pdev->device == 0x1305) || -		    (adev->pdev->device == 0x130C) || -		    (adev->pdev->device == 0x130F) || -		    (adev->pdev->device == 0x1310) || -		    (adev->pdev->device == 0x1311) || -		    (adev->pdev->device == 0x131C)) { -			adev->gfx.config.max_cu_per_sh = 8; -			adev->gfx.config.max_backends_per_se = 2; -		} else if ((adev->pdev->device == 0x1309) || -			   (adev->pdev->device == 0x130A) || -			   (adev->pdev->device == 0x130D) || -			   (adev->pdev->device == 0x1313) || -			   (adev->pdev->device == 0x131D)) { -			adev->gfx.config.max_cu_per_sh = 6; -			adev->gfx.config.max_backends_per_se = 2; -		} else if ((adev->pdev->device == 0x1306) || -			   (adev->pdev->device == 0x1307) || -			   (adev->pdev->device == 0x130B) || -			   (adev->pdev->device == 0x130E) || -			   (adev->pdev->device == 0x1315) || -			   (adev->pdev->device == 0x131B)) { -			adev->gfx.config.max_cu_per_sh = 4; -			adev->gfx.config.max_backends_per_se = 1; -		} else { -			adev->gfx.config.max_cu_per_sh = 3; -			adev->gfx.config.max_backends_per_se = 1; -		} +		adev->gfx.config.max_cu_per_sh = 8; +		adev->gfx.config.max_backends_per_se = 2;  		adev->gfx.config.max_sh_per_se = 1;  		adev->gfx.config.max_texture_channel_caches = 4;  		adev->gfx.config.max_gprs = 256; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index 2719937e09d6..3b7e7af09ead 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c @@ -634,7 +634,7 @@ static int gmc_v9_0_late_init(void *handle)  	for(i = 0; i < AMDGPU_MAX_VMHUBS; ++i)  		BUG_ON(vm_inv_eng[i] > 16); -	if (adev->asic_type == CHIP_VEGA10) { +	if (adev->asic_type == CHIP_VEGA10 && !amdgpu_sriov_vf(adev)) {  		r = gmc_v9_0_ecc_available(adev);  		if (r == 1) {  			DRM_INFO("ECC is active.\n"); @@ -682,7 +682,10 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev)  	adev->mc.vram_width = amdgpu_atomfirmware_get_vram_width(adev);  	if (!adev->mc.vram_width) {  		/* hbm memory channel size */ -		chansize = 128; +		if (adev->flags & AMD_IS_APU) +			chansize = 64; +		else +			chansize = 128;  		tmp = RREG32_SOC15(DF, 0, mmDF_CS_AON0_DramBaseAddress0);  		tmp &= DF_CS_AON0_DramBaseAddress0__IntLvNumChan_MASK; diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index e92fb372bc99..91cf95a8c39c 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c @@ -238,31 +238,27 @@ static uint64_t sdma_v4_0_ring_get_rptr(struct amdgpu_ring *ring)  static uint64_t sdma_v4_0_ring_get_wptr(struct amdgpu_ring *ring)  {  	struct amdgpu_device *adev = ring->adev; -	u64 *wptr = NULL; -	uint64_t local_wptr = 0; +	u64 wptr;  	if (ring->use_doorbell) {  		/* XXX check if swapping is necessary on BE */ -		wptr = ((u64 *)&adev->wb.wb[ring->wptr_offs]); -		DRM_DEBUG("wptr/doorbell before shift == 0x%016llx\n", *wptr); -		*wptr = (*wptr) >> 2; -		DRM_DEBUG("wptr/doorbell after shift == 0x%016llx\n", *wptr); +		wptr = READ_ONCE(*((u64 *)&adev->wb.wb[ring->wptr_offs])); +		DRM_DEBUG("wptr/doorbell before shift == 0x%016llx\n", wptr);  	} else {  		u32 lowbit, highbit;  		int me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1; -		wptr = &local_wptr;  		lowbit = RREG32(sdma_v4_0_get_reg_offset(adev, me, mmSDMA0_GFX_RB_WPTR)) >> 2;  		highbit = RREG32(sdma_v4_0_get_reg_offset(adev, me, mmSDMA0_GFX_RB_WPTR_HI)) >> 2;  		DRM_DEBUG("wptr [%i]high== 0x%08x low==0x%08x\n",  				me, highbit, lowbit); -		*wptr = highbit; -		*wptr = (*wptr) << 32; -		*wptr |= lowbit; +		wptr = highbit; +		wptr = wptr << 32; +		wptr |= lowbit;  	} -	return *wptr; +	return wptr >> 2;  }  /** diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index 543101d5a5ed..2095173aaabf 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c @@ -31,6 +31,7 @@  #include "amdgpu_uvd.h"  #include "amdgpu_vce.h"  #include "atom.h" +#include "amd_pcie.h"  #include "amdgpu_powerplay.h"  #include "sid.h"  #include "si_ih.h" @@ -1461,8 +1462,8 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)  {  	struct pci_dev *root = adev->pdev->bus->self;  	int bridge_pos, gpu_pos; -	u32 speed_cntl, mask, current_data_rate; -	int ret, i; +	u32 speed_cntl, current_data_rate; +	int i;  	u16 tmp16;  	if (pci_is_root_bus(adev->pdev->bus)) @@ -1474,23 +1475,20 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)  	if (adev->flags & AMD_IS_APU)  		return; -	ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); -	if (ret != 0) -		return; - -	if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) +	if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | +					CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)))  		return;  	speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL);  	current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >>  		LC_CURRENT_DATA_RATE_SHIFT; -	if (mask & DRM_PCIE_SPEED_80) { +	if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) {  		if (current_data_rate == 2) {  			DRM_INFO("PCIE gen 3 link speeds already enabled\n");  			return;  		}  		DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); -	} else if (mask & DRM_PCIE_SPEED_50) { +	} else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) {  		if (current_data_rate == 1) {  			DRM_INFO("PCIE gen 2 link speeds already enabled\n");  			return; @@ -1506,7 +1504,7 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)  	if (!gpu_pos)  		return; -	if (mask & DRM_PCIE_SPEED_80) { +	if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) {  		if (current_data_rate != 2) {  			u16 bridge_cfg, gpu_cfg;  			u16 bridge_cfg2, gpu_cfg2; @@ -1589,9 +1587,9 @@ static void si_pcie_gen3_enable(struct amdgpu_device *adev)  	pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16);  	tmp16 &= ~0xf; -	if (mask & DRM_PCIE_SPEED_80) +	if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)  		tmp16 |= 3; -	else if (mask & DRM_PCIE_SPEED_50) +	else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2)  		tmp16 |= 2;  	else  		tmp16 |= 1; diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index ce675a7f179a..22f0b7ff3ac9 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c @@ -26,6 +26,7 @@  #include "amdgpu_pm.h"  #include "amdgpu_dpm.h"  #include "amdgpu_atombios.h" +#include "amd_pcie.h"  #include "sid.h"  #include "r600_dpm.h"  #include "si_dpm.h" @@ -3331,29 +3332,6 @@ static void btc_apply_voltage_delta_rules(struct amdgpu_device *adev,  	}  } -static enum amdgpu_pcie_gen r600_get_pcie_gen_support(struct amdgpu_device *adev, -					       u32 sys_mask, -					       enum amdgpu_pcie_gen asic_gen, -					       enum amdgpu_pcie_gen default_gen) -{ -	switch (asic_gen) { -	case AMDGPU_PCIE_GEN1: -		return AMDGPU_PCIE_GEN1; -	case AMDGPU_PCIE_GEN2: -		return AMDGPU_PCIE_GEN2; -	case AMDGPU_PCIE_GEN3: -		return AMDGPU_PCIE_GEN3; -	default: -		if ((sys_mask & DRM_PCIE_SPEED_80) && (default_gen == AMDGPU_PCIE_GEN3)) -			return AMDGPU_PCIE_GEN3; -		else if ((sys_mask & DRM_PCIE_SPEED_50) && (default_gen == AMDGPU_PCIE_GEN2)) -			return AMDGPU_PCIE_GEN2; -		else -			return AMDGPU_PCIE_GEN1; -	} -	return AMDGPU_PCIE_GEN1; -} -  static void r600_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,  			    u32 *p, u32 *u)  { @@ -5028,10 +5006,11 @@ static int si_populate_smc_acpi_state(struct amdgpu_device *adev,  							      table->ACPIState.levels[0].vddc.index,  							      &table->ACPIState.levels[0].std_vddc);  		} -		table->ACPIState.levels[0].gen2PCIE = (u8)r600_get_pcie_gen_support(adev, -										    si_pi->sys_pcie_mask, -										    si_pi->boot_pcie_gen, -										    AMDGPU_PCIE_GEN1); +		table->ACPIState.levels[0].gen2PCIE = +			(u8)amdgpu_get_pcie_gen_support(adev, +							si_pi->sys_pcie_mask, +							si_pi->boot_pcie_gen, +							AMDGPU_PCIE_GEN1);  		if (si_pi->vddc_phase_shed_control)  			si_populate_phase_shedding_value(adev, @@ -7168,10 +7147,10 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev,  	pl->vddc = le16_to_cpu(clock_info->si.usVDDC);  	pl->vddci = le16_to_cpu(clock_info->si.usVDDCI);  	pl->flags = le32_to_cpu(clock_info->si.ulFlags); -	pl->pcie_gen = r600_get_pcie_gen_support(adev, -						 si_pi->sys_pcie_mask, -						 si_pi->boot_pcie_gen, -						 clock_info->si.ucPCIEGen); +	pl->pcie_gen = amdgpu_get_pcie_gen_support(adev, +						   si_pi->sys_pcie_mask, +						   si_pi->boot_pcie_gen, +						   clock_info->si.ucPCIEGen);  	/* patch up vddc if necessary */  	ret = si_get_leakage_voltage_from_leakage_index(adev, pl->vddc, @@ -7326,7 +7305,6 @@ static int si_dpm_init(struct amdgpu_device *adev)  	struct si_power_info *si_pi;  	struct atom_clock_dividers dividers;  	int ret; -	u32 mask;  	si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL);  	if (si_pi == NULL) @@ -7336,11 +7314,9 @@ static int si_dpm_init(struct amdgpu_device *adev)  	eg_pi = &ni_pi->eg;  	pi = &eg_pi->rv7xx; -	ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); -	if (ret) -		si_pi->sys_pcie_mask = 0; -	else -		si_pi->sys_pcie_mask = mask; +	si_pi->sys_pcie_mask = +		(adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) >> +		CAIL_PCIE_LINK_SPEED_SUPPORT_SHIFT;  	si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;  	si_pi->boot_pcie_gen = si_get_current_pcie_speed(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index b2bfedaf57f1..9bab4842cd44 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c @@ -1618,7 +1618,7 @@ static const struct amdgpu_ring_funcs uvd_v6_0_enc_ring_vm_funcs = {  	.set_wptr = uvd_v6_0_enc_ring_set_wptr,  	.emit_frame_size =  		4 + /* uvd_v6_0_enc_ring_emit_pipeline_sync */ -		6 + /* uvd_v6_0_enc_ring_emit_vm_flush */ +		5 + /* uvd_v6_0_enc_ring_emit_vm_flush */  		5 + 5 + /* uvd_v6_0_enc_ring_emit_fence x2 vm fence */  		1, /* uvd_v6_0_enc_ring_insert_end */  	.emit_ib_size = 5, /* uvd_v6_0_enc_ring_emit_ib */  | 

