drm/radeon/si: Add support for CP DMA to CS checker for compute
Subsystems (3)
PATCH 1/1 drm/radeon/si: Add support for CP DMA to CS checker for compute
From: Tom Stellard <[email protected]>
Also add a new RADEON_INFO query to check that CP DMA packets are supported on the compute ring.
--- drivers/gpu/drm/radeon/radeon_drv.c | 3 +- drivers/gpu/drm/radeon/radeon_kms.c | 3 + drivers/gpu/drm/radeon/si.c | 106 +++++++++++++++++++++--------------- include/uapi/drm/radeon_drm.h | 2 + 4 files changed, 68 insertions(+), 46 deletions(-)
drivers/gpu/drm/radeon/radeon_drv.c +2 -1
@@ -75,9 +75,10 @@* 2.32.0 - new info request for rings working * 2.33.0 - Add SI tiling mode array query * 2.34.0 - Add CIK tiling mode array query +* 2.35.0 - Add SI CP DMA compute query */ #define KMS_DRIVER_MAJOR 2 -#define KMS_DRIVER_MINOR 34 +#define KMS_DRIVER_MINOR 35#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 +3 -0
@@ -433,6 +433,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)return -EINVAL ; }break ; +case RADEON_INFO_SI_CP_DMA_COMPUTE : + *value =1 ; +break ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->request);return -EINVAL ;
drivers/gpu/drm/radeon/si.c +61 -45
136 lines not on this page · raw message
include/uapi/drm/radeon_drm.h +2 -0
@@ -979,6 +979,8 @@ struct drm_radeon_cs {#define RADEON_INFO_RING_WORKING 0x15/* SI tile mode array */ #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16 +/* query if CP DMA is supported on the compute ring */ +#define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17struct drm_radeon_info {
Signature · 1 line
1.8.1.5
Quoted 18 lines · Tom Stellard
From: Tom Stellard <[email protected]>
Also add a new
RADEON_INFOquery to check that CP DMA packets are supported on the compute ring.Signed-off-by Tom Stellard <[email protected]>--- drivers/gpu/drm/radeon/radeon_drv.c | 3 +- drivers/gpu/drm/radeon/radeon_kms.c | 3 + drivers/gpu/drm/radeon/si.c | 106 +++++++++++++++++++++--------------- include/uapi/drm/radeon_drm.h | 2 + 4 files changed, 68 insertions(+), 46 deletions(-)drivers/gpu/drm/radeon/radeon_drv.c +0
-0
drivers/gpu/drm/radeon/radeon_drv.c line 81
Quoted 8 lines
drivers/gpu/drm/radeon/radeon_drv.c +2
-1@@ -75,9 +75,10 @@* 2.32.0 - new info request for rings working * 2.33.0 - Add SI tiling mode array query * 2.34.0 - Add CIK tiling mode array query +* 2.35.0 - Add SI CP DMA compute query */ #define KMS_DRIVER_MAJOR 2 -#define KMS_DRIVER_MINOR 34 +#define KMS_DRIVER_MINOR 35
Skip the version bump if we want this to go to stable kernels. We can query the info ioctl for the cp_dma_compute arg and if it's a kernel where it doesn't exist, it'll just fail. if it exists the ioctl will succeed. If we don't want to send this to stable, just bump the version and skip the info ioctl.
Alex
Quoted 181 lines
drivers/gpu/drm/radeon/radeon_drv.c +0
-0#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 +3
-0@@ -433,6 +433,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)return -EINVAL ; }break ; +case RADEON_INFO_SI_CP_DMA_COMPUTE : + *value =1 ; +break ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->request);return -EINVAL ;drivers/gpu/drm/radeon/si.c +61
-45@@ -4083,13 +4083,64 @@ static int si_vm_packet3_ce_check(struct radeon_device *rdev,return 0 ; } +static int si_vm_packet3_cp_dma_check (u32 *ib,u32 idx) +{ +u32 start_reg, reg, i; +u32 command = ib[idx +4 ]; +u32 info = ib[idx +1 ]; +u32 idx_value = ib[idx]; +if (command &PACKET3_CP_DMA_CMD_SAS ) { +/* src address space is register */ +if (((info &0x60000000 ) >>29 ) ==0 ) { + start_reg = idx_value <<2 ; +if (command &PACKET3_CP_DMA_CMD_SAIC ) { + reg = start_reg; +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad SRC register\n" ); +return -EINVAL ; + } + }else { +for (i =0 ; i < (command &0x1fffff ); i++) { + reg = start_reg + (4 * i); +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad SRC register\n" ); +return -EINVAL ; + } + } + } + } + } +if (command &PACKET3_CP_DMA_CMD_DAS ) { +/* dst address space is register */ +if (((info &0x00300000 ) >>20 ) ==0 ) { + start_reg = ib[idx +2 ]; +if (command &PACKET3_CP_DMA_CMD_DAIC ) { + reg = start_reg; +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad DST register\n" ); +return -EINVAL ; + } + }else { +for (i =0 ; i < (command &0x1fffff ); i++) { + reg = start_reg + (4 * i); +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad DST register\n" ); +return -EINVAL ; + } + } + } + } + } +return 0 ; +} +static int si_vm_packet3_gfx_check (struct radeon_device *rdev,u32 *ib,struct radeon_cs_packet *pkt) { +int r;u32 idx = pkt->idx +1 ;u32 idx_value = ib[idx];u32 start_reg, end_reg, reg, i; -u32 command, info;switch (pkt->opcode) {case PACKET3_NOP :@@ -4190,50 +4241,9 @@ static int si_vm_packet3_gfx_check(struct radeon_device *rdev, }break ;case PACKET3_CP_DMA : - command = ib[idx +4 ]; - info = ib[idx +1 ]; -if (command &PACKET3_CP_DMA_CMD_SAS ) { -/* src address space is register */ -if (((info &0x60000000 ) >>29 ) ==0 ) { - start_reg = idx_value <<2 ; -if (command &PACKET3_CP_DMA_CMD_SAIC ) { - reg = start_reg; -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad SRC register\n" ); -return -EINVAL ; - } - }else { -for (i =0 ; i < (command &0x1fffff ); i++) { - reg = start_reg + (4 * i); -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad SRC register\n" ); -return -EINVAL ; - } - } - } - } - } -if (command &PACKET3_CP_DMA_CMD_DAS ) { -/* dst address space is register */ -if (((info &0x00300000 ) >>20 ) ==0 ) { - start_reg = ib[idx +2 ]; -if (command &PACKET3_CP_DMA_CMD_DAIC ) { - reg = start_reg; -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad DST register\n" ); -return -EINVAL ; - } - }else { -for (i =0 ; i < (command &0x1fffff ); i++) { - reg = start_reg + (4 * i); -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad DST register\n" ); -return -EINVAL ; - } - } - } - } - } + r =si_vm_packet3_cp_dma_check (ib, idx); +if (r) +return r;break ;default :DRM_ERROR ("Invalid GFX packet3: 0x%x\n" , pkt->opcode);@@ -4245,6 +4255,7 @@ static int si_vm_packet3_gfx_check(struct radeon_device *rdev,static int si_vm_packet3_compute_check (struct radeon_device *rdev,u32 *ib,struct radeon_cs_packet *pkt) { +int r;u32 idx = pkt->idx +1 ;u32 idx_value = ib[idx];u32 start_reg, reg, i;@@ -4317,6 +4328,11 @@ static int si_vm_packet3_compute_check(struct radeon_device *rdev,return -EINVAL ; }break ; +case PACKET3_CP_DMA : + r =si_vm_packet3_cp_dma_check (ib, idx); +if (r) +return r; +break ;default :DRM_ERROR ("Invalid Compute packet3: 0x%x\n" , pkt->opcode);return -EINVAL ;include/uapi/drm/radeon_drm.h +2
-1@@ -979,6 +979,8 @@ struct drm_radeon_cs {#define RADEON_INFO_RING_WORKING 0x15/* SI tile mode array */ #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16 +/* query if CP DMA is supported on the compute ring */ +#define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17struct drm_radeon_info { --1.8.1.5
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/radeon/si: Add support for CP DMA to CS checker for compute v2
From: Tom Stellard <[email protected]>
Also add a new RADEON_INFO query to check that CP DMA packets are supported on the compute ring.
v2:
- Don't bump kms version, so this patch can be backported to stable kernels.
--- drivers/gpu/drm/radeon/radeon_kms.c | 3 + drivers/gpu/drm/radeon/si.c | 106 +++++++++++++++++++++--------------- include/uapi/drm/radeon_drm.h | 2 + 3 files changed, 66 insertions(+), 45 deletions(-)
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
@@ -433,6 +433,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)return -EINVAL ; }break ; +case RADEON_INFO_SI_CP_DMA_COMPUTE : + *value =1 ; +break ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->request);return -EINVAL ;
drivers/gpu/drm/radeon/si.c +61 -45
136 lines not on this page · raw message
include/uapi/drm/radeon_drm.h +2 -0
@@ -979,6 +979,8 @@ struct drm_radeon_cs {#define RADEON_INFO_RING_WORKING 0x15/* SI tile mode array */ #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16 +/* query if CP DMA is supported on the compute ring */ +#define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17struct drm_radeon_info {
Signature · 1 line
1.8.1.5
Re: [PATCH] drm/radeon/si: Add support for CP DMA to CS checker for compute v2
Quoted 8 lines · Tom Stellard
From: Tom Stellard <[email protected]>
Also add a new
RADEON_INFOquery to check that CP DMA packets are supported on the compute ring.v2:
- Don't bump kms version, so this patch can be backported to stable kernels.
Why is this for a stable kernel? What reported problem does it fix?
thanks,
greg k-h
Re: [PATCH] drm/radeon/si: Add support for CP DMA to CS checker for compute v2
Quoted 12 lines · Greg KH
Quoted 8 lines · Tom Stellard
From: Tom Stellard <[email protected]>
Also add a new
RADEON_INFOquery to check that CP DMA packets are supported on the compute ring.v2:
- Don't bump kms version, so this patch can be backported to stable kernels.Why is this for a stable kernel? What reported problem does it fix?
CP DMA has been supported since the 3.8 kernel, but due to an oversight we forgot to teach the CS checker that the CP DMA packet was legal for the compute ring on Southern Islands GPUs.
This patch fixes a bug where the radeon driver will incorrectly reject a legal CP DMA packet from user space. I would like to have the patch backported to stable so that we don't have to require Mesa users to use a bleeding edge kernel in order to take advantage of this feature which is already present in the stable kernels (3.8 and newer).
-Tom
Re: [PATCH] drm/radeon/si: Add support for CP DMA to CS checker for compute v2
Quoted 18 lines · Tom Stellard
Quoted 12 lines · Greg KH
Quoted 8 lines · Tom Stellard
From: Tom Stellard <[email protected]>
Also add a new
RADEON_INFOquery to check that CP DMA packets are supported on the compute ring.v2:
- Don't bump kms version, so this patch can be backported to stable kernels.Why is this for a stable kernel? What reported problem does it fix?
CP DMA has been supported since the 3.8 kernel, but due to an oversight we forgot to teach the CS checker that the CP DMA packet was legal for the compute ring on Southern Islands GPUs.
Quoted 5 lines
This patch fixes a bug where the radeon driver will incorrectly reject a legal CP DMA packet from user space. I would like to have the patch backported to stable so that we don't have to require Mesa users to use a bleeding edge kernel in order to take advantage of this feature which is already present in the stable kernels (3.8 and newer).
Then please put that in the changelog section of the patch, otherwise people (like me), will ask these types of things :)
thanks,
greg k-h
Re: [PATCH] drm/radeon/si: Add support for CP DMA to CS checker for compute v2
In reply to Tom StellardQuoted 6 lines · Tom Stellard
From: Tom Stellard <[email protected]>
Also add a new
RADEON_INFOquery to check that CP DMA packets are supported on the compute ring.
Quoted 6 lines
v2:
- Don't bump kms version, so this patch can be backported to stable kernels.Signed-off-by Tom Stellard <[email protected]>
I've applied this to my tree and updated the the commit regarding why it needs to go to stable.
Thanks!
Alex
Quoted 184 lines
--- drivers/gpu/drm/radeon/radeon_kms.c | 3 + drivers/gpu/drm/radeon/si.c | 106 +++++++++++++++++++++--------------- include/uapi/drm/radeon_drm.h | 2 + 3 files changed, 66 insertions(+), 45 deletions(-)drivers/gpu/drm/radeon/radeon_kms.c +3
-0@@ -433,6 +433,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)return -EINVAL ; }break ; +case RADEON_INFO_SI_CP_DMA_COMPUTE : + *value =1 ; +break ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->request);return -EINVAL ;drivers/gpu/drm/radeon/si.c +61
-45@@ -4083,13 +4083,64 @@ static int si_vm_packet3_ce_check(struct radeon_device *rdev,return 0 ; } +static int si_vm_packet3_cp_dma_check (u32 *ib,u32 idx) +{ +u32 start_reg, reg, i; +u32 command = ib[idx +4 ]; +u32 info = ib[idx +1 ]; +u32 idx_value = ib[idx]; +if (command &PACKET3_CP_DMA_CMD_SAS ) { +/* src address space is register */ +if (((info &0x60000000 ) >>29 ) ==0 ) { + start_reg = idx_value <<2 ; +if (command &PACKET3_CP_DMA_CMD_SAIC ) { + reg = start_reg; +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad SRC register\n" ); +return -EINVAL ; + } + }else { +for (i =0 ; i < (command &0x1fffff ); i++) { + reg = start_reg + (4 * i); +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad SRC register\n" ); +return -EINVAL ; + } + } + } + } + } +if (command &PACKET3_CP_DMA_CMD_DAS ) { +/* dst address space is register */ +if (((info &0x00300000 ) >>20 ) ==0 ) { + start_reg = ib[idx +2 ]; +if (command &PACKET3_CP_DMA_CMD_DAIC ) { + reg = start_reg; +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad DST register\n" ); +return -EINVAL ; + } + }else { +for (i =0 ; i < (command &0x1fffff ); i++) { + reg = start_reg + (4 * i); +if (!si_vm_reg_valid (reg)) { +DRM_ERROR ("CP DMA Bad DST register\n" ); +return -EINVAL ; + } + } + } + } + } +return 0 ; +} +static int si_vm_packet3_gfx_check (struct radeon_device *rdev,u32 *ib,struct radeon_cs_packet *pkt) { +int r;u32 idx = pkt->idx +1 ;u32 idx_value = ib[idx];u32 start_reg, end_reg, reg, i; -u32 command, info;switch (pkt->opcode) {case PACKET3_NOP :@@ -4190,50 +4241,9 @@ static int si_vm_packet3_gfx_check(struct radeon_device *rdev, }break ;case PACKET3_CP_DMA : - command = ib[idx +4 ]; - info = ib[idx +1 ]; -if (command &PACKET3_CP_DMA_CMD_SAS ) { -/* src address space is register */ -if (((info &0x60000000 ) >>29 ) ==0 ) { - start_reg = idx_value <<2 ; -if (command &PACKET3_CP_DMA_CMD_SAIC ) { - reg = start_reg; -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad SRC register\n" ); -return -EINVAL ; - } - }else { -for (i =0 ; i < (command &0x1fffff ); i++) { - reg = start_reg + (4 * i); -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad SRC register\n" ); -return -EINVAL ; - } - } - } - } - } -if (command &PACKET3_CP_DMA_CMD_DAS ) { -/* dst address space is register */ -if (((info &0x00300000 ) >>20 ) ==0 ) { - start_reg = ib[idx +2 ]; -if (command &PACKET3_CP_DMA_CMD_DAIC ) { - reg = start_reg; -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad DST register\n" ); -return -EINVAL ; - } - }else { -for (i =0 ; i < (command &0x1fffff ); i++) { - reg = start_reg + (4 * i); -if (!si_vm_reg_valid (reg)) { -DRM_ERROR ("CP DMA Bad DST register\n" ); -return -EINVAL ; - } - } - } - } - } + r =si_vm_packet3_cp_dma_check (ib, idx); +if (r) +return r;break ;default :DRM_ERROR ("Invalid GFX packet3: 0x%x\n" , pkt->opcode);@@ -4245,6 +4255,7 @@ static int si_vm_packet3_gfx_check(struct radeon_device *rdev,static int si_vm_packet3_compute_check (struct radeon_device *rdev,u32 *ib,struct radeon_cs_packet *pkt) { +int r;u32 idx = pkt->idx +1 ;u32 idx_value = ib[idx];u32 start_reg, reg, i;@@ -4317,6 +4328,11 @@ static int si_vm_packet3_compute_check(struct radeon_device *rdev,return -EINVAL ; }break ; +case PACKET3_CP_DMA : + r =si_vm_packet3_cp_dma_check (ib, idx); +if (r) +return r; +break ;default :DRM_ERROR ("Invalid Compute packet3: 0x%x\n" , pkt->opcode);return -EINVAL ;include/uapi/drm/radeon_drm.h +2
-1@@ -979,6 +979,8 @@ struct drm_radeon_cs {#define RADEON_INFO_RING_WORKING 0x15/* SI tile mode array */ #define RADEON_INFO_SI_TILE_MODE_ARRAY 0x16 +/* query if CP DMA is supported on the compute ring */ +#define RADEON_INFO_SI_CP_DMA_COMPUTE 0x17struct drm_radeon_info { --1.8.1.5
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel