/* * Make sure any device matches here are from most specific to most * general. For example, since the Quanta match is based on the subsystem * and subvendor IDs, we need it to come before the more general IVB * PCI ID matches, otherwise we'll use the wrong info struct above.
*/ staticconststruct pci_device_id pciidlist[] = {
INTEL_TGL_IDS(INTEL_VGA_DEVICE, &tgl_desc),
INTEL_RKL_IDS(INTEL_VGA_DEVICE, &rkl_desc),
INTEL_ADLS_IDS(INTEL_VGA_DEVICE, &adl_s_desc),
INTEL_ADLP_IDS(INTEL_VGA_DEVICE, &adl_p_desc),
INTEL_ADLN_IDS(INTEL_VGA_DEVICE, &adl_n_desc),
INTEL_RPLU_IDS(INTEL_VGA_DEVICE, &adl_p_desc),
INTEL_RPLP_IDS(INTEL_VGA_DEVICE, &adl_p_desc),
INTEL_RPLS_IDS(INTEL_VGA_DEVICE, &adl_s_desc),
INTEL_DG1_IDS(INTEL_VGA_DEVICE, &dg1_desc),
INTEL_ATS_M_IDS(INTEL_VGA_DEVICE, &ats_m_desc),
INTEL_ARL_IDS(INTEL_VGA_DEVICE, &mtl_desc),
INTEL_DG2_IDS(INTEL_VGA_DEVICE, &dg2_desc),
INTEL_MTL_IDS(INTEL_VGA_DEVICE, &mtl_desc),
INTEL_LNL_IDS(INTEL_VGA_DEVICE, &lnl_desc),
INTEL_BMG_IDS(INTEL_VGA_DEVICE, &bmg_desc),
INTEL_PTL_IDS(INTEL_VGA_DEVICE, &ptl_desc),
{ }
};
MODULE_DEVICE_TABLE(pci, pciidlist);
/* is device_id present in comma separated list of ids */ staticbool device_id_in_list(u16 device_id, constchar *devices, bool negative)
{ char *s, *p, *tok; bool ret;
if (!devices || !*devices) returnfalse;
/* match everything */ if (negative && strcmp(devices, "!*") == 0) returntrue; if (!negative && strcmp(devices, "*") == 0) returntrue;
s = kstrdup(devices, GFP_KERNEL); if (!s) returnfalse;
for (p = s, ret = false; (tok = strsep(&p, ",")) != NULL; ) {
u16 val;
if (IS_SRIOV_VF(xe)) { struct xe_gt *gt = xe_root_mmio_gt(xe);
/* * To get the value of the GMDID register, VFs must obtain it * from the GuC using MMIO communication. * * Note that at this point the xe_gt is not fully uninitialized * and only basic access to MMIO registers is possible. To use * our existing GuC communication functions we must perform at * least basic xe_gt and xe_guc initialization. * * Since to obtain the value of GMDID_MEDIA we need to use the * media GuC, temporarily tweak the gt type.
*/
xe_gt_assert(gt, gt->info.type == XE_GT_TYPE_UNINITIALIZED);
/* Don't bother with GMDID if failed to negotiate the GuC ABI */
val = xe_gt_sriov_vf_bootstrap(gt) ? 0 : xe_gt_sriov_vf_gmdid(gt);
/* * Only undo xe_gt.info here, the remaining changes made above * will be overwritten as part of the regular initialization.
*/
gt->info.id = 0;
gt->info.type = XE_GT_TYPE_UNINITIALIZED;
} else { /* * GMD_ID is a GT register, but at this point in the driver * init we haven't fully initialized the GT yet so we need to * read the register with the tile's MMIO accessor. That means * we need to apply the GSI offset manually since it won't get * automatically added as it would if we were using a GT mmio * accessor.
*/ if (type == GMDID_MEDIA)
gmdid_reg.addr += MEDIA_GT_GSI_OFFSET;
/* * Read IP version from hardware and select graphics/media IP descriptors * based on the result.
*/ staticvoid handle_gmdid(struct xe_device *xe, conststruct xe_ip **graphics_ip, conststruct xe_ip **media_ip,
u32 *graphics_revid,
u32 *media_revid)
{
u32 ver;
for (int i = 0; i < ARRAY_SIZE(graphics_ips); i++) { if (ver == graphics_ips[i].verx100) {
*graphics_ip = &graphics_ips[i];
break;
}
}
if (!*graphics_ip) {
drm_err(&xe->drm, "Hardware reports unknown graphics version %u.%02u\n",
ver / 100, ver % 100);
}
read_gmdid(xe, GMDID_MEDIA, &ver, media_revid); /* Media may legitimately be fused off / not present */ if (ver == 0) return;
for (int i = 0; i < ARRAY_SIZE(media_ips); i++) { if (ver == media_ips[i].verx100) {
*media_ip = &media_ips[i];
break;
}
}
if (!*media_ip) {
drm_err(&xe->drm, "Hardware reports unknown media version %u.%02u\n",
ver / 100, ver % 100);
}
}
/* * Initialize device info content that only depends on static driver_data * passed to the driver at probe time from PCI ID table.
*/ staticint xe_info_init_early(struct xe_device *xe, conststruct xe_device_desc *desc, conststruct xe_subplatform_desc *subplatform_desc)
{ int err;
err = xe_tile_init_early(xe_device_get_root_tile(xe), xe, 0); if (err) return err;
return 0;
}
/* * Initialize device info content that does require knowledge about * graphics / media IP version. * Make sure that GT / tile structures allocated by the driver match the data * present in device info.
*/ staticint xe_info_init(struct xe_device *xe, conststruct xe_device_desc *desc)
{
u32 graphics_gmdid_revid = 0, media_gmdid_revid = 0; conststruct xe_ip *graphics_ip; conststruct xe_ip *media_ip; conststruct xe_graphics_desc *graphics_desc; conststruct xe_media_desc *media_desc; struct xe_tile *tile; struct xe_gt *gt;
u8 id;
/* * If this platform supports GMD_ID, we'll detect the proper IP * descriptor to use from hardware registers. * desc->pre_gmdid_graphics_ip will only ever be set at this point for * platforms before GMD_ID. In that case the IP descriptions and * versions are simply derived from that.
*/ if (desc->pre_gmdid_graphics_ip) {
graphics_ip = desc->pre_gmdid_graphics_ip;
media_ip = desc->pre_gmdid_media_ip;
xe->info.step = xe_step_pre_gmdid_get(xe);
} else {
xe_assert(xe, !desc->pre_gmdid_media_ip);
handle_gmdid(xe, &graphics_ip, &media_ip,
&graphics_gmdid_revid, &media_gmdid_revid);
xe->info.step = xe_step_gmdid_get(xe,
graphics_gmdid_revid,
media_gmdid_revid);
}
/* * If we couldn't detect the graphics IP, that's considered a fatal * error and we should abort driver load. Failing to detect media * IP is non-fatal; we'll just proceed without enabling media support.
*/ if (!graphics_ip) return -ENODEV;
err = xe_tile_init_early(tile, xe, id); if (err) return err;
}
/* * All platforms have at least one primary GT. Any platform with media * version 13 or higher has an additional dedicated media GT. And * depending on the graphics IP there may be additional "remote tiles." * All of these together determine the overall GT count.
*/
for_each_tile(tile, xe, id) { int err;
err = xe_tile_alloc_vram(tile); if (err) return err;
if (MEDIA_VER(xe) < 13 && media_desc)
gt->info.engine_mask |= media_desc->hw_engine_mask;
if (MEDIA_VER(xe) < 13 || !media_desc) continue;
/* * Allocate and setup media GT for platforms with standalone * media.
*/
tile->media_gt = xe_gt_alloc(tile); if (IS_ERR(tile->media_gt)) return PTR_ERR(tile->media_gt);
if (IS_SRIOV_PF(xe))
xe_pci_sriov_configure(pdev, 0);
if (xe_survivability_mode_is_enabled(xe)) return;
xe_device_remove(xe);
xe_pm_fini(xe);
}
/* * Probe the PCI device, initialize various parts of the driver. * * Fault injection is used to test the error paths of some initialization * functions called either directly from xe_pci_probe() or indirectly for * example through xe_device_probe(). Those functions use the kernel fault * injection capabilities infrastructure, see * Documentation/fault-injection/fault-injection.rst for details. The macro * ALLOW_ERROR_INJECTION() is used to conditionally skip function execution * at runtime and use a provided return value. The first requirement for * error injectable functions is proper handling of the error code by the * caller for recovery, which is always the case here. The second * requirement is that no state is changed before the first error return. * It is not strictly fulfilled for all initialization functions using the * ALLOW_ERROR_INJECTION() macro but this is acceptable because for those * error cases at probe time, the error code is simply propagated up by the * caller. Therefore there is no consequence on those specific callers when * function error injection skips the whole function.
*/ staticint xe_pci_probe(struct pci_dev *pdev, conststruct pci_device_id *ent)
{ conststruct xe_device_desc *desc = (constvoid *)ent->driver_data; conststruct xe_subplatform_desc *subplatform_desc; struct xe_device *xe; int err;
if (desc->require_force_probe && !id_forced(pdev->device)) {
dev_info(&pdev->dev, "Your graphics device %04x is not officially supported\n" "by xe driver in this kernel version. To force Xe probe,\n" "use xe.force_probe='%04x' and i915.force_probe='!%04x'\n" "module parameters or CONFIG_DRM_XE_FORCE_PROBE='%04x' and\n" "CONFIG_DRM_I915_FORCE_PROBE='!%04x' configuration options.\n",
pdev->device, pdev->device, pdev->device,
pdev->device, pdev->device); return -ENODEV;
}
if (id_blocked(pdev->device)) {
dev_info(&pdev->dev, "Probe blocked for device [%04x:%04x].\n",
pdev->vendor, pdev->device); return -ENODEV;
}
if (xe_display_driver_probe_defer(pdev)) return -EPROBE_DEFER;
err = pcim_enable_device(pdev); if (err) return err;
xe = xe_device_create(pdev, ent); if (IS_ERR(xe)) return PTR_ERR(xe);
err = xe_info_init_early(xe, desc, subplatform_desc); if (err) return err;
xe_vram_resize_bar(xe);
err = xe_device_probe_early(xe); /* * In Boot Survivability mode, no drm card is exposed and driver * is loaded with bare minimum to allow for firmware to be * flashed through mei. Return success, if survivability mode * is enabled due to pcode failure or configfs being set
*/ if (xe_survivability_mode_is_enabled(xe)) return 0;
if (err) return err;
err = xe_info_init(xe, desc); if (err) return err;
if (xe_survivability_mode_is_enabled(xe)) return -EBUSY;
err = xe_pm_suspend(xe); if (err) return err;
/* * Enabling D3Cold is needed for S2Idle/S0ix. * It is save to allow here since xe_pm_suspend has evicted * the local memory and the direct complete optimization is disabled.
*/
d3cold_toggle(pdev, D3COLD_ENABLE);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.