Skip to content

Commit 18778b5

Browse files
committed
drm/xe: Eliminate usage of TIMESTAMP_OVERRIDE
Recent discussions with the hardware architects have revealed that the TIMESTAMP_OVERRIDE register is never expected to hold a valid/useful value on production hardware. That register would only get used by hardware workarounds (although there are none that use it today) or during early internal hardware testing. Due to lack of documentation it's not clear exactly what the driver should be doing if CTC_MODE[0] is set (or even whether that's a setting that would ever be encountered on real hardware), but it's definitely not what Xe and i915 have been doing. So drop the incorrect code trying to use TIMESTAMP_REGISTER. If the driver does encounter CTC_MODE[0] in the wild, we'll print a warning and just continue trying to use the crystal clock frequency since that's probably less incorrect than what we're doing today. Cc: Lucas De Marchi <[email protected]> Cc: Balasubramani Vivekanandan <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Matt Roper <[email protected]>
1 parent a33c969 commit 18778b5

File tree

3 files changed

+23
-43
lines changed

3 files changed

+23
-43
lines changed

drivers/gpu/drm/xe/regs/xe_regs.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
#include "regs/xe_reg_defs.h"
99

10-
#define TIMESTAMP_OVERRIDE XE_REG(0x44074)
11-
#define TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK REG_GENMASK(15, 12)
12-
#define TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK REG_GENMASK(9, 0)
13-
1410
#define GU_CNTL_PROTECTED XE_REG(0x10100C)
1511
#define DRIVERINT_FLR_DIS REG_BIT(31)
1612

drivers/gpu/drm/xe/xe_gt_clock.c

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,10 @@
1212
#include "xe_assert.h"
1313
#include "xe_device.h"
1414
#include "xe_gt.h"
15+
#include "xe_gt_printk.h"
1516
#include "xe_macros.h"
1617
#include "xe_mmio.h"
1718

