[Intel-gfx] [PATCH] drm/i915: Use BUILD_BUG_ON to detected missing engine definitions
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Tue Feb 28 14:21:23 UTC 2017
On 28/02/2017 14:00, Michal Wajdeczko wrote:
> Additionally use runtime check to catch invalid engine indices.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Jani Nikula <jani.nikula at intel.com>
> ---
> drivers/gpu/drm/i915/intel_engine_cs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
> index a238304..8df53ae 100644
> --- a/drivers/gpu/drm/i915/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/intel_engine_cs.c
> @@ -89,6 +89,8 @@ intel_engine_setup(struct drm_i915_private *dev_priv,
> const struct engine_info *info = &intel_engines[id];
> struct intel_engine_cs *engine;
>
> + BUILD_BUG_ON(ARRAY_SIZE(intel_engines) != I915_NUM_ENGINES);
For some reason I feel this is too strict. ;)
> + GEM_BUG_ON(id < 0 || id >= I915_NUM_ENGINES);
The caller of this function iterates 0..ARRAY_SIZE(intel_engines) and
also filters with HAS_ENGINE before calling it so not sure this is
absolutely needed. Maybe instead:
GEM_BUG_ON(id >= ARRAY_SIZE(dev_priv->engine));
?
> GEM_BUG_ON(dev_priv->engine[id]);
> engine = kzalloc(sizeof(*engine), GFP_KERNEL);
> if (!engine)
>
Regards,
Tvrtko
More information about the Intel-gfx
mailing list