Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad093607 authored by Thierry Reding's avatar Thierry Reding
Browse files

drm: Introduce drm_connector_{get,put}()



For consistency with other reference counting APIs in the kernel, add
drm_connector_get() and drm_connector_put() functions to reference count
connectors.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

The existing semantic patch for mode object reference count conversion
is extended for these new helpers.

Reviewed-by: default avatarSean Paul <seanpaul@chromium.org>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170228144643.5668-4-thierry.reding@gmail.com
parent 020a218f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
						       state->connectors[i].state);
		state->connectors[i].ptr = NULL;
		state->connectors[i].state = NULL;
		drm_connector_unreference(connector);
		drm_connector_put(connector);
	}

	for (i = 0; i < config->num_crtc; i++) {
@@ -1030,7 +1030,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
	if (!connector_state)
		return ERR_PTR(-ENOMEM);

	drm_connector_reference(connector);
	drm_connector_get(connector);
	state->connectors[index].state = connector_state;
	state->connectors[index].old_state = connector->state;
	state->connectors[index].new_state = connector_state;
@@ -1380,7 +1380,7 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
		crtc_state->connector_mask &=
			~(1 << drm_connector_index(conn_state->connector));

		drm_connector_unreference(conn_state->connector);
		drm_connector_put(conn_state->connector);
		conn_state->crtc = NULL;
	}

@@ -1392,7 +1392,7 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
		crtc_state->connector_mask |=
			1 << drm_connector_index(conn_state->connector);

		drm_connector_reference(conn_state->connector);
		drm_connector_get(conn_state->connector);
		conn_state->crtc = crtc;

		DRM_DEBUG_ATOMIC("Link connector state %p to [CRTC:%d:%s]\n",
+2 −2
Original line number Diff line number Diff line
@@ -3351,7 +3351,7 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
{
	memcpy(state, connector->state, sizeof(*state));
	if (state->crtc)
		drm_connector_reference(connector);
		drm_connector_get(connector);
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);

@@ -3477,7 +3477,7 @@ void
__drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state)
{
	if (state->crtc)
		drm_connector_unreference(state->connector);
		drm_connector_put(state->connector);
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);

+5 −5
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@
 * als fixed panels or anything else that can display pixels in some form. As
 * opposed to all other KMS objects representing hardware (like CRTC, encoder or
 * plane abstractions) connectors can be hotplugged and unplugged at runtime.
 * Hence they are reference-counted using drm_connector_reference() and
 * drm_connector_unreference().
 * Hence they are reference-counted using drm_connector_get() and
 * drm_connector_put().
 *
 * KMS driver must create, initialize, register and attach at a &struct
 * drm_connector for each such sink. The instance is created as other KMS
@@ -557,7 +557,7 @@ drm_connector_list_iter_next(struct drm_connector_list_iter *iter)
	spin_unlock_irqrestore(&config->connector_list_lock, flags);

	if (old_conn)
		drm_connector_unreference(old_conn);
		drm_connector_put(old_conn);

	return iter->conn;
}
@@ -576,7 +576,7 @@ void drm_connector_list_iter_put(struct drm_connector_list_iter *iter)
{
	iter->dev = NULL;
	if (iter->conn)
		drm_connector_unreference(iter->conn);
		drm_connector_put(iter->conn);
	lock_release(&connector_list_iter_dep_map, 0, _RET_IP_);
}
EXPORT_SYMBOL(drm_connector_list_iter_put);
@@ -1309,7 +1309,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
out:
	mutex_unlock(&dev->mode_config.mutex);
out_unref:
	drm_connector_unreference(connector);
	drm_connector_put(connector);

	return ret;
}
+1 −1
Original line number Diff line number Diff line
@@ -685,7 +685,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
	if (connector_set) {
		for (i = 0; i < crtc_req->count_connectors; i++) {
			if (connector_set[i])
				drm_connector_unreference(connector_set[i]);
				drm_connector_put(connector_set[i]);
		}
	}
	kfree(connector_set);
+3 −3
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
			connector->dpms = DRM_MODE_DPMS_OFF;

			/* we keep a reference while the encoder is bound */
			drm_connector_unreference(connector);
			drm_connector_put(connector);
		}
		drm_connector_list_iter_put(&conn_iter);
	}
@@ -623,7 +623,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
	for (ro = 0; ro < set->num_connectors; ro++) {
		if (set->connectors[ro]->encoder)
			continue;
		drm_connector_reference(set->connectors[ro]);
		drm_connector_get(set->connectors[ro]);
	}

	/* a) traverse passed in connector list and get encoders for them */
@@ -772,7 +772,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
	for (ro = 0; ro < set->num_connectors; ro++) {
		if (set->connectors[ro]->encoder)
			continue;
		drm_connector_unreference(set->connectors[ro]);
		drm_connector_put(set->connectors[ro]);
	}

	/* Try to restore the config */
Loading