From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4471ACAC598 for ; Tue, 16 Sep 2025 07:18:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBEF210E6B6; Tue, 16 Sep 2025 07:18:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="YdPwG5U7"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0920A10E6B3; Tue, 16 Sep 2025 07:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758007096; x=1789543096; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Ore7HZ6cvMhY6cBIXRmckVSq1ARj81zP4JcZQnXeVjc=; b=YdPwG5U719+ESmaaH2BZ0UyDKYcaR8W5BwDCha67DeTk6XGVmf4iOfkW FdxAV+zH/gMbAednC1u1uwoJix6c9Krc+6ZJrHwHELzlbvIDYUNIk+5Fx Ik/Y/gcXkozZe+zeQ4UpgWSsGRfmIkJ749PzvfFsG2NVUMa3JblhKYOj2 4BfvoiTAxiarofmErCvK8p1BTw3q8ewmqiiU9tYeOq9j1qf8+YwlsZTfn DjAaApswgYPAZiX0PaYoAScn8g9sZqEDXANaRmECgUwM/vr0vdNWCwDnh BOrYlrpb1NxBDizAenVnwX4eRRkYi62Np0bIzW3ihueAOAk3NjElaDS4+ w==; X-CSE-ConnectionGUID: Xm3iMFvTTbi7w8dSlrUBNg== X-CSE-MsgGUID: I+sw8tn5SXaSDj9axC7DmQ== X-IronPort-AV: E=McAfee;i="6800,10657,11554"; a="70526980" X-IronPort-AV: E=Sophos;i="6.18,268,1751266800"; d="scan'208";a="70526980" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2025 00:18:14 -0700 X-CSE-ConnectionGUID: o+DRAf+ORj2aXYeI3Ln10g== X-CSE-MsgGUID: Kl2D+rLjT66Qx+ZUmN4HUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,268,1751266800"; d="scan'208";a="175650822" Received: from srr4-3-linux-106-armuthy.iind.intel.com ([10.190.238.56]) by fmviesa010.fm.intel.com with ESMTP; 16 Sep 2025 00:18:09 -0700 From: Arun R Murthy Date: Tue, 16 Sep 2025 12:48:13 +0530 Subject: [PATCH v5 3/5] drm/atomic: Allocate atomic_state at the beginning of atomic_ioctl MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250916-atomic-v5-3-821525cfbf25@intel.com> References: <20250916-atomic-v5-0-821525cfbf25@intel.com> In-Reply-To: <20250916-atomic-v5-0-821525cfbf25@intel.com> To: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , xaver.hugl@kde.org, harry.wentland@amd.com, uma.shankar@intel.com Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Arun R Murthy X-Mailer: b4 0.15-dev X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Moving atomic_state allocation to the beginning of the atomci_ioctl to accommodate drm_mode_atomic_err_code usage for returning error code on failures. Signed-off-by: Arun R Murthy --- drivers/gpu/drm/drm_atomic_uapi.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 85dbdaa4a2e25878c953b9b41539c8566d55c6d9..3ef478e717bec917d1b8803c72bbcc8d6409d745 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1394,13 +1394,21 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, struct drm_modeset_acquire_ctx ctx; struct drm_out_fence_state *fence_state; int ret = 0; - unsigned int i, j, num_fences; + unsigned int i, j, num_fences = 0; bool async_flip = false; /* disallow for drivers not supporting atomic: */ if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) return -EOPNOTSUPP; + state = drm_atomic_state_alloc(dev); + if (!state) + return -ENOMEM; + + drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); + state->acquire_ctx = &ctx; + state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET); + /* disallow for userspace that has not enabled atomic cap (even * though this may be a bit overkill, since legacy userspace * wouldn't know how to call this ioctl) @@ -1439,14 +1447,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, return -EINVAL; } - state = drm_atomic_state_alloc(dev); - if (!state) - return -ENOMEM; - - drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); - state->acquire_ctx = &ctx; - state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET); - retry: copied_objs = 0; copied_props = 0; @@ -1543,7 +1543,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } out: - complete_signaling(dev, state, fence_state, num_fences, !ret); + if (num_fences) + complete_signaling(dev, state, fence_state, num_fences, !ret); if (ret == -EDEADLK) { drm_atomic_state_clear(state); -- 2.25.1