Skip to content

Commit 73bc073

Browse files
committed
Merge tag 'drm-xe-next-fixes-2025-10-03' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-next
Cross-subsystem Changes: - Fix userptr to not allow device private pages with SVM (Thomas Hellström) Driver Changes: - Fix build with clang 16 (Michal Wajdeczko) - Fix handling of invalid configfs syntax usage and spell out the expected syntax in the documentation (Lucas De Marchi) - Do not try late bind firmware when running as VF since it shouldn't handle firmware loading (Michal Wajdeczko) - Fix idle assertion for local BOs (Thomas Hellström) - Fix uninitialized variable for late binding (Colin Ian King, Mallesh Koujalagi) - Do not require perfmon_capable to expose free memory at page granularity. Handle it like other drm drivers do (Matthew Auld) - Fix lock handling on suspend error path (Shuicheng Lin) - Fix I2C controller resume after S3 (Raag Jadav) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://lore.kernel.org/r/q6yeyb7n2eqo5megxjqayooajirx5hhsntfo65m3y4myscz7oz@25qbabbbr4hj
2 parents bae04c9 + 1af59cd commit 73bc073

File tree

14 files changed

+111
-78
lines changed

14 files changed

+111
-78
lines changed

drivers/gpu/drm/drm_gpusvm.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ static const struct mmu_interval_notifier_ops drm_gpusvm_notifier_ops = {
361361
* @name: Name of the GPU SVM.
362362
* @drm: Pointer to the DRM device structure.
363363
* @mm: Pointer to the mm_struct for the address space.
364-
* @device_private_page_owner: Device private pages owner.
365364
* @mm_start: Start address of GPU SVM.
366365
* @mm_range: Range of the GPU SVM.
367366
* @notifier_size: Size of individual notifiers.
@@ -383,7 +382,7 @@ static const struct mmu_interval_notifier_ops drm_gpusvm_notifier_ops = {
383382
*/
384383
int drm_gpusvm_init(struct drm_gpusvm *gpusvm,
385384
const char *name, struct drm_device *drm,
386-
struct mm_struct *mm, void *device_private_page_owner,
385+
struct mm_struct *mm,
387386
unsigned long mm_start, unsigned long mm_range,
388387
unsigned long notifier_size,
389388
const struct drm_gpusvm_ops *ops,
@@ -395,15 +394,13 @@ int drm_gpusvm_init(struct drm_gpusvm *gpusvm,
395394
mmgrab(mm);
396395
} else {
397396
/* No full SVM mode, only core drm_gpusvm_pages API. */
398-
if (ops || num_chunks || mm_range || notifier_size ||
399-
device_private_page_owner)
397+
if (ops || num_chunks || mm_range || notifier_size)
400398
return -EINVAL;
401399
}
402400

403401
gpusvm->name = name;
404402
gpusvm->drm = drm;
405403
gpusvm->mm = mm;
406-
gpusvm->device_private_page_owner = device_private_page_owner;
407404
gpusvm->mm_start = mm_start;
408405
gpusvm->mm_range = mm_range;
409406
gpusvm->notifier_size = notifier_size;
@@ -684,6 +681,7 @@ static unsigned int drm_gpusvm_hmm_pfn_to_order(unsigned long hmm_pfn,
684681
* @notifier: Pointer to the GPU SVM notifier structure
685682
* @start: Start address
686683
* @end: End address
684+
* @dev_private_owner: The device private page owner
687685
*
688686
* Check if pages between start and end have been faulted in on the CPU. Use to
689687
* prevent migration of pages without CPU backing store.
@@ -692,14 +690,15 @@ static unsigned int drm_gpusvm_hmm_pfn_to_order(unsigned long hmm_pfn,
692690
*/
693691
static bool drm_gpusvm_check_pages(struct drm_gpusvm *gpusvm,
694692
struct drm_gpusvm_notifier *notifier,
695-
unsigned long start, unsigned long end)
693+
unsigned long start, unsigned long end,
694+
void *dev_private_owner)
696695
{
697696
struct hmm_range hmm_range = {
698697
.default_flags = 0,
699698
.notifier = &notifier->notifier,
700699
.start = start,
701700
.end = end,
702-
.dev_private_owner = gpusvm->device_private_page_owner,
701+
.dev_private_owner = dev_private_owner,
703702
};
704703
unsigned long timeout =
705704
jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
@@ -753,6 +752,7 @@ static bool drm_gpusvm_check_pages(struct drm_gpusvm *gpusvm,
753752
* @gpuva_start: Start address of GPUVA which mirrors CPU
754753
* @gpuva_end: End address of GPUVA which mirrors CPU
755754
* @check_pages_threshold: Check CPU pages for present threshold
755+
* @dev_private_owner: The device private page owner
756756
*
757757
* This function determines the chunk size for the GPU SVM range based on the
758758
* fault address, GPU SVM chunk sizes, existing GPU SVM ranges, and the virtual
@@ -767,7 +767,8 @@ drm_gpusvm_range_chunk_size(struct drm_gpusvm *gpusvm,
767767
unsigned long fault_addr,
768768
unsigned long gpuva_start,
769769
unsigned long gpuva_end,
770-
unsigned long check_pages_threshold)
770+
unsigned long check_pages_threshold,
771+
void *dev_private_owner)
771772
{
772773
unsigned long start, end;
773774
int i = 0;
@@ -814,7 +815,7 @@ drm_gpusvm_range_chunk_size(struct drm_gpusvm *gpusvm,
814815
* process-many-malloc' mallocs at least 64k at a time.
815816
*/
816817
if (end - start <= check_pages_threshold &&
817-
!drm_gpusvm_check_pages(gpusvm, notifier, start, end)) {
818+
!drm_gpusvm_check_pages(gpusvm, notifier, start, end, dev_private_owner)) {
818819
++i;
819820
goto retry;
820821
}
@@ -957,7 +958,8 @@ drm_gpusvm_range_find_or_insert(struct drm_gpusvm *gpusvm,
957958
chunk_size = drm_gpusvm_range_chunk_size(gpusvm, notifier, vas,
958959
fault_addr, gpuva_start,
959960
gpuva_end,
960-
ctx->check_pages_threshold);
961+
ctx->check_pages_threshold,
962+
ctx->device_private_page_owner);
961963
if (chunk_size == LONG_MAX) {
962964
err = -EINVAL;
963965
goto err_notifier_remove;
@@ -1268,7 +1270,7 @@ int drm_gpusvm_get_pages(struct drm_gpusvm *gpusvm,
12681270
.notifier = notifier,
12691271
.start = pages_start,
12701272
.end = pages_end,
1271-
.dev_private_owner = gpusvm->device_private_page_owner,
1273+
.dev_private_owner = ctx->device_private_page_owner,
12721274
};
12731275
void *zdd;
12741276
unsigned long timeout =

drivers/gpu/drm/xe/tests/xe_pci.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@ static void xe_ip_kunit_desc(const struct xe_ip *param, char *desc)
211211
* param generator can be used for both
212212
*/
213213
static const struct xe_ip pre_gmdid_graphics_ips[] = {
214-
graphics_ip_xelp,
215-
graphics_ip_xelpp,
216-
graphics_ip_xehpg,
217-
graphics_ip_xehpc,
214+
{ 1200, "Xe_LP", &graphics_xelp },
215+
{ 1210, "Xe_LP+", &graphics_xelp },
216+
{ 1255, "Xe_HPG", &graphics_xehpg },
217+
{ 1260, "Xe_HPC", &graphics_xehpc },
218218
};
219219

220220
static const struct xe_ip pre_gmdid_media_ips[] = {
221-
media_ip_xem,
222-
media_ip_xehpm,
221+
{ 1200, "Xe_M", &media_xem },
222+
{ 1255, "Xe_HPM", &media_xem },
223223
};
224224

225225
KUNIT_ARRAY_PARAM(pre_gmdid_graphics_ip, pre_gmdid_graphics_ips, xe_ip_kunit_desc);

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,24 @@ static bool should_migrate_to_smem(struct xe_bo *bo)
17371737
bo->attr.atomic_access == DRM_XE_ATOMIC_CPU;
17381738
}
17391739

1740+
static int xe_bo_wait_usage_kernel(struct xe_bo *bo, struct ttm_operation_ctx *ctx)
1741+
{
1742+
long lerr;
1743+
1744+
if (ctx->no_wait_gpu)
1745+
return dma_resv_test_signaled(bo->ttm.base.resv, DMA_RESV_USAGE_KERNEL) ?
1746+
0 : -EBUSY;
1747+
1748+
lerr = dma_resv_wait_timeout(bo->ttm.base.resv, DMA_RESV_USAGE_KERNEL,
1749+
ctx->interruptible, MAX_SCHEDULE_TIMEOUT);
1750+
if (lerr < 0)
1751+
return lerr;
1752+
if (lerr == 0)
1753+
return -EBUSY;
1754+
1755+
return 0;
1756+
}
1757+
17401758
/* Populate the bo if swapped out, or migrate if the access mode requires that. */
17411759
static int xe_bo_fault_migrate(struct xe_bo *bo, struct ttm_operation_ctx *ctx,
17421760
struct drm_exec *exec)
@@ -1745,10 +1763,9 @@ static int xe_bo_fault_migrate(struct xe_bo *bo, struct ttm_operation_ctx *ctx,
17451763
int err = 0;
17461764

17471765
if (ttm_manager_type(tbo->bdev, tbo->resource->mem_type)->use_tt) {
1748-
xe_assert(xe_bo_device(bo),
1749-
dma_resv_test_signaled(tbo->base.resv, DMA_RESV_USAGE_KERNEL) ||
1750-
(tbo->ttm && ttm_tt_is_populated(tbo->ttm)));
1751-
err = ttm_bo_populate(&bo->ttm, ctx);
1766+
err = xe_bo_wait_usage_kernel(bo, ctx);
1767+
if (!err)
1768+
err = ttm_bo_populate(&bo->ttm, ctx);
17521769
} else if (should_migrate_to_smem(bo)) {
17531770
xe_assert(xe_bo_device(bo), bo->flags & XE_BO_FLAG_SYSTEM);
17541771
err = xe_bo_migrate(bo, XE_PL_TT, ctx, exec);
@@ -1922,7 +1939,6 @@ static vm_fault_t xe_bo_cpu_fault(struct vm_fault *vmf)
19221939
.no_wait_gpu = false,
19231940
.gfp_retry_mayfail = retry_after_wait,
19241941
};
1925-
long lerr;
19261942

19271943
err = drm_exec_lock_obj(&exec, &tbo->base);
19281944
drm_exec_retry_on_contention(&exec);
@@ -1942,13 +1958,9 @@ static vm_fault_t xe_bo_cpu_fault(struct vm_fault *vmf)
19421958
break;
19431959
}
19441960

1945-
lerr = dma_resv_wait_timeout(tbo->base.resv,
1946-
DMA_RESV_USAGE_KERNEL, true,
1947-
MAX_SCHEDULE_TIMEOUT);
1948-
if (lerr < 0) {
1949-
err = lerr;
1961+
err = xe_bo_wait_usage_kernel(bo, &tctx);
1962+
if (err)
19501963
break;
1951-
}
19521964

19531965
if (!retry_after_wait)
19541966
ret = __xe_bo_cpu_fault(vmf, xe, bo);

drivers/gpu/drm/xe/xe_configfs.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,20 @@
126126
* not intended for normal execution and will taint the kernel with TAINT_TEST
127127
* when used.
128128
*
129-
* Currently this is implemented only for post and mid context restore.
130-
* Examples:
129+
* The syntax allows to pass straight instructions to be executed by the engine
130+
* in a batch buffer or set specific registers.
131+
*
132+
* #. Generic instruction::
133+
*
134+
* <engine-class> cmd <instr> [[dword0] [dword1] [...]]
135+
*
136+
* #. Simple register setting::
137+
*
138+
* <engine-class> reg <address> <value>
139+
*
140+
* Commands are saved per engine class: all instances of that class will execute
141+
* those commands during context switch. The instruction, dword arguments,
142+
* addresses and values are in hex format like in the examples below.
131143
*
132144
* #. Execute a LRI command to write 0xDEADBEEF to register 0x4f10 after the
133145
* normal context restore::
@@ -154,7 +166,8 @@
154166
* When using multiple lines, make sure to use a command that is
155167
* implemented with a single write syscall, like HEREDOC.
156168
*
157-
* These attributes can only be set before binding to the device.
169+
* Currently this is implemented only for post and mid context restore and
170+
* these attributes can only be set before binding to the device.
158171
*
159172
* Remove devices
160173
* ==============
@@ -324,8 +337,8 @@ static const struct engine_info *lookup_engine_info(const char *pattern, u64 *ma
324337
continue;
325338

326339
pattern += strlen(engine_info[i].cls);
327-
if (!mask && !*pattern)
328-
return &engine_info[i];
340+
if (!mask)
341+
return *pattern ? NULL : &engine_info[i];
329342

330343
if (!strcmp(pattern, "*")) {
331344
*mask = engine_info[i].mask;

drivers/gpu/drm/xe/xe_device.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,16 +685,16 @@ static int wait_for_lmem_ready(struct xe_device *xe)
685685
}
686686
ALLOW_ERROR_INJECTION(wait_for_lmem_ready, ERRNO); /* See xe_pci_probe() */
687687

688-
static void sriov_update_device_info(struct xe_device *xe)
688+
static void vf_update_device_info(struct xe_device *xe)
689689
{
690+
xe_assert(xe, IS_SRIOV_VF(xe));
690691
/* disable features that are not available/applicable to VFs */
691-
if (IS_SRIOV_VF(xe)) {
692-
xe->info.probe_display = 0;
693-
xe->info.has_heci_cscfi = 0;
694-
xe->info.has_heci_gscfi = 0;
695-
xe->info.skip_guc_pc = 1;
696-
xe->info.skip_pcode = 1;
697-
}
692+
xe->info.probe_display = 0;
693+
xe->info.has_heci_cscfi = 0;
694+
xe->info.has_heci_gscfi = 0;
695+
xe->info.has_late_bind = 0;
696+
xe->info.skip_guc_pc = 1;
697+
xe->info.skip_pcode = 1;
698698
}
699699

700700
static int xe_device_vram_alloc(struct xe_device *xe)
@@ -735,7 +735,8 @@ int xe_device_probe_early(struct xe_device *xe)
735735

736736
xe_sriov_probe_early(xe);
737737

738-
sriov_update_device_info(xe);
738+
if (IS_SRIOV_VF(xe))
739+
vf_update_device_info(xe);
739740

740741
err = xe_pcode_probe_early(xe);
741742
if (err || xe_survivability_mode_is_requested(xe)) {

drivers/gpu/drm/xe/xe_hw_engine_group.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,13 @@ static int xe_hw_engine_group_suspend_faulting_lr_jobs(struct xe_hw_engine_group
213213

214214
err = q->ops->suspend_wait(q);
215215
if (err)
216-
goto err_suspend;
216+
return err;
217217
}
218218

219219
if (need_resume)
220220
xe_hw_engine_group_resume_faulting_lr_jobs(group);
221221

222222
return 0;
223-
224-
err_suspend:
225-
up_write(&group->mode_sem);
226-
return err;
227223
}
228224

229225
/**

drivers/gpu/drm/xe/xe_late_bind_fw.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int parse_cpd_header(struct xe_late_bind_fw *lb_fw,
6060
const struct gsc_manifest_header *manifest;
6161
const struct gsc_cpd_entry *entry;
6262
size_t min_size = sizeof(*header);
63-
u32 offset;
63+
u32 offset = 0;
6464
int i;
6565

6666
/* manifest_entry is mandatory */
@@ -116,7 +116,7 @@ static int parse_lb_layout(struct xe_late_bind_fw *lb_fw,
116116
const struct csc_fpt_header *header = data;
117117
const struct csc_fpt_entry *entry;
118118
size_t min_size = sizeof(*header);
119-
u32 offset;
119+
u32 offset = 0;
120120
int i;
121121

122122
/* fpt_entry is mandatory */
@@ -184,17 +184,13 @@ static const char *xe_late_bind_parse_status(uint32_t status)
184184
}
185185
}
186186

187-
static int xe_late_bind_fw_num_fans(struct xe_late_bind *late_bind)
187+
static int xe_late_bind_fw_num_fans(struct xe_late_bind *late_bind, u32 *num_fans)
188188
{
189189
struct xe_device *xe = late_bind_to_xe(late_bind);
190190
struct xe_tile *root_tile = xe_device_get_root_tile(xe);
191-
u32 uval;
192191

193-
if (!xe_pcode_read(root_tile,
194-
PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), &uval, NULL))
195-
return uval;
196-
else
197-
return 0;
192+
return xe_pcode_read(root_tile,
193+
PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), num_fans, NULL);
198194
}
199195

200196
void xe_late_bind_wait_for_worker_completion(struct xe_late_bind *late_bind)
@@ -314,7 +310,11 @@ static int __xe_late_bind_fw_init(struct xe_late_bind *late_bind, u32 fw_id)
314310
lb_fw->flags &= ~INTEL_LB_FLAG_IS_PERSISTENT;
315311

316312
if (lb_fw->type == INTEL_LB_TYPE_FAN_CONTROL) {
317-
num_fans = xe_late_bind_fw_num_fans(late_bind);
313+
ret = xe_late_bind_fw_num_fans(late_bind, &num_fans);
314+
if (ret) {
315+
drm_dbg(&xe->drm, "Failed to read number of fans: %d\n", ret);
316+
return 0; /* Not a fatal error, continue without fan control */
317+
}
318318
drm_dbg(&xe->drm, "Number of Fans: %d\n", num_fans);
319319
if (!num_fans)
320320
return 0;

drivers/gpu/drm/xe/xe_pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ int xe_pm_resume(struct xe_device *xe)
201201
if (err)
202202
goto err;
203203

204-
xe_i2c_pm_resume(xe, xe->d3cold.allowed);
204+
xe_i2c_pm_resume(xe, true);
205205

206206
xe_irq_resume(xe);
207207

drivers/gpu/drm/xe/xe_query.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ static int query_mem_regions(struct xe_device *xe,
276276
mem_regions->mem_regions[0].instance = 0;
277277
mem_regions->mem_regions[0].min_page_size = PAGE_SIZE;
278278
mem_regions->mem_regions[0].total_size = man->size << PAGE_SHIFT;
279-
if (perfmon_capable())
280-
mem_regions->mem_regions[0].used = ttm_resource_manager_usage(man);
279+
mem_regions->mem_regions[0].used = ttm_resource_manager_usage(man);
281280
mem_regions->num_mem_regions = 1;
282281

283282
for (i = XE_PL_VRAM0; i <= XE_PL_VRAM1; ++i) {
@@ -293,13 +292,11 @@ static int query_mem_regions(struct xe_device *xe,
293292
mem_regions->mem_regions[mem_regions->num_mem_regions].total_size =
294293
man->size;
295294

296-
if (perfmon_capable()) {
297-
xe_ttm_vram_get_used(man,
298-
&mem_regions->mem_regions
299-
[mem_regions->num_mem_regions].used,
300-
&mem_regions->mem_regions
301-
[mem_regions->num_mem_regions].cpu_visible_used);
302-
}
295+
xe_ttm_vram_get_used(man,
296+
&mem_regions->mem_regions
297+
[mem_regions->num_mem_regions].used,
298+
&mem_regions->mem_regions
299+
[mem_regions->num_mem_regions].cpu_visible_used);
303300

304301
mem_regions->mem_regions[mem_regions->num_mem_regions].cpu_visible_size =
305302
xe_ttm_vram_get_cpu_visible_size(man);

0 commit comments

Comments
 (0)