Commit bed61c8f authored by Jammy Huang's avatar Jammy Huang Committed by Thomas Zimmermann
Browse files

drm/ast: Fix long time waiting on s3/s4 resume



In resume, DP's launch function, ast_dp_launch, could wait at most 30
seconds before timeout to check if DP is enabled. It could lead to 'DPM
device timeout' and trigger unrecoverable kernel panic.

To avoid this problem, we check if DP enable or not at driver probe only.

Reported-and-tested-by: default avatarWendy Wang <wendy.wang@intel.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217278


Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarJammy Huang <jammy_huang@aspeedtech.com>
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230530041240.13427-1-jammy_huang@aspeedtech.com
parent e79d85c6
Loading
Loading
Loading
Loading
+17 −38
Original line number Diff line number Diff line
@@ -119,35 +119,15 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
/*
 * Launch Aspeed DP
 */
void ast_dp_launch(struct drm_device *dev, u8 bPower)
void ast_dp_launch(struct drm_device *dev)
{
	u32 i = 0, j = 0, WaitCount = 1;
	u8 bDPTX = 0;
	u32 i = 0;
	u8 bDPExecute = 1;

	struct ast_device *ast = to_ast_device(dev);
	// S3 come back, need more time to wait BMC ready.
	if (bPower)
		WaitCount = 300;


	// Wait total count by different condition.
	for (j = 0; j < WaitCount; j++) {
		bDPTX = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, TX_TYPE_MASK);

		if (bDPTX)
			break;

		msleep(100);
	}

	// 0xE : ASTDP with DPMCU FW handling
	if (bDPTX == ASTDP_DPMCU_TX) {
	// Wait one second then timeout.
		i = 0;

		while (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, COPROCESSOR_LAUNCH) !=
			COPROCESSOR_LAUNCH) {
	while (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, ASTDP_MCU_FW_EXECUTING) !=
		ASTDP_MCU_FW_EXECUTING) {
		i++;
		// wait 100 ms
		msleep(100);
@@ -159,14 +139,13 @@ void ast_dp_launch(struct drm_device *dev, u8 bPower)
		}
	}

		if (bDPExecute)
			ast->tx_chip_types |= BIT(AST_TX_ASTDP);
	if (!bDPExecute)
		drm_err(dev, "Wait DPMCU executing timeout\n");

	ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xE5,
			       (u8) ~ASTDP_HOST_EDID_READ_DONE_MASK,
			       ASTDP_HOST_EDID_READ_DONE);
}
}



+1 −4
Original line number Diff line number Diff line
@@ -350,9 +350,6 @@ int ast_mode_config_init(struct ast_device *ast);
#define AST_DP501_LINKRATE	0xf014
#define AST_DP501_EDID_DATA	0xf020

/* Define for Soc scratched reg */
#define COPROCESSOR_LAUNCH			BIT(5)

/*
 * Display Transmitter Type:
 */
@@ -480,7 +477,7 @@ struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev);

/* aspeed DP */
int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
void ast_dp_launch(struct drm_device *dev, u8 bPower);
void ast_dp_launch(struct drm_device *dev);
void ast_dp_power_on_off(struct drm_device *dev, bool no);
void ast_dp_set_on_off(struct drm_device *dev, bool no);
void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode);
+9 −2
Original line number Diff line number Diff line
@@ -254,8 +254,13 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
		case 0x0c:
			ast->tx_chip_types = AST_TX_DP501_BIT;
		}
	} else if (ast->chip == AST2600)
		ast_dp_launch(&ast->base, 0);
	} else if (ast->chip == AST2600) {
		if (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, TX_TYPE_MASK) ==
		    ASTDP_DPMCU_TX) {
			ast->tx_chip_types = AST_TX_ASTDP_BIT;
			ast_dp_launch(&ast->base);
		}
	}

	/* Print stuff for diagnostic purposes */
	if (ast->tx_chip_types & AST_TX_NONE_BIT)
@@ -264,6 +269,8 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
		drm_info(dev, "Using Sil164 TMDS transmitter\n");
	if (ast->tx_chip_types & AST_TX_DP501_BIT)
		drm_info(dev, "Using DP501 DisplayPort transmitter\n");
	if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
		drm_info(dev, "Using ASPEED DisplayPort transmitter\n");

	return 0;
}
+2 −1
Original line number Diff line number Diff line
@@ -380,7 +380,8 @@ void ast_post_gpu(struct drm_device *dev)
	ast_set_def_ext_reg(dev);

	if (ast->chip == AST2600) {
		ast_dp_launch(dev, 1);
		if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
			ast_dp_launch(dev);
	} else if (ast->config_mode == ast_use_p2a) {
		if (ast->chip == AST2500)
			ast_post_chip_2500(dev);