Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Disantkumar Mistry <disantkumar.isvarbhai.mistry@intel.com>
Cc: igt-dev@lists.freedesktop.org, khaled.almahallawy@intel.com,
	jeevaka.badrappan@intel.com, kamil.konieczny@intel.com
Subject: Re: [PATCH i-g-t v2] tools/intel_dp_compliance: Enabling XE driver support
Date: Fri, 11 Jul 2025 17:31:45 +0300	[thread overview]
Message-ID: <aHEgUdUwMW_xfUWJ@intel.com> (raw)
In-Reply-To: <20250711065645.3074530-1-disantkumar.isvarbhai.mistry@intel.com>

On Fri, Jul 11, 2025 at 12:26:45PM +0530, Disantkumar Mistry wrote:
> i915 and XE driver have different api for mapping buffer. Enabling XE driver
> support by selecting XE driver specific map buffer api for XE devices.
> 
> Signed-off-by: Disantkumar Mistry <disantkumar.isvarbhai.mistry@intel.com>
> Tested-by: Khaled Almahallawy <khaled.almahallawy@intel.com>
> ----
> v2:
>  - Updated commit description
> ---
>  tools/igt_dp_compliance.h   |  1 +
>  tools/intel_dp_compliance.c | 50 ++++++++++++++++++++++++-------------
>  2 files changed, 33 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/igt_dp_compliance.h b/tools/igt_dp_compliance.h
> index 226a13662871..89bab0e6b8f8 100644
> --- a/tools/igt_dp_compliance.h
> +++ b/tools/igt_dp_compliance.h
> @@ -33,6 +33,7 @@
>  #else
>  #include <glib.h>
>  #endif
> +#include "xe/xe_ioctl.h"
>  
>  extern int drm_fd;
>  
> diff --git a/tools/intel_dp_compliance.c b/tools/intel_dp_compliance.c
> index 99196a450b45..60f064442396 100644
> --- a/tools/intel_dp_compliance.c
> +++ b/tools/intel_dp_compliance.c
> @@ -350,6 +350,14 @@ static void dump_info(void)
>  	igt_dump_crtcs_fd(drm_fd);
>  }
>  
> +static void *map_buffer(int fd, uint32_t handle, size_t size)
> +{
> +	if (is_xe_device(fd))
> +		return xe_bo_mmap_ext(fd, handle, size, PROT_READ | PROT_WRITE);
> +	else
> +		return gem_mmap__device_coherent(fd, handle, 0, size, PROT_READ | PROT_WRITE);
> +}

Can someone please introduce some sanity into lib/ so
that we have a *single* api to do common things?

> +
>  static int setup_framebuffers(struct connector *dp_conn)
>  {
>  
> @@ -361,15 +369,17 @@ static int setup_framebuffers(struct connector *dp_conn)
>  	igt_assert(dp_conn->fb);
>  
>  	/* Map the mapping of GEM object into the virtual address space */
> -	dp_conn->pixmap = gem_mmap__device_coherent(drm_fd,
> -					dp_conn->fb_video_pattern.gem_handle,
> -					0, dp_conn->fb_video_pattern.size,
> -					PROT_READ | PROT_WRITE);
> +	dp_conn->pixmap = map_buffer(drm_fd,
> +				     dp_conn->fb_video_pattern.gem_handle,
> +				     dp_conn->fb_video_pattern.size);
> +
>  	if (dp_conn->pixmap == NULL)
>  		return -1;
>  
> -	gem_set_domain(drm_fd, dp_conn->fb_video_pattern.gem_handle,
> -		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> +	if (is_i915_device(drm_fd))
> +		gem_set_domain(drm_fd, dp_conn->fb_video_pattern.gem_handle,
> +			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> +
>  	dp_conn->fb_size = dp_conn->fb_video_pattern.size;
>  
>  	/* After filling the device memory with 0s it needs to be unmapped */
> @@ -391,15 +401,17 @@ static int setup_failsafe_framebuffer(struct connector *dp_conn)
>  	igt_assert(dp_conn->failsafe_fb);
>  
>  	/* Map the mapping of GEM object into the virtual address space */
> -	dp_conn->failsafe_pixmap = gem_mmap__device_coherent(drm_fd,
> -						 dp_conn->fb_failsafe_pattern.gem_handle,
> -						 0, dp_conn->fb_failsafe_pattern.size,
> -						 PROT_READ | PROT_WRITE);
> +	dp_conn->failsafe_pixmap = map_buffer(drm_fd,
> +					      dp_conn->fb_failsafe_pattern.gem_handle,
> +					      dp_conn->fb_failsafe_pattern.size);
> +
>  	if (dp_conn->failsafe_pixmap == NULL)
>  		return -1;
>  
> -	gem_set_domain(drm_fd, dp_conn->fb_failsafe_pattern.gem_handle,
> -		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> +	if (is_i915_device(drm_fd))
> +		gem_set_domain(drm_fd, dp_conn->fb_failsafe_pattern.gem_handle,
> +			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> +
>  	dp_conn->failsafe_size = dp_conn->fb_failsafe_pattern.size;
>  
>  	/* After filling the device framebuffer the mapped memory needs to be freed */
> @@ -428,15 +440,17 @@ static int setup_video_pattern_framebuffer(struct connector *dp_conn)
>  	igt_assert(dp_conn->test_pattern.fb);
>  
>  	/* Map the mapping of GEM object into the virtual address space */
> -	dp_conn->test_pattern.pixmap = gem_mmap__device_coherent(drm_fd,
> -						     dp_conn->test_pattern.fb_pattern.gem_handle,
> -						     0, dp_conn->test_pattern.fb_pattern.size,
> -						     PROT_READ | PROT_WRITE);
> +
> +	dp_conn->test_pattern.pixmap = map_buffer(drm_fd,
> +						  dp_conn->test_pattern.fb_pattern.gem_handle,
> +						  dp_conn->test_pattern.fb_pattern.size);
> +
>  	if (dp_conn->test_pattern.pixmap == NULL)
>  		return -1;
>  
> -	gem_set_domain(drm_fd, dp_conn->test_pattern.fb_pattern.gem_handle,
> -		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
> +	if (is_i915_device(drm_fd))
> +		gem_set_domain(drm_fd, dp_conn->test_pattern.fb_pattern.gem_handle,
> +			       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
>  
>  	dp_conn->test_pattern.size = dp_conn->test_pattern.fb_pattern.size;
>  
> -- 
> 2.49.0

-- 
Ville Syrjälä
Intel

  parent reply	other threads:[~2025-07-11 14:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11  6:56 [PATCH i-g-t v2] tools/intel_dp_compliance: Enabling XE driver support Disantkumar Mistry
2025-07-11  7:50 ` ✓ Xe.CI.BAT: success for tools/intel_dp_compliance: Enabling XE driver support (rev2) Patchwork
2025-07-11  7:59 ` ✓ i915.CI.BAT: " Patchwork
2025-07-11 12:09 ` ✓ i915.CI.Full: " Patchwork
2025-07-11 14:31 ` Ville Syrjälä [this message]
2025-07-21 13:32   ` [PATCH i-g-t v2] tools/intel_dp_compliance: Enabling XE driver support Sharma, Swati2
2025-07-11 15:48 ` ✓ Xe.CI.Full: success for tools/intel_dp_compliance: Enabling XE driver support (rev2) 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=aHEgUdUwMW_xfUWJ@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=disantkumar.isvarbhai.mistry@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jeevaka.badrappan@intel.com \
    --cc=kamil.konieczny@intel.com \
    --cc=khaled.almahallawy@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