Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
	intel-xe@lists.freedesktop.org
Cc: Matt Roper <matthew.d.roper@intel.com>
Subject: Re: [Intel-xe] [PATCH 1/2] drm/xe: Indroduce low level driver error counting APIs
Date: Thu, 21 Sep 2023 08:44:31 +0200	[thread overview]
Message-ID: <db2ee607-2f4e-b7b5-9bf7-b306eea198f0@intel.com> (raw)
In-Reply-To: <20230921060314.5933-2-tejas.upadhyay@intel.com>



On 21.09.2023 08:03, Tejas Upadhyay wrote:
> Low level driver error that might have power or performance
> impact on the system, we are adding a new error counter to GT
> and tile and increment on each occurrance. Lets introcuce APIs

typos

> to define and increment each error type counter.
> 
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_device_types.h | 13 +++++++++++++
>  drivers/gpu/drm/xe/xe_gt.c           | 24 ++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_gt_types.h     | 12 ++++++++++++
>  drivers/gpu/drm/xe/xe_tile.c         | 25 +++++++++++++++++++++++++
>  4 files changed, 74 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index a82f28c6a3a0..14f477412581 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -57,6 +57,13 @@ struct xe_ggtt;
>  		 const struct xe_tile * : (const struct xe_device *)((tile__)->xe),	\
>  		 struct xe_tile * : (tile__)->xe)
>  
> +enum xe_tile_err_type {

to follow enum name, below enumerator names likely should start with:

	XE_TILE_ERR_..

or change enum type name to:

	xe_tile_drv_err_type

> +	XE_TILE_DRV_ERR_GGTT = 0,

value of first enumerator is 0 by default, no need to set explicitly

> +	XE_TILE_DRV_ERR_GUC_COMM,

GuC is per GT, not per tile, so why here?

> +	XE_TILE_DRV_ERR_INTR,
> +	XE_TILE_DRV_ERR_MAX

while this is common practice to have "MAX" as part of the enum, it is
breaking the one of the benefit of allowing only explicit constants as
params - note that if someone passes "MAX" it wont be treated as error
by the compiler ...

maybe at least name that enumerator differently to avoid mistakes ?
or best make it as #define outside enum definition ?

> +};
> +
>  /**
>   * struct xe_mem_region - memory region structure
>   * This is used to describe a memory region in xe
> @@ -173,8 +180,14 @@ struct xe_tile {
>  
>  	/** @sysfs: sysfs' kobj used by xe_tile_sysfs */
>  	struct kobject *sysfs;
> +
> +	/** @drv_err_cnt: driver error counter for this tile */
> +	u32 drv_err_cnt[XE_TILE_DRV_ERR_MAX];
>  };
>  
> +void xe_tile_cnt_drv_err(struct xe_tile *tile,
> +			 const enum xe_tile_err_type err);

this _types.h header, no forward decls here, please
move it to xe_device.h

> +
>  /**
>   * struct xe_device - Top level struct of XE device
>   */
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index 1aa44d4f9ac1..61e4d0222836 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -47,6 +47,30 @@
>  #include "xe_wa.h"
>  #include "xe_wopcm.h"
>  
> +static const char *const xe_gt_drv_err_to_str[] = {
> +	[XE_GT_DRV_ERR_ENGINE] = "ENGINE OTHER",
> +	[XE_GT_DRV_ERR_OTHERS] = "GT OTHER"

nit: bkm is to have trailing , to minimize diff once we add new item ;)

nit: why all names are upper-case ?

hmm, and starting only with "other" items does not sound promising, are
there no specific class of errors that we want to show?

> +};

and this whole table seems to be unused in this patch

