All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Archit Taneja <architt@codeaurora.org>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel@lists.freedesktop.org, "Pandiyan,
	Dhinakaran" <dhinakaran.pandiyan@intel.com>,
	Harry Wentland <Harry.wentland@amd.com>
Subject: [PATCH v6 4/5] drm: Connector helper function to release resources
Date: Tue,  4 Apr 2017 12:30:44 -0700	[thread overview]
Message-ID: <1491334245-17194-4-git-send-email-dhinakaran.pandiyan@intel.com> (raw)
In-Reply-To: <1491334245-17194-1-git-send-email-dhinakaran.pandiyan@intel.com>

From: "Pandiyan, Dhinakaran" <dhinakaran.pandiyan@intel.com>

Having an ->atomic_release callback is useful to release shared resources
that get allocated in compute_config(). This function is expected to be
called in the atomic_check() phase before new resources are acquired.

v5: Return an int (Maarten)
v4: Document that the function is conditionally called and before
other atomic_checks() (Daniel)
v3: Use the new 'for_each_oldnew_connector_in_state()' macro.
v2: Moved the caller hunk to this patch (Daniel)

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Harry Wentland <Harry.wentland@amd.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c      | 22 ++++++++++++++++++++++
 include/drm/drm_modeset_helper_vtables.h | 20 ++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index d14094d..57d2e50 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -586,6 +586,28 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 		}
 	}
 
+	for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
+		const struct drm_connector_helper_funcs *conn_funcs;
+		struct drm_crtc_state *crtc_state;
+
+		conn_funcs = connector->helper_private;
+		if (!conn_funcs->atomic_release)
+			continue;
+
+		if (!old_connector_state->crtc)
+			continue;
+
+		crtc_state = drm_atomic_get_existing_crtc_state(state, old_connector_state->crtc);
+
+		if (crtc_state->connectors_changed ||
+		    crtc_state->mode_changed ||
+		    (crtc_state->active_changed && !crtc_state->active)) {
+			ret = conn_funcs->atomic_release(connector, new_connector_state);
+			if (ret != 0)
+				return ret;
+		}
+	}
+
 	return mode_fixup(state);
 }
 EXPORT_SYMBOL(drm_atomic_helper_check_modeset);
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 091c422..36a4b16 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -836,6 +836,26 @@ struct drm_connector_helper_funcs {
 	 */
 	struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
 						   struct drm_connector_state *connector_state);
+
+	/**
+	 * @atomic_release:
+	 *
+	 * This function is conditionally called to release shared resources
+	 * when the attached CRTC's mode changes or it's connectors change or
+	 * becomes inactive. It is called before the corresponding
+	 * &drm_crtc_helper_funcs.atomic_check or
+	 * &drm_crtc_helper_funcs.mode_fixup hooks are called.
+	 *
+	 * NOTE:
+	 *
+	 * This function is called in the check phase of an atomic update.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on success or negative error codes on failure.
+	 */
+	int (*atomic_release)(struct drm_connector *connector,
+			       struct drm_connector_state *connector_state);
 };
 
 /**
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-04-04 19:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  8:42 [PATCH v5 0/5] Adding driver-private objects to atomic state Dhinakaran Pandiyan
2017-03-30  8:42 ` [PATCH v5 1/5] drm: Add " Dhinakaran Pandiyan
2017-04-01  5:46   ` kbuild test robot
2017-03-30  8:42 ` [PATCH v5 2/5] drm/dp: Introduce MST topology state to track available link bandwidth Dhinakaran Pandiyan
2017-03-30  8:42 ` [PATCH v5 3/5] drm/dp: Add DP MST helpers to atomically find and release vcpi slots Dhinakaran Pandiyan
2017-04-04  1:46   ` Pandiyan, Dhinakaran
2017-03-30  8:42 ` [PATCH v5 4/5] drm: Connector helper function to release resources Dhinakaran Pandiyan
2017-03-30 10:36   ` Maarten Lankhorst
2017-04-01  2:37     ` Pandiyan, Dhinakaran
2017-04-04 19:30     ` [PATCH v6 1/5] drm: Add driver-private objects to atomic state Dhinakaran Pandiyan
2017-04-04 19:30       ` [PATCH v6 2/5] drm/dp: Introduce MST topology state to track available link bandwidth Dhinakaran Pandiyan
2017-04-04 19:30       ` [PATCH v6 3/5] drm/dp: Add DP MST helpers to atomically find and release vcpi slots Dhinakaran Pandiyan
2017-04-04 19:30       ` Dhinakaran Pandiyan [this message]
2017-04-04 19:30       ` [PATCH v6 5/5] drm/dp: Track MST link bandwidth Dhinakaran Pandiyan
2017-03-30  8:42 ` [PATCH v5 " Dhinakaran Pandiyan
2017-03-30 11:17 ` ✗ Fi.CI.BAT: warning for Adding driver-private objects to atomic state Patchwork
2017-04-04 20:36 ` ✗ Fi.CI.BAT: failure for Adding driver-private objects to atomic state (rev6) Patchwork
2017-04-04 22:35   ` Pandiyan, Dhinakaran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491334245-17194-4-git-send-email-dhinakaran.pandiyan@intel.com \
    --to=dhinakaran.pandiyan@intel.com \
    --cc=Harry.wentland@amd.com \
    --cc=architt@codeaurora.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.