From 51c3ac1665265bf107d111927d242f0799ba11f8 Mon Sep 17 00:00:00 2001 From: Michal Wajdeczko Date: Sat, 5 Sep 2026 22:01:57 +0200 Subject: [PATCH] drm/xe/tests: Fix subplatform selection If a test does not specify subplatform details about the fake device it wants to create, our helper may select a sentinel of the subplatform descriptors list instead of the first available subplatform. Signed-off-by: Michal Wajdeczko Reviewed-by: Gustavo Sousa Link: https://patch.msgid.link/20260905200157.3164-3-michal.wajdeczko@intel.com --- drivers/gpu/drm/xe/tests/xe_pci.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c index a82cab7a2b86..8ab4270cf5d8 100644 --- a/drivers/gpu/drm/xe/tests/xe_pci.c +++ b/drivers/gpu/drm/xe/tests/xe_pci.c @@ -364,13 +364,23 @@ int xe_pci_fake_device_init(struct xe_device *xe) if (!ent->device) return -ENODEV; + if (data->subplatform == XE_SUBPLATFORM_NONE) { + subplatform_desc = NULL; + goto done; + } + + if (data->subplatform == XE_SUBPLATFORM_UNINITIALIZED) { + subplatform_desc = desc->subplatforms; + goto done; + } + for (subplatform_desc = desc->subplatforms; subplatform_desc && subplatform_desc->subplatform; subplatform_desc++) if (subplatform_desc->subplatform == data->subplatform) break; - if (data->subplatform != XE_SUBPLATFORM_NONE && !subplatform_desc) + if (!subplatform_desc || !subplatform_desc->subplatform) return -ENODEV; done: