Skip to content

Commit f5d6c41

Browse files
committed
Merge tag 'amd-drm-fixes-6.11-2024-09-11' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
amd-drm-fixes-6.11-2024-09-11: amdgpu: - Avoid races between set_drr() functions and dc_state_destruct() - Fix regerssion related to zpos - Fix regression related to overlay cursor - SMU 14.x updates - JPEG fixes - Silence an UBSAN warning amdkfd: - Fetch cacheline size from IP discovery Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexander.deucher@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240911170528.838655-1-alexander.deucher@amd.com
2 parents da3ea35 + 2a2a865 commit f5d6c41

File tree

19 files changed

+231
-86
lines changed

19 files changed

+231
-86
lines changed

drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.c

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "amdgpu.h"
2525
#include "amdgpu_jpeg.h"
26+
#include "amdgpu_cs.h"
2627
#include "soc15.h"
2728
#include "soc15d.h"
2829
#include "vcn_v1_0.h"
@@ -34,6 +35,9 @@
3435
static void jpeg_v1_0_set_dec_ring_funcs(struct amdgpu_device *adev);
3536
static void jpeg_v1_0_set_irq_funcs(struct amdgpu_device *adev);
3637
static void jpeg_v1_0_ring_begin_use(struct amdgpu_ring *ring);
38+
static int jpeg_v1_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,
39+
struct amdgpu_job *job,
40+
struct amdgpu_ib *ib);
3741

3842
static void jpeg_v1_0_decode_ring_patch_wreg(struct amdgpu_ring *ring, uint32_t *ptr, uint32_t reg_offset, uint32_t val)
3943
{
@@ -300,7 +304,10 @@ static void jpeg_v1_0_decode_ring_emit_ib(struct amdgpu_ring *ring,
300304

301305
amdgpu_ring_write(ring,
302306
PACKETJ(SOC15_REG_OFFSET(JPEG, 0, mmUVD_LMI_JRBC_IB_VMID), 0, 0, PACKETJ_TYPE0));
303-
amdgpu_ring_write(ring, (vmid | (vmid << 4)));
307+
if (ring->funcs->parse_cs)
308+
amdgpu_ring_write(ring, 0);
309+
else
310+
amdgpu_ring_write(ring, (vmid | (vmid << 4)));
304311

305312
amdgpu_ring_write(ring,
306313
PACKETJ(SOC15_REG_OFFSET(JPEG, 0, mmUVD_LMI_JPEG_VMID), 0, 0, PACKETJ_TYPE0));
@@ -554,6 +561,7 @@ static const struct amdgpu_ring_funcs jpeg_v1_0_decode_ring_vm_funcs = {
554561
.get_rptr = jpeg_v1_0_decode_ring_get_rptr,
555562
.get_wptr = jpeg_v1_0_decode_ring_get_wptr,
556563
.set_wptr = jpeg_v1_0_decode_ring_set_wptr,
564+
.parse_cs = jpeg_v1_dec_ring_parse_cs,
557565
.emit_frame_size =
558566
6 + 6 + /* hdp invalidate / flush */
559567
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
@@ -611,3 +619,69 @@ static void jpeg_v1_0_ring_begin_use(struct amdgpu_ring *ring)
611619

612620
vcn_v1_0_set_pg_for_begin_use(ring, set_clocks);
613621
}
622+
623+
/**
624+
* jpeg_v1_dec_ring_parse_cs - command submission parser
625+
*
626+
* @parser: Command submission parser context
627+
* @job: the job to parse
628+
* @ib: the IB to parse
629+
*
630+
* Parse the command stream, return -EINVAL for invalid packet,
631+
* 0 otherwise
632+
*/
633+
static int jpeg_v1_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,
634+
struct amdgpu_job *job,
635+
struct amdgpu_ib *ib)
636+
{
637+
u32 i, reg, res, cond, type;
638+
int ret = 0;
639+
struct amdgpu_device *adev = parser->adev;
640+
641+
for (i = 0; i < ib->length_dw ; i += 2) {
642+
reg = CP_PACKETJ_GET_REG(ib->ptr[i]);
643+
res = CP_PACKETJ_GET_RES(ib->ptr[i]);
644+
cond = CP_PACKETJ_GET_COND(ib->ptr[i]);
645+
type = CP_PACKETJ_GET_TYPE(ib->ptr[i]);
646+
647+
if (res || cond != PACKETJ_CONDITION_CHECK0) /* only allow 0 for now */
648+
return -EINVAL;
649+
650+
if (reg >= JPEG_V1_REG_RANGE_START && reg <= JPEG_V1_REG_RANGE_END)
651+
continue;
652+
653+
switch (type) {
654+
case PACKETJ_TYPE0:
655+
if (reg != JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_HIGH &&
656+
reg != JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_LOW &&
657+
reg != JPEG_V1_LMI_JPEG_READ_64BIT_BAR_HIGH &&
658+
reg != JPEG_V1_LMI_JPEG_READ_64BIT_BAR_LOW &&
659+
reg != JPEG_V1_REG_CTX_INDEX &&
660+
reg != JPEG_V1_REG_CTX_DATA) {
661+
ret = -EINVAL;
662+
}
663+
break;
664+
case PACKETJ_TYPE1:
665+
if (reg != JPEG_V1_REG_CTX_DATA)
666+
ret = -EINVAL;
667+
break;
668+
case PACKETJ_TYPE3:
669+
if (reg != JPEG_V1_REG_SOFT_RESET)
670+
ret = -EINVAL;
671+
break;
672+
case PACKETJ_TYPE6:
673+
if (ib->ptr[i] != CP_PACKETJ_NOP)
674+
ret = -EINVAL;
675+
break;
676+
default:
677+
ret = -EINVAL;
678+
}
679+
680+
if (ret) {
681+
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
682+
break;
683+
}
684+
}
685+
686+
return ret;
687+
}

drivers/gpu/drm/amd/amdgpu/jpeg_v1_0.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,15 @@ int jpeg_v1_0_sw_init(void *handle);
2929
void jpeg_v1_0_sw_fini(void *handle);
3030
void jpeg_v1_0_start(struct amdgpu_device *adev, int mode);
3131

32+
#define JPEG_V1_REG_RANGE_START 0x8000
33+
#define JPEG_V1_REG_RANGE_END 0x803f
34+
35+
#define JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_HIGH 0x8238
36+
#define JPEG_V1_LMI_JPEG_WRITE_64BIT_BAR_LOW 0x8239
37+
#define JPEG_V1_LMI_JPEG_READ_64BIT_BAR_HIGH 0x825a
38+
#define JPEG_V1_LMI_JPEG_READ_64BIT_BAR_LOW 0x825b
39+
#define JPEG_V1_REG_CTX_INDEX 0x8328
40+
#define JPEG_V1_REG_CTX_DATA 0x8329
41+
#define JPEG_V1_REG_SOFT_RESET 0x83a0
42+
3243
#endif /*__JPEG_V1_0_H__*/

drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "amdgpu.h"
2525
#include "amdgpu_jpeg.h"
26+
#include "amdgpu_cs.h"
2627
#include "amdgpu_pm.h"
2728
#include "soc15.h"
2829
#include "soc15d.h"
@@ -538,7 +539,11 @@ void jpeg_v2_0_dec_ring_emit_ib(struct amdgpu_ring *ring,
538539

539540
amdgpu_ring_write(ring, PACKETJ(mmUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET,
540541
0, 0, PACKETJ_TYPE0));
541-
amdgpu_ring_write(ring, (vmid | (vmid << 4) | (vmid << 8)));
542+
543+
if (ring->funcs->parse_cs)
544+
amdgpu_ring_write(ring, 0);
545+
else
546+
amdgpu_ring_write(ring, (vmid | (vmid << 4) | (vmid << 8)));
542547

543548
amdgpu_ring_write(ring, PACKETJ(mmUVD_LMI_JPEG_VMID_INTERNAL_OFFSET,
544549
0, 0, PACKETJ_TYPE0));
@@ -764,6 +769,7 @@ static const struct amdgpu_ring_funcs jpeg_v2_0_dec_ring_vm_funcs = {
764769
.get_rptr = jpeg_v2_0_dec_ring_get_rptr,
765770
.get_wptr = jpeg_v2_0_dec_ring_get_wptr,
766771
.set_wptr = jpeg_v2_0_dec_ring_set_wptr,
772+
.parse_cs = jpeg_v2_dec_ring_parse_cs,
767773
.emit_frame_size =
768774
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
769775
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +
@@ -810,3 +816,58 @@ const struct amdgpu_ip_block_version jpeg_v2_0_ip_block = {
810816
.rev = 0,
811817
.funcs = &jpeg_v2_0_ip_funcs,
812818
};
819+
820+
/**
821+
* jpeg_v2_dec_ring_parse_cs - command submission parser
822+
*
823+
* @parser: Command submission parser context
824+
* @job: the job to parse
825+
* @ib: the IB to parse
826+
*
827+
* Parse the command stream, return -EINVAL for invalid packet,
828+
* 0 otherwise
829+
*/
830+
int jpeg_v2_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,
831+
struct amdgpu_job *job,
832+
struct amdgpu_ib *ib)
833+
{
834+
u32 i, reg, res, cond, type;
835+
struct amdgpu_device *adev = parser->adev;
836+
837+
for (i = 0; i < ib->length_dw ; i += 2) {
838+
reg = CP_PACKETJ_GET_REG(ib->ptr[i]);
839+
res = CP_PACKETJ_GET_RES(ib->ptr[i]);
840+
cond = CP_PACKETJ_GET_COND(ib->ptr[i]);
841+
type = CP_PACKETJ_GET_TYPE(ib->ptr[i]);
842+
843+
if (res) /* only support 0 at the moment */
844+
return -EINVAL;
845+
846+
switch (type) {
847+
case PACKETJ_TYPE0:
848+
if (cond != PACKETJ_CONDITION_CHECK0 || reg < JPEG_REG_RANGE_START ||
849+
reg > JPEG_REG_RANGE_END) {
850+
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
851+
return -EINVAL;
852+
}
853+
break;
854+
case PACKETJ_TYPE3:
855+
if (cond != PACKETJ_CONDITION_CHECK3 || reg < JPEG_REG_RANGE_START ||
856+
reg > JPEG_REG_RANGE_END) {
857+
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
858+
return -EINVAL;
859+
}
860+
break;
861+
case PACKETJ_TYPE6:
862+
if (ib->ptr[i] == CP_PACKETJ_NOP)
863+
continue;
864+
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
865+
return -EINVAL;
866+
default:
867+
dev_err(adev->dev, "Unknown packet type %d !\n", type);
868+
return -EINVAL;
869+
}
870+
}
871+
872+
return 0;
873+
}

drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
#define JRBC_DEC_EXTERNAL_REG_WRITE_ADDR 0x18000
4747

48+
#define JPEG_REG_RANGE_START 0x4000
49+
#define JPEG_REG_RANGE_END 0x41c2
50+
4851
void jpeg_v2_0_dec_ring_insert_start(struct amdgpu_ring *ring);
4952
void jpeg_v2_0_dec_ring_insert_end(struct amdgpu_ring *ring);
5053
void jpeg_v2_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq,
@@ -57,6 +60,9 @@ void jpeg_v2_0_dec_ring_emit_vm_flush(struct amdgpu_ring *ring,
5760
unsigned vmid, uint64_t pd_addr);
5861
void jpeg_v2_0_dec_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg, uint32_t val);
5962
void jpeg_v2_0_dec_ring_nop(struct amdgpu_ring *ring, uint32_t count);
63+
int jpeg_v2_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,
64+
struct amdgpu_job *job,
65+
struct amdgpu_ib *ib);
6066

