@@ -57,12 +57,35 @@ bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe)
57
57
return GRAPHICS_VERx100 (xe ) < 1270 && !IS_DGFX (xe );
58
58
}
59
59
60
+ static u32 get_wopcm_size (struct xe_device * xe )
61
+ {
62
+ u32 wopcm_size ;
63
+ u64 val ;
64
+
65
+ val = xe_mmio_read64_2x32 (xe_root_tile_mmio (xe ), STOLEN_RESERVED );
66
+ val = REG_FIELD_GET64 (WOPCM_SIZE_MASK , val );
67
+
68
+ switch (val ) {
69
+ case 0x5 ... 0x6 :
70
+ val -- ;
71
+ fallthrough ;
72
+ case 0x0 ... 0x3 :
73
+ wopcm_size = (1U << val ) * SZ_1M ;
74
+ break ;
75
+ default :
76
+ WARN (1 , "Missing case wopcm_size=%llx\n" , val );
77
+ wopcm_size = 0 ;
78
+ }
79
+
80
+ return wopcm_size ;
81
+ }
82
+
60
83
static s64 detect_bar2_dgfx (struct xe_device * xe , struct xe_ttm_stolen_mgr * mgr )
61
84
{
62
85
struct xe_tile * tile = xe_device_get_root_tile (xe );
63
86
struct xe_mmio * mmio = xe_root_tile_mmio (xe );
64
87
struct pci_dev * pdev = to_pci_dev (xe -> drm .dev );
65
- u64 stolen_size ;
88
+ u64 stolen_size , wopcm_size ;
66
89
u64 tile_offset ;
67
90
u64 tile_size ;
68
91
@@ -74,7 +97,13 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
74
97
if (drm_WARN_ON (& xe -> drm , tile_size < mgr -> stolen_base ))
75
98
return 0 ;
76
99
100
+ /* Carve out the top of DSM as it contains the reserved WOPCM region */
101
+ wopcm_size = get_wopcm_size (xe );
102
+ if (drm_WARN_ON (& xe -> drm , !wopcm_size ))
103
+ return 0 ;
104
+
77
105
stolen_size = tile_size - mgr -> stolen_base ;
106
+ stolen_size -= wopcm_size ;
78
107
79
108
/* Verify usage fits in the actual resource available */
80
109
if (mgr -> stolen_base + stolen_size <= pci_resource_len (pdev , LMEM_BAR ))
@@ -89,29 +118,6 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
89
118
return ALIGN_DOWN (stolen_size , SZ_1M );
90
119
}
91
120
92
- static u32 get_wopcm_size (struct xe_device * xe )
93
- {
94
- u32 wopcm_size ;
95
- u64 val ;
96
-
97
- val = xe_mmio_read64_2x32 (xe_root_tile_mmio (xe ), STOLEN_RESERVED );
98
- val = REG_FIELD_GET64 (WOPCM_SIZE_MASK , val );
99
-
100
- switch (val ) {
101
- case 0x5 ... 0x6 :
102
- val -- ;
103
- fallthrough ;
104
- case 0x0 ... 0x3 :
105
- wopcm_size = (1U << val ) * SZ_1M ;
106
- break ;
107
- default :
108
- WARN (1 , "Missing case wopcm_size=%llx\n" , val );
109
- wopcm_size = 0 ;
110
- }
111
-
112
- return wopcm_size ;
113
- }
114
-
115
121
static u32 detect_bar2_integrated (struct xe_device * xe , struct xe_ttm_stolen_mgr * mgr )
116
122
{
117
123
struct pci_dev * pdev = to_pci_dev (xe -> drm .dev );
0 commit comments