mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 17:12:50 -04:00
drm/xe/pat: Extract gt_pta_entry()
Avoid code duplication by extracting the logic for selection of the correct PAT_PTA entry for a GT into function gt_pta_entry() and using that function whenever necessary. Reviewed-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com> Link: https://patch.msgid.link/20260303-pat-gt_pta_entry-v1-1-0dee8e1e7bd9@intel.com Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
This commit is contained in:
@@ -311,10 +311,25 @@ u16 xe_pat_index_get_l3_policy(struct xe_device *xe, u16 pat_index)
|
||||
return REG_FIELD_GET(XE2_L3_POLICY, xe->pat.table[pat_index].value);
|
||||
}
|
||||
|
||||
static const struct xe_pat_table_entry *gt_pta_entry(struct xe_gt *gt)
|
||||
{
|
||||
struct xe_device *xe = gt_to_xe(gt);
|
||||
|
||||
if (xe_gt_is_main_type(gt))
|
||||
return xe->pat.pat_primary_pta;
|
||||
|
||||
if (xe_gt_is_media_type(gt))
|
||||
return xe->pat.pat_media_pta;
|
||||
|
||||
xe_assert(xe, false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void program_pat(struct xe_gt *gt, const struct xe_pat_table_entry table[],
|
||||
int n_entries)
|
||||
{
|
||||
struct xe_device *xe = gt_to_xe(gt);
|
||||
const struct xe_pat_table_entry *pta_entry = gt_pta_entry(gt);
|
||||
|
||||
for (int i = 0; i < n_entries; i++) {
|
||||
struct xe_reg reg = XE_REG(_PAT_INDEX(i));
|
||||
@@ -324,16 +339,16 @@ static void program_pat(struct xe_gt *gt, const struct xe_pat_table_entry table[
|
||||
|
||||
if (xe->pat.pat_ats)
|
||||
xe_mmio_write32(>->mmio, XE_REG(_PAT_ATS), xe->pat.pat_ats->value);
|
||||
if (xe->pat.pat_primary_pta && xe_gt_is_main_type(gt))
|
||||
xe_mmio_write32(>->mmio, XE_REG(_PAT_PTA), xe->pat.pat_primary_pta->value);
|
||||
if (xe->pat.pat_media_pta && xe_gt_is_media_type(gt))
|
||||
xe_mmio_write32(>->mmio, XE_REG(_PAT_PTA), xe->pat.pat_media_pta->value);
|
||||
|
||||
if (pta_entry)
|
||||
xe_mmio_write32(>->mmio, XE_REG(_PAT_PTA), pta_entry->value);
|
||||
}
|
||||
|
||||
static void program_pat_mcr(struct xe_gt *gt, const struct xe_pat_table_entry table[],
|
||||
int n_entries)
|
||||
{
|
||||
struct xe_device *xe = gt_to_xe(gt);
|
||||
const struct xe_pat_table_entry *pta_entry = gt_pta_entry(gt);
|
||||
|
||||
for (int i = 0; i < n_entries; i++) {
|
||||
struct xe_reg_mcr reg_mcr = XE_REG_MCR(_PAT_INDEX(i));
|
||||
@@ -343,10 +358,9 @@ static void program_pat_mcr(struct xe_gt *gt, const struct xe_pat_table_entry ta
|
||||
|
||||
if (xe->pat.pat_ats)
|
||||
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_ATS), xe->pat.pat_ats->value);
|
||||
if (xe->pat.pat_primary_pta && xe_gt_is_main_type(gt))
|
||||
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_PTA), xe->pat.pat_primary_pta->value);
|
||||
if (xe->pat.pat_media_pta && xe_gt_is_media_type(gt))
|
||||
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_PTA), xe->pat.pat_media_pta->value);
|
||||
|
||||
if (pta_entry)
|
||||
xe_gt_mcr_multicast_write(gt, XE_REG_MCR(_PAT_PTA), pta_entry->value);
|
||||
}
|
||||
|
||||
static int xelp_dump(struct xe_gt *gt, struct drm_printer *p)
|
||||
@@ -677,8 +691,7 @@ int xe_pat_dump(struct xe_gt *gt, struct drm_printer *p)
|
||||
int xe_pat_dump_sw_config(struct xe_gt *gt, struct drm_printer *p)
|
||||
{
|
||||
struct xe_device *xe = gt_to_xe(gt);
|
||||
const struct xe_pat_table_entry *pta_entry = xe_gt_is_main_type(gt) ?
|
||||
xe->pat.pat_primary_pta : xe->pat.pat_media_pta;
|
||||
const struct xe_pat_table_entry *pta_entry = gt_pta_entry(gt);
|
||||
char label[PAT_LABEL_LEN];
|
||||
|
||||
if (!xe->pat.table || !xe->pat.n_entries)
|
||||
|
||||
Reference in New Issue
Block a user