From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 221DBC79F82 for ; Tue, 8 Sep 2026 10:19:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C94BC10EB08; Tue, 8 Sep 2026 10:19:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XZPZ8FIE"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id B0F0910EB08 for ; Tue, 8 Sep 2026 10:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788862743; x=1820398743; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OOJyFi1JJ5FRTXb4+vOLs7LhpuVz7azU1aLeRQd8gFI=; b=XZPZ8FIERV+Xs7Frdf7InP6RM3h+fL6B9vDDuug6Zw7MrTN/uUIt71vd WMJwAIo/Smad/CS+KpfJXvNRwNlb1Hy9oAHSr78gZg2vei9E7dCsP0yL/ NRa1LIo/AB1wiKRvOD0eoKE+NxuTordKDfo5F5g/QV/VuA9APh03D49qV XTwcZNNVNPeQdckCfkSN/b+odDKciLl51O5MuJmQx24SHlC+GJls94+0i DOJD8xcfnw2Bvptnf1Mi6NTp+s1ndvXBXJ6COPEMF7UoK19O+ZM9ozrbc kX2jGXVtqn6a8OKEFg0sK7mFvSfkVhVVuyLPIOqV8OOep8f5B7CQ33p9o g==; X-CSE-ConnectionGUID: F/SnzeFKSMaWgqop9kd4EQ== X-CSE-MsgGUID: B9C2jUojROCi5OhyStsUUQ== X-IronPort-AV: E=McAfee;i="6800,10657,11899"; a="89278277" X-IronPort-AV: E=Sophos;i="6.25,268,1779174000"; d="scan'208";a="89278277" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2026 03:19:03 -0700 X-CSE-ConnectionGUID: vqt6UuBiS6qz69kCMHQ/gA== X-CSE-MsgGUID: 1ms/Ysr4T1OO/bRvSEDhuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,268,1779174000"; d="scan'208";a="269628458" Received: from dbhadane-mobl1.iind.intel.com ([10.190.239.58]) by orviesa010.jf.intel.com with ESMTP; 08 Sep 2026 03:19:03 -0700 From: Dnyaneshwar Bhadane To: intel-xe@lists.freedesktop.org Cc: mallesh.koujalagi@intel.com, Dnyaneshwar Bhadane Subject: [PATCH v2 08/13] drm/xe/pat: Return error from xe_pat_init_early() on unknown platform Date: Tue, 8 Sep 2026 15:48:44 +0530 Message-ID: <20260908101849.1219614-9-dnyaneshwar.bhadane@intel.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260908101849.1219614-1-dnyaneshwar.bhadane@intel.com> References: <20260908101849.1219614-1-dnyaneshwar.bhadane@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" 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. Signed-off-by: Dnyaneshwar Bhadane --- drivers/gpu/drm/xe/xe_device.c | 4 +++- drivers/gpu/drm/xe/xe_pat.c | 14 +++++--------- drivers/gpu/drm/xe/xe_pat.h | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 8583b2e9ecf4..b7f78d45dee1 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -960,7 +960,9 @@ int xe_device_probe(struct xe_device *xe) int err; u8 id; - 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..8af92e3c4c17 100644 --- a/drivers/gpu/drm/xe/xe_pat.c +++ b/drivers/gpu/drm/xe/xe_pat.c @@ -590,7 +590,7 @@ 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) +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; @@ -678,22 +678,18 @@ void xe_pat_init_early(struct xe_device *xe) xe->pat.idx[XE_CACHE_WT] = 2; xe->pat.idx[XE_CACHE_WB] = 0; } else { - /* - * Going forward we expect to need new PAT settings for most - * new platforms; failure to provide a new table can easily - * lead to subtle, hard-to-debug problems. If none of the - * conditions above match the platform we're running on we'll - * raise an error rather than trying to silently inherit the - * most recent platform's behavior. - */ 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..66e335fb3b0c 100644 --- a/drivers/gpu/drm/xe/xe_pat.h +++ b/drivers/gpu/drm/xe/xe_pat.h @@ -43,7 +43,7 @@ struct xe_pat_table_entry { * xe_pat_init_early - SW initialization, setting up data based on device * @xe: xe device */ -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