> +
> +/**
> + * xe_gt_cnt_drv_err - Count driver err for gt

maybe xe_gt_report_driver_error() will be a better name?

from coding-style.rst

" If you have a function that counts the number of active users, you
should call that ``count_active_users()`` or similar, you should **not**
call it ``cntusr()``. "

> + * @gt: GT to count error for
> + * @err: enum error type
> + *
> + * Increment the driver error counter in respective error
> + * category for this GT.
> + *
> + * Returns void.
> + */
> +void xe_gt_cnt_drv_err(struct xe_gt *gt,
> +		       const enum xe_gt_err_type err)
> +{
> +	if (err >= ARRAY_SIZE(gt->drv_err_cnt))
> +		return;

with correctly defined enums that wouldn't be possible ;)

and since this is only possible due to our coding mistake, we should use
xe_gt_assert() here rather then silently ignore the problem

> +	WRITE_ONCE(gt->drv_err_cnt[err],
> +		   READ_ONCE(gt->drv_err_cnt[err]) + 1);

maybe there is already some helper that inc given counter ?

> +}
> +
>  struct xe_gt *xe_gt_alloc(struct xe_tile *tile)
>  {
>  	struct xe_gt *gt;
> diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> index d4310be3e1e7..cb71aff16a0b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> @@ -24,6 +24,12 @@ enum xe_gt_type {
>  	XE_GT_TYPE_MEDIA,
>  };
>  
> +enum xe_gt_err_type {
> +	XE_GT_DRV_ERR_ENGINE = 0,
> +	XE_GT_DRV_ERR_OTHERS,
> +	XE_GT_DRV_ERR_MAX

ditto

> +};
> +
>  #define XE_MAX_DSS_FUSE_REGS	3
>  #define XE_MAX_EU_FUSE_REGS	1
>  
> @@ -347,6 +353,12 @@ struct xe_gt {
>  		/** @oob: bitmap with active OOB workaroudns */
>  		unsigned long *oob;
>  	} wa_active;
> +
> +	/** @drv_err_cnt: driver error counter for this GT */
> +	u32 drv_err_cnt[XE_GT_DRV_ERR_MAX];
>  };
>  
> +void xe_gt_cnt_drv_err(struct xe_gt *gt,
> +		       const enum xe_gt_err_type err);

wrong header, move it to xe_gt.h

> +
>  #endif
> diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c
> index 131752a57f65..c6dfcb4431f0 100644
> --- a/drivers/gpu/drm/xe/xe_tile.c
> +++ b/drivers/gpu/drm/xe/xe_tile.c
> @@ -71,6 +71,31 @@
>   *  - MOCS and PAT programming
>   */
>  
> +static const char *const xe_tile_drv_err_to_str[] = {
> +	[XE_TILE_DRV_ERR_GGTT] = "GGTT",
> +	[XE_TILE_DRV_ERR_GUC_COMM] = "GUC COMMUNICATION",
> +	[XE_TILE_DRV_ERR_INTR] = "INTERRUPT"
> +};

ditto

> +
> +/**
> + * xe_tile_cnt_drv_err - Count driver err for tile

maybe xe_tile_report_driver_error() will be a better name?

> + * @tile: Tile to count error for
> + * @err: enum error type
> + *
> + * Increment the driver error counter in respective error
> + * category for this tile.
> + *
> + * Returns void.
> + */
> +void xe_tile_cnt_drv_err(struct xe_tile *tile,
> +			 const enum xe_tile_err_type err)
> +{
> +	if (err >= ARRAY_SIZE(tile->drv_err_cnt))
> +		return;

ditto

> +	WRITE_ONCE(tile->drv_err_cnt[err],
> +		   READ_ONCE(tile->drv_err_cnt[err]) + 1);
> +}
> +
>  /**
>   * xe_tile_alloc - Perform per-tile memory allocation
>   * @tile: Tile to perform allocations for

  reply	other threads:[~2023-09-21  6:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21  6:03 [Intel-xe] [PATCH 0/2] drm/xe: Count and report low level driver errors Tejas Upadhyay
2023-09-21  5:58 ` [Intel-xe] ✓ CI.Patch_applied: success for " Patchwork
2023-09-21  5:58 ` [Intel-xe] ✓ CI.checkpatch: " Patchwork
2023-09-21  5:59 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-09-21  6:03 ` [Intel-xe] [PATCH 1/2] drm/xe: Indroduce low level driver error counting APIs Tejas Upadhyay
2023-09-21  6:44   ` Michal Wajdeczko [this message]
2023-09-25 10:24     ` Upadhyay, Tejas
2023-09-21  6:03 ` [Intel-xe] [PATCH 2/2] drm/xe: Update counter for low level driver errors Tejas Upadhyay
2023-09-21  6:06 ` [Intel-xe] ✓ CI.Build: success for drm/xe: Count and report " Patchwork
2023-09-21  6:07 ` [Intel-xe] ✗ CI.Hooks: failure " Patchwork
2023-09-21  6:08 ` [Intel-xe] ✓ CI.checksparse: success " Patchwork
2023-09-21  6:41 ` [Intel-xe] ✓ CI.BAT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db2ee607-2f4e-b7b5-9bf7-b306eea198f0@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=tejas.upadhyay@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox