summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ast
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2023-06-21 15:53:42 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2023-06-27 15:26:33 +0300
commita74ec2bcdc2298ab025a75b9d5683aabf4e4c043 (patch)
tree6d430048fa9c4255488b8c47909fab9531233f50 /drivers/gpu/drm/ast
parent5b71707dd13cb611bba07ab5f38f92b8f7859d6e (diff)
downloadlinux-a74ec2bcdc2298ab025a75b9d5683aabf4e4c043.tar.xz
drm/ast: Set up release action right after enabling MMIO
Ast sets up a managed release of the MMIO access flags. Move this code next to the MMIO access code, so that it runs if other errors occur during the device initialization. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Tested-by: Sui Jingfeng <suijingfeng@loongson.cn> # AST2400 Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Tested-by: Jocelyn Falempe <jfalempe@redhat.com> # AST2600 Link: https://patchwork.freedesktop.org/patch/msgid/20230621130032.3568-9-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast')
-rw-r--r--drivers/gpu/drm/ast/ast_main.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 031ff4ed1920..d2f8396ec0a0 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -70,11 +70,25 @@ static void ast_enable_vga(struct drm_device *dev)
ast_io_write8(ast, AST_IO_MISC_PORT_WRITE, 0x01);
}
-static void ast_enable_mmio(struct drm_device *dev)
+/*
+ * Run this function as part of the HW device cleanup; not
+ * when the DRM device gets released.
+ */
+static void ast_enable_mmio_release(void *data)
{
- struct ast_device *ast = to_ast_device(dev);
+ struct ast_device *ast = data;
+
+ /* enable standard VGA decode */
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
+}
+
+static int ast_enable_mmio(struct ast_device *ast)
+{
+ struct drm_device *dev = &ast->base;
ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x06);
+
+ return devm_add_action_or_reset(dev->dev, ast_enable_mmio_release, ast);
}
static void ast_open_key(struct ast_device *ast)
@@ -391,18 +405,6 @@ static int ast_get_dram_info(struct drm_device *dev)
return 0;
}
-/*
- * Run this function as part of the HW device cleanup; not
- * when the DRM device gets released.
- */
-static void ast_device_release(void *data)
-{
- struct ast_device *ast = data;
-
- /* enable standard VGA decode */
- ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
-}
-
struct ast_device *ast_device_create(const struct drm_driver *drv,
struct pci_dev *pdev,
unsigned long flags)
@@ -464,7 +466,9 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
/* Enable extended register access */
ast_open_key(ast);
- ast_enable_mmio(dev);
+ ret = ast_enable_mmio(ast);
+ if (ret)
+ return ERR_PTR(ret);
/* Find out whether P2A works or whether to use device-tree */
ast_detect_config_mode(dev, &scu_rev);
@@ -497,9 +501,5 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
if (ret)
return ERR_PTR(ret);
- ret = devm_add_action_or_reset(dev->dev, ast_device_release, ast);
- if (ret)
- return ERR_PTR(ret);
-
return ast;
}