[PATCH v4] drm/ast: Disable fast reset after DRAM initial
Thomas Zimmermann
tzimmermann at suse.de
Wed Jun 23 08:02:58 UTC 2021
Hi,
here's the review that you've been waiting for. Sorry for taking so long.
Am 07.05.21 um 11:27 schrieb KuoHsiang Chou:
> [Bug][AST2500]
>
> V1:
> When AST2500 acts as stand-alone VGA so that DRAM and DVO initialization
> have to be achieved by VGA driver with P2A (PCI to AHB) enabling.
> However, HW suggests disable Fast reset mode after DRAM initializaton,
> because fast reset mode is mainly designed for ARM ICE debugger.
> Once Fast reset is checked as enabling, WDT (Watch Dog Timer) should be
> first enabled to avoid system deadlock before disable fast reset mode.
>
> V2:
> Use to_pci_dev() to get revision of PCI configuration.
>
> V3:
> If SCU00 is not unlocked, just enter its password again.
> It is unnecessary to clear AHB lock condition and restore WDT default
> setting again, before Fast-reset clearing.
>
> V4:
> repatch after "error : could not build fake ancestor" resolved.
>
> Signed-off-by: KuoHsiang Chou <kuohsiang_chou at aspeedtech.com>
> ---
> drivers/gpu/drm/ast/ast_drv.h | 1 +
> drivers/gpu/drm/ast/ast_main.c | 4 ++
> drivers/gpu/drm/ast/ast_post.c | 68 +++++++++++++++++++++-------------
> 3 files changed, 47 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
> index 911f9f414..5ebb5905d 100644
> --- a/drivers/gpu/drm/ast/ast_drv.h
> +++ b/drivers/gpu/drm/ast/ast_drv.h
> @@ -346,6 +346,7 @@ 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);
> /* 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);
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index 2aff2e6cf..cfb56ea3a 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -97,6 +97,10 @@ static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev)
> jregd0 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
> jregd1 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
> if (!(jregd0 & 0x80) || !(jregd1 & 0x10)) {
> + /* Patch AST2500 */
> + if (((pdev->revision & 0xF0) == 0x40) && ((jregd0 & 0xC0) == 0))
These magic numbers are hard to read. Is there any way of make it more
clear what we're testing for? Constants? Helper functions?
> + ast_patch_ahb_2500(ast);
> +
> /* Double check it's actually working */
> data = ast_read32(ast, 0xf004);
> if ((data != 0xFFFFFFFF) && (data != 0x00)) {
> diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
> index 0607658dd..56428798a 100644
> --- a/drivers/gpu/drm/ast/ast_post.c
> +++ b/drivers/gpu/drm/ast/ast_post.c
> @@ -2028,6 +2028,30 @@ static bool ast_dram_init_2500(struct ast_private *ast)
> return true;
> }
>
> +void ast_patch_ahb_2500(struct ast_private *ast)
> +{
> + u32 data;
Only a single space after the type.
> +
> + /* Clear bus lock condition */
> + ast_moutdwm(ast, 0x1e600000, 0xAEED1A03);
> + ast_moutdwm(ast, 0x1e600084, 0x00010000);
> + ast_moutdwm(ast, 0x1e600088, 0x00000000);
> + ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
> + data = ast_mindwm(ast, 0x1e6e2070);
> + if (data & 0x08000000) { /* check fast reset */
> +
No empty line here.
> + ast_moutdwm(ast, 0x1E785004, 0x00000010);
> + ast_moutdwm(ast, 0x1E785008, 0x00004755);
> + ast_moutdwm(ast, 0x1E78500c, 0x00000033);
> + udelay(1000);
> + }
> + do {
> + ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
> + data = ast_mindwm(ast, 0x1e6e2000);
> + } while (data != 1);
> + ast_moutdwm(ast, 0x1e6e207c, 0x08000000); /* clear fast reset */
> +}
> +
> void ast_post_chip_2500(struct drm_device *dev)
> {
> struct ast_private *ast = to_ast_private(dev);
> @@ -2035,39 +2059,31 @@ void ast_post_chip_2500(struct drm_device *dev)
> u8 reg;
>
> reg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
> - if ((reg & 0x80) == 0) {/* vga only */
> + if ((reg & 0xC0) == 0) {/* vga only */
Why this change?
> /* Clear bus lock condition */
> - ast_moutdwm(ast, 0x1e600000, 0xAEED1A03);
> - ast_moutdwm(ast, 0x1e600084, 0x00010000);
> - ast_moutdwm(ast, 0x1e600088, 0x00000000);
> - ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
> - ast_write32(ast, 0xf004, 0x1e6e0000);
> - ast_write32(ast, 0xf000, 0x1);
> - ast_write32(ast, 0x12000, 0x1688a8a8);
> - while (ast_read32(ast, 0x12000) != 0x1)
> - ;
> -
> - ast_write32(ast, 0x10000, 0xfc600309);
> - while (ast_read32(ast, 0x10000) != 0x1)
> - ;
> + ast_patch_ahb_2500(ast);
You're calling this function here, but it's different from the old code.
> +
> + /* Disable watchdog */
> + ast_moutdwm(ast, 0x1E78502C, 0x00000000);
> + ast_moutdwm(ast, 0x1E78504C, 0x00000000);
> + /* Reset USB port */
Reset USB port? In the graphics driver?
The whole gpu post/init code is undecipherable to me. It's full of magic
numbers that are nowhere documented.
Therefore, the overall problem with this patch is that I have no idea
what the actual bug fix is.
Is it possible to first refactor that code a bit and then add a
minimal fix?
Best regards
Thomas
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20210623/f40ec2f4/attachment-0001.sig>
More information about the dri-devel
mailing list