From patchwork Wed Oct 13 20:48:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fernando Ramos X-Patchwork-Id: 12557029 X-Patchwork-Delegate: kieran@bingham.xyz 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F89BC433F5 for ; Wed, 13 Oct 2021 20:50:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C1EB610FE for ; Wed, 13 Oct 2021 20:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230452AbhJMUwL (ORCPT ); Wed, 13 Oct 2021 16:52:11 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:60855 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbhJMUvr (ORCPT ); Wed, 13 Oct 2021 16:51:47 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 9EC94581178; Wed, 13 Oct 2021 16:49:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 13 Oct 2021 16:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u92.eu; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=ecsQu7tdKkgkn KncDSxCGakyZcMIr6lVyFBxuQ1iKRU=; b=GnhF9DahHnTnPd4Tq+xVAhQPnlE0N bWHwLdwx2rJvORYJ9xSsDDptaR35qrzTgs+U7HkLbeCSO0uPWiuqxFZ/QV27+WTM vHuNy1O0UP4RoSdFXTbIM9MVnoGpYPUvZof/o/xm2Ctnd5Q546ItIOkjjwEUClcz QRNg95uER3+0cRbNVTwrLjoxz+PaZW6Hba2VuflbS5EPZCliWMSXUAwnT549U5Iy wFNkLbg/4SC9jfhwkQGPxG+/F6LgGhaiJ82qVHREOWdHCB1F9j8g9aA6CP6S/aca oC49xbl20GiksOET5HBYvZrGfXOGI1O9EiyNR/44dt1HdRAHl+bOv549w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=ecsQu7tdKkgknKncDSxCGakyZcMIr6lVyFBxuQ1iKRU=; b=EcdqXkkc puD4F+sN9+xN0bqSXEM0zLlL/V5tEbz6Qid4g9y8aAFTOEeOpO2DDwDcjbzr2Sv6 /PlU2rwpgxu91KyoGsHJd2xUOWY2nEMwhBJgQ9mnSirvpS0/L+iRmh3o+131Oc51 U4Nl9yvOKd7rqcqBf2R7m7QPBDmyuZJkEJVarxK0lJPkBq0I2m13YoL5jHEaoyBU 3p5EbF30OebM8EirWJ9oENXwxJh54h1MhKJ5NAKPSf5zBxbjZawYH0Y6yHfviRa6 D/6E0899/0vCOF1weF5QhOPR1fX3dWGhy6XLrOzDTMI0PCV+DHxYUUon9o4SrjUt zywlkIeoDQqYsw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddutddgudehvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefhvghrnhgrnhguohcutfgrmhhoshcuoehgrhgvvghnfhho ohesuhelvddrvghuqeenucggtffrrghtthgvrhhnpeekleekjedtheejheekfefggeevvd fgueegffeuveduhfehueegkeeijedvvdejfeenucevlhhushhtvghrufhiiigvpedunecu rfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvvghnfhhoohesuhelvddrvghu X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Oct 2021 16:49:40 -0400 (EDT) From: Fernando Ramos To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, sean@poorly.run, linux-doc@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v4 17/20] drm/amd: cleanup: drm_modeset_lock_all() --> DRM_MODESET_LOCK_ALL_BEGIN() [part 2] Date: Wed, 13 Oct 2021 22:48:43 +0200 Message-Id: <20211013204846.90026-18-greenfoo@u92.eu> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211013204846.90026-1-greenfoo@u92.eu> References: <20211013204846.90026-1-greenfoo@u92.eu> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Refactor places using drm_modeset_{lock,unlock}_all() so that they only appear once per function. This is needed so that in the next commit I can replace those functions by the new macros (which use labels that can only appear once per function). Signed-off-by: Fernando Ramos --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 43 ++++++++----------- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 18 +++----- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index f35561b5a465..10ed1f8ad514 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2935,13 +2935,6 @@ static void handle_hpd_irq_helper(struct amdgpu_dm_connector *aconnector) if (aconnector->base.force && new_connection_type == dc_connection_none) { emulated_link_detect(aconnector->dc_link); - drm_modeset_lock_all(dev); - dm_restore_drm_connector_state(dev, connector); - drm_modeset_unlock_all(dev); - - if (aconnector->base.force == DRM_FORCE_UNSPECIFIED) - drm_kms_helper_hotplug_event(dev); - } else if (dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD)) { if (new_connection_type == dc_connection_none && aconnector->dc_link->type == dc_connection_none && @@ -2950,13 +2943,18 @@ static void handle_hpd_irq_helper(struct amdgpu_dm_connector *aconnector) amdgpu_dm_update_connector_after_detect(aconnector); - drm_modeset_lock_all(dev); - dm_restore_drm_connector_state(dev, connector); - drm_modeset_unlock_all(dev); - - if (aconnector->base.force == DRM_FORCE_UNSPECIFIED) - drm_kms_helper_hotplug_event(dev); + } else { + goto out; } + + drm_modeset_lock_all(dev); + dm_restore_drm_connector_state(dev, connector); + drm_modeset_unlock_all(dev); + + if (aconnector->base.force == DRM_FORCE_UNSPECIFIED) + drm_kms_helper_hotplug_event(dev); + +out: mutex_unlock(&aconnector->hpd_lock); } @@ -3144,12 +3142,6 @@ static void handle_hpd_rx_irq(void *param) amdgpu_dm_update_connector_after_detect(aconnector); - - drm_modeset_lock_all(dev); - dm_restore_drm_connector_state(dev, connector); - drm_modeset_unlock_all(dev); - - drm_kms_helper_hotplug_event(dev); } else if (dc_link_detect(dc_link, DETECT_REASON_HPDRX)) { if (aconnector->fake_enable) @@ -3157,14 +3149,17 @@ static void handle_hpd_rx_irq(void *param) amdgpu_dm_update_connector_after_detect(aconnector); + } else { + goto finish; + } - drm_modeset_lock_all(dev); - dm_restore_drm_connector_state(dev, connector); - drm_modeset_unlock_all(dev); + drm_modeset_lock_all(dev); + dm_restore_drm_connector_state(dev, connector); + drm_modeset_unlock_all(dev); - drm_kms_helper_hotplug_event(dev); - } + drm_kms_helper_hotplug_event(dev); } +finish: #ifdef CONFIG_DRM_AMD_DC_HDCP if (hpd_irq_data.bytes.device_service_irq.bits.CP_IRQ) { if (adev->dm.hdcp_workqueue) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c index 814f67d86a3c..7751038d5788 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c @@ -1237,12 +1237,6 @@ static ssize_t trigger_hotplug(struct file *f, const char __user *buf, goto unlock; amdgpu_dm_update_connector_after_detect(aconnector); - - drm_modeset_lock_all(dev); - dm_restore_drm_connector_state(dev, connector); - drm_modeset_unlock_all(dev); - - drm_kms_helper_hotplug_event(dev); } else if (param[0] == 0) { if (!aconnector->dc_link) goto unlock; @@ -1260,13 +1254,15 @@ static ssize_t trigger_hotplug(struct file *f, const char __user *buf, amdgpu_dm_update_connector_after_detect(aconnector); - drm_modeset_lock_all(dev); - dm_restore_drm_connector_state(dev, connector); - drm_modeset_unlock_all(dev); - - drm_kms_helper_hotplug_event(dev); + } else { + goto unlock; } + drm_modeset_lock_all(dev); + dm_restore_drm_connector_state(dev, connector); + drm_modeset_unlock_all(dev); + drm_kms_helper_hotplug_event(dev); + unlock: mutex_unlock(&aconnector->hpd_lock);