]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Introduce xe_gt_is_main_type helper
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Sun, 13 Jul 2025 10:36:22 +0000 (12:36 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 14 Jul 2025 16:19:29 +0000 (18:19 +0200)
Instead of checking for not being a media type GT provide a small
helper to explicitly express our intentions.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://lore.kernel.org/r/20250713103625.1964-5-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_bb.c
drivers/gpu/drm/xe/xe_force_wake.c
drivers/gpu/drm/xe/xe_gt.c
drivers/gpu/drm/xe/xe_gt.h
drivers/gpu/drm/xe/xe_gt_idle.c
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
drivers/gpu/drm/xe/xe_gt_sriov_vf.c
drivers/gpu/drm/xe/xe_irq.c
drivers/gpu/drm/xe/xe_oa.c

index 9570672fce33a120843aad516db79eecd93aab59..5ce0e26822f2c4d8dff4a1ae3bb8acb26d5575d6 100644 (file)
@@ -19,7 +19,7 @@ static int bb_prefetch(struct xe_gt *gt)
 {
        struct xe_device *xe = gt_to_xe(gt);
 
-       if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
+       if (GRAPHICS_VERx100(xe) >= 1250 && xe_gt_is_main_type(gt))
                /*
                 * RCS and CCS require 1K, although other engines would be
                 * okay with 512.
index 8a5cba22b58610224b854e42b9431dcae174ac1c..c59a9b330697dff151294678e0ac18695d3cfa91 100644 (file)
@@ -64,7 +64,7 @@ void xe_force_wake_init_engines(struct xe_gt *gt, struct xe_force_wake *fw)
 {
        int i, j;
 
-       if (!xe_gt_is_media_type(gt))
+       if (xe_gt_is_main_type(gt))
                init_domain(fw, XE_FW_DOMAIN_ID_RENDER,
                            FORCEWAKE_RENDER,
                            FORCEWAKE_ACK_RENDER);
index af03e19ef9bef6850805bb135a26b070f4d820ab..9dad4f79328e3234dbe02946283506496881332a 100644 (file)
@@ -112,7 +112,7 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
        if (!fw_ref)
                return;
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMREQSTRM_CTRL);
                reg |= CG_DIS_CNTLBUS;
                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)
        xe_gt_mcr_init(gt);
        xe_gt_enable_host_l2_vram(gt);
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt);
                if (err)
                        goto err_force_wake;
@@ -547,7 +547,7 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
        if (err)
                goto err_force_wake;
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                /*
                 * USM has its only SA pool to non-block behind user operations
                 */
@@ -563,7 +563,7 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
                }
        }
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                struct xe_tile *tile = gt_to_tile(gt);
 
                tile->migrate = xe_migrate_init(tile);
@@ -583,7 +583,7 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
                xe_gt_apply_ccs_mode(gt);
        }
 
-       if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt))
+       if (IS_SRIOV_PF(gt_to_xe(gt)) && xe_gt_is_main_type(gt))
                xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt);
 
        if (IS_SRIOV_PF(gt_to_xe(gt))) {
@@ -780,7 +780,7 @@ static int do_gt_restart(struct xe_gt *gt)
        if (err)
                return err;
 
-       if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt))
+       if (IS_SRIOV_PF(gt_to_xe(gt)) && xe_gt_is_main_type(gt))
                xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt);
 
        if (IS_SRIOV_PF(gt_to_xe(gt)))
index 8128ddfdd7886310cd15d095f6ae99954d062e4e..e9ccab8aedbef11013bb8fae225b851f121439c7 100644 (file)
@@ -106,6 +106,11 @@ static inline bool xe_gt_has_indirect_ring_state(struct xe_gt *gt)
               xe_device_uc_enabled(gt_to_xe(gt));
 }
 
+static inline bool xe_gt_is_main_type(struct xe_gt *gt)
+{
+       return gt->info.type == XE_GT_TYPE_MAIN;
+}
+
 static inline bool xe_gt_is_media_type(struct xe_gt *gt)
 {
        return gt->info.type == XE_GT_TYPE_MEDIA;
index c11206410a4d4ead095aee24a61d177e4b76e58b..ffb210216aa99fcd4d459cbbaf69987e1d158382 100644 (file)
@@ -121,7 +121,7 @@ void xe_gt_idle_enable_pg(struct xe_gt *gt)
        if (vcs_mask || vecs_mask)
                gtidle->powergate_enable = MEDIA_POWERGATE_ENABLE;
 
-       if (!xe_gt_is_media_type(gt))
+       if (xe_gt_is_main_type(gt))
                gtidle->powergate_enable |= RENDER_POWERGATE_ENABLE;
 
        if (xe->info.platform != XE_DG1) {
index d0cf1d80be074bf3e32df19de06a63809e433949..9ba9dc7c4ee939e3591dcb45d9bfa89f7f7ff626 100644 (file)
@@ -376,7 +376,7 @@ static u64 pf_get_spare_ggtt(struct xe_gt *gt)
 {
        u64 spare;
 
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
        xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
        lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
 
@@ -388,7 +388,7 @@ static u64 pf_get_spare_ggtt(struct xe_gt *gt)
 
 static int pf_set_spare_ggtt(struct xe_gt *gt, u64 size)
 {
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
        xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
        lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
 
@@ -443,7 +443,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
        int err;
 
        xe_gt_assert(gt, vfid);
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
        xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
 
        size = round_up(size, alignment);
@@ -492,7 +492,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
        struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
        struct xe_ggtt_node *node = config->ggtt_region;
 
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
        return xe_ggtt_node_allocated(node) ? node->base.size : 0;
 }
 
@@ -560,7 +560,7 @@ int xe_gt_sriov_pf_config_set_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size
 {
        int err;
 
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
        if (vfid)
@@ -622,7 +622,7 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
        int err = 0;
 
        xe_gt_assert(gt, vfid);
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        if (!num_vfs)
                return 0;
@@ -693,7 +693,7 @@ int xe_gt_sriov_pf_config_set_fair_ggtt(struct xe_gt *gt, unsigned int vfid,
 
        xe_gt_assert(gt, vfid);
        xe_gt_assert(gt, num_vfs);
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
        fair = pf_estimate_fair_ggtt(gt, num_vfs);
@@ -1406,7 +1406,7 @@ fail:
 static void pf_release_vf_config_lmem(struct xe_gt *gt, struct xe_gt_sriov_config *config)
 {
        xe_gt_assert(gt, IS_DGFX(gt_to_xe(gt)));
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
        lockdep_assert_held(xe_gt_sriov_pf_master_mutex(gt));
 
        if (config->lmem_obj) {
@@ -1425,7 +1425,7 @@ static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
 
        xe_gt_assert(gt, vfid);
        xe_gt_assert(gt, IS_DGFX(xe));
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        size = round_up(size, pf_get_lmem_alignment(gt));
 
@@ -1552,7 +1552,7 @@ int xe_gt_sriov_pf_config_bulk_set_lmem(struct xe_gt *gt, unsigned int vfid,
        int err = 0;
 
        xe_gt_assert(gt, vfid);
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        if (!num_vfs)
                return 0;
@@ -1629,7 +1629,7 @@ int xe_gt_sriov_pf_config_set_fair_lmem(struct xe_gt *gt, unsigned int vfid,
 
        xe_gt_assert(gt, vfid);
        xe_gt_assert(gt, num_vfs);
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        if (!xe_device_has_lmtt(gt_to_xe(gt)))
                return 0;
@@ -1663,7 +1663,7 @@ int xe_gt_sriov_pf_config_set_fair(struct xe_gt *gt, unsigned int vfid,
        xe_gt_assert(gt, vfid);
        xe_gt_assert(gt, num_vfs);
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                err = xe_gt_sriov_pf_config_set_fair_ggtt(gt, vfid, num_vfs);
                result = result ?: err;
                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)
        struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
        struct xe_device *xe = gt_to_xe(gt);
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                pf_release_vf_config_ggtt(gt, config);
                if (IS_DGFX(xe)) {
                        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)
         * Only GGTT and LMEM requires to be cleared by the PF.
         * GuC doorbell IDs and context IDs do not need any clearing.
         */
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                pf_sanitize_ggtt(config->ggtt_region, vfid);
                if (IS_DGFX(xe))
                        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)
 {
        struct xe_gt *primary_gt = gt_to_tile(gt)->primary_gt;
        struct xe_device *xe = gt_to_xe(gt);
-       bool is_primary = !xe_gt_is_media_type(gt);
+       bool is_primary = xe_gt_is_main_type(gt);
        bool valid_ggtt, valid_ctxs, valid_dbs;
        bool valid_any, valid_all;
 
index 13970d5a2867dd5f10b139499e1efa0c2081cade..9b7772928d62203f3eb2534a823f480c75eeeeb0 100644 (file)
@@ -305,7 +305,7 @@ static void pf_add_config_attrs(struct xe_gt *gt, struct dentry *parent, unsigne
        xe_gt_assert(gt, gt == extract_gt(parent));
        xe_gt_assert(gt, vfid == extract_vfid(parent));
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                debugfs_create_file_unsafe(vfid ? "ggtt_quota" : "ggtt_spare",
                                           0644, parent, parent, &ggtt_fops);
                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)
        pfdentry->d_inode->i_private = gt;
 
        drm_debugfs_create_files(pf_info, ARRAY_SIZE(pf_info), pfdentry, minor);
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                drm_debugfs_create_files(pf_ggtt_info,
                                         ARRAY_SIZE(pf_ggtt_info),
                                         pfdentry, minor);
index 93cd26dca070fe812dc2405bf37ee6119f05338e..d65eafd91b179a2c3e507fa15822d72a6954f988 100644 (file)
@@ -552,7 +552,7 @@ int xe_gt_sriov_vf_query_config(struct xe_gt *gt)
        if (unlikely(err))
                return err;
 
-       if (IS_DGFX(xe) && !xe_gt_is_media_type(gt)) {
+       if (IS_DGFX(xe) && xe_gt_is_main_type(gt)) {
                err = vf_get_lmem_info(gt);
                if (unlikely(err))
                        return err;
@@ -649,7 +649,7 @@ s64 xe_gt_sriov_vf_ggtt_shift(struct xe_gt *gt)
        struct xe_gt_sriov_vf_selfconfig *config = &gt->sriov.vf.self_config;
 
        xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
-       xe_gt_assert(gt, !xe_gt_is_media_type(gt));
+       xe_gt_assert(gt, xe_gt_is_main_type(gt));
 
        return config->ggtt_shift;
 }
@@ -1036,7 +1036,7 @@ void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p)
 
        drm_printf(p, "GGTT shift on last restore:\t%lld\n", config->ggtt_shift);
 
-       if (IS_DGFX(xe) && !xe_gt_is_media_type(gt)) {
+       if (IS_DGFX(xe) && xe_gt_is_main_type(gt)) {
                string_get_size(config->lmem_size, 1, STRING_UNITS_2, buf, sizeof(buf));
                drm_printf(p, "LMEM size:\t%llu (%s)\n", config->lmem_size, buf);
        }
index cbb1850d0caba95566225c7465123a6707eb1858..5df5b8c2a3e4df74e17ff78f325ca37b8db72dae 100644 (file)
@@ -162,7 +162,7 @@ void xe_irq_enable_hwe(struct xe_gt *gt)
        dmask = irqs << 16 | irqs;
        smask = irqs << 16;
 
-       if (!xe_gt_is_media_type(gt)) {
+       if (xe_gt_is_main_type(gt)) {
                /* Enable interrupts for each engine class */
                xe_mmio_write32(mmio, RENDER_COPY_INTR_ENABLE, dmask);
                if (ccs_mask)
@@ -262,7 +262,7 @@ gt_engine_identity(struct xe_device *xe,
 static void
 gt_other_irq_handler(struct xe_gt *gt, const u8 instance, const u16 iir)
 {
-       if (instance == OTHER_GUC_INSTANCE && !xe_gt_is_media_type(gt))
+       if (instance == OTHER_GUC_INSTANCE && xe_gt_is_main_type(gt))
                return xe_guc_irq_handler(&gt->uc.guc, iir);
        if (instance == OTHER_MEDIA_GUC_INSTANCE && xe_gt_is_media_type(gt))
                return xe_guc_irq_handler(&gt->uc.guc, iir);
index a3379d39f76ddebb6031c8674f189c443393332c..d991fbd90f2017f7b68e115215cdd423de1e1e17 100644 (file)
@@ -2493,7 +2493,7 @@ int xe_oa_register(struct xe_device *xe)
 
 static u32 num_oa_units_per_gt(struct xe_gt *gt)
 {
-       if (!xe_gt_is_media_type(gt) || GRAPHICS_VER(gt_to_xe(gt)) < 20)
+       if (xe_gt_is_main_type(gt) || GRAPHICS_VER(gt_to_xe(gt)) < 20)
                return 1;
        else if (!IS_DGFX(gt_to_xe(gt)))
                return XE_OAM_UNIT_SCMI_0 + 1; /* SAG + SCMI_0 */
@@ -2506,7 +2506,7 @@ static u32 __hwe_oam_unit(struct xe_hw_engine *hwe)
        if (GRAPHICS_VERx100(gt_to_xe(hwe->gt)) < 1270)
                return XE_OA_UNIT_INVALID;
 
-       xe_gt_WARN_ON(hwe->gt, !xe_gt_is_media_type(hwe->gt));
+       xe_gt_WARN_ON(hwe->gt, xe_gt_is_main_type(hwe->gt));
 
        if (GRAPHICS_VER(gt_to_xe(hwe->gt)) < 20)
                return 0;
@@ -2589,7 +2589,7 @@ static void __xe_oa_init_oa_units(struct xe_gt *gt)
        for (i = 0; i < num_units; i++) {
                struct xe_oa_unit *u = &gt->oa.oa_unit[i];
 
-               if (!xe_gt_is_media_type(gt)) {
+               if (xe_gt_is_main_type(gt)) {
                        u->regs = __oag_regs();
                        u->type = DRM_XE_OA_UNIT_TYPE_OAG;
                } else {