drm/amdkfd: gfx12 trap handler DVGPR save/restore support
Subsystems (3)
PATCH 1/1 drm/amdkfd: gfx12 trap handler DVGPR save/restore support
A gfx12 wave using dynamic VGPRs is launched with a fixed 16-VGPR block and allocates the rest from a shared pool with s_alloc_vgpr.
- the fixed block (WAVE_MIN_NUM_DVGPRS, 16 VGPRs) continues to go to the CWSR buffer;
- the dynamic VGPRs go to the wave's scratch, which is durable per wave and therefore survives a restore that cannot reallocate them.
Persist wave's total VGPR count in a 4-byte per-lane
slot reserved at the front of the dynamic-VGPR scratch region, read back through a VGPR lane since scratch is per lane.
Restore reallocates with s_alloc_vgpr once SCRATCH_BASE is available and retries while the pool is full. If a context save becomes pending while the allocation still cannot be satisfied, waiting would block the very preemption that frees pool space, so the wave leaves its dynamic VGPRs in scratch, completes the restore without resuming the shader, and re-enters the save path at L_SAVE_BYPASS to be retried on a later restore. Such a re-save must not overwrite the persisted count. The live allocation has collapsed to the fixed block, and recording that would lose the real count and strand the dynamic VGPRs in scratch. Signal the condition in PC_HI bit 16.
--- .../gpu/drm/amd/amdkfd/cwsr_trap_handler.h | 355 +++++++++++------- .../amd/amdkfd/cwsr_trap_handler_gfx12.asm | 224 ++++++++++- 2 files changed, 437 insertions(+), 142 deletions(-)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h +215 -140
@@ -3644,7 +3644,7 @@ static const uint32_t cwsr_trap_gfx9_4_3_hex[] = { };static const uint32_t cwsr_trap_gfx12_hex[] = { -0xbfa00001 ,0xbfa00255 , +0xbfa00001 ,0xbfa0028f ,0xb0804009 ,0xb8f8f804 ,0xb8eef81a ,0xbf880000 ,0xb980081a ,0x00000000 ,
@@ -3721,7 +3721,10 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0x000c0000 ,0x00000000 ,0x7e000280 ,0xbefe007a ,0xbeff007b ,0xb8fb0742 , -0x847b997b ,0xb8fa3b05 , +0x847b997b ,0xb8faf802 , +0xbf0d9e7a ,0xbfa10003 , +0xbefa00ff ,0x00000800 , +0xbfa00007 ,0xb8fa3b05 ,0x807a817a ,0xbf0d997b ,0xbfa20002 ,0x847a897a , 0xbfa00001, 0x847a8a7a,
@@ -3762,6 +3765,9 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0xee0a4074 ,0x010c0000 ,0x00020000 ,0xee0a4074 ,0x018c0000 ,0x00030000 , +0xb8f0f802 ,0xbf0d9e70 , +0xbfa10003 ,0xbef000ff , +0x00000800 ,0xbfa00007 ,0xb8f03b05 ,0x80708170 ,0xbf0d9973 ,0xbfa20002 , 0x84708970, 0xbfa00001,
@@ -3804,7 +3810,10 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0xbeff0080 ,0x80767074 ,0x82778075 ,0xee0a4076 ,0x010c0000 ,0x00000000 , -0xbefe00c1 ,0xb8f03b05 , +0xbefe00c1 ,0xb8f0f802 , +0xbf0d9e70 ,0xbfa10003 , +0xbef000ff ,0x00000800 , +0xbfa00007 ,0xb8f03b05 ,0x80708170 ,0xbf0d9973 ,0xbfa20002 ,0x84708970 , 0xbfa00001, 0x84708a70,
@@ -3873,9 +3882,12 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0xbf06817d ,0xbfa20002 ,0xbeff0080 ,0xbfa00001 ,0xbeff00c1 ,0xb8fb4306 , -0x8b7bc17b ,0xbfa10042 , +0x8b7bc17b ,0xbfa10048 ,0x8b7aff6d ,0x80000000 , -0xbfa1003f ,0x847b897b , +0xbfa10045 ,0x847b897b , +0xb8f0f802 ,0xbf0d9e70 , +0xbfa10003 ,0xbef000ff , +0x00000800 ,0xbfa00007 ,0xb8f03b05 ,0x80708170 ,0xbf0d9973 ,0xbfa20002 , 0x84708970, 0xbfa00001,
@@ -3916,20 +3928,37 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0xb8fb3b05 ,0x807b817b ,0x847b827b ,0x857d9973 ,0x8b7d817d ,0xbf06817d , -0xbfa2001b ,0xbefd0084 , -0xbf0a7b7d ,0xbfa10032 , -0x7e008700 ,0x7e028701 , -0x7e048702 ,0x7e068703 , -0x80767074 ,0x82778075 , -0xee0a4076 ,0x000c0000 , -0x00000000 ,0xee0a4076 , -0x008c0000 ,0x00008000 , -0xee0a4076 ,0x010c0000 , -0x00010000 ,0xee0a4076 , -0x018c0000 ,0x00018000 , -0x807d847d ,0x8070ff70 , -0x00000200 ,0xbf0a7b7d , -0xbfa2ffe9 ,0xbfa0001a , +0xbfa2003d ,0xbefd0084 , +0xb8faf802 ,0xbf0a7b7d , +0xbfa10053 ,0x7e008700 , +0x7e028701 ,0x7e048702 , +0x7e068703 ,0x80767074 , +0x82778075 ,0xee0a4076 , +0x000c0000 ,0x00000000 , +0xee0a4076 ,0x008c0000 , +0x00008000 ,0xee0a4076 , +0x010c0000 ,0x00010000 , +0xee0a4076 ,0x018c0000 , +0x00018000 ,0x807d847d , +0xbf0d9e7a ,0xbfa10002 , +0xbf0a907d ,0xbfa10005 , +0x8070ff70 ,0x00000200 , +0xbf0a7b7d ,0xbfa2ffe5 , +0xbfa00037 ,0xbf0d906d , +0xbfa20035 ,0xbef00080 , +0x7e00027b ,0xed068070 , +0x00000000 ,0x00000000 , +0xbef00084 ,0xbf097b7d , +0xbfa2002d ,0x7e008700 , +0x7e028701 ,0x7e048702 , +0x7e068703 ,0xed068070 , +0x00000000 ,0x00000000 , +0xed068070 ,0x00800000 , +0x00000400 ,0xed068070 , +0x01000000 ,0x00000800 , +0xed068070 ,0x01800000 , +0x00000c00 ,0x807d847d , +0x80709070 ,0xbfa0ffeb ,0xbefd0084 ,0xbf0a7b7d ,0xbfa10017 ,0x7e008700 , 0x7e028701, 0x7e048702,
@@ -3943,17 +3972,20 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0x00030000 ,0x807d847d ,0x8070ff70 ,0x00000400 ,0xbf0a7b7d ,0xbfa2ffe9 , -0xbfa0014c ,0xbef4007e , +0xbfa001a9 ,0xbef4007e ,0x8b75ff7f ,0x0000ffff ,0xbef1007f ,0xb8f20742 ,0x84729972 ,0x8b6eff7f , -0x04000000 ,0xbfa10044 , +0x04000000 ,0xbfa1004a ,0xbefe00c1 ,0x857d9972 ,0x8b7d817d ,0xbf06817d ,0xbfa20002 ,0xbeff0080 ,0xbfa00001 ,0xbeff00c1 ,0xb8ef4306 ,0x8b6fc16f , -0xbfa10039 ,0x846f896f , +0xbfa1003f ,0x846f896f , +0xb8f8f802 ,0xbf0d9e78 , +0xbfa10003 ,0xbef800ff , +0x00000800 ,0xbfa00007 ,0xb8f83b05 ,0x80788178 ,0xbf0d9972 ,0xbfa20002 , 0x84788978, 0xbfa00001,
@@ -3986,134 +4018,177 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {0x857d9972 ,0x8b7d817d ,0xbf06817d ,0xbfa20002 ,0xbeff0080 ,0xbfa00001 , -0xbeff00c1 ,0xb8ef3b05 , -0x806f816f ,0x846f826f , -0x857d9972 ,0x8b7d817d , -0xbf06817d ,0xbfa2002c , -0xbeee0078 ,0x8078ff78 , -0x00000200 ,0xbefd0084 , -0x80767874 ,0x82778075 , -0xee0a0076 ,0x000c0000 , -0x00000000 ,0xee0a0076 , -0x000c0001 ,0x00008000 , -0xee0a0076 ,0x000c0002 , -0x00010000 ,0xee0a0076 , -0x000c0003 ,0x00018000 , -0xbf8a0000 ,0x7e008500 , -0x7e028501 ,0x7e048502 , -0x7e068503 ,0x807d847d , +0xbeff00c1 ,0xb8ecf802 , +0xbf0d9e6c ,0xbfa10002 , +0xbeef0090 ,0xbfa00003 , +0xb8ef3b05 ,0x806f816f , +0x846f826f ,0x857d9972 , +0x8b7d817d ,0xbf06817d , +0xbfa2002c ,0xbeee0078 ,0x8078ff78 ,0x00000200 , -0xbf0a6f7d ,0xbfa2ffe8 , -0x80766e74 ,0x82778075 , -0xee0a0076 ,0x000c0000 , -0x00000000 ,0xee0a0076 , -0x000c0001 ,0x00008000 , -0xee0a0076 ,0x000c0002 , -0x00010000 ,0xee0a0076 , -0x000c0003 ,0x00018000 , -0xbf8a0000 ,0xbfa0002d , -0xbeee0078 ,0x8078ff78 , -0x00000400 ,0xbefd0084 , -0xbf0a6f7d ,0xbfa10018 , -0x80767874 ,0x82778075 , -0xee0a0076 ,0x000c0000 , -0x00000000 ,0xee0a0076 , -0x000c0001 ,0x00010000 , -0xee0a0076 ,0x000c0002 , -0x00020000 ,0xee0a0076 , -0x000c0003 ,0x00030000 , -0xbf8a0000 ,0x7e008500 , -0x7e028501 ,0x7e048502 , -0x7e068503 ,0x807d847d , +0xbefd0084 ,0x80767874 , +0x82778075 ,0xee0a0076 , +0x000c0000 ,0x00000000 , +0xee0a0076 ,0x000c0001 , +0x00008000 ,0xee0a0076 , +0x000c0002 ,0x00010000 , +0xee0a0076 ,0x000c0003 , +0x00018000 ,0xbf8a0000 , +0x7e008500 ,0x7e028501 , +0x7e048502 ,0x7e068503 , +0x807d847d ,0x8078ff78 , +0x00000200 ,0xbf0a6f7d , +0xbfa2ffe8 ,0x80766e74 , +0x82778075 ,0xee0a0076 , +0x000c0000 ,0x00000000 , +0xee0a0076 ,0x000c0001 , +0x00008000 ,0xee0a0076 , +0x000c0002 ,0x00010000 , +0xee0a0076 ,0x000c0003 , +0x00018000 ,0xbf8a0000 , +0xbfa0002d ,0xbeee0078 ,0x8078ff78 ,0x00000400 , -0xbf0a6f7d ,0xbfa2ffe8 , -0x80766e74 ,0x82778075 , -0xee0a0076 ,0x000c0000 , -0x00000000 ,0xee0a0076 , -0x000c0001 ,0x00010000 , -0xee0a0076 ,0x000c0002 , -0x00020000 ,0xee0a0076 , -0x000c0003 ,0x00030000 , -0xbf8a0000 ,0xb8f83b05 , -0x80788178 ,0xbf0d9972 , -0xbfa20002 ,0x84788978 , -0xbfa00001 ,0x84788a78 , -0x8078ff78 ,0x00000200 , -0x80f8ff78 ,0x00000060 , -0x80767874 ,0x82778075 , -0xbefd00ff ,0x0000006c , -0xf460403b ,0xf8000000 , -0xbf8a0000 ,0x80fd847d , -0xbf800000 ,0xbe804300 , -0xbe824302 ,0x80f6a076 , -0x82f78077 ,0xf460603b , +0xbefd0084 ,0xbf0a6f7d , +0xbfa10018 ,0x80767874 , +0x82778075 ,0xee0a0076 , +0x000c0000 ,0x00000000 , +0xee0a0076 ,0x000c0001 , +0x00010000 ,0xee0a0076 , +0x000c0002 ,0x00020000 , +0xee0a0076 ,0x000c0003 , +0x00030000 ,0xbf8a0000 , +0x7e008500 ,0x7e028501 , +0x7e048502 ,0x7e068503 , +0x807d847d ,0x8078ff78 , +0x00000400 ,0xbf0a6f7d , +0xbfa2ffe8 ,0x80766e74 , +0x82778075 ,0xee0a0076 , +0x000c0000 ,0x00000000 , +0xee0a0076 ,0x000c0001 , +0x00010000 ,0xee0a0076 , +0x000c0002 ,0x00020000 , +0xee0a0076 ,0x000c0003 , +0x00030000 ,0xbf8a0000 , +0xb8f8f802 ,0xbf0d9e78 , +0xbfa10003 ,0xbef800ff , +0x00000800 ,0xbfa00007 , +0xb8f83b05 ,0x80788178 , +0xbf0d9972 ,0xbfa20002 , +0x84788978 ,0xbfa00001 , +0x84788a78 ,0x8078ff78 , +0x00000200 ,0x80f8ff78 , +0x00000060 ,0x80767874 , +0x82778075 ,0xbefd00ff , +0x0000006c ,0xf460403b ,0xf8000000 ,0xbf8a0000 , -0x80fd887d ,0xbf800000 , +0x80fd847d ,0xbf800000 ,0xbe804300 ,0xbe824302 , -0xbe844304 ,0xbe864306 , -0x80f6c076 ,0x82f78077 , -0xf460803b ,0xf8000000 , -0xbf8a0000 ,0x80fd907d , +0x80f6a076 ,0x82f78077 , +0xf460603b ,0xf8000000 , +0xbf8a0000 ,0x80fd887d ,0xbf800000 ,0xbe804300 ,0xbe824302 ,0xbe844304 , -0xbe864306 ,0xbe884308 , -0xbe8a430a ,0xbe8c430c , -0xbe8e430e ,0xbf06807d , -0xbfa1ffef ,0xb980f801 , -0x00000000 ,0xb8f83b05 , -0x80788178 ,0xbf0d9972 , -0xbfa20002 ,0x84788978 , -0xbfa00001 ,0x84788a78 , -0x8078ff78 ,0x00000200 , -0x80767874 ,0x82778075 , -0xbeff0071 ,0xf4601bfb , -0xf8000000 ,0xf4601b3b , -0xf8000004 ,0xf4601b7b , -0xf8000008 ,0xf4601c3b , -0xf800000c ,0xf4601c7b , -0xf8000010 ,0xf4601ebb , -0xf8000014 ,0xf4601efb , -0xf8000018 ,0xf4601e7b , -0xf800001c ,0xf4601cfb , -0xf8000020 ,0xf4601bbb , -0xf8000024 ,0xbf8a0000 , -0xb96ef814 ,0xf4601bbb , -0xf8000028 ,0xbf8a0000 , -0xb96ef815 ,0xf4601bbb , -0xf800002c ,0xbf8a0000 , -0xb96ef812 ,0xf4601bbb , -0xf8000030 ,0xbf8a0000 , -0xb96ef813 ,0x8b6eff7f , -0x04000000 ,0xbfa1000b , -0xf4601bbb ,0xf8000038 , -0xbf8a0000 ,0xbf0d806e , -0xbfa10006 ,0x856e906e , -0x8b6e6e6e ,0xbfa10003 , -0xbe804ec1 ,0x816ec16e , -0xbfa0fffb ,0xbefd006f , -0xbefe0070 ,0xbeff0071 , -0xb97b2011 ,0x857b867b , -0xb97b0191 ,0x857b827b , -0xb97bba11 ,0xb973f801 , -0xb8ee3b05 ,0x806e816e , +0xbe864306 ,0x80f6c076 , +0x82f78077 ,0xf460803b , +0xf8000000 ,0xbf8a0000 , +0x80fd907d ,0xbf800000 , +0xbe804300 ,0xbe824302 , +0xbe844304 ,0xbe864306 , +0xbe884308 ,0xbe8a430a , +0xbe8c430c ,0xbe8e430e , +0xbf06807d ,0xbfa1ffef , +0xb980f801 ,0x00000000 , +0xb8f8f802 ,0xbf0d9e78 , +0xbfa10003 ,0xbef800ff , +0x00000800 ,0xbfa00007 , +0xb8f83b05 ,0x80788178 ,0xbf0d9972 ,0xbfa20002 , -0x846e896e ,0xbfa00001 , -0x846e8a6e ,0x806eff6e , -0x00000240 ,0x806e746e , -0x826f8075 ,0xf4605c37 , -0xf8000010 ,0xf4605d37 , -0xf8000020 ,0xf4601e77 , -0xf8000034 ,0xbf8a0000 , -0x8b6dff6d ,0x0000ffff , -0x8bfe7e7e ,0x8bea6a6a , -0x936eff77 ,0x0002001a , -0xb96ef81a ,0xb97af804 , +0x84788978 ,0xbfa00001 , +0x84788a78 ,0x8078ff78 , +0x00000200 ,0x80767874 , +0x82778075 ,0xbeff0071 , +0xf4601bfb ,0xf8000000 , +0xf4601b3b ,0xf8000004 , +0xf4601b7b ,0xf8000008 , +0xf4601c3b ,0xf800000c , +0xf4601c7b ,0xf8000010 , +0xf4601ebb ,0xf8000014 , +0xf4601efb ,0xf8000018 , +0xf4601e7b ,0xf800001c , +0xf4601cfb ,0xf8000020 , +0xf4601bbb ,0xf8000024 , +0xbf8a0000 ,0xb96ef814 , +0xf4601bbb ,0xf8000028 , +0xbf8a0000 ,0xb96ef815 , +0xf4601bbb ,0xf800002c , +0xbf8a0000 ,0xb96ef812 , +0xf4601bbb ,0xf8000030 , +0xbf8a0000 ,0xb96ef813 , +0x8b6eff7f ,0x04000000 , +0xbfa1000b ,0xf4601bbb , +0xf8000038 ,0xbf8a0000 , +0xbf0d806e ,0xbfa10006 , +0x856e906e ,0x8b6e6e6e , +0xbfa10003 ,0xbe804ec1 , +0x816ec16e ,0xbfa0fffb , +0xbef80080 ,0xb8f6f802 , +0xbf0d9e76 ,0xbfa10036 , +0xbefe00c1 ,0xbef80080 , +0xed050078 ,0x00000000 , +0x00000000 ,0xbfc00000 , +0xd7600077 ,0x00010100 , +0xbe805377 ,0xbfa20006 , +0xb8f6f811 ,0x8b76a076 , +0xbf830010 ,0xbfa1fffa , +0xbef80081 ,0xbfa00019 , +0xbefd0090 ,0xbef80084 , +0xbf0a777d ,0xbfa10015 , +0xed050078 ,0x00000000 , +0x00000000 ,0xed050078 , +0x00000001 ,0x00000400 , +0xed050078 ,0x00000002 , +0x00000800 ,0xed050078 , +0x00000003 ,0x00000c00 , +0xbfc00000 ,0x7e008500 , +0x7e028501 ,0x7e048502 , +0x7e068503 ,0x807d847d , +0x80789078 ,0xbf0a777d , +0xbfa2ffeb ,0xee0a0074 , +0x000c0000 ,0x00000000 , +0xee0a0074 ,0x000c0001 , +0x00008000 ,0xee0a0074 , +0x000c0002 ,0x00010000 , +0xee0a0074 ,0x000c0003 , +0x00018000 ,0xbfc00000 , +0xbefd006f ,0xbefe0070 , +0xbeff0071 ,0xb97b2011 , +0x857b867b ,0xb97b0191 , +0x857b827b ,0xb97bba11 , +0xb973f801 ,0xb8eef802 , +0xbf0d9e6e ,0xbfa10003 , +0xbeee00ff ,0x00000800 , +0xbfa00007 ,0xb8ee3b05 , +0x806e816e ,0xbf0d9972 , +0xbfa20002 ,0x846e896e , +0xbfa00001 ,0x846e8a6e , +0x806eff6e ,0x00000240 , +0x806e746e ,0x826f8075 , +0xf4605c37 ,0xf8000010 , +0xf4605d37 ,0xf8000020 , +0xf4601e77 ,0xf8000034 , +0xbf8a0000 ,0x8b6dff6d , +0x0000ffff ,0x8bfe7e7e , +0x8bea6a6a ,0xbf068178 , +0xbfa10004 ,0xbef8007a , +0x8c6dff6d ,0x00010000 , +0xbfa0fc50 ,0x936eff77 , +0x0002001a ,0xb96ef81a , +0xb97af804 ,0xbe804ec2 , +0xbf94fffe ,0xbe804a6c ,0xbe804ec2 ,0xbf94fffe , -0xbe804a6c ,0xbe804ec2 , -0xbf94fffe ,0xbfb10000 , +0xbfb10000 ,0xbf9f0000 ,0xbf9f0000 ,0xbf9f0000 , 0xbf9f0000, 0xbf9f0000, - 0xbf9f0000, 0x00000000, }; static const uint32_t cwsr_trap_gfx9_5_0_hex[] = {
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx12.asm +222 -2
326 lines not on this page · raw message
Signature · 1 line
2.43.0