Skip to content

Commit f36e3f7

Browse files
lmorichealexdeucher
authored andcommitted
drm/amdkfd: Increase the size of the memory reserved for the TBA
In a future commit, the cwsr trap handler code size for gfx10.1 will increase to slightly above the one page mark. Since the TMA does not need to be page aligned, and only 2 pointers are stored in it, push the TMA offset by 2 KiB and keep the TBA+TMA reserved memory size to two pages. Signed-off-by: Laurent Morichetti <laurent.morichetti@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent bf90945 commit f36e3f7

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_device.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,34 +466,43 @@ static void kfd_cwsr_init(struct kfd_dev *kfd)
466466
{
467467
if (cwsr_enable && kfd->device_info.supports_cwsr) {
468468
if (KFD_GC_VERSION(kfd) < IP_VERSION(9, 0, 1)) {
469-
BUILD_BUG_ON(sizeof(cwsr_trap_gfx8_hex) > PAGE_SIZE);
469+
BUILD_BUG_ON(sizeof(cwsr_trap_gfx8_hex)
470+
> KFD_CWSR_TMA_OFFSET);
470471
kfd->cwsr_isa = cwsr_trap_gfx8_hex;
471472
kfd->cwsr_isa_size = sizeof(cwsr_trap_gfx8_hex);
472473
} else if (KFD_GC_VERSION(kfd) == IP_VERSION(9, 4, 1)) {
473-
BUILD_BUG_ON(sizeof(cwsr_trap_arcturus_hex) > PAGE_SIZE);
474+
BUILD_BUG_ON(sizeof(cwsr_trap_arcturus_hex)
475+
> KFD_CWSR_TMA_OFFSET);
474476
kfd->cwsr_isa = cwsr_trap_arcturus_hex;
475477
kfd->cwsr_isa_size = sizeof(cwsr_trap_arcturus_hex);
476478
} else if (KFD_GC_VERSION(kfd) == IP_VERSION(9, 4, 2)) {
477-
BUILD_BUG_ON(sizeof(cwsr_trap_aldebaran_hex) > PAGE_SIZE);
479+
BUILD_BUG_ON(sizeof(cwsr_trap_aldebaran_hex)
480+
> KFD_CWSR_TMA_OFFSET);
478481
kfd->cwsr_isa = cwsr_trap_aldebaran_hex;
479482
kfd->cwsr_isa_size = sizeof(cwsr_trap_aldebaran_hex);
480483
} else if (KFD_GC_VERSION(kfd) == IP_VERSION(9, 4, 3)) {
481-
BUILD_BUG_ON(sizeof(cwsr_trap_gfx9_4_3_hex) > PAGE_SIZE);
484+
BUILD_BUG_ON(sizeof(cwsr_trap_gfx9_4_3_hex)
485+
> KFD_CWSR_TMA_OFFSET);
482486
kfd->cwsr_isa = cwsr_trap_gfx9_4_3_hex;
483487
kfd->cwsr_isa_size = sizeof(cwsr_trap_gfx9_4_3_hex);
484488
} else if (KFD_GC_VERSION(kfd) < IP_VERSION(10, 1, 1)) {
485-
BUILD_BUG_ON(sizeof(cwsr_trap_gfx9_hex) > PAGE_SIZE);
489+
BUILD_BUG_ON(sizeof(cwsr_trap_gfx9_hex)
490+
> KFD_CWSR_TMA_OFFSET);
486491
kfd->cwsr_isa = cwsr_trap_gfx9_hex;
487492
kfd->cwsr_isa_size = sizeof(cwsr_trap_gfx9_hex);
488493
} else if (KFD_GC_VERSION(kfd) < IP_VERSION(10, 3, 0)) {
489-
BUILD_BUG_ON(sizeof(cwsr_trap_nv1x_hex) > PAGE_SIZE);
494+
BUILD_BUG_ON(sizeof(cwsr_trap_nv1x_hex)
495+
> KFD_CWSR_TMA_OFFSET);
490496
kfd->cwsr_isa = cwsr_trap_nv1x_hex;
491497
kfd->cwsr_isa_size = sizeof(cwsr_trap_nv1x_hex);
492498
} else if (KFD_GC_VERSION(kfd) < IP_VERSION(11, 0, 0)) {
493-
BUILD_BUG_ON(sizeof(cwsr_trap_gfx10_hex) > PAGE_SIZE);
499+
BUILD_BUG_ON(sizeof(cwsr_trap_gfx10_hex)
500+
> KFD_CWSR_TMA_OFFSET);
494501
kfd->cwsr_isa = cwsr_trap_gfx10_hex;
495502
kfd->cwsr_isa_size = sizeof(cwsr_trap_gfx10_hex);
496503
} else {
504+
/* The gfx11 cwsr trap handler must fit inside a single
505+
page. */
497506
BUILD_BUG_ON(sizeof(cwsr_trap_gfx11_hex) > PAGE_SIZE);
498507
kfd->cwsr_isa = cwsr_trap_gfx11_hex;
499508
kfd->cwsr_isa_size = sizeof(cwsr_trap_gfx11_hex);

drivers/gpu/drm/amd/amdkfd/kfd_priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@
9999
/*
100100
* Size of the per-process TBA+TMA buffer: 2 pages
101101
*
102-
* The first page is the TBA used for the CWSR ISA code. The second
103-
* page is used as TMA for user-mode trap handler setup in daisy-chain mode.
102+
* The first chunk is the TBA used for the CWSR ISA code. The second
103+
* chunk is used as TMA for user-mode trap handler setup in daisy-chain mode.
104104
*/
105105
#define KFD_CWSR_TBA_TMA_SIZE (PAGE_SIZE * 2)
106-
#define KFD_CWSR_TMA_OFFSET PAGE_SIZE
106+
#define KFD_CWSR_TMA_OFFSET (PAGE_SIZE + 2048)
107107

108108
#define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \
109109
(KFD_MAX_NUM_OF_PROCESSES * \

0 commit comments

Comments
 (0)