mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-24 06:44:23 +08:00
882f38b7f6
While the current locking/serialization of the global state suffices for protecting the obj->state access and the actual hardware reprogramming, we do have a problem with accessing the old/new states during nonblocking commits. The state computation and swap will be protected by the crtc locks, but the commit_tails can finish out of order, thus also causing the atomic states to be cleaned up out of order. This would mean the commit that started first but finished last has had its new state freed as the no-longer-needed old state by the other commit. To fix this let's just refcount the states. obj->state amounts to one reference, and the intel_atomic_state holds extra references to both its new and old global obj states. Fixes:0ef1905ecf
("drm/i915: Introduce better global state handling") Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200527200245.13184-1-ville.syrjala@linux.intel.com Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com> (cherry picked from commitf8c86ffa28
) Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
91 lines
2.9 KiB
C
91 lines
2.9 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
/*
|
|
* Copyright © 2020 Intel Corporation
|
|
*/
|
|
|
|
#ifndef __INTEL_GLOBAL_STATE_H__
|
|
#define __INTEL_GLOBAL_STATE_H__
|
|
|
|
#include <linux/kref.h>
|
|
#include <linux/list.h>
|
|
|
|
struct drm_i915_private;
|
|
struct intel_atomic_state;
|
|
struct intel_global_obj;
|
|
struct intel_global_state;
|
|
|
|
struct intel_global_state_funcs {
|
|
struct intel_global_state *(*atomic_duplicate_state)(struct intel_global_obj *obj);
|
|
void (*atomic_destroy_state)(struct intel_global_obj *obj,
|
|
struct intel_global_state *state);
|
|
};
|
|
|
|
struct intel_global_obj {
|
|
struct list_head head;
|
|
struct intel_global_state *state;
|
|
const struct intel_global_state_funcs *funcs;
|
|
};
|
|
|
|
#define intel_for_each_global_obj(obj, dev_priv) \
|
|
list_for_each_entry(obj, &(dev_priv)->global_obj_list, head)
|
|
|
|
#define for_each_new_global_obj_in_state(__state, obj, new_obj_state, __i) \
|
|
for ((__i) = 0; \
|
|
(__i) < (__state)->num_global_objs && \
|
|
((obj) = (__state)->global_objs[__i].ptr, \
|
|
(new_obj_state) = (__state)->global_objs[__i].new_state, 1); \
|
|
(__i)++) \
|
|
for_each_if(obj)
|
|
|
|
#define for_each_old_global_obj_in_state(__state, obj, new_obj_state, __i) \
|
|
for ((__i) = 0; \
|
|
(__i) < (__state)->num_global_objs && \
|
|
((obj) = (__state)->global_objs[__i].ptr, \
|
|
(new_obj_state) = (__state)->global_objs[__i].old_state, 1); \
|
|
(__i)++) \
|
|
for_each_if(obj)
|
|
|
|
#define for_each_oldnew_global_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \
|
|
for ((__i) = 0; \
|
|
(__i) < (__state)->num_global_objs && \
|
|
((obj) = (__state)->global_objs[__i].ptr, \
|
|
(old_obj_state) = (__state)->global_objs[__i].old_state, \
|
|
(new_obj_state) = (__state)->global_objs[__i].new_state, 1); \
|
|
(__i)++) \
|
|
for_each_if(obj)
|
|
|
|
struct intel_global_state {
|
|
struct intel_global_obj *obj;
|
|
struct intel_atomic_state *state;
|
|
struct kref ref;
|
|
bool changed;
|
|
};
|
|
|
|
struct __intel_global_objs_state {
|
|
struct intel_global_obj *ptr;
|
|
struct intel_global_state *state, *old_state, *new_state;
|
|
};
|
|
|
|
void intel_atomic_global_obj_init(struct drm_i915_private *dev_priv,
|
|
struct intel_global_obj *obj,
|
|
struct intel_global_state *state,
|
|
const struct intel_global_state_funcs *funcs);
|
|
void intel_atomic_global_obj_cleanup(struct drm_i915_private *dev_priv);
|
|
|
|
struct intel_global_state *
|
|
intel_atomic_get_global_obj_state(struct intel_atomic_state *state,
|
|
struct intel_global_obj *obj);
|
|
struct intel_global_state *
|
|
intel_atomic_get_old_global_obj_state(struct intel_atomic_state *state,
|
|
struct intel_global_obj *obj);
|
|
struct intel_global_state *
|
|
intel_atomic_get_new_global_obj_state(struct intel_atomic_state *state,
|
|
struct intel_global_obj *obj);
|
|
|
|
void intel_atomic_swap_global_state(struct intel_atomic_state *state);
|
|
void intel_atomic_clear_global_state(struct intel_atomic_state *state);
|
|
int intel_atomic_lock_global_state(struct intel_global_state *obj_state);
|
|
int intel_atomic_serialize_global_state(struct intel_global_state *obj_state);
|
|
|
|
#endif
|