From patchwork Tue Apr 25 07:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jammy Huang X-Patchwork-Id: 87265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3227434vqo; Tue, 25 Apr 2023 00:26:41 -0700 (PDT) X-Google-Smtp-Source: AKy350byM/SjAFSNxpoJNoatM9GhaTX6kCC2z1gySNlbkXhgVFgNYrIqyrdtnYVuisk3D0hXIjA/ X-Received: by 2002:a17:903:24e:b0:19d:778:ff5 with SMTP id j14-20020a170903024e00b0019d07780ff5mr20494943plh.15.1682407601418; Tue, 25 Apr 2023 00:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682407601; cv=none; d=google.com; s=arc-20160816; b=vc/D4Nizu28CmGXJO3uikBDJtmH8j2dV2Lejwv06w3zSBnoQXBrdtfagA9OcqvtVol zHq1IXYMONr63eIHns9vTI/2CvXJdo4qce50xzq6Nr4dINDwnIwSfn126hJ6BV/iXl3T XAXtX0ytoW+BYhnDrKUxr2LYrkFZsl+W0fEolomU7JvqzrAUz+b8JtNykkG9SDhRaZdk 66FLpaUVetkYnaCyZ+vYAbxywnUNJhnMfo83ryyLDiCxFWVbyn8p1b46/3k0aUKeEpI2 XgWvZO0jaJsdgPdHLuZdcvHTqITOZ3hbu0oOoTOSM2HTN/FXn/WpJ24eeh6+xGd3R9sp Fezw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o2-20020a1709026b0200b0019a9f8bdba0si12326572plk.62.2023.04.25.00.26.26; Tue, 25 Apr 2023 00:26:41 -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 S233333AbjDYHEQ (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764132233053534122?= X-GMAIL-MSGID: =?utf-8?q?1764132233053534122?= 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(+) base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b 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);