Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6581246rwr; Tue, 25 Apr 2023 00:08:37 -0700 (PDT) X-Google-Smtp-Source: AKy350bnlONlY1/hjTnHwkbV/piugeHkKRe/p0RWO2cP++j7xyZzGQH8DPf8pAWXWLz7owJmnTGK X-Received: by 2002:a17:902:f28d:b0:1a1:b440:3773 with SMTP id k13-20020a170902f28d00b001a1b4403773mr15347377plc.27.1682406517386; Tue, 25 Apr 2023 00:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682406517; cv=none; d=google.com; s=arc-20160816; b=GsXWh3BzdsF4z35+GjkT+3M4G6MDtrEXksW3Qvd5m2O50MEn9vIjhAXB9pQg8N6iIW 07mHUNas13Q98WkHBZnfFifz7GA/w+Ulhleuw/7Mn7F3I6xoJ/gbjDkqy14yUJFITcB0 pPjbA3O4ofavW7eHt+YvSb8BmOzLlbAZwkkb9OZ7aCr3y+siKER1cFipEnSZ4hY+Pmk0 Q/jrA+CBAI4t+secDqsD/7N18NQLJUTJJz1GkKGou+KIXcutnMqlNmaZtiLIerNrYq5K a1mmOfxauGXRnHSfxEonXbStd3lBwXgnBtfnT8V6cHVQtmhJEWzeqECJzzjkgpxsq2gI U2Pw== 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=QIX4jh2uJicd+VaKcUfqiyhQEOvv6IDgsC8khpM8efs=; b=fn8mSERBdbn0Sdk8aJTP4BFm66skk2cz2GE0cPsr9JEdUNJyBGtqXCIeyJbb59qEwB sZWTytJfvvsy+hkkAmqLjm8sHQTZ0syh0KxcDCjkxajrr0IX2UEKNpQUJw5iBrTJYCK6 9wU5GMO1QXJCZDQTdS6l0Pp/BA1AG5jPCFMpqZ4OukBKGicZCpzI/RKD8wJph71OTYVG 9ITmYQmocj/w3yoRvJ0RyjxMyOabNNQVnCinA0rhUaXk0oEc6K3L2j7qeQf5fF1PPZ4J 7S2nqcs8a4UZ8SV4CWqte0bppE5dV88VdXGqxyYKcCQAcD/JPU69pK1f7/51Ic5iLz4R 0YOA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a170902ec8f00b001a217a73d56si14082112plg.161.2023.04.25.00.08.08; Tue, 25 Apr 2023 00:08:37 -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 S233313AbjDYHEQ (ORCPT + 99 others); Tue, 25 Apr 2023 03:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbjDYHEN (ORCPT ); Tue, 25 Apr 2023 03:04:13 -0400 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086B34ED5 for ; Tue, 25 Apr 2023 00:04:10 -0700 (PDT) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 33P6kpTP054710; Tue, 25 Apr 2023 14:46:51 +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; Tue, 25 Apr 2023 15:03:32 +0800 From: Jammy Huang To: , CC: , , , Subject: [PATCH] drm/ast: Fix modeset failed on DisplayPort Date: Tue, 25 Apr 2023 15:03:30 +0800 Message-ID: <20230425070330.8520-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 33P6kpTP054710 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 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 --- drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 984ec590a7e7..fe5f1fd61361 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct ast_private *ast) static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) { void *edid; + struct drm_device *dev = connector->dev; + struct ast_private *ast = to_ast_private(dev); int succ; int count; @@ -1643,10 +1645,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); @@ -1654,6 +1664,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); base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b -- 2.25.1