[igt-dev] [PATCH i-g-t 15/31] i915/perf: Add OAM support

Dixit, Ashutosh ashutosh.dixit at intel.com
Wed Mar 15 00:38:36 UTC 2023


On Mon, 13 Mar 2023 08:21:21 -0700, Kamil Konieczny wrote:
>
> > @@ -5306,10 +5345,27 @@ test_sysctl_defaults(void)
> >	igt_assert_eq(max_freq, 100000);
> >  }
> >
> > -#define __for_each_perf_enabled_engine(fd__, e__) \
> > -	for_each_physical_engine(fd__, e__) \
> > -		if (perf_supports_engine(e__)) \
> > -			igt_dynamic_f("%s", e__->name)
> > +static struct intel_execution_engine2 *
> > +__ci_to_e2(const intel_ctx_t *ctx, struct i915_engine_class_instance *ci)
> > +{
> > +	static struct intel_execution_engine2 e2;
>
> e2 is on stack, see below, so it should be *e2
>
> > +	struct intel_execution_engine2 *e;
> > +
> > +	for_each_ctx_engine(drm_fd, ctx, e) {
> > +		if (e->class == ci->engine_class && e->instance == ci->engine_instance) {
> > +			e2 = *e;
> > +			break;
> > +		}
> > +	}
> > +
> > +	return &e2;
> --------------- ^
> imho you should allocate memory for this and return NULL when
> not found.

Yup something needs to be done here since e2 is on stack so dangerous to
return a pointer to it.


More information about the igt-dev mailing list