From patchwork Sat Jun 26 07:25:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 467647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7653C49EA6 for ; Sat, 26 Jun 2021 07:25:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B26EA616E8 for ; Sat, 26 Jun 2021 07:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbhFZH2L (ORCPT ); Sat, 26 Jun 2021 03:28:11 -0400 Received: from h4.fbrelay.privateemail.com ([131.153.2.45]:56368 "EHLO h4.fbrelay.privateemail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbhFZH2K (ORCPT ); Sat, 26 Jun 2021 03:28:10 -0400 Received: from MTA-06-3.privateemail.com (mta-06.privateemail.com [68.65.122.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h3.fbrelay.privateemail.com (Postfix) with ESMTPS id 2243E80524 for ; Sat, 26 Jun 2021 03:25:48 -0400 (EDT) Received: from MTA-06.privateemail.com (localhost [127.0.0.1]) by MTA-06.privateemail.com (Postfix) with ESMTP id 3187F6009C; Sat, 26 Jun 2021 03:25:46 -0400 (EDT) Received: from hal-station.. (unknown [10.20.151.246]) by MTA-06.privateemail.com (Postfix) with ESMTPA id F20106009A; Sat, 26 Jun 2021 03:25:43 -0400 (EDT) From: Hamza Mahfooz To: linux-kernel@vger.kernel.org Cc: Sean Paul , Hamza Mahfooz , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6ni?= =?utf-8?q?g?= , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= , Manasi Navare , =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= , Imre Deak , Dave Airlie , Maarten Lankhorst , Karthik B S , Matt Roper , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH] drm/i915/display: replace boilerplate code with helper macros Date: Sat, 26 Jun 2021 03:25:09 -0400 Message-Id: <20210626072513.41049-1-someguy@effective-light.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As per commit 22be87401289 ("drm: TODO: Add DRM_MODESET_LOCK_ALL* conversion to todo.rst"), drm_modeset_lock_all()/drm_modeset_unlock_all() and boilerplate code surronding instances of drm_modeset_lock_all_ctx() with a local acquire context should be replaced with the relevant helper macros. Signed-off-by: Hamza Mahfooz --- drivers/gpu/drm/i915/display/intel_display.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 64e9107d70f7..e8cb2881d2b4 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -40,6 +40,7 @@ #include #include #include +#include "drm/drm_modeset_lock.h" #include #include #include @@ -11836,6 +11837,7 @@ int intel_modeset_init_nogem(struct drm_i915_private *i915) struct drm_device *dev = &i915->drm; enum pipe pipe; struct intel_crtc *crtc; + struct drm_modeset_acquire_ctx ctx; int ret; intel_init_pm(i915); @@ -11884,9 +11886,9 @@ int intel_modeset_init_nogem(struct drm_i915_private *i915) intel_vga_disable(i915); intel_setup_outputs(i915); - drm_modeset_lock_all(dev); + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); intel_modeset_setup_hw_state(dev, dev->mode_config.acquire_ctx); - drm_modeset_unlock_all(dev); + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); for_each_intel_crtc(dev, crtc) { struct intel_initial_plane_config plane_config = {}; @@ -12795,22 +12797,14 @@ void intel_display_resume(struct drm_device *dev) if (state) state->acquire_ctx = &ctx; - drm_modeset_acquire_init(&ctx, 0); - - while (1) { - ret = drm_modeset_lock_all_ctx(dev, &ctx); - if (ret != -EDEADLK) - break; - - drm_modeset_backoff(&ctx); - } + DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, ret); if (!ret) ret = __intel_display_resume(dev, state, &ctx); intel_enable_ipc(dev_priv); - drm_modeset_drop_locks(&ctx); - drm_modeset_acquire_fini(&ctx); + + DRM_MODESET_LOCK_ALL_END(dev, ctx, ret); if (ret) drm_err(&dev_priv->drm,