6167
extern const struct amdgpu_ip_block_version jpeg_v2_0_ip_block;
6268

drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ static const struct amdgpu_ring_funcs jpeg_v2_5_dec_ring_vm_funcs = {
662662
.get_rptr = jpeg_v2_5_dec_ring_get_rptr,
663663
.get_wptr = jpeg_v2_5_dec_ring_get_wptr,
664664
.set_wptr = jpeg_v2_5_dec_ring_set_wptr,
665+
.parse_cs = jpeg_v2_dec_ring_parse_cs,
665666
.emit_frame_size =
666667
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
667668
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +
@@ -691,6 +692,7 @@ static const struct amdgpu_ring_funcs jpeg_v2_6_dec_ring_vm_funcs = {
691692
.get_rptr = jpeg_v2_5_dec_ring_get_rptr,
692693
.get_wptr = jpeg_v2_5_dec_ring_get_wptr,
693694
.set_wptr = jpeg_v2_5_dec_ring_set_wptr,
695+
.parse_cs = jpeg_v2_dec_ring_parse_cs,
694696
.emit_frame_size =
695697
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
696698
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +

drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ static const struct amdgpu_ring_funcs jpeg_v3_0_dec_ring_vm_funcs = {
560560
.get_rptr = jpeg_v3_0_dec_ring_get_rptr,
561561
.get_wptr = jpeg_v3_0_dec_ring_get_wptr,
562562
.set_wptr = jpeg_v3_0_dec_ring_set_wptr,
563+
.parse_cs = jpeg_v2_dec_ring_parse_cs,
563564
.emit_frame_size =
564565
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
565566
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +

drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ static const struct amdgpu_ring_funcs jpeg_v4_0_dec_ring_vm_funcs = {
727727
.get_rptr = jpeg_v4_0_dec_ring_get_rptr,
728728
.get_wptr = jpeg_v4_0_dec_ring_get_wptr,
729729
.set_wptr = jpeg_v4_0_dec_ring_set_wptr,
730+
.parse_cs = jpeg_v2_dec_ring_parse_cs,
730731
.emit_frame_size =
731732
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
732733
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +

drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ enum amdgpu_jpeg_v4_0_sub_block {
3232
};
3333

3434
extern const struct amdgpu_ip_block_version jpeg_v4_0_ip_block;
35-
3635
#endif /* __JPEG_V4_0_H__ */

drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
#include "amdgpu.h"
2525
#include "amdgpu_jpeg.h"
26-
#include "amdgpu_cs.h"
2726
#include "soc15.h"
2827
#include "soc15d.h"
28+
#include "jpeg_v2_0.h"
2929
#include "jpeg_v4_0_3.h"
3030
#include "mmsch_v4_0_3.h"
3131

@@ -1089,7 +1089,7 @@ static const struct amdgpu_ring_funcs jpeg_v4_0_3_dec_ring_vm_funcs = {
10891089
.get_rptr = jpeg_v4_0_3_dec_ring_get_rptr,
10901090
.get_wptr = jpeg_v4_0_3_dec_ring_get_wptr,
10911091
.set_wptr = jpeg_v4_0_3_dec_ring_set_wptr,
1092-
.parse_cs = jpeg_v4_0_3_dec_ring_parse_cs,
1092+
.parse_cs = jpeg_v2_dec_ring_parse_cs,
10931093
.emit_frame_size =
10941094
SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 +
10951095
SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +
@@ -1254,56 +1254,3 @@ static void jpeg_v4_0_3_set_ras_funcs(struct amdgpu_device *adev)
12541254
{
12551255
adev->jpeg.ras = &jpeg_v4_0_3_ras;
12561256
}
1257-
1258-
/**
1259-
* jpeg_v4_0_3_dec_ring_parse_cs - command submission parser
1260-
*
1261-
* @parser: Command submission parser context
1262-
* @job: the job to parse
1263-
* @ib: the IB to parse
1264-
*
1265-
* Parse the command stream, return -EINVAL for invalid packet,
1266-
* 0 otherwise
1267-
*/
1268-
int jpeg_v4_0_3_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,
1269-
struct amdgpu_job *job,
1270-
struct amdgpu_ib *ib)
1271-
{
1272-
uint32_t i, reg, res, cond, type;
1273-
struct amdgpu_device *adev = parser->adev;
1274-
1275-
for (i = 0; i < ib->length_dw ; i += 2) {
1276-
reg = CP_PACKETJ_GET_REG(ib->ptr[i]);
1277-
res = CP_PACKETJ_GET_RES(ib->ptr[i]);
1278-
cond = CP_PACKETJ_GET_COND(ib->ptr[i]);
1279-
type = CP_PACKETJ_GET_TYPE(ib->ptr[i]);
1280-
1281-
if (res) /* only support 0 at the moment */
1282-
return -EINVAL;
1283-
1284-
switch (type) {
1285-
case PACKETJ_TYPE0:
1286-
if (cond != PACKETJ_CONDITION_CHECK0 || reg < JPEG_REG_RANGE_START || reg > JPEG_REG_RANGE_END) {
1287-
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
1288-
return -EINVAL;
1289-
}
1290-
break;
1291-
case PACKETJ_TYPE3:
1292-
if (cond != PACKETJ_CONDITION_CHECK3 || reg < JPEG_REG_RANGE_START || reg > JPEG_REG_RANGE_END) {
1293-
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
1294-
return -EINVAL;
1295-
}
1296-
break;
1297-
case PACKETJ_TYPE6:
1298-
if (ib->ptr[i] == CP_PACKETJ_NOP)
1299-
continue;
1300-
dev_err(adev->dev, "Invalid packet [0x%08x]!\n", ib->ptr[i]);
1301-
return -EINVAL;
1302-
default:
1303-
dev_err(adev->dev, "Unknown packet type %d !\n", type);
1304-
return -EINVAL;
1305-
}
1306-
}
1307-
1308-
return 0;
1309-
}

drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646

4747
#define JRBC_DEC_EXTERNAL_REG_WRITE_ADDR 0x18000
4848

49-
#define JPEG_REG_RANGE_START 0x4000
50-
#define JPEG_REG_RANGE_END 0x41c2
51-
5249
extern const struct amdgpu_ip_block_version jpeg_v4_0_3_ip_block;
5350

5451
void jpeg_v4_0_3_dec_ring_emit_ib(struct amdgpu_ring *ring,
@@ -65,7 +62,5 @@ void jpeg_v4_0_3_dec_ring_insert_end(struct amdgpu_ring *ring);
6562
void jpeg_v4_0_3_dec_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg, uint32_t val);
6663
void jpeg_v4_0_3_dec_ring_emit_reg_wait(struct amdgpu_ring *ring, uint32_t reg,
6764
uint32_t val, uint32_t mask);
68-
int jpeg_v4_0_3_dec_ring_parse_cs(struct amdgpu_cs_parser *parser,
69-
struct amdgpu_job *job,
70-
struct amdgpu_ib *ib);
65+
7166
#endif /* __JPEG_V4_0_3_H__ */

0 commit comments

Comments
 (0)