Skip to content

Commit 699686d

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: stable@vger.kernel.org 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 <jeffbai@aosc.io> Tested-by: Haien Liang <27873200@qq.com> Tested-by: Shirong Liu <lsr1024@qq.com> Tested-by: Haofeng Wu <s2600cw2@126.com> Link: FanFansfan@22c55ab Co-developed-by: Shang Yatsen <429839446@qq.com> Signed-off-by: Shang Yatsen <429839446@qq.com> Co-developed-by: Kexy Biscuit <kexybiscuit@aosc.io> Signed-off-by: Kexy Biscuit <kexybiscuit@aosc.io> Signed-off-by: Mingcong Bai <jeffbai@aosc.io> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://lore.kernel.org/all/20250613-upstream-xe-non-4k-v2-v2-1-934f82249f8a@aosc.io/ Signed-off-by: Mingcong Bai <jeffbai@aosc.io> [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.] [Mingcong Bai: Resolved a minor post-6.19 merge conflict in drivers/gpu/drm/xe/xe_guc_log.c drivers/gpu/drm/xe/xe_guc_pc.c] Signed-off-by: Mingcong Bai <jeffbai@aosc.io> [Xi Ruoyao: Fix a merge error.] Signed-off-by: Xi Ruoyao <xry111@xry111.site> Signed-off-by: Mingcong Bai <jeffbai@aosc.io> [ Mingcong Bai: Resolved a minor post-7.0 merge conflict in drivers/gpu/drm/xe/xe_guc_ct.c ] Signed-off-by: Mingcong Bai <jeffbai@aosc.io>
1 parent 83d9435 commit 699686d

5 files changed

Lines changed: 25 additions & 25 deletions

File tree

drivers/gpu/drm/xe/xe_guc.c

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

107107
static u32 guc_ctl_log_params_flags(struct xe_guc *guc)
108108
{
109-
u32 offset = guc_bo_ggtt_addr(guc, guc->log.bo) >> PAGE_SHIFT;
109+
u32 offset = guc_bo_ggtt_addr(guc, guc->log.bo) >> XE_PTE_SHIFT;
110110
u32 flags;
111111

112112
#if (((XE_GUC_LOG_CRASH_DUMP_BUFFER_SIZE) % SZ_1M) == 0)
@@ -152,7 +152,7 @@ static u32 guc_ctl_log_params_flags(struct xe_guc *guc)
152152

153153
static u32 guc_ctl_ads_flags(struct xe_guc *guc)
154154
{
155-
u32 ads = guc_bo_ggtt_addr(guc, guc->ads.bo) >> PAGE_SHIFT;
155+
u32 ads = guc_bo_ggtt_addr(guc, guc->ads.bo) >> XE_PTE_SHIFT;
156156
u32 flags = FIELD_PREP(GUC_ADS_ADDR, ads);
157157

158158
return flags;

drivers/gpu/drm/xe/xe_guc_ads.c

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

143143
static size_t guc_ads_golden_lrc_size(struct xe_guc_ads *ads)
144144
{
145-
return PAGE_ALIGN(ads->golden_lrc_size);
145+
return ALIGN(ads->golden_lrc_size, SZ_4K);
146146
}
147147

148148
static u32 guc_ads_waklv_size(struct xe_guc_ads *ads)
149149
{
150-
return PAGE_ALIGN(ads->ads_waklv_size);
150+
return ALIGN(ads->ads_waklv_size, SZ_4K);
151151
}
152152

153153
static size_t guc_ads_capture_size(struct xe_guc_ads *ads)
154154
{
155-
return PAGE_ALIGN(ads->capture_size);
155+
return ALIGN(ads->capture_size, SZ_4K);
156156
}
157157

158158
static size_t guc_ads_um_queues_size(struct xe_guc_ads *ads)
@@ -167,7 +167,7 @@ static size_t guc_ads_um_queues_size(struct xe_guc_ads *ads)
167167

168168
static size_t guc_ads_private_data_size(struct xe_guc_ads *ads)
169169
{
170-
return PAGE_ALIGN(ads_to_guc(ads)->fw.private_data_size);
170+
return ALIGN(ads_to_guc(ads)->fw.private_data_size, SZ_4K);
171171
}
172172

173173
static size_t guc_ads_regset_offset(struct xe_guc_ads *ads)
@@ -182,7 +182,7 @@ static size_t guc_ads_golden_lrc_offset(struct xe_guc_ads *ads)
182182
offset = guc_ads_regset_offset(ads) +
183183
guc_ads_regset_size(ads);
184184

185-
return PAGE_ALIGN(offset);
185+
return ALIGN(offset, SZ_4K);
186186
}
187187

188188
static size_t guc_ads_waklv_offset(struct xe_guc_ads *ads)
@@ -192,7 +192,7 @@ static size_t guc_ads_waklv_offset(struct xe_guc_ads *ads)
192192
offset = guc_ads_golden_lrc_offset(ads) +
193193
guc_ads_golden_lrc_size(ads);
194194

195-
return PAGE_ALIGN(offset);
195+
return ALIGN(offset, SZ_4K);
196196
}
197197

