Skip to content

Commit 4495816

Browse files
zhanjunThomas Hellström
authored andcommitted
drm/xe/guc: Fix missing init value and add register order check
Fix missing initial value for last_value. For GuC capture register definition, it is required to define 64bit register in a pair of 2 consecutive 32bit register entries, low first, then hi. Add code to check this order. Changes from prior revs: v5:- Correct cross-line comment format v4:- Fix warn on condition and remove skipping v3:- Move break inside brace v2:- Correct the fix tag pointed commit Add examples in comments for warning Add 1 missing hi condition check Fixes: ecb6336 ("drm/xe/guc: Plumb GuC-capture into dev coredump") Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241126201052.1937079-1-zhanjun.dong@intel.com (cherry picked from commit 6f59fbc) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 40384c8 commit 4495816

File tree

1 file changed

+62
-15
lines changed

1 file changed

+62
-15
lines changed

drivers/gpu/drm/xe/xe_guc_capture.c

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct __guc_capture_parsed_output {
102102
* A 64 bit register define requires 2 consecutive entries,
103103
* with low dword first and hi dword the second.
104104
* 2. Register name: null for incompleted define
105+
* 3. Incorrect order will trigger XE_WARN.
105106
*/
106107
#define COMMON_XELP_BASE_GLOBAL \
107108
{ FORCEWAKE_GT, REG_32BIT, 0, 0, "FORCEWAKE_GT"}
@@ -1675,10 +1676,10 @@ snapshot_print_by_list_order(struct xe_hw_engine_snapshot *snapshot, struct drm_
16751676
struct xe_devcoredump *devcoredump = &xe->devcoredump;
16761677
struct xe_devcoredump_snapshot *devcore_snapshot = &devcoredump->snapshot;
16771678
struct gcap_reg_list_info *reginfo = NULL;
1678-
u32 last_value, i;
1679-
bool is_ext;
1679+
u32 i, last_value = 0;
1680+
bool is_ext, low32_ready = false;
16801681

1681-
if (!list || list->num_regs == 0)
1682+
if (!list || !list->list || list->num_regs == 0)
16821683
return;
16831684
XE_WARN_ON(!devcore_snapshot->matched_node);
16841685

@@ -1701,29 +1702,75 @@ snapshot_print_by_list_order(struct xe_hw_engine_snapshot *snapshot, struct drm_
17011702
continue;
17021703

17031704
value = reg->value;
1704-
if (reg_desc->data_type == REG_64BIT_LOW_DW) {
1705+
switch (reg_desc->data_type) {
1706+
case REG_64BIT_LOW_DW:
17051707
last_value = value;
1708+
1709+
/*
1710+
* A 64 bit register define requires 2 consecutive
1711+
* entries in register list, with low dword first
1712+
* and hi dword the second, like:
1713+
* { XXX_REG_LO(0), REG_64BIT_LOW_DW, 0, 0, NULL},
1714+
* { XXX_REG_HI(0), REG_64BIT_HI_DW, 0, 0, "XXX_REG"},
1715+
*
1716+
* Incorrect order will trigger XE_WARN.
1717+
*
1718+
* Possible double low here, for example:
1719+
* { XXX_REG_LO(0), REG_64BIT_LOW_DW, 0, 0, NULL},
1720+
* { XXX_REG_LO(0), REG_64BIT_LOW_DW, 0, 0, NULL},
1721+
*/
1722+
XE_WARN_ON(low32_ready);
1723+
low32_ready = true;
17061724
/* Low 32 bit dword saved, continue for high 32 bit */
1707-
continue;
1708-
} else if (reg_desc->data_type == REG_64BIT_HI_DW) {
1725+
break;
1726+
1727+
case REG_64BIT_HI_DW: {
17091728
u64 value_qw = ((u64)value << 32) | last_value;
17101729

1730+
/*
1731+
* Incorrect 64bit register order. Possible missing low.
1732+
* for example:
1733+
* { XXX_REG(0), REG_32BIT, 0, 0, NULL},
1734+
* { XXX_REG_HI(0), REG_64BIT_HI_DW, 0, 0, NULL},
1735+
*/
1736+
XE_WARN_ON(!low32_ready);
1737+
low32_ready = false;
1738+
17111739
drm_printf(p, "\t%s: 0x%016llx\n", reg_desc->regname, value_qw);
1712-
continue;
1740+
break;
17131741
}
17141742

1715-
if (is_ext) {
1716-
int dss, group, instance;
1743+
case REG_32BIT:
1744+
/*
1745+
* Incorrect 64bit register order. Possible missing high.
1746+
* for example:
1747+
* { XXX_REG_LO(0), REG_64BIT_LOW_DW, 0, 0, NULL},
1748+
* { XXX_REG(0), REG_32BIT, 0, 0, "XXX_REG"},
1749+
*/
1750+
XE_WARN_ON(low32_ready);
1751+
1752+
if (is_ext) {
1753+
int dss, group, instance;
17171754

1718-
group = FIELD_GET(GUC_REGSET_STEERING_GROUP, reg_desc->flags);
1719-
instance = FIELD_GET(GUC_REGSET_STEERING_INSTANCE, reg_desc->flags);
1720-
dss = xe_gt_mcr_steering_info_to_dss_id(gt, group, instance);
1755+
group = FIELD_GET(GUC_REGSET_STEERING_GROUP, reg_desc->flags);
1756+
instance = FIELD_GET(GUC_REGSET_STEERING_INSTANCE, reg_desc->flags);
1757+
dss = xe_gt_mcr_steering_info_to_dss_id(gt, group, instance);
17211758

1722-
drm_printf(p, "\t%s[%u]: 0x%08x\n", reg_desc->regname, dss, value);
1723-
} else {
1724-
drm_printf(p, "\t%s: 0x%08x\n", reg_desc->regname, value);
1759+
drm_printf(p, "\t%s[%u]: 0x%08x\n", reg_desc->regname, dss, value);
1760+
} else {
1761+
drm_printf(p, "\t%s: 0x%08x\n", reg_desc->regname, value);
1762+
}
1763+
break;
17251764
}
17261765
}
1766+
1767+
/*
1768+
* Incorrect 64bit register order. Possible missing high.
1769+
* for example:
1770+
* { XXX_REG_LO(0), REG_64BIT_LOW_DW, 0, 0, NULL},
1771+
* } // <- Register list end
1772+
*/
1773+
XE_WARN_ON(low32_ready);
17271774
}
17281775

17291776
/**

0 commit comments

Comments
 (0)