From patchwork Thu Jun 1 00:48:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jammy Huang X-Patchwork-Id: 101629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp6727rwl; Wed, 31 May 2023 17:56:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qNTZbZZV25AUbqVsqRjZ/HFggnaJhEEIfkThsUdApLiJEHhv885VZC8vaeZ2GdPs8KBg3 X-Received: by 2002:a25:3752:0:b0:b9e:5d84:d859 with SMTP id e79-20020a253752000000b00b9e5d84d859mr8338028yba.46.1685580969852; Wed, 31 May 2023 17:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685580969; cv=none; d=google.com; s=arc-20160816; b=pczDldYkZmidkQzIFf/5VlfEgA5PP958auzR/vIgtveodMzoX2jh5StO0FsGUAumiR T3Gsi6KIoKRSsK8vWSL37a7NjwuK0gos7pjlYAaj83tdZ79nF6mjcavE7+kLaFXO/97P YNvCksDiXeP8W5Ze7HDgJyZHWVflI9RX4sBntKwwUkxoSRgMSd3k69hCCXAhC2uRRx8g lXbxI3MlRNRubYe0xmtsaBrCmqOc23FcpJMfTgkIoi1UgvEc+QiJdmN9StSZoiEMN1Op BGzCmwYsxgASBEPDTZ4b8dTLRKG2qYl4uVmCAZmJ4ueBBGGP4zdqKdtd066DORKgXNwi A2GQ== 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=QSc/nnHrMyMAIQcViQxz5SWSkEOugSKFFHQDV1+Wzr4=; b=Ek55TBwwGChKq+9olu8NxUa3Pl+3nq9zOHw06xbxfhG7Myd+hTEfBjzuy5xsptt5QE gHK3JV0OPvrHekiQT49vfVOZMPoESvdMvxGsKRqGyp5cJb/FJ28gFCWnRUojhZvPu4wq VT1pJCSPisCY4jMa8mARA5MhiASgPgea7fSN814A7zeMqkE4PDDMakYOB9b1hQvuU9pa 6Fhe1C0LuRlstHaaQSOvuxNMn2+03PsGzHkRsfayJWHgyUX1qCAqP3Dh9uUEepUSvI9q vWOALM3emUv+GyMcAKPa6OYybUlZsRHWr22w6IOB9VRkv3QMjxB4nIBQSDo04cyvsjqN N6oQ== 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 jk2-20020a170903330200b0019acbf1dc4asi1825227plb.181.2023.05.31.17.55.55; Wed, 31 May 2023 17:56:09 -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 S229915AbjFAAtG (ORCPT + 99 others); Wed, 31 May 2023 20:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjFAAtE (ORCPT ); Wed, 31 May 2023 20:49:04 -0400 Received: from mail.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015FA119 for ; Wed, 31 May 2023 17:48:55 -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, 1 Jun 2023 08:48:51 +0800 From: Jammy Huang To: , , , CC: , Subject: [PATCH v3] drm/ast: Fix modeset failed on DisplayPort Date: Thu, 1 Jun 2023 08:48:47 +0800 Message-ID: <20230601004847.1115-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?1767459751005777921?= X-GMAIL-MSGID: =?utf-8?q?1767459751005777921?= 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. Reviewed-by: Thomas Zimmermann Signed-off-by: Jammy Huang --- v3 changes: - Update label name after mutex added. v2 changes: - Fix build error since new struct ast_device is used. --- drivers/gpu/drm/ast/ast_mode.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) base-commit: e338142b39cf40155054f95daa28d210d2ee1b2d diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 36374828f6c8..b3c670af6ef2 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,9 +1657,17 @@ 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; + goto err_mutex_unlock; + + mutex_unlock(&ast->ioregs_lock); drm_connector_update_edid_property(connector, edid); count = drm_add_edid_modes(connector, edid); @@ -1665,7 +1675,8 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) return count; -err_kfree: +err_mutex_unlock: + mutex_unlock(&ast->ioregs_lock); kfree(edid); err_drm_connector_update_edid_property: drm_connector_update_edid_property(connector, NULL);