From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: Shuicheng Lin <shuicheng.lin@intel.com>,
<intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v2 3/3] drm/xe: Change return type of detect_bar2_dgfx() from s64 to u64
Date: Thu, 16 Oct 2025 15:33:41 -0400 [thread overview]
Message-ID: <aPFIlVSfcIyiynIc@intel.com> (raw)
In-Reply-To: <d177de7d-a98a-43ea-88ff-f52d8349d22a@intel.com>
On Thu, Oct 16, 2025 at 10:57:40AM +0100, Matthew Auld wrote:
> On 10/10/2025 00:02, Shuicheng Lin wrote:
> > The function never returns a negative value, and the return value is
> > assigned to a u64 variable. Use u64 for better type correctness
> > and clarity.
> >
> > v2: add assert to catch theoretical negative or zero stolen size. (Rodrigo)
> >
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
> > index 9b00bdc8ef1a..e368b2a36bac 100644
> > --- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
> > +++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
> > @@ -81,7 +81,7 @@ static u32 get_wopcm_size(struct xe_device *xe)
> > return wopcm_size;
> > }
> > -static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
> > +static u64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
> > {
> > struct xe_vram_region *tile_vram = xe_device_get_root_tile(xe)->mem.vram;
> > resource_size_t tile_io_start = xe_vram_region_io_start(tile_vram);
> > @@ -105,6 +105,8 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
> > return 0;
> > stolen_size = tile_size - mgr->stolen_base;
> > +
> > + xe_assert(xe, stolen_size > wopcm_size);
>
> This looks to be triggering:
> https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6359
And when I suggested it I thought it would be useless!
It already caught a bad bug! :)
It looks like we do need to change some logic now and
handle error conditions in this path and block the
code to move forward with invalid initialization.
>
> > stolen_size -= wopcm_size;
> > /* Verify usage fits in the actual resource available */
>
next prev parent reply other threads:[~2025-10-16 19:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 23:02 [PATCH v2 0/3] Fix copyright Shuicheng Lin
2025-10-09 23:02 ` [PATCH v2 1/3] drm/xe: Fix copyright and function naming in xe_ttm_sys_mgr Shuicheng Lin
2025-10-09 23:02 ` [PATCH v2 2/3] drm/xe: Fix copyright in xe_ttm_stolen_mgr Shuicheng Lin
2025-10-09 23:02 ` [PATCH v2 3/3] drm/xe: Change return type of detect_bar2_dgfx() from s64 to u64 Shuicheng Lin
2025-10-10 19:10 ` Rodrigo Vivi
2025-10-16 9:57 ` Matthew Auld
2025-10-16 14:54 ` Lin, Shuicheng
2025-10-16 19:33 ` Rodrigo Vivi [this message]
2025-10-10 0:24 ` ✓ CI.KUnit: success for Fix copyright (rev2) Patchwork
2025-10-10 1:05 ` ✓ Xe.CI.BAT: " Patchwork
2025-10-10 9:52 ` ✓ 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=aPFIlVSfcIyiynIc@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=shuicheng.lin@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