From: Eric Engestrom <eric.engestrom@intel.com>
To: Imre Deak <imre.deak@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH libdrm] intel: drm_intel_bo_gem_create_from_* on platforms w/o HW tiling
Date: Tue, 21 Jan 2020 22:40:48 +0000 [thread overview]
Message-ID: <20200121224048.f7b2kckdjqebnyhi@intel.com> (raw)
In-Reply-To: <20200120164343.2262-1-imre.deak@intel.com>
On Monday, 2020-01-20 18:43:43 +0200, Imre Deak wrote:
> Platforms without a HW detiler doesn't support the get_tiling IOCTL.
> Fix the drm_intel_bo_gem_create_from_* functions assuming the default
> no-tiling, no-swizzling setting for the GEM buffer in this case.
>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
> intel/intel_bufmgr_gem.c | 42 +++++++++++++++++++++++++---------------
> 1 file changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index fbf48730..fc249ef1 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -1069,6 +1069,27 @@ check_bo_alloc_userptr(drm_intel_bufmgr *bufmgr,
> tiling_mode, stride, size, flags);
> }
>
> +static int get_tiling_mode(drm_intel_bufmgr_gem *bufmgr_gem,
> + uint32_t gem_handle,
> + uint32_t *tiling_mode,
> + uint32_t *swizzle_mode)
> +{
> + struct drm_i915_gem_get_tiling get_tiling;
> + int ret;
> +
> + memclear(get_tiling);
> + ret = drmIoctl(bufmgr_gem->fd,
> + DRM_IOCTL_I915_GEM_GET_TILING,
> + &get_tiling);
You're missing `get_tiling.handle = gem_handle;`
Or better yet, just initialise `get_tiling` and get rid of the memclear():
struct drm_i915_gem_get_tiling get_tiling = {
.handle = gem_handle,
};
With either fix:
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
FYI, I've posted the following MR for the equivalent Mesa changes:
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3497
> + if (ret != 0 && errno != EOPNOTSUPP)
> + return ret;
> +
> + *tiling_mode = get_tiling.tiling_mode;
> + *swizzle_mode = get_tiling.swizzle_mode;
> +
> + return 0;
> +}
> +
> /**
> * Returns a drm_intel_bo wrapping the given buffer object handle.
> *
> @@ -1084,7 +1105,6 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
> drm_intel_bo_gem *bo_gem;
> int ret;
> struct drm_gem_open open_arg;
> - struct drm_i915_gem_get_tiling get_tiling;
>
> /* At the moment most applications only have a few named bo.
> * For instance, in a DRI client only the render buffers passed
> @@ -1146,16 +1166,11 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
> HASH_ADD(name_hh, bufmgr_gem->name_table,
> global_name, sizeof(bo_gem->global_name), bo_gem);
>
> - memclear(get_tiling);
> - get_tiling.handle = bo_gem->gem_handle;
> - ret = drmIoctl(bufmgr_gem->fd,
> - DRM_IOCTL_I915_GEM_GET_TILING,
> - &get_tiling);
> + ret = get_tiling_mode(bufmgr_gem, bo_gem->gem_handle,
> + &bo_gem->tiling_mode, &bo_gem->swizzle_mode);
> if (ret != 0)
> goto err_unref;
>
> - bo_gem->tiling_mode = get_tiling.tiling_mode;
> - bo_gem->swizzle_mode = get_tiling.swizzle_mode;
> /* XXX stride is unknown */
> drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, 0);
> DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name);
> @@ -2634,7 +2649,6 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
> int ret;
> uint32_t handle;
> drm_intel_bo_gem *bo_gem;
> - struct drm_i915_gem_get_tiling get_tiling;
>
> pthread_mutex_lock(&bufmgr_gem->lock);
> ret = drmPrimeFDToHandle(bufmgr_gem->fd, prime_fd, &handle);
> @@ -2688,15 +2702,11 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
> bo_gem->has_error = false;
> bo_gem->reusable = false;
>
> - memclear(get_tiling);
> - get_tiling.handle = bo_gem->gem_handle;
> - if (drmIoctl(bufmgr_gem->fd,
> - DRM_IOCTL_I915_GEM_GET_TILING,
> - &get_tiling))
> + ret = get_tiling_mode(bufmgr_gem, handle,
> + &bo_gem->tiling_mode, &bo_gem->swizzle_mode);
> + if (ret)
> goto err;
>
> - bo_gem->tiling_mode = get_tiling.tiling_mode;
> - bo_gem->swizzle_mode = get_tiling.swizzle_mode;
> /* XXX stride is unknown */
> drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, 0);
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-01-21 22:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-20 16:43 [Intel-gfx] [PATCH libdrm] intel: drm_intel_bo_gem_create_from_* on platforms w/o HW tiling Imre Deak
2020-01-21 18:52 ` Emil Velikov
2020-01-21 22:40 ` Eric Engestrom [this message]
2020-01-21 23:38 ` Imre Deak
2020-01-22 9:31 ` [Intel-gfx] [PATCH libdrm v2] " Imre Deak
2020-01-28 13:38 ` Imre Deak
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=20200121224048.f7b2kckdjqebnyhi@intel.com \
--to=eric.engestrom@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=imre.deak@intel.com \
--cc=intel-gfx@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