Skip to contentSkip to conversation

drm: atomic-helper: Implement drm_atomic_helper_duplicate_state()

PATCH Superseded Thierry Reding 3 participants 8 messages Aug 11, 2015

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm: atomic-helper: Implement drm_atomic_helper_duplicate_state()

From: Thierry Reding <[email protected]>

This function can be used to duplicate an atomic state object. This is useful for example to implement suspend/resume, where the state before suspend can be saved and restored upon resume.

---
 drivers/gpu/drm/drm_atomic_helper.c | 90 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  2 +
 2 files changed, 92 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +90 -0
index fd06595c2ee5..f842499ca79e 100644
@@ -2358,6 +2358,96 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state);
 
 /**
+ * drm_atomic_helper_duplicate_state - duplicate an atomic state object
+ * @dev: DRM device
+ *
+ * Makes a copy of the current atomic state by looping over all objects and
+ * duplicating their respective states.
+ *
+ * Returns: A pointer to the copy of the atomic state object on success or an
+ * ERR_PTR()-encoded error code on failure.
+ */
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	int err;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return ERR_PTR(-ENOMEM);
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->acquire_ctx = &ctx;
+
+	err = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
+	if (err < 0)
+		goto free;
+
+	drm_for_each_crtc(crtc, dev) {
+		unsigned int index = drm_crtc_index(crtc);
+		struct drm_crtc_state *crtc_state;
+
+		crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
+		if (!crtc_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->crtc_states[index] = crtc_state;
+		state->crtcs[index] = crtc;
+		crtc_state->state = state;
+	}
+
+	drm_for_each_plane(plane, dev) {
+		unsigned int index = drm_plane_index(plane);
+		struct drm_plane_state *plane_state;
+
+		plane_state = plane->funcs->atomic_duplicate_state(plane);
+		if (!plane_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->plane_states[index] = plane_state;
+		state->planes[index] = plane;
+		plane_state->state = state;
+	}
+
+	drm_for_each_connector(conn, dev) {
+		unsigned int index = drm_connector_index(conn);
+		struct drm_connector_state *conn_state;
+
+		conn_state = conn->funcs->atomic_duplicate_state(conn);
+		if (!conn_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->connector_states[index] = conn_state;
+		state->connectors[index] = conn;
+		conn_state->state = state;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);
+
+	if (err < 0) {
+		drm_atomic_state_free(state);
+		state = ERR_PTR(err);
+	}
+
+	return state;
+}
+EXPORT_SYMBOL(drm_atomic_helper_duplicate_state);
+
+/**
  * __drm_atomic_helper_connector_destroy_state - release connector state
  * @connector: connector object
  * @state: connector state object to release
include/drm/drm_atomic_helper.h +2 -0
index 4ffe9dca07c4..5d27612997ce 100644
@@ -118,6 +118,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
 					   struct drm_connector_state *state);
 struct drm_connector_state *
 drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev);
 void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					    struct drm_connector_state *state);
Signature · 6 lines
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/3 drm/atomic-helper: Implement subsystem-level suspend/resume

From: Thierry Reding <[email protected]>

Provide subsystem-level suspend and resume helpers that can be used to implement suspend/resume on atomic mode-setting enabled drivers.

---
 drivers/gpu/drm/drm_atomic_helper.c | 191 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |   5 +
 2 files changed, 196 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +191 -0
index f842499ca79e..aface21b713e 100644
@@ -1751,6 +1751,197 @@ backoff:
 EXPORT_SYMBOL(drm_atomic_helper_set_config);
 
 /**
+ * drm_atomic_helper_disable_all - disable all currently active outputs
+ * @dev: DRM device
+ *
+ * Loops through all connectors, finding those that aren't turned off and then
+ * turns them off by setting their DPMS mode to OFF and deactivating the CRTC
+ * that they are connected to.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_disable_all(struct drm_device *dev)
+{
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_connector_state *conn_state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	unsigned int i;
+	int err;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;
+
+	drm_modeset_acquire_init(&ctx, 0);
+
+	state->allow_modeset = true;
+	state->acquire_ctx = &ctx;
+
+retry:
+	err = drm_modeset_lock(&config->connection_mutex, &ctx);
+	if (err < 0)
+		goto free;
+
+	drm_for_each_connector(conn, dev) {
+		struct drm_crtc *crtc = conn->state->crtc;
+		struct drm_crtc_state *crtc_state;
+
+		if (!crtc || conn->dpms != DRM_MODE_DPMS_ON)
+			continue;
+
+		crtc_state = drm_atomic_get_crtc_state(state, crtc);
+		if (IS_ERR(crtc_state)) {
+			err = PTR_ERR(crtc_state);
+			goto unlock;
+		}
+
+		err = drm_atomic_add_affected_connectors(state, crtc);
+		if (err < 0)
+			goto unlock;
+
+		conn->dpms = DRM_MODE_DPMS_OFF;
+		crtc_state->active = false;
+	}
+
+	err = drm_atomic_commit(state);
+	if (err < 0) {
+		/* restore DPMS mode */
+		for_each_connector_in_state(state, conn, conn_state, i)
+			conn->dpms = DRM_MODE_DPMS_ON;
+
+		if (err == -EDEADLK) {
+			drm_atomic_state_clear(state);
+			drm_modeset_backoff(&ctx);
+			goto retry;
+		}
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);
+
+	if (err < 0)
+		drm_atomic_state_free(state);
+
+	return err;
+}
+EXPORT_SYMBOL(drm_atomic_helper_disable_all);
+
+/**
+ * drm_atomic_helper_restore_commit - restores an atomic state object
+ * @state: atomic state object
+ *
+ * Takes an atomic state object for which no locks have been taken (such as
+ * atomic state objects obtained from drm_atomic_helper_duplicate_state()),
+ * grabs all the necessary locks, commits the state and releases the locks
+ * while gracefully handling deadlocks.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+static int drm_atomic_helper_restore_commit(struct drm_atomic_state *state)
+{
+	struct drm_mode_config *config = &state->dev->mode_config;
+	struct drm_plane_state *plane_state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_crtc_state *crtc_state;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	unsigned int i;
+	int err;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->allow_modeset = true;
+	state->acquire_ctx = &ctx;
+
+retry:
+	err = drm_modeset_lock(&config->connection_mutex, &ctx);
+	if (err < 0)
+		goto fini;
+
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		err = drm_modeset_lock(&crtc->mutex, &ctx);
+		if (err < 0)
+			goto unlock;
+	}
+
+	for_each_plane_in_state(state, plane, plane_state, i) {
+		err = drm_modeset_lock(&plane->mutex, &ctx);
+		if (err < 0)
+			goto unlock;
+	}
+
+	err = drm_atomic_commit(state);
+	if (err == -EDEADLK) {
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+fini:
+	drm_modeset_acquire_fini(&ctx);
+
+	return err;
+}
+
+/**
+ * drm_atomic_helper_suspend - subsystem-level suspend helper
+ * @dev: DRM device
+ *
+ * Duplicates the current atomic state, disables all active outputs and then
+ * returns a pointer to the original atomic state to the caller. Drivers can
+ * pass this pointer to the drm_atomic_helper_resume() helper upon resume to
+ * restore the output configuration that was active at the time the system
+ * entered suspend.
+ *
+ * Returns: A pointer to a copy of the state before suspend on success or an
+ * ERR_PTR()-encoded error code on failure. Drivers should store the returned
+ * atomic state object and pass it to the drm_atomic_helper_resume() helper
+ * upon resume.
+ */
+struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
+{
+	struct drm_atomic_state *state;
+	int err;
+
+	state = drm_atomic_helper_duplicate_state(dev);
+	if (IS_ERR(state))
+		return state;
+
+	err = drm_atomic_helper_disable_all(dev);
+	if (err < 0) {
+		drm_atomic_state_free(state);
+		return ERR_PTR(err);
+	}
+
+	return state;
+}
+EXPORT_SYMBOL(drm_atomic_helper_suspend);
+
+/**
+ * drm_atomic_helper_resume - subsystem-level resume helper
+ * @dev: DRM device
+ * @state: atomic state to resume to
+ *
+ * Takes an atomic state object, grabs all the necessary locks and commits it.
+ * This can be used in conjunction with the drm_atomic_helper_suspend() helper
+ * to implement suspend/resume for atomic mode-setting enabled drivers.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_resume(struct drm_device *dev,
+				    struct drm_atomic_state *state)
+{
+	drm_mode_config_reset(dev);
+
+	return drm_atomic_helper_restore_commit(state);
+}
+EXPORT_SYMBOL(drm_atomic_helper_resume);
+
+/**
  * drm_atomic_helper_crtc_set_property - helper for crtc properties
  * @crtc: DRM crtc
  * @property: DRM property
include/drm/drm_atomic_helper.h +5 -0
index 5d27612997ce..080f131c9f2e 100644
@@ -75,6 +75,11 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,
 int drm_atomic_helper_disable_plane(struct drm_plane *plane);
 int drm_atomic_helper_set_config(struct drm_mode_set *set);
 
+int drm_atomic_helper_disable_all(struct drm_device *dev);
+struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev);
+int drm_atomic_helper_resume(struct drm_device *dev,
+			     struct drm_atomic_state *state);
+
 int drm_atomic_helper_crtc_set_property(struct drm_crtc *crtc,
 					struct drm_property *property,
 					uint64_t val);
Signature · 6 lines
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 2/3] drm/atomic-helper: Implement subsystem-level suspend/resume

Op 11-08-15 om 13:37 schreef Thierry Reding:

Quoted 87 lines

From: Thierry Reding <[email protected]>

Provide subsystem-level suspend and resume helpers that can be used to implement suspend/resume on atomic mode-setting enabled drivers.

---
 drivers/gpu/drm/drm_atomic_helper.c | 191 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |   5 +
 2 files changed, 196 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +68 -0
index f842499ca79e..aface21b713e 100644
@@ -1751,6 +1751,197 @@ backoff:
 EXPORT_SYMBOL(drm_atomic_helper_set_config);
 
 /**
+ * drm_atomic_helper_disable_all - disable all currently active outputs
+ * @dev: DRM device
+ *
+ * Loops through all connectors, finding those that aren't turned off and then
+ * turns them off by setting their DPMS mode to OFF and deactivating the CRTC
+ * that they are connected to.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_disable_all(struct drm_device *dev)
+{
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_connector_state *conn_state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	unsigned int i;
+	int err;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;
+
+	drm_modeset_acquire_init(&ctx, 0);
+
+	state->allow_modeset = true;
+	state->acquire_ctx = &ctx;
+
+retry:
+	err = drm_modeset_lock(&config->connection_mutex, &ctx);
+	if (err < 0)
+		goto free;
+
+	drm_for_each_connector(conn, dev) {
+		struct drm_crtc *crtc = conn->state->crtc;
+		struct drm_crtc_state *crtc_state;
+
+		if (!crtc || conn->dpms != DRM_MODE_DPMS_ON)
+			continue;
+
+		crtc_state = drm_atomic_get_crtc_state(state, crtc);
+		if (IS_ERR(crtc_state)) {
+			err = PTR_ERR(crtc_state);
+			goto unlock;
+		}
+
+		err = drm_atomic_add_affected_connectors(state, crtc);
+		if (err < 0)
+			goto unlock;
+
+		conn->dpms = DRM_MODE_DPMS_OFF;
+		crtc_state->active = false;
+	}
+
+	err = drm_atomic_commit(state);
+	if (err < 0) {
+		/* restore DPMS mode */
+		for_each_connector_in_state(state, conn, conn_state, i)
+			conn->dpms = DRM_MODE_DPMS_ON;
+
+		if (err == -EDEADLK) {
+			drm_atomic_state_clear(state);
+			drm_modeset_backoff(&ctx);
+			goto retry;
+		}
+	}
+
+unlock:

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1831

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);
+
+	if (err < 0)
+		drm_atomic_state_free(state);
+
+	return err;
+}
+EXPORT_SYMBOL(drm_atomic_helper_disable_all);

