1dd08ebf6SMatthew Brost // SPDX-License-Identifier: MIT 2dd08ebf6SMatthew Brost /* 3dd08ebf6SMatthew Brost * Copyright © 2022 Intel Corporation 4dd08ebf6SMatthew Brost */ 5dd08ebf6SMatthew Brost 6dd08ebf6SMatthew Brost #include <linux/bitfield.h> 7dd08ebf6SMatthew Brost #include <linux/firmware.h> 8dd08ebf6SMatthew Brost 9dd08ebf6SMatthew Brost #include <drm/drm_managed.h> 10dd08ebf6SMatthew Brost 11a9b1a136SLucas De Marchi #include "regs/xe_guc_regs.h" 12dd08ebf6SMatthew Brost #include "xe_bo.h" 13dd08ebf6SMatthew Brost #include "xe_device_types.h" 14dd08ebf6SMatthew Brost #include "xe_force_wake.h" 15985d5a49SDaniele Ceraolo Spurio #include "xe_gsc.h" 16dd08ebf6SMatthew Brost #include "xe_gt.h" 1726a22952SMichal Wajdeczko #include "xe_gt_printk.h" 184eb0aab6SJulia Filipchuk #include "xe_guc.h" 19dd08ebf6SMatthew Brost #include "xe_map.h" 20dd08ebf6SMatthew Brost #include "xe_mmio.h" 21a455ed04SDaniele Ceraolo Spurio #include "xe_module.h" 2266cb3ca9SMichal Wajdeczko #include "xe_sriov.h" 23dd08ebf6SMatthew Brost #include "xe_uc_fw.h" 24dd08ebf6SMatthew Brost 25ad55ead7SLucas De Marchi /* 26ad55ead7SLucas De Marchi * List of required GuC and HuC binaries per-platform. They must be ordered 27ad55ead7SLucas De Marchi * based on platform, from newer to older. 28ad55ead7SLucas De Marchi * 29ad55ead7SLucas De Marchi * Versioning follows the guidelines from 30ad55ead7SLucas De Marchi * Documentation/driver-api/firmware/firmware-usage-guidelines.rst. There is a 31ad55ead7SLucas De Marchi * distinction for platforms being officially supported by the driver or not. 32ad55ead7SLucas De Marchi * Platforms not available publicly or not yet officially supported by the 33ad55ead7SLucas De Marchi * driver (under force-probe), use the mmp_ver(): the firmware autoselect logic 34ad55ead7SLucas De Marchi * will select the firmware from disk with filename that matches the full 35ad55ead7SLucas De Marchi * "mpp version", i.e. major.minor.patch. mmp_ver() should only be used for 36ad55ead7SLucas De Marchi * this case. 37ad55ead7SLucas De Marchi * 38ad55ead7SLucas De Marchi * For platforms officially supported by the driver, the filename always only 39ad55ead7SLucas De Marchi * ever contains the major version (GuC) or no version at all (HuC). 40ad55ead7SLucas De Marchi * 41ad55ead7SLucas De Marchi * After loading the file, the driver parses the versions embedded in the blob. 42ad55ead7SLucas De Marchi * The major version needs to match a major version supported by the driver (if 43ad55ead7SLucas De Marchi * any). The minor version is also checked and a notice emitted to the log if 44ad55ead7SLucas De Marchi * the version found is smaller than the version wanted. This is done only for 45ad55ead7SLucas De Marchi * informational purposes so users may have a chance to upgrade, but the driver 46ad55ead7SLucas De Marchi * still loads and use the older firmware. 47ad55ead7SLucas De Marchi * 48ad55ead7SLucas De Marchi * Examples: 49ad55ead7SLucas De Marchi * 50ad55ead7SLucas De Marchi * 1) Platform officially supported by i915 - using Tigerlake as example. 51ad55ead7SLucas De Marchi * Driver loads the following firmware blobs from disk: 52ad55ead7SLucas De Marchi * 53ad55ead7SLucas De Marchi * - i915/tgl_guc_<major>.bin 54ad55ead7SLucas De Marchi * - i915/tgl_huc.bin 55ad55ead7SLucas De Marchi * 56ad55ead7SLucas De Marchi * <major> number for GuC is checked that it matches the version inside 57ad55ead7SLucas De Marchi * the blob. <minor> version is checked and if smaller than the expected 58ad55ead7SLucas De Marchi * an info message is emitted about that. 59ad55ead7SLucas De Marchi * 60ad55ead7SLucas De Marchi * 1) XE_<FUTUREINTELPLATFORM>, still under require_force_probe. Using 61ad55ead7SLucas De Marchi * "wipplat" as a short-name. Driver loads the following firmware blobs 62ad55ead7SLucas De Marchi * from disk: 63ad55ead7SLucas De Marchi * 64ad55ead7SLucas De Marchi * - xe/wipplat_guc_<major>.<minor>.<patch>.bin 65ad55ead7SLucas De Marchi * - xe/wipplat_huc_<major>.<minor>.<patch>.bin 66ad55ead7SLucas De Marchi * 67ad55ead7SLucas De Marchi * <major> and <minor> are checked that they match the version inside 68ad55ead7SLucas De Marchi * the blob. Both of them need to match exactly what the driver is 69ad55ead7SLucas De Marchi * expecting, otherwise it fails. 70ad55ead7SLucas De Marchi * 71ad55ead7SLucas De Marchi * 3) Platform officially supported by xe and out of force-probe. Using 72ad55ead7SLucas De Marchi * "plat" as a short-name. Except for the different directory, the 73ad55ead7SLucas De Marchi * behavior is the same as (1). Driver loads the following firmware 74ad55ead7SLucas De Marchi * blobs from disk: 75ad55ead7SLucas De Marchi * 76ad55ead7SLucas De Marchi * - xe/plat_guc_<major>.bin 77ad55ead7SLucas De Marchi * - xe/plat_huc.bin 78ad55ead7SLucas De Marchi * 79ad55ead7SLucas De Marchi * <major> number for GuC is checked that it matches the version inside 80ad55ead7SLucas De Marchi * the blob. <minor> version is checked and if smaller than the expected 81ad55ead7SLucas De Marchi * an info message is emitted about that. 82ad55ead7SLucas De Marchi * 83ad55ead7SLucas De Marchi * For the platforms already released with a major version, they should never be 84ad55ead7SLucas De Marchi * removed from the table. Instead new entries with newer versions may be added 85ad55ead7SLucas De Marchi * before them, so they take precedence. 86ad55ead7SLucas De Marchi * 87ad55ead7SLucas De Marchi * TODO: Currently there's no fallback on major version. That's because xe 88ad55ead7SLucas De Marchi * driver only supports the one major version of each firmware in the table. 89ad55ead7SLucas De Marchi * This needs to be fixed when the major version of GuC is updated. 90ad55ead7SLucas De Marchi */ 91ad55ead7SLucas De Marchi 92ad55ead7SLucas De Marchi struct uc_fw_entry { 93ad55ead7SLucas De Marchi enum xe_platform platform; 94ad55ead7SLucas De Marchi struct { 95ad55ead7SLucas De Marchi const char *path; 96ad55ead7SLucas De Marchi u16 major; 97ad55ead7SLucas De Marchi u16 minor; 986650ad3eSJohn Harrison u16 patch; 99ad55ead7SLucas De Marchi bool full_ver_required; 100ad55ead7SLucas De Marchi }; 101ad55ead7SLucas De Marchi }; 102ad55ead7SLucas De Marchi 103ad55ead7SLucas De Marchi struct fw_blobs_by_type { 104ad55ead7SLucas De Marchi const struct uc_fw_entry *entries; 105ad55ead7SLucas De Marchi u32 count; 106ad55ead7SLucas De Marchi }; 107ad55ead7SLucas De Marchi 108ad55ead7SLucas De Marchi #define XE_GUC_FIRMWARE_DEFS(fw_def, mmp_ver, major_ver) \ 1094eb0aab6SJulia Filipchuk fw_def(LUNARLAKE, major_ver(xe, guc, lnl, 70, 29, 2)) \ 1104eb0aab6SJulia Filipchuk fw_def(METEORLAKE, major_ver(i915, guc, mtl, 70, 29, 2)) \ 1114eb0aab6SJulia Filipchuk fw_def(DG2, major_ver(i915, guc, dg2, 70, 29, 2)) \ 1124eb0aab6SJulia Filipchuk fw_def(DG1, major_ver(i915, guc, dg1, 70, 29, 2)) \ 1134eb0aab6SJulia Filipchuk fw_def(ALDERLAKE_N, major_ver(i915, guc, tgl, 70, 29, 2)) \ 1144eb0aab6SJulia Filipchuk fw_def(ALDERLAKE_P, major_ver(i915, guc, adlp, 70, 29, 2)) \ 1154eb0aab6SJulia Filipchuk fw_def(ALDERLAKE_S, major_ver(i915, guc, tgl, 70, 29, 2)) \ 1164eb0aab6SJulia Filipchuk fw_def(ROCKETLAKE, major_ver(i915, guc, tgl, 70, 29, 2)) \ 1174eb0aab6SJulia Filipchuk fw_def(TIGERLAKE, major_ver(i915, guc, tgl, 70, 29, 2)) 118ad55ead7SLucas De Marchi 119ad55ead7SLucas De Marchi #define XE_HUC_FIRMWARE_DEFS(fw_def, mmp_ver, no_ver) \ 120351a8871SDaniele Ceraolo Spurio fw_def(BATTLEMAGE, no_ver(xe, huc, bmg)) \ 121e8149028SDaniele Ceraolo Spurio fw_def(LUNARLAKE, no_ver(xe, huc, lnl)) \ 122bfeb4ac5SDaniele Ceraolo Spurio fw_def(METEORLAKE, no_ver(i915, huc_gsc, mtl)) \ 123420c6a6fSDaniele Ceraolo Spurio fw_def(DG1, no_ver(i915, huc, dg1)) \ 12485635f5dSLucas De Marchi fw_def(ALDERLAKE_P, no_ver(i915, huc, tgl)) \ 125ad55ead7SLucas De Marchi fw_def(ALDERLAKE_S, no_ver(i915, huc, tgl)) \ 12694324e6bSAnusha Srivatsa fw_def(ROCKETLAKE, no_ver(i915, huc, tgl)) \ 127ad55ead7SLucas De Marchi fw_def(TIGERLAKE, no_ver(i915, huc, tgl)) 128ad55ead7SLucas De Marchi 1295152234eSDaniele Ceraolo Spurio /* for the GSC FW we match the compatibility version and not the release one */ 1305152234eSDaniele Ceraolo Spurio #define XE_GSC_FIRMWARE_DEFS(fw_def, major_ver) \ 131f4aa02c4SDaniele Ceraolo Spurio fw_def(LUNARLAKE, major_ver(xe, gsc, lnl, 1, 0, 0)) \ 1326650ad3eSJohn Harrison fw_def(METEORLAKE, major_ver(i915, gsc, mtl, 1, 0, 0)) 1335152234eSDaniele Ceraolo Spurio 134ad55ead7SLucas De Marchi #define MAKE_FW_PATH(dir__, uc__, shortname__, version__) \ 135ad55ead7SLucas De Marchi __stringify(dir__) "/" __stringify(shortname__) "_" __stringify(uc__) version__ ".bin" 136ad55ead7SLucas De Marchi 137ad55ead7SLucas De Marchi #define fw_filename_mmp_ver(dir_, uc_, shortname_, a, b, c) \ 138ad55ead7SLucas De Marchi MAKE_FW_PATH(dir_, uc_, shortname_, "_" __stringify(a ## . ## b ## . ## c)) 1396650ad3eSJohn Harrison #define fw_filename_major_ver(dir_, uc_, shortname_, a, b, c) \ 140ad55ead7SLucas De Marchi MAKE_FW_PATH(dir_, uc_, shortname_, "_" __stringify(a)) 141ad55ead7SLucas De Marchi #define fw_filename_no_ver(dir_, uc_, shortname_) \ 142ad55ead7SLucas De Marchi MAKE_FW_PATH(dir_, uc_, shortname_, "") 143ad55ead7SLucas De Marchi 144ad55ead7SLucas De Marchi #define uc_fw_entry_mmp_ver(dir_, uc_, shortname_, a, b, c) \ 145ad55ead7SLucas De Marchi { fw_filename_mmp_ver(dir_, uc_, shortname_, a, b, c), \ 1466650ad3eSJohn Harrison a, b, c, true } 1476650ad3eSJohn Harrison #define uc_fw_entry_major_ver(dir_, uc_, shortname_, a, b, c) \ 1486650ad3eSJohn Harrison { fw_filename_major_ver(dir_, uc_, shortname_, a, b, c), \ 1496650ad3eSJohn Harrison a, b, c } 150ad55ead7SLucas De Marchi #define uc_fw_entry_no_ver(dir_, uc_, shortname_) \ 151ad55ead7SLucas De Marchi { fw_filename_no_ver(dir_, uc_, shortname_), \ 152ad55ead7SLucas De Marchi 0, 0 } 153ad55ead7SLucas De Marchi 154ad55ead7SLucas De Marchi /* All blobs need to be declared via MODULE_FIRMWARE() */ 155ad55ead7SLucas De Marchi #define XE_UC_MODULE_FIRMWARE(platform__, fw_filename) \ 156ad55ead7SLucas De Marchi MODULE_FIRMWARE(fw_filename); 157ad55ead7SLucas De Marchi 158ad55ead7SLucas De Marchi #define XE_UC_FW_ENTRY(platform__, entry__) \ 159ad55ead7SLucas De Marchi { \ 160ad55ead7SLucas De Marchi .platform = XE_ ## platform__, \ 161ad55ead7SLucas De Marchi entry__, \ 162ad55ead7SLucas De Marchi }, 163ad55ead7SLucas De Marchi 1643e8e7ee6SFrancois Dugast XE_GUC_FIRMWARE_DEFS(XE_UC_MODULE_FIRMWARE, 165ad55ead7SLucas De Marchi fw_filename_mmp_ver, fw_filename_major_ver) 1663e8e7ee6SFrancois Dugast XE_HUC_FIRMWARE_DEFS(XE_UC_MODULE_FIRMWARE, 167ad55ead7SLucas De Marchi fw_filename_mmp_ver, fw_filename_no_ver) 1685152234eSDaniele Ceraolo Spurio XE_GSC_FIRMWARE_DEFS(XE_UC_MODULE_FIRMWARE, fw_filename_major_ver) 169ad55ead7SLucas De Marchi 170dd08ebf6SMatthew Brost static struct xe_gt * 171dd08ebf6SMatthew Brost __uc_fw_to_gt(struct xe_uc_fw *uc_fw, enum xe_uc_fw_type type) 172dd08ebf6SMatthew Brost { 1730d1caff4SDaniele Ceraolo Spurio XE_WARN_ON(type >= XE_UC_FW_NUM_TYPES); 174dd08ebf6SMatthew Brost 1750d1caff4SDaniele Ceraolo Spurio switch (type) { 1760d1caff4SDaniele Ceraolo Spurio case XE_UC_FW_TYPE_GUC: 1770d1caff4SDaniele Ceraolo Spurio return container_of(uc_fw, struct xe_gt, uc.guc.fw); 1780d1caff4SDaniele Ceraolo Spurio case XE_UC_FW_TYPE_HUC: 179dd08ebf6SMatthew Brost return container_of(uc_fw, struct xe_gt, uc.huc.fw); 1800d1caff4SDaniele Ceraolo Spurio case XE_UC_FW_TYPE_GSC: 1810d1caff4SDaniele Ceraolo Spurio return container_of(uc_fw, struct xe_gt, uc.gsc.fw); 1820d1caff4SDaniele Ceraolo Spurio default: 1830d1caff4SDaniele Ceraolo Spurio return NULL; 1840d1caff4SDaniele Ceraolo Spurio } 185dd08ebf6SMatthew Brost } 186dd08ebf6SMatthew Brost 187dd08ebf6SMatthew Brost static struct xe_gt *uc_fw_to_gt(struct xe_uc_fw *uc_fw) 188dd08ebf6SMatthew Brost { 189dd08ebf6SMatthew Brost return __uc_fw_to_gt(uc_fw, uc_fw->type); 190dd08ebf6SMatthew Brost } 191dd08ebf6SMatthew Brost 192dd08ebf6SMatthew Brost static struct xe_device *uc_fw_to_xe(struct xe_uc_fw *uc_fw) 193dd08ebf6SMatthew Brost { 194dd08ebf6SMatthew Brost return gt_to_xe(uc_fw_to_gt(uc_fw)); 195dd08ebf6SMatthew Brost } 196dd08ebf6SMatthew Brost 197dd08ebf6SMatthew Brost static void 198dd08ebf6SMatthew Brost uc_fw_auto_select(struct xe_device *xe, struct xe_uc_fw *uc_fw) 199dd08ebf6SMatthew Brost { 200ad55ead7SLucas De Marchi static const struct uc_fw_entry entries_guc[] = { 201ad55ead7SLucas De Marchi XE_GUC_FIRMWARE_DEFS(XE_UC_FW_ENTRY, 202ad55ead7SLucas De Marchi uc_fw_entry_mmp_ver, 203ad55ead7SLucas De Marchi uc_fw_entry_major_ver) 204dd08ebf6SMatthew Brost }; 205ad55ead7SLucas De Marchi static const struct uc_fw_entry entries_huc[] = { 206ad55ead7SLucas De Marchi XE_HUC_FIRMWARE_DEFS(XE_UC_FW_ENTRY, 207ad55ead7SLucas De Marchi uc_fw_entry_mmp_ver, 208ad55ead7SLucas De Marchi uc_fw_entry_no_ver) 209dd08ebf6SMatthew Brost }; 2105152234eSDaniele Ceraolo Spurio static const struct uc_fw_entry entries_gsc[] = { 2115152234eSDaniele Ceraolo Spurio XE_GSC_FIRMWARE_DEFS(XE_UC_FW_ENTRY, uc_fw_entry_major_ver) 2125152234eSDaniele Ceraolo Spurio }; 213dd08ebf6SMatthew Brost static const struct fw_blobs_by_type blobs_all[XE_UC_FW_NUM_TYPES] = { 214ad55ead7SLucas De Marchi [XE_UC_FW_TYPE_GUC] = { entries_guc, ARRAY_SIZE(entries_guc) }, 215ad55ead7SLucas De Marchi [XE_UC_FW_TYPE_HUC] = { entries_huc, ARRAY_SIZE(entries_huc) }, 2165152234eSDaniele Ceraolo Spurio [XE_UC_FW_TYPE_GSC] = { entries_gsc, ARRAY_SIZE(entries_gsc) }, 217dd08ebf6SMatthew Brost }; 218ad55ead7SLucas De Marchi static const struct uc_fw_entry *entries; 219dd08ebf6SMatthew Brost enum xe_platform p = xe->info.platform; 220ad55ead7SLucas De Marchi u32 count; 221dd08ebf6SMatthew Brost int i; 222dd08ebf6SMatthew Brost 223c73acc1eSFrancois Dugast xe_assert(xe, uc_fw->type < ARRAY_SIZE(blobs_all)); 224ad55ead7SLucas De Marchi entries = blobs_all[uc_fw->type].entries; 225ad55ead7SLucas De Marchi count = blobs_all[uc_fw->type].count; 226dd08ebf6SMatthew Brost 227ad55ead7SLucas De Marchi for (i = 0; i < count && p <= entries[i].platform; i++) { 228ad55ead7SLucas De Marchi if (p == entries[i].platform) { 229ad55ead7SLucas De Marchi uc_fw->path = entries[i].path; 2302e7227b4SDaniele Ceraolo Spurio uc_fw->versions.wanted.major = entries[i].major; 2312e7227b4SDaniele Ceraolo Spurio uc_fw->versions.wanted.minor = entries[i].minor; 2326650ad3eSJohn Harrison uc_fw->versions.wanted.patch = entries[i].patch; 233ad55ead7SLucas De Marchi uc_fw->full_ver_required = entries[i].full_ver_required; 2342e7227b4SDaniele Ceraolo Spurio 2350881cbe0SDaniele Ceraolo Spurio if (uc_fw->type == XE_UC_FW_TYPE_GSC) 2360881cbe0SDaniele Ceraolo Spurio uc_fw->versions.wanted_type = XE_UC_FW_VER_COMPATIBILITY; 2370881cbe0SDaniele Ceraolo Spurio else 2382e7227b4SDaniele Ceraolo Spurio uc_fw->versions.wanted_type = XE_UC_FW_VER_RELEASE; 2390881cbe0SDaniele Ceraolo Spurio 240dd08ebf6SMatthew Brost break; 241dd08ebf6SMatthew Brost } 242dd08ebf6SMatthew Brost } 243dd08ebf6SMatthew Brost } 244dd08ebf6SMatthew Brost 245a455ed04SDaniele Ceraolo Spurio static void 246a455ed04SDaniele Ceraolo Spurio uc_fw_override(struct xe_uc_fw *uc_fw) 247a455ed04SDaniele Ceraolo Spurio { 248a455ed04SDaniele Ceraolo Spurio char *path_override = NULL; 249a455ed04SDaniele Ceraolo Spurio 250a455ed04SDaniele Ceraolo Spurio /* empty string disables, but it's not allowed for GuC */ 251a455ed04SDaniele Ceraolo Spurio switch (uc_fw->type) { 252a455ed04SDaniele Ceraolo Spurio case XE_UC_FW_TYPE_GUC: 253adce1b39SBommithi Sakeena if (xe_modparam.guc_firmware_path && *xe_modparam.guc_firmware_path) 254adce1b39SBommithi Sakeena path_override = xe_modparam.guc_firmware_path; 255a455ed04SDaniele Ceraolo Spurio break; 256a455ed04SDaniele Ceraolo Spurio case XE_UC_FW_TYPE_HUC: 257adce1b39SBommithi Sakeena path_override = xe_modparam.huc_firmware_path; 258a455ed04SDaniele Ceraolo Spurio break; 2595152234eSDaniele Ceraolo Spurio case XE_UC_FW_TYPE_GSC: 2605152234eSDaniele Ceraolo Spurio path_override = xe_modparam.gsc_firmware_path; 2615152234eSDaniele Ceraolo Spurio break; 262a455ed04SDaniele Ceraolo Spurio default: 263a455ed04SDaniele Ceraolo Spurio break; 264a455ed04SDaniele Ceraolo Spurio } 265a455ed04SDaniele Ceraolo Spurio 266a455ed04SDaniele Ceraolo Spurio if (path_override) { 267a455ed04SDaniele Ceraolo Spurio uc_fw->path = path_override; 268a455ed04SDaniele Ceraolo Spurio uc_fw->user_overridden = true; 269a455ed04SDaniele Ceraolo Spurio } 270a455ed04SDaniele Ceraolo Spurio } 271a455ed04SDaniele Ceraolo Spurio 272dd08ebf6SMatthew Brost /** 273dd08ebf6SMatthew Brost * xe_uc_fw_copy_rsa - copy fw RSA to buffer 274dd08ebf6SMatthew Brost * 275dd08ebf6SMatthew Brost * @uc_fw: uC firmware 276dd08ebf6SMatthew Brost * @dst: dst buffer 277dd08ebf6SMatthew Brost * @max_len: max number of bytes to copy 278dd08ebf6SMatthew Brost * 279dd08ebf6SMatthew Brost * Return: number of copied bytes. 280dd08ebf6SMatthew Brost */ 281dd08ebf6SMatthew Brost size_t xe_uc_fw_copy_rsa(struct xe_uc_fw *uc_fw, void *dst, u32 max_len) 282dd08ebf6SMatthew Brost { 283dd08ebf6SMatthew Brost struct xe_device *xe = uc_fw_to_xe(uc_fw); 284dd08ebf6SMatthew Brost u32 size = min_t(u32, uc_fw->rsa_size, max_len); 285dd08ebf6SMatthew Brost 286c73acc1eSFrancois Dugast xe_assert(xe, !(size % 4)); 287c73acc1eSFrancois Dugast xe_assert(xe, xe_uc_fw_is_available(uc_fw)); 288dd08ebf6SMatthew Brost 289dd08ebf6SMatthew Brost xe_map_memcpy_from(xe, dst, &uc_fw->bo->vmap, 290dd08ebf6SMatthew Brost xe_uc_fw_rsa_offset(uc_fw), size); 291dd08ebf6SMatthew Brost 292dd08ebf6SMatthew Brost return size; 293dd08ebf6SMatthew Brost } 294dd08ebf6SMatthew Brost 295dd08ebf6SMatthew Brost static void uc_fw_fini(struct drm_device *drm, void *arg) 296dd08ebf6SMatthew Brost { 297dd08ebf6SMatthew Brost struct xe_uc_fw *uc_fw = arg; 298dd08ebf6SMatthew Brost 299dd08ebf6SMatthew Brost if (!xe_uc_fw_is_available(uc_fw)) 300dd08ebf6SMatthew Brost return; 301dd08ebf6SMatthew Brost 302dd08ebf6SMatthew Brost xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_SELECTED); 303dd08ebf6SMatthew Brost } 304dd08ebf6SMatthew Brost 30543c4ff3cSDaniele Ceraolo Spurio static int guc_read_css_info(struct xe_uc_fw *uc_fw, struct uc_css_header *css) 30699c821b0SMatthew Brost { 30799c821b0SMatthew Brost struct xe_gt *gt = uc_fw_to_gt(uc_fw); 3082e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE]; 3092e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *compatibility = &uc_fw->versions.found[XE_UC_FW_VER_COMPATIBILITY]; 31099c821b0SMatthew Brost 311c73acc1eSFrancois Dugast xe_gt_assert(gt, uc_fw->type == XE_UC_FW_TYPE_GUC); 31299c821b0SMatthew Brost 3134eb0aab6SJulia Filipchuk /* We don't support GuC releases older than 70.29.2 */ 3144eb0aab6SJulia Filipchuk if (MAKE_GUC_VER_STRUCT(*release) < MAKE_GUC_VER(70, 29, 2)) { 3154eb0aab6SJulia Filipchuk xe_gt_err(gt, "Unsupported GuC v%u.%u.%u! v70.29.2 or newer is required\n", 3164eb0aab6SJulia Filipchuk release->major, release->minor, release->patch); 31743c4ff3cSDaniele Ceraolo Spurio return -EINVAL; 31899c821b0SMatthew Brost } 31999c821b0SMatthew Brost 32043c4ff3cSDaniele Ceraolo Spurio compatibility->major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, css->submission_version); 32143c4ff3cSDaniele Ceraolo Spurio compatibility->minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, css->submission_version); 32243c4ff3cSDaniele Ceraolo Spurio compatibility->patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, css->submission_version); 32343c4ff3cSDaniele Ceraolo Spurio 32499c821b0SMatthew Brost uc_fw->private_data_size = css->private_data_size; 32543c4ff3cSDaniele Ceraolo Spurio 32643c4ff3cSDaniele Ceraolo Spurio return 0; 32799c821b0SMatthew Brost } 32899c821b0SMatthew Brost 3290881cbe0SDaniele Ceraolo Spurio int xe_uc_fw_check_version_requirements(struct xe_uc_fw *uc_fw) 330ad55ead7SLucas De Marchi { 331ad55ead7SLucas De Marchi struct xe_device *xe = uc_fw_to_xe(uc_fw); 3322e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *wanted = &uc_fw->versions.wanted; 3332e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *found = &uc_fw->versions.found[uc_fw->versions.wanted_type]; 334ad55ead7SLucas De Marchi 335ad55ead7SLucas De Marchi /* Driver has no requirement on any version, any is good. */ 3362e7227b4SDaniele Ceraolo Spurio if (!wanted->major) 337ad55ead7SLucas De Marchi return 0; 338ad55ead7SLucas De Marchi 339ad55ead7SLucas De Marchi /* 340ad55ead7SLucas De Marchi * If full version is required, both major and minor should match. 341ad55ead7SLucas De Marchi * Otherwise, at least the major version. 342ad55ead7SLucas De Marchi */ 3432e7227b4SDaniele Ceraolo Spurio if (wanted->major != found->major || 3446650ad3eSJohn Harrison (uc_fw->full_ver_required && 3456650ad3eSJohn Harrison ((wanted->minor != found->minor) || 3466650ad3eSJohn Harrison (wanted->patch != found->patch)))) { 3476650ad3eSJohn Harrison drm_notice(&xe->drm, "%s firmware %s: unexpected version: %u.%u.%u != %u.%u.%u\n", 348ad55ead7SLucas De Marchi xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, 3496650ad3eSJohn Harrison found->major, found->minor, found->patch, 3506650ad3eSJohn Harrison wanted->major, wanted->minor, wanted->patch); 351ad55ead7SLucas De Marchi goto fail; 352ad55ead7SLucas De Marchi } 353ad55ead7SLucas De Marchi 3546650ad3eSJohn Harrison if (wanted->minor > found->minor || 3556650ad3eSJohn Harrison (wanted->minor == found->minor && wanted->patch > found->patch)) { 3566650ad3eSJohn Harrison drm_notice(&xe->drm, "%s firmware (%u.%u.%u) is recommended, but only (%u.%u.%u) was found in %s\n", 357ad55ead7SLucas De Marchi xe_uc_fw_type_repr(uc_fw->type), 3586650ad3eSJohn Harrison wanted->major, wanted->minor, wanted->patch, 3596650ad3eSJohn Harrison found->major, found->minor, found->patch, 360ad55ead7SLucas De Marchi uc_fw->path); 361ad55ead7SLucas De Marchi drm_info(&xe->drm, "Consider updating your linux-firmware pkg or downloading from %s\n", 362ad55ead7SLucas De Marchi XE_UC_FIRMWARE_URL); 363ad55ead7SLucas De Marchi } 364ad55ead7SLucas De Marchi 365ad55ead7SLucas De Marchi return 0; 366ad55ead7SLucas De Marchi 367ad55ead7SLucas De Marchi fail: 368ad55ead7SLucas De Marchi if (xe_uc_fw_is_overridden(uc_fw)) 369ad55ead7SLucas De Marchi return 0; 370ad55ead7SLucas De Marchi 371ad55ead7SLucas De Marchi return -ENOEXEC; 372ad55ead7SLucas De Marchi } 373ad55ead7SLucas De Marchi 374a9a95523SDaniele Ceraolo Spurio /* Refer to the "CSS-based Firmware Layout" documentation entry for details */ 375a9a95523SDaniele Ceraolo Spurio static int parse_css_header(struct xe_uc_fw *uc_fw, const void *fw_data, size_t fw_size) 376a9a95523SDaniele Ceraolo Spurio { 377a9a95523SDaniele Ceraolo Spurio struct xe_device *xe = uc_fw_to_xe(uc_fw); 3782e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE]; 379a9a95523SDaniele Ceraolo Spurio struct uc_css_header *css; 380a9a95523SDaniele Ceraolo Spurio size_t size; 381a9a95523SDaniele Ceraolo Spurio 382a9a95523SDaniele Ceraolo Spurio /* Check the size of the blob before examining buffer contents */ 383a9a95523SDaniele Ceraolo Spurio if (unlikely(fw_size < sizeof(struct uc_css_header))) { 384a9a95523SDaniele Ceraolo Spurio drm_warn(&xe->drm, "%s firmware %s: invalid size: %zu < %zu\n", 385a9a95523SDaniele Ceraolo Spurio xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, 386a9a95523SDaniele Ceraolo Spurio fw_size, sizeof(struct uc_css_header)); 387a9a95523SDaniele Ceraolo Spurio return -ENODATA; 388a9a95523SDaniele Ceraolo Spurio } 389a9a95523SDaniele Ceraolo Spurio 390a9a95523SDaniele Ceraolo Spurio css = (struct uc_css_header *)fw_data; 391a9a95523SDaniele Ceraolo Spurio 392a9a95523SDaniele Ceraolo Spurio /* Check integrity of size values inside CSS header */ 393a9a95523SDaniele Ceraolo Spurio size = (css->header_size_dw - css->key_size_dw - css->modulus_size_dw - 394a9a95523SDaniele Ceraolo Spurio css->exponent_size_dw) * sizeof(u32); 395a9a95523SDaniele Ceraolo Spurio if (unlikely(size != sizeof(struct uc_css_header))) { 396a9a95523SDaniele Ceraolo Spurio drm_warn(&xe->drm, 397a9a95523SDaniele Ceraolo Spurio "%s firmware %s: unexpected header size: %zu != %zu\n", 398a9a95523SDaniele Ceraolo Spurio xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, 399a9a95523SDaniele Ceraolo Spurio fw_size, sizeof(struct uc_css_header)); 400a9a95523SDaniele Ceraolo Spurio return -EPROTO; 401a9a95523SDaniele Ceraolo Spurio } 402a9a95523SDaniele Ceraolo Spurio 403a9a95523SDaniele Ceraolo Spurio /* uCode size must calculated from other sizes */ 404a9a95523SDaniele Ceraolo Spurio uc_fw->ucode_size = (css->size_dw - css->header_size_dw) * sizeof(u32); 405a9a95523SDaniele Ceraolo Spurio 406a9a95523SDaniele Ceraolo Spurio /* now RSA */ 407a9a95523SDaniele Ceraolo Spurio uc_fw->rsa_size = css->key_size_dw * sizeof(u32); 408a9a95523SDaniele Ceraolo Spurio 409a9a95523SDaniele Ceraolo Spurio /* At least, it should have header, uCode and RSA. Size of all three. */ 410a9a95523SDaniele Ceraolo Spurio size = sizeof(struct uc_css_header) + uc_fw->ucode_size + 411a9a95523SDaniele Ceraolo Spurio uc_fw->rsa_size; 412a9a95523SDaniele Ceraolo Spurio if (unlikely(fw_size < size)) { 413a9a95523SDaniele Ceraolo Spurio drm_warn(&xe->drm, "%s firmware %s: invalid size: %zu < %zu\n", 414a9a95523SDaniele Ceraolo Spurio xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, 415a9a95523SDaniele Ceraolo Spurio fw_size, size); 416a9a95523SDaniele Ceraolo Spurio return -ENOEXEC; 417a9a95523SDaniele Ceraolo Spurio } 418a9a95523SDaniele Ceraolo Spurio 419a9a95523SDaniele Ceraolo Spurio /* Get version numbers from the CSS header */ 4202e7227b4SDaniele Ceraolo Spurio release->major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, css->sw_version); 4212e7227b4SDaniele Ceraolo Spurio release->minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, css->sw_version); 4222e7227b4SDaniele Ceraolo Spurio release->patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, css->sw_version); 423a9a95523SDaniele Ceraolo Spurio 424a9a95523SDaniele Ceraolo Spurio if (uc_fw->type == XE_UC_FW_TYPE_GUC) 42543c4ff3cSDaniele Ceraolo Spurio return guc_read_css_info(uc_fw, css); 426a9a95523SDaniele Ceraolo Spurio 427a9a95523SDaniele Ceraolo Spurio return 0; 428a9a95523SDaniele Ceraolo Spurio } 429a9a95523SDaniele Ceraolo Spurio 430484ecffaSDaniele Ceraolo Spurio static bool is_cpd_header(const void *data) 431484ecffaSDaniele Ceraolo Spurio { 432484ecffaSDaniele Ceraolo Spurio const u32 *marker = data; 433484ecffaSDaniele Ceraolo Spurio 434484ecffaSDaniele Ceraolo Spurio return *marker == GSC_CPD_HEADER_MARKER; 435484ecffaSDaniele Ceraolo Spurio } 436484ecffaSDaniele Ceraolo Spurio 437484ecffaSDaniele Ceraolo Spurio static u32 entry_offset(const struct gsc_cpd_header_v2 *header, const char *name) 438484ecffaSDaniele Ceraolo Spurio { 439484ecffaSDaniele Ceraolo Spurio const struct gsc_cpd_entry *entry; 440484ecffaSDaniele Ceraolo Spurio int i; 441484ecffaSDaniele Ceraolo Spurio 442484ecffaSDaniele Ceraolo Spurio entry = (void *)header + header->header_length; 443484ecffaSDaniele Ceraolo Spurio 444484ecffaSDaniele Ceraolo Spurio for (i = 0; i < header->num_of_entries; i++, entry++) 445484ecffaSDaniele Ceraolo Spurio if (strcmp(entry->name, name) == 0) 446484ecffaSDaniele Ceraolo Spurio return entry->offset & GSC_CPD_ENTRY_OFFSET_MASK; 447484ecffaSDaniele Ceraolo Spurio 448484ecffaSDaniele Ceraolo Spurio return 0; 449484ecffaSDaniele Ceraolo Spurio } 450484ecffaSDaniele Ceraolo Spurio 451484ecffaSDaniele Ceraolo Spurio /* Refer to the "GSC-based Firmware Layout" documentation entry for details */ 452484ecffaSDaniele Ceraolo Spurio static int parse_cpd_header(struct xe_uc_fw *uc_fw, const void *data, size_t size, 453484ecffaSDaniele Ceraolo Spurio const char *manifest_entry, const char *css_entry) 454484ecffaSDaniele Ceraolo Spurio { 455484ecffaSDaniele Ceraolo Spurio struct xe_gt *gt = uc_fw_to_gt(uc_fw); 456484ecffaSDaniele Ceraolo Spurio struct xe_device *xe = gt_to_xe(gt); 457484ecffaSDaniele Ceraolo Spurio const struct gsc_cpd_header_v2 *header = data; 4582e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *release = &uc_fw->versions.found[XE_UC_FW_VER_RELEASE]; 459484ecffaSDaniele Ceraolo Spurio const struct gsc_manifest_header *manifest; 460484ecffaSDaniele Ceraolo Spurio size_t min_size = sizeof(*header); 461484ecffaSDaniele Ceraolo Spurio u32 offset; 462484ecffaSDaniele Ceraolo Spurio 463484ecffaSDaniele Ceraolo Spurio /* manifest_entry is mandatory, css_entry is optional */ 464484ecffaSDaniele Ceraolo Spurio xe_assert(xe, manifest_entry); 465484ecffaSDaniele Ceraolo Spurio 466484ecffaSDaniele Ceraolo Spurio if (size < min_size || !is_cpd_header(header)) 467484ecffaSDaniele Ceraolo Spurio return -ENOENT; 468484ecffaSDaniele Ceraolo Spurio 469484ecffaSDaniele Ceraolo Spurio if (header->header_length < sizeof(struct gsc_cpd_header_v2)) { 470484ecffaSDaniele Ceraolo Spurio xe_gt_err(gt, "invalid CPD header length %u!\n", header->header_length); 471484ecffaSDaniele Ceraolo Spurio return -EINVAL; 472484ecffaSDaniele Ceraolo Spurio } 473484ecffaSDaniele Ceraolo Spurio 474484ecffaSDaniele Ceraolo Spurio min_size = header->header_length + sizeof(struct gsc_cpd_entry) * header->num_of_entries; 475484ecffaSDaniele Ceraolo Spurio if (size < min_size) { 476484ecffaSDaniele Ceraolo Spurio xe_gt_err(gt, "FW too small! %zu < %zu\n", size, min_size); 477484ecffaSDaniele Ceraolo Spurio return -ENODATA; 478484ecffaSDaniele Ceraolo Spurio } 479484ecffaSDaniele Ceraolo Spurio 480484ecffaSDaniele Ceraolo Spurio /* Look for the manifest first */ 481484ecffaSDaniele Ceraolo Spurio offset = entry_offset(header, manifest_entry); 482484ecffaSDaniele Ceraolo Spurio if (!offset) { 483484ecffaSDaniele Ceraolo Spurio xe_gt_err(gt, "Failed to find %s manifest!\n", 484484ecffaSDaniele Ceraolo Spurio xe_uc_fw_type_repr(uc_fw->type)); 485484ecffaSDaniele Ceraolo Spurio return -ENODATA; 486484ecffaSDaniele Ceraolo Spurio } 487484ecffaSDaniele Ceraolo Spurio 488484ecffaSDaniele Ceraolo Spurio min_size = offset + sizeof(struct gsc_manifest_header); 489484ecffaSDaniele Ceraolo Spurio if (size < min_size) { 490484ecffaSDaniele Ceraolo Spurio xe_gt_err(gt, "FW too small! %zu < %zu\n", size, min_size); 491484ecffaSDaniele Ceraolo Spurio return -ENODATA; 492484ecffaSDaniele Ceraolo Spurio } 493484ecffaSDaniele Ceraolo Spurio 494484ecffaSDaniele Ceraolo Spurio manifest = data + offset; 495484ecffaSDaniele Ceraolo Spurio 4962e7227b4SDaniele Ceraolo Spurio release->major = manifest->fw_version.major; 4972e7227b4SDaniele Ceraolo Spurio release->minor = manifest->fw_version.minor; 4982e7227b4SDaniele Ceraolo Spurio release->patch = manifest->fw_version.hotfix; 499484ecffaSDaniele Ceraolo Spurio 500985d5a49SDaniele Ceraolo Spurio if (uc_fw->type == XE_UC_FW_TYPE_GSC) { 501985d5a49SDaniele Ceraolo Spurio struct xe_gsc *gsc = container_of(uc_fw, struct xe_gsc, fw); 502985d5a49SDaniele Ceraolo Spurio 503985d5a49SDaniele Ceraolo Spurio release->build = manifest->fw_version.build; 504985d5a49SDaniele Ceraolo Spurio gsc->security_version = manifest->security_version; 505985d5a49SDaniele Ceraolo Spurio } 506985d5a49SDaniele Ceraolo Spurio 507484ecffaSDaniele Ceraolo Spurio /* then optionally look for the css header */ 508484ecffaSDaniele Ceraolo Spurio if (css_entry) { 509484ecffaSDaniele Ceraolo Spurio int ret; 510484ecffaSDaniele Ceraolo Spurio 511484ecffaSDaniele Ceraolo Spurio /* 512484ecffaSDaniele Ceraolo Spurio * This section does not contain a CSS entry on DG2. We 513484ecffaSDaniele Ceraolo Spurio * don't support DG2 HuC right now, so no need to handle 514484ecffaSDaniele Ceraolo Spurio * it, just add a reminder in case that changes. 515484ecffaSDaniele Ceraolo Spurio */ 516484ecffaSDaniele Ceraolo Spurio xe_assert(xe, xe->info.platform != XE_DG2); 517484ecffaSDaniele Ceraolo Spurio 518484ecffaSDaniele Ceraolo Spurio offset = entry_offset(header, css_entry); 519484ecffaSDaniele Ceraolo Spurio 520484ecffaSDaniele Ceraolo Spurio /* the CSS header parser will check that the CSS header fits */ 521484ecffaSDaniele Ceraolo Spurio if (offset > size) { 522484ecffaSDaniele Ceraolo Spurio xe_gt_err(gt, "FW too small! %zu < %u\n", size, offset); 523484ecffaSDaniele Ceraolo Spurio return -ENODATA; 524484ecffaSDaniele Ceraolo Spurio } 525484ecffaSDaniele Ceraolo Spurio 526484ecffaSDaniele Ceraolo Spurio ret = parse_css_header(uc_fw, data + offset, size - offset); 527484ecffaSDaniele Ceraolo Spurio if (ret) 528484ecffaSDaniele Ceraolo Spurio return ret; 529484ecffaSDaniele Ceraolo Spurio 530484ecffaSDaniele Ceraolo Spurio uc_fw->css_offset = offset; 531484ecffaSDaniele Ceraolo Spurio } 532484ecffaSDaniele Ceraolo Spurio 533d8b15713SDaniele Ceraolo Spurio uc_fw->has_gsc_headers = true; 534d8b15713SDaniele Ceraolo Spurio 535484ecffaSDaniele Ceraolo Spurio return 0; 536484ecffaSDaniele Ceraolo Spurio } 537484ecffaSDaniele Ceraolo Spurio 538985d5a49SDaniele Ceraolo Spurio static int parse_gsc_layout(struct xe_uc_fw *uc_fw, const void *data, size_t size) 539985d5a49SDaniele Ceraolo Spurio { 540985d5a49SDaniele Ceraolo Spurio struct xe_gt *gt = uc_fw_to_gt(uc_fw); 541985d5a49SDaniele Ceraolo Spurio const struct gsc_layout_pointers *layout = data; 542985d5a49SDaniele Ceraolo Spurio const struct gsc_bpdt_header *bpdt_header = NULL; 543985d5a49SDaniele Ceraolo Spurio const struct gsc_bpdt_entry *bpdt_entry = NULL; 544985d5a49SDaniele Ceraolo Spurio size_t min_size = sizeof(*layout); 545985d5a49SDaniele Ceraolo Spurio int i; 546985d5a49SDaniele Ceraolo Spurio 547985d5a49SDaniele Ceraolo Spurio if (size < min_size) { 548985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "GSC FW too small! %zu < %zu\n", size, min_size); 549985d5a49SDaniele Ceraolo Spurio return -ENODATA; 550985d5a49SDaniele Ceraolo Spurio } 551985d5a49SDaniele Ceraolo Spurio 552985d5a49SDaniele Ceraolo Spurio min_size = layout->boot1.offset + layout->boot1.size; 553985d5a49SDaniele Ceraolo Spurio if (size < min_size) { 554985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "GSC FW too small for boot section! %zu < %zu\n", 555985d5a49SDaniele Ceraolo Spurio size, min_size); 556985d5a49SDaniele Ceraolo Spurio return -ENODATA; 557985d5a49SDaniele Ceraolo Spurio } 558985d5a49SDaniele Ceraolo Spurio 559985d5a49SDaniele Ceraolo Spurio min_size = sizeof(*bpdt_header); 560985d5a49SDaniele Ceraolo Spurio if (layout->boot1.size < min_size) { 561985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "GSC FW boot section too small for BPDT header: %u < %zu\n", 562985d5a49SDaniele Ceraolo Spurio layout->boot1.size, min_size); 563985d5a49SDaniele Ceraolo Spurio return -ENODATA; 564985d5a49SDaniele Ceraolo Spurio } 565985d5a49SDaniele Ceraolo Spurio 566985d5a49SDaniele Ceraolo Spurio bpdt_header = data + layout->boot1.offset; 567985d5a49SDaniele Ceraolo Spurio if (bpdt_header->signature != GSC_BPDT_HEADER_SIGNATURE) { 568985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "invalid signature for BPDT header: 0x%08x!\n", 569985d5a49SDaniele Ceraolo Spurio bpdt_header->signature); 570985d5a49SDaniele Ceraolo Spurio return -EINVAL; 571985d5a49SDaniele Ceraolo Spurio } 572985d5a49SDaniele Ceraolo Spurio 573985d5a49SDaniele Ceraolo Spurio min_size += sizeof(*bpdt_entry) * bpdt_header->descriptor_count; 574985d5a49SDaniele Ceraolo Spurio if (layout->boot1.size < min_size) { 575985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "GSC FW boot section too small for BPDT entries: %u < %zu\n", 576985d5a49SDaniele Ceraolo Spurio layout->boot1.size, min_size); 577985d5a49SDaniele Ceraolo Spurio return -ENODATA; 578985d5a49SDaniele Ceraolo Spurio } 579985d5a49SDaniele Ceraolo Spurio 580985d5a49SDaniele Ceraolo Spurio bpdt_entry = (void *)bpdt_header + sizeof(*bpdt_header); 581985d5a49SDaniele Ceraolo Spurio for (i = 0; i < bpdt_header->descriptor_count; i++, bpdt_entry++) { 582985d5a49SDaniele Ceraolo Spurio if ((bpdt_entry->type & GSC_BPDT_ENTRY_TYPE_MASK) != 583985d5a49SDaniele Ceraolo Spurio GSC_BPDT_ENTRY_TYPE_GSC_RBE) 584985d5a49SDaniele Ceraolo Spurio continue; 585985d5a49SDaniele Ceraolo Spurio 586985d5a49SDaniele Ceraolo Spurio min_size = bpdt_entry->sub_partition_offset; 587985d5a49SDaniele Ceraolo Spurio 588985d5a49SDaniele Ceraolo Spurio /* the CPD header parser will check that the CPD header fits */ 589985d5a49SDaniele Ceraolo Spurio if (layout->boot1.size < min_size) { 590985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "GSC FW boot section too small for CPD offset: %u < %zu\n", 591985d5a49SDaniele Ceraolo Spurio layout->boot1.size, min_size); 592985d5a49SDaniele Ceraolo Spurio return -ENODATA; 593985d5a49SDaniele Ceraolo Spurio } 594985d5a49SDaniele Ceraolo Spurio 595985d5a49SDaniele Ceraolo Spurio return parse_cpd_header(uc_fw, 596985d5a49SDaniele Ceraolo Spurio (void *)bpdt_header + min_size, 597985d5a49SDaniele Ceraolo Spurio layout->boot1.size - min_size, 598985d5a49SDaniele Ceraolo Spurio "RBEP.man", NULL); 599985d5a49SDaniele Ceraolo Spurio } 600985d5a49SDaniele Ceraolo Spurio 601985d5a49SDaniele Ceraolo Spurio xe_gt_err(gt, "couldn't find CPD header in GSC binary!\n"); 602985d5a49SDaniele Ceraolo Spurio return -ENODATA; 603985d5a49SDaniele Ceraolo Spurio } 604985d5a49SDaniele Ceraolo Spurio 605a9a95523SDaniele Ceraolo Spurio static int parse_headers(struct xe_uc_fw *uc_fw, const struct firmware *fw) 606a9a95523SDaniele Ceraolo Spurio { 607484ecffaSDaniele Ceraolo Spurio int ret; 608484ecffaSDaniele Ceraolo Spurio 609484ecffaSDaniele Ceraolo Spurio /* 610484ecffaSDaniele Ceraolo Spurio * All GuC releases and older HuC ones use CSS headers, while newer HuC 611484ecffaSDaniele Ceraolo Spurio * releases use GSC CPD headers. 612484ecffaSDaniele Ceraolo Spurio */ 613484ecffaSDaniele Ceraolo Spurio switch (uc_fw->type) { 614985d5a49SDaniele Ceraolo Spurio case XE_UC_FW_TYPE_GSC: 615985d5a49SDaniele Ceraolo Spurio return parse_gsc_layout(uc_fw, fw->data, fw->size); 616484ecffaSDaniele Ceraolo Spurio case XE_UC_FW_TYPE_HUC: 617484ecffaSDaniele Ceraolo Spurio ret = parse_cpd_header(uc_fw, fw->data, fw->size, "HUCP.man", "huc_fw"); 618484ecffaSDaniele Ceraolo Spurio if (!ret || ret != -ENOENT) 619484ecffaSDaniele Ceraolo Spurio return ret; 620484ecffaSDaniele Ceraolo Spurio fallthrough; 621484ecffaSDaniele Ceraolo Spurio case XE_UC_FW_TYPE_GUC: 622a9a95523SDaniele Ceraolo Spurio return parse_css_header(uc_fw, fw->data, fw->size); 623484ecffaSDaniele Ceraolo Spurio default: 624484ecffaSDaniele Ceraolo Spurio return -EINVAL; 625484ecffaSDaniele Ceraolo Spurio } 626484ecffaSDaniele Ceraolo Spurio 627484ecffaSDaniele Ceraolo Spurio return 0; 628a9a95523SDaniele Ceraolo Spurio } 629a9a95523SDaniele Ceraolo Spurio 6302e7227b4SDaniele Ceraolo Spurio #define print_uc_fw_version(p_, version_, prefix_, ...) \ 6312e7227b4SDaniele Ceraolo Spurio do { \ 6322e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *ver_ = (version_); \ 6332e7227b4SDaniele Ceraolo Spurio if (ver_->build) \ 6342e7227b4SDaniele Ceraolo Spurio drm_printf(p_, prefix_ " version %u.%u.%u.%u\n", ##__VA_ARGS__, \ 6352e7227b4SDaniele Ceraolo Spurio ver_->major, ver_->minor, \ 6362e7227b4SDaniele Ceraolo Spurio ver_->patch, ver_->build); \ 6372e7227b4SDaniele Ceraolo Spurio else \ 6382e7227b4SDaniele Ceraolo Spurio drm_printf(p_, prefix_ " version %u.%u.%u\n", ##__VA_ARGS__, \ 6392e7227b4SDaniele Ceraolo Spurio ver_->major, ver_->minor, ver_->patch); \ 6402e7227b4SDaniele Ceraolo Spurio } while (0) 6412e7227b4SDaniele Ceraolo Spurio 642c93ea051SMichał Winiarski static int uc_fw_request(struct xe_uc_fw *uc_fw, const struct firmware **firmware_p) 643dd08ebf6SMatthew Brost { 644dd08ebf6SMatthew Brost struct xe_device *xe = uc_fw_to_xe(uc_fw); 645dd08ebf6SMatthew Brost struct device *dev = xe->drm.dev; 6462e7227b4SDaniele Ceraolo Spurio struct drm_printer p = drm_info_printer(dev); 647dd08ebf6SMatthew Brost const struct firmware *fw = NULL; 648dd08ebf6SMatthew Brost int err; 649dd08ebf6SMatthew Brost 650dd08ebf6SMatthew Brost /* 651dd08ebf6SMatthew Brost * we use FIRMWARE_UNINITIALIZED to detect checks against uc_fw->status 652dd08ebf6SMatthew Brost * before we're looked at the HW caps to see if we have uc support 653dd08ebf6SMatthew Brost */ 654dd08ebf6SMatthew Brost BUILD_BUG_ON(XE_UC_FIRMWARE_UNINITIALIZED); 655c73acc1eSFrancois Dugast xe_assert(xe, !uc_fw->status); 656c73acc1eSFrancois Dugast xe_assert(xe, !uc_fw->path); 657dd08ebf6SMatthew Brost 658dd08ebf6SMatthew Brost uc_fw_auto_select(xe, uc_fw); 65966cb3ca9SMichal Wajdeczko 66066cb3ca9SMichal Wajdeczko if (IS_SRIOV_VF(xe)) { 66105e49e0cSMichal Wajdeczko /* Only GuC/HuC are supported */ 66205e49e0cSMichal Wajdeczko if (uc_fw->type != XE_UC_FW_TYPE_GUC && 66305e49e0cSMichal Wajdeczko uc_fw->type != XE_UC_FW_TYPE_HUC) 66405e49e0cSMichal Wajdeczko uc_fw->path = NULL; 66566cb3ca9SMichal Wajdeczko /* VF will support only firmwares that driver can autoselect */ 66666cb3ca9SMichal Wajdeczko xe_uc_fw_change_status(uc_fw, uc_fw->path ? 66766cb3ca9SMichal Wajdeczko XE_UC_FIRMWARE_PRELOADED : 66866cb3ca9SMichal Wajdeczko XE_UC_FIRMWARE_NOT_SUPPORTED); 66966cb3ca9SMichal Wajdeczko return 0; 67066cb3ca9SMichal Wajdeczko } 67166cb3ca9SMichal Wajdeczko 67245883418SLucas De Marchi uc_fw_override(uc_fw); 67366cb3ca9SMichal Wajdeczko 67475730847SDaniele Ceraolo Spurio xe_uc_fw_change_status(uc_fw, uc_fw->path ? 675dd08ebf6SMatthew Brost XE_UC_FIRMWARE_SELECTED : 676dd08ebf6SMatthew Brost XE_UC_FIRMWARE_NOT_SUPPORTED); 677dd08ebf6SMatthew Brost 6786badfc46SLucas De Marchi if (!xe_uc_fw_is_supported(uc_fw)) { 6796badfc46SLucas De Marchi if (uc_fw->type == XE_UC_FW_TYPE_GUC) { 6806badfc46SLucas De Marchi drm_err(&xe->drm, "No GuC firmware defined for platform\n"); 6816badfc46SLucas De Marchi return -ENOENT; 6826badfc46SLucas De Marchi } 68375730847SDaniele Ceraolo Spurio return 0; 6846badfc46SLucas De Marchi } 68575730847SDaniele Ceraolo Spurio 686a455ed04SDaniele Ceraolo Spurio /* an empty path means the firmware is disabled */ 687a455ed04SDaniele Ceraolo Spurio if (!xe_device_uc_enabled(xe) || !(*uc_fw->path)) { 688dd08ebf6SMatthew Brost xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_DISABLED); 68975730847SDaniele Ceraolo Spurio drm_dbg(&xe->drm, "%s disabled", xe_uc_fw_type_repr(uc_fw->type)); 69075730847SDaniele Ceraolo Spurio return 0; 691dd08ebf6SMatthew Brost } 69275730847SDaniele Ceraolo Spurio 693dd08ebf6SMatthew Brost err = request_firmware(&fw, uc_fw->path, dev); 694dd08ebf6SMatthew Brost if (err) 695dd08ebf6SMatthew Brost goto fail; 696dd08ebf6SMatthew Brost 697a9a95523SDaniele Ceraolo Spurio err = parse_headers(uc_fw, fw); 698a9a95523SDaniele Ceraolo Spurio if (err) 699dd08ebf6SMatthew Brost goto fail; 700dd08ebf6SMatthew Brost 7012e7227b4SDaniele Ceraolo Spurio print_uc_fw_version(&p, 7022e7227b4SDaniele Ceraolo Spurio &uc_fw->versions.found[XE_UC_FW_VER_RELEASE], 7032e7227b4SDaniele Ceraolo Spurio "Using %s firmware from %s", 7042e7227b4SDaniele Ceraolo Spurio xe_uc_fw_type_repr(uc_fw->type), uc_fw->path); 70561e72e77SLucas De Marchi 7060881cbe0SDaniele Ceraolo Spurio /* for GSC FW we want the compatibility version, which we query after load */ 7070881cbe0SDaniele Ceraolo Spurio if (uc_fw->type != XE_UC_FW_TYPE_GSC) { 7080881cbe0SDaniele Ceraolo Spurio err = xe_uc_fw_check_version_requirements(uc_fw); 709ad55ead7SLucas De Marchi if (err) 710dd08ebf6SMatthew Brost goto fail; 7110881cbe0SDaniele Ceraolo Spurio } 712dd08ebf6SMatthew Brost 713c93ea051SMichał Winiarski *firmware_p = fw; 714dd08ebf6SMatthew Brost 715dd08ebf6SMatthew Brost return 0; 716dd08ebf6SMatthew Brost 717dd08ebf6SMatthew Brost fail: 718dd08ebf6SMatthew Brost xe_uc_fw_change_status(uc_fw, err == -ENOENT ? 719dd08ebf6SMatthew Brost XE_UC_FIRMWARE_MISSING : 720dd08ebf6SMatthew Brost XE_UC_FIRMWARE_ERROR); 721dd08ebf6SMatthew Brost 722dd08ebf6SMatthew Brost drm_notice(&xe->drm, "%s firmware %s: fetch failed with error %d\n", 723dd08ebf6SMatthew Brost xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, err); 724dd08ebf6SMatthew Brost drm_info(&xe->drm, "%s firmware(s) can be downloaded from %s\n", 725dd08ebf6SMatthew Brost xe_uc_fw_type_repr(uc_fw->type), XE_UC_FIRMWARE_URL); 726dd08ebf6SMatthew Brost 727dd08ebf6SMatthew Brost release_firmware(fw); /* OK even if fw is NULL */ 7280e1a47fcSMichał Winiarski 729dd08ebf6SMatthew Brost return err; 730dd08ebf6SMatthew Brost } 731dd08ebf6SMatthew Brost 732c93ea051SMichał Winiarski static void uc_fw_release(const struct firmware *fw) 733c93ea051SMichał Winiarski { 734c93ea051SMichał Winiarski release_firmware(fw); 735c93ea051SMichał Winiarski } 736c93ea051SMichał Winiarski 737c93ea051SMichał Winiarski static int uc_fw_copy(struct xe_uc_fw *uc_fw, const void *data, size_t size, u32 flags) 738c93ea051SMichał Winiarski { 739c93ea051SMichał Winiarski struct xe_device *xe = uc_fw_to_xe(uc_fw); 740c93ea051SMichał Winiarski struct xe_gt *gt = uc_fw_to_gt(uc_fw); 741c93ea051SMichał Winiarski struct xe_tile *tile = gt_to_tile(gt); 742c93ea051SMichał Winiarski struct xe_bo *obj; 743c93ea051SMichał Winiarski int err; 744c93ea051SMichał Winiarski 745c93ea051SMichał Winiarski obj = xe_managed_bo_create_from_data(xe, tile, data, size, flags); 746c93ea051SMichał Winiarski if (IS_ERR(obj)) { 747c93ea051SMichał Winiarski drm_notice(&xe->drm, "%s firmware %s: failed to create / populate bo", 748c93ea051SMichał Winiarski xe_uc_fw_type_repr(uc_fw->type), uc_fw->path); 749c93ea051SMichał Winiarski err = PTR_ERR(obj); 750c93ea051SMichał Winiarski goto fail; 751c93ea051SMichał Winiarski } 752c93ea051SMichał Winiarski 753c93ea051SMichał Winiarski uc_fw->bo = obj; 754c93ea051SMichał Winiarski uc_fw->size = size; 755c93ea051SMichał Winiarski 756c93ea051SMichał Winiarski xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_AVAILABLE); 757c93ea051SMichał Winiarski 758c93ea051SMichał Winiarski err = drmm_add_action_or_reset(&xe->drm, uc_fw_fini, uc_fw); 759c93ea051SMichał Winiarski if (err) 760c93ea051SMichał Winiarski goto fail; 761c93ea051SMichał Winiarski 762c93ea051SMichał Winiarski return 0; 763c93ea051SMichał Winiarski 764c93ea051SMichał Winiarski fail: 765c93ea051SMichał Winiarski xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_ERROR); 766c93ea051SMichał Winiarski drm_notice(&xe->drm, "%s firmware %s: copy failed with error %d\n", 767c93ea051SMichał Winiarski xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, err); 768c93ea051SMichał Winiarski 769c93ea051SMichał Winiarski return err; 770c93ea051SMichał Winiarski } 771c93ea051SMichał Winiarski 772c93ea051SMichał Winiarski int xe_uc_fw_init(struct xe_uc_fw *uc_fw) 773c93ea051SMichał Winiarski { 774c93ea051SMichał Winiarski const struct firmware *fw = NULL; 775c93ea051SMichał Winiarski int err; 776c93ea051SMichał Winiarski 777c93ea051SMichał Winiarski err = uc_fw_request(uc_fw, &fw); 778c93ea051SMichał Winiarski if (err) 779c93ea051SMichał Winiarski return err; 780c93ea051SMichał Winiarski 781c93ea051SMichał Winiarski /* no error and no firmware means nothing to copy */ 782c93ea051SMichał Winiarski if (!fw) 783c93ea051SMichał Winiarski return 0; 784c93ea051SMichał Winiarski 785c93ea051SMichał Winiarski err = uc_fw_copy(uc_fw, fw->data, fw->size, 78662742d12SLucas De Marchi XE_BO_FLAG_SYSTEM | XE_BO_FLAG_GGTT | 78762742d12SLucas De Marchi XE_BO_FLAG_GGTT_INVALIDATE); 788c93ea051SMichał Winiarski 789c93ea051SMichał Winiarski uc_fw_release(fw); 790c93ea051SMichał Winiarski 791c93ea051SMichał Winiarski return err; 792c93ea051SMichał Winiarski } 793c93ea051SMichał Winiarski 794dd08ebf6SMatthew Brost static u32 uc_fw_ggtt_offset(struct xe_uc_fw *uc_fw) 795dd08ebf6SMatthew Brost { 796dd08ebf6SMatthew Brost return xe_bo_ggtt_addr(uc_fw->bo); 797dd08ebf6SMatthew Brost } 798dd08ebf6SMatthew Brost 799dd08ebf6SMatthew Brost static int uc_fw_xfer(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags) 800dd08ebf6SMatthew Brost { 801dd08ebf6SMatthew Brost struct xe_device *xe = uc_fw_to_xe(uc_fw); 802dd08ebf6SMatthew Brost struct xe_gt *gt = uc_fw_to_gt(uc_fw); 8034c15a6dcSDaniele Ceraolo Spurio u64 src_offset; 8044c15a6dcSDaniele Ceraolo Spurio u32 dma_ctrl; 805dd08ebf6SMatthew Brost int ret; 806dd08ebf6SMatthew Brost 807dd08ebf6SMatthew Brost xe_force_wake_assert_held(gt_to_fw(gt), XE_FW_GT); 808dd08ebf6SMatthew Brost 809dd08ebf6SMatthew Brost /* Set the source address for the uCode */ 810484ecffaSDaniele Ceraolo Spurio src_offset = uc_fw_ggtt_offset(uc_fw) + uc_fw->css_offset; 811ce8bf5bdSLucas De Marchi xe_mmio_write32(gt, DMA_ADDR_0_LOW, lower_32_bits(src_offset)); 812473b6276SFei Yang xe_mmio_write32(gt, DMA_ADDR_0_HIGH, 813473b6276SFei Yang upper_32_bits(src_offset) | DMA_ADDRESS_SPACE_GGTT); 814dd08ebf6SMatthew Brost 815dd08ebf6SMatthew Brost /* Set the DMA destination */ 816ce8bf5bdSLucas De Marchi xe_mmio_write32(gt, DMA_ADDR_1_LOW, offset); 817ce8bf5bdSLucas De Marchi xe_mmio_write32(gt, DMA_ADDR_1_HIGH, DMA_ADDRESS_SPACE_WOPCM); 818dd08ebf6SMatthew Brost 819dd08ebf6SMatthew Brost /* 820dd08ebf6SMatthew Brost * Set the transfer size. The header plus uCode will be copied to WOPCM 821dd08ebf6SMatthew Brost * via DMA, excluding any other components 822dd08ebf6SMatthew Brost */ 823ce8bf5bdSLucas De Marchi xe_mmio_write32(gt, DMA_COPY_SIZE, 824dd08ebf6SMatthew Brost sizeof(struct uc_css_header) + uc_fw->ucode_size); 825dd08ebf6SMatthew Brost 826dd08ebf6SMatthew Brost /* Start the DMA */ 827ce8bf5bdSLucas De Marchi xe_mmio_write32(gt, DMA_CTRL, 828dd08ebf6SMatthew Brost _MASKED_BIT_ENABLE(dma_flags | START_DMA)); 829dd08ebf6SMatthew Brost 830dd08ebf6SMatthew Brost /* Wait for DMA to finish */ 831063e09afSRodrigo Vivi ret = xe_mmio_wait32(gt, DMA_CTRL, START_DMA, 0, 100000, &dma_ctrl, 8327dc9b92dSRodrigo Vivi false); 833dd08ebf6SMatthew Brost if (ret) 834dd08ebf6SMatthew Brost drm_err(&xe->drm, "DMA for %s fw failed, DMA_CTRL=%u\n", 8357aaec3a6SRodrigo Vivi xe_uc_fw_type_repr(uc_fw->type), dma_ctrl); 836dd08ebf6SMatthew Brost 837dd08ebf6SMatthew Brost /* Disable the bits once DMA is over */ 838ce8bf5bdSLucas De Marchi xe_mmio_write32(gt, DMA_CTRL, _MASKED_BIT_DISABLE(dma_flags)); 839dd08ebf6SMatthew Brost 840dd08ebf6SMatthew Brost return ret; 841dd08ebf6SMatthew Brost } 842dd08ebf6SMatthew Brost 843dd08ebf6SMatthew Brost int xe_uc_fw_upload(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags) 844dd08ebf6SMatthew Brost { 845dd08ebf6SMatthew Brost struct xe_device *xe = uc_fw_to_xe(uc_fw); 846dd08ebf6SMatthew Brost int err; 847dd08ebf6SMatthew Brost 848dd08ebf6SMatthew Brost /* make sure the status was cleared the last time we reset the uc */ 849c73acc1eSFrancois Dugast xe_assert(xe, !xe_uc_fw_is_loaded(uc_fw)); 850dd08ebf6SMatthew Brost 851dd08ebf6SMatthew Brost if (!xe_uc_fw_is_loadable(uc_fw)) 852dd08ebf6SMatthew Brost return -ENOEXEC; 853dd08ebf6SMatthew Brost 854dd08ebf6SMatthew Brost /* Call custom loader */ 855dd08ebf6SMatthew Brost err = uc_fw_xfer(uc_fw, offset, dma_flags); 856dd08ebf6SMatthew Brost if (err) 857dd08ebf6SMatthew Brost goto fail; 858dd08ebf6SMatthew Brost 859dd08ebf6SMatthew Brost xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_TRANSFERRED); 860dd08ebf6SMatthew Brost return 0; 861dd08ebf6SMatthew Brost 862dd08ebf6SMatthew Brost fail: 863dd08ebf6SMatthew Brost drm_err(&xe->drm, "Failed to load %s firmware %s (%d)\n", 864dd08ebf6SMatthew Brost xe_uc_fw_type_repr(uc_fw->type), uc_fw->path, 865dd08ebf6SMatthew Brost err); 866dd08ebf6SMatthew Brost xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_LOAD_FAIL); 867dd08ebf6SMatthew Brost return err; 868dd08ebf6SMatthew Brost } 869dd08ebf6SMatthew Brost 8702e7227b4SDaniele Ceraolo Spurio static const char *version_type_repr(enum xe_uc_fw_version_types type) 8712e7227b4SDaniele Ceraolo Spurio { 8722e7227b4SDaniele Ceraolo Spurio switch (type) { 8732e7227b4SDaniele Ceraolo Spurio case XE_UC_FW_VER_RELEASE: 8742e7227b4SDaniele Ceraolo Spurio return "release"; 8752e7227b4SDaniele Ceraolo Spurio case XE_UC_FW_VER_COMPATIBILITY: 8762e7227b4SDaniele Ceraolo Spurio return "compatibility"; 8772e7227b4SDaniele Ceraolo Spurio default: 8782e7227b4SDaniele Ceraolo Spurio return "Unknown version type"; 8792e7227b4SDaniele Ceraolo Spurio } 8802e7227b4SDaniele Ceraolo Spurio } 881dd08ebf6SMatthew Brost 882dd08ebf6SMatthew Brost void xe_uc_fw_print(struct xe_uc_fw *uc_fw, struct drm_printer *p) 883dd08ebf6SMatthew Brost { 8842e7227b4SDaniele Ceraolo Spurio int i; 8852e7227b4SDaniele Ceraolo Spurio 886dd08ebf6SMatthew Brost drm_printf(p, "%s firmware: %s\n", 887dd08ebf6SMatthew Brost xe_uc_fw_type_repr(uc_fw->type), uc_fw->path); 888dd08ebf6SMatthew Brost drm_printf(p, "\tstatus: %s\n", 889dd08ebf6SMatthew Brost xe_uc_fw_status_repr(uc_fw->status)); 89099c821b0SMatthew Brost 8912e7227b4SDaniele Ceraolo Spurio print_uc_fw_version(p, &uc_fw->versions.wanted, "\twanted %s", 8922e7227b4SDaniele Ceraolo Spurio version_type_repr(uc_fw->versions.wanted_type)); 89399c821b0SMatthew Brost 8942e7227b4SDaniele Ceraolo Spurio for (i = 0; i < XE_UC_FW_VER_TYPE_COUNT; i++) { 8952e7227b4SDaniele Ceraolo Spurio struct xe_uc_fw_version *ver = &uc_fw->versions.found[i]; 8962e7227b4SDaniele Ceraolo Spurio 8972e7227b4SDaniele Ceraolo Spurio if (ver->major) 8982e7227b4SDaniele Ceraolo Spurio print_uc_fw_version(p, ver, "\tfound %s", 8992e7227b4SDaniele Ceraolo Spurio version_type_repr(i)); 90099c821b0SMatthew Brost } 9012e7227b4SDaniele Ceraolo Spurio 9022e7227b4SDaniele Ceraolo Spurio if (uc_fw->ucode_size) 9032e7227b4SDaniele Ceraolo Spurio drm_printf(p, "\tuCode: %u bytes\n", uc_fw->ucode_size); 9042e7227b4SDaniele Ceraolo Spurio if (uc_fw->rsa_size) 9052e7227b4SDaniele Ceraolo Spurio drm_printf(p, "\tRSA: %u bytes\n", uc_fw->rsa_size); 906dd08ebf6SMatthew Brost } 907