From a38410860628909712ea6a2becd42bab56c70e9a Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 21 Feb 2023 16:57:42 +0100 Subject: drm/ast: Remove little-endianism from I/O helpers Replace one call to ast_io_write16() with two calls to ast_io_write8() in ast_set_index_reg(). The combined 16-bit-wide write of an index register and the corresponding data register only works on little- endian systems. Write both registers independent from each other. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas Link: https://patchwork.freedesktop.org/patch/msgid/20230221155745.27484-2-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_drv.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/ast/ast_drv.h') diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index d51b81fea9c8..1f46162adb64 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -282,7 +282,9 @@ static inline void ast_set_index_reg(struct ast_private *ast, uint32_t base, uint8_t index, uint8_t val) { - ast_io_write16(ast, base, ((u16)val << 8) | index); + ast_io_write8(ast, base, index); + ++base; + ast_io_write8(ast, base, val); } void ast_set_index_reg_mask(struct ast_private *ast, -- cgit From faf67f640fa6c036d19727e294a2915e3fe5bf7c Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 21 Feb 2023 16:57:43 +0100 Subject: drm/ast: Rework definition of I/O read and write helpers Ast defines a number of I/O helpers for accessing hardware. Only 4 of the many generated functions are actually used. Replace the respective generator macros with those 4 functions. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas Link: https://patchwork.freedesktop.org/patch/msgid/20230221155745.27484-3-tzimmermann@suse.de --- drivers/gpu/drm/ast/ast_drv.h | 48 +++++++++++++------------------------------ 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_drv.h') diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 1f46162adb64..6e5ed5bafdc1 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -238,45 +238,25 @@ struct ast_private *ast_device_create(const struct drm_driver *drv, #define AST_IO_VGACRCB_HWC_ENABLED BIT(1) #define AST_IO_VGACRCB_HWC_16BPP BIT(0) /* set: ARGB4444, cleared: 2bpp palette */ -#define __ast_read(x) \ -static inline u##x ast_read##x(struct ast_private *ast, u32 reg) { \ -u##x val = 0;\ -val = ioread##x(ast->regs + reg); \ -return val;\ +static inline u32 ast_read32(struct ast_private *ast, u32 reg) +{ + return ioread32(ast->regs + reg); } -__ast_read(8); -__ast_read(16); -__ast_read(32) - -#define __ast_io_read(x) \ -static inline u##x ast_io_read##x(struct ast_private *ast, u32 reg) { \ -u##x val = 0;\ -val = ioread##x(ast->ioregs + reg); \ -return val;\ +static inline void ast_write32(struct ast_private *ast, u32 reg, u32 val) +{ + iowrite32(val, ast->regs + reg); } -__ast_io_read(8); -__ast_io_read(16); -__ast_io_read(32); - -#define __ast_write(x) \ -static inline void ast_write##x(struct ast_private *ast, u32 reg, u##x val) {\ - iowrite##x(val, ast->regs + reg);\ - } - -__ast_write(8); -__ast_write(16); -__ast_write(32); - -#define __ast_io_write(x) \ -static inline void ast_io_write##x(struct ast_private *ast, u32 reg, u##x val) {\ - iowrite##x(val, ast->ioregs + reg);\ - } +static inline u8 ast_io_read8(struct ast_private *ast, u32 reg) +{ + return ioread8(ast->ioregs + reg); +} -__ast_io_write(8); -__ast_io_write(16); -#undef __ast_io_write +static inline void ast_io_write8(struct ast_private *ast, u32 reg, u8 val) +{ + iowrite8(val, ast->ioregs + reg); +} static inline void ast_set_index_reg(struct ast_private *ast, uint32_t base, uint8_t index, -- cgit 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_drv.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_drv.h') diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 6e5ed5bafdc1..cf4327019468 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -157,7 +157,7 @@ to_ast_sil164_connector(struct drm_connector *connector) * Device */ -struct ast_private { +struct ast_device { struct drm_device base; struct mutex ioregs_lock; /* Protects access to I/O registers in ioregs */ @@ -210,14 +210,14 @@ struct ast_private { const struct firmware *dp501_fw; /* dp501 fw */ }; -static inline struct ast_private *to_ast_private(struct drm_device *dev) +static inline struct ast_device *to_ast_private(struct drm_device *dev) { - return container_of(dev, struct ast_private, base); + return container_of(dev, struct ast_device, base); } -struct ast_private *ast_device_create(const struct drm_driver *drv, - struct pci_dev *pdev, - unsigned long flags); +struct ast_device *ast_device_create(const struct drm_driver *drv, + struct pci_dev *pdev, + unsigned long flags); #define AST_IO_AR_PORT_WRITE (0x40) #define AST_IO_MISC_PORT_WRITE (0x42) @@ -238,27 +238,27 @@ struct ast_private *ast_device_create(const struct drm_driver *drv, #define AST_IO_VGACRCB_HWC_ENABLED BIT(1) #define AST_IO_VGACRCB_HWC_16BPP BIT(0) /* set: ARGB4444, cleared: 2bpp palette */ -static inline u32 ast_read32(struct ast_private *ast, u32 reg) +static inline u32 ast_read32(struct ast_device *ast, u32 reg) { return ioread32(ast->regs + reg); } -static inline void ast_write32(struct ast_private *ast, u32 reg, u32 val) +static inline void ast_write32(struct ast_device *ast, u32 reg, u32 val) { iowrite32(val, ast->regs + reg); } -static inline u8 ast_io_read8(struct ast_private *ast, u32 reg) +static inline u8 ast_io_read8(struct ast_device *ast, u32 reg) { return ioread8(ast->ioregs + reg); } -static inline void ast_io_write8(struct ast_private *ast, u32 reg, u8 val) +static inline void ast_io_write8(struct ast_device *ast, u32 reg, u8 val) { iowrite8(val, ast->ioregs + reg); } -static inline void ast_set_index_reg(struct ast_private *ast, +static inline void ast_set_index_reg(struct ast_device *ast, uint32_t base, uint8_t index, uint8_t val) { @@ -267,15 +267,15 @@ static inline void ast_set_index_reg(struct ast_private *ast, ast_io_write8(ast, base, val); } -void ast_set_index_reg_mask(struct ast_private *ast, +void ast_set_index_reg_mask(struct ast_device *ast, uint32_t base, uint8_t index, uint8_t mask, uint8_t val); -uint8_t ast_get_index_reg(struct ast_private *ast, +uint8_t ast_get_index_reg(struct ast_device *ast, uint32_t base, uint8_t index); -uint8_t ast_get_index_reg_mask(struct ast_private *ast, +uint8_t ast_get_index_reg_mask(struct ast_device *ast, uint32_t base, uint8_t index, uint8_t mask); -static inline void ast_open_key(struct ast_private *ast) +static inline void ast_open_key(struct ast_device *ast) { ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0x80, 0xA8); } @@ -334,7 +334,7 @@ struct ast_crtc_state { #define to_ast_crtc_state(state) container_of(state, struct ast_crtc_state, base) -int ast_mode_config_init(struct ast_private *ast); +int ast_mode_config_init(struct ast_device *ast); #define AST_MM_ALIGN_SHIFT 4 #define AST_MM_ALIGN_MASK ((1 << AST_MM_ALIGN_SHIFT) - 1) @@ -458,16 +458,16 @@ int ast_mode_config_init(struct ast_private *ast); #define ASTDP_1366x768_60 0x1E #define ASTDP_1152x864_75 0x1F -int ast_mm_init(struct ast_private *ast); +int ast_mm_init(struct ast_device *ast); /* ast post */ void ast_enable_vga(struct drm_device *dev); void ast_enable_mmio(struct drm_device *dev); bool ast_is_vga_enabled(struct drm_device *dev); void ast_post_gpu(struct drm_device *dev); -u32 ast_mindwm(struct ast_private *ast, u32 r); -void ast_moutdwm(struct ast_private *ast, u32 r, u32 v); -void ast_patch_ahb_2500(struct ast_private *ast); +u32 ast_mindwm(struct ast_device *ast, u32 r); +void ast_moutdwm(struct ast_device *ast, u32 r, u32 v); +void ast_patch_ahb_2500(struct ast_device *ast); /* ast dp501 */ void ast_set_dp501_video_output(struct drm_device *dev, u8 mode); bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size); -- 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_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/ast/ast_drv.h') diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index cf4327019468..a501169cddad 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -210,7 +210,7 @@ struct ast_device { const struct firmware *dp501_fw; /* dp501 fw */ }; -static inline struct ast_device *to_ast_private(struct drm_device *dev) +static inline struct ast_device *to_ast_device(struct drm_device *dev) { return container_of(dev, struct ast_device, base); } -- 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_drv.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/gpu/drm/ast/ast_drv.h') diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index a501169cddad..5498a6676f2e 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -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); -- cgit