Use lock_all again. And this version is not handling -EDEADLK from get_*_state so it doesn't work as intended. :-) In case of doubt, try with CONFIG_DEBUG_WW_MUTEX_SLOWPATH.

Quoted 46 lines
drivers/gpu/drm/drm_atomic_helper.c +46 -0
+/**
+ * drm_atomic_helper_restore_commit - restores an atomic state object
+ * @state: atomic state object
+ *
+ * Takes an atomic state object for which no locks have been taken (such as
+ * atomic state objects obtained from drm_atomic_helper_duplicate_state()),
+ * grabs all the necessary locks, commits the state and releases the locks
+ * while gracefully handling deadlocks.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+static int drm_atomic_helper_restore_commit(struct drm_atomic_state *state)
+{
+	struct drm_mode_config *config = &state->dev->mode_config;
+	struct drm_plane_state *plane_state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_crtc_state *crtc_state;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	unsigned int i;
+	int err;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->allow_modeset = true;
+	state->acquire_ctx = &ctx;
+
+retry:
+	err = drm_modeset_lock(&config->connection_mutex, &ctx);
+	if (err < 0)
+		goto fini;
+
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		err = drm_modeset_lock(&crtc->mutex, &ctx);
+		if (err < 0)
+			goto unlock;
+	}
+
+	for_each_plane_in_state(state, plane, plane_state, i) {
+		err = drm_modeset_lock(&plane->mutex, &ctx);
+		if (err < 0)
+			goto unlock;
+	}
+
+	err = drm_atomic_commit(state);
+	if (err == -EDEADLK) {
+		drm_modeset_backoff(&ctx);

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1888

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+		goto retry;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+fini:
+	drm_modeset_acquire_fini(&ctx);
+
+	return err;
+}

^^

drm_modeset_lock_all(dev);
state->acquire_ctx = ...;
ret = drm_atomic_commit(state);
drm_modeset_unlock_all(dev);

and fold it into atomic_helper_resume

Quoted 9 lines
drivers/gpu/drm/drm_atomic_helper.c +9 -0
+/**
+ * drm_atomic_helper_suspend - subsystem-level suspend helper
+ * @dev: DRM device
+ *
+ * Duplicates the current atomic state, disables all active outputs and then
+ * returns a pointer to the original atomic state to the caller. Drivers can
+ * pass this pointer to the drm_atomic_helper_resume() helper upon resume to
+ * restore the output configuration that was active at the time the system
+ * entered suspend.

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1908

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+ *
+ * Returns: A pointer to a copy of the state before suspend on success or an
+ * ERR_PTR()-encoded error code on failure. Drivers should store the returned
+ * atomic state object and pass it to the drm_atomic_helper_resume() helper
+ * upon resume.
+ */
+struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
+{
+	struct drm_atomic_state *state;
+	int err;

drm_modeset_lock_all();

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1918

Quoted 9 lines
drivers/gpu/drm/drm_atomic_helper.c +9 -0
+	state = drm_atomic_helper_duplicate_state(dev);
+	if (IS_ERR(state))
+		return state;
+
+	err = drm_atomic_helper_disable_all(dev);
+	if (err < 0) {
+		drm_atomic_state_free(state);
+		return ERR_PTR(err);
+	}

drm_modeset_lock_unlock_all();

Quoted 35 lines
drivers/gpu/drm/drm_atomic_helper.c +24 -0
+	return state;
+}
+EXPORT_SYMBOL(drm_atomic_helper_suspend);
 
 
+/**
+ * drm_atomic_helper_resume - subsystem-level resume helper
+ * @dev: DRM device
+ * @state: atomic state to resume to
+ *
+ * Takes an atomic state object, grabs all the necessary locks and commits it.
+ * This can be used in conjunction with the drm_atomic_helper_suspend() helper
+ * to implement suspend/resume for atomic mode-setting enabled drivers.
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_resume(struct drm_device *dev,
+				    struct drm_atomic_state *state)
+{
+	drm_mode_config_reset(dev);
+
+	return drm_atomic_helper_restore_commit(state);
+}
+EXPORT_SYMBOL(drm_atomic_helper_resume);
+
+/**
  * drm_atomic_helper_crtc_set_property - helper for crtc properties
  * @crtc: DRM crtc
  * @property: DRM property
include/drm/drm_atomic_helper.h +0 -0
index 5d27612997ce..080f131c9f2e 100644
@@ -75,6 +75,11 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,
 int drm_atomic_helper_disable_plane(struct drm_plane *plane);

include/drm/drm_atomic_helper.h int drm_atomic_helper_update_plane(struct drm_plane *plane, · line 85

Quoted 10 lines
include/drm/drm_atomic_helper.h +5 -0
 int drm_atomic_helper_set_config(struct drm_mode_set *set);
 
+int drm_atomic_helper_disable_all(struct drm_device *dev);
+struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev);
+int drm_atomic_helper_resume(struct drm_device *dev,
+			     struct drm_atomic_state *state);
+
 int drm_atomic_helper_crtc_set_property(struct drm_crtc *crtc,
 					struct drm_property *property,
 					uint64_t val);

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH 2/3] drm/atomic-helper: Implement subsystem-level suspend/resume

In reply to Thierry Reding
Quoted 16 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Provide subsystem-level suspend and resume helpers that can be used to implement suspend/resume on atomic mode-setting enabled drivers.

---
 drivers/gpu/drm/drm_atomic_helper.c | 191 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |   5 +
 2 files changed, 196 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index f842499ca79e..aface21b713e 100644

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1759

Quoted 9 lines
drivers/gpu/drm/drm_atomic_helper.c +6 -0
@@ -1751,6 +1751,197 @@ backoff:
 EXPORT_SYMBOL(drm_atomic_helper_set_config);
 
 /**
+ * drm_atomic_helper_disable_all - disable all currently active outputs
+ * @dev: DRM device
+ *
+ * Loops through all connectors, finding those that aren't turned off and then
+ * turns them off by setting their DPMS mode to OFF and deactivating the CRTC
+ * that they are connected to.

Imo the subordinate helpers here should also mention how they're used in the suspend/resume helpers and reference them (soonish all those function references will be hyperlinks, making them even more useful). Same for the other subordinate helpers (also duplicate_state from the previous patch).

Quoted 16 lines
drivers/gpu/drm/drm_atomic_helper.c +16 -0
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_disable_all(struct drm_device *dev)
+{
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_connector_state *conn_state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	unsigned int i;
+	int err;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1785

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+	drm_modeset_acquire_init(&ctx, 0);
+
+	state->allow_modeset = true;
+	state->acquire_ctx = &ctx;
+
+retry:
+	err = drm_modeset_lock(&config->connection_mutex, &ctx);
+	if (err < 0)
+		goto free;

Same comment about locking as with the duplicate_state helper.

Quoted 45 lines
drivers/gpu/drm/drm_atomic_helper.c +45 -0
+
+	drm_for_each_connector(conn, dev) {
+		struct drm_crtc *crtc = conn->state->crtc;
+		struct drm_crtc_state *crtc_state;
+
+		if (!crtc || conn->dpms != DRM_MODE_DPMS_ON)
+			continue;
+
+		crtc_state = drm_atomic_get_crtc_state(state, crtc);
+		if (IS_ERR(crtc_state)) {
+			err = PTR_ERR(crtc_state);
+			goto unlock;
+		}
+
+		err = drm_atomic_add_affected_connectors(state, crtc);
+		if (err < 0)
+			goto unlock;
+
+		conn->dpms = DRM_MODE_DPMS_OFF;
+		crtc_state->active = false;
+	}
+
+	err = drm_atomic_commit(state);
+	if (err < 0) {
+		/* restore DPMS mode */
+		for_each_connector_in_state(state, conn, conn_state, i)
+			conn->dpms = DRM_MODE_DPMS_ON;
+
+		if (err == -EDEADLK) {
+			drm_atomic_state_clear(state);
+			drm_modeset_backoff(&ctx);
+			goto retry;
+		}
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);
+
+	if (err < 0)
+		drm_atomic_state_free(state);
+
+	return err;
+}

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1840

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+EXPORT_SYMBOL(drm_atomic_helper_disable_all);
+
+/**
+ * drm_atomic_helper_restore_commit - restores an atomic state object
+ * @state: atomic state object
+ *
+ * Takes an atomic state object for which no locks have been taken (such as
+ * atomic state objects obtained from drm_atomic_helper_duplicate_state()),
+ * grabs all the necessary locks, commits the state and releases the locks
+ * while gracefully handling deadlocks.

I think this also needs some warnings that reusing atomic states while locks have been droppped could be risky, similar to duplicate_state().

Quoted 53 lines
drivers/gpu/drm/drm_atomic_helper.c +53 -0
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+static int drm_atomic_helper_restore_commit(struct drm_atomic_state *state)
+{
+	struct drm_mode_config *config = &state->dev->mode_config;
+	struct drm_plane_state *plane_state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_crtc_state *crtc_state;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	unsigned int i;
+	int err;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->allow_modeset = true;
+	state->acquire_ctx = &ctx;
+
+retry:
+	err = drm_modeset_lock(&config->connection_mutex, &ctx);
+	if (err < 0)
+		goto fini;
+
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		err = drm_modeset_lock(&crtc->mutex, &ctx);
+		if (err < 0)
+			goto unlock;
+	}
+
+	for_each_plane_in_state(state, plane, plane_state, i) {
+		err = drm_modeset_lock(&plane->mutex, &ctx);
+		if (err < 0)
+			goto unlock;
+	}
+
+	err = drm_atomic_commit(state);
+	if (err == -EDEADLK) {
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+fini:
+	drm_modeset_acquire_fini(&ctx);
+
+	return err;
+}
+
+/**
+ * drm_atomic_helper_suspend - subsystem-level suspend helper
+ * @dev: DRM device
+ *

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1903

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+ * Duplicates the current atomic state, disables all active outputs and then
+ * returns a pointer to the original atomic state to the caller. Drivers can
+ * pass this pointer to the drm_atomic_helper_resume() helper upon resume to
+ * restore the output configuration that was active at the time the system
+ * entered suspend.
+ *
+ * Returns: A pointer to a copy of the state before suspend on success or an
+ * ERR_PTR()-encoded error code on failure. Drivers should store the returned
+ * atomic state object and pass it to the drm_atomic_helper_resume() helper
+ * upon resume.

Style-nit: There should be a newline after "Returns:" for consistency with other kerneldoc in drm.

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1916

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +13 -0
+ */
+struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
+{
+	struct drm_atomic_state *state;
+	int err;
+
+	state = drm_atomic_helper_duplicate_state(dev);
+	if (IS_ERR(state))
+		return state;
+
+	err = drm_atomic_helper_disable_all(dev);
+	if (err < 0) {
+		drm_atomic_state_free(state);

This will hit a locking WARN_ON. Maybe better to pull out the drm_modset_lock all from these two functions and just pass them the acquire ctx? Otoh drm-misc already has a patch from Maarten to remove that locking check since its violated with drm dp mst stuff iirc.

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -0
+		return ERR_PTR(err);
+	}
+
+	return state;
+}

