|
@@ -1164,6 +1164,7 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* drm_atomic_private_obj_init - initialize private object
|
|
* drm_atomic_private_obj_init - initialize private object
|
|
|
|
|
+ * @dev: DRM device this object will be attached to
|
|
|
* @obj: private object
|
|
* @obj: private object
|
|
|
* @state: initial private object state
|
|
* @state: initial private object state
|
|
|
* @funcs: pointer to the struct of function pointers that identify the object
|
|
* @funcs: pointer to the struct of function pointers that identify the object
|
|
@@ -1173,14 +1174,18 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
|
|
|
* driver private object that needs its own atomic state.
|
|
* driver private object that needs its own atomic state.
|
|
|
*/
|
|
*/
|
|
|
void
|
|
void
|
|
|
-drm_atomic_private_obj_init(struct drm_private_obj *obj,
|
|
|
|
|
|
|
+drm_atomic_private_obj_init(struct drm_device *dev,
|
|
|
|
|
+ struct drm_private_obj *obj,
|
|
|
struct drm_private_state *state,
|
|
struct drm_private_state *state,
|
|
|
const struct drm_private_state_funcs *funcs)
|
|
const struct drm_private_state_funcs *funcs)
|
|
|
{
|
|
{
|
|
|
memset(obj, 0, sizeof(*obj));
|
|
memset(obj, 0, sizeof(*obj));
|
|
|
|
|
|
|
|
|
|
+ drm_modeset_lock_init(&obj->lock);
|
|
|
|
|
+
|
|
|
obj->state = state;
|
|
obj->state = state;
|
|
|
obj->funcs = funcs;
|
|
obj->funcs = funcs;
|
|
|
|
|
+ list_add_tail(&obj->head, &dev->mode_config.privobj_list);
|
|
|
}
|
|
}
|
|
|
EXPORT_SYMBOL(drm_atomic_private_obj_init);
|
|
EXPORT_SYMBOL(drm_atomic_private_obj_init);
|
|
|
|
|
|
|
@@ -1193,7 +1198,9 @@ EXPORT_SYMBOL(drm_atomic_private_obj_init);
|
|
|
void
|
|
void
|
|
|
drm_atomic_private_obj_fini(struct drm_private_obj *obj)
|
|
drm_atomic_private_obj_fini(struct drm_private_obj *obj)
|
|
|
{
|
|
{
|
|
|
|
|
+ list_del(&obj->head);
|
|
|
obj->funcs->atomic_destroy_state(obj, obj->state);
|
|
obj->funcs->atomic_destroy_state(obj, obj->state);
|
|
|
|
|
+ drm_modeset_lock_fini(&obj->lock);
|
|
|
}
|
|
}
|
|
|
EXPORT_SYMBOL(drm_atomic_private_obj_fini);
|
|
EXPORT_SYMBOL(drm_atomic_private_obj_fini);
|
|
|
|
|
|
|
@@ -1203,8 +1210,8 @@ EXPORT_SYMBOL(drm_atomic_private_obj_fini);
|
|
|
* @obj: private object to get the state for
|
|
* @obj: private object to get the state for
|
|
|
*
|
|
*
|
|
|
* This function returns the private object state for the given private object,
|
|
* This function returns the private object state for the given private object,
|
|
|
- * allocating the state if needed. It does not grab any locks as the caller is
|
|
|
|
|
- * expected to care of any required locking.
|
|
|
|
|
|
|
+ * allocating the state if needed. It will also grab the relevant private
|
|
|
|
|
+ * object lock to make sure that the state is consistent.
|
|
|
*
|
|
*
|
|
|
* RETURNS:
|
|
* RETURNS:
|
|
|
*
|
|
*
|
|
@@ -1214,7 +1221,7 @@ struct drm_private_state *
|
|
|
drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
|
|
drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
|
|
|
struct drm_private_obj *obj)
|
|
struct drm_private_obj *obj)
|
|
|
{
|
|
{
|
|
|
- int index, num_objs, i;
|
|
|
|
|
|
|
+ int index, num_objs, i, ret;
|
|
|
size_t size;
|
|
size_t size;
|
|
|
struct __drm_private_objs_state *arr;
|
|
struct __drm_private_objs_state *arr;
|
|
|
struct drm_private_state *obj_state;
|
|
struct drm_private_state *obj_state;
|
|
@@ -1223,6 +1230,10 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
|
|
|
if (obj == state->private_objs[i].ptr)
|
|
if (obj == state->private_objs[i].ptr)
|
|
|
return state->private_objs[i].state;
|
|
return state->private_objs[i].state;
|
|
|
|
|
|
|
|
|
|
+ ret = drm_modeset_lock(&obj->lock, state->acquire_ctx);
|
|
|
|
|
+ if (ret)
|
|
|
|
|
+ return ERR_PTR(ret);
|
|
|
|
|
+
|
|
|
num_objs = state->num_private_objs + 1;
|
|
num_objs = state->num_private_objs + 1;
|
|
|
size = sizeof(*state->private_objs) * num_objs;
|
|
size = sizeof(*state->private_objs) * num_objs;
|
|
|
arr = krealloc(state->private_objs, size, GFP_KERNEL);
|
|
arr = krealloc(state->private_objs, size, GFP_KERNEL);
|