Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: "Cavitt, Jonathan" <jonathan.cavitt@intel.com>,
	Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 1/2] drm/xe/display: Move dpt allocation to helper
Date: Wed, 15 Jan 2025 11:19:18 +0100	[thread overview]
Message-ID: <4edb736f-907c-4506-ae77-739d3aa377aa@linux.intel.com> (raw)
In-Reply-To: <CH0PR11MB5444F77CC2DE257A7BA51E1DE5182@CH0PR11MB5444.namprd11.prod.outlook.com>



Den 2025-01-14 kl. 20:22, skrev Cavitt, Jonathan:
> -----Original Message-----
> From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Juha-Pekka Heikkila
> Sent: Tuesday, January 14, 2025 10:04 AM
> To: intel-xe@lists.freedesktop.org
> Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
> Subject: [PATCH 1/2] drm/xe/display: Move dpt allocation to helper
>>
>> Simplify __xe_pin_fb_vma_dpt() by moving dpt allocation into helper.
>> This also fixes bug where dpt could have been allocated from system
>> memory when on dgfx.
>>
>> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
>> ---
>>   drivers/gpu/drm/xe/display/xe_fb_pin.c | 67 +++++++++++++++++---------
>>   1 file changed, 43 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
>> index 9fa51b84737c..c28885316986 100644
>> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
>> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
>> @@ -77,6 +77,47 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
>>   	*dpt_ofs = ALIGN(*dpt_ofs, 4096);
>>   }
>>   
>> +static struct xe_bo *xe_alloc_dpt_bo(struct xe_device *xe,
>> +				     struct xe_tile *tile0, u64 size,
>> +				     u64 physical_alignment)
>> +{
>> +	struct xe_bo *dpt;
>> +
>> +	/*
>> +	 * If DGFX: try VRAM0 only
>> +	 */
>> +	if (IS_DGFX(xe)) {
>> +		dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
>> +						      size, ~0ull,
>> +						      ttm_bo_type_kernel,
>> +						      XE_BO_FLAG_VRAM0 |
>> +						      XE_BO_FLAG_GGTT |
>> +						      XE_BO_FLAG_PAGETABLE,
>> +						      physical_alignment);
>> +	} else {
>> +		/*
>> +		 * For IGFX: first try STOLEN. on fail try SYSTEM.
>> +		 */
>> +		dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
>> +						      size, ~0ull,
>> +						      ttm_bo_type_kernel,
>> +						      XE_BO_FLAG_STOLEN |
>> +						      XE_BO_FLAG_GGTT |
>> +						      XE_BO_FLAG_PAGETABLE,
>> +						      physical_alignment);
>> +		if (IS_ERR(dpt)) {
>> +			dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
>> +							      size, ~0ull,
>> +							      ttm_bo_type_kernel,
>> +							      XE_BO_FLAG_SYSTEM |
>> +							      XE_BO_FLAG_GGTT |
>> +							      XE_BO_FLAG_PAGETABLE,
>> +							      physical_alignment);
>> +		}
>> +	}
>> +	return dpt;
> 
> We might be able to collapse some of this logic by storing the flags separately:
> 
> """
> static struct xe_bo *xe_alloc_dpt_bo(struct xe_device *xe,
> 				     struct xe_tile *tile0, u64 size,
> 				     u64 physical_alignment)
> {
> 	struct xe_bo *dpt;
> 	u32 base_flags = XE_BO_FLAG_GGTT | XE_BO_FLAG_PAGETABLE;
> 	u32 flags = base_flags;
> 
> 	/*
> 	 * If DGFX: try VRAM0.
> 	 * If IGFX: try STOLEN.
> 	 */
> 	flags |= IS_DGFX(xe) ? XE_BO_FLAG_VRAM0 : XE_BO_FLAG_STOLEN;
> 
> 	dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL, size,
> 					      ~0ull, ttm_bo_type_kernel,
> 					      flags, physical_alignment);
> 
> 	/*
> 	 * For IGFX, we first try STOLEN, and on a failure we try SYSTEM.
> 	 * DGFX should only attempt VRAM0
> 	 */
> 	if (IS_DGFX(xe) && IS_ERR(dpt))
> 		dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
> 						      size, ~0ull,
> 						      ttm_bo_type_kernel,
> 						      base_flags |
> 						      XE_BO_FLAG_SYSTEM,
> 						      physical_alignment);
> 	return dpt;
> }
> """
> This isn't a particularly necessary compression, but it might be worth considering.
> Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>Except that fails on both integrated and discrete, due to IS_DGFX() used 
wrongly here. ;-)

Every change, no matter how small, has the opportunity to break things.

Regardless, for both patches:
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Cheers,
~Maarten

  reply	other threads:[~2025-01-15 10:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14 18:04 [PATCH 1/2] drm/xe/display: Move dpt allocation to helper Juha-Pekka Heikkila
2025-01-14 18:04 ` [PATCH 2/2] drm/xe/display: Unify display page table mapping Juha-Pekka Heikkila
2025-01-14 19:56   ` Cavitt, Jonathan
2025-02-04 11:25   ` Tvrtko Ursulin
2025-02-04 11:38     ` Tvrtko Ursulin
2025-02-04 12:10       ` Juha-Pekka Heikkilä
2025-02-04 12:31         ` Tvrtko Ursulin
2025-02-04 13:11           ` Juha-Pekka Heikkilä
2025-02-04 18:05             ` Tvrtko Ursulin
2025-02-07 14:33               ` Juha-Pekka Heikkilä
2025-02-11 11:22                 ` Tvrtko Ursulin
2025-01-14 19:22 ` [PATCH 1/2] drm/xe/display: Move dpt allocation to helper Cavitt, Jonathan
2025-01-15 10:19   ` Maarten Lankhorst [this message]
2025-01-15 15:09     ` Cavitt, Jonathan
2025-01-15 15:26       ` Cavitt, Jonathan
2025-01-16 15:33         ` Juha-Pekka Heikkilä
2025-01-14 19:39 ` ✓ CI.Patch_applied: success for series starting with [1/2] " Patchwork
2025-01-14 19:39 ` ✓ CI.checkpatch: " Patchwork
2025-01-14 19:40 ` ✓ CI.KUnit: " Patchwork
2025-01-14 19:58 ` ✓ CI.Build: " Patchwork
2025-01-14 20:01 ` ✓ CI.Hooks: " Patchwork
2025-01-14 20:02 ` ✓ CI.checksparse: " Patchwork
2025-01-14 20:28 ` ✓ Xe.CI.BAT: " Patchwork
2025-01-14 23:24 ` ✗ Xe.CI.Full: failure " Patchwork
2025-02-03 13:07 ` [PATCH 1/2] " Jani Nikula
2025-02-03 15:36   ` Lucas De Marchi
2025-02-04 10:37     ` Jani Nikula
2025-02-04 14:59       ` Lucas De Marchi
2025-02-04 15:11         ` Jani Nikula
2025-02-04 16:07           ` Tvrtko Ursulin
  -- strict thread matches above, loose matches on Subject: below --
2025-05-13 14:14 Juha-Pekka Heikkila

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=4edb736f-907c-4506-ae77-739d3aa377aa@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=juhapekka.heikkila@gmail.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