summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/xe/xe_log.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/gpu/drm/xe/xe_log.c b/drivers/gpu/drm/xe/xe_log.c
index 5549ef6966fd..29eb16db3320 100644
--- a/drivers/gpu/drm/xe/xe_log.c
+++ b/drivers/gpu/drm/xe/xe_log.c
@@ -10,6 +10,7 @@
#include "xe_device.h"
#include "xe_log.h"
+#include "xe_pci_types.h"
#include "xe_printk.h"
static void log_emit_cper(struct pci_dev *pdev, int cper_sev, enum xe_sigid sigid,
@@ -52,18 +53,24 @@ static const char *log_component_prefix(u32 component)
return component ? log_unknown_component_prefix(component) : "";
}
-static struct xe_gt *get_gt_safe(struct pci_dev *pdev, u8 id)
+static bool allowed_tile_id(struct xe_device *xe, u8 tile_id)
{
- struct xe_device *xe = pdev_to_xe_device(pdev);
+ return tile_id < 1 + xe->desc->max_remote_tiles;
+}
- return xe ? xe_device_get_gt(xe, id) : NULL;
+static bool allowed_gt_id(struct xe_device *xe, u8 gt_id)
+{
+ return gt_id < (1 + xe->desc->max_remote_tiles) * xe->desc->max_gt_per_tile;
}
-static struct xe_tile *get_tile_safe(struct pci_dev *pdev, u8 id)
+static u8 gt_id_to_tile_id(struct xe_device *xe, u8 gt_id)
{
- struct xe_device *xe = pdev_to_xe_device(pdev);
+ return gt_id / xe->desc->max_gt_per_tile;
+}
- return xe && id < xe->info.tile_count ? &xe->tiles[id] : NULL;
+static const char *location_suffix(bool valid)
+{
+ return valid ? ":" : "?";
}
static const char *log_location_prefix(struct pci_dev *pdev, u32 location, char *buf, size_t size)
@@ -76,17 +83,22 @@ static const char *log_location_prefix(struct pci_dev *pdev, u32 location, char
goto unrecognized;
strscpy(buf, "", size);
} else if (type == XE_LOG_LOCATION_TYPE_TILE) {
- struct xe_tile *tile = get_tile_safe(pdev, id);
+ struct xe_device *xe = xe_any_to_xe(pdev);
+ bool valid = xe ? allowed_tile_id(xe, id) : false;
+ const char *pad = location_suffix(valid);
- if (!tile)
- goto unrecognized;
- snprintf(buf, size, "Tile%u: ", id);
+ pci_WARN(pdev, !valid && IS_ENABLED(CONFIG_DRM_XE_DEBUG),
+ "LOG: invalid tile identifier: %u\n", id);
+ snprintf(buf, size, "Tile%u%s ", id, pad);
} 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);
+ struct xe_device *xe = xe_any_to_xe(pdev);
+ bool valid = xe ? allowed_gt_id(xe, id) : false;
+ const char *pad = location_suffix(valid);
+ u8 tile_id = xe ? gt_id_to_tile_id(xe, id) : 0;
+
+ pci_WARN(pdev, !valid && IS_ENABLED(CONFIG_DRM_XE_DEBUG),
+ "LOG: invalid GT identifier: %u\n", id);
+ snprintf(buf, size, "Tile%u%s GT%u%s ", tile_id, pad, id, pad);
} else {
goto unrecognized;
}