Re: [PATCH v2 04/22] drm/xe/log: Add component/location decorations to dmesg

Rodrigo Vivi <[email protected]>
Newsgroups org.freedesktop.lists.intel-xe
Message-ID <[email protected]>
On Tue, Jul 28, 2026 at 06:10:19PM +0200, Michal Wajdeczko wrote:
> While we can't directly use our xe_tile|gt_err|info helpers to get
> nice Tile/GT decorations, we can still add them manually based on
> the structured location parameter. Similarly, we can add component
> name prefix based on the component identifier.

Okay, perhaps I was wrong and these levels are indeed useful info there.

Reviewed-by: Rodrigo Vivi <[email protected]>

> 
> Signed-off-by: Michal Wajdeczko <[email protected]>
> Cc: Rodrigo Vivi <[email protected]>
> ---
> Cc: Aravind Iddamsetty <[email protected]>
> Cc: Mallesh Koujalagi <[email protected]>
> ---
>  drivers/gpu/drm/xe/xe_log.c | 82 +++++++++++++++++++++++++++++++++----
>  1 file changed, 74 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c
> index 70a41bdf1a01..a4f4f2d4e250 100644
> --- a/drivers/gpu/drm/xe/xe_log.c
> +++ b/drivers/gpu/drm/xe/xe_log.c
> @@ -3,6 +3,9 @@
>   * Copyright © 2026 Intel Corporation
>   */
>  
> +#include "abi/xe_log_abi.h"
> +
> +#include "xe_device.h"
>  #include "xe_log.h"
>  #include "xe_printk.h"
>  
> @@ -13,6 +16,65 @@ static void log_emit_cper(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigi
>  	/* TODO */
>  }
>  
> +static const char *log_component_prefix(u32 component)
> +{
> +	switch (component) {
> +#define MAKE_XE_LOG_COMPONENT_CASE_PREFIX(_CLASS, _ID, _TAG, _SIG, _NAME) \
> +	case XE_LOG_COMPONENT_##_TAG: return #_TAG ": ";
> +	DEFINE_XE_LOG_COMPONENTS(MAKE_XE_LOG_COMPONENT_CASE_PREFIX)
> +#undef MAKE_XE_LOG_COMPONENT_CASE_PREFIX
> +	}
> +	return "";
> +}
> +
> +static struct xe_gt *get_gt_safe(struct pci_dev *pdev, u8 id)
> +{
> +	struct xe_device *xe = pdev_to_xe_device(pdev);
> +
> +	return xe ? xe_device_get_gt(xe, id) : NULL;
> +}
> +
> +static struct xe_tile *get_tile_safe(struct pci_dev *pdev, u8 id)
> +{
> +	struct xe_device *xe = pdev_to_xe_device(pdev);
> +
> +	return xe && id < XE_MAX_TILES_PER_DEVICE ? &xe->tiles[id] : NULL;
> +}
> +
> +static const char *log_location_prefix(struct pci_dev *pdev, u32 location, char *buf, size_t size)
> +{
> +	u32 type = FIELD_GET(XE_LOG_LOCATION_TYPE_MASK, location);
> +	u32 id = FIELD_GET(XE_LOG_LOCATION_ID_MASK, location);
> +
> +	if (!location || type == XE_LOG_LOCATION_TYPE_DEVICE) {
> +		if (id)
> +			goto unrecognized;
> +		strscpy(buf, "", size);
> +	} else if (type == XE_LOG_LOCATION_TYPE_TILE) {
> +		struct xe_tile *tile = get_tile_safe(pdev, id);
> +
> +		if (!tile)
> +			goto unrecognized;
> +		snprintf(buf, size, "Tile%u: ", id);
> +	} else if (type == XE_LOG_LOCATION_TYPE_GT) {
> +		struct xe_gt *gt = get_gt_safe(pdev, id);
> +
> +		if (!gt)
> +			goto unrecognized;
> +		snprintf(buf, size, "Tile%u: GT%u: ", gt->tile->id, id);
> +	} else {
> +		goto unrecognized;
> +	}
> +
> +	return buf;
> +
> +unrecognized:
> +	pci_WARN(pdev, IS_ENABLED(CONFIG_DRM_XE_DEBUG),
> +		 "LOG: malformed location %#x\n", location);
> +	snprintf(buf, size, "LOC%u? ID%u? ", type, id);
> +	return buf;
> +}
> +
>  static bool is_hw_sigid(enum xe_sigid sigid)
>  {
>  	return (int)sigid >= INTEL_SIGID_GPU_XE_HARDWARE_START;
> @@ -71,20 +133,24 @@ static void log_emit_dmesg(struct pci_dev *pdev, int cper_sev, enum xe_sigid sig
>  			   u32 component, u32 location, const void *data, size_t len,
>  			   struct va_format *vaf)
>  {
> +	char buf[32];
> +	const char *loc_prefix = log_location_prefix(pdev, location, buf, sizeof(buf));
> +	const char *comp_prefix = log_component_prefix(component);
>  	const char *hwe_prefix = log_hwe_prefix(cper_sev, sigid);
>  	const char *sev_prefix = log_sev_prefix(cper_sev);
>  
> -	/* TODO: add component/location details */
> -
>  	if (IS_ERR(data))
> -		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%pV",
> -				 sigid, sev_prefix, data, hwe_prefix, vaf);
> +		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%pe) %s%s%s%pV",
> +				 sigid, sev_prefix, data, hwe_prefix,
> +				 loc_prefix, comp_prefix, vaf);
>  	else if (data && len)
> -		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%pV",
> -				 sigid, sev_prefix, (int)len, data, hwe_prefix, vaf);
> +		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s(%*phN) %s%s%s%pV",
> +				 sigid, sev_prefix, (int)len, data, hwe_prefix,
> +				 loc_prefix, comp_prefix, vaf);
>  	else
> -		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%pV",
> -				 sigid, sev_prefix, hwe_prefix, vaf);
> +		log_dmesg_printf(pdev, cper_sev, "SIGID=%u %s%s%s%s%pV",
> +				 sigid, sev_prefix, hwe_prefix,
> +				 loc_prefix, comp_prefix, vaf);
>  }
>  
>  /**
> -- 
> 2.47.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.