Message ID | 20200504111249.1367096-5-lionel.g.landwerlin@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/perf: Add support for multi context perf queries | expand |
Quoting Lionel Landwerlin (2020-05-04 12:12:49) > Add 2 new properties to the i915-perf open ioctl to specify an array > of GEM context handles as well as the length of the array. > > This can be used by drivers using multiple GEM contexts to implement a > single GL context. > > Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> > Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4464 From what I recall of the tests, the API extension looked reasonable. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> -Chris
On 04/05/2020 14:23, Chris Wilson wrote: > Quoting Lionel Landwerlin (2020-05-04 12:12:49) >> Add 2 new properties to the i915-perf open ioctl to specify an array >> of GEM context handles as well as the length of the array. >> >> This can be used by drivers using multiple GEM contexts to implement a >> single GL context. >> >> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> >> Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4464 > >From what I recall of the tests, the API extension looked reasonable. > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> > -Chris Is that Rb for the whole series? The meat of the change to enable this being in the previous commit. Thanks, -Lionel
On 06/05/2020 15:04, Lionel Landwerlin wrote: > On 04/05/2020 14:23, Chris Wilson wrote: >> Quoting Lionel Landwerlin (2020-05-04 12:12:49) >>> Add 2 new properties to the i915-perf open ioctl to specify an array >>> of GEM context handles as well as the length of the array. >>> >>> This can be used by drivers using multiple GEM contexts to implement a >>> single GL context. >>> >>> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> >>> Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4464 >> >From what I recall of the tests, the API extension looked reasonable. >> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> >> -Chris > > Is that Rb for the whole series? > > The meat of the change to enable this being in the previous commit. > > > Thanks, > > -Lionel Oops... Missed one of your mail. Same question about the tests ;) -Lionel
Quoting Lionel Landwerlin (2020-05-06 13:04:57) > On 04/05/2020 14:23, Chris Wilson wrote: > > Quoting Lionel Landwerlin (2020-05-04 12:12:49) > >> Add 2 new properties to the i915-perf open ioctl to specify an array > >> of GEM context handles as well as the length of the array. > >> > >> This can be used by drivers using multiple GEM contexts to implement a > >> single GL context. > >> > >> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> > >> Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4464 > > >From what I recall of the tests, the API extension looked reasonable. > > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> > > -Chris > > Is that Rb for the whole series? I believe they are all tagged, and if not, then make it so. -Chris
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 66d52ee4767b..cc7ad38b3294 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -3691,7 +3691,8 @@ static int read_properties_unlocked(struct i915_perf *perf, struct perf_open_properties *props) { u64 __user *uprop = uprops; - u32 i; + u32 __user *uctx_handles = NULL; + u32 i, n_uctx_handles = 0; int err; memset(props, 0, sizeof(struct perf_open_properties)); @@ -3742,7 +3743,7 @@ static int read_properties_unlocked(struct i915_perf *perf, switch ((enum drm_i915_perf_property_id)id) { case DRM_I915_PERF_PROP_CTX_HANDLE: - if (props->n_ctx_handles > 0) { + if (props->n_ctx_handles > 0 || n_uctx_handles > 0) { DRM_DEBUG("Context handle specified multiple times\n"); err = -EINVAL; goto error; @@ -3856,6 +3857,38 @@ static int read_properties_unlocked(struct i915_perf *perf, } props->poll_oa_period = value; break; + case DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY: + /* HSW can only filter in HW and only on a single + * context. + */ + if (IS_HASWELL(perf->i915)) { + DRM_DEBUG("Multi context filter not supported on HSW\n"); + err = -ENODEV; + goto error; + } + uctx_handles = u64_to_user_ptr(value); + break; + case DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY_LENGTH: + if (IS_HASWELL(perf->i915)) { + DRM_DEBUG("Multi context filter not supported on HSW\n"); + err = -ENODEV; + goto error; + } + if (props->n_ctx_handles > 0 || n_uctx_handles > 0) { + DRM_DEBUG("Context handle specified multiple times\n"); + err = -EINVAL; + goto error; + } + props->ctx_handles = + kmalloc_array(value, + sizeof(*props->ctx_handles), + GFP_KERNEL); + if (!props->ctx_handles) { + err = -ENOMEM; + goto error; + } + n_uctx_handles = value; + break; case DRM_I915_PERF_PROP_MAX: MISSING_CASE(id); err = -EINVAL; @@ -3865,6 +3898,21 @@ static int read_properties_unlocked(struct i915_perf *perf, uprop += 2; } + if (n_uctx_handles > 0 && props->n_ctx_handles > 0) { + DRM_DEBUG("Context handle specified multiple times\n"); + err = -EINVAL; + goto error; + } + + for (i = 0; i < n_uctx_handles; i++) { + err = get_user(props->ctx_handles[i], uctx_handles); + if (err) + goto error; + + uctx_handles++; + props->n_ctx_handles++; + } + return 0; error: @@ -4648,8 +4696,12 @@ int i915_perf_ioctl_version(void) * * 5: Add DRM_I915_PERF_PROP_POLL_OA_PERIOD parameter that controls the * interval for the hrtimer used to check for OA data. + * + * 6: Add DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY & + * DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY_LENGTH to allow an + * application monitor/pin multiple contexts. */ - return 5; + return 6; } #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 14b67cd6b54b..f80e7932d728 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -1993,6 +1993,27 @@ enum drm_i915_perf_property_id { */ DRM_I915_PERF_PROP_POLL_OA_PERIOD, + /** + * Specifies an array of u32 GEM context handles to filter reports + * with. + * + * Using this parameter is incompatible with using + * DRM_I915_PERF_PROP_CTX_HANDLE. + * + * This property is available in perf revision 6. + */ + DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY, + + /** + * Specifies the length of the array specified with + * DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY. + * + * The length must be in the range [1, 4]. + * + * This property is available in perf revision 6. + */ + DRM_I915_PERF_PROP_CTX_HANDLE_ARRAY_LENGTH, + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
Add 2 new properties to the i915-perf open ioctl to specify an array of GEM context handles as well as the length of the array. This can be used by drivers using multiple GEM contexts to implement a single GL context. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4464 --- drivers/gpu/drm/i915/i915_perf.c | 58 ++++++++++++++++++++++++++++++-- include/uapi/drm/i915_drm.h | 21 ++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-)