diff options
| author | Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com> | 2026-10-12 17:55:16 +0530 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2026-11-09 19:17:54 +1000 |
| commit | 7539edbca32d63ce309f5e29cb9d595b0959466a (patch) | |
| tree | 32c0bb73bc74bde94c3d2880f9398da2e5e84791 /drivers/gpu | |
| parent | 55d37e0c6155368240070c3e14b75265d12397d8 (diff) | |
| download | linux-7539edbca32d63ce309f5e29cb9d595b0959466a.tar.gz linux-7539edbca32d63ce309f5e29cb9d595b0959466a.zip | |
drm/xe/pat: Return error from xe_pat_init_early() on unknown platform
xe_pat_init_early() currently only logs an error when the platform's
graphics version doesn't match any known PAT table, but continues
probing with an uninitialized pat.ops. This can lead to a NULL
pointer dereference later when pat.ops is used.
Change xe_pat_init_early() to return an int and propagate -ENODATA
to xe_device_probe() so the driver fails to load cleanly instead of
continuing in a broken state.
Fixes: 152d7f2db978 ("drm/xe/pat: Handle unicast vs MCR PAT registers")
Signed-off-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com>
Reviewed-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
Link: https://patch.msgid.link/20261012122522.2307625-8-dnyaneshwar.bhadane@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
(cherry picked from commit e952337c3dbccf600ddae3bb1d38e996172ac8f8)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/xe/xe_device.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/xe/xe_pat.c | 11 | ||||
| -rw-r--r-- | drivers/gpu/drm/xe/xe_pat.h | 4 |
3 files changed, 16 insertions, 3 deletions
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 7e6027f49a4c..aa0bdf9c6caa 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -888,7 +888,9 @@ int xe_device_probe(struct xe_device *xe) xe_uid_probe(xe); - xe_pat_init_early(xe); + err = xe_pat_init_early(xe); + if (err) + return err; err = xe_sriov_init(xe); if (err) diff --git a/drivers/gpu/drm/xe/xe_pat.c b/drivers/gpu/drm/xe/xe_pat.c index a5fe1beec652..0ac64a6a3098 100644 --- a/drivers/gpu/drm/xe/xe_pat.c +++ b/drivers/gpu/drm/xe/xe_pat.c @@ -590,7 +590,13 @@ static const struct xe_pat_ops xe3p_xpc_pat_ops = { .entry_dump = xe3p_xpc_pat_entry_dump, }; -void xe_pat_init_early(struct xe_device *xe) +/** + * xe_pat_init_early() - Init early pat table operation. + * @xe: the &xe_device + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_pat_init_early(struct xe_device *xe) { xe->pat.idx[XE_CACHE_WB_COMPRESSION] = XE_PAT_INVALID_IDX; xe->pat.idx[XE_CACHE_NONE_COMPRESSION] = XE_PAT_INVALID_IDX; @@ -688,12 +694,15 @@ void xe_pat_init_early(struct xe_device *xe) */ drm_err(&xe->drm, "Missing PAT table for platform with graphics version %d.%02d!\n", GRAPHICS_VER(xe), GRAPHICS_VERx100(xe) % 100); + return -ENODATA; } + xe_assert(xe, xe->pat.ops); xe_assert(xe, xe->pat.ops->dump); xe_assert(xe, xe->pat.ops->program_graphics); xe_assert(xe, MEDIA_VER(xe) < 13 || xe->pat.ops->program_media); xe_assert(xe, GRAPHICS_VER(xe) < 20 || xe->pat.ops->entry_dump); + return 0; } void xe_pat_init(struct xe_gt *gt) diff --git a/drivers/gpu/drm/xe/xe_pat.h b/drivers/gpu/drm/xe/xe_pat.h index 7060f66e1d63..6398c3ab4805 100644 --- a/drivers/gpu/drm/xe/xe_pat.h +++ b/drivers/gpu/drm/xe/xe_pat.h @@ -42,8 +42,10 @@ struct xe_pat_table_entry { /** * xe_pat_init_early - SW initialization, setting up data based on device * @xe: xe device + * + * Return: 0 on success or a negative error code on failure. */ -void xe_pat_init_early(struct xe_device *xe); +int xe_pat_init_early(struct xe_device *xe); /** * xe_pat_init - Program HW PAT table |
