[PATCH 2/3] drm/i915/display: Add infra to reduce global state funcs boilerplate
Gustavo Sousa
gustavo.sousa at intel.com
Fri Dec 20 13:56:46 UTC 2024
Quoting Jani Nikula (2024-12-20 05:51:51-03:00)
>On Thu, 19 Dec 2024, Gustavo Sousa <gustavo.sousa at intel.com> wrote:
>> diff --git a/drivers/gpu/drm/i915/display/intel_global_state.h b/drivers/gpu/drm/i915/display/intel_global_state.h
>> index 6506a8e32972..e47e007225cc 100644
>> --- a/drivers/gpu/drm/i915/display/intel_global_state.h
>> +++ b/drivers/gpu/drm/i915/display/intel_global_state.h
>> @@ -8,6 +8,8 @@
>>
>> #include <linux/kref.h>
>> #include <linux/list.h>
>> +#include <linux/stddef.h>
>
>What do you need this for?
Because of offsetof().
--
Gustavo Sousa
>
>> +#include <linux/types.h>
>>
>> struct drm_i915_private;
>> struct intel_atomic_state;
>> @@ -15,6 +17,10 @@ struct intel_global_obj;
>> struct intel_global_state;
>>
>> struct intel_global_state_funcs {
>> + /* state_size and base_offset are initialized by INTEL_GLOBAL_STATE_DEFAULTS() */
>> + size_t state_size;
>> + size_t base_offset;
>> +
>> 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);
>> @@ -26,6 +32,10 @@ struct intel_global_obj {
>> const struct intel_global_state_funcs *funcs;
>> };
>>
>> +#define INTEL_GLOBAL_STATE_DEFAULTS(type, base_member) \
>> + .state_size = sizeof(type), \
>> + .base_offset = offsetof(type, base_member)
>> +
>> #define intel_for_each_global_obj(obj, dev_priv) \
>> list_for_each_entry(obj, &(dev_priv)->display.global.obj_list, head)
>>
>> @@ -96,4 +106,9 @@ int intel_atomic_global_state_wait_for_dependencies(struct intel_atomic_state *s
>>
>> bool intel_atomic_global_state_is_serialized(struct intel_atomic_state *state);
>>
>> +struct intel_global_state *
>> +intel_atomic_global_duplicate_state_common(struct intel_global_obj *obj);
>> +void intel_atomic_global_destroy_state_common(struct intel_global_obj *obj,
>> + struct intel_global_state *state);
>> +
>> #endif
>
>--
>Jani Nikula, Intel
More information about the Intel-gfx
mailing list