From 37b42cf904e2ed92a612aa09481385cc9eb2a6ce Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 21 Feb 2023 16:57:44 +0100 Subject: drm/ast: Rename struct ast_private to struct ast_device The data structure struct ast_private represents an AST device. Its name comes from the time when it was allocated and stored separately in struct drm_device.dev_private. The DRM device is now embedded, so rename struct ast_private to struct ast_device. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas Link: https://patchwork.freedesktop.org/patch/msgid/20230221155745.27484-4-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_dp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_dp.c') diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 56483860306b..9e34297d836d 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -9,7 +9,7 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata) { - struct ast_private *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_private(dev); u8 i = 0, j = 0; /* @@ -125,7 +125,7 @@ void ast_dp_launch(struct drm_device *dev, u8 bPower) u8 bDPTX = 0; u8 bDPExecute = 1; - struct ast_private *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_private(dev); // S3 come back, need more time to wait BMC ready. if (bPower) WaitCount = 300; @@ -172,7 +172,7 @@ void ast_dp_launch(struct drm_device *dev, u8 bPower) void ast_dp_power_on_off(struct drm_device *dev, bool on) { - struct ast_private *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_private(dev); // Read and Turn off DP PHY sleep u8 bE3 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xE3, AST_DP_VIDEO_ENABLE); @@ -188,7 +188,7 @@ void ast_dp_power_on_off(struct drm_device *dev, bool on) void ast_dp_set_on_off(struct drm_device *dev, bool on) { - struct ast_private *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_private(dev); u8 video_on_off = on; // Video On/Off @@ -208,7 +208,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on) void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode) { - struct ast_private *ast = to_ast_private(crtc->dev); + struct ast_device *ast = to_ast_private(crtc->dev); u32 ulRefreshRateIndex; u8 ModeIdx; -- cgit From 5abaa6835f42db7a20ff57447d60303cd81495f8 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 21 Feb 2023 16:57:45 +0100 Subject: drm/ast: Rename to_ast_private() to to_ast_device() The helper to_ast_private() now upcasts to struct ast_device. Rename it accordingly. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas Link: https://patchwork.freedesktop.org/patch/msgid/20230221155745.27484-5-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_dp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_dp.c') diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 9e34297d836d..fbb070f63e36 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -9,7 +9,7 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata) { - struct ast_device *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_device(dev); u8 i = 0, j = 0; /* @@ -125,7 +125,7 @@ void ast_dp_launch(struct drm_device *dev, u8 bPower) u8 bDPTX = 0; u8 bDPExecute = 1; - struct ast_device *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_device(dev); // S3 come back, need more time to wait BMC ready. if (bPower) WaitCount = 300; @@ -172,7 +172,7 @@ void ast_dp_launch(struct drm_device *dev, u8 bPower) void ast_dp_power_on_off(struct drm_device *dev, bool on) { - struct ast_device *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_device(dev); // Read and Turn off DP PHY sleep u8 bE3 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xE3, AST_DP_VIDEO_ENABLE); @@ -188,7 +188,7 @@ void ast_dp_power_on_off(struct drm_device *dev, bool on) void ast_dp_set_on_off(struct drm_device *dev, bool on) { - struct ast_device *ast = to_ast_private(dev); + struct ast_device *ast = to_ast_device(dev); u8 video_on_off = on; // Video On/Off @@ -208,7 +208,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on) void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode) { - struct ast_device *ast = to_ast_private(crtc->dev); + struct ast_device *ast = to_ast_device(crtc->dev); u32 ulRefreshRateIndex; u8 ModeIdx; -- cgit From bed61c8fc7ba17d0f259c674137a5198fd2e3334 Mon Sep 17 00:00:00 2001 From: Jammy Huang Date: Tue, 30 May 2023 12:12:40 +0800 Subject: 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: Wendy Wang Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217278 Acked-by: Thomas Zimmermann Signed-off-by: Jammy Huang Signed-off-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/20230530041240.13427-1-jammy_huang@aspeedtech.com --- drivers/gpu/drm/ast/ast_dp.c | 55 ++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 38 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_dp.c') diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index fbb070f63e36..6dc1a09504e1 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -119,53 +119,32 @@ err_astdp_edid_not_ready: /* * 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; + // Wait one second then timeout. + 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); - } - // 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) { - i++; - // wait 100 ms - msleep(100); - - if (i >= 10) { - // DP would not be ready. - bDPExecute = 0; - break; - } + if (i >= 10) { + // DP would not be ready. + bDPExecute = 0; + break; } + } - 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); - } + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xE5, + (u8) ~ASTDP_HOST_EDID_READ_DONE_MASK, + ASTDP_HOST_EDID_READ_DONE); } -- cgit