Skip to content

Commit 3091bd4

Browse files
committed
drm/xe/pat: Consolidate PAT programming logic for pre-Xe2 and post-Xe2
Now that the PAT settings for the new special entries introduced by Xe2 are decided during early software init and left NULL on platforms they don't apply to, there's no need to keep separate programming functions for pre-Xe2 and post-Xe2 platforms. Consolidate down to a single pair of programming functions (mcr and non-mcr) that can be used on any platform. Reviewed-by: Tejas Upadhyay <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Matt Roper <[email protected]>
1 parent 564e1a8 commit 3091bd4

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

drivers/gpu/drm/xe/xe_pat.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,35 @@ u16 xe_pat_index_get_coh_mode(struct xe_device *xe, u16 pat_index)
163163
static void program_pat(struct xe_gt *gt, const struct xe_pat_table_entry table[],
164164
int n_entries)
165165
{
166+
struct xe_device *xe = gt_to_xe(gt);
167+
166168
for (int i = 0; i < n_entries; i++) {
167169
struct xe_reg reg = XE_REG(_PAT_INDEX(i));
168170

169171
xe_mmio_write32(&gt->mmio, reg, table[i].value);
170172
}
173+
174+
if (xe->pat.pat_ats)
175+
xe_mmio_write32(&gt->mmio, XE_REG(_PAT_ATS), xe->pat.pat_ats->value);
176+
if (xe->pat.pat_pta)
177+
xe_mmio_write32(&gt->mmio, XE_REG(_PAT_PTA), xe->pat.pat_pta->value);
171178
}
172179

173180
static void program_pat_mcr(struct xe_gt *gt, const struct xe_pat_table_entry table[],
174181
int n_entries)
175182
{
183+
struct xe_device *xe = gt_to_xe(gt);
184+
176185
for (int i = 0; i < n_entries; i++) {
177186
struct xe_reg_mcr reg_mcr = XE_REG_MCR(_PAT_INDEX(i));
178187

179188
xe_gt_mcr_multicast_write(gt, reg_mcr, table[i].value);
180189
}
190+
191+
if (xe->pat.pat_ats)
192+
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_ATS), xe->pat.pat_ats->value);
193+
if (xe->pat.pat_pta)
194+
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_PTA), xe->pat.pat_pta->value);
181195
}
182196

183197
static void xelp_dump(struct xe_gt *gt, struct drm_printer *p)
@@ -304,32 +318,6 @@ static const struct xe_pat_ops xelpg_pat_ops = {
304318
.dump = xelpg_dump,
305319
};
306320

307-
static void xe2lpg_program_pat(struct xe_gt *gt, const struct xe_pat_table_entry table[],
308-
int n_entries)
309-
{
310-
struct xe_device *xe = gt_to_xe(gt);
311-
312-
program_pat_mcr(gt, table, n_entries);
313-
314-
if (xe->pat.pat_ats)
315-
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_ATS), xe->pat.pat_ats->value);
316-
if (xe->pat.pat_pta)
317-
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_PTA), xe->pat.pat_pta->value);
318-
}
319-
320-
static void xe2lpm_program_pat(struct xe_gt *gt, const struct xe_pat_table_entry table[],
321-
int n_entries)
322-
{
323-
struct xe_device *xe = gt_to_xe(gt);
324-
325-
program_pat(gt, table, n_entries);
326-
327-
if (xe->pat.pat_ats)
328-
xe_mmio_write32(&gt->mmio, XE_REG(_PAT_ATS), xe->pat.pat_ats->value);
329-
if (xe->pat.pat_pta)
330-
xe_mmio_write32(&gt->mmio, XE_REG(_PAT_PTA), xe->pat.pat_pta->value);
331-
}
332-
333321
static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
334322
{
335323
struct xe_device *xe = gt_to_xe(gt);
@@ -382,8 +370,8 @@ static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
382370
}
383371

384372
static const struct xe_pat_ops xe2_pat_ops = {
385-
.program_graphics = xe2lpg_program_pat,
386-
.program_media = xe2lpm_program_pat,
373+
.program_graphics = program_pat_mcr,
374+
.program_media = program_pat,
387375
.dump = xe2_dump,
388376
};
389377

0 commit comments

Comments
 (0)