[Intel-gfx] [PATCH v8 6/6] drm/i915: expose rcs topology through query uAPI

Lionel Landwerlin lionel.g.landwerlin at intel.com
Wed Jan 17 15:50:30 UTC 2018


On 17/01/18 15:39, Lionel Landwerlin wrote:
> With the introduction of asymmetric slices in CNL, we cannot rely on
> the previous SUBSLICE_MASK getparam to tell userspace what subslices
> are available. Here we introduce a more detailed way of querying the
> Gen's GPU topology that doesn't aggregate numbers.
>
> This is essential for monitoring parts of the GPU with the OA unit,
> because counters need to be normalized to the number of
> EUs/subslices/slices. The current aggregated numbers like EU_TOTAL do
> not gives us sufficient information.
>
> As a bonus we can draw representations of the GPU :
>
>          https://imgur.com/a/vuqpa
>
> v2: Rename uapi struct s/_mask/_info/ (Tvrtko)
>      Report max_slice/subslice/eus_per_subslice rather than strides (Tvrtko)
>      Add uapi macros to read data from *_info structs (Tvrtko)
>
> v3: Use !!(v & DRM_I915_BIT()) for uapi macros instead of custom shifts (Tvrtko)
>
> v4: factorize query item writting (Tvrtko)
>      tweak uapi struct/define names (Tvrtko)
>
> v5: Replace ALIGN() macro (Chris)
>
> v6: Updated uapi comments (Tvrtko)
>      Moved flags != 0 checks into vfuncs (Tvrtko)
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> ---
>   drivers/gpu/drm/i915/i915_query.c | 105 ++++++++++++++++++++++++++++++++++++++
>   include/uapi/drm/i915_drm.h       |  68 ++++++++++++++++++++++++
>   2 files changed, 173 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_query.c b/drivers/gpu/drm/i915/i915_query.c
> index 5aa886313cf9..5d1386db8e7b 100644
> --- a/drivers/gpu/drm/i915/i915_query.c
> +++ b/drivers/gpu/drm/i915/i915_query.c
> @@ -25,8 +25,113 @@
>   #include "i915_drv.h"
>   #include <uapi/drm/i915_drm.h>
>   
> +static int copy_query_data(struct drm_i915_query_item *query_item,
> +			   const void *item_ptr, u32 item_length,
> +			   const void *data_ptr, u32 data_length)
> +{
> +	u32 total_length = item_length + data_length;
> +
> +	BUG_ON(add_overflows(item_length, data_length));
> +
> +	if (query_item->length == 0)
> +		return total_length;
> +
> +	if (query_item->length < total_length)
> +		return -EINVAL;
> +
> +	if (copy_to_user(u64_to_user_ptr(query_item->data_ptr),
> +			 item_ptr, item_length))
> +		return -EFAULT;
> +
> +	if (copy_to_user(u64_to_user_ptr(query_item->data_ptr + item_length),
> +			 data_ptr, data_length))
> +		return -EFAULT;
> +

Dammit... Forgot some overflow checking here.


More information about the Intel-gfx mailing list