drivers/gpu/drm/drm_atomic_helper.c backoff: · line 1931

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+EXPORT_SYMBOL(drm_atomic_helper_suspend);
+
+/**
+ * drm_atomic_helper_resume - subsystem-level resume helper
+ * @dev: DRM device
+ * @state: atomic state to resume to
+ *
+ * Takes an atomic state object, grabs all the necessary locks and commits it.
+ * This can be used in conjunction with the drm_atomic_helper_suspend() helper
+ * to implement suspend/resume for atomic mode-setting enabled drivers.

Kerneldoc should also mention that it calls reset() first to make sure sw and hw state agree again. Otherwise the atomic_commit might go "well there's nothing to do here", so it's a crucial step.

Looks great otherwise.
-Daniel

Quoted 35 lines
drivers/gpu/drm/drm_atomic_helper.c +13 -0
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_resume(struct drm_device *dev,
+				    struct drm_atomic_state *state)
+{
+	drm_mode_config_reset(dev);
+
+	return drm_atomic_helper_restore_commit(state);
+}
+EXPORT_SYMBOL(drm_atomic_helper_resume);
+
+/**
  * drm_atomic_helper_crtc_set_property - helper for crtc properties
  * @crtc: DRM crtc
  * @property: DRM property
include/drm/drm_atomic_helper.h +5 -0
index 5d27612997ce..080f131c9f2e 100644
@@ -75,6 +75,11 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,
 int drm_atomic_helper_disable_plane(struct drm_plane *plane);
 int drm_atomic_helper_set_config(struct drm_mode_set *set);
 
+int drm_atomic_helper_disable_all(struct drm_device *dev);
+struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev);
+int drm_atomic_helper_resume(struct drm_device *dev,
+			     struct drm_atomic_state *state);
+
 int drm_atomic_helper_crtc_set_property(struct drm_crtc *crtc,
 					struct drm_property *property,
 					uint64_t val);
Signature · 1 line
2.4.5
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH 3/3 drm/tegra: Implement subsystem-level suspend/resume

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the drm_atomic_helper_suspend() and drm_atomic_helper_resume() helpers to implement subsystem-level suspend/resume.

---
 drivers/gpu/drm/tegra/drm.c | 9 +++++++++
 drivers/gpu/drm/tegra/drm.h | 2 ++
 2 files changed, 11 insertions(+)
drivers/gpu/drm/tegra/drm.c +9 -0
index 767dce20736c..fe5fcb777fb4 100644
@@ -1022,16 +1022,25 @@ static int host1x_drm_remove(struct host1x_device *dev)
 static int host1x_drm_suspend(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
+	struct tegra_drm *tegra = drm->dev_private;
 
 	drm_kms_helper_poll_disable(drm);
 
+	tegra->state = drm_atomic_helper_suspend(drm);
+	if (IS_ERR(tegra->state)) {
+		drm_kms_helper_poll_enable(drm);
+		return PTR_ERR(tegra->state);
+	}
+
 	return 0;
 }
 
 static int host1x_drm_resume(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
+	struct tegra_drm *tegra = drm->dev_private;
 
+	drm_atomic_helper_resume(drm, tegra->state);
 	drm_kms_helper_poll_enable(drm);
 
 	return 0;
drivers/gpu/drm/tegra/drm.h +2 -0
index dfbc0868dc6f..c31d43150ce1 100644
@@ -57,6 +57,8 @@ struct tegra_drm {
 		struct work_struct work;
 		struct mutex lock;
 	} commit;
+
+	struct drm_atomic_state *state;
 };
 
 struct tegra_drm_client;
Signature · 6 lines
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
In reply to Thierry Reding
Quoted 17 lines · Thierry Reding

From: Thierry Reding <[email protected]>

This function can be used to duplicate an atomic state object. This is useful for example to implement suspend/resume, where the state before suspend can be saved and restored upon resume.

---
 drivers/gpu/drm/drm_atomic_helper.c | 90 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  2 +
 2 files changed, 92 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index fd06595c2ee5..f842499ca79e 100644

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector) · line 2365

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -0
@@ -2358,6 +2358,96 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state);
 
 /**
+ * drm_atomic_helper_duplicate_state - duplicate an atomic state object
+ * @dev: DRM device
+ *
+ * Makes a copy of the current atomic state by looping over all objects and
+ * duplicating their respective states.

This needs a big warning that drivers better know what they're doing for two reasons: It promises that atomic states can be treated as persistent bits (e.g. if a driver has an update-counter somewhere that won't work). And it drops locks again so will race if that's not otherwise excluded (like in suspend/resume where nothing else is allowed to run if you shut down fbcon with fbdev_set_suspend() before calling this function).

Maybe needs some rewording, but all of the above (including details like fbdev_set_suspend) must be mentioned.

Quoted 14 lines
drivers/gpu/drm/drm_atomic_helper.c +14 -0
+ *
+ * Returns: A pointer to the copy of the atomic state object on success or an
+ * ERR_PTR()-encoded error code on failure.
+ */
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	int err;
+

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector) · line 2389

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return ERR_PTR(-ENOMEM);
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->acquire_ctx = &ctx;
+
+	err = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
+	if (err < 0)
+		goto free;

Just use drm_modeset_lock_all. You need them all anyway and for suspend/resume there won't be any contention anyway.

Otherwise lgtm.
-Daniel

Quoted 80 lines
drivers/gpu/drm/drm_atomic_helper.c +61 -0
+
+	drm_for_each_crtc(crtc, dev) {
+		unsigned int index = drm_crtc_index(crtc);
+		struct drm_crtc_state *crtc_state;
+
+		crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
+		if (!crtc_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->crtc_states[index] = crtc_state;
+		state->crtcs[index] = crtc;
+		crtc_state->state = state;
+	}
+
+	drm_for_each_plane(plane, dev) {
+		unsigned int index = drm_plane_index(plane);
+		struct drm_plane_state *plane_state;
+
+		plane_state = plane->funcs->atomic_duplicate_state(plane);
+		if (!plane_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->plane_states[index] = plane_state;
+		state->planes[index] = plane;
+		plane_state->state = state;
+	}
+
+	drm_for_each_connector(conn, dev) {
+		unsigned int index = drm_connector_index(conn);
+		struct drm_connector_state *conn_state;
+
+		conn_state = conn->funcs->atomic_duplicate_state(conn);
+		if (!conn_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->connector_states[index] = conn_state;
+		state->connectors[index] = conn;
+		conn_state->state = state;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);
+
+	if (err < 0) {
+		drm_atomic_state_free(state);
+		state = ERR_PTR(err);
+	}
+
+	return state;
+}
+EXPORT_SYMBOL(drm_atomic_helper_duplicate_state);
+
+/**
  * __drm_atomic_helper_connector_destroy_state - release connector state
  * @connector: connector object
  * @state: connector state object to release
include/drm/drm_atomic_helper.h +2 -0
index 4ffe9dca07c4..5d27612997ce 100644
@@ -118,6 +118,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
 					   struct drm_connector_state *state);
 struct drm_connector_state *
 drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev);
 void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					    struct drm_connector_state *state);
Signature · 1 line
2.4.5
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
In reply to Thierry Reding

Hey,

This patch series would be less complicated if you assume the caller locked with drm_modeset_lock_all and use the global acquire_ctx in each function. You're locking all state here after all..

Also you should use drm_atomic_get_*_state instead of calling those duplicate_state functions directly.

Op 11-08-15 om 13:37 schreef Thierry Reding:

Quoted 118 lines

From: Thierry Reding <[email protected]>

This function can be used to duplicate an atomic state object. This is useful for example to implement suspend/resume, where the state before suspend can be saved and restored upon resume.

---
 drivers/gpu/drm/drm_atomic_helper.c | 90 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  2 +
 2 files changed, 92 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +90 -0
index fd06595c2ee5..f842499ca79e 100644
@@ -2358,6 +2358,96 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state);
 
 /**
+ * drm_atomic_helper_duplicate_state - duplicate an atomic state object
+ * @dev: DRM device
+ *
+ * Makes a copy of the current atomic state by looping over all objects and
+ * duplicating their respective states.
+ *
+ * Returns: A pointer to the copy of the atomic state object on success or an
+ * ERR_PTR()-encoded error code on failure.
+ */
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	int err;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return ERR_PTR(-ENOMEM);
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->acquire_ctx = &ctx;
+
+	err = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
+	if (err < 0)
+		goto free;
+
+	drm_for_each_crtc(crtc, dev) {
+		unsigned int index = drm_crtc_index(crtc);
+		struct drm_crtc_state *crtc_state;
+
+		crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
+		if (!crtc_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->crtc_states[index] = crtc_state;
+		state->crtcs[index] = crtc;
+		crtc_state->state = state;
+	}
+
+	drm_for_each_plane(plane, dev) {
+		unsigned int index = drm_plane_index(plane);
+		struct drm_plane_state *plane_state;
+
+		plane_state = plane->funcs->atomic_duplicate_state(plane);
+		if (!plane_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->plane_states[index] = plane_state;
+		state->planes[index] = plane;
+		plane_state->state = state;
+	}
+
+	drm_for_each_connector(conn, dev) {
+		unsigned int index = drm_connector_index(conn);
+		struct drm_connector_state *conn_state;
+
+		conn_state = conn->funcs->atomic_duplicate_state(conn);
+		if (!conn_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->connector_states[index] = conn_state;
+		state->connectors[index] = conn;
+		conn_state->state = state;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);
+
+	if (err < 0) {
+		drm_atomic_state_free(state);
+		state = ERR_PTR(err);
+	}
+
+	return state;
+}
+EXPORT_SYMBOL(drm_atomic_helper_duplicate_state);
+
+/**
  * __drm_atomic_helper_connector_destroy_state - release connector state
  * @connector: connector object
  * @state: connector state object to release
include/drm/drm_atomic_helper.h +0 -0
index 4ffe9dca07c4..5d27612997ce 100644

include/drm/drm_atomic_helper.h __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, · line 125

Quoted 8 lines
include/drm/drm_atomic_helper.h +2 -0
@@ -118,6 +118,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
 					   struct drm_connector_state *state);
 struct drm_connector_state *
 drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev);
 void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					    struct drm_connector_state *state);

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
In reply to Thierry Reding
Quoted 89 lines · Thierry Reding

From: Thierry Reding <[email protected]>

This function can be used to duplicate an atomic state object. This is useful for example to implement suspend/resume, where the state before suspend can be saved and restored upon resume.

---
 drivers/gpu/drm/drm_atomic_helper.c | 90 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  2 +
 2 files changed, 92 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +69 -0
index fd06595c2ee5..f842499ca79e 100644
@@ -2358,6 +2358,96 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state);
 
 /**
+ * drm_atomic_helper_duplicate_state - duplicate an atomic state object
+ * @dev: DRM device
+ *
+ * Makes a copy of the current atomic state by looping over all objects and
+ * duplicating their respective states.
+ *
+ * Returns: A pointer to the copy of the atomic state object on success or an
+ * ERR_PTR()-encoded error code on failure.
+ */
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_atomic_state *state;
+	struct drm_connector *conn;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	int err;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return ERR_PTR(-ENOMEM);
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->acquire_ctx = &ctx;
+
+	err = drm_modeset_lock(&dev->mode_config.connection_mutex, &ctx);
+	if (err < 0)
+		goto free;
+
+	drm_for_each_crtc(crtc, dev) {
+		unsigned int index = drm_crtc_index(crtc);
+		struct drm_crtc_state *crtc_state;
+
+		crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
+		if (!crtc_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->crtc_states[index] = crtc_state;
+		state->crtcs[index] = crtc;
+		crtc_state->state = state;
+	}
+
+	drm_for_each_plane(plane, dev) {
+		unsigned int index = drm_plane_index(plane);
+		struct drm_plane_state *plane_state;
+
+		plane_state = plane->funcs->atomic_duplicate_state(plane);
+		if (!plane_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}
+
+		state->plane_states[index] = plane_state;
+		state->planes[index] = plane;
+		plane_state->state = state;
+	}
+
+	drm_for_each_connector(conn, dev) {
+		unsigned int index = drm_connector_index(conn);
+		struct drm_connector_state *conn_state;
+
+		conn_state = conn->funcs->atomic_duplicate_state(conn);
+		if (!conn_state) {
+			err = -ENOMEM;
+			goto unlock;
+		}

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector) · line 2439

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+
+		state->connector_states[index] = conn_state;
+		state->connectors[index] = conn;
+		conn_state->state = state;
+	}
+
+unlock:
+	drm_modeset_drop_locks(&ctx);
+free:
+	drm_modeset_acquire_fini(&ctx);

One more: I think we should clear state->acquire_ctx here, just to make sure it's not accidentally reused.
-Daniel

Quoted 30 lines
drivers/gpu/drm/drm_atomic_helper.c +11 -0
+
+	if (err < 0) {
+		drm_atomic_state_free(state);
+		state = ERR_PTR(err);
+	}
+
+	return state;
+}
+EXPORT_SYMBOL(drm_atomic_helper_duplicate_state);
+
+/**
  * __drm_atomic_helper_connector_destroy_state - release connector state
  * @connector: connector object
  * @state: connector state object to release
include/drm/drm_atomic_helper.h +2 -0
index 4ffe9dca07c4..5d27612997ce 100644
@@ -118,6 +118,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
 					   struct drm_connector_state *state);
 struct drm_connector_state *
 drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
+struct drm_atomic_state *
+drm_atomic_helper_duplicate_state(struct drm_device *dev);
 void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					    struct drm_connector_state *state);
Signature · 1 line
2.4.5
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel