@@ -57,12 +57,35 @@ bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe)
5757 return GRAPHICS_VERx100 (xe ) < 1270 && !IS_DGFX (xe );
5858}
5959
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+
6083static s64 detect_bar2_dgfx (struct xe_device * xe , struct xe_ttm_stolen_mgr * mgr )
6184{
6285 struct xe_tile * tile = xe_device_get_root_tile (xe );
6386 struct xe_mmio * mmio = xe_root_tile_mmio (xe );
6487 struct pci_dev * pdev = to_pci_dev (xe -> drm .dev );
65- u64 stolen_size ;
88+ u64 stolen_size , wopcm_size ;
6689 u64 tile_offset ;
6790 u64 tile_size ;
6891
@@ -74,7 +97,13 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
7497 if (drm_WARN_ON (& xe -> drm , tile_size < mgr -> stolen_base ))
7598 return 0 ;
7699
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+
77105 stolen_size = tile_size - mgr -> stolen_base ;
106+ stolen_size -= wopcm_size ;
78107
79108 /* Verify usage fits in the actual resource available */
80109 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)
89118 return ALIGN_DOWN (stolen_size , SZ_1M );
90119}
91120
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-
115121static u32 detect_bar2_integrated (struct xe_device * xe , struct xe_ttm_stolen_mgr * mgr )
116122{
117123 struct pci_dev * pdev = to_pci_dev (xe -> drm .dev );
0 commit comments