drm/amdgpu/jpeg_v1_0: allow type4 commands
Subsystems (2)
PATCH 2/4 drm/amdgpu/jpeg_v2_0: set only IB_RD_VMID to 0
In reply to Benjamin ChengIf IB parsing is done by kernel, the IB will need to be read from VMID 0. However, memory read/write operations from within the IB should stay in the job's VMID. This will allow us to enable packet type 4.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c +6 -5
@@ -557,18 +557,19 @@ void jpeg_v2_0_dec_ring_emit_ib(struct amdgpu_ring *ring, uint32_t flags) {unsigned vmid =AMDGPU_JOB_GET_VMID (job); +uint32_t reg;amdgpu_ring_write (ring,PACKETJ (mmUVD_JPEG_IH_CTRL_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 ));amdgpu_ring_write (ring, (vmid <<JPEG_IH_CTRL__IH_VMID__SHIFT )); + reg = (vmid <<UVD_LMI_JRBC_IB_VMID__IB_WR_VMID__SHIFT ) | + (vmid <<UVD_LMI_JRBC_IB_VMID__MEM_RD_VMID__SHIFT ); +if (!ring->funcs->parse_cs) + reg |= (vmid <<UVD_LMI_JRBC_IB_VMID__IB_RD_VMID__SHIFT );amdgpu_ring_write (ring,PACKETJ (mmUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 )); - -if (ring->funcs->parse_cs) -amdgpu_ring_write (ring,0 ); -else -amdgpu_ring_write (ring, (vmid | (vmid <<4 ) | (vmid <<8 ))); +amdgpu_ring_write (ring, reg);amdgpu_ring_write (ring,PACKETJ (mmUVD_LMI_JPEG_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 ));
Signature · 1 line
2.56.0
PATCH 3/4 drm/amdgpu/jpeg_v4_0_3: set only IB_RD_VMID to 0
In reply to Benjamin ChengIf IB parsing is done by kernel, the IB will need to be read from VMID 0. However, memory read/write operations from within the IB should stay in the job's VMID. This will allow us to enable packet type 4.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +6 -9
@@ -892,18 +892,15 @@ void jpeg_v4_0_3_dec_ring_emit_ib(struct amdgpu_ring *ring, uint32_t flags) {unsigned int vmid =AMDGPU_JOB_GET_VMID (job); +uint32_t reg; + reg = (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__IB_WR_VMID_MASK ) | + (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__MEM_RD_VMID__SHIFT ); +if (!ring->funcs->parse_cs) + reg |= (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__IB_RD_VMID__SHIFT );amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 )); - -if (ring->funcs->parse_cs) -amdgpu_ring_write (ring,0 ); -else -amdgpu_ring_write (ring, (vmid | (vmid <<4 ) | (vmid <<8 ))); - -amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JPEG_VMID_INTERNAL_OFFSET, -0 ,0 ,PACKETJ_TYPE0 )); -amdgpu_ring_write (ring, (vmid | (vmid <<4 ) | (vmid <<8 ))); +amdgpu_ring_write (ring, reg);amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JRBC_IB_64BIT_BAR_LOW_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 ));
Signature · 1 line
2.56.0
PATCH 4/4 drm/amdgpu/jpeg: allow type 4 commands
In reply to Benjamin ChengPacket type 4 is used for conditional memory write and can be used to allow a memory write from within the IB. Now that the vmid's are set up correctly (IB_WR_VMID is set to the job's vmid), we can enable this with no issues.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c +6 -0
@@ -595,6 +595,12 @@ int amdgpu_jpeg_dec_parse_cs(struct amdgpu_cs_parser *parser,return -EINVAL ; }break ; +case PACKETJ_TYPE4 : +if (!amdgpu_jpeg_reg_valid (reg)) { +dev_err (adev->dev,"Invalid packet [0x%08x]!\n" , ib->ptr[i]); +return -EINVAL ; + } +break ;case PACKETJ_TYPE6 :if (ib->ptr[i] ==CP_PACKETJ_NOP )continue ;
Signature · 1 line
2.56.0
PATCH 1/4 drm/amdgpu/jpeg_v1_0: allow type4 commands
Packet type 4 is used for conditional memory write and can be used to allow a memory write from within the IB.
This write is done through IB_WR_VMID, which previously was set to 0 if we do IB parsing. After programming the VMIDs correctly we can enable packet type 4 with no issues.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c +8 -4
@@ -301,13 +301,14 @@ static void jpeg_v1_0_decode_ring_emit_ib(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev;unsigned vmid =AMDGPU_JOB_GET_VMID (job); +uint32_t reg; + reg = vmid <<UVD_LMI_JRBC_IB_VMID__IB_WR_VMID__SHIFT ; +if (!ring->funcs->parse_cs) + reg |= (vmid <<UVD_LMI_JRBC_IB_VMID__IB_RD_VMID__SHIFT );amdgpu_ring_write (ring,PACKETJ (SOC15_REG_OFFSET (JPEG ,0 , mmUVD_LMI_JRBC_IB_VMID),0 ,0 ,PACKETJ_TYPE0 )); -if (ring->funcs->parse_cs) -amdgpu_ring_write (ring,0 ); -else -amdgpu_ring_write (ring, (vmid | (vmid <<4 ))); +amdgpu_ring_write (ring, reg);amdgpu_ring_write (ring,PACKETJ (SOC15_REG_OFFSET (JPEG ,0 , mmUVD_LMI_JPEG_VMID),0 ,0 ,PACKETJ_TYPE0 ));
@@ -669,6 +670,9 @@ static int jpeg_v1_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,if (reg !=JPEG_V1_REG_SOFT_RESET ) ret = -EINVAL ;break ; +case PACKETJ_TYPE4 : +/* Allow any wait reg */ +break ;case PACKETJ_TYPE6 :if (ib->ptr[i] !=CP_PACKETJ_NOP ) ret = -EINVAL ;
Signature · 1 line
2.56.0
Re: [PATCH 3/4] drm/amdgpu/jpeg_v4_0_3: set only IB_RD_VMID to 0
In reply to Benjamin ChengQuoted 23 lines · Benjamin Cheng
If IB parsing is done by kernel, the IB will need to be read from VMID 0. However, memory read/write operations from within the IB should stay in the job's VMID. This will allow us to enable packet type 4.
Signed-off-by Benjamin Cheng<[email protected]>--- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +5
-0@@ -892,18 +892,15 @@ void jpeg_v4_0_3_dec_ring_emit_ib(struct amdgpu_ring *ring, uint32_t flags) {unsigned int vmid =AMDGPU_JOB_GET_VMID (job); +uint32_t reg; + reg = (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__IB_WR_VMID_MASK ) | + (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__MEM_RD_VMID__SHIFT ); +if (!ring->funcs->parse_cs) + reg |= (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__IB_RD_VMID__SHIFT );
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c void jpeg_v4_0_3_dec_ring_emit_ib(struct amdgpu_ring *ring, · line 905
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +0
-8amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 )); - -if (ring->funcs->parse_cs) -amdgpu_ring_write (ring,0 ); -else -amdgpu_ring_write (ring, (vmid | (vmid <<4 ) | (vmid <<8 ))); - -amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JPEG_VMID_INTERNAL_OFFSET, -0 ,0 ,PACKETJ_TYPE0 ));
is this removal of regUVD_LMI_JPEG_VMID_INTERNAL_OFFSET intended?
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +1
-1-amdgpu_ring_write (ring, (vmid | (vmid <<4 ) | (vmid <<8 ))); +amdgpu_ring_write (ring, reg);amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JRBC_IB_64BIT_BAR_LOW_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 ));
PATCH v2 1/1 drm/amdgpu/jpeg_v4_0_3: set only IB_RD_VMID to 0
In reply to Benjamin ChengIf IB parsing is done by kernel, the IB will need to be read from VMID 0. However, memory read/write operations from within the IB should stay in the job's VMID. This will allow us to enable packet type 4.
---
v2: Fix accidental removal of LMI_JPEG_VMID_INTERNAL_OFFSET as David pointed out.
--- drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +6 -5
@@ -892,14 +892,15 @@ void jpeg_v4_0_3_dec_ring_emit_ib(struct amdgpu_ring *ring, uint32_t flags) {unsigned int vmid =AMDGPU_JOB_GET_VMID (job); +uint32_t reg; + reg = (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__IB_WR_VMID_MASK ) | + (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__MEM_RD_VMID__SHIFT ); +if (!ring->funcs->parse_cs) + reg |= (vmid <<UVD_JMI0_UVD_LMI_JRBC_IB_VMID__IB_RD_VMID__SHIFT );amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 )); - -if (ring->funcs->parse_cs) -amdgpu_ring_write (ring,0 ); -else -amdgpu_ring_write (ring, (vmid | (vmid <<4 ) | (vmid <<8 ))); +amdgpu_ring_write (ring, reg);amdgpu_ring_write (ring,PACKETJ (regUVD_LMI_JPEG_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 ));
Signature · 1 line
2.56.0
v2 fix looks good to me. thanks!
The series is
Regards,
David
Quoted 45 lines · Benjamin Cheng
Packet type 4 is used for conditional memory write and can be used to allow a memory write from within the IB.
This write is done through
IB_WR_VMID, which previously was set to 0 if we do IB parsing. After programming the VMIDs correctly we can enable packet type 4 with no issues.Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c +8
-4@@ -301,13 +301,14 @@ static void jpeg_v1_0_decode_ring_emit_ib(struct amdgpu_ring *ring, {struct amdgpu_device *adev = ring->adev;unsigned vmid =AMDGPU_JOB_GET_VMID (job); +uint32_t reg; + reg = vmid <<UVD_LMI_JRBC_IB_VMID__IB_WR_VMID__SHIFT ; +if (!ring->funcs->parse_cs) + reg |= (vmid <<UVD_LMI_JRBC_IB_VMID__IB_RD_VMID__SHIFT );amdgpu_ring_write (ring,PACKETJ (SOC15_REG_OFFSET (JPEG ,0 , mmUVD_LMI_JRBC_IB_VMID),0 ,0 ,PACKETJ_TYPE0 )); -if (ring->funcs->parse_cs) -amdgpu_ring_write (ring,0 ); -else -amdgpu_ring_write (ring, (vmid | (vmid <<4 ))); +amdgpu_ring_write (ring, reg);amdgpu_ring_write (ring,PACKETJ (SOC15_REG_OFFSET (JPEG ,0 , mmUVD_LMI_JPEG_VMID),0 ,0 ,PACKETJ_TYPE0 ));@@ -669,6 +670,9 @@ static int jpeg_v1_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,if (reg !=JPEG_V1_REG_SOFT_RESET ) ret = -EINVAL ;break ; +case PACKETJ_TYPE4 : +/* Allow any wait reg */ +break ;case PACKETJ_TYPE6 :if (ib->ptr[i] !=CP_PACKETJ_NOP ) ret = -EINVAL ;
PATCH 1/1 drm/amdgpu: Bump version for allowing jpeg type 4
In reply to Benjamin ChengAllow userspace to know that kernel will not reject type 4 packets.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -128,9 +128,10 @@* - 3.63.0 - GFX12 display DCC supports 256B max compressed block size * - 3.64.0 - Userq IP support query * - 3.65.0 - Add userq syncobj timeline signaling support +* - 3.66.0 - Allow jpeg type 4 packets */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 65 +#define KMS_DRIVER_MINOR 66#define KMS_DRIVER_PATCHLEVEL 0/*
Signature · 1 line
2.56.0
Re: [PATCH] drm/amdgpu: Bump version for allowing jpeg type 4
Hi Alex/Christian,
Ping on this patch that would be submitted last with the previous 4 patches in this series?
Userspace needs a way to know that the type 4 packets won't be rejected.
Thanks,
Ben
Quoted 23 lines · Benjamin Cheng
Allow userspace to know that kernel will not reject type 4 packets.
Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -128,9 +128,10 @@* - 3.63.0 - GFX12 display DCC supports 256B max compressed block size * - 3.64.0 - Userq IP support query * - 3.65.0 - Add userq syncobj timeline signaling support +* - 3.66.0 - Allow jpeg type 4 packets */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 65 +#define KMS_DRIVER_MINOR 66#define KMS_DRIVER_PATCHLEVEL 0/*
Re: [PATCH] drm/amdgpu: Bump version for allowing jpeg type 4
Quoted 3 lines · Benjamin Cheng
Hi Alex/Christian,
Ping on this patch that would be submitted last with the previous 4 patches in this series?
Nevermind, I had a discussion with David Rosca, I will land this series before his VCE series so we can share the same version bump.
Quoted 31 lines
Userspace needs a way to know that the type 4 packets won't be rejected.
Thanks,
Ben
Quoted 23 lines · Benjamin Cheng
Allow userspace to know that kernel will not reject type 4 packets.
Signed-off-by Benjamin Cheng <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -128,9 +128,10 @@* - 3.63.0 - GFX12 display DCC supports 256B max compressed block size * - 3.64.0 - Userq IP support query * - 3.65.0 - Add userq syncobj timeline signaling support +* - 3.66.0 - Allow jpeg type 4 packets */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 65 +#define KMS_DRIVER_MINOR 66#define KMS_DRIVER_PATCHLEVEL 0/*