Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1726351pxb; Thu, 7 Oct 2021 13:51:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx/Lp437O/lFUzbeEhOuuIaaZDAPs7i7OZQOMz25uxsj8aig0ry+lYXJHPnOLHPBcAk3WK X-Received: by 2002:a17:906:2ed1:: with SMTP id s17mr8817147eji.261.1633639909144; Thu, 07 Oct 2021 13:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633639909; cv=none; d=google.com; s=arc-20160816; b=MOZFw8YTdzecr1UIqhRUDf4DE1THmpKaZ9T9h6CB5nHTL4WvGB3PID+R4Txfgmm8Zh Yy+d28dwRBmMjq3/Z5jaQVkgvk9Oq2SSCR/jwBxDQHltqge0enaKMtp2HJGBOWpcQcCm yvIw9j2GtGubRO+SobzAL6RvZnm3vHGxorc+6cI2eW3VXq5hjyXF+xJo0S8AWzQ2KFvR /rMilUs9yo+Qi/JQZ8n/fNDRqSLzz0IfZyLEpPBp6GH9RbKLcDLpae69VCCcvdKqC+gX sdp0FIKg1GOG1CxUy34H675ITOh+58Hy9exTHNpmgw2OlRXlp4dEBwubXYOnnC5YK0aJ xTwg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=0vXLAERJOT6eV0x2T3ACRSK5sfS0df+vTX7/S7lYM4s=; b=gIrktBghEmTka4TNaJavxAQuRHNcKJ4yyh/aQOVqw5bzDic2Zk5WEcbHXUE6dB/xRL UUK4k1d48QRzqRy+R5u2iBzSINWhowBZ9/fgUwz/1IFWKdjf4HEPFW7ggdrAEJ0tWNY6 4uLhjg17B8L92jgrIk51PWRHomMAPwhZKiZ5bL6g+nzWWA7tD1M0hmrajZoJzHHRcZe/ 7a/0zPcU5D2hsWLhQMoWuh7pDPPf4uoLmGWRp2wIqxvqdkq9rb+xAPT/NNg6Ogl/ux8o y0AOHEnvAE6TiwbZ+iGCfXe9ZIpJ3uMqo2VVSAz3BIkZ7nbAo6zkDLjdEoZIWQLUE6KI VUVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@u92.eu header.s=fm3 header.b=HEu90+ci; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=OMQc+zt8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp35si695554ejc.63.2021.10.07.13.51.25; Thu, 07 Oct 2021 13:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@u92.eu header.s=fm3 header.b=HEu90+ci; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=OMQc+zt8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243941AbhJGTkx (ORCPT + 99 others); Thu, 7 Oct 2021 15:40:53 -0400 Received: from wnew1-smtp.messagingengine.com ([64.147.123.26]:50129 "EHLO wnew1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241801AbhJGTks (ORCPT ); Thu, 7 Oct 2021 15:40:48 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 777C02B00A30; Thu, 7 Oct 2021 15:38:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 07 Oct 2021 15:38:54 -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=0vXLAERJOT6eV 0x2T3ACRSK5sfS0df+vTX7/S7lYM4s=; b=HEu90+ciHY+hrpSv8QYI3ImDu+21u hZbeXEFJv8xZ0fN1SqNsncxvZ2Fs3mWoxfJVW8d0oH91gxWY5gLpzSB9tt+orWBj aMWJt4321HM86k4dOBUv1ISvtdyVvW8jwqqnuKtSg5qLLqPlAAl0dSCF4ak9w1K0 JiA8q2K7Lt+HIVUB1GNM1cAsr6Nk7tJ/73Y4R+ik6UMvETkMv838dzJfzbgreFm6 qABZNl3fBzLzOtrS5V1sJd2XzxlQ/2jRQY8b7VN4dDO3GdgCf8PzEZ8HAXqie14K fJkbodQQyGTYjjaoz2rivssmuDIA2zrR0fNYFdcc2XA9w9Zx042f/vlxw== 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=0vXLAERJOT6eV0x2T3ACRSK5sfS0df+vTX7/S7lYM4s=; b=OMQc+zt8 rZWT2116908DwRKBzB4/uK3hX3oqKp1Yrhm/RehMgz7hin3fSVMaoGP8DW/JSdWf 3tPmOWPottPq5AuvgDBFbwjcqk2TOqm7TRs/0TCDxPXb/76CyNUfIGM8MN6DzTUC FCutS3e2JWYpGkmg7LYoL/90u23mv6QSzM8dQWorKtC8D3UNAsS/wduNKHfR/Alh 1ZWeZyibAubd80tc6C5CXU2ibQS8SlANe7XapUtBkJGJgsus/KH7rXb8dAmOpv52 A79dJOTiKOrv4ANF3RPBRGbJyFYsiz5sxnThCdeaUhYNjiflo2xteibdJsV/JF+N XBhkQR9CFTzc3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudelkedgudefjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefhvghrnhgrnhguohcutfgrmhhoshcuoehgrhgvvghnfhho ohesuhelvddrvghuqeenucggtffrrghtthgvrhhnpeekleekjedtheejheekfefggeevvd fgueegffeuveduhfehueegkeeijedvvdejfeenucevlhhushhtvghrufhiiigvpedunecu rfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvvghnfhhoohesuhelvddrvghu X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Oct 2021 15:38:50 -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 v3 12/20] drm/i915: cleanup: drm_modeset_lock_all() --> DRM_MODESET_LOCK_ALL_BEGIN() Date: Thu, 7 Oct 2021 21:37:47 +0200 Message-Id: <20211007193755.29579-13-greenfoo@u92.eu> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211007193755.29579-1-greenfoo@u92.eu> References: <20211007193755.29579-1-greenfoo@u92.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As requested in Documentation/gpu/todo.rst, replace driver calls to drm_modeset_lock_all() with DRM_MODESET_LOCK_ALL_BEGIN() and DRM_MODESET_LOCK_ALL_END() Signed-off-by: Fernando Ramos --- drivers/gpu/drm/i915/display/intel_audio.c | 16 ++++--- .../drm/i915/display/intel_display_debugfs.c | 46 ++++++++++++------- drivers/gpu/drm/i915/display/intel_overlay.c | 6 ++- drivers/gpu/drm/i915/display/intel_pipe_crc.c | 7 ++- drivers/gpu/drm/i915/i915_drv.c | 13 ++++-- 5 files changed, 58 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c index 03e8c05a74f6..37699f13b21f 100644 --- a/drivers/gpu/drm/i915/display/intel_audio.c +++ b/drivers/gpu/drm/i915/display/intel_audio.c @@ -26,6 +26,7 @@ #include #include +#include #include "i915_drv.h" #include "intel_atomic.h" @@ -1225,7 +1226,8 @@ static int i915_audio_component_bind(struct device *i915_kdev, { struct i915_audio_component *acomp = data; struct drm_i915_private *dev_priv = kdev_to_i915(i915_kdev); - int i; + struct drm_modeset_acquire_ctx ctx; + int i, ret; if (drm_WARN_ON(&dev_priv->drm, acomp->base.ops || acomp->base.dev)) return -EEXIST; @@ -1235,16 +1237,16 @@ static int i915_audio_component_bind(struct device *i915_kdev, DL_FLAG_STATELESS))) return -ENOMEM; - drm_modeset_lock_all(&dev_priv->drm); + DRM_MODESET_LOCK_ALL_BEGIN((&dev_priv->drm), ctx, 0, ret); acomp->base.ops = &i915_audio_component_ops; acomp->base.dev = i915_kdev; BUILD_BUG_ON(MAX_PORTS != I915_MAX_PORTS); for (i = 0; i < ARRAY_SIZE(acomp->aud_sample_rate); i++) acomp->aud_sample_rate[i] = 0; dev_priv->audio_component = acomp; - drm_modeset_unlock_all(&dev_priv->drm); + DRM_MODESET_LOCK_ALL_END((&dev_priv->drm), ctx, ret); - return 0; + return ret; } static void i915_audio_component_unbind(struct device *i915_kdev, @@ -1252,12 +1254,14 @@ static void i915_audio_component_unbind(struct device *i915_kdev, { struct i915_audio_component *acomp = data; struct drm_i915_private *dev_priv = kdev_to_i915(i915_kdev); + struct drm_modeset_acquire_ctx ctx; + int ret; - drm_modeset_lock_all(&dev_priv->drm); + DRM_MODESET_LOCK_ALL_BEGIN((&dev_priv->drm), ctx, 0, ret); acomp->base.ops = NULL; acomp->base.dev = NULL; dev_priv->audio_component = NULL; - drm_modeset_unlock_all(&dev_priv->drm); + DRM_MODESET_LOCK_ALL_END((&dev_priv->drm), ctx, ret); device_link_remove(hda_kdev, i915_kdev); diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c index 309d74fd86ce..8a4cc82f9f23 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -5,6 +5,7 @@ #include #include +#include #include "i915_debugfs.h" #include "intel_display_debugfs.h" @@ -1058,11 +1059,13 @@ static int i915_display_info(struct seq_file *m, void *unused) struct intel_crtc *crtc; struct drm_connector *connector; struct drm_connector_list_iter conn_iter; + struct drm_modeset_acquire_ctx ctx; intel_wakeref_t wakeref; + int ret; wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm); - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); seq_printf(m, "CRTC info\n"); seq_printf(m, "---------\n"); @@ -1077,20 +1080,21 @@ static int i915_display_info(struct seq_file *m, void *unused) intel_connector_info(m, connector); drm_connector_list_iter_end(&conn_iter); - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref); - return 0; + return ret; } static int i915_shared_dplls_info(struct seq_file *m, void *unused) { struct drm_i915_private *dev_priv = node_to_i915(m->private); struct drm_device *dev = &dev_priv->drm; - int i; + struct drm_modeset_acquire_ctx ctx; + int i, ret; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); seq_printf(m, "PLL refclks: non-SSC: %d kHz, SSC: %d kHz\n", dev_priv->dpll.ref_clks.nssc, @@ -1133,9 +1137,9 @@ static int i915_shared_dplls_info(struct seq_file *m, void *unused) seq_printf(m, " mg_pll_tdc_coldst_bias: 0x%08x\n", pll->state.hw_state.mg_pll_tdc_coldst_bias); } - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); - return 0; + return ret; } static int i915_ipc_status_show(struct seq_file *m, void *data) @@ -1194,13 +1198,15 @@ static int i915_ddb_info(struct seq_file *m, void *unused) { struct drm_i915_private *dev_priv = node_to_i915(m->private); struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; struct skl_ddb_entry *entry; struct intel_crtc *crtc; + int ret; if (DISPLAY_VER(dev_priv) < 9) return -ENODEV; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); seq_printf(m, "%-15s%8s%8s%8s\n", "", "Start", "End", "Size"); @@ -1224,9 +1230,9 @@ static int i915_ddb_info(struct seq_file *m, void *unused) entry->end, skl_ddb_entry_size(entry)); } - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); - return 0; + return ret; } static void drrs_status_per_crtc(struct seq_file *m, @@ -1304,10 +1310,12 @@ static int i915_drrs_status(struct seq_file *m, void *unused) { struct drm_i915_private *dev_priv = node_to_i915(m->private); struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; struct intel_crtc *crtc; int active_crtc_cnt = 0; + int ret; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); for_each_intel_crtc(dev, crtc) { if (crtc->base.state->active) { active_crtc_cnt++; @@ -1316,7 +1324,7 @@ static int i915_drrs_status(struct seq_file *m, void *unused) drrs_status_per_crtc(m, dev, crtc); } } - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); if (!active_crtc_cnt) seq_puts(m, "No active crtc found\n"); @@ -1593,8 +1601,10 @@ static void wm_latency_show(struct seq_file *m, const u16 wm[8]) { struct drm_i915_private *dev_priv = m->private; struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; int level; int num_levels; + int ret; if (IS_CHERRYVIEW(dev_priv)) num_levels = 3; @@ -1605,7 +1615,7 @@ static void wm_latency_show(struct seq_file *m, const u16 wm[8]) else num_levels = ilk_wm_max_level(dev_priv) + 1; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); for (level = 0; level < num_levels; level++) { unsigned int latency = wm[level]; @@ -1626,7 +1636,7 @@ static void wm_latency_show(struct seq_file *m, const u16 wm[8]) level, wm[level], latency / 10, latency % 10); } - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); } static int pri_wm_latency_show(struct seq_file *m, void *data) @@ -1710,6 +1720,7 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, struct seq_file *m = file->private_data; struct drm_i915_private *dev_priv = m->private; struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; u16 new[8] = { 0 }; int num_levels; int level; @@ -1739,12 +1750,15 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf, if (ret != num_levels) return -EINVAL; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); for (level = 0; level < num_levels; level++) wm[level] = new[level]; - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); + + if (ret) + return ret; return len; } diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c b/drivers/gpu/drm/i915/display/intel_overlay.c index 7e3f5c6ca484..c0ee135e5499 100644 --- a/drivers/gpu/drm/i915/display/intel_overlay.c +++ b/drivers/gpu/drm/i915/display/intel_overlay.c @@ -27,6 +27,7 @@ */ #include +#include #include "gem/i915_gem_pm.h" #include "gt/intel_gpu_commands.h" @@ -1263,6 +1264,7 @@ int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, { struct drm_intel_overlay_attrs *attrs = data; struct drm_i915_private *dev_priv = to_i915(dev); + struct drm_modeset_acquire_ctx ctx; struct intel_overlay *overlay; int ret; @@ -1272,7 +1274,7 @@ int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, return -ENODEV; } - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); ret = -EINVAL; if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) { @@ -1329,7 +1331,7 @@ int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, ret = 0; out_unlock: - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); return ret; } diff --git a/drivers/gpu/drm/i915/display/intel_pipe_crc.c b/drivers/gpu/drm/i915/display/intel_pipe_crc.c index 8ac263f471be..d0bc74904b93 100644 --- a/drivers/gpu/drm/i915/display/intel_pipe_crc.c +++ b/drivers/gpu/drm/i915/display/intel_pipe_crc.c @@ -29,6 +29,8 @@ #include #include +#include + #include "intel_atomic.h" #include "intel_de.h" #include "intel_display_types.h" @@ -76,6 +78,7 @@ static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv, enum intel_pipe_crc_source *source) { struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; struct intel_encoder *encoder; struct intel_crtc *crtc; struct intel_digital_port *dig_port; @@ -83,7 +86,7 @@ static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv, *source = INTEL_PIPE_CRC_SOURCE_PIPE; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); for_each_intel_encoder(dev, encoder) { if (!encoder->base.crtc) continue; @@ -120,7 +123,7 @@ static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv, break; } } - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); return ret; } diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index c65c3742887a..298a5b12e882 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "display/intel_acpi.h" #include "display/intel_bw.h" @@ -1010,31 +1011,35 @@ static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file) static void intel_suspend_encoders(struct drm_i915_private *dev_priv) { struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; struct intel_encoder *encoder; + int ret; if (!HAS_DISPLAY(dev_priv)) return; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); for_each_intel_encoder(dev, encoder) if (encoder->suspend) encoder->suspend(encoder); - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); } static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) { struct drm_device *dev = &dev_priv->drm; + struct drm_modeset_acquire_ctx ctx; struct intel_encoder *encoder; + int ret; if (!HAS_DISPLAY(dev_priv)) return; - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); for_each_intel_encoder(dev, encoder) if (encoder->shutdown) encoder->shutdown(encoder); - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); } void i915_driver_shutdown(struct drm_i915_private *i915) -- 2.33.0