198198
static size_t guc_ads_capture_offset(struct xe_guc_ads *ads)
@@ -202,7 +202,7 @@ static size_t guc_ads_capture_offset(struct xe_guc_ads *ads)
202202
offset = guc_ads_waklv_offset(ads) +
203203
guc_ads_waklv_size(ads);
204204

205-
return PAGE_ALIGN(offset);
205+
return ALIGN(offset, SZ_4K);
206206
}
207207

208208
static size_t guc_ads_um_queues_offset(struct xe_guc_ads *ads)
@@ -212,7 +212,7 @@ static size_t guc_ads_um_queues_offset(struct xe_guc_ads *ads)
212212
offset = guc_ads_capture_offset(ads) +
213213
guc_ads_capture_size(ads);
214214

215-
return PAGE_ALIGN(offset);
215+
return ALIGN(offset, SZ_4K);
216216
}
217217

218218
static size_t guc_ads_private_data_offset(struct xe_guc_ads *ads)
@@ -222,7 +222,7 @@ static size_t guc_ads_private_data_offset(struct xe_guc_ads *ads)
222222
offset = guc_ads_um_queues_offset(ads) +
223223
guc_ads_um_queues_size(ads);
224224

225-
return PAGE_ALIGN(offset);
225+
return ALIGN(offset, SZ_4K);
226226
}
227227

228228
static size_t guc_ads_size(struct xe_guc_ads *ads)
@@ -275,7 +275,7 @@ static size_t calculate_golden_lrc_size(struct xe_guc_ads *ads)
275275
continue;
276276

277277
real_size = xe_gt_lrc_size(gt, class);
278-
alloc_size = PAGE_ALIGN(real_size);
278+
alloc_size = ALIGN(real_size, SZ_4K);
279279
total_size += alloc_size;
280280
}
281281

@@ -623,12 +623,12 @@ static int guc_capture_prep_lists(struct xe_guc_ads *ads)
623623
offsetof(struct __guc_ads_blob, system_info));
624624

625625
/* first, set aside the first page for a capture_list with zero descriptors */
626-
total_size = PAGE_SIZE;
626+
total_size = SZ_4K;
627627
if (!xe_guc_capture_getnullheader(guc, &ptr, &size))
628628
xe_map_memcpy_to(ads_to_xe(ads), ads_to_map(ads), capture_offset, ptr, size);
629629

630630
null_ggtt = ads_ggtt + capture_offset;
631-
capture_offset += PAGE_SIZE;
631+
capture_offset += SZ_4K;
632632

