From nobody Thu Dec 18 18:53:41 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12043C77B6E for ; Fri, 14 Apr 2023 07:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbjDNHmy (ORCPT ); Fri, 14 Apr 2023 03:42:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbjDNHmr (ORCPT ); Fri, 14 Apr 2023 03:42:47 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F1D59E9 for ; Fri, 14 Apr 2023 00:42:43 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 33E7Q6Kw033714; Fri, 14 Apr 2023 15:26:06 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from JammyHuang-PC.aspeed.com (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 14 Apr 2023 15:42:07 +0800 From: Jammy Huang To: , CC: , , , Subject: [PATCH v2] drm/ast: Fix long time waiting on s3/s4 resume Date: Fri, 14 Apr 2023 15:42:04 +0800 Message-ID: <20230414074204.5787-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 33E7Q6Kw033714 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In resume, DP's launch function, ast_dp_launch, could wait at most 30 seconds before timeout to check if DP is enabled. To avoid this problem, we only check if DP enable or not at driver probe. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D217278 Signed-off-by: Jammy Huang Acked-by: Thomas Zimmermann --- v2 changes: - Fix build error. --- drivers/gpu/drm/ast/ast_dp.c | 55 +++++++++++----------------------- drivers/gpu/drm/ast/ast_drv.h | 2 +- drivers/gpu/drm/ast/ast_main.c | 11 +++++-- drivers/gpu/drm/ast/ast_post.c | 3 +- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 56483860306b..eee2f264c880 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -119,53 +119,32 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *e= diddata) /* * Launch Aspeed DP */ -void ast_dp_launch(struct drm_device *dev, u8 bPower) +void ast_dp_launch(struct drm_device *dev) { - u32 i =3D 0, j =3D 0, WaitCount =3D 1; - u8 bDPTX =3D 0; + u32 i =3D 0; u8 bDPExecute =3D 1; - struct ast_private *ast =3D to_ast_private(dev); - // S3 come back, need more time to wait BMC ready. - if (bPower) - WaitCount =3D 300; - - - // Wait total count by different condition. - for (j =3D 0; j < WaitCount; j++) { - bDPTX =3D ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, TX_TYPE_MA= SK); - - if (bDPTX) - break; =20 + // Wait one second then timeout. + while (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, COPROCESSOR_LA= UNCH) !=3D + COPROCESSOR_LAUNCH) { + i++; + // wait 100 ms msleep(100); - } =20 - // 0xE : ASTDP with DPMCU FW handling - if (bDPTX =3D=3D ASTDP_DPMCU_TX) { - // Wait one second then timeout. - i =3D 0; - - while (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, COPROCESSOR_L= AUNCH) !=3D - COPROCESSOR_LAUNCH) { - i++; - // wait 100 ms - msleep(100); - - if (i >=3D 10) { - // DP would not be ready. - bDPExecute =3D 0; - break; - } + if (i >=3D 10) { + // DP would not be ready. + bDPExecute =3D 0; + break; } + } =20 - if (bDPExecute) - ast->tx_chip_types |=3D BIT(AST_TX_ASTDP); + if (!bDPExecute) + drm_err(dev, "Wait DPMCU executing timeout\n"); =20 - 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); } =20 =20 diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index d51b81fea9c8..15e86394be4f 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -498,7 +498,7 @@ struct ast_i2c_chan *ast_i2c_create(struct drm_device *= dev); =20 /* 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 *vb= ios_mode); diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index f83ce77127cb..8ecddf20113f 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -254,8 +254,13 @@ static int ast_detect_chip(struct drm_device *dev, boo= l *need_post) case 0x0c: ast->tx_chip_types =3D AST_TX_DP501_BIT; } - } else if (ast->chip =3D=3D AST2600) - ast_dp_launch(&ast->base, 0); + } else if (ast->chip =3D=3D AST2600) { + if (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, TX_TYPE_MASK) = =3D=3D + ASTDP_DPMCU_TX) { + ast->tx_chip_types =3D AST_TX_ASTDP_BIT; + ast_dp_launch(&ast->base); + } + } =20 /* Print stuff for diagnostic purposes */ if (ast->tx_chip_types & AST_TX_NONE_BIT) @@ -264,6 +269,8 @@ static int ast_detect_chip(struct drm_device *dev, bool= *need_post) drm_info(dev, "Using Sil164 TMDS transmitter\n"); if (ast->tx_chip_types & AST_TX_DP501_BIT) drm_info(dev, "Using DP501 DisplayPort transmitter\n"); + if (ast->tx_chip_types & AST_TX_ASTDP_BIT) + drm_info(dev, "Using ASPEED DisplayPort transmitter\n"); =20 return 0; } diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c index 82fd3c8adee1..90e40f59aff7 100644 --- a/drivers/gpu/drm/ast/ast_post.c +++ b/drivers/gpu/drm/ast/ast_post.c @@ -380,7 +380,8 @@ void ast_post_gpu(struct drm_device *dev) ast_set_def_ext_reg(dev); =20 if (ast->chip =3D=3D AST2600) { - ast_dp_launch(dev, 1); + if (ast->tx_chip_types & AST_TX_ASTDP_BIT) + ast_dp_launch(dev); } else if (ast->config_mode =3D=3D ast_use_p2a) { if (ast->chip =3D=3D AST2500) ast_post_chip_2500(dev); base-commit: e62252bc55b6d4eddc6c2bdbf95a448180d6a08d --=20 2.25.1