drm/xe: Separate engine fuse handling into dedicated functions
Subsystems (2)
PATCH v2 1/2 drm/xe: Separate engine fuse handling into dedicated functions
The single function to handle fuse registers for all types of engines is becoming a bit long and hard to follow (and we haven't even added the compute engines yet). Let's split it into dedicated functions for each engine class.
v2:
- Add note about BCS0 always being present. (Bala)
- Add forcewake assertion to read_copy_fuses. (Bala)
--- drivers/gpu/drm/xe/xe_hw_engine.c | 37 +++++++++++++++++++------------ 1 file changed, 23 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/xe_hw_engine.c +23 -14
@@ -369,29 +369,29 @@ static void hw_engine_setup_logical_mapping(struct xe_gt *gt) } } -static void read_fuses (struct xe_gt *gt) +static void read_media_fuses (struct xe_gt *gt) {struct xe_device *xe =gt_to_xe (gt);u32 media_fuse;u16 vdbox_mask;u16 vebox_mask; -u32 bcs_mask;int i, j;xe_force_wake_assert_held (gt_to_fw (gt),XE_FW_GT ); + media_fuse =xe_mmio_read32 (gt,GEN11_GT_VEBOX_VDBOX_DISABLE .reg); +/* -* FIXME: Hack job, thinking we should have table of vfuncs for each -* class which picks the correct vfunc based on IP version. +* Pre-Xe_HP platforms had register bits representing absent engines, +* whereas Xe_HP and beyond have bits representing present engines. +* Invert the polarity on old platforms so that we can use common +* handling below. */ - - media_fuse =xe_mmio_read32 (gt,GEN11_GT_VEBOX_VDBOX_DISABLE .reg);if (GRAPHICS_VERx100 (xe) <1250 ) media_fuse = ~media_fuse; - vdbox_mask = media_fuse &GEN11_GT_VDBOX_DISABLE_MASK ; - vebox_mask = (media_fuse &GEN11_GT_VEBOX_DISABLE_MASK ) >> -GEN11_GT_VEBOX_DISABLE_SHIFT ; + vdbox_mask =REG_FIELD_GET (GEN11_GT_VDBOX_DISABLE_MASK , media_fuse); + vebox_mask =REG_FIELD_GET (GEN11_GT_VEBOX_DISABLE_MASK , media_fuse);for (i =XE_HW_ENGINE_VCS0 , j =0 ; i <=XE_HW_ENGINE_VCS7 ; ++i, ++j) {if (!(gt->info.engine_mask &BIT (i)))
@@ -412,28 +412,37 @@ static void read_fuses(struct xe_gt *gt)drm_info (&xe->drm,"vecs%u fused off\n" , j); } } +} + +static void read_copy_fuses (struct xe_gt *gt) +{ +struct xe_device *xe =gt_to_xe (gt); +u32 bcs_mask; + +xe_force_wake_assert_held (gt_to_fw (gt),XE_FW_GT ); bcs_mask =xe_mmio_read32 (gt,GEN10_MIRROR_FUSE3 .reg); bcs_mask =REG_FIELD_GET (GEN12_MEML3_EN_MASK , bcs_mask); -for (i =XE_HW_ENGINE_BCS1 , j =0 ; i <=XE_HW_ENGINE_BCS8 ; ++i, ++j) { +/* BCS0 is always present; only BCS1-BCS8 may be fused off */ +for (int i =XE_HW_ENGINE_BCS1 , j =0 ; i <=XE_HW_ENGINE_BCS8 ; ++i, ++j) {if (!(gt->info.engine_mask &BIT (i)))continue ; -if (!(BIT (j/2 ) & bcs_mask)) { +if (!(BIT (j /2 ) & bcs_mask)) { gt->info.engine_mask &= ~BIT (i);drm_info (&xe->drm,"bcs%u fused off\n" , j); } } - -/* TODO: compute engines */ }int xe_hw_engines_init_early (struct xe_gt *gt) {int i; -read_fuses (gt); +read_media_fuses (gt); +read_copy_fuses (gt); +/* TODO: compute engines */ for (i =0 ; i <ARRAY_SIZE (gt->hw_engines); i++)hw_engine_init_early (gt, >->hw_engines[i], i);
Signature · 1 line
2.39.2
PATCH v2 2/2 drm/xe: Add support for CCS engine fusing
For Xe_HP platforms that can have multiple CCS engines, the presence/absence of each CCS is inferred by the presence/absence of any DSS in the corresponding quadrant of the GT's DSS mask.
This handling is only needed on platforms that can have more than one CCS. The CCS is never fused off on platforms like MTL that can only have one.
v2:
- Add extra warnings to try to catch mistakes where the register counts in get_num_dss_regs() are updated without corresponding updates to the register parameters passed to load_dss_mask(). (Lucas)
- Add kerneldoc for xe_gt_topology_has_dss_in_quadrant() and clarify why we care about quadrants of the DSS space. (Lucas)
- Ensure CCS engine counting treats engine mask as 64-bit. (Lucas)
--- drivers/gpu/drm/xe/xe_gt_topology.c | 65 ++++++++++++++++++++++++----- drivers/gpu/drm/xe/xe_gt_topology.h | 3 ++ drivers/gpu/drm/xe/xe_hw_engine.c | 29 ++++++++++++- 3 files changed, 85 insertions(+), 12 deletions(-)
drivers/gpu/drm/xe/xe_gt_topology.c +54 -11
@@ -62,6 +62,21 @@ load_eu_mask(struct xe_gt *gt, xe_eu_mask_t mask)bitmap_from_arr32 (mask, &val,XE_MAX_EU_FUSE_BITS ); } +static void +get_num_dss_regs (struct xe_device *xe,int *geometry_regs,int *compute_regs) +{ +if (GRAPHICS_VERx100 (xe) ==1260 ) { + *geometry_regs =0 ; + *compute_regs =2 ; + }else if (GRAPHICS_VERx100 (xe) >=1250 ) { + *geometry_regs =1 ; + *compute_regs =1 ; + }else { + *geometry_regs =1 ; + *compute_regs =0 ; + } +} +void xe_gt_topology_init (struct xe_gt *gt) {
@@ -69,18 +84,17 @@ xe_gt_topology_init(struct xe_gt *gt)struct drm_printer p =drm_debug_printer ("GT topology" );int num_geometry_regs, num_compute_regs; -if (GRAPHICS_VERx100 (xe) ==1260 ) { - num_geometry_regs =0 ; - num_compute_regs =2 ; - }else if (GRAPHICS_VERx100 (xe) >=1250 ) { - num_geometry_regs =1 ; - num_compute_regs =1 ; - }else { - num_geometry_regs =1 ; - num_compute_regs =0 ; - } +get_num_dss_regs (xe, &num_geometry_regs, &num_compute_regs); -load_dss_mask (gt, gt->fuse_topo.g_dss_mask, num_geometry_regs, +/* +* Register counts returned shouldn't exceed the number of registers +* passed as parameters below. +*/ +drm_WARN_ON (&xe->drm, num_geometry_regs >1 ); +drm_WARN_ON (&xe->drm, num_compute_regs >2 ); + +load_dss_mask (gt, gt->fuse_topo.g_dss_mask, + num_geometry_regs,XELP_GT_GEOMETRY_DSS_ENABLE .reg); load_dss_mask(gt, gt->fuse_topo.c_dss_mask, num_compute_regs, XEHP_GT_COMPUTE_DSS_ENABLE.reg,
@@ -113,3 +127,32 @@ xe_dss_mask_group_ffs(xe_dss_mask_t mask, int groupsize, int groupnum) {return find_next_bit (mask,XE_MAX_DSS_FUSE_BITS , groupnum * groupsize); } + +/** +* xe_gt_topology_has_dss_in_quadrant - check fusing of DSS in GT quadrant +* @gt: GT to check +* @quad: Which quadrant of the DSS space to check +* +* Since Xe_HP platforms can have up to four CCS engines, those engines +* are each logically associated with a quarter of the possible DSS. If there +* are no DSS present in one of the four quadrants of the DSS space, the +* corresponding CCS engine is also not available for use. +* +* Returns false if all DSS in a quadrant of the GT are fused off, else true. +*/ +bool xe_gt_topology_has_dss_in_quadrant (struct xe_gt *gt,int quad) +{ +struct xe_device *xe =gt_to_xe (gt); +xe_dss_mask_t all_dss; +int g_dss_regs, c_dss_regs, dss_per_quad, quad_first; + +bitmap_or (all_dss, gt->fuse_topo.g_dss_mask, gt->fuse_topo.c_dss_mask, +XE_MAX_DSS_FUSE_BITS ); + +get_num_dss_regs (xe, &g_dss_regs, &c_dss_regs); + dss_per_quad =32 *max (g_dss_regs, c_dss_regs) /4 ; + + quad_first =xe_dss_mask_group_ffs (all_dss, dss_per_quad, quad); + +return quad_first < (quad +1 ) * dss_per_quad; +}
drivers/gpu/drm/xe/xe_gt_topology.h +3 -0
@@ -17,4 +17,7 @@ void xe_gt_topology_dump(struct xe_gt *gt, struct drm_printer *p);unsigned int xe_dss_mask_group_ffs (xe_dss_mask_t mask,int groupsize,int groupnum); +bool +xe_gt_topology_has_dss_in_quadrant (struct xe_gt *gt,int quad); +#endif /* _XE_GT_TOPOLOGY_H_ */
drivers/gpu/drm/xe/xe_hw_engine.c +28 -1
@@ -436,13 +436,40 @@ static void read_copy_fuses(struct xe_gt *gt) } } +static void read_compute_fuses (struct xe_gt *gt) +{ +struct xe_device *xe =gt_to_xe (gt); + +/* +* CCS fusing based on DSS masks only applies to platforms that can +* have more than one CCS. +*/ +if (hweight64 (gt->info.engine_mask & +GENMASK_ULL (XE_HW_ENGINE_CCS3 ,XE_HW_ENGINE_CCS0 )) <=1 ) +return ; + +/* +* CCS availability on Xe_HP is inferred from the presence of DSS in +* each quadrant. +*/ +for (int i =XE_HW_ENGINE_CCS0 , j =0 ; i <=XE_HW_ENGINE_CCS3 ; ++i, ++j) { +if (!(gt->info.engine_mask &BIT (i))) +continue ; + +if (!xe_gt_topology_has_dss_in_quadrant (gt, j)) { + gt->info.engine_mask &= ~BIT (i); +drm_info (&xe->drm,"ccs%u fused off\n" , j); + } + } +} +int xe_hw_engines_init_early (struct xe_gt *gt) {int i;read_media_fuses (gt);read_copy_fuses (gt); -/* TODO: compute engines */ +read_compute_fuses (gt);for (i =0 ; i <ARRAY_SIZE (gt->hw_engines); i++)hw_engine_init_early (gt, >->hw_engines[i], i);
Signature · 1 line
2.39.2
Re: [Intel-xe] [PATCH v2 2/2] drm/xe: Add support for CCS engine fusing
Quoted 16 lines · Matt Roper
For
Xe_HPplatforms that can have multiple CCS engines, the presence/absence of each CCS is inferred by the presence/absence of any DSS in the corresponding quadrant of the GT's DSS mask.This handling is only needed on platforms that can have more than one CCS. The CCS is never fused off on platforms like MTL that can only have one.
v2:
- Add extra warnings to try to catch mistakes where the register counts inget_num_dss_regs()are updated without corresponding updates to the register parameters passed toload_dss_mask(). (Lucas)
- Add kerneldoc forxe_gt_topology_has_dss_in_quadrant()and clarify why we care about quadrants of the DSS space. (Lucas)
- Ensure CCS engine counting treats engine mask as 64-bit. (Lucas)
Quoted 2 lines
Cc Lucas De Marchi <[email protected]>Signed-off-by Matt Roper <[email protected]>
thanks
Lucas De Marchi
[Intel-xe] ✗ CI.Patch_applied: failure for series starting with [v2,1/2] drm/xe: Separate engine fuse handling into dedicated functions
In reply to Matt Roper== Series Details ==
== Series Details ==
Series: series starting with [v2,1/2] drm/xe: Separate engine fuse handling into dedicated functions
URL : https://patchwork.freedesktop.org/series/114881/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-xe-next' with base: === commit 91440895e3fe91928c6e8a682e87d2b8ca677d82
Author: Lucas De Marchi <[email protected]> AuthorDate: Wed Mar 1 01:31:12 2023 -0800 Commit: Lucas De Marchi <[email protected]> CommitDate: Fri Mar 10 13:52:30 2023 -0800
drm/xe/pvc: Remove A* steppings
The PVC pre-production A* steppings are not going to be supported in xe driver - the steppings are important for the WAs and since we are not adding the pre-productions ones, there is no need to add the stepping.
=== git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_hw_engine.c:369
error: drivers/gpu/drm/xe/xe_hw_engine.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: drm/xe: Separate engine fuse handling into dedicated functions Patch failed at 0001 drm/xe: Separate engine fuse handling into dedicated functions When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".