633633
/*
634634
* Populate capture list : at this point adps is already allocated and
@@ -694,8 +694,8 @@ static int guc_capture_prep_lists(struct xe_guc_ads *ads)
694694

695695
if (ads->capture_size != PAGE_ALIGN(total_size))
696696
xe_gt_dbg(gt, "Updated ADS capture size %d (was %d)\n",
697-
PAGE_ALIGN(total_size), ads->capture_size);
698-
return PAGE_ALIGN(total_size);
697+
ALIGN(total_size, SZ_4K), ads->capture_size);
698+
return ALIGN(total_size, SZ_4K);
699699
}
700700

701701
static void guc_mmio_regset_write_one(struct xe_guc_ads *ads,
@@ -963,7 +963,7 @@ static void guc_golden_lrc_populate(struct xe_guc_ads *ads)
963963
xe_gt_assert(gt, gt->default_lrc[class]);
964964

965965
real_size = xe_gt_lrc_size(gt, class);
966-
alloc_size = PAGE_ALIGN(real_size);
966+
alloc_size = ALIGN(real_size, SZ_4K);
967967
total_size += alloc_size;
968968

969969
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
@@ -615,8 +615,8 @@ guc_capture_getlistsize(struct xe_guc *guc, u32 owner, u32 type,
615615
return -ENODATA;
616616

617617
if (size)
618-
*size = PAGE_ALIGN((sizeof(struct guc_debug_capture_list)) +
619-
(num_regs * sizeof(struct guc_mmio_reg)));
618+
*size = ALIGN((sizeof(struct guc_debug_capture_list)) +
619+
(num_regs * sizeof(struct guc_mmio_reg)), SZ_4K);
620620

621621
return 0;
622622
}
@@ -763,7 +763,7 @@ size_t xe_guc_capture_ads_input_worst_size(struct xe_guc *guc)
763763
* sequence, that is, during the pre-hwconfig phase before we have
764764
* the exact engine fusing info.
765765
*/
766-
total_size = PAGE_SIZE; /* Pad a page in front for empty lists */
766+
total_size = SZ_4K; /* Pad a page in front for empty lists */
767767
for (i = 0; i < GUC_CAPTURE_LIST_INDEX_MAX; i++) {
768768
for (j = 0; j < GUC_CAPTURE_LIST_CLASS_MAX; j++) {
769769
if (xe_guc_capture_getlistsize(guc, i,
@@ -783,7 +783,7 @@ size_t xe_guc_capture_ads_input_worst_size(struct xe_guc *guc)
783783
total_size += global_size;
784784
}
785785

786-
return PAGE_ALIGN(total_size);
786+
return ALIGN(total_size, SZ_4K);
787787
}
788788

789789
static int guc_capture_output_size_est(struct xe_guc *guc)

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ int xe_guc_ct_init_noalloc(struct xe_guc_ct *ct)
317317
struct xe_gt *gt = ct_to_gt(ct);
318318
int err;
319319

320-
xe_gt_assert(gt, !(guc_h2g_size() % PAGE_SIZE));
321-
xe_gt_assert(gt, !(guc_g2h_size() % PAGE_SIZE));
320+
xe_gt_assert(gt, !(guc_h2g_size() % SZ_4K));
321+
xe_gt_assert(gt, !(guc_g2h_size() % SZ_4K));
322322

323323
err = drmm_mutex_init(&xe->drm, &ct->lock);
324324
if (err)

drivers/gpu/drm/xe/xe_guc_pc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
12211221
{
12221222
struct xe_device *xe = pc_to_xe(pc);
12231223
struct xe_gt *gt = pc_to_gt(pc);
1224-
u32 size = PAGE_ALIGN(sizeof(struct slpc_shared_data));
1224+
u32 size = ALIGN(sizeof(struct slpc_shared_data), SZ_4K);
12251225
ktime_t earlier;
12261226
int ret;
12271227

@@ -1331,7 +1331,7 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
13311331
struct xe_tile *tile = gt_to_tile(gt);
13321332
struct xe_device *xe = gt_to_xe(gt);
13331333
struct xe_bo *bo;
1334-
u32 size = PAGE_ALIGN(sizeof(struct slpc_shared_data));
1334+
u32 size = ALIGN(sizeof(struct slpc_shared_data), SZ_4K);
13351335
int err;
13361336

13371337
if (xe->info.skip_guc_pc)

0 commit comments

Comments
 (0)