From patchwork Thu May 25 01:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jammy Huang X-Patchwork-Id: 98736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp43338vqr; Wed, 24 May 2023 18:41:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6K+WIyGnFP5t/YSFGQ5AsjuChmQm9pBclQv3KA4/9diPD5qfN8iVEgAOLIhbDCDNGSrRK4 X-Received: by 2002:a05:6a21:99a8:b0:10c:3557:399a with SMTP id ve40-20020a056a2199a800b0010c3557399amr10028976pzb.49.1684978876014; Wed, 24 May 2023 18:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684978876; cv=none; d=google.com; s=arc-20160816; b=bQeq5Qb0JejrqHVvrnbDomwUlqHmDzR8sBG5H1I6RffrtDfWUDmOoGYyu/nP0GHnuE izsKXVgmdyJeUIy8VdX3QSbrmOaU8Iqb7sYNXgu5I3LUzE1G3zwEMAlOZWOaWZBB0s60 UHh1CvpXqY+hOcwTPr5aZ53+gdyqVwctZxlgdjb34l7tliXUciOS2fy2KCCgr6opLGWw WFa5c5NZ8+5Dx2HdTvXBcZSOn/ki1veYXnQV70Xv7FOoh+mfnMjU9L7qwLR08WWEHiXB LP/ZI0U4mn1/wlUm6xSBn+vIr9dH6IxQlkDajd6woVKpkdlIjHkxjHDDvHMeSAfx2h9n b+bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ZGNPML81wFBICx8LI6/zXiQ7StnTvmF3Jt+ve7GZDT8=; b=SVonND3kQHU25SY/xjlsBFopu9cxy8HJv4b0Fznsdi1GeUkvOUk069DAwPrZgMeEw3 2sqeM19GGe4KsfU4iqVgv3CeSaH0JnZEXjhb6Lz9l1/vVUes6YeoiG4wDnA4obK0DXl7 toN2VgtxXc4bv+UfZEgzmomz93oPKCGGcvGlp7sS7/9PIzgIhulGPXqn3HnQaNFfnZm1 4cuNHhxbUBIafr1p+sXlbZMLBlS98ygqH3l6CehsLKoD3GvDmaORoZr0pLbwAC5GcY/F bleS73au2mPqXo4iMnxB6NPKwwghUGcPUpsRQwrPQKpyrlosrXhKXrxidCLSESU2no2g wTWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020a656aad000000b0053ef14a4fe8si2251571pgu.446.2023.05.24.18.41.01; Wed, 24 May 2023 18:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236169AbjEYB3a (ORCPT + 99 others); Wed, 24 May 2023 21:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232530AbjEYB31 (ORCPT ); Wed, 24 May 2023 21:29:27 -0400 Received: from mail.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 679C4F5 for ; Wed, 24 May 2023 18:29:24 -0700 (PDT) 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; Thu, 25 May 2023 09:29:21 +0800 From: Jammy Huang To: , , , CC: , Subject: [PATCH v2] drm/ast: Fix modeset failed on DisplayPort Date: Thu, 25 May 2023 09:29:18 +0800 Message-ID: <20230525012918.11918-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766828409972619903?= X-GMAIL-MSGID: =?utf-8?q?1766828409972619903?= If we switch display and update cursor together, it could lead to modeset failed because of concurrent access to IO registers. Add lock protection in DP's edid access to avoid this problem. Signed-off-by: Jammy Huang Reviewed-by: Thomas Zimmermann --- v2 changes: - Fix build error since new struct ast_device is used. --- drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++ 1 file changed, 11 insertions(+) base-commit: 933174ae28ba72ab8de5b35cb7c98fc211235096 diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 36374828f6c8..9fcbf540d6fc 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -1647,6 +1647,8 @@ static int ast_dp501_output_init(struct ast_device *ast) static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) { void *edid; + struct drm_device *dev = connector->dev; + struct ast_device *ast = to_ast_device(dev); int succ; int count; @@ -1655,10 +1657,18 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) if (!edid) goto err_drm_connector_update_edid_property; + /* + * Protect access to I/O registers from concurrent modesetting + * by acquiring the I/O-register lock. + */ + mutex_lock(&ast->ioregs_lock); + succ = ast_astdp_read_edid(connector->dev, edid); if (succ < 0) goto err_kfree; + mutex_unlock(&ast->ioregs_lock); + drm_connector_update_edid_property(connector, edid); count = drm_add_edid_modes(connector, edid); kfree(edid); @@ -1666,6 +1676,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) return count; err_kfree: + mutex_unlock(&ast->ioregs_lock); kfree(edid); err_drm_connector_update_edid_property: drm_connector_update_edid_property(connector, NULL);