intel: drm_intel_bo_gem_create_from_* on platforms w/o HW tiling
PATCH 1/1 intel: drm_intel_bo_gem_create_from_* on platforms w/o HW tiling
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.
--- intel/intel_bufmgr_gem.c | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-)
intel/intel_bufmgr_gem.c +26 -16
@@ -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); +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 sint 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 );
Signature · 6 lines
2.23.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Imre Deak
Platforms without a HW detiler doesn't support the
get_tilingIOCTL. 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 <[email protected]>
Seems like it this can happen only in vgpu cases.... which explains why it was not raised earlier. Regardless:
Aside: might want to do similar patch for mesa. Be that for classic/i965, gallium/iris and/or the Vulkan ANV driver.
-Emil
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 19 lines · Imre Deak
Platforms without a HW detiler doesn't support the
get_tilingIOCTL. 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 <[email protected]>--- intel/intel_bufmgr_gem.c | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-)intel/intel_bufmgr_gem.c +2
-0@@ -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,
intel/intel_bufmgr_gem.c check_bo_alloc_userptr(drm_intel_bufmgr *bufmgr, · line 1083
Quoted 10 lines
intel/intel_bufmgr_gem.c +10
-0+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:
FYI, I've posted the following MR for the equivalent Mesa changes:
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3497
Quoted 56 lines
intel/intel_bufmgr_gem.c +11
-14+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 sint 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))
intel/intel_bufmgr_gem.c drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s · line 2712
Quoted 10 lines
intel/intel_bufmgr_gem.c +3
-2+ 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 18 lines · Eric Engestrom
Quoted 17 lines · Imre Deak
Platforms without a HW detiler doesn't support the
get_tilingIOCTL. 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 <[email protected]>--- intel/intel_bufmgr_gem.c | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-)intel/intel_bufmgr_gem.c +0
-0@@ -1069,6 +1069,27 @@ check_bo_alloc_userptr(drm_intel_bufmgr *bufmgr, tiling_mode, stride, size, flags); }
Quoted 14 lines
intel/intel_bufmgr_gem.c check_bo_alloc_userptr(drm_intel_bufmgr *bufmgr, · line 1083
Quoted 12 lines
intel/intel_bufmgr_gem.c +12
-0+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;
Err, thanks for catching that, will resend fixing it.
Quoted 72 lines
Or better yet, just initialise
get_tilingand get rid of thememclear():
structdrm_i915_gem_get_tilingget_tiling= {
.handle =gem_handle,
};With either fix:
Reviewed-by Eric Engestrom <[email protected]>FYI, I've posted the following MR for the equivalent Mesa changes:
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3497Quoted 61 lines
intel/intel_bufmgr_gem.c +14
-14+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 sint 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;
Quoted 5 lines
intel/intel_bufmgr_gem.c drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s · line 2712
Quoted 5 lines
intel/intel_bufmgr_gem.c +0
-2- 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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/1 intel: drm_intel_bo_gem_create_from_* on platforms w/o HW tiling
In reply to Imre DeakPlatforms 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.
v2:
- Add the missing gem handle IOCTL parameter. (Eric)
--- intel/intel_bufmgr_gem.c | 43 +++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)
intel/intel_bufmgr_gem.c +27 -16
@@ -1069,6 +1069,28 @@ 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 = { + .handle = gem_handle, + }; +int ret; + + ret =drmIoctl (bufmgr_gem->fd, +DRM_IOCTL_I915_GEM_GET_TILING , + &get_tiling); +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 +1106,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 +1167,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 +2650,6 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int sint 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 +2703,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 );
Signature · 6 lines
2.23.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Imre Deak
Platforms without a HW detiler doesn't support the
get_tilingIOCTL. Fix the drm_intel_bo_gem_create_from_* functions assuming the default no-tiling, no-swizzling setting for the GEM buffer in this case.v2:
- Add the missing gem handle IOCTL parameter. (Eric)Signed-off-by Imre Deak <[email protected]>Reviewed-by Emil Velikov <[email protected]>Reviewed-by Eric Engestrom <[email protected]>
Thanks for the reviewes, pushed to
gitlab.freedesktop.org:mesa/drm.git master
Quoted 98 lines
--- intel/intel_bufmgr_gem.c | 43 +++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)intel/intel_bufmgr_gem.c +27
-16@@ -1069,6 +1069,28 @@ 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 = { + .handle = gem_handle, + }; +int ret; + + ret =drmIoctl (bufmgr_gem->fd, +DRM_IOCTL_I915_GEM_GET_TILING , + &get_tiling); +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 +1106,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 +1167,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 +2650,6 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int sint 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 +2703,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 );Signature · 6 lines
2.23.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx