Skip to content

Commit ffab82b

Browse files
committed
drm/xe: Introduce xe_gt_is_main_type helper
Instead of checking for not being a media type GT provide a small helper to explicitly express our intentions. Signed-off-by: Michal Wajdeczko <[email protected]> Reviewed-by: Piotr Piórkowski <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 76293a8 commit ffab82b

File tree

10 files changed

+39
-34
lines changed

10 files changed

+39
-34
lines changed

drivers/gpu/drm/xe/xe_bb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static int bb_prefetch(struct xe_gt *gt)
1919
{
2020
struct xe_device *xe = gt_to_xe(gt);
2121

22-
if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
22+
if (GRAPHICS_VERx100(xe) >= 1250 && xe_gt_is_main_type(gt))
2323
/*
2424
* RCS and CCS require 1K, although other engines would be
2525
* okay with 512.

drivers/gpu/drm/xe/xe_force_wake.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void xe_force_wake_init_engines(struct xe_gt *gt, struct xe_force_wake *fw)
6464
{
6565
int i, j;
6666

67-
if (!xe_gt_is_media_type(gt))
67+
if (xe_gt_is_main_type(gt))
6868
init_domain(fw, XE_FW_DOMAIN_ID_RENDER,
6969
FORCEWAKE_RENDER,
7070
FORCEWAKE_ACK_RENDER);

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
112112
if (!fw_ref)
113113
return;
114114

115-
if (!xe_gt_is_media_type(gt)) {
115+
if (xe_gt_is_main_type(gt)) {
116116
reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMREQSTRM_CTRL);
117117
reg |= CG_DIS_CNTLBUS;
118118
xe_gt_mcr_multicast_write(gt, XE2_GAMREQSTRM_CTRL, reg);
@@ -470,7 +470,7 @@ static int gt_init_with_gt_forcewake(struct xe_gt *gt)
470470
xe_gt_mcr_init(gt);
471471
xe_gt_enable_host_l2_vram(gt);
472472

473-
if (!xe_gt_is_media_type(gt)) {
473+
if (xe_gt_is_main_type(gt)) {
474474
err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt);
475475
if (err)
476476
goto err_force_wake;
@@ -547,7 +547,7 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
547547
if (err)
548548
goto err_force_wake;
549549

550-
if (!xe_gt_is_media_type(gt)) {
550+
if (xe_gt_is_main_type(gt)) {
551551
/*
552552
* USM has its only SA pool to non-block behind user operations
553553
*/
@@ -563,7 +563,7 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
563563
}
564564
}
565565

566-
if (!xe_gt_is_media_type(gt)) {
566+
if (xe_gt_is_main_type(gt)) {
567567
struct xe_tile *tile = gt_to_tile(gt);
568568

569569
tile->migrate = xe_migrate_init(tile);
@@ -583,7 +583,7 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
583583
xe_gt_apply_ccs_mode(gt);
584584
}
585585

586-
if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt))
586+
if (IS_SRIOV_PF(gt_to_xe(gt)) && xe_gt_is_main_type(gt))
587587
xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt);
588588

589589
if (IS_SRIOV_PF(gt_to_xe(gt))) {
@@ -780,7 +780,7 @@ static int do_gt_restart(struct xe_gt *gt)
780780
if (err)
781781
return err;
782782

783-
if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt))
783+
if (IS_SRIOV_PF(gt_to_xe(gt)) && xe_gt_is_main_type(gt))
784784
xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt);
785785

786786
if (IS_SRIOV_PF(gt_to_xe(gt)))

drivers/gpu/drm/xe/xe_gt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ static inline bool xe_gt_has_indirect_ring_state(struct xe_gt *gt)
106106
xe_device_uc_enabled(gt_to_xe(gt));
107107
}
108108

109+
static inline bool xe_gt_is_main_type(struct xe_gt *gt)
110+
{
111+
return gt->info.type == XE_GT_TYPE_MAIN;
112+
}
113+
109114
static inline bool xe_gt_is_media_type(struct xe_gt *gt)
110115
{
111116
return gt->info.type == XE_GT_TYPE_MEDIA;

drivers/gpu/drm/xe/xe_gt_idle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void xe_gt_idle_enable_pg(struct xe_gt *gt)
121121
if (vcs_mask || vecs_mask)
122122
gtidle->powergate_enable = MEDIA_POWERGATE_ENABLE;
123123

124-
if (!xe_gt_is_media_type(gt))
124+
if (xe_gt_is_main_type(gt))
125125
gtidle->powergate_enable |= RENDER_POWERGATE_ENABLE;
126126

127127
if (xe->info.platform != XE_DG1) {

drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static u64 pf_get_spare_ggtt(struct xe_gt *gt)
376376
{
377377
u64 spare;
378378

379-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
379+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
380380
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
381381
lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
382382

@@ -388,7 +388,7 @@ static u64 pf_get_spare_ggtt(struct xe_gt *gt)
388388

389389
static int pf_set_spare_ggtt(struct xe_gt *gt, u64 size)
390390
{
391-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
391+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
392392
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
393393
lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
394394

@@ -443,7 +443,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
443443
int err;
444444

445445
xe_gt_assert(gt, vfid);
446-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
446+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
447447
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
448448

449449
size = round_up(size, alignment);
@@ -492,7 +492,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
492492
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
493493
struct xe_ggtt_node *node = config->ggtt_region;
494494

495-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
495+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
496496
return xe_ggtt_node_allocated(node) ? node->base.size : 0;
497497
}
498498

@@ -560,7 +560,7 @@ int xe_gt_sriov_pf_config_set_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size
560560
{
561561
int err;
562562

563-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
563+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
564564

565565
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
566566
if (vfid)
@@ -622,7 +622,7 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
622622
int err = 0;
623623

624624
xe_gt_assert(gt, vfid);
625-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
625+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
626626

627627
if (!num_vfs)
628628
return 0;
@@ -693,7 +693,7 @@ int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt, unsigned int vfid,
693693

694694
xe_gt_assert(gt, vfid);
695695
xe_gt_assert(gt, num_vfs);
696-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
696+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
697697

698698
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
699699
fair = pf_estimate_fair_ggtt(gt, num_vfs);
@@ -1406,7 +1406,7 @@ static int pf_update_vf_lmtt(struct xe_device *xe, unsigned int vfid)
14061406
static void pf_release_vf_config_lmem(struct xe_gt *gt, struct xe_gt_sriov_config *config)
14071407
{
14081408
xe_gt_assert(gt, IS_DGFX(gt_to_xe(gt)));
1409-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
1409+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
14101410
lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
14111411

14121412
if (config->lmem_obj) {
@@ -1425,7 +1425,7 @@ static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
14251425

14261426
xe_gt_assert(gt, vfid);
14271427
xe_gt_assert(gt, IS_DGFX(xe));
1428-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
1428+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
14291429

14301430
size = round_up(size, pf_get_lmem_alignment(gt));
14311431

@@ -1552,7 +1552,7 @@ int xe_gt_sriov_pf_config_bulk_set_lmem(struct xe_gt *gt, unsigned int vfid,
15521552
int err = 0;
15531553

15541554
xe_gt_assert(gt, vfid);
1555-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
1555+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
15561556

15571557
if (!num_vfs)
15581558
return 0;
@@ -1629,7 +1629,7 @@ int xe_gt_sriov_pf_config_set_fair_lmem(struct xe_gt *gt, unsigned int vfid,
16291629

16301630
xe_gt_assert(gt, vfid);
16311631
xe_gt_assert(gt, num_vfs);
1632-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
1632+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
16331633

16341634
if (!xe_device_has_lmtt(gt_to_xe(gt)))
16351635
return 0;
@@ -1663,7 +1663,7 @@ int xe_gt_sriov_pf_config_set_fair(struct xe_gt *gt, unsigned int vfid,
16631663
xe_gt_assert(gt, vfid);
16641664
xe_gt_assert(gt, num_vfs);
16651665

1666-
if (!xe_gt_is_media_type(gt)) {
1666+
if (xe_gt_is_main_type(gt)) {
16671667
err = xe_gt_sriov_pf_config_set_fair_ggtt(gt, vfid, num_vfs);
16681668
result = result ?: err;
16691669
err = xe_gt_sriov_pf_config_set_fair_lmem(gt, vfid, num_vfs);
@@ -1991,7 +1991,7 @@ static void pf_release_vf_config(struct xe_gt *gt, unsigned int vfid)
19911991
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
19921992
struct xe_device *xe = gt_to_xe(gt);
19931993

1994-
if (!xe_gt_is_media_type(gt)) {
1994+
if (xe_gt_is_main_type(gt)) {
19951995
pf_release_vf_config_ggtt(gt, config);
19961996
if (IS_DGFX(xe)) {
19971997
pf_release_vf_config_lmem(gt, config);
@@ -2082,7 +2082,7 @@ static int pf_sanitize_vf_resources(struct xe_gt *gt, u32 vfid, long timeout)
20822082
* Only GGTT and LMEM requires to be cleared by the PF.
20832083
* GuC doorbell IDs and context IDs do not need any clearing.
20842084
*/
2085-
if (!xe_gt_is_media_type(gt)) {
2085+
if (xe_gt_is_main_type(gt)) {
20862086
pf_sanitize_ggtt(config->ggtt_region, vfid);
20872087
if (IS_DGFX(xe))
20882088
err = pf_sanitize_lmem(tile, config->lmem_obj, timeout);
@@ -2149,7 +2149,7 @@ static int pf_validate_vf_config(struct xe_gt *gt, unsigned int vfid)
21492149
{
21502150
struct xe_gt *primary_gt = gt_to_tile(gt)->primary_gt;
21512151
struct xe_device *xe = gt_to_xe(gt);
2152-
bool is_primary = !xe_gt_is_media_type(gt);
2152+
bool is_primary = xe_gt_is_main_type(gt);
21532153
bool valid_ggtt, valid_ctxs, valid_dbs;
21542154
bool valid_any, valid_all;
21552155

drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigne
305305
xe_gt_assert(gt, gt == extract_gt(parent));
306306
xe_gt_assert(gt, vfid == extract_vfid(parent));
307307

308-
if (!xe_gt_is_media_type(gt)) {
308+
if (xe_gt_is_main_type(gt)) {
309309
debugfs_create_file_unsafe(vfid ? "ggtt_quota" : "ggtt_spare",
310310
0644, parent, parent, &ggtt_fops);
311311
if (xe_device_has_lmtt(gt_to_xe(gt)))
@@ -554,7 +554,7 @@ void xe_gt_sriov_pf_debugfs_register(struct xe_gt *gt, struct dentry *root)
554554
pfdentry->d_inode->i_private = gt;
555555

556556
drm_debugfs_create_files(pf_info, ARRAY_SIZE(pf_info), pfdentry, minor);
557-
if (!xe_gt_is_media_type(gt)) {
557+
if (xe_gt_is_main_type(gt)) {
558558
drm_debugfs_create_files(pf_ggtt_info,
559559
ARRAY_SIZE(pf_ggtt_info),
560560
pfdentry, minor);

drivers/gpu/drm/xe/xe_gt_sriov_vf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ int xe_gt_sriov_vf_query_config(struct xe_gt *gt)
552552
if (unlikely(err))
553553
return err;
554554

555-
if (IS_DGFX(xe) && !xe_gt_is_media_type(gt)) {
555+
if (IS_DGFX(xe) && xe_gt_is_main_type(gt)) {
556556
err = vf_get_lmem_info(gt);
557557
if (unlikely(err))
558558
return err;
@@ -649,7 +649,7 @@ s64 xe_gt_sriov_vf_ggtt_shift(struct xe_gt *gt)
649649
struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config;
650650

651651
xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
652-
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
652+
xe_gt_assert(gt, xe_gt_is_main_type(gt));
653653

654654
return config->ggtt_shift;
655655
}
@@ -1036,7 +1036,7 @@ void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p)
10361036

10371037
drm_printf(p, "GGTT shift on last restore:\t%lld\n", config->ggtt_shift);
10381038

1039-
if (IS_DGFX(xe) && !xe_gt_is_media_type(gt)) {
1039+
if (IS_DGFX(xe) && xe_gt_is_main_type(gt)) {
10401040
string_get_size(config->lmem_size, 1, STRING_UNITS_2, buf, sizeof(buf));
10411041
drm_printf(p, "LMEM size:\t%llu (%s)\n", config->lmem_size, buf);
10421042
}

drivers/gpu/drm/xe/xe_irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void xe_irq_enable_hwe(struct xe_gt *gt)
162162
dmask = irqs << 16 | irqs;
163163
smask = irqs << 16;
164164

165-
if (!xe_gt_is_media_type(gt)) {
165+
if (xe_gt_is_main_type(gt)) {
166166
/* Enable interrupts for each engine class */
167167
xe_mmio_write32(mmio, RENDER_COPY_INTR_ENABLE, dmask);
168168
if (ccs_mask)
@@ -262,7 +262,7 @@ gt_engine_identity(struct xe_device *xe,
262262
static void
263263
gt_other_irq_handler(struct xe_gt *gt, const u8 instance, const u16 iir)
264264
{
265-
if (instance == OTHER_GUC_INSTANCE && !xe_gt_is_media_type(gt))
265+
if (instance == OTHER_GUC_INSTANCE && xe_gt_is_main_type(gt))
266266
return xe_guc_irq_handler(&gt->uc.guc, iir);
267267
if (instance == OTHER_MEDIA_GUC_INSTANCE && xe_gt_is_media_type(gt))
268268
return xe_guc_irq_handler(&gt->uc.guc, iir);

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,7 @@ int xe_oa_register(struct xe_device *xe)
24932493

24942494
static u32 num_oa_units_per_gt(struct xe_gt *gt)
24952495
{
2496-
if (!xe_gt_is_media_type(gt) || GRAPHICS_VER(gt_to_xe(gt)) < 20)
2496+
if (xe_gt_is_main_type(gt) || GRAPHICS_VER(gt_to_xe(gt)) < 20)
24972497
return 1;
24982498
else if (!IS_DGFX(gt_to_xe(gt)))
24992499
return XE_OAM_UNIT_SCMI_0 + 1; /* SAG + SCMI_0 */
@@ -2506,7 +2506,7 @@ static u32 __hwe_oam_unit(struct xe_hw_engine *hwe)
25062506
if (GRAPHICS_VERx100(gt_to_xe(hwe->gt)) < 1270)
25072507
return XE_OA_UNIT_INVALID;
25082508

2509-
xe_gt_WARN_ON(hwe->gt, !xe_gt_is_media_type(hwe->gt));
2509+
xe_gt_WARN_ON(hwe->gt, xe_gt_is_main_type(hwe->gt));
25102510

25112511
if (GRAPHICS_VER(gt_to_xe(hwe->gt)) < 20)
25122512
return 0;
@@ -2589,7 +2589,7 @@ static void __xe_oa_init_oa_units(struct xe_gt *gt)
25892589
for (i = 0; i < num_units; i++) {
25902590
struct xe_oa_unit *u = &gt->oa.oa_unit[i];
25912591

2592-
if (!xe_gt_is_media_type(gt)) {
2592+
if (xe_gt_is_main_type(gt)) {
25932593
u->regs = __oag_regs();
25942594
u->type = DRM_XE_OA_UNIT_TYPE_OAG;
25952595
} else {

0 commit comments

Comments
 (0)