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

drm/xe: Extract function to initialize xe->info

Extract the part setting up from xe->info from xe_pci_probe() into its
own function. This pairs nicely with the display counterpart, avoids
info initialization to be placed elsewhere and helps future
improvements to build fake devices for tests.

While at it, normalize the names a little bit: the _get() suffix may be
mistaken by lock-related operation, so rename the function to
"find_subplatform()". Also rename the variable to subplatform_desc to
make it easier to understand, even if longer.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20230401085151.1786204-2-lucas.demarchi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Lucas De Marchi and committed by
Rodrigo Vivi
d19ad0e8 b73d520b

+54 -44
+54 -44
drivers/gpu/drm/xe/xe_pci.c
··· 343 343 } 344 344 345 345 static const struct xe_subplatform_desc * 346 - subplatform_get(const struct xe_device *xe, const struct xe_device_desc *desc) 346 + find_subplatform(const struct xe_device *xe, const struct xe_device_desc *desc) 347 347 { 348 348 const struct xe_subplatform_desc *sp; 349 349 const u16 *id; ··· 356 356 return NULL; 357 357 } 358 358 359 - static void xe_pci_remove(struct pci_dev *pdev) 359 + static void xe_info_init(struct xe_device *xe, 360 + const struct xe_device_desc *desc, 361 + const struct xe_subplatform_desc *subplatform_desc) 360 362 { 361 - struct xe_device *xe; 362 - 363 - xe = pci_get_drvdata(pdev); 364 - if (!xe) /* driver load aborted, nothing to cleanup */ 365 - return; 366 - 367 - xe_device_remove(xe); 368 - xe_pm_runtime_fini(xe); 369 - pci_set_drvdata(pdev, NULL); 370 - } 371 - 372 - static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 373 - { 374 - const struct xe_device_desc *desc = (void *)ent->driver_data; 375 - const struct xe_subplatform_desc *spd; 376 - struct xe_device *xe; 377 363 struct xe_gt *gt; 378 364 u8 id; 379 - int err; 380 - 381 - if (desc->require_force_probe && !id_forced(pdev->device)) { 382 - dev_info(&pdev->dev, 383 - "Your graphics device %04x is not officially supported\n" 384 - "by xe driver in this kernel version. To force Xe probe,\n" 385 - "use xe.force_probe='%04x' and i915.force_probe='!%04x'\n" 386 - "module parameters or CONFIG_DRM_XE_FORCE_PROBE='%04x' and\n" 387 - "CONFIG_DRM_I915_FORCE_PROBE='!%04x' configuration options.\n", 388 - pdev->device, pdev->device, pdev->device, 389 - pdev->device, pdev->device); 390 - return -ENODEV; 391 - } 392 - 393 - if (id_blocked(pdev->device)) { 394 - dev_info(&pdev->dev, "Probe blocked for device [%04x:%04x].\n", 395 - pdev->vendor, pdev->device); 396 - return -ENODEV; 397 - } 398 - 399 - xe = xe_device_create(pdev, ent); 400 - if (IS_ERR(xe)) 401 - return PTR_ERR(xe); 402 365 403 366 xe->info.graphics_verx100 = desc->graphics_ver * 100 + 404 367 desc->graphics_rel; ··· 380 417 xe->info.has_range_tlb_invalidation = desc->has_range_tlb_invalidation; 381 418 xe->info.has_link_copy_engine = desc->has_link_copy_engine; 382 419 383 - spd = subplatform_get(xe, desc); 384 - xe->info.subplatform = spd ? spd->subplatform : XE_SUBPLATFORM_NONE; 420 + xe->info.subplatform = subplatform_desc ? 421 + subplatform_desc->subplatform : XE_SUBPLATFORM_NONE; 385 422 xe->info.step = xe_step_get(xe); 386 423 387 424 for (id = 0; id < xe->info.tile_count; ++id) { ··· 406 443 desc->extra_gts[id - 1].mmio_adj_offset; 407 444 } 408 445 } 446 + } 409 447 448 + static void xe_pci_remove(struct pci_dev *pdev) 449 + { 450 + struct xe_device *xe; 451 + 452 + xe = pci_get_drvdata(pdev); 453 + if (!xe) /* driver load aborted, nothing to cleanup */ 454 + return; 455 + 456 + xe_device_remove(xe); 457 + xe_pm_runtime_fini(xe); 458 + pci_set_drvdata(pdev, NULL); 459 + } 460 + 461 + static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 462 + { 463 + const struct xe_device_desc *desc = (void *)ent->driver_data; 464 + const struct xe_subplatform_desc *subplatform_desc; 465 + struct xe_device *xe; 466 + int err; 467 + 468 + if (desc->require_force_probe && !id_forced(pdev->device)) { 469 + dev_info(&pdev->dev, 470 + "Your graphics device %04x is not officially supported\n" 471 + "by xe driver in this kernel version. To force Xe probe,\n" 472 + "use xe.force_probe='%04x' and i915.force_probe='!%04x'\n" 473 + "module parameters or CONFIG_DRM_XE_FORCE_PROBE='%04x' and\n" 474 + "CONFIG_DRM_I915_FORCE_PROBE='!%04x' configuration options.\n", 475 + pdev->device, pdev->device, pdev->device, 476 + pdev->device, pdev->device); 477 + return -ENODEV; 478 + } 479 + 480 + if (id_blocked(pdev->device)) { 481 + dev_info(&pdev->dev, "Probe blocked for device [%04x:%04x].\n", 482 + pdev->vendor, pdev->device); 483 + return -ENODEV; 484 + } 485 + 486 + xe = xe_device_create(pdev, ent); 487 + if (IS_ERR(xe)) 488 + return PTR_ERR(xe); 489 + 490 + subplatform_desc = find_subplatform(xe, desc); 491 + 492 + xe_info_init(xe, desc, subplatform_desc); 410 493 drm_dbg(&xe->drm, "%s %s %04x:%04x dgfx:%d gfx100:%d media100:%d dma_m_s:%d tc:%d", 411 - desc->platform_name, spd ? spd->name : "", 494 + desc->platform_name, 495 + subplatform_desc ? subplatform_desc->name : "", 412 496 xe->info.devid, xe->info.revid, 413 497 xe->info.is_dgfx, xe->info.graphics_verx100, 414 498 xe->info.media_verx100,