remoteproc/mediatek: support L1TCM for MT8192 SCP
Subsystems (3)
v3 cover remoteproc/mediatek: support L1TCM for MT8192 SCP
The series applies after [1].
The series supports L1TCM which is a high performance memory region in MT8192 SCP.
The 1st patch replaces platform_get_resource_byname() and devm_ioremap_resource() pairs per [2] suggested.
The 2nd patch enables MPU for all memory regions. The patch was independent but merged to this series per [3] suggested.
The 3rd patch adds a new reg-name "l1tcm" for L1TCM.
The 4th patch supports L1TCM in the firmware loader. Note that MT8192 SCP is still under development. The patch breaks early MT8192 SCP firmware which should only break our own development environment.
Changes from v2[4]:
- Rebases the series to [1].
Changes from v1[5]:
- Adds 2 patches at beginning of the series.
[1]: https://patchwork.kernel.org/project/linux-remoteproc/list/?series=422635
[2]: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/#23879113
[3]: https://patchwork.kernel.org/project/linux-remoteproc/patch/[email protected]/#23879623
[4]: https://patchwork.kernel.org/project/linux-remoteproc/list/?series=411065
[5]: https://patchwork.kernel.org/project/linux-remoteproc/list/?series=401287
Tzung-Bi Shih (4):
remoteproc/mediatek: use devm_platform_ioremap_resource_byname remoteproc/mediatek: enable MPU for all memory regions in MT8192 SCP
dt-bindings: remoteproc: mediatek: add L1TCM memory region remoteproc/mediatek: support L1TCM
.../bindings/remoteproc/mtk,scp.txt | 8 +-- drivers/remoteproc/mtk_common.h | 6 ++ drivers/remoteproc/mtk_scp.c | 62 +++++++++++++++++-- 3 files changed, 68 insertions(+), 8 deletions(-)
Signature · 7 lines
2.30.0.280.ga3ce27912f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v3 1/4 remoteproc/mediatek: use devm_platform_ioremap_resource_byname
Replaces platform_get_resource_byname() and devm_ioremap_resource() pairs to devm_platform_ioremap_resource_byname().
Note that, not every pairs are applicable to replace. Especially when it needs to access the resource struct from platform_get_resource_byname().
For example:scp->sram_size = resource_size(res);
--- drivers/remoteproc/mtk_scp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/remoteproc/mtk_scp.c +1 -2
@@ -721,8 +721,7 @@ static int scp_probe(struct platform_device *pdev)for (i =0 ; i <SCP_IPI_MAX ; i++)mutex_init (&scp->ipi_desc[i].lock); - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"cfg" ); - scp->reg_base =devm_ioremap_resource (dev, res); + scp->reg_base =devm_platform_ioremap_resource_byname (pdev,"cfg" );if (IS_ERR ((__force void *)scp->reg_base)) {dev_err (dev,"Failed to parse and map cfg memory\n" ); ret =PTR_ERR ((__force void *)scp->reg_base);
Signature · 1 line
2.30.0.280.ga3ce27912f-goog
PATCH v3 2/4 remoteproc/mediatek: enable MPU for all memory regions in MT8192 SCP
In reply to Tzung-Bi ShihThe register MT8192_CORE0_MEM_ATT_PREDEF contains attributes for each memory region. It defines whether a memory region can be managed by MPU or not.
In the past, due to the default settings in the register, MT8192 SCP works luckily. After enabling L1TCM, SCP starts to access memory region that is not included in the default settings. As a result, SCP hangs.
Enables MPU for all memory regions in MT8192 SCP.
Note that the register is read only once when SCP resets. Thus, it must be set from kernel side.
--- drivers/remoteproc/mtk_common.h | 1 + drivers/remoteproc/mtk_scp.c | 3 +++ 2 files changed, 4 insertions(+)
drivers/remoteproc/mtk_common.h +1 -0
@@ -47,6 +47,7 @@#define MT8192_CORE0_SW_RSTN_CLR 0x10000#define MT8192_CORE0_SW_RSTN_SET 0x10004 +#define MT8192_CORE0_MEM_ATT_PREDEF 0x10008#define MT8192_CORE0_WDT_IRQ 0x10030#define MT8192_CORE0_WDT_CFG 0x10034
drivers/remoteproc/mtk_scp.c +3 -0
@@ -371,6 +371,9 @@ static int mt8192_scp_before_load(struct mtk_scp *scp)mt8192_power_on_sram (scp->reg_base +MT8192_L1TCM_SRAM_PDN );mt8192_power_on_sram (scp->reg_base +MT8192_CPU0_SRAM_PD ); +/* enable MPU for all memory regions */ +writel (0xff , scp->reg_base +MT8192_CORE0_MEM_ATT_PREDEF ); +return 0 ; }
Signature · 1 line
2.30.0.280.ga3ce27912f-goog
PATCH v3 3/4 dt-bindings: remoteproc: mediatek: add L1TCM memory region
In reply to Tzung-Bi ShihAdds L1TCM memory region. The reg-name is "l1tcm".
--- Documentation/devicetree/bindings/remoteproc/mtk,scp.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.txt +4 -4
@@ -6,10 +6,10 @@ Mediatek SoCs. Required properties: - compatible Should be "mediatek,mt8183-scp" -- reg Should contain the address ranges for the two memory - regions, SRAM and CFG. -- reg-names Contains the corresponding names for the two memory - regions. These should be named "sram" & "cfg". +- reg Should contain the address ranges for memory regions: + SRAM, CFG, and L1TCM. +- reg-names Contains the corresponding names for the memory regions: + "sram", "cfg", and "l1tcm". - clocks Clock for co-processor (See: ../clock/clock-bindings.txt) - clock-names Contains the corresponding name for the clock. This should be named "main".
Signature · 7 lines
2.30.0.280.ga3ce27912f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v3 4/4 remoteproc/mediatek: support L1TCM
In reply to Tzung-Bi ShihL1TCM is a high performance memory region in MT8192 SCP.
Reads L1TCM memory region from DTS to determine if the machine supports. Loads L1TCM memory region to SCP sys if the firmware provides.
Starts from MT8192 SCP, the firmware contains physical addresses for each memory region, for instance:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0xXXXXXX 0xXXXXXXXX 0x10500000 0xXXXXX 0xXXXXX XXX 0xXXXX LOAD 0xXXXXXX 0xXXXXXXXX 0x10700000 0xXXXXX 0xXXXXX XXX 0xXXXX LOAD 0xXXXXXX 0xXXXXXXXX 0x50000000 0xXXXXX 0xXXXXX XXX 0xXXXX
Kernel driver can use the "PhysAddr" (i.e. da in the da_to_va callbacks) to know the ELF segment belongs to which region.
To backward compatible to MT8183 SCP, separates the da_to_va callbacks for new and legacy version.
--- drivers/remoteproc/mtk_common.h | 5 +++ drivers/remoteproc/mtk_scp.c | 56 +++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-)
drivers/remoteproc/mtk_common.h +5 -0
@@ -77,6 +77,7 @@ struct mtk_scp_of_data {void (*scp_reset_assert)(struct mtk_scp *scp);void (*scp_reset_deassert)(struct mtk_scp *scp);void (*scp_stop)(struct mtk_scp *scp); +void *(*scp_da_to_va)(struct mtk_scp *scp,u64 da,size_t len);u32 host_to_scp_reg;u32 host_to_scp_int_bit;
@@ -91,6 +92,10 @@ struct mtk_scp {void __iomem *reg_base;void __iomem *sram_base;size_t sram_size; +phys_addr_t sram_phys; +void __iomem *l1tcm_base; +size_t l1tcm_size; +phys_addr_t l1tcm_phys;const struct mtk_scp_of_data *data;
drivers/remoteproc/mtk_scp.c +54 -2
87 lines not on this page · raw message
Signature · 7 lines
2.30.0.280.ga3ce27912f-goog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
This series was applied to andersson/remoteproc.git (refs/heads/for-next):
Hello:
This series was applied to andersson/remoteproc.git (refs/heads/for-next):
Quoted 9 lines · On Wed, 27 Jan 2021 16:31:32 +0800 you wrote:
The series applies after [1].
The series supports L1TCM which is a high performance memory region in MT8192 SCP.
The 1st patch replaces
platform_get_resource_byname()anddevm_ioremap_resource()pairs per [2] suggested.[...]
Here is the summary with links:
- [v3,1/4] remoteproc/mediatek: use devm_platform_ioremap_resource_byname
https://git.kernel.org/andersson/remoteproc/c/2e88e8fcdfcd
- [v3,2/4] remoteproc/mediatek: enable MPU for all memory regions in MT8192 SCP
https://git.kernel.org/andersson/remoteproc/c/ff3ea536023e - [v3,3/4] dt-bindings: remoteproc: mediatek: add L1TCM memory region https://git.kernel.org/andersson/remoteproc/c/503c64cc42f1
- [v3,4/4] remoteproc/mediatek: support L1TCM
https://git.kernel.org/andersson/remoteproc/c/ca23ecfdbd44
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html