18-
static u32 read_reference_ts_freq(struct xe_gt *gt)
19-
{
20-
u32 ts_override = xe_mmio_read32(&gt->mmio, TIMESTAMP_OVERRIDE);
21-
u32 base_freq, frac_freq;
22-
23-
base_freq = REG_FIELD_GET(TIMESTAMP_OVERRIDE_US_COUNTER_DIVIDER_MASK,
24-
ts_override) + 1;
25-
base_freq *= 1000000;
26-
27-
frac_freq = REG_FIELD_GET(TIMESTAMP_OVERRIDE_US_COUNTER_DENOMINATOR_MASK,
28-
ts_override);
29-
frac_freq = 1000000 / (frac_freq + 1);
30-
31-
return base_freq + frac_freq;
32-
}
33-
3419
static u32 get_crystal_clock_freq(u32 rpm_config_reg)
3520
{
3621
const u32 f19_2_mhz = 19200000;
@@ -57,26 +42,30 @@ static u32 get_crystal_clock_freq(u32 rpm_config_reg)
5742

5843
int xe_gt_clock_init(struct xe_gt *gt)
5944
{
60-
u32 ctc_reg = xe_mmio_read32(&gt->mmio, CTC_MODE);
45+
u32 c0 = xe_mmio_read32(&gt->mmio, RPM_CONFIG0);
6146
u32 freq = 0;
6247

63-
/* Assuming gen11+ so assert this assumption is correct */
64-
xe_gt_assert(gt, GRAPHICS_VER(gt_to_xe(gt)) >= 11);
65-
66-
if (ctc_reg & CTC_SOURCE_DIVIDE_LOGIC) {
67-
freq = read_reference_ts_freq(gt);
68-
} else {
69-
u32 c0 = xe_mmio_read32(&gt->mmio, RPM_CONFIG0);
70-
71-
freq = get_crystal_clock_freq(c0);
72-
73-
/*
74-
* Now figure out how the command stream's timestamp
75-
* register increments from this frequency (it might
76-
* increment only every few clock cycle).
77-
*/
78-
freq >>= 3 - REG_FIELD_GET(RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK, c0);
79-
}
48+
/*
49+
* CTC_MODE[0] = 1 is definitely not supported for Xe2 and later
50+
* platforms. In theory it could be a valid setting for pre-Xe2
51+
* platforms, but there's no documentation on how to properly handle
52+
* this case. Reading TIMESTAMP_OVERRIDE, as the driver attempted in
53+
* the past has been confirmed as incorrect by the hardware architects.
54+
*
55+
* For now just warn if we ever encounter hardware in the wild that
56+
* has this setting and move on as if it hadn't been set.
57+
*/
58+
if (xe_mmio_read32(&gt->mmio, CTC_MODE) & CTC_SOURCE_DIVIDE_LOGIC)
59+
xe_gt_warn(gt, "CTC_MODE[0] is set; this is unexpected and undocumented\n");
60+
61+
freq = get_crystal_clock_freq(c0);
62+
63+
/*
64+
* Now figure out how the command stream's timestamp
65+
* register increments from this frequency (it might
66+
* increment only every few clock cycle).
67+
*/
68+
freq >>= 3 - REG_FIELD_GET(RPM_CONFIG0_CTC_SHIFT_PARAMETER_MASK, c0);
8069

8170
gt->info.reference_clock = freq;
8271
return 0;

drivers/gpu/drm/xe/xe_gt_sriov_pf_service.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ static const struct xe_reg tgl_runtime_regs[] = {
114114
GT_VEBOX_VDBOX_DISABLE, /* _MMIO(0x9140) */
115115
CTC_MODE, /* _MMIO(0xa26c) */
116116
HUC_KERNEL_LOAD_INFO, /* _MMIO(0xc1dc) */
117-
TIMESTAMP_OVERRIDE, /* _MMIO(0x44074) */
118117
};
119118

120119
static const struct xe_reg ats_m_runtime_regs[] = {
@@ -127,7 +126,6 @@ static const struct xe_reg ats_m_runtime_regs[] = {
127126
XEHP_GT_COMPUTE_DSS_ENABLE, /* _MMIO(0x9144) */
128127
CTC_MODE, /* _MMIO(0xa26c) */
129128
HUC_KERNEL_LOAD_INFO, /* _MMIO(0xc1dc) */
130-
TIMESTAMP_OVERRIDE, /* _MMIO(0x44074) */
131129
};
132130

133131
static const struct xe_reg pvc_runtime_regs[] = {
@@ -140,7 +138,6 @@ static const struct xe_reg pvc_runtime_regs[] = {
140138
XEHPC_GT_COMPUTE_DSS_ENABLE_EXT,/* _MMIO(0x9148) */
141139
CTC_MODE, /* _MMIO(0xA26C) */
142140
HUC_KERNEL_LOAD_INFO, /* _MMIO(0xc1dc) */
143-
TIMESTAMP_OVERRIDE, /* _MMIO(0x44074) */
144141
};
145142

146143
static const struct xe_reg ver_1270_runtime_regs[] = {
@@ -155,7 +152,6 @@ static const struct xe_reg ver_1270_runtime_regs[] = {
155152
XEHPC_GT_COMPUTE_DSS_ENABLE_EXT,/* _MMIO(0x9148) */
156153
CTC_MODE, /* _MMIO(0xa26c) */
157154
HUC_KERNEL_LOAD_INFO, /* _MMIO(0xc1dc) */
158-
TIMESTAMP_OVERRIDE, /* _MMIO(0x44074) */
159155
};
160156

161157
static const struct xe_reg ver_2000_runtime_regs[] = {
@@ -173,7 +169,6 @@ static const struct xe_reg ver_2000_runtime_regs[] = {
173169
XE2_GT_GEOMETRY_DSS_2, /* _MMIO(0x9154) */
174170
CTC_MODE, /* _MMIO(0xa26c) */
175171
HUC_KERNEL_LOAD_INFO, /* _MMIO(0xc1dc) */
176-
TIMESTAMP_OVERRIDE, /* _MMIO(0x44074) */
177172
};
178173

179174
static const struct xe_reg ver_3000_runtime_regs[] = {

0 commit comments

Comments
 (0)