Skip to content

Commit 0138fe9

Browse files
committed
BACKPORT: FROMLIST: drm/xe/guc: use SZ_4K for alignment
Per the "Firmware" chapter in "drm/xe Intel GFX Driver", as well as "Volume 8: Command Stream Programming" in "Intel® Arc™ A-Series Graphics and Intel Data Center GPU Flex Series Open-Source Programmer's Reference Manual For the discrete GPUs code named "Alchemist" and "Arctic Sound-M"" and "Intel® Iris® Xe MAX Graphics Open Source Programmer's Reference Manual For the 2020 Discrete GPU formerly named "DG1"": "The RINGBUF register sets (defined in Memory Interface Registers) are used to specify the ring buffer memory areas. The ring buffer must start on a 4KB boundary and be allocated in linear memory. The length of any one ring buffer is limited to 2MB." The Graphics micro (μ) Controller (GuC) really expects command buffers aligned to 4K boundaries. Current code uses `PAGE_SIZE' as an assumed alignment reference but 4K kernel page sizes is by no means a guarantee. On 16K-paged kernels, this causes driver failures after loading the GuC firmware: [ 7.398317] xe 0000:09:00.0: [drm] Found dg2/g10 (device ID 56a1) display version 13.00 stepping C0 [ 7.410429] xe 0000:09:00.0: [drm] Using GuC firmware from i915/dg2_guc_70.bin version 70.36.0 [ 10.719989] xe 0000:09:00.0: [drm] *ERROR* GT0: load failed: status = 0x800001EC, time = 3297ms, freq = 2400MHz (req 2400MHz), done = 0 [ 10.732106] xe 0000:09:00.0: [drm] *ERROR* GT0: load failed: status: Reset = 0, BootROM = 0x76, UKernel = 0x01, MIA = 0x00, Auth = 0x02 [ 10.744214] xe 0000:09:00.0: [drm] *ERROR* CRITICAL: Xe has declared device 0000:09:00.0 as wedged. Please file a _new_ bug report at https://gitlab.freedesktop.org/drm/xe/kernel/issues/new [ 10.828908] xe 0000:09:00.0: [drm] *ERROR* GT0: GuC mmio request 0x4100: no reply 0x4100 Correct this by revising all instances of `PAGE_SIZE' to `SZ_4K' and revise `PAGE_ALIGN()' calls to `ALIGN()' with `SZ_4K' as the second argument (overriding `PAGE_SIZE'). Cc: [email protected] Fixes: 84d15f4 ("drm/xe/guc: Add capture size check in GuC log buffer") Fixes: 9c8c7a7 ("drm/xe/guc: Prepare GuC register list and update ADS size for error capture") Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Tested-by: Mingcong Bai <[email protected]> Tested-by: Haien Liang <[email protected]> Tested-by: Shirong Liu <[email protected]> Tested-by: Haofeng Wu <[email protected]> Link: FanFansfan@22c55ab Co-developed-by: Shang Yatsen <[email protected]> Signed-off-by: Shang Yatsen <[email protected]> Co-developed-by: Kexy Biscuit <[email protected]> Signed-off-by: Kexy Biscuit <[email protected]> Signed-off-by: Mingcong Bai <[email protected]> Reviewed-by: Matthew Brost <[email protected]> [Mingcong Bai: Resolved a minor merge conflict post-6.16 in drivers/gpu/drm/xe/xe_guc_ads.c] [Mingcong Bai: Resolved a minor merge conflict since 6.18 in drivers/gpu/drm/xe/xe_guc.c.] Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Mingcong Bai <[email protected]>
1 parent f835331 commit 0138fe9

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

drivers/gpu/drm/xe/xe_guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static u32 guc_ctl_feature_flags(struct xe_guc *guc)
9595

9696
static u32 guc_ctl_log_params_flags(struct xe_guc *guc)
9797
{
98-
u32 offset = guc_bo_ggtt_addr(guc, guc->log.bo) >> PAGE_SHIFT;
98+
u32 offset = guc_bo_ggtt_addr(guc, guc->log.bo) >> XE_PTE_SHIFT;
9999
u32 flags;
100100

101101
#if (((CRASH_BUFFER_SIZE) % SZ_1M) == 0)
@@ -140,7 +140,7 @@ static u32 guc_ctl_log_params_flags(struct xe_guc *guc)
140140

141141
static u32 guc_ctl_ads_flags(struct xe_guc *guc)
142142
{
143-
u32 ads = guc_bo_ggtt_addr(guc, guc->ads.bo) >> PAGE_SHIFT;
143+
u32 ads = guc_bo_ggtt_addr(guc, guc->ads.bo) >> XE_PTE_SHIFT;
144144
u32 flags = FIELD_PREP(GUC_ADS_ADDR, ads);
145145

146146
return flags;

drivers/gpu/drm/xe/xe_guc_ads.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ static size_t guc_ads_regset_size(struct xe_guc_ads *ads)
144144

145145
static size_t guc_ads_golden_lrc_size(struct xe_guc_ads *ads)
146146
{
147-
return PAGE_ALIGN(ads->golden_lrc_size);
147+
return ALIGN(ads->golden_lrc_size, SZ_4K);
148148
}
149149

150150
static u32 guc_ads_waklv_size(struct xe_guc_ads *ads)
151151
{
152-
return PAGE_ALIGN(ads->ads_waklv_size);
152+
return ALIGN(ads->ads_waklv_size, SZ_4K);
153153
}
154154

155155
static size_t guc_ads_capture_size(struct xe_guc_ads *ads)
156156
{
157-
return PAGE_ALIGN(ads->capture_size);
157+
return ALIGN(ads->capture_size, SZ_4K);
158158
}
159159

160160
static size_t guc_ads_um_queues_size(struct xe_guc_ads *ads)
@@ -169,7 +169,7 @@ static size_t guc_ads_um_queues_size(struct xe_guc_ads *ads)
169169

170170
static size_t guc_ads_private_data_size(struct xe_guc_ads *ads)
171171
{
172-
return PAGE_ALIGN(ads_to_guc(ads)->fw.private_data_size);
172+
return ALIGN(ads_to_guc(ads)->fw.private_data_size, SZ_4K);
173173
}
174174

175175
static size_t guc_ads_regset_offset(struct xe_guc_ads *ads)
@@ -184,7 +184,7 @@ static size_t guc_ads_golden_lrc_offset(struct xe_guc_ads *ads)
184184
offset = guc_ads_regset_offset(ads) +
185185
guc_ads_regset_size(ads);
186186

187-
return PAGE_ALIGN(offset);
187+
return ALIGN(offset, SZ_4K);
188188
}
189189

190190
static size_t guc_ads_waklv_offset(struct xe_guc_ads *ads)
@@ -194,7 +194,7 @@ static size_t guc_ads_waklv_offset(struct xe_guc_ads *ads)
194194
offset = guc_ads_golden_lrc_offset(ads) +
195195
guc_ads_golden_lrc_size(ads);
196196

197-
return PAGE_ALIGN(offset);
197+
return ALIGN(offset, SZ_4K);
198198
}
199199

200200
static size_t guc_ads_capture_offset(struct xe_guc_ads *ads)
@@ -204,7 +204,7 @@ static size_t guc_ads_capture_offset(struct xe_guc_ads *ads)
204204
offset = guc_ads_waklv_offset(ads) +
205205
guc_ads_waklv_size(ads);
206206

207-
return PAGE_ALIGN(offset);
207+
return ALIGN(offset, SZ_4K);
208208
}
209209

210210
static size_t guc_ads_um_queues_offset(struct xe_guc_ads *ads)
@@ -214,7 +214,7 @@ static size_t guc_ads_um_queues_offset(struct xe_guc_ads *ads)
214214
offset = guc_ads_capture_offset(ads) +
215215
guc_ads_capture_size(ads);
216216

217-
return PAGE_ALIGN(offset);
217+
return ALIGN(offset, SZ_4K);
218218
}
219219

220220
static size_t guc_ads_private_data_offset(struct xe_guc_ads *ads)
@@ -224,7 +224,7 @@ static size_t guc_ads_private_data_offset(struct xe_guc_ads *ads)
224224
offset = guc_ads_um_queues_offset(ads) +
225225
guc_ads_um_queues_size(ads);
226226

227-
return PAGE_ALIGN(offset);
227+
return ALIGN(offset, SZ_4K);
228228
}
229229

230230
static size_t guc_ads_size(struct xe_guc_ads *ads)
@@ -277,7 +277,7 @@ static size_t calculate_golden_lrc_size(struct xe_guc_ads *ads)
277277
continue;
278278

279279
real_size = xe_gt_lrc_size(gt, class);
280-
alloc_size = PAGE_ALIGN(real_size);
280+
alloc_size = ALIGN(real_size, SZ_4K);
281281
total_size += alloc_size;
282282
}
283283

@@ -628,12 +628,12 @@ static int guc_capture_prep_lists(struct xe_guc_ads *ads)
628628
offsetof(struct __guc_ads_blob, system_info));
629629

630630
/* first, set aside the first page for a capture_list with zero descriptors */
631-
total_size = PAGE_SIZE;
631+
total_size = SZ_4K;
632632
if (!xe_guc_capture_getnullheader(guc, &ptr, &size))
633633
xe_map_memcpy_to(ads_to_xe(ads), ads_to_map(ads), capture_offset, ptr, size);
634634

635635
null_ggtt = ads_ggtt + capture_offset;
636-
capture_offset += PAGE_SIZE;
636+
capture_offset += SZ_4K;
637637

638638
/*
639639
* Populate capture list : at this point adps is already allocated and
@@ -699,8 +699,8 @@ static int guc_capture_prep_lists(struct xe_guc_ads *ads)
699699

700700
if (ads->capture_size != PAGE_ALIGN(total_size))
701701
xe_gt_dbg(gt, "Updated ADS capture size %d (was %d)\n",
702-
PAGE_ALIGN(total_size), ads->capture_size);
703-
return PAGE_ALIGN(total_size);
702+
ALIGN(total_size, SZ_4K), ads->capture_size);
703+
return ALIGN(total_size, SZ_4K);
704704
}
705705

706706
static void guc_mmio_regset_write_one(struct xe_guc_ads *ads,
@@ -948,7 +948,7 @@ static void guc_golden_lrc_populate(struct xe_guc_ads *ads)
948948
xe_gt_assert(gt, gt->default_lrc[class]);
949949

950950
real_size = xe_gt_lrc_size(gt, class);
951-
alloc_size = PAGE_ALIGN(real_size);
951+
alloc_size = ALIGN(real_size, SZ_4K);
952952
total_size += alloc_size;
953953

954954
xe_map_memcpy_to(xe, ads_to_map(ads), offset,

drivers/gpu/drm/xe/xe_guc_capture.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ guc_capture_getlistsize(struct xe_guc *guc, u32 owner, u32 type,
591591
return -ENODATA;
592592

593593
if (size)
594-
*size = PAGE_ALIGN((sizeof(struct guc_debug_capture_list)) +
595-
(num_regs * sizeof(struct guc_mmio_reg)));
594+
*size = ALIGN((sizeof(struct guc_debug_capture_list)) +
595+
(num_regs * sizeof(struct guc_mmio_reg)), SZ_4K);
596596

597597
return 0;
598598
}
@@ -739,7 +739,7 @@ size_t xe_guc_capture_ads_input_worst_size(struct xe_guc *guc)
739739
* sequence, that is, during the pre-hwconfig phase before we have
740740
* the exact engine fusing info.
741741
*/
742-
total_size = PAGE_SIZE; /* Pad a page in front for empty lists */
742+
total_size = SZ_4K; /* Pad a page in front for empty lists */
743743
for (i = 0; i < GUC_CAPTURE_LIST_INDEX_MAX; i++) {
744744
for (j = 0; j < GUC_CAPTURE_LIST_CLASS_MAX; j++) {
745745
if (xe_guc_capture_getlistsize(guc, i,
@@ -759,7 +759,7 @@ size_t xe_guc_capture_ads_input_worst_size(struct xe_guc *guc)
759759
total_size += global_size;
760760
}
761761

762-
return PAGE_ALIGN(total_size);
762+
return ALIGN(total_size, SZ_4K);
763763
}
764764

765765
static int guc_capture_output_size_est(struct xe_guc *guc)

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ int xe_guc_ct_init_noalloc(struct xe_guc_ct *ct)
221221
struct xe_gt *gt = ct_to_gt(ct);
222222
int err;
223223

224-
xe_gt_assert(gt, !(guc_ct_size() % PAGE_SIZE));
224+
xe_gt_assert(gt, !(guc_ct_size() % SZ_4K));
225225

226226
ct->g2h_wq = alloc_ordered_workqueue("xe-g2h-wq", WQ_MEM_RECLAIM);
227227
if (!ct->g2h_wq)

drivers/gpu/drm/xe/xe_guc_log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static size_t guc_log_size(void)
5858
* | Capture logs |
5959
* +===============================+ + CAPTURE_SIZE
6060
*/
61-
return PAGE_SIZE + CRASH_BUFFER_SIZE + DEBUG_BUFFER_SIZE +
61+
return SZ_4K + CRASH_BUFFER_SIZE + DEBUG_BUFFER_SIZE +
6262
CAPTURE_BUFFER_SIZE;
6363
}
6464

@@ -328,7 +328,7 @@ u32 xe_guc_get_log_buffer_size(struct xe_guc_log *log, enum guc_log_buffer_type
328328
u32 xe_guc_get_log_buffer_offset(struct xe_guc_log *log, enum guc_log_buffer_type type)
329329
{
330330
enum guc_log_buffer_type i;
331-
u32 offset = PAGE_SIZE;/* for the log_buffer_states */
331+
u32 offset = SZ_4K; /* for the log_buffer_states */
332332

333333
for (i = GUC_LOG_BUFFER_CRASH_DUMP; i < GUC_LOG_BUFFER_TYPE_MAX; ++i) {
334334
if (i == type)

drivers/gpu/drm/xe/xe_guc_pc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
12391239
{
12401240
struct xe_device *xe = pc_to_xe(pc);
12411241
struct xe_gt *gt = pc_to_gt(pc);
1242-
u32 size = PAGE_ALIGN(sizeof(struct slpc_shared_data));
1242+
u32 size = ALIGN(sizeof(struct slpc_shared_data), SZ_4K);
12431243
unsigned int fw_ref;
12441244
ktime_t earlier;
12451245
int ret;
@@ -1372,7 +1372,7 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
13721372
struct xe_tile *tile = gt_to_tile(gt);
13731373
struct xe_device *xe = gt_to_xe(gt);
13741374
struct xe_bo *bo;
1375-
u32 size = PAGE_ALIGN(sizeof(struct slpc_shared_data));
1375+
u32 size = ALIGN(sizeof(struct slpc_shared_data), SZ_4K);
13761376
int err;
13771377

13781378
if (xe->info.skip_guc_pc)

0 commit comments

Comments
 (0)