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

drm/xe: Split xe_info_init

Parts of xe_info_init are only dealing with processing driver_data.
Extract it into xe_info_init_early to be able to use it earlier during
probe.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Michał Winiarski and committed by
Rodrigo Vivi
4f5ee007 a754391f

+49 -34
+2 -1
drivers/gpu/drm/xe/tests/xe_pci.c
··· 143 143 return -ENODEV; 144 144 145 145 done: 146 - xe_info_init(xe, desc, subplatform_desc); 146 + xe_info_init_early(xe, desc, subplatform_desc); 147 + xe_info_init(xe, desc->graphics, desc->media); 147 148 148 149 return 0; 149 150 }
+47 -33
drivers/gpu/drm/xe/xe_pci.c
··· 473 473 * media is optional. 474 474 */ 475 475 static void handle_pre_gmdid(struct xe_device *xe, 476 - const struct xe_device_desc *desc, 477 - const struct xe_graphics_desc **graphics, 478 - const struct xe_media_desc **media) 476 + const struct xe_graphics_desc *graphics, 477 + const struct xe_media_desc *media) 479 478 { 480 - *graphics = desc->graphics; 481 - xe->info.graphics_verx100 = (*graphics)->ver * 100 + (*graphics)->rel; 479 + xe->info.graphics_verx100 = graphics->ver * 100 + graphics->rel; 482 480 483 - *media = desc->media; 484 - if (*media) 485 - xe->info.media_verx100 = (*media)->ver * 100 + (*media)->rel; 481 + if (media) 482 + xe->info.media_verx100 = media->ver * 100 + media->rel; 486 483 487 484 } 488 485 ··· 488 491 * based on the result. 489 492 */ 490 493 static void handle_gmdid(struct xe_device *xe, 491 - const struct xe_device_desc *desc, 492 494 const struct xe_graphics_desc **graphics, 493 495 const struct xe_media_desc **media, 494 496 u32 *graphics_revid, ··· 531 535 } 532 536 } 533 537 534 - static int xe_info_init(struct xe_device *xe, 535 - const struct xe_device_desc *desc, 536 - const struct xe_subplatform_desc *subplatform_desc) 538 + /* 539 + * Initialize device info content that only depends on static driver_data 540 + * passed to the driver at probe time from PCI ID table. 541 + */ 542 + static void xe_info_init_early(struct xe_device *xe, 543 + const struct xe_device_desc *desc, 544 + const struct xe_subplatform_desc *subplatform_desc) 537 545 { 538 - const struct xe_graphics_desc *graphics_desc = NULL; 539 - const struct xe_media_desc *media_desc = NULL; 546 + xe->info.platform = desc->platform; 547 + xe->info.subplatform = subplatform_desc ? 548 + subplatform_desc->subplatform : XE_SUBPLATFORM_NONE; 549 + 550 + xe->info.is_dgfx = desc->is_dgfx; 551 + xe->info.has_heci_gscfi = desc->has_heci_gscfi; 552 + xe->info.has_llc = desc->has_llc; 553 + xe->info.has_sriov = desc->has_sriov; 554 + xe->info.skip_mtcfg = desc->skip_mtcfg; 555 + xe->info.skip_pcode = desc->skip_pcode; 556 + xe->info.supports_mmio_ext = desc->supports_mmio_ext; 557 + xe->info.skip_guc_pc = desc->skip_guc_pc; 558 + 559 + xe->info.enable_display = IS_ENABLED(CONFIG_DRM_XE_DISPLAY) && 560 + xe_modparam.enable_display && 561 + desc->has_display; 562 + } 563 + 564 + /* 565 + * Initialize device info content that does require knowledge about 566 + * graphics / media IP version. 567 + * Make sure that GT / tile structures allocated by the driver match the data 568 + * present in device info. 569 + */ 570 + static int xe_info_init(struct xe_device *xe, 571 + const struct xe_graphics_desc *graphics_desc, 572 + const struct xe_media_desc *media_desc) 573 + { 540 574 u32 graphics_gmdid_revid = 0, media_gmdid_revid = 0; 541 575 struct xe_tile *tile; 542 576 struct xe_gt *gt; 543 577 u8 id; 544 - 545 - xe->info.platform = desc->platform; 546 - xe->info.subplatform = subplatform_desc ? 547 - subplatform_desc->subplatform : XE_SUBPLATFORM_NONE; 548 578 549 579 /* 550 580 * If this platform supports GMD_ID, we'll detect the proper IP ··· 578 556 * ever be set at this point for platforms before GMD_ID. In that case 579 557 * the IP descriptions and versions are simply derived from that. 580 558 */ 581 - if (desc->graphics) { 582 - handle_pre_gmdid(xe, desc, &graphics_desc, &media_desc); 559 + if (graphics_desc) { 560 + handle_pre_gmdid(xe, graphics_desc, media_desc); 583 561 xe->info.step = xe_step_pre_gmdid_get(xe); 584 562 } else { 585 - handle_gmdid(xe, desc, &graphics_desc, &media_desc, 563 + xe_assert(xe, !media_desc); 564 + handle_gmdid(xe, &graphics_desc, &media_desc, 586 565 &graphics_gmdid_revid, &media_gmdid_revid); 587 566 xe->info.step = xe_step_gmdid_get(xe, 588 567 graphics_gmdid_revid, ··· 598 575 if (!graphics_desc) 599 576 return -ENODEV; 600 577 601 - xe->info.is_dgfx = desc->is_dgfx; 602 - xe->info.has_heci_gscfi = desc->has_heci_gscfi; 603 578 xe->info.graphics_name = graphics_desc->name; 604 579 xe->info.media_name = media_desc ? media_desc->name : "none"; 605 - xe->info.has_llc = desc->has_llc; 606 - xe->info.has_sriov = desc->has_sriov; 607 - xe->info.skip_mtcfg = desc->skip_mtcfg; 608 - xe->info.skip_pcode = desc->skip_pcode; 609 - xe->info.supports_mmio_ext = desc->supports_mmio_ext; 610 580 xe->info.tile_mmio_ext_size = graphics_desc->tile_mmio_ext_size; 611 581 612 582 xe->info.dma_mask_size = graphics_desc->dma_mask_size; ··· 610 594 xe->info.has_asid = graphics_desc->has_asid; 611 595 xe->info.has_flat_ccs = graphics_desc->has_flat_ccs; 612 596 xe->info.has_range_tlb_invalidation = graphics_desc->has_range_tlb_invalidation; 613 - xe->info.skip_guc_pc = desc->skip_guc_pc; 614 597 615 - xe->info.enable_display = IS_ENABLED(CONFIG_DRM_XE_DISPLAY) && 616 - xe_modparam.enable_display && 617 - desc->has_display; 618 598 /* 619 599 * All platforms have at least one primary GT. Any platform with media 620 600 * version 13 or higher has an additional dedicated media GT. And ··· 723 711 724 712 pci_set_master(pdev); 725 713 714 + xe_info_init_early(xe, desc, subplatform_desc); 715 + 726 716 xe_sriov_probe_early(xe, desc->has_sriov); 727 717 728 - err = xe_info_init(xe, desc, subplatform_desc); 718 + err = xe_info_init(xe, desc->graphics, desc->media); 729 719 if (err) 730 720 return err; 731 721