Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>
Cc: intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 5/6] drm/xe/display: Remove duplicated code
Date: Fri, 17 Jul 2026 17:46:39 +0300	[thread overview]
Message-ID: <alpAT3UENLh_SPEa@intel.com> (raw)
In-Reply-To: <b654aaaa-4290-4aab-be36-c2f3a01eb369@lankhorst.se>

On Wed, Jul 15, 2026 at 01:34:28PM +0200, Maarten Lankhorst wrote:
> 
> 
> On 7/15/26 13:05, Maarten Lankhorst wrote:
> > The order of pte vs checks isn't important, so read the pte
> > outside the if block. This makes it slightly more readable.
> > 
> > Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
> > ---
> >  drivers/gpu/drm/xe/display/xe_initial_plane.c | 35 ++++++-------------
> >  1 file changed, 11 insertions(+), 24 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/display/xe_initial_plane.c b/drivers/gpu/drm/xe/display/xe_initial_plane.c
> > index 5540b0fca392a..e16a6a1e6288a 100644
> > --- a/drivers/gpu/drm/xe/display/xe_initial_plane.c
> > +++ b/drivers/gpu/drm/xe/display/xe_initial_plane.c
> > @@ -64,7 +64,7 @@ initial_plane_bo(struct xe_device *xe,
> >  	struct xe_bo *bo;
> >  	resource_size_t phys_base;
> >  	u32 base, size, flags;
> > -	u64 page_size = xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K;
> > +	u64 page_size = xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K, pte;
> >  	struct xe_ggtt_node *original_ggtt_node;
> >  
> >  	if (plane_config->size == 0)
> > @@ -77,16 +77,14 @@ initial_plane_bo(struct xe_device *xe,
> >  			page_size);
> >  	size -= base;
> >  
> > -	if (IS_DGFX(xe)) {
> > -		u64 pte = xe_ggtt_read_pte(tile0->mem.ggtt, base);
> > -
> > -		if (is_pte_local(pte) != need_pte_local(xe)) {
> > -			drm_err(&xe->drm, "Initial plane PTE has bad local memory bit\n");
> > -			return NULL;
> > -		}
> > -
> > -		phys_base = pte & ~(page_size - 1);
> > +	pte = xe_ggtt_read_pte(tile0->mem.ggtt, base);
> > +	phys_base = pte & ~(page_size - 1);
> > +	if (is_pte_local(pte) != need_pte_local(xe)) {
> > +		drm_err(&xe->drm, "Initial plane PTE has bad local memory bit\n");
> > +		return NULL;
> > +	}
> >  
> > +	if (IS_DGFX(xe)) {
> >  		flags |= XE_BO_FLAG_VRAM0;
> >  
> >  		/*
> > @@ -104,25 +102,14 @@ initial_plane_bo(struct xe_device *xe,
> >  			    "Using phys_base=%pa, based on initial plane programming\n",
> >  			    &phys_base);
> >  	} else {
> > -		struct ttm_resource_manager *stolen;
> > -		u64 pte;
> > +		flags |= XE_BO_FLAG_STOLEN;
> > +		phys_base -= xe_ttm_stolen_gpu_offset(xe);
> >  
> > -		stolen = ttm_manager_type(&xe->ttm, XE_PL_STOLEN);
> > -		if (!stolen) {
> > +		if (!ttm_manager_type(&xe->ttm, XE_PL_STOLEN)) {
> >  			drm_dbg_kms(&xe->drm, "No stolen for initial FB\n");
> >  			return NULL;
> >  		}
> >
> 
> Woops, phys_base adjustment should be after !stolen check,
> result should be the same though.

I would still like to see the dma_addr/phys_base/ggtt offset
(old and new) debug stuff from
https://patchwork.freedesktop.org/patch/724207/?series=166362&rev=1
sucked in as well, as a separate patch. It's useful to see all of
that when debugging this stuff...

But this patch seems fine, with the reordering to avoid oopsing
if stolen isn't there
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> > -		pte = xe_ggtt_read_pte(tile0->mem.ggtt, base);
> > -
> > -		if (is_pte_local(pte) != need_pte_local(xe)) {
> > -			drm_err(&xe->drm, "Initial plane PTE has bad local memory bit\n");
> > -			return NULL;
> > -		}
> > -
> > -		phys_base = (pte & ~(page_size - 1)) - xe_ttm_stolen_gpu_offset(xe);
> > -		flags |= XE_BO_FLAG_STOLEN;
> > -
> >  		if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE) &&
> >  		    IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) &&
> >  		    !xe_display_bo_fbdev_prefer_stolen(xe, plane_config->size)) {

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2026-07-17 14:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 11:05 [PATCH v2 0/6] drm/xe: More BIOS FB takeover fixes Maarten Lankhorst
2026-07-15 11:05 ` [PATCH v2 1/6] drm/xe/ggtt: Add xe_ggtt_insert_node_at Maarten Lankhorst
2026-07-17 14:24   ` Ville Syrjälä
2026-07-15 11:05 ` [PATCH v2 2/6] drm/xe/ggtt: Add xe_ggtt_node_remove_noclear Maarten Lankhorst
2026-07-17 14:35   ` Ville Syrjälä
2026-07-15 11:05 ` [PATCH v2 3/6] drm/xe/display: Reserve the original GGTT space before creating a bo Maarten Lankhorst
2026-07-17 14:28   ` Ville Syrjälä
2026-07-15 11:05 ` [PATCH v2 4/6] drm/xe/display: Use the correct calculation for phys_base on integrated Maarten Lankhorst
2026-07-15 11:05 ` [PATCH v2 5/6] drm/xe/display: Remove duplicated code Maarten Lankhorst
2026-07-15 11:34   ` Maarten Lankhorst
2026-07-17 14:46     ` Ville Syrjälä [this message]
2026-07-15 11:05 ` [PATCH v2 6/6] drm/xe/ggtt: Remove xe_ggtt_insert_bo_at Maarten Lankhorst
2026-07-17 14:34   ` Ville Syrjälä
2026-07-15 11:50 ` ✗ CI.checkpatch: warning for drm/xe: More BIOS FB takeover fixes (rev2) Patchwork
2026-07-15 11:51 ` ✓ CI.KUnit: success " Patchwork
2026-07-15 12:28 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-15 13:42 ` ✓ 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=alpAT3UENLh_SPEa@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dev@lankhorst.se \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /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