drm/radeon: add si tile mode array query
Subsystems (3)
PATCH 1/1 drm/radeon: add si tile mode array query
From: Jerome Glisse <[email protected]>
Allow userspace to query for the tile mode array so userspace can properly compute surface pitch and alignment requirement depending on tiling.
Signed-off-by Jerome Glisse <[email protected]>
--- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_drv.c | 3 +- drivers/gpu/drm/radeon/radeon_kms.c | 158 +++++++++++++++++++----------------- drivers/gpu/drm/radeon/si.c | 2 + include/uapi/drm/radeon_drm.h | 20 +++++ 5 files changed, 109 insertions(+), 75 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
@@ -1443,6 +1443,7 @@ struct si_asic {unsigned multi_gpu_tile_size;unsigned tile_config; +uint32_t tile_mode_array[32 ]; };union radeon_asic_config {
drivers/gpu/drm/radeon/radeon_drv.c +2 -1
@@ -71,9 +71,10 @@* 2.28.0 - r600-eg: Add MEM_WRITE packet support * 2.29.0 - R500 FP16 color clear registers * 2.30.0 - fix for FMASK texturing +* 2.31.0 - Add SI tiling mode array query */ #define KMS_DRIVER_MAJOR 2 -#define KMS_DRIVER_MINOR 30 +#define KMS_DRIVER_MINOR 31#define KMS_DRIVER_PATCHLEVEL 0int radeon_driver_load_kms (struct drm_device *dev,unsigned long flags);int radeon_driver_unload_kms (struct drm_device *dev);
drivers/gpu/drm/radeon/radeon_kms.c +84 -74
287 lines not on this page · raw message
drivers/gpu/drm/radeon/si.c +2 -0
@@ -1211,6 +1211,7 @@ static void si_tiling_mode_table_init(struct radeon_device *rdev) gb_tile_moden =0 ;break ; } + rdev->config.si.tile_mode_array[reg_offset] = gb_tile_moden;WREG32 (GB_TILE_MODE0 + (reg_offset *4 ), gb_tile_moden); } } else if ((rdev->family == CHIP_VERDE) ||
@@ -1451,6 +1452,7 @@ static void si_tiling_mode_table_init(struct radeon_device *rdev) gb_tile_moden =0 ;break ; } + rdev->config.si.tile_mode_array[reg_offset] = gb_tile_moden;WREG32 (GB_TILE_MODE0 + (reg_offset *4 ), gb_tile_moden); } }else
include/uapi/drm/radeon_drm.h +20 -0
@@ -972,6 +972,8 @@ struct drm_radeon_cs {#define RADEON_INFO_MAX_SE 0x12/* max SH per SE */ #define RADEON_INFO_MAX_SH_PER_SE 0x13 +/* SI tile mode array */ +#define RADEON_INFO_SI_TILE_MODE_ARRAY 0x14struct drm_radeon_info {uint32_t request;
@@ -979,4 +981,22 @@ struct drm_radeon_info { uint64_t value; }; +/* Those correspond to the tile index to use, this is to explicitly state +* the API that is implicitly defined by the tile mode array. +*/ +#define SI_TILE_MODE_COLOR_LINEAR_ALIGNED 8 +#define SI_TILE_MODE_COLOR_1D 13 +#define SI_TILE_MODE_COLOR_1D_SCANOUT 9 +#define SI_TILE_MODE_COLOR_2D_8BPP 14 +#define SI_TILE_MODE_COLOR_2D_16BPP 15 +#define SI_TILE_MODE_COLOR_2D_32BPP 16 +#define SI_TILE_MODE_COLOR_2D_64BPP 17 +#define SI_TILE_MODE_COLOR_2D_SCANOUT_16BPP 11 +#define SI_TILE_MODE_COLOR_2D_SCANOUT_32BPP 12 +#define SI_TILE_MODE_DEPTH_STENCIL_1D 4 +#define SI_TILE_MODE_DEPTH_STENCIL_2D 0 +#define SI_TILE_MODE_DEPTH_STENCIL_2D_2AA 3 +#define SI_TILE_MODE_DEPTH_STENCIL_2D_4AA 3 +#define SI_TILE_MODE_DEPTH_STENCIL_2D_8AA 2 +#endif
Signature · 1 line
1.8.1.4
Quoted 6 lines · On Mit, 2013-04-03 at 17:22 -0400, [email protected] wrote:
From: Jerome Glisse <[email protected]>
Allow userspace to query for the tile mode array so userspace can properly compute surface pitch and alignment requirement depending on tiling.
Signed-off-by Jerome Glisse <[email protected]>
[...]
Quoted 39 lines
drivers/gpu/drm/radeon/radeon_kms.c +4
-23@@ -176,80 +176,65 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)struct radeon_device *rdev = dev->dev_private;struct drm_radeon_info *info = data;struct radeon_mode_info *minfo = &rdev->mode_info; -uint32_t value, *value_ptr; -uint64_t value64, *value_ptr64; +uint32_t *value, value_tmp, *value_ptr, value_size; +uint64_t value64;struct drm_crtc *crtc;int i, found; -/* TIMESTAMP is a 64-bit value, needs special handling. */ -if (info->request ==RADEON_INFO_TIMESTAMP ) { -if (rdev->family >=CHIP_R600 ) { - value_ptr64 = (uint64_t *)((unsigned long )info->value); - value64 =radeon_get_gpu_clock_counter (rdev); - -if (DRM_COPY_TO_USER (value_ptr64, &value64,sizeof (value64))) { -DRM_ERROR ("copy_to_user %s:%u\n" , __func__, __LINE__); -return -EFAULT ; - } -return 0 ; - }else { -DRM_DEBUG_KMS ("timestamp is r6xx+ only!\n" ); -return -EINVAL ; - } - } - value_ptr = (uint32_t *)((unsigned long )info->value); -if (DRM_COPY_FROM_USER (&value, value_ptr,sizeof (value))) { -DRM_ERROR ("copy_from_user %s:%u\n" , __func__, __LINE__); -return -EFAULT ; - } + value = &value_tmp; + value_size =sizeof (uint32_t );
[...]
Quoted 9 lines
drivers/gpu/drm/radeon/radeon_kms.c +9
-0+case RADEON_INFO_TIMESTAMP : +if (rdev->family <CHIP_R600 ) { +DRM_DEBUG_KMS ("timestamp is r6xx+ only!\n" ); +return -EINVAL ; + } + value = (uint32_t *)&value64; + value_size =sizeof (uint64_t ); + value64 =radeon_get_gpu_clock_counter (rdev); +break ;
[...]
drivers/gpu/drm/radeon/radeon_kms.c int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 396
Quoted 5 lines
drivers/gpu/drm/radeon/radeon_kms.c +1
-1-if (DRM_COPY_TO_USER (value_ptr, &value,sizeof (uint32_t ))) { +if (DRM_COPY_TO_USER (value_ptr, value, value_size)) {DRM_ERROR ("copy_to_user %s:%u\n" , __func__, __LINE__);return -EFAULT ; }
Are these changes safe wrt strict aliasing? Might be safer to use char* for the second argument passed to DRM_COPY_TO_USER.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel