Skip to content

Commit 9ab440a

Browse files
shekhar-chauhanmattrope
authored andcommitted
drm/xe/ptl: L3bank mask is not available on the media GT
On PTL platforms with media version 30.00, the fuse registers for reporting L3 bank availability to the GT just read out as ~0 and do not provide proper values. Xe does not use the L3 bank mask for anything internally; it only passes the mask through to userspace via the GT topology query. Since we don't have any way to get the real L3 bank mask, we don't want to pass garbage to userspace. Passing a zeroed mask or a copy of the primary GT's L3 bank mask would also be inaccurate and likely to cause confusion for userspace. The best approach is to simply not include L3 in the list of masks returned by the topology query in cases where we aren't able to provide a meaningful value. This won't change the behavior for any existing platforms (where we can always obtain L3 masks successfully for all GTs), it will only prevent us from mis-reporting bad information on upcoming platform(s). There's a good chance this will become a formal workaround in the future, but for now we don't have a lineage number so "no_media_l3" is used in place of a lineage as the OOB workaround descriptor. v2: - Re-calculate query size to properly match data returned. (Gustavo) - Update kerneldoc to clarify that the L3bank mask may not be included in the query results if the hardware doesn't make it available. (Gustavo) Cc: Matt Atwood <[email protected]> Cc: Gustavo Sousa <[email protected]> Signed-off-by: Shekhar Chauhan <[email protected]> Co-developed-by: Matt Roper <[email protected]> Signed-off-by: Matt Roper <[email protected]> Reviewed-by: Jonathan Cavitt <[email protected]> Reviewed-by: Gustavo Sousa <[email protected]> Acked-by: Francois Dugast <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 691b5a6 commit 9ab440a

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

drivers/gpu/drm/xe/xe_gt_topology.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
#include "xe_gt_topology.h"
77

8+
#include <generated/xe_wa_oob.h>
89
#include <linux/bitmap.h>
910
#include <linux/compiler.h>
1011

1112
#include "regs/xe_gt_regs.h"
1213
#include "xe_assert.h"
1314
#include "xe_gt.h"
1415
#include "xe_mmio.h"
16+
#include "xe_wa.h"
1517

1618
static void
1719
load_dss_mask(struct xe_gt *gt, xe_dss_mask_t mask, int numregs, ...)
@@ -129,6 +131,18 @@ load_l3_bank_mask(struct xe_gt *gt, xe_l3_bank_mask_t l3_bank_mask)
129131
struct xe_device *xe = gt_to_xe(gt);
130132
u32 fuse3 = xe_mmio_read32(&gt->mmio, MIRROR_FUSE3);
131133

