From patchwork Mon Jun 17 14:18:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13700843 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 49572C2BA15 for ; Mon, 17 Jun 2024 14:19:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C01C910E3E0; Mon, 17 Jun 2024 14:19:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="fpdgdjEv"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D3EB10E3E0; Mon, 17 Jun 2024 14:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718633961; x=1750169961; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yanv56szG+ThJkyYknIv2uah8syWvuCvPX2B4g74ogc=; b=fpdgdjEv2Pyvn3mocq6+tJbD+JPBR2QeaVohCoPct4AYKlU+2BPiSFWv nO1srhQUkPUbwVKpDmU/fvp5S6mRTbxLzncXvfcGo9c2WJVrYZYVQNh/F 1CBJPhQHp+Z6fA0L4UiDD/K9caimmCB79zAXYtHdtLzf4XIGTjXe/GmkA 4ahkRAkfg3+kXN8p25isAbOxqXiO1HGtH++JYoGdNvA/MXHtbzDlsImOB SSK9m9hw10liIyK3HS2x2TBzfnBMpnmcVeFZx88d4ObWRl3yg4iKu+tSG UogJgDbhroiZwYPoaFTy3ihJhYprMGg1FwWA+SHno5WIvHkrzsQ2n2maV g==; X-CSE-ConnectionGUID: u31srAuZSeSD3Aha/tsqZA== X-CSE-MsgGUID: w7Q1xWWyTvWpTzk6g2ciCA== X-IronPort-AV: E=McAfee;i="6700,10204,11105"; a="15593293" X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="15593293" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:21 -0700 X-CSE-ConnectionGUID: +ah75LEDS/iSnsheGkge5A== X-CSE-MsgGUID: n7NELmCvQNOxJyfs6F+qlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="41083510" Received: from mjarzebo-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.85]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:19 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com Subject: [PATCH 1/5] drm/i915/frontbuffer: un-inline frontbuffer bits checks Date: Mon, 17 Jun 2024 17:18:58 +0300 Message-Id: <53a8e43c2846c513f248b37bc4ba2173b2ec1378.1718633874.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Move frontbuffer bits read and check from intel_frontbuffer.h inline functions to intel_frontbuffer.c, in preparation for making struct intel_frontbuffer opaque. Rename __intel_fb_* to __intel_frontbuffer_* while at it, because fb sounds like framebuffer more than frontbuffer. Signed-off-by: Jani Nikula --- .../gpu/drm/i915/display/intel_frontbuffer.c | 22 ++++++++++----- .../gpu/drm/i915/display/intel_frontbuffer.h | 27 +++++-------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c index 4923c340a0b6..7964eaa6a60a 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -167,11 +167,15 @@ void intel_frontbuffer_flip(struct drm_i915_private *i915, frontbuffer_flush(i915, frontbuffer_bits, ORIGIN_FLIP); } -void __intel_fb_invalidate(struct intel_frontbuffer *front, - enum fb_op_origin origin, - unsigned int frontbuffer_bits) +bool __intel_frontbuffer_invalidate(struct intel_frontbuffer *front, + enum fb_op_origin origin) { struct drm_i915_private *i915 = intel_bo_to_i915(front->obj); + unsigned int frontbuffer_bits; + + frontbuffer_bits = atomic_read(&front->bits); + if (!frontbuffer_bits) + return false; if (origin == ORIGIN_CS) { spin_lock(&i915->display.fb_tracking.lock); @@ -186,13 +190,19 @@ void __intel_fb_invalidate(struct intel_frontbuffer *front, intel_psr_invalidate(i915, frontbuffer_bits, origin); intel_drrs_invalidate(i915, frontbuffer_bits); intel_fbc_invalidate(i915, frontbuffer_bits, origin); + + return true; } -void __intel_fb_flush(struct intel_frontbuffer *front, - enum fb_op_origin origin, - unsigned int frontbuffer_bits) +void __intel_frontbuffer_flush(struct intel_frontbuffer *front, + enum fb_op_origin origin) { struct drm_i915_private *i915 = intel_bo_to_i915(front->obj); + unsigned int frontbuffer_bits; + + frontbuffer_bits = atomic_read(&front->bits); + if (!frontbuffer_bits) + return; if (origin == ORIGIN_CS) { spin_lock(&i915->display.fb_tracking.lock); diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.h b/drivers/gpu/drm/i915/display/intel_frontbuffer.h index abb51e8bb920..f4a3495300de 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.h +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.h @@ -79,9 +79,8 @@ void intel_frontbuffer_put(struct intel_frontbuffer *front); struct intel_frontbuffer * intel_frontbuffer_get(struct drm_i915_gem_object *obj); -void __intel_fb_invalidate(struct intel_frontbuffer *front, - enum fb_op_origin origin, - unsigned int frontbuffer_bits); +bool __intel_frontbuffer_invalidate(struct intel_frontbuffer *front, + enum fb_op_origin origin); /** * intel_frontbuffer_invalidate - invalidate frontbuffer object @@ -97,22 +96,14 @@ void __intel_fb_invalidate(struct intel_frontbuffer *front, static inline bool intel_frontbuffer_invalidate(struct intel_frontbuffer *front, enum fb_op_origin origin) { - unsigned int frontbuffer_bits; - if (!front) return false; - frontbuffer_bits = atomic_read(&front->bits); - if (!frontbuffer_bits) - return false; - - __intel_fb_invalidate(front, origin, frontbuffer_bits); - return true; + return __intel_frontbuffer_invalidate(front, origin); } -void __intel_fb_flush(struct intel_frontbuffer *front, - enum fb_op_origin origin, - unsigned int frontbuffer_bits); +void __intel_frontbuffer_flush(struct intel_frontbuffer *front, + enum fb_op_origin origin); /** * intel_frontbuffer_flush - flush frontbuffer object @@ -125,16 +116,10 @@ void __intel_fb_flush(struct intel_frontbuffer *front, static inline void intel_frontbuffer_flush(struct intel_frontbuffer *front, enum fb_op_origin origin) { - unsigned int frontbuffer_bits; - if (!front) return; - frontbuffer_bits = atomic_read(&front->bits); - if (!frontbuffer_bits) - return; - - __intel_fb_flush(front, origin, frontbuffer_bits); + __intel_frontbuffer_flush(front, origin); } void intel_frontbuffer_queue_flush(struct intel_frontbuffer *front); From patchwork Mon Jun 17 14:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13700844 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 52D59C27C79 for ; Mon, 17 Jun 2024 14:19:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B92AB10E3E6; Mon, 17 Jun 2024 14:19:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="M7RC2Ylw"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 15F1B10E3E3; Mon, 17 Jun 2024 14:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718633966; x=1750169966; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GQ4neILaA7OIZnHnepEnKSX1QiGbeTgOinGLpzGP3uM=; b=M7RC2YlwxOS0WQ7P2d3wxOUyFiywnUJ5RHhPtzwCXL5MRqyqz/FOmcSW iotH53eXzlfm4DpJq4lp9Bf4S3fFn4UU5VUfLBBU25+AmKRtuQT+44Idz 2/pDDFtzRX+nGuVu3zKK0YB04WQx4OoyBC1fy3zym4hrY81ZAOTWhWGIf YPNLNcpcWCxGAWs40i34H/CC7lVbPOryfVlD4YAgl/PgybOQ17CRLDu6W vjm3fQGXZ2/CW/k+uGP9dJiC+Ny6pLWrJ8EkUaxuvLh9ItRZpX03HzXsv oaHyVEmN7Nwbu+WfktL78brlVRxCuyaQ/SbQcxiVOXNpSEEoJt7yy2awI g==; X-CSE-ConnectionGUID: p0T3VO8YQzmzkocUTTe0Tw== X-CSE-MsgGUID: D3R/hXPISfa7h49N14zx9A== X-IronPort-AV: E=McAfee;i="6700,10204,11105"; a="15593305" X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="15593305" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:26 -0700 X-CSE-ConnectionGUID: JmNrXUT5Q3Om65rvk3AQ+A== X-CSE-MsgGUID: uPeayP8FQhORldsgcormhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="41083527" Received: from mjarzebo-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.85]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:24 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com Subject: [PATCH 2/5] drm/i915/frontbuffer: hide ->bits more Date: Mon, 17 Jun 2024 17:18:59 +0300 Message-Id: <9fb35580ddf23db815f563269f27790e7bf8dfe0.1718633874.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add helpers for ->bits in preparation for making struct intel_frontbuffer opaque. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_fb.c | 2 +- drivers/gpu/drm/i915/display/intel_frontbuffer.c | 10 ++++++++++ drivers/gpu/drm/i915/display/intel_frontbuffer.h | 3 +++ drivers/gpu/drm/i915/display/intel_plane_initial.c | 2 +- drivers/gpu/drm/xe/display/xe_plane_initial.c | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c index 8069abf91c5e..a49b5a1589a6 100644 --- a/drivers/gpu/drm/i915/display/intel_fb.c +++ b/drivers/gpu/drm/i915/display/intel_fb.c @@ -1965,7 +1965,7 @@ static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb, struct frontbuffer_fence_cb *cb; int ret = 0; - if (!atomic_read(&front->bits)) + if (!intel_frontbuffer_bits(front)) return 0; if (dma_resv_test_signaled(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false))) diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c index 7964eaa6a60a..effb13e8a6bb 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -67,6 +67,16 @@ #include "intel_psr.h" #include "intel_tdf.h" +unsigned int intel_frontbuffer_bits(struct intel_frontbuffer *front) +{ + return atomic_read(&front->bits); +} + +void intel_frontbuffer_bits_or(struct intel_frontbuffer *front, unsigned int bits) +{ + atomic_or(bits, &front->bits); +} + /** * frontbuffer_flush - flush frontbuffer * @i915: i915 device diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.h b/drivers/gpu/drm/i915/display/intel_frontbuffer.h index f4a3495300de..827b0129da71 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.h +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.h @@ -67,6 +67,9 @@ struct intel_frontbuffer { GENMASK(INTEL_FRONTBUFFER_BITS_PER_PIPE * ((pipe) + 1) - 1, \ INTEL_FRONTBUFFER_BITS_PER_PIPE * (pipe)) +unsigned int intel_frontbuffer_bits(struct intel_frontbuffer *front); +void intel_frontbuffer_bits_or(struct intel_frontbuffer *front, unsigned int bits); + void intel_frontbuffer_flip_prepare(struct drm_i915_private *i915, unsigned frontbuffer_bits); void intel_frontbuffer_flip_complete(struct drm_i915_private *i915, diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c b/drivers/gpu/drm/i915/display/intel_plane_initial.c index ada1792df5b3..7cc9863ffce8 100644 --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c @@ -391,7 +391,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc, plane_state->uapi.crtc = &crtc->base; intel_plane_copy_uapi_to_hw_state(plane_state, plane_state, crtc); - atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits); + intel_frontbuffer_bits_or(to_intel_frontbuffer(fb), plane->frontbuffer_bit); } static void plane_config_fini(struct intel_initial_plane_config *plane_config) diff --git a/drivers/gpu/drm/xe/display/xe_plane_initial.c b/drivers/gpu/drm/xe/display/xe_plane_initial.c index e135b20962d9..a838459c49ae 100644 --- a/drivers/gpu/drm/xe/display/xe_plane_initial.c +++ b/drivers/gpu/drm/xe/display/xe_plane_initial.c @@ -232,7 +232,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc, plane_state->uapi.crtc = &crtc->base; intel_plane_copy_uapi_to_hw_state(plane_state, plane_state, crtc); - atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits); + intel_frontbuffer_bits_or(to_intel_frontbuffer(fb), plane->frontbuffer_bit); plane_config->vma = vma; From patchwork Mon Jun 17 14:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13700845 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 67DFFC27C79 for ; Mon, 17 Jun 2024 14:19:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C5E1410E3B9; Mon, 17 Jun 2024 14:19:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="QY9CUgna"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA79C10E3B9; Mon, 17 Jun 2024 14:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718633971; x=1750169971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dJzV6LAVdMMWODOnRkeLY1jigUjq6n8CFWefMgDlCVw=; b=QY9CUgnafCzmb/8E+8RiaPac/Cle7jPwhthtbhybRteYoFdyfDx9S8md 8Ry0zFOHhq7muVsfLYt7lSod/MHqIxCrXxTxgzfQXVxTW8n9EAPx4oq9s jLn6EbpOPFMoJk2UdwFXNL+ld2anRKvhwnSKwEtyJYHh95u8c+tFs2ngy CGMZ7dtikAKMQ1e1xw097onjT9cC3fm64tp8ZTPddG3yUZPxRGp/RFmJt px4EMzQytYsEVa7ZgxJdr9CL2YmAbQamRFpBftaU3U3wJh/2A63FYXoet FCmjixt6fpL+md5cXu7BaqpZQlC8K5k8XPfur7506+wu2df/z3wzAQnkZ g==; X-CSE-ConnectionGUID: +HycxGXxRCiBz4wklM2xDw== X-CSE-MsgGUID: QNLiPgGpRO2o1NVltCj0Kw== X-IronPort-AV: E=McAfee;i="6700,10204,11105"; a="15593319" X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="15593319" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:31 -0700 X-CSE-ConnectionGUID: O8Tb7KMkTAeHQcSHbFrKeA== X-CSE-MsgGUID: Q27b/WKxTYWbKD5BmP6lLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="41083540" Received: from mjarzebo-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.85]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:29 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com Subject: [PATCH 3/5] drm/i915/frontbuffer: add low-level kref accessors Date: Mon, 17 Jun 2024 17:19:00 +0300 Message-Id: <0c93a7e223b11d39af1dc6a1e195d2e1965c3e17.1718633874.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add _raw accessors for front->ref to avoid direct access from outside of intel_frontbuffer.c, in preparation for making struct intel_frontbuffer opaque. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_frontbuffer.c | 10 ++++++++++ drivers/gpu/drm/i915/display/intel_frontbuffer.h | 3 +++ drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c index effb13e8a6bb..42defe2b7661 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -77,6 +77,16 @@ void intel_frontbuffer_bits_or(struct intel_frontbuffer *front, unsigned int bit atomic_or(bits, &front->bits); } +bool intel_frontbuffer_get_unless_zero_raw(struct intel_frontbuffer *front) +{ + return kref_get_unless_zero(&front->ref); +} + +void intel_frontbuffer_get_raw(struct intel_frontbuffer *front) +{ + kref_get(&front->ref); +} + /** * frontbuffer_flush - flush frontbuffer * @i915: i915 device diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.h b/drivers/gpu/drm/i915/display/intel_frontbuffer.h index 827b0129da71..221f41096416 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.h +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.h @@ -79,6 +79,9 @@ void intel_frontbuffer_flip(struct drm_i915_private *i915, void intel_frontbuffer_put(struct intel_frontbuffer *front); +bool intel_frontbuffer_get_unless_zero_raw(struct intel_frontbuffer *front); +void intel_frontbuffer_get_raw(struct intel_frontbuffer *front); + struct intel_frontbuffer * intel_frontbuffer_get(struct drm_i915_gem_object *obj); diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h b/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h index 9fbf14867a2a..22df3c70c8a6 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_frontbuffer.h @@ -56,7 +56,7 @@ i915_gem_object_get_frontbuffer(const struct drm_i915_gem_object *obj) if (!front) break; - if (unlikely(!kref_get_unless_zero(&front->ref))) + if (unlikely(!intel_frontbuffer_get_unless_zero_raw(front))) continue; if (likely(front == rcu_access_pointer(obj->frontbuffer))) @@ -92,7 +92,7 @@ i915_gem_object_set_frontbuffer(struct drm_i915_gem_object *obj, drm_gem_object_put(intel_bo_to_drm_bo(obj)); } else if (rcu_access_pointer(obj->frontbuffer)) { cur = rcu_dereference_protected(obj->frontbuffer, true); - kref_get(&cur->ref); + intel_frontbuffer_get_raw(cur); } else { drm_gem_object_get(intel_bo_to_drm_bo(obj)); rcu_assign_pointer(obj->frontbuffer, front); From patchwork Mon Jun 17 14:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13700846 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 94E52C27C79 for ; Mon, 17 Jun 2024 14:19:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C68E10E3E2; Mon, 17 Jun 2024 14:19:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="LyXjMa2Z"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BE8310E3E2; Mon, 17 Jun 2024 14:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718633976; x=1750169976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Yn3khoseLunC6aRDinvmUwl8RNSOSrvBcYvLU4D3vc=; b=LyXjMa2Z6cdRafn0uoDFJky0g2Ggqx45fVF7Q4O1gpOP6FmvPEuOvs5C kDxMmLty+EFI8Ik9jjBn4wdNKCUCWRQoYl4laMk+LeUSmx4fUksEaG7uX n1jxZ0zxiJyB7RY1KZt9aVAEeXdPKSqJUQ4jRSx4YL6JoXQDkT2RWjQHq nNp/1N9HDtLO4dNMjqH+nmRVU+GO91OESAq1vQ1IZxnFNxLJZ+TIqONWc KmomAViTk9EzwyVrlXFt0q+RIVLtubst47sHIROCyUkNZP6gKnLIWFh0g +4C8vwEZrlkkEFfsRIp4wJjkB0evBtqCVzVSMG4ftdYYGqyOBToqdbqwx g==; X-CSE-ConnectionGUID: CLhXvjX2TqKDzvmgjEye6w== X-CSE-MsgGUID: jU4moI3ZRzSkSPTD3gVqyw== X-IronPort-AV: E=McAfee;i="6700,10204,11105"; a="15593327" X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="15593327" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:35 -0700 X-CSE-ConnectionGUID: AaPDnSE2RwGzRDvWCV8CEw== X-CSE-MsgGUID: QES4aZV3TrWui6fflAidxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="41083544" Received: from mjarzebo-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.85]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:34 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com Subject: [PATCH 4/5] drm/i915/frontbuffer: hide ->write Date: Mon, 17 Jun 2024 17:19:01 +0300 Message-Id: <926007fda6f9d9f57d7c84bdeb891cabf4aafac7.1718633874.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add accessor to frontbuffer ->write to avoid direct access from outside of intel_frontbuffer.c in preparation for making struct intel_frontbuffer opaque. Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_frontbuffer.c | 5 +++++ drivers/gpu/drm/i915/display/intel_frontbuffer.h | 2 ++ drivers/gpu/drm/i915/i915_vma.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c index 42defe2b7661..dd5fd1e2859e 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -87,6 +87,11 @@ void intel_frontbuffer_get_raw(struct intel_frontbuffer *front) kref_get(&front->ref); } +struct i915_active *intel_frontbuffer_active(struct intel_frontbuffer *front) +{ + return &front->write; +} + /** * frontbuffer_flush - flush frontbuffer * @i915: i915 device diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.h b/drivers/gpu/drm/i915/display/intel_frontbuffer.h index 221f41096416..62d6e3cedea4 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.h +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.h @@ -134,4 +134,6 @@ void intel_frontbuffer_track(struct intel_frontbuffer *old, struct intel_frontbuffer *new, unsigned int frontbuffer_bits); +struct i915_active *intel_frontbuffer_active(struct intel_frontbuffer *front); + #endif /* __INTEL_FRONTBUFFER_H__ */ diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c index d2f064d2525c..2b5cc7af19c5 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -1975,7 +1975,7 @@ int _i915_vma_move_to_active(struct i915_vma *vma, front = i915_gem_object_get_frontbuffer(obj); if (unlikely(front)) { if (intel_frontbuffer_invalidate(front, ORIGIN_CS)) - i915_active_add_request(&front->write, rq); + i915_active_add_request(intel_frontbuffer_active(front), rq); intel_frontbuffer_put(front); } } From patchwork Mon Jun 17 14:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13700847 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 5CC37C27C79 for ; Mon, 17 Jun 2024 14:20:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B891210E3EB; Mon, 17 Jun 2024 14:19:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="J3lr9K78"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 145ED10E3E7; Mon, 17 Jun 2024 14:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718633996; x=1750169996; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R2X5wER3cN2q4cAk64/ig/YgL3IiObrhDUI7MlDeKoY=; b=J3lr9K78T4Gtb+X5ul/YVWHRCn90Cq4bGEyENA5e5wk7yqKrjSrhplIb HbHwhuVav/kpEzZhLiJ8MuUM4NwYsPYXjRu6TcrL7d3v3du3lvYPMJ8W9 X8a95BCqTsEhhnDWdUy78YX91KU5vFoDZsD2KpHhl52l2KbyzeOcn8qvR IYUbG3qixqBGVx77RWSb2AsHt5JvU2M3pY9+WdJ7tv/Df0I+sf9DriPm7 vosGfM6/VkQKdFfY+RomqMsS4FhEv06HTSIxf/a6zfNGCsBnrOcp0NJi6 km2tJq2ZV6FAjCslU2EqWxgUufCbdKCz/XG5Ovq5LByZcbmjeeBMZ8KgW A==; X-CSE-ConnectionGUID: PVUlmhGGShSNgRgjRRXGzw== X-CSE-MsgGUID: emvS/V5yQvqWXdHrVOZ3TA== X-IronPort-AV: E=McAfee;i="6700,10204,11105"; a="15593335" X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="15593335" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:40 -0700 X-CSE-ConnectionGUID: rI50lKjfTvCrkzmhjOwQaQ== X-CSE-MsgGUID: HCzsTAjtQ1WkgOfA6Sh3aA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,244,1712646000"; d="scan'208";a="41083549" Received: from mjarzebo-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.246.85]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2024 07:19:38 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com Subject: [PATCH 5/5] drm/i915/frontbuffer: make struct intel_frontbuffer opaque Date: Mon, 17 Jun 2024 17:19:02 +0300 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Hide struct intel_frontbuffer implementation details within intel_frontbuffer.c. Signed-off-by: Jani Nikula --- .../gpu/drm/i915/display/intel_frontbuffer.c | 10 ++++++++++ .../gpu/drm/i915/display/intel_frontbuffer.h | 18 ++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.c b/drivers/gpu/drm/i915/display/intel_frontbuffer.c index dd5fd1e2859e..53a4cbc43ae3 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.c +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.c @@ -67,6 +67,16 @@ #include "intel_psr.h" #include "intel_tdf.h" +struct intel_frontbuffer { + struct kref ref; + atomic_t bits; + struct i915_active write; + struct drm_i915_gem_object *obj; + struct rcu_head rcu; + + struct work_struct flush_work; +}; + unsigned int intel_frontbuffer_bits(struct intel_frontbuffer *front) { return atomic_read(&front->bits); diff --git a/drivers/gpu/drm/i915/display/intel_frontbuffer.h b/drivers/gpu/drm/i915/display/intel_frontbuffer.h index 62d6e3cedea4..a6212ee4ed12 100644 --- a/drivers/gpu/drm/i915/display/intel_frontbuffer.h +++ b/drivers/gpu/drm/i915/display/intel_frontbuffer.h @@ -24,13 +24,13 @@ #ifndef __INTEL_FRONTBUFFER_H__ #define __INTEL_FRONTBUFFER_H__ -#include #include -#include - -#include "i915_active_types.h" +#include +struct drm_i915_gem_object; struct drm_i915_private; +struct i915_active; +struct intel_frontbuffer; enum fb_op_origin { ORIGIN_CPU = 0, @@ -40,16 +40,6 @@ enum fb_op_origin { ORIGIN_CURSOR_UPDATE, }; -struct intel_frontbuffer { - struct kref ref; - atomic_t bits; - struct i915_active write; - struct drm_i915_gem_object *obj; - struct rcu_head rcu; - - struct work_struct flush_work; -}; - /* * Frontbuffer tracking bits. Set in obj->frontbuffer_bits while a gem bo is * considered to be the frontbuffer for the given plane interface-wise. This