From 5792362533f5658512439a1e11fe95901ad35f18 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Mon, 17 Feb 2025 16:20:54 +0800 Subject: [PATCH] drm/ast: Fix io access error when resuming from sleep commit 12c35c5582acb0fd8f7713ffa75f450766022ff1 upstream. Suspend will disable pcie device. Thus, resume should do full hw initialization again. Add some APIs to ast_drm_thaw() before ast_post_gpu() to fix the issue. v2: - fix function-call arguments Fixes: 5b71707dd13c ("drm/ast: Enable and unlock device access early during init") Reported-by: Cary Garrett Closes: https://lore.kernel.org/dri-devel/8ce1e1cc351153a890b65e62fed93b54ccd43f6a.camel@gmail.com/ Cc: Thomas Zimmermann Cc: Jocelyn Falempe Cc: Dave Airlie Cc: dri-devel@lists.freedesktop.org Cc: # v6.6+ Signed-off-by: Jammy Huang Reviewed-by: Thomas Zimmermann Signed-off-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/20240718030352.654155-1-jammy_huang@aspeedtech.com [ wxiat: Redefine some APIs to fix compile error. ] Signed-off-by: Zhou Xuemei [ deepin: Backport - keep out-of-tree, unlikely to merge 6.6.y. ] Signed-off-by: wenlunpeng Signed-off-by: WangYuli --- drivers/gpu/drm/ast/ast_drv.c | 5 +++++ drivers/gpu/drm/ast/ast_drv.h | 7 +++++++ drivers/gpu/drm/ast/ast_main.c | 8 ++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index e1224ef4ad83d..6a2624dc04b4b 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -138,6 +138,11 @@ static int ast_drm_freeze(struct drm_device *dev) static int ast_drm_thaw(struct drm_device *dev) { + struct ast_device *ast = to_ast_device(dev); + + ast_enable_vga(dev); + ast_open_key(ast); + ast_enable_mmio(ast); ast_post_gpu(dev); return drm_mode_config_helper_resume(dev); diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index f7053f2972bb9..a3f37c25f7157 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -340,6 +340,11 @@ static inline void ast_set_index_reg_mask(struct ast_device *ast, u32 base, u8 i ast_set_index_reg(ast, base, index, tmp); } +static inline void ast_open_key(struct ast_device *ast) +{ + ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x80, 0xA8); +} + #define AST_VIDMEM_SIZE_8M 0x00800000 #define AST_VIDMEM_SIZE_16M 0x01000000 #define AST_VIDMEM_SIZE_32M 0x02000000 @@ -518,6 +523,8 @@ int ast_mode_config_init(struct ast_device *ast); int ast_mm_init(struct ast_device *ast); /* ast post */ +void ast_enable_vga(struct drm_device *dev); +int ast_enable_mmio(struct ast_device *ast); void ast_post_gpu(struct drm_device *dev); u32 ast_mindwm(struct ast_device *ast, u32 r); void ast_moutdwm(struct ast_device *ast, u32 r, u32 v); diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index dae365ed39696..9fcd6f8b1bd36 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -45,7 +45,7 @@ static bool ast_is_vga_enabled(struct drm_device *dev) return !!(ch & 0x01); } -static void ast_enable_vga(struct drm_device *dev) +void ast_enable_vga(struct drm_device *dev) { struct ast_device *ast = to_ast_device(dev); @@ -65,7 +65,7 @@ static void ast_enable_mmio_release(void *data) ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04); } -static int ast_enable_mmio(struct ast_device *ast) +int ast_enable_mmio(struct ast_device *ast) { struct drm_device *dev = &ast->base; @@ -74,10 +74,6 @@ static int ast_enable_mmio(struct ast_device *ast) return devm_add_action_or_reset(dev->dev, ast_enable_mmio_release, ast); } -static void ast_open_key(struct ast_device *ast) -{ - ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x80, 0xA8); -} static int ast_device_config_init(struct ast_device *ast) {