All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: mallesh.koujalagi@intel.com,
	Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com>
Subject: [PATCH v5 07/12] drm/xe/pat: Return error from xe_pat_init_early() on unknown platform
Date: Thu,  8 Oct 2026 02:44:12 +0530	[thread overview]
Message-ID: <20261007211417.2093611-8-dnyaneshwar.bhadane@intel.com> (raw)
In-Reply-To: <20261007211417.2093611-1-dnyaneshwar.bhadane@intel.com>

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>

---
v2:
 - Update kernel-doc for xe_pat_init_early. (Michal)
---
---
 drivers/gpu/drm/xe/xe_device.c |  4 +++-
 drivers/gpu/drm/xe/xe_pat.c    | 11 ++++++++++-
 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 8392c9fad3c4..6c214799b65b 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -895,7 +895,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
-- 
2.54.0


  parent reply	other threads:[~2026-10-07 21:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 21:14 [PATCH v5 00/12] drm/xe: Convert IO_BUS errors to structured xe_log API Dnyaneshwar Bhadane
2026-10-07 21:14 ` [PATCH v5 01/12] drm/xe/log: Add VRAM, PAT, and HWMON DRIVER_HARDWARE components Dnyaneshwar Bhadane
2026-10-08 13:59   ` Mallesh, Koujalagi
2026-10-07 21:14 ` [PATCH v5 02/12] drm/xe/ggtt: Report GGTT errors using structured logging Dnyaneshwar Bhadane
2026-10-07 21:14 ` [PATCH v5 03/12] drm/xe/hwmon: Report errors using structured xe_log API Dnyaneshwar Bhadane
2026-10-08 13:01   ` Mallesh, Koujalagi
2026-10-07 21:14 ` [PATCH v5 04/12] drm/xe/mmio: Report BAR mapping " Dnyaneshwar Bhadane
2026-10-07 21:14 ` [PATCH v5 05/12] drm/xe/memirq: Report " Dnyaneshwar Bhadane
2026-10-07 21:20   ` sashiko-bot
2026-10-07 21:14 ` [PATCH v5 06/12] drm/xe/reg_sr: Report save-restore " Dnyaneshwar Bhadane
2026-10-07 21:23   ` sashiko-bot
2026-10-08 13:45   ` Mallesh, Koujalagi
2026-10-07 21:14 ` Dnyaneshwar Bhadane [this message]
2026-10-07 21:14 ` [PATCH v5 08/12] drm/xe/pat: Report missing PAT table " Dnyaneshwar Bhadane
2026-10-07 21:14 ` [PATCH v5 09/12] drm/xe/pci: Report unknown GMDID versions " Dnyaneshwar Bhadane
2026-10-07 21:14 ` [PATCH v5 10/12] drm/xe/lmtt: Report invalidation errors " Dnyaneshwar Bhadane
2026-10-08 13:07   ` Mallesh, Koujalagi
2026-10-07 21:14 ` [PATCH v5 11/12] drm/xe/vram: Report tile vs device VRAM visibility errors Dnyaneshwar Bhadane
2026-10-08 13:25   ` Mallesh, Koujalagi
2026-10-09 10:42     ` Bhadane, Dnyaneshwar
2026-10-07 21:14 ` [PATCH v5 12/12] drm/xe/vram: Report VRAM errors using structured xe_log API Dnyaneshwar Bhadane
2026-10-07 21:19   ` sashiko-bot
2026-10-07 21:40 ` ✗ CI.checkpatch: warning for drm/xe: Convert IO_BUS errors to structured xe_log API (rev5) Patchwork
2026-10-07 21:42 ` ✓ CI.KUnit: success " Patchwork
2026-10-07 22:32 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-08  2:59 ` ✗ Xe.CI.FULL: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261007211417.2093611-8-dnyaneshwar.bhadane@intel.com \
    --to=dnyaneshwar.bhadane@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mallesh.koujalagi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.