Skip to content

Commit 9af45bb

Browse files
tnmyshmathieupoirier
authored andcommitted
remoteproc: zynqmp: fix TCM carveouts in lockstep mode
In lockstep mode following is TCM address map: | *TCM* | *R5 View* | *Linux view* | | R5_0 ATCM (128 KB) | 0x0000_0000 | 0xFFE0_0000 | | R5_0 BTCM (128 KB) | 0x0002_0000 | 0xFFE2_0000 | Current driver keeps single TCM carveout in lockstep mode as ATCM and BTCM addresses form contiguous memory region. Although the addresses are contiguous, it is not same type of memory. ATCM typically holds interrupt or exception code that must be accessed at high speed. BTCM typically holds a block of data for intensive processing, such as audio or video processing. As both are different types of memory, they should be allocated as different carveout. This patch is fixing TCM carveout allocation in lockstep mode. Signed-off-by: Tanmay Shah <tanmay.shah@amd.com> Link: https://lore.kernel.org/r/20230913024323.2768114-1-tanmay.shah@amd.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent d1a8ac1 commit 9af45bb

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

drivers/remoteproc/xlnx_r5_remoteproc.c

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,21 @@ struct mbox_info {
7575
* Hardcoded TCM bank values. This will be removed once TCM bindings are
7676
* accepted for system-dt specifications and upstreamed in linux kernel
7777
*/
78-
static const struct mem_bank_data zynqmp_tcm_banks[] = {
78+
static const struct mem_bank_data zynqmp_tcm_banks_split[] = {
7979
{0xffe00000UL, 0x10000UL, PD_R5_0_ATCM, "atcm0"}, /* TCM 64KB each */
8080
{0xffe20000UL, 0x10000UL, PD_R5_0_BTCM, "btcm0"},
8181
{0xffe90000UL, 0x10000UL, PD_R5_1_ATCM, "atcm1"},
8282
{0xffeb0000UL, 0x10000UL, PD_R5_1_BTCM, "btcm1"},
8383
};
8484

85+
/* In lockstep mode cluster combines each 64KB TCM and makes 128KB TCM */
86+
static const struct mem_bank_data zynqmp_tcm_banks_lockstep[] = {
87+
{0xffe00000UL, 0x20000UL, PD_R5_0_ATCM, "atcm0"}, /* TCM 128KB each */
88+
{0xffe20000UL, 0x20000UL, PD_R5_0_BTCM, "btcm0"},
89+
{0, 0, PD_R5_1_ATCM, ""},
90+
{0, 0, PD_R5_1_BTCM, ""},
91+
};
92+
8593
/**
8694
* struct zynqmp_r5_core
8795
*
@@ -650,14 +658,11 @@ static int add_tcm_carveout_lockstep_mode(struct rproc *rproc)
650658
/*
651659
* In lockstep mode, TCM is contiguous memory block
652660
* However, each TCM block still needs to be enabled individually.
653-
* So, Enable each TCM block individually, but add their size
654-
* to create contiguous memory region.
661+
* So, Enable each TCM block individually.
662+
* Although ATCM and BTCM is contiguous memory block, add two separate
663+
* carveouts for both.
655664
*/
656-
bank_addr = r5_core->tcm_banks[0]->addr;
657-
bank_name = r5_core->tcm_banks[0]->bank_name;
658-
659665
for (i = 0; i < num_banks; i++) {
660-
bank_size += r5_core->tcm_banks[i]->size;
661666
pm_domain_id = r5_core->tcm_banks[i]->pm_domain_id;
662667

663668
/* Turn on each TCM bank individually */
@@ -668,23 +673,31 @@ static int add_tcm_carveout_lockstep_mode(struct rproc *rproc)
668673
dev_err(dev, "failed to turn on TCM 0x%x", pm_domain_id);
669674
goto release_tcm_lockstep;
670675
}
671-
}
672676

673-
dev_dbg(dev, "TCM add carveout lockstep mode %s addr=0x%llx, size=0x%lx",
674-
bank_name, bank_addr, bank_size);
675-
676-
/* Register TCM address range, TCM map and unmap functions */
677-
rproc_mem = rproc_mem_entry_init(dev, NULL, bank_addr,
678-
bank_size, bank_addr,
679-
tcm_mem_map, tcm_mem_unmap,
680-
bank_name);
681-
if (!rproc_mem) {
682-
ret = -ENOMEM;
683-
goto release_tcm_lockstep;
684-
}
677+
bank_size = r5_core->tcm_banks[i]->size;
678+
if (bank_size == 0)
679+
continue;
685680

686-
/* If registration is success, add carveouts */
687-
rproc_add_carveout(rproc, rproc_mem);
681+
bank_addr = r5_core->tcm_banks[i]->addr;
682+
bank_name = r5_core->tcm_banks[i]->bank_name;
683+
684+
/* Register TCM address range, TCM map and unmap functions */
685+
rproc_mem = rproc_mem_entry_init(dev, NULL, bank_addr,
686+
bank_size, bank_addr,
687+
tcm_mem_map, tcm_mem_unmap,
688+
bank_name);
689+
if (!rproc_mem) {
690+
ret = -ENOMEM;
691+
zynqmp_pm_release_node(pm_domain_id);
692+
goto release_tcm_lockstep;
693+
}
694+
695+
/* If registration is success, add carveouts */
696+
rproc_add_carveout(rproc, rproc_mem);
697+
698+
dev_dbg(dev, "TCM add carveout lockstep mode %s addr=0x%llx, size=0x%lx",
699+
bank_name, bank_addr, bank_size);
700+
}
688701

689702
return 0;
690703

@@ -895,12 +908,19 @@ static struct zynqmp_r5_core *zynqmp_r5_add_rproc_core(struct device *cdev)
895908
*/
896909
static int zynqmp_r5_get_tcm_node(struct zynqmp_r5_cluster *cluster)
897910
{
911+
const struct mem_bank_data *zynqmp_tcm_banks;
898912
struct device *dev = cluster->dev;
899913
struct zynqmp_r5_core *r5_core;
900914
int tcm_bank_count, tcm_node;
901915
int i, j;
902916

903-
tcm_bank_count = ARRAY_SIZE(zynqmp_tcm_banks);
917+
if (cluster->mode == SPLIT_MODE) {
918+
zynqmp_tcm_banks = zynqmp_tcm_banks_split;
919+
tcm_bank_count = ARRAY_SIZE(zynqmp_tcm_banks_split);
920+
} else {
921+
zynqmp_tcm_banks = zynqmp_tcm_banks_lockstep;
922+
tcm_bank_count = ARRAY_SIZE(zynqmp_tcm_banks_lockstep);
923+
}
904924

905925
/* count per core tcm banks */
906926
tcm_bank_count = tcm_bank_count / cluster->core_count;

0 commit comments

Comments
 (0)