134+
/*
135+
* PTL platforms with media version 30.00 do not provide proper values
136+
* for the media GT's L3 bank registers. Skip the readout since we
137+
* don't have any way to obtain real values.
138+
*
139+
* This may get re-described as an official workaround in the future,
140+
* but there's no tracking number assigned yet so we use a custom
141+
* OOB workaround descriptor.
142+
*/
143+
if (XE_WA(gt, no_media_l3))
144+
return;
145+
132146
if (GRAPHICS_VER(xe) >= 20) {
133147
xe_l3_bank_mask_t per_node = {};
134148
u32 meml3_en = REG_FIELD_GET(XE2_NODE_ENABLE_MASK, fuse3);

drivers/gpu/drm/xe/xe_query.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/sched/clock.h>
1010

1111
#include <drm/ttm/ttm_placement.h>
12+
#include <generated/xe_wa_oob.h>
1213
#include <uapi/drm/xe_drm.h>
1314

1415
#include "regs/xe_engine_regs.h"
@@ -23,6 +24,7 @@
2324
#include "xe_macros.h"
2425
#include "xe_mmio.h"
2526
#include "xe_ttm_vram_mgr.h"
27+
#include "xe_wa.h"
2628

2729
static const u16 xe_to_user_engine_class[] = {
2830
[XE_ENGINE_CLASS_RENDER] = DRM_XE_ENGINE_CLASS_RENDER,
@@ -455,12 +457,23 @@ static int query_hwconfig(struct xe_device *xe,
455457

456458
static size_t calc_topo_query_size(struct xe_device *xe)
457459
{
458-
return xe->info.gt_count *
459-
(4 * sizeof(struct drm_xe_query_topology_mask) +
460-
sizeof_field(struct xe_gt, fuse_topo.g_dss_mask) +
461-
sizeof_field(struct xe_gt, fuse_topo.c_dss_mask) +
462-
sizeof_field(struct xe_gt, fuse_topo.l3_bank_mask) +
463-
sizeof_field(struct xe_gt, fuse_topo.eu_mask_per_dss));
460+
struct xe_gt *gt;
461+
size_t query_size = 0;
462+
int id;
463+
464+
for_each_gt(gt, xe, id) {
465+
query_size += 3 * sizeof(struct drm_xe_query_topology_mask) +
466+
sizeof_field(struct xe_gt, fuse_topo.g_dss_mask) +
467+
sizeof_field(struct xe_gt, fuse_topo.c_dss_mask) +
468+
sizeof_field(struct xe_gt, fuse_topo.eu_mask_per_dss);
469+
470+
/* L3bank mask may not be available for some GTs */
471+
if (!XE_WA(gt, no_media_l3))
472+
query_size += sizeof(struct drm_xe_query_topology_mask) +
473+
sizeof_field(struct xe_gt, fuse_topo.l3_bank_mask);
474+
}
475+
476+
return query_size;
464477
}
465478

466479
static int copy_mask(void __user **ptr,
@@ -513,11 +526,18 @@ static int query_gt_topology(struct xe_device *xe,
513526
if (err)
514527
return err;
515528

516-
topo.type = DRM_XE_TOPO_L3_BANK;
517-
err = copy_mask(&query_ptr, &topo, gt->fuse_topo.l3_bank_mask,
518-
sizeof(gt->fuse_topo.l3_bank_mask));
519-
if (err)
520-
return err;
529+
/*
530+
* If the kernel doesn't have a way to obtain a correct L3bank
531+
* mask, then it's better to omit L3 from the query rather than
532+
* reporting bogus or zeroed information to userspace.
533+
*/
534+
if (!XE_WA(gt, no_media_l3)) {
535+
topo.type = DRM_XE_TOPO_L3_BANK;
536+
err = copy_mask(&query_ptr, &topo, gt->fuse_topo.l3_bank_mask,
537+
sizeof(gt->fuse_topo.l3_bank_mask));
538+
if (err)
539+
return err;
540+
}
521541

522542
topo.type = gt->fuse_topo.eu_type == XE_GT_EU_TYPE_SIMD16 ?
523543
DRM_XE_TOPO_SIMD16_EU_PER_DSS :

drivers/gpu/drm/xe/xe_wa_oob.rules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737
16023588340 GRAPHICS_VERSION(2001)
3838
14019789679 GRAPHICS_VERSION(1255)
3939
GRAPHICS_VERSION_RANGE(1270, 2004)
40+
no_media_l3 MEDIA_VERSION(3000)

include/uapi/drm/xe_drm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,9 @@ struct drm_xe_query_gt_list {
512512
* containing the following in mask:
513513
* ``DSS_COMPUTE ff ff ff ff 00 00 00 00``
514514
* means 32 DSS are available for compute.
515-
* - %DRM_XE_TOPO_L3_BANK - To query the mask of enabled L3 banks
515+
* - %DRM_XE_TOPO_L3_BANK - To query the mask of enabled L3 banks. This type
516+
* may be omitted if the driver is unable to query the mask from the
517+
* hardware.
516518
* - %DRM_XE_TOPO_EU_PER_DSS - To query the mask of Execution Units (EU)
517519
* available per Dual Sub Slices (DSS). For example a query response
518520
* containing the following in mask:

0 commit comments

Comments
 (0)