Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@Intel.com>,
	<intel-xe@lists.freedesktop.org>,
	Matt Roper <matthew.d.roper@intel.com>
Subject: Re: [PATCH v3 08/13] drm/xe/pat: Return error from xe_pat_init_early() on unknown platform
Date: Fri, 18 Sep 2026 09:40:44 +0200	[thread overview]
Message-ID: <0300c6bf-3f12-4944-a8fd-370ce07fd9d3@intel.com> (raw)
In-Reply-To: <a4fe2692-700d-4a88-ba1d-6806e6ea4b12@Intel.com>



On 9/18/2026 6:31 AM, Dnyaneshwar Bhadane wrote:
> 
> 
> On 09-Sep-26 12:07 AM, Michal Wajdeczko wrote:
>>
>>
>> On 9/8/2026 12:45 PM, Dnyaneshwar Bhadane wrote:
>>> 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: ??
> Hi, For the missing pat we should not process the further as we need proper IP specific xe->pat.ops assigned before moving from this function. so early exit from the driver probe would limit the pat->ops null pointer in xe_pat_init access.?

I know what's broken, as I pointed that out in [1]

what I meant here, that maybe we need to add the proper "Fixes:" tag with the commit that introduced that possible NPD

[1] https://patchwork.freedesktop.org/patch/744652/?series=171725&rev=1#comment_1371831

>>
>>> Signed-off-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com>
>>> ---
>>>   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,
>>>   };
>>>   
>>
>> now it's time to add kernel-doc
> Yes, I will add this in document.>> -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.
>>> -         */
>>
>> can't we leave this comment as-is?
> Noted. Thank you Michal
> 
> Dnyaneshwar, >
>>>           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
>>
> 


  reply	other threads:[~2026-09-18  7:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 10:45 [PATCH v3 00/13] drm/xe: Convert IO_BUS errors to structured xe_log API Dnyaneshwar Bhadane
2026-09-08 10:45 ` [PATCH v3 01/13] drm/xe/log: Add VRAM, PAT, and HWMON DRIVER_HARDWARE components Dnyaneshwar Bhadane
2026-09-23  4:42   ` Mallesh, Koujalagi
2026-09-08 10:45 ` [PATCH v3 02/13] drm/xe/ggtt: Report GGTT errors using structured logging Dnyaneshwar Bhadane
2026-09-08 10:57   ` sashiko-bot
2026-09-23  4:43     ` Bhadane, Dnyaneshwar
2026-09-08 10:45 ` [PATCH v3 03/13] drm/xe/hwmon: Report errors using structured xe_log API Dnyaneshwar Bhadane
2026-09-08 10:45 ` [PATCH v3 04/13] drm/xe/mmio: Report BAR mapping " Dnyaneshwar Bhadane
2026-09-08 10:45 ` [PATCH v3 05/13] drm/xe/memirq: Report " Dnyaneshwar Bhadane
2026-09-08 10:51   ` sashiko-bot
2026-09-08 10:45 ` [PATCH v3 06/13] drm/xe/reg_whitelist: Report whitelist overflow " Dnyaneshwar Bhadane
2026-09-08 18:12   ` Michal Wajdeczko
2026-09-22 10:16     ` Bhadane, Dnyaneshwar
2026-09-08 10:45 ` [PATCH v3 07/13] drm/xe/reg_sr: Report save-restore errors " Dnyaneshwar Bhadane
2026-09-08 18:33   ` Michal Wajdeczko
2026-09-23  5:49     ` Bhadane, Dnyaneshwar
2026-09-08 10:45 ` [PATCH v3 08/13] drm/xe/pat: Return error from xe_pat_init_early() on unknown platform Dnyaneshwar Bhadane
2026-09-08 18:37   ` Michal Wajdeczko
2026-09-18  4:31     ` Dnyaneshwar Bhadane
2026-09-18  7:40       ` Michal Wajdeczko [this message]
2026-09-08 10:45 ` [PATCH v3 09/13] drm/xe/pat: Report missing PAT table using structured xe_log API Dnyaneshwar Bhadane
2026-09-23  4:54   ` Mallesh, Koujalagi
2026-09-08 10:45 ` [PATCH v3 10/13] drm/xe/pci: Report unknown GMDID versions " Dnyaneshwar Bhadane
2026-09-08 10:45 ` [PATCH v3 11/13] drm/xe/lmtt: Report invalidation errors " Dnyaneshwar Bhadane
2026-09-08 10:45 ` [PATCH v3 12/13] drm/xe/vram: Report tile vs device VRAM visibility errors Dnyaneshwar Bhadane
2026-09-08 10:45 ` [PATCH v3 13/13] drm/xe/vram: Report VRAM errors using structured xe_log API Dnyaneshwar Bhadane
2026-09-08 13:17 ` ✓ CI.KUnit: success for drm/xe: Convert IO_BUS errors to structured xe_log API (rev3) Patchwork
2026-09-08 14:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-08 18:11 ` ✓ Xe.CI.FULL: " 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=0300c6bf-3f12-4944-a8fd-370ce07fd9d3@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=dnyaneshwar.bhadane@Intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox