MT8189 SMI SUPPORT
v3 cover MT8189 SMI SUPPORT
Based on tag: next-20260629, linux-next/master
This patchset add mt8189 smi support.
---
Changes in v3:
- Change the clock numbers of smi-sub-common to minium 3
- Link to v2:
https://lore.kernel.org/linux-mediatek/[email protected]/
---
Zhengnan Chen (2):
dt-bindings: memory-controllers: mtk-smi: Add support for mt8189
memory: mtk-smi: Add mt8189 support
.../mediatek,smi-common.yaml | 18 ++++++++ .../memory-controllers/mediatek,smi-larb.yaml | 3 ++ drivers/memory/mtk-smi.c | 44 +++++++++++++++++++ 3 files changed, 65 insertions(+)
Signature · 1 line
2.43.0
PATCH v3 1/2 dt-bindings: memory-controllers: mtk-smi: Add support for mt8189
From: Zhengnan Chen <[email protected]>
Add smi larb, common and sub-commom binding description for mt8189.
About what smi-sub-common is, please check the below diagram, we add it in mediatek,smi-common.yaml file.
--- .../mediatek,smi-common.yaml | 18 ++++++++++++++++++ .../memory-controllers/mediatek,smi-larb.yaml | 3 +++ 2 files changed, 21 insertions(+)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml +18 -0
@@ -25,6 +25,21 @@ description: | SMI generation 1 to transform the smi clock into emi clock domain, but that is not needed for SMI generation 2. + The smi-common connects with smi-larb and IOMMU. The maximum inputs number of + a smi-common is 8. In SMI generation 2, the engines number may be over 8. + In this case, we use a smi-sub-common to merge some larbs. + The block diagram something is like: + + IOMMU + | | + smi-common + --------------------------- + | | ... + larb0 sub-common ... <-max number is 8 + ---------------- + | | ... + larb1 larbX ... <-max number is 8 + properties: compatible: oneOf:
@@ -40,6 +55,8 @@ properties: - mediatek,mt8186-smi-common - mediatek,mt8188-smi-common-vdo - mediatek,mt8188-smi-common-vpp + - mediatek,mt8189-smi-common + - mediatek,mt8189-smi-sub-common - mediatek,mt8192-smi-common - mediatek,mt8195-smi-common-vdo - mediatek,mt8195-smi-common-vpp
@@ -108,6 +125,7 @@ allOf: compatible: contains: enum: + - mediatek,mt8189-smi-sub-common - mediatek,mt8195-smi-sub-common then: required:
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +3 -0
@@ -27,6 +27,7 @@ properties: - mediatek,mt8183-smi-larb - mediatek,mt8186-smi-larb - mediatek,mt8188-smi-larb + - mediatek,mt8189-smi-larb - mediatek,mt8192-smi-larb - mediatek,mt8195-smi-larb
@@ -85,6 +86,7 @@ allOf: - mediatek,mt8183-smi-larb - mediatek,mt8186-smi-larb - mediatek,mt8188-smi-larb + - mediatek,mt8189-smi-larb - mediatek,mt8195-smi-larb then:
@@ -119,6 +121,7 @@ allOf: - mediatek,mt6779-smi-larb - mediatek,mt8186-smi-larb - mediatek,mt8188-smi-larb + - mediatek,mt8189-smi-larb - mediatek,mt8192-smi-larb - mediatek,mt8195-smi-larb
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 1/2] dt-bindings: memory-controllers: mtk-smi: Add support for mt8189
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The newly added compatible string `mediatek,mt8189-smi-common` is omitted from the `if-then`…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The newly added compatible string mediatek,mt8189-smi-common is omitted from the if-then generational conditional blocks that define strict clock constraints.
- [Low] The SoC generation list in the binding description was not updated to include mt8189.
--
commit 6c2bad5d055d1f72dd33d20414abab2cdf2654cb
Author: Zhengnan Chen <[email protected]>
dt-bindings: memory-controllers: mtk-smi: Add support for mt8189
Add smi larb, common and sub-commom binding description for mt8189.
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml description: | · line 26
Quoted 7 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml +0
-0@@ -25,6 +25,21 @@ description: | SMI generation 1 to transform the smi clock into emi clock domain, but that is not needed for SMI generation 2.
[Severity: Low]
This isn't a bug, but the generation 2 SoC list earlier in this description block reads: "generation 2: mt2712, mt6779, mt8167, mt8173, mt8183, mt8186, mt8188, mt8192 and mt8195." Should mt8189 be added to this list as well?
Quoted 2 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml +2
-0+ The smi-common connects with smi-larb and IOMMU. The maximum inputs number of + a smi-common is 8. In SMI generation 2, the engines number may be over 8.
[ ... ]
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml properties: · line 59
Quoted 6 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml +2
-0@@ -40,6 +55,8 @@ properties: - mediatek,mt8186-smi-common - mediatek,mt8188-smi-common-vdo - mediatek,mt8188-smi-common-vpp + - mediatek,mt8189-smi-common + - mediatek,mt8189-smi-sub-common
[Severity: Medium]
Is mediatek,mt8189-smi-common missing from the generational conditional blocks that enforce strict clock constraints?
Looking further down in mediatek,smi-common.yaml at the allOf block:
- if: # for gen2 HW that have gals
properties:
compatible:
enum:
- mediatek,mt6779-smi-common
- mediatek,mt8183-smi-common
...
If mt8189-smi-common shares the same clock constraints as these Gen 2 devices, omitting it from this conditional block will cause device trees with invalid clock configurations to silently pass validation. Should it be added to the enum list here (or the corresponding Gen2 block without gals)?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v3 2/2 memory: mtk-smi: Add mt8189 support
In reply to Congcong YaoFrom: Zhengnan Chen <[email protected]>
Add the necessary platform data and ostdl setting to enable support for mt8189 smi.
--- drivers/memory/mtk-smi.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
drivers/memory/mtk-smi.c +44 -0
@@ -401,6 +401,30 @@ static const u8 mtk_smi_larb_mt8188_ostd[][SMI_LARB_PORT_NR_MAX] = { [25] = {0x01}, }; +static const u8 mtk_smi_larb_mt8189_ostd[][SMI_LARB_PORT_NR_MAX ] = { + [0 ] = {0x8 ,0x20 ,0x20 ,0x20 ,0x20 ,0x20 ,0x10 ,0x0 ,}, + [1 ] = {0x8 ,0x20 ,0x20 ,0x20 ,0x20 ,0x20 ,0x10 ,0x0 ,}, + [2 ] = {0x7 ,0x7 ,0x4 ,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,0x3 ,0x1 ,0x1 ,}, +}; +static const u8 mtk_smi_larb_mt8192_ostd[][SMI_LARB_PORT_NR_MAX ] = { [0 ] = {0x2 ,0x2 ,0x28 ,0xa ,0xc ,0x28 ,}, [1 ] = {0x2 ,0x2 ,0x18 ,0x18 ,0x18 ,0xa ,0xc ,0x28 ,},
@@ -533,6 +557,13 @@ static const struct mtk_smi_larb_gen mtk_smi_larb_mt8188 = { .ostd = mtk_smi_larb_mt8188_ostd, }; +static const struct mtk_smi_larb_gen mtk_smi_larb_mt8189 = { + .config_port = mtk_smi_larb_config_port_gen2_general, + .flags_general =MTK_SMI_FLAG_THRT_UPDATE |MTK_SMI_FLAG_SW_FLAG | +MTK_SMI_FLAG_SLEEP_CTL |MTK_SMI_FLAG_CFG_PORT_SEC_CTL , + .ostd = mtk_smi_larb_mt8189_ostd, +}; +static const struct mtk_smi_larb_gen mtk_smi_larb_mt8192 = { .config_port = mtk_smi_larb_config_port_gen2_general, .ostd = mtk_smi_larb_mt8192_ostd,
@@ -556,6 +587,7 @@ static const struct of_device_id mtk_smi_larb_of_ids[] = { {.compatible = "mediatek,mt8183-smi-larb", .data = &mtk_smi_larb_mt8183}, {.compatible = "mediatek,mt8186-smi-larb", .data = &mtk_smi_larb_mt8186}, {.compatible = "mediatek,mt8188-smi-larb", .data = &mtk_smi_larb_mt8188}, + {.compatible = "mediatek,mt8189-smi-larb", .data = &mtk_smi_larb_mt8189}, {.compatible = "mediatek,mt8192-smi-larb", .data = &mtk_smi_larb_mt8192}, {.compatible = "mediatek,mt8195-smi-larb", .data = &mtk_smi_larb_mt8195}, {}
@@ -808,6 +840,16 @@ static const struct mtk_smi_common_plat mtk_smi_common_mt8188_vpp = { .init = mtk_smi_common_mt8195_init, }; +static const struct mtk_smi_common_plat mtk_smi_common_mt8189 = { + .type =MTK_SMI_GEN2 , + .bus_sel =F_MMU1_LARB (1 ) |F_MMU1_LARB (3 ) |F_MMU1_LARB (5 ) | +F_MMU1_LARB (7 ), +}; + +static const struct mtk_smi_common_plat mtk_smi_sub_common_mt8189 = { + .type =MTK_SMI_GEN2_SUB_COMM , +}; +static const struct mtk_smi_common_plat mtk_smi_common_mt8192 = { .type =MTK_SMI_GEN2 , .has_gals = true,
@@ -852,6 +894,8 @@ static const struct of_device_id mtk_smi_common_of_ids[] = { {.compatible = "mediatek,mt8186-smi-common", .data = &mtk_smi_common_mt8186}, {.compatible = "mediatek,mt8188-smi-common-vdo", .data = &mtk_smi_common_mt8188_vdo}, {.compatible = "mediatek,mt8188-smi-common-vpp", .data = &mtk_smi_common_mt8188_vpp}, + {.compatible = "mediatek,mt8189-smi-common", .data = &mtk_smi_common_mt8189}, + {.compatible = "mediatek,mt8189-smi-sub-common", .data = &mtk_smi_sub_common_mt8189}, {.compatible = "mediatek,mt8192-smi-common", .data = &mtk_smi_common_mt8192}, {.compatible = "mediatek,mt8195-smi-common-vdo", .data = &mtk_smi_common_mt8195_vdo}, {.compatible = "mediatek,mt8195-smi-common-vpp", .data = &mtk_smi_common_mt8195_vpp},
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 2/2] memory: mtk-smi: Add mt8189 support
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Implicitly sized array mtk_smi_larb_mt8189_ostd may be accessed out of bounds for LARB IDs >= 21.…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Implicitly sized array mtk_smi_larb_mt8189_ostd may be accessed out of bounds for LARB IDs >= 21.
- [High] Explicit 0x0 values in mtk_smi_larb_mt8189_ostd cause premature loop termination. --
commit 34a5ce3e55a813425dbbd1c5607a1ed17951862b
Author: Zhengnan Chen <[email protected]>
memory: mtk-smi: Add mt8189 support
Add the necessary platform data and ostdl setting to enable support for mt8189 smi.
drivers/memory/mtk-smi.c static const u8 mtk_smi_larb_mt8188_ostd[][SMI_LARB_PORT_NR_MAX] = { · line 407
Quoted 12 lines
drivers/memory/mtk-smi.c +4
-0@@ -401,6 +401,30 @@ static const u8 mtk_smi_larb_mt8188_ostd[][SMI_LARB_PORT_NR_MAX] = { [25] = {0x01}, }; +static const u8 mtk_smi_larb_mt8189_ostd[][SMI_LARB_PORT_NR_MAX ] = { + [0 ] = {0x8 ,0x20 ,0x20 ,0x20 ,0x20 ,0x20 ,0x10 ,0x0 ,}, + [1 ] = {0x8 ,0x20 ,0x20 ,0x20 ,0x20 ,0x20 ,0x10 ,0x0 ,}, + [2 ] = {0x7 ,0x7 ,0x4 ,0x4 ,0x0 ,0x0 ,0x2 ,0x2 ,0x7 ,0x7 ,0x0 ,},
[Severity: High]
Does the inclusion of 0x0 values in this array cause valid hardware ports to be left uninitialized?
The initialization loop in mtk_smi_larb_config_port_gen2_general() treats a 0 value as the end of the array:
for (i = 0; i < SMI_LARB_PORT_NR_MAX && larbostd && !!larbostd[i]; i++)
writel_relaxed(larbostd[i], larb->base + SMI_LARB_OSTDL_PORTx(i));When it encounters the 0x0 at the fifth element of LARB 2, the loop will terminate immediately, ignoring the remaining configurations like 0x2 and 0x7.
[ ... ]
drivers/memory/mtk-smi.c static const u8 mtk_smi_larb_mt8188_ostd[][SMI_LARB_PORT_NR_MAX] = { · line 426
Quoted 3 lines
drivers/memory/mtk-smi.c +3
-0+ [19] = {0x2, 0x1, 0x3, 0x1,}, + [20] = {0x7, 0x7, 0x3, 0x3, 0x1, 0x1,}, +};
[Severity: High]
Will this implicitly sized array lead to an out-of-bounds read if the device tree probes a LARB with an ID of 21 or 22?
Because the largest index provided is 20, the array has exactly 21 elements. However, mtk_smi_larb_config_port_gen2_general() blindly accesses the array using the LARB ID:
const u8 *larbostd = larb->larb_gen->ostd ?
larb->larb_gen->ostd[larb->larbid] : NULL;If MT8189 defines LARB IDs up to at least 22, accessing index 21 or 22 will read past the end of the array and could write garbage data from read-only memory into hardware limit registers.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Krzysztof Kozlowski
maintainerQuoted 3 lines · Congcong Yao
Based on tag: next-20260629, linux-next/master
This patchset add mt8189 smi support.
b4 diff '<[email protected]>' Looking up
https://lore.kernel.org/all/[email protected]/
Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz Checking for older revisions
Grabbing search results from lore.kernel.org
---
Analyzing 5 messages in the thread
Could not find lower series to compare against.
I also do not see that you used b4 to submit. You are not making maintainer life easier. I will get back to this much later.
Best regards,
Krzysztof