Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/gsc: Introduce GSC FW

Add the basic definitions and init function. Same as HuC, GSC is only
supported on the media GT on MTL and newer platforms.
Note that the GSC requires submission resources which can't be allocated
during init (because we don't have the hwconfig yet), so it can't be
marked as loadable at the end of the init function. The allocation of
those resources will come in the patch that makes use of them to load
the FW.

v2: better comment, move num FWs define inside the enum (John)

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Daniele Ceraolo Spurio and committed by
Rodrigo Vivi
0d1caff4 2e7227b4

+121 -9
+1
drivers/gpu/drm/xe/Makefile
··· 58 58 xe_force_wake.o \ 59 59 xe_ggtt.o \ 60 60 xe_gpu_scheduler.o \ 61 + xe_gsc.o \ 61 62 xe_gt.o \ 62 63 xe_gt_clock.o \ 63 64 xe_gt_debugfs.o \
+52
drivers/gpu/drm/xe/xe_gsc.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #include "xe_gsc.h" 7 + 8 + #include "xe_device.h" 9 + #include "xe_gt.h" 10 + #include "xe_gt_printk.h" 11 + #include "xe_uc_fw.h" 12 + 13 + static struct xe_gt * 14 + gsc_to_gt(struct xe_gsc *gsc) 15 + { 16 + return container_of(gsc, struct xe_gt, uc.gsc); 17 + } 18 + 19 + int xe_gsc_init(struct xe_gsc *gsc) 20 + { 21 + struct xe_gt *gt = gsc_to_gt(gsc); 22 + struct xe_tile *tile = gt_to_tile(gt); 23 + int ret; 24 + 25 + gsc->fw.type = XE_UC_FW_TYPE_GSC; 26 + 27 + /* The GSC uC is only available on the media GT */ 28 + if (tile->media_gt && (gt != tile->media_gt)) { 29 + xe_uc_fw_change_status(&gsc->fw, XE_UC_FIRMWARE_NOT_SUPPORTED); 30 + return 0; 31 + } 32 + 33 + /* 34 + * Some platforms can have GuC but not GSC. That would cause 35 + * xe_uc_fw_init(gsc) to return a "not supported" failure code and abort 36 + * all firmware loading. So check for GSC being enabled before 37 + * propagating the failure back up. That way the higher level will keep 38 + * going and load GuC as appropriate. 39 + */ 40 + ret = xe_uc_fw_init(&gsc->fw); 41 + if (!xe_uc_fw_is_enabled(&gsc->fw)) 42 + return 0; 43 + else if (ret) 44 + goto out; 45 + 46 + return 0; 47 + 48 + out: 49 + xe_gt_err(gt, "GSC init failed with %d", ret); 50 + return ret; 51 + } 52 +
+13
drivers/gpu/drm/xe/xe_gsc.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef _XE_GSC_H_ 7 + #define _XE_GSC_H_ 8 + 9 + #include "xe_gsc_types.h" 10 + 11 + int xe_gsc_init(struct xe_gsc *gsc); 12 + 13 + #endif
+19
drivers/gpu/drm/xe/xe_gsc_types.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef _XE_GSC_TYPES_H_ 7 + #define _XE_GSC_TYPES_H_ 8 + 9 + #include "xe_uc_fw_types.h" 10 + 11 + /** 12 + * struct xe_gsc - GSC 13 + */ 14 + struct xe_gsc { 15 + /** @fw: Generic uC firmware management */ 16 + struct xe_uc_fw fw; 17 + }; 18 + 19 + #endif
+7 -2
drivers/gpu/drm/xe/xe_uc.c
··· 6 6 #include "xe_uc.h" 7 7 8 8 #include "xe_device.h" 9 + #include "xe_gsc.h" 9 10 #include "xe_gt.h" 10 11 #include "xe_guc.h" 11 12 #include "xe_guc_pc.h" ··· 33 32 int ret; 34 33 35 34 /* 36 - * We call the GuC/HuC init functions even if GuC submission is off to 37 - * correctly move our tracking of the FW state to "disabled". 35 + * We call the GuC/HuC/GSC init functions even if GuC submission is off 36 + * to correctly move our tracking of the FW state to "disabled". 38 37 */ 39 38 40 39 ret = xe_guc_init(&uc->guc); ··· 42 41 goto err; 43 42 44 43 ret = xe_huc_init(&uc->huc); 44 + if (ret) 45 + goto err; 46 + 47 + ret = xe_gsc_init(&uc->gsc); 45 48 if (ret) 46 49 goto err; 47 50
+19 -4
drivers/gpu/drm/xe/xe_uc_fw.c
··· 158 158 static struct xe_gt * 159 159 __uc_fw_to_gt(struct xe_uc_fw *uc_fw, enum xe_uc_fw_type type) 160 160 { 161 - if (type == XE_UC_FW_TYPE_GUC) 162 - return container_of(uc_fw, struct xe_gt, uc.guc.fw); 161 + XE_WARN_ON(type >= XE_UC_FW_NUM_TYPES); 163 162 164 - XE_WARN_ON(type != XE_UC_FW_TYPE_HUC); 165 - return container_of(uc_fw, struct xe_gt, uc.huc.fw); 163 + switch (type) { 164 + case XE_UC_FW_TYPE_GUC: 165 + return container_of(uc_fw, struct xe_gt, uc.guc.fw); 166 + case XE_UC_FW_TYPE_HUC: 167 + return container_of(uc_fw, struct xe_gt, uc.huc.fw); 168 + case XE_UC_FW_TYPE_GSC: 169 + return container_of(uc_fw, struct xe_gt, uc.gsc.fw); 170 + default: 171 + return NULL; 172 + } 166 173 } 167 174 168 175 static struct xe_gt *uc_fw_to_gt(struct xe_uc_fw *uc_fw) ··· 203 196 enum xe_platform p = xe->info.platform; 204 197 u32 count; 205 198 int i; 199 + 200 + /* 201 + * GSC FW support is still not fully in place, so we're not defining 202 + * the FW blob yet because we don't want the driver to attempt to load 203 + * it until we're ready for it. 204 + */ 205 + if (uc_fw->type == XE_UC_FW_TYPE_GSC) 206 + return; 206 207 207 208 xe_assert(xe, uc_fw->type < ARRAY_SIZE(blobs_all)); 208 209 entries = blobs_all[uc_fw->type].entries;
+4 -1
drivers/gpu/drm/xe/xe_uc_fw.h
··· 96 96 return "GuC"; 97 97 case XE_UC_FW_TYPE_HUC: 98 98 return "HuC"; 99 + case XE_UC_FW_TYPE_GSC: 100 + return "GSC"; 101 + default: 102 + return "uC"; 99 103 } 100 - return "uC"; 101 104 } 102 105 103 106 static inline enum xe_uc_fw_status
+3 -2
drivers/gpu/drm/xe/xe_uc_fw_types.h
··· 55 55 56 56 enum xe_uc_fw_type { 57 57 XE_UC_FW_TYPE_GUC = 0, 58 - XE_UC_FW_TYPE_HUC 58 + XE_UC_FW_TYPE_HUC, 59 + XE_UC_FW_TYPE_GSC, 60 + XE_UC_FW_NUM_TYPES 59 61 }; 60 - #define XE_UC_FW_NUM_TYPES 2 61 62 62 63 /** 63 64 * struct xe_uc_fw_version - Version for XE micro controller firmware
+3
drivers/gpu/drm/xe/xe_uc_types.h
··· 6 6 #ifndef _XE_UC_TYPES_H_ 7 7 #define _XE_UC_TYPES_H_ 8 8 9 + #include "xe_gsc_types.h" 9 10 #include "xe_guc_types.h" 10 11 #include "xe_huc_types.h" 11 12 #include "xe_wopcm_types.h" ··· 19 18 struct xe_guc guc; 20 19 /** @huc: HuC */ 21 20 struct xe_huc huc; 21 + /** @gsc: Graphics Security Controller */ 22 + struct xe_gsc gsc; 22 23 /** @wopcm: WOPCM */ 23 24 struct xe_wopcm wopcm; 24 25 };