MT8189: Add support for system and base clock controllers
Subsystems (6)
v2 cover MT8189: Add support for system and base clock controllers
This series is a continuation by AngeloGioacchino Del Regno and I of a previous series ([1]), that adds the clock controller support for the Mediatek MT8189 SoC and its variants (MT8371, MT8391).
The first major changes is the split of the series in two:
- one for all basic clock controllers including system ones (this series)
- one for the multimedia and graphics related clock controllers (to be send in the future)
We chose to separate the multimedia clock drivers from the base system ones, as there is currently an unsolvable inter-dependency between the power domains and multimedia clocks; the power domains need a dual-stage bring-up, where only a part of the multimedia clocks are accessible in the first power domain powerup stage, and the rest when the second stage (SRAM enablement) is done.
The current workarounds for this issue, such as removing the is_enabled operation from the impacted clock controllers clk_ops table or let the multimedia power domain always on, were quickly discarded for upstream.
The second major change is the dt-bindings patch that got heavily reworked, not only because of the split choice. We took the opportunity to regroup in the MT8186 clock and system clock dt-bindings the description of several other Mediatek SoC (MT8188, MT8192 and MT8195) and add in them the MT8189 new ones.
The rationale is to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
Finally the pending remarks from peer reviews on the v6 revision of [1] were also taken into account and new fixes and cleanups were also added.
A more detailed changelog between [1] and this series:
- Removed multimedia and graphics related clock controllers code and definitions from series
- Added new dt-bindings patches to factorise existing MT8188, MT8192 and MT8195 in MT8186 clock dt-bindings
- Heavily modified the MT8189 dt-bindings to add new compatibles in MT8186 clock dt-bindings
- Created a new dt-bindings include for the MT8189 reset controller definitions (include/dt-bindings/reset/mediatek,mt8189-resets.h)
- Removed unnecessary syscon compatible fallback from MT8189 base clock controllers
- Added missing 'mediatek,mt8189-fhctl' compatible declaration in dt-bindings
- Modified Kconfig to COMMON_CLK_MT8189 be tristate (and not bool) to allow all MT8189 clock controller drivers to be built as modules (it was partial)
- Fix pll unregisters in clk_mt8189_apmixed_probe error case
- Reparent several clocks to correct 26M references in clk-mt8189-bus.c, clk-mt8189-topckgen.c and clk-mt8189-vlpckgen.c
- Removed CLK_SET_RATE_NO_REPARENT flag from mfg_sel_mfgpll
- Rename TOPCKGEN_fmipi_csi_up26m clock to fmipi_csi_up26m to remove caps usage
- Implemented reset controllers in clk-mt8189-ufs.c
- Updated all file headers to update copyrights and add all authors
- Added all co-developed-by trailers
The series is based on linux-next tree (tag: next-20260630) and has been tested on Mediatek Genio 520-EVK (MT8371) and 720-EVK (MT8391) boards with board hardware enablement patch series ([3]).
[1]: https://lore.kernel.org/linux-mediatek/[email protected]/
[2]: https://lore.kernel.org/linux-mediatek/[email protected]/
[3]: https://lore.kernel.org/linux-mediatek/20260701-add-mediatek-genio-520-720-evk-v2-0-19d5da4ef984@collabora.com/
---
Changes in v2:
- Rebased on next-20260708 tag
- Added patch 1,2 and 3 to make the #clock-cells a required property in
MT8186, MT8192 and MT8195 clock controller dt-bindings
- Patch 5:
- Removed conditional blocks to check clock-cells property presence
for MT8188 clock controller compatible
- Reworded commit message to remove the note (no more applicable)
- Fixed incorrect property value in else block for #reset-cells
property check.
_ Removed from patch 9 conditional blocks to check clock-cells property
presence for MT8189 clock controller compatible
- Fixed missing MODULE_DEVICE_TABLE in patches 10, 11 and 12.
- Added devicetree series link in cover letter
- Link to v1: https://lore.kernel.org/r/20260701-mt8189-clocks-system-base-v1-0-2b048feea50a@collabora.com
---
Louis-Alexis Eyraud (18):
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
dt-bindings: clock: mediatek: reorder MT8186 compatibles
dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
dt-bindings: clock: mediatek: Add MT8189 clocks
clk: mediatek: Add MT8189 apmixedsys clock support
clk: mediatek: Add MT8189 topckgen clock support
clk: mediatek: Add MT8189 vlpckgen clock support
clk: mediatek: Add MT8189 vlpcfg clock support
clk: mediatek: Add MT8189 bus clock support
clk: mediatek: Add MT8189 dbgao clock support
clk: mediatek: Add MT8189 dvfsrc clock support
clk: mediatek: Add MT8189 i2c clock support
clk: mediatek: Add MT8189 scp clock support
clk: mediatek: Add MT8189 ufs clock support
.../bindings/clock/mediatek,mt8186-clock.yaml | 128 ++- .../bindings/clock/mediatek,mt8186-fhctl.yaml | 1 + .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 24 +- .../bindings/clock/mediatek,mt8188-clock.yaml | 93 -- .../bindings/clock/mediatek,mt8188-sys-clock.yaml | 58 -- .../bindings/clock/mediatek,mt8192-clock.yaml | 191 ---- .../bindings/clock/mediatek,mt8192-sys-clock.yaml | 68 -- .../bindings/clock/mediatek,mt8195-clock.yaml | 238 ----- .../bindings/clock/mediatek,mt8195-sys-clock.yaml | 76 -- drivers/clk/mediatek/Kconfig | 79 ++ drivers/clk/mediatek/Makefile | 8 + drivers/clk/mediatek/clk-mt8189-apmixedsys.c | 196 ++++ drivers/clk/mediatek/clk-mt8189-bus.c | 200 ++++ drivers/clk/mediatek/clk-mt8189-dbgao.c | 98 ++ drivers/clk/mediatek/clk-mt8189-dvfsrc.c | 58 ++ drivers/clk/mediatek/clk-mt8189-iic.c | 122 +++ drivers/clk/mediatek/clk-mt8189-scp.c | 77 ++ drivers/clk/mediatek/clk-mt8189-topckgen.c | 1025 ++++++++++++++++++++ drivers/clk/mediatek/clk-mt8189-ufs.c | 133 +++ drivers/clk/mediatek/clk-mt8189-vlpcfg.c | 116 +++ drivers/clk/mediatek/clk-mt8189-vlpckgen.c | 285 ++++++ include/dt-bindings/clock/mediatek,mt8189-clk.h | 433 +++++++++ include/dt-bindings/reset/mediatek,mt8189-resets.h | 17 + 23 files changed, 2988 insertions(+), 736 deletions(-)
---
base-commit: 451b00e20bcd5526c6def9ee76f9bdb322ae9b46
change-id: 20260630-mt8189-clocks-system-base-70714e4ff2aa
Best regards,
Signature · 1 line
Louis-Alexis Eyraud <[email protected]>
PATCH v2 1/18 dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186
Both MT8186 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.
--- Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml | 1 + Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +1 -0
@@ -44,6 +44,7 @@ properties: required: - compatible - reg + - '#clock-cells' additionalProperties: false
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +1 -0
@@ -45,6 +45,7 @@ properties: required: - compatible - reg + - '#clock-cells' additionalProperties: false
Signature · 1 line
2.55.0
Re: [PATCH v2 01/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186
Quoted 7 lines · Louis-Alexis Eyraud
Both MT8186 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.Signed-off-by Louis-Alexis Eyraud <[email protected]>
Though you could've done that in one commit, or just skipped the additions in all of mt8186/92/95 and went directly for the new one... IMO, it's ok as you're showing that there was an actual mistake on the bindings for clock controllers.
Same comment applies for patch 2 and 3, btw.
Anyway:
Conor Dooley
Acked-byRe: [PATCH v2 01/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186
Quoted 13 lines · AngeloGioacchino Del Regno
Quoted 7 lines · Louis-Alexis Eyraud
Both MT8186 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.Signed-off-by Louis-Alexis Eyraud <[email protected]>Though you could've done that in one commit, or just skipped the additions in all of mt8186/92/95 and went directly for the new one... IMO, it's ok as you're showing that there was an actual mistake on the bindings for clock controllers.
Quoted 6 lines
Same comment applies for patch 2 and 3, btw.
Anyway:
Reviewed-by AngeloGioacchino Del Regno <[email protected]>
Prob should have a fixes tag too.
pw-bot: not-applicable
(sorry if you got this twice, mutt crashed while sending)
PATCH v2 2/18 dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
In reply to Louis-Alexis EyraudBoth MT8192 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.
--- Documentation/devicetree/bindings/clock/mediatek,mt8192-clock.yaml | 1 + Documentation/devicetree/bindings/clock/mediatek,mt8192-sys-clock.yaml | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8192-clock.yaml +1 -0
@@ -46,6 +46,7 @@ properties: required: - compatible - reg + - '#clock-cells' additionalProperties: false
Documentation/devicetree/bindings/clock/mediatek,mt8192-sys-clock.yaml +1 -0
@@ -35,6 +35,7 @@ properties: required: - compatible - reg + - '#clock-cells' additionalProperties: false
Signature · 1 line
2.55.0
Re: [PATCH v2 02/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
Quoted 7 lines · Louis-Alexis Eyraud
Both MT8192 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.Signed-off-by Louis-Alexis Eyraud <[email protected]>
Conor Dooley
Acked-byRe: [PATCH v2 02/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
pw-bot: not-applicable
PATCH v2 3/18 dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
In reply to Louis-Alexis EyraudBoth MT8195 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.
--- Documentation/devicetree/bindings/clock/mediatek,mt8195-clock.yaml | 1 + Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8195-clock.yaml +1 -0
@@ -58,6 +58,7 @@ properties: required: - compatible - reg + - '#clock-cells' additionalProperties: false
Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml +1 -0
@@ -43,6 +43,7 @@ properties: required: - compatible - reg + - '#clock-cells' additionalProperties: false
Signature · 1 line
2.55.0
Re: [PATCH v2 03/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
Quoted 7 lines · Louis-Alexis Eyraud
Both MT8195 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.Signed-off-by Louis-Alexis Eyraud <[email protected]>
Re: [PATCH v2 03/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
In reply to Louis-Alexis Eyraudpw-bot: not-applicable
[email protected]
AI reviewRe: [PATCH v2 03/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
In reply to Louis-Alexis EyraudThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The mediatek,mt8195-sys-clock.yaml binding documents #reset-cells as a property but fails to enforce it conditionally for hardware variants that act as reset providers (e.g., mediatek,mt8195-infracfg_ao), and the example is missing it. --
--- Patch [3]: [PATCH v2 03/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195 --- commit 42e0c80a3dd56f332e8ace6fcaa3d35d00fa2f11
Author: Louis-Alexis Eyraud <[email protected]>
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
This commit updates the MT8195 clock and sys-clock device tree bindings. It adds the #clock-cells property to the required list to ensure clock provider nodes define it properly.
Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml properties: · line 46
Quoted 9 lines
Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml +1
-0@@ -43,6 +43,7 @@ properties: required: - compatible - reg + - '#clock-cells'
[Severity: High]
This is a pre-existing issue, but the mediatek,mt8195-sys-clock.yaml binding documents #reset-cells as a property but fails to enforce it conditionally for hardware variants that act as reset providers, such as mediatek,mt8195-infracfg_ao.
Should an allOf conditional block be added to enforce #reset-cells for these compatibles?
Without this constraint, an incomplete device tree node lacking #reset-cells for infracfg_ao will silently pass dt_binding_check validation. At runtime, dependent drivers like the thermal driver (which relies on MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST) could fail to probe or operate correctly.
Additionally, the example for infracfg_ao later in the file is missing the #reset-cells property:
- |
infracfg_ao: syscon@10001000 {
compatible = "mediatek,mt8195-infracfg_ao", "syscon";
reg = <0x10001000 0x1000>;
#clock-cells = <1>;
};If the constraint is properly added, wouldn't the example also need to be updated with #reset-cells = <1>; to prevent dt_binding_check from failing?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=3
PATCH v2 4/18 dt-bindings: clock: mediatek: reorder MT8186 compatibles
In reply to Louis-Alexis EyraudIn order to prepare regrouping several Mediatek SoC clock controller dt-bindings files into the MT8186 ones, reorder the MT8186 clock controller compatibles so they are sorted alphanumerically.
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 17 +++++++++-------- .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +9 -8
@@ -23,18 +23,19 @@ properties: compatible: items: - enum: - - mediatek,mt8186-imp_iic_wrap - - mediatek,mt8186-mfgsys - - mediatek,mt8186-wpesys - - mediatek,mt8186-imgsys1 - - mediatek,mt8186-imgsys2 - - mediatek,mt8186-vdecsys - - mediatek,mt8186-vencsys - mediatek,mt8186-camsys - mediatek,mt8186-camsys_rawa - mediatek,mt8186-camsys_rawb - - mediatek,mt8186-mdpsys + - mediatek,mt8186-imgsys1 + - mediatek,mt8186-imgsys2 + - mediatek,mt8186-imp_iic_wrap - mediatek,mt8186-ipesys + - mediatek,mt8186-mdpsys + - mediatek,mt8186-mfgsys + - mediatek,mt8186-vdecsys + - mediatek,mt8186-vencsys + - mediatek,mt8186-wpesys + reg: maxItems: 1
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +2 -2
@@ -27,10 +27,10 @@ properties: compatible: items: - enum: + - mediatek,mt8186-apmixedsys + - mediatek,mt8186-infracfg_ao - mediatek,mt8186-mcusys - mediatek,mt8186-topckgen - - mediatek,mt8186-infracfg_ao - - mediatek,mt8186-apmixedsys - const: syscon reg:
Signature · 1 line
2.55.0
Re: [PATCH v2 04/18] dt-bindings: clock: mediatek: reorder MT8186 compatibles
Quoted 5 lines · Louis-Alexis Eyraud
In order to prepare regrouping several Mediatek SoC clock controller dt-bindings files into the MT8186 ones, reorder the MT8186 clock controller compatibles so they are sorted alphanumerically.
Signed-off-by Louis-Alexis Eyraud <[email protected]>
Re: [PATCH v2 04/18] dt-bindings: clock: mediatek: reorder MT8186 compatibles
In reply to Louis-Alexis Eyraudpw-bot: not-applicable
PATCH v2 5/18 dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
In reply to Louis-Alexis EyraudRegroup the MT8188 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 50 +++++++++++- .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 6 +- .../bindings/clock/mediatek,mt8188-clock.yaml | 93 ---------------------- .../bindings/clock/mediatek,mt8188-sys-clock.yaml | 58 -------------- 4 files changed, 54 insertions(+), 153 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +49 -1
@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/clock/mediatek,mt8186-clock.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: MediaTek Functional Clock Controller for MT8186 +title: MediaTek Functional Clock Controller for Mediatek SoCs maintainers: - Chun-Jie Chen <[email protected]>
@@ -35,6 +35,29 @@ properties: - mediatek,mt8186-vdecsys - mediatek,mt8186-vencsys - mediatek,mt8186-wpesys + - mediatek,mt8188-adsp-audio26m + - mediatek,mt8188-camsys + - mediatek,mt8188-camsys-rawa + - mediatek,mt8188-camsys-rawb + - mediatek,mt8188-camsys-yuva + - mediatek,mt8188-camsys-yuvb + - mediatek,mt8188-ccusys + - mediatek,mt8188-imgsys + - mediatek,mt8188-imgsys-wpe1 + - mediatek,mt8188-imgsys-wpe2 + - mediatek,mt8188-imgsys-wpe3 + - mediatek,mt8188-imgsys1-dip-nr + - mediatek,mt8188-imgsys1-dip-top + - mediatek,mt8188-imp-iic-wrap-c + - mediatek,mt8188-imp-iic-wrap-en + - mediatek,mt8188-imp-iic-wrap-w + - mediatek,mt8188-ipesys + - mediatek,mt8188-mfgcfg + - mediatek,mt8188-vdecsys + - mediatek,mt8188-vdecsys-soc + - mediatek,mt8188-vencsys + - mediatek,mt8188-wpesys + - mediatek,mt8188-wpesys-vpp0 reg: maxItems: 1
@@ -42,11 +65,36 @@ properties: '#clock-cells': const: 1 + '#reset-cells': + const: 1 + required: - compatible - reg - '#clock-cells' +allOf: + - if: + properties: + compatible: + enum: + - mediatek,mt8188-camsys-rawa + - mediatek,mt8188-camsys-rawb + - mediatek,mt8188-camsys-yuva + - mediatek,mt8188-camsys-yuvb + - mediatek,mt8188-imgsys-wpe1 + - mediatek,mt8188-imgsys-wpe2 + - mediatek,mt8188-imgsys-wpe3 + - mediatek,mt8188-imgsys1-dip-nr + - mediatek,mt8188-imgsys1-dip-top + - mediatek,mt8188-ipesys + then: + required: + - '#reset-cells' + else: + properties: + '#reset-cells': false + additionalProperties: false examples:
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +5 -1
@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/clock/mediatek,mt8186-sys-clock.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: MediaTek System Clock Controller for MT8186 +title: MediaTek System Clock Controller for Mediatek SoCs maintainers: - Chun-Jie Chen <[email protected]>
@@ -31,6 +31,10 @@ properties: - mediatek,mt8186-infracfg_ao - mediatek,mt8186-mcusys - mediatek,mt8186-topckgen + - mediatek,mt8188-apmixedsys + - mediatek,mt8188-infracfg-ao + - mediatek,mt8188-pericfg-ao + - mediatek,mt8188-topckgen - const: syscon reg:
Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml deleted +0 -93
93 lines not on this page · raw message
Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml deleted +0 -58
58 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH v2 05/18] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
Quoted 13 lines · Louis-Alexis Eyraud
Regroup the MT8188 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
Signed-off-by Louis-Alexis Eyraud <[email protected]>--- .../bindings/clock/mediatek,mt8186-clock.yaml | 50 +++++++++++- .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 6 +- .../bindings/clock/mediatek,mt8188-clock.yaml | 93 ---------------------- .../bindings/clock/mediatek,mt8188-sys-clock.yaml | 58 -------------- 4 files changed, 54 insertions(+), 153 deletions(-)
..snip..
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml line 7
Quoted 10 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +1
-1@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/clock/mediatek,mt8186-sys-clock.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: MediaTek System Clock Controller for MT8186 +title: MediaTek System Clock Controller for Mediatek SoCs
"for<space><space>MediaTek SoCs"
You should really fix the double space, or if that can be fixed while applying, that's also fine for me.
So, with that fixed, either by you or while applying...
Re: [PATCH v2 05/18] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
In reply to Louis-Alexis Eyraudpw-bot: not-applicable
[email protected]
AI reviewRe: [PATCH v2 05/18] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
In reply to Louis-Alexis EyraudThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The `allOf` conditional block in `mediatek,mt8186-clock.yaml` is missing the `contains:` keyword…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The allOf conditional block in mediatek,mt8186-clock.yaml is missing the contains: keyword when matching the compatible property array against an enum, causing the condition to never match and falsely forbidding #reset-cells for all devices. --
--- Patch [5]: [PATCH v2 05/18] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186 --- commit 833611ff98aed20bc6663bc2bdced91c5491f806
Author: Louis-Alexis Eyraud <[email protected]>
dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
This commit regroups the MT8188 clock and system clock device tree bindings into the MT8186 bindings to ease maintainability and share common files for SoCs with similar clock controller designs.
Quoted 4 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +0
-0
[ ... ]
Quoted 8 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +3
-0@@ -42,11 +65,36 @@ properties: '#clock-cells': const: 1 + '#reset-cells': + const: 1 + required:
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml properties: · line 81
Quoted 10 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +6
-0- compatible - reg - '#clock-cells' +allOf: + - if: + properties: + compatible: + enum: + - mediatek,mt8188-camsys-rawa
[Severity: Medium]
When the MT8188 clock binding was moved here, the contains keyword was dropped from this conditional block.
Since the compatible property is evaluated as an array, matching it directly against an enum without the contains keyword evaluates to false.
Will this cause the else branch to execute unconditionally and falsely forbid the #reset-cells property for valid MT8188 device tree nodes during dt_binding_check validation?
Quoted 2 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +2
-0+ - mediatek,mt8188-camsys-rawb + - mediatek,mt8188-camsys-yuva
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=5
PATCH v2 6/18 dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
In reply to Louis-Alexis EyraudRegroup the MT8192 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 20 +++ .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 4 + .../bindings/clock/mediatek,mt8192-clock.yaml | 192 --------------------- .../bindings/clock/mediatek,mt8192-sys-clock.yaml | 69 -------- 4 files changed, 24 insertions(+), 261 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +20 -0
@@ -58,6 +58,26 @@ properties: - mediatek,mt8188-vencsys - mediatek,mt8188-wpesys - mediatek,mt8188-wpesys-vpp0 + - mediatek,mt8192-camsys + - mediatek,mt8192-camsys_rawa + - mediatek,mt8192-camsys_rawb + - mediatek,mt8192-camsys_rawc + - mediatek,mt8192-imgsys + - mediatek,mt8192-imgsys2 + - mediatek,mt8192-imp_iic_wrap_c + - mediatek,mt8192-imp_iic_wrap_e + - mediatek,mt8192-imp_iic_wrap_s + - mediatek,mt8192-imp_iic_wrap_ws + - mediatek,mt8192-imp_iic_wrap_w + - mediatek,mt8192-imp_iic_wrap_n + - mediatek,mt8192-ipesys + - mediatek,mt8192-mdpsys + - mediatek,mt8192-mfgcfg + - mediatek,mt8192-msdc_top + - mediatek,mt8192-scp_adsp + - mediatek,mt8192-vdecsys_soc + - mediatek,mt8192-vdecsys + - mediatek,mt8192-vencsys reg: maxItems: 1
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +4 -0
@@ -35,6 +35,10 @@ properties: - mediatek,mt8188-infracfg-ao - mediatek,mt8188-pericfg-ao - mediatek,mt8188-topckgen + - mediatek,mt8192-apmixedsys + - mediatek,mt8192-infracfg + - mediatek,mt8192-pericfg + - mediatek,mt8192-topckgen - const: syscon reg:
Documentation/devicetree/bindings/clock/mediatek,mt8192-clock.yaml deleted +0 -192
192 lines not on this page · raw message
Documentation/devicetree/bindings/clock/mediatek,mt8192-sys-clock.yaml deleted +0 -69
69 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH v2 06/18] dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
Quoted 6 lines · Louis-Alexis Eyraud
Regroup the MT8192 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
Signed-off-by Louis-Alexis Eyraud <[email protected]>
Re: [PATCH v2 06/18] dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
In reply to Louis-Alexis Eyraudpw-bot: not-applicable
[email protected]
AI reviewRe: [PATCH v2 06/18] dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
In reply to Louis-Alexis EyraudThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The if-then block conditionally requiring `#reset-cells` for MT8188 devices incorrectly uses…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The if-then block conditionally requiring #reset-cells for MT8188 devices incorrectly uses enum instead of contains: enum to match the compatible array. --
--- Patch [6]: [PATCH v2 06/18] dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186 --- commit 788afe3e2a2b9eb892a1f9b88e225e3204455c7a
Author: Louis-Alexis Eyraud <[email protected]>
dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
Regroup the MT8192 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml
Quoted 4 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +0
-0
[ ... ]
[Severity: Medium]
Looking at the schema validation in this file, there is a regression introduced in the prior patch of this series (dt-bindings: clock: mediatek:
regroup MT8188 dt-bindings into MT8186) where the if-then block evaluates the compatible array against a scalar string enum:
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml:allOf.if
allOf:
- if:
properties:
compatible:
enum:
- mediatek,mt8188-camsys-rawa
Is this evaluation correct for an array property?
Comparing the compatible array directly against an enum always fails. Consequently, valid device trees with MT8188 blocks and the required #reset-cells property fall into the else block (which enforces #reset-cells: false), leading to spurious schema validation failures when running make dtbs_check.
Could this be updated to use contains: enum to correctly match the compatible array?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=6
PATCH v2 7/18 dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
In reply to Louis-Alexis EyraudRegroup the MT8195 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 25 +++ .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 4 + .../bindings/clock/mediatek,mt8195-clock.yaml | 239 --------------------- .../bindings/clock/mediatek,mt8195-sys-clock.yaml | 77 ------- 4 files changed, 29 insertions(+), 316 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +25 -0
@@ -78,6 +78,31 @@ properties: - mediatek,mt8192-vdecsys_soc - mediatek,mt8192-vdecsys - mediatek,mt8192-vencsys + - mediatek,mt8195-apusys_pll + - mediatek,mt8195-camsys + - mediatek,mt8195-camsys_rawa + - mediatek,mt8195-camsys_yuva + - mediatek,mt8195-camsys_rawb + - mediatek,mt8195-camsys_yuvb + - mediatek,mt8195-camsys_mraw + - mediatek,mt8195-ccusys + - mediatek,mt8195-imgsys + - mediatek,mt8195-imgsys1_dip_top + - mediatek,mt8195-imgsys1_dip_nr + - mediatek,mt8195-imgsys1_wpe + - mediatek,mt8195-imp_iic_wrap_s + - mediatek,mt8195-imp_iic_wrap_w + - mediatek,mt8195-ipesys + - mediatek,mt8195-mfgcfg + - mediatek,mt8195-scp_adsp + - mediatek,mt8195-vdecsys_soc + - mediatek,mt8195-vdecsys + - mediatek,mt8195-vdecsys_core1 + - mediatek,mt8195-vencsys + - mediatek,mt8195-vencsys_core1 + - mediatek,mt8195-wpesys + - mediatek,mt8195-wpesys_vpp0 + - mediatek,mt8195-wpesys_vpp1 reg: maxItems: 1
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +4 -0
@@ -39,6 +39,10 @@ properties: - mediatek,mt8192-infracfg - mediatek,mt8192-pericfg - mediatek,mt8192-topckgen + - mediatek,mt8195-apmixedsys + - mediatek,mt8195-infracfg_ao + - mediatek,mt8195-pericfg_ao + - mediatek,mt8195-topckgen - const: syscon reg:
Documentation/devicetree/bindings/clock/mediatek,mt8195-clock.yaml deleted +0 -239
239 lines not on this page · raw message
Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml deleted +0 -77
77 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH v2 07/18] dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
Quoted 6 lines · Louis-Alexis Eyraud
Regroup the MT8195 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.
Signed-off-by Louis-Alexis Eyraud <[email protected]>
Re: [PATCH v2 07/18] dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
In reply to Louis-Alexis Eyraudpw-bot: not-applicable
PATCH v2 8/18 dt-bindings: clock: mediatek: Add MT8189 clocks
In reply to Louis-Alexis EyraudAdd dt schema and IDs for the clocks of MediaTek MT8189 SoC. The MT8189 clock IP provide clock control for main system (apmixedsys, topcksys and vlpcksys) and subsys (eg. peri, scp, ufs...).
Also, add compatible for frequency hopping and spread spectrum clock functionality and reset controller header file for MT8189 UFS reset controller support.
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 15 + .../bindings/clock/mediatek,mt8186-fhctl.yaml | 1 + .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 5 + include/dt-bindings/clock/mediatek,mt8189-clk.h | 433 +++++++++++++++++++++ include/dt-bindings/reset/mediatek,mt8189-resets.h | 17 + 5 files changed, 471 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +15 -0
@@ -58,6 +58,19 @@ properties: - mediatek,mt8188-vencsys - mediatek,mt8188-wpesys - mediatek,mt8188-wpesys-vpp0 + - mediatek,mt8189-dbg-ao + - mediatek,mt8189-dem + - mediatek,mt8189-dvfsrc-top + - mediatek,mt8189-iic-wrap-e + - mediatek,mt8189-iic-wrap-en + - mediatek,mt8189-iic-wrap-s + - mediatek,mt8189-iic-wrap-ws + - mediatek,mt8189-scp-clk + - mediatek,mt8189-scp-i2c-clk + - mediatek,mt8189-ufscfg-ao + - mediatek,mt8189-ufscfg-pdn + - mediatek,mt8189-vlpcfg + - mediatek,mt8189-vlpcfg-ao - mediatek,mt8192-camsys - mediatek,mt8192-camsys_rawa - mediatek,mt8192-camsys_rawb
@@ -133,6 +146,8 @@ allOf: - mediatek,mt8188-imgsys1-dip-nr - mediatek,mt8188-imgsys1-dip-top - mediatek,mt8188-ipesys + - mediatek,mt8189-ufscfg-ao + - mediatek,mt8189-ufscfg-pdn then: required: - '#reset-cells'
Documentation/devicetree/bindings/clock/mediatek,mt8186-fhctl.yaml +1 -0
@@ -20,6 +20,7 @@ properties: - mediatek,mt6795-fhctl - mediatek,mt8173-fhctl - mediatek,mt8186-fhctl + - mediatek,mt8189-fhctl - mediatek,mt8192-fhctl - mediatek,mt8195-fhctl
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +5 -0
@@ -35,6 +35,11 @@ properties: - mediatek,mt8188-infracfg-ao - mediatek,mt8188-pericfg-ao - mediatek,mt8188-topckgen + - mediatek,mt8189-apmixedsys + - mediatek,mt8189-infra-ao + - mediatek,mt8189-peri-ao + - mediatek,mt8189-topckgen + - mediatek,mt8189-vlpckgen - mediatek,mt8192-apmixedsys - mediatek,mt8192-infracfg - mediatek,mt8192-pericfg
include/dt-bindings/clock/mediatek,mt8189-clk.h new file +433 -0
433 lines not on this page · raw message
include/dt-bindings/reset/mediatek,mt8189-resets.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (c) 2026 Collabora Ltd. +* Author: Louis-Alexis Eyraud <[email protected]> +*/ + +#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT8189 +#define _DT_BINDINGS_RESET_CONTROLLER_MT8189 + +/* UFS resets */ +#define MT8189_UFSAO_RST_UFS_MPHY 0 + +#define MT8189_UFSPDN_RST_UFS_UNIPRO 0 +#define MT8189_UFSPDN_RST_UFS_CRYPTO 1 +#define MT8189_UFSPDN_RST_UFS_HCI 2 + +#endif /* _DT_BINDINGS_RESET_CONTROLLER_MT8189 */
Signature · 1 line
2.55.0
Re: [PATCH v2 08/18] dt-bindings: clock: mediatek: Add MT8189 clocks
Quoted 5 lines · Louis-Alexis Eyraud
Add dt schema and IDs for the clocks of MediaTek MT8189 SoC. The MT8189 clock IP provide clock control for main system (apmixedsys, topcksys and vlpcksys) and subsys (eg. peri, scp, ufs...).
Quoted 7 lines
Also, add compatible for frequency hopping and spread spectrum clock functionality and reset controller header file for MT8189 UFS reset controller support.
Co-developed-by Irving-CH Lin <[email protected]>Signed-off-by Irving-CH Lin <[email protected]>Signed-off-by Louis-Alexis Eyraud <[email protected]>
Both the commit description and title are misleading, as in, you're not adding MT8189 clocks, but *both* clocks *and* resets.
Fix it please.
After which:
Quoted 8 lines
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 15 + .../bindings/clock/mediatek,mt8186-fhctl.yaml | 1 + .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 5 + include/dt-bindings/clock/mediatek,mt8189-clk.h | 433 +++++++++++++++++++++ include/dt-bindings/reset/mediatek,mt8189-resets.h | 17 + 5 files changed, 471 insertions(+)
Conor Dooley
Acked-byRe: [PATCH v2 08/18] dt-bindings: clock: mediatek: Add MT8189 clocks
Quoted 14 lines · AngeloGioacchino Del Regno
Quoted 5 lines · Louis-Alexis Eyraud
Add dt schema and IDs for the clocks of MediaTek MT8189 SoC. The MT8189 clock IP provide clock control for main system (apmixedsys, topcksys and vlpcksys) and subsys (eg. peri, scp, ufs...).
Quoted 7 lines
Also, add compatible for frequency hopping and spread spectrum clock functionality and reset controller header file for MT8189 UFS reset controller support.
Co-developed-by Irving-CH Lin <[email protected]>Signed-off-by Irving-CH Lin <[email protected]>Signed-off-by Louis-Alexis Eyraud <[email protected]>
Quoted 8 lines
Both the commit description and title are misleading, as in, you're not adding MT8189 clocks, but *both* clocks *and* resets.
Fix it please.
After which:
Reviewed-by AngeloGioacchino Del Regno <[email protected]>
And
pw-bot: changes-requested
Cheers,
Conor.
Quoted 11 lines
Quoted 9 lines
--- .../bindings/clock/mediatek,mt8186-clock.yaml | 15 + .../bindings/clock/mediatek,mt8186-fhctl.yaml | 1 + .../bindings/clock/mediatek,mt8186-sys-clock.yaml | 5 + include/dt-bindings/clock/mediatek,mt8189-clk.h | 433 +++++++++++++++++++++ include/dt-bindings/reset/mediatek,mt8189-resets.h | 17 + 5 files changed, 471 insertions(+)
PATCH v2 9/18 clk: mediatek: Add MT8189 apmixedsys clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 apmixedsys clock controller, which provides PLLs generated from SoC 26m.
--- drivers/clk/mediatek/Kconfig | 13 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-apmixedsys.c | 196 +++++++++++++++++++++++++++ 3 files changed, 210 insertions(+)
drivers/clk/mediatek/Kconfig +13 -0
@@ -815,6 +815,19 @@ config COMMON_CLK_MT8188_WPESYS help This driver supports MediaTek MT8188 Warp Engine clocks. +config COMMON_CLK_MT8189 + tristate "Clock driver for MediaTek MT8189" + depends on ARM64 || COMPILE_TEST + select COMMON_CLK_MEDIATEK + select COMMON_CLK_MEDIATEK_FHCTL + default ARCH_MEDIATEK + help + Enable this option to support the clock management for MediaTek MT8189 SoC. This + includes handling of all primary clock functions and features specific to the MT8189 + platform. Enabling this driver ensures that the system's clock functionality aligns + with the MediaTek MT8189 hardware capabilities, providing efficient management of + clock speeds and power consumption. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -123,6 +123,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o +obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 09/18] clk: mediatek: Add MT8189 apmixedsys clock support
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] FHCTL I/O memory mapped by fhctl_parse_dt() is leaked if mtk_clk_register_pllfhs() fails during probe.
Pre-existing issues:
- [High] Dangling I/O pointers in the static pllfhs array can lead to a use-after-free Data Abort on driver re-probe. --
--- Patch [9]: [PATCH v2 09/18] clk: mediatek: Add MT8189 apmixedsys clock support --- commit 5ceb4e2595f9e63ad996ab6c91c8b563477a9fc7
Author: Louis-Alexis Eyraud <[email protected]>
clk: mediatek: Add MT8189 apmixedsys clock support
Add support for the MT8189 apmixedsys clock controller, which provides PLLs generated from SoC 26m.
Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +0
-0
[ ... ]
Quoted 15 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +15
-0+static struct mtk_pllfh_data pllfhs[] = { +FH (CLK_APMIXED_ARMPLL_LL ,0 ,0x003C ), +FH (CLK_APMIXED_ARMPLL_BL ,1 ,0x0050 ), +FH (CLK_APMIXED_CCIPLL ,2 ,0x0064 ), +FH (CLK_APMIXED_MAINPLL ,3 ,0x0078 ), +FH (CLK_APMIXED_MMPLL ,4 ,0x008C ), +FH (CLK_APMIXED_MFGPLL ,5 ,0x00A0 ), +FH (CLK_APMIXED_EMIPLL ,6 ,0x00B4 ), +FH (CLK_APMIXED_TVDPLL1 ,7 ,0x00C8 ), +FH (CLK_APMIXED_TVDPLL2 ,8 ,0x00DC ), +FH (CLK_APMIXED_MSDCPLL ,9 ,0x00F0 ), +FH (CLK_APMIXED_UFSPLL ,10 ,0x0104 ), +FH (CLK_APMIXED_APUPLL ,11 ,0x0118 ), +FH (CLK_APMIXED_APUPLL2 ,12 ,0x012c ), +};
[ ... ]
drivers/clk/mediatek/clk-mt8189-apmixedsys.c line 152
Quoted 13 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +13
-0+static int clk_mt8189_apmixed_probe (struct platform_device *pdev) +{ +int r; +struct clk_hw_onecell_data *clk_data; +struct device_node *node = pdev->dev.of_node; +const u8 *fhctl_node ="mediatek,mt8189-fhctl" ; + + clk_data =mtk_alloc_clk_data (ARRAY_SIZE (apmixed_plls)); +if (!clk_data) +return -ENOMEM ; + +fhctl_parse_dt (fhctl_node, pllfhs,ARRAY_SIZE (pllfhs)); +
[Severity: High]
This is a pre-existing issue, but does unbinding and re-probing this driver create a use-after-free risk with the static pllfhs array?
When the driver is unbound, mtk_clk_unregister_pllfhs() unmaps the FHCTL base but leaves the state.base pointer and state.fh_enable flag set in the static array:
drivers/clk/mediatek/clk-pllfh.c:mtk_clk_unregister_pllfhs() {
...
if (fhctl_base)
iounmap(fhctl_base);
...
}If the driver is then re-probed and fhctl_parse_dt() encounters an error (like an of_iomap failure), it returns without clearing the static array.
When probe proceeds to mtk_clk_register_pllfhs(), will it see fh_enable == 1 and attempt to access the unmapped I/O memory left over in state.base?
drivers/clk/mediatek/clk-mt8189-apmixedsys.c line 156
Quoted 4 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +4
-0+ r =mtk_clk_register_pllfhs (&pdev->dev, apmixed_plls,ARRAY_SIZE (apmixed_plls), + pllfhs,ARRAY_SIZE (pllfhs), clk_data); +if (r) + goto free_apmixed_data;
[Severity: Medium]
If mtk_clk_register_pllfhs() fails here, does the error handling path leak the I/O memory mapped by fhctl_parse_dt()?
The goto jumps directly to free_apmixed_data, completely bypassing the unregister_plls label where the unmapping would normally happen.
Quoted 16 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +16
-0+ + r =of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); +if (r) + goto unregister_plls; + +platform_set_drvdata (pdev, clk_data); + +return 0 ; + +unregister_plls: +mtk_clk_unregister_pllfhs (apmixed_plls,ARRAY_SIZE (apmixed_plls), pllfhs, +ARRAY_SIZE (pllfhs), clk_data); +free_apmixed_data: +mtk_free_clk_data (clk_data); +return r; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=9
PATCH v2 10/18 clk: mediatek: Add MT8189 topckgen clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 topckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8189-topckgen.c | 1025 ++++++++++++++++++++++++++++ 2 files changed, 1026 insertions(+), 1 deletion(-)
drivers/clk/mediatek/Makefile +1 -1
@@ -123,7 +123,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o -obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o +obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +1025 -0
1,025 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 10/18] clk: mediatek: Add MT8189 topckgen clock support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-After-Free in the clock notifier unregistration path on driver removal. --
--- Patch [10]: [PATCH v2 10/18] clk: mediatek: Add MT8189 topckgen clock support --- commit 5d23b090dfc84556b649dbc1711e28c8f0b06604
Author: Louis-Alexis Eyraud <[email protected]>
clk: mediatek: Add MT8189 topckgen clock support
Add support for the MT8189 topckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.
Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +0
-0
[ ... ]
Quoted 14 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +14
-0+static int clk_mt8189_reg_mfg_mux_notifier (struct device *dev, +struct clk *clk) +{ +struct mtk_mux_nb *mfg_mux_nb; + + mfg_mux_nb =devm_kzalloc (dev,sizeof (*mfg_mux_nb),GFP_KERNEL ); +if (!mfg_mux_nb) +return -ENOMEM ; + + mfg_mux_nb->ops = &mtk_mux_clr_set_upd_ops; + mfg_mux_nb->bypass_index =0 ;/* Bypass to CLK_TOP_MFG_REF_SEL */ + +return devm_mtk_clk_mux_notifier_register (dev, clk, mfg_mux_nb); +}
[ ... ]
drivers/clk/mediatek/clk-mt8189-topckgen.c line 1016
Quoted 3 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +3
-0+static struct platform_driver clk_mt8189_topck_drv = { + .probe = mtk_clk_simple_probe, + .remove = mtk_clk_simple_remove,
[Severity: High]
This is a pre-existing issue, but does combining devm_mtk_clk_mux_notifier_register() with mtk_clk_simple_remove() lead to a use-after-free on driver unbind?
When the driver is unbound, the .remove callback (mtk_clk_simple_remove) is executed first, which manually unregisters and frees the clocks.
After .remove completes, the devres framework executes its teardown routines. This triggers the release of the notifier registered via devm_mtk_clk_mux_notifier_register(), causing clk_notifier_unregister() to be called with the already-freed clk pointer.
Can this sequence cause memory corruption when the freed clock pointer is dereferenced?
Quoted 6 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +6
-0+ .driver = { + .name = "clk-mt8189-topck", + .of_match_table = of_match_clk_mt8189_topck, + }, +}; +module_platform_driver (clk_mt8189_topck_drv);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=10
PATCH v2 11/18 clk: mediatek: Add MT8189 vlpckgen clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 vlpckgen clock controller, which provides muxes and dividers for clock selection in vlp domain for other IP blocks.
--- drivers/clk/mediatek/Makefile | 3 +- drivers/clk/mediatek/clk-mt8189-vlpckgen.c | 285 +++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+), 1 deletion(-)
drivers/clk/mediatek/Makefile +2 -1
@@ -123,7 +123,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o -obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o +obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \ + clk-mt8189-vlpckgen.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-vlpckgen.c new file +285 -0
285 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 12/18 clk: mediatek: Add MT8189 vlpcfg clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 vlpcfg clock controller, which provides clock gate control for vlp domain IPs.
--- drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mt8189-vlpcfg.c | 116 +++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-)
drivers/clk/mediatek/Makefile +1 -1
@@ -124,7 +124,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \ - clk-mt8189-vlpckgen.o + clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-vlpcfg.c new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 13/18 clk: mediatek: Add MT8189 bus clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 bus clock controller, which provides clock gate control for infra/peri IPs (such as spi, uart, msdc, flashif ...).
--- drivers/clk/mediatek/Kconfig | 11 ++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-bus.c | 200 ++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+)
drivers/clk/mediatek/Kconfig +11 -0
@@ -828,6 +828,17 @@ config COMMON_CLK_MT8189 with the MediaTek MT8189 hardware capabilities, providing efficient management of clock speeds and power consumption. +config COMMON_CLK_MT8189_BUS + tristate "Clock driver for MediaTek MT8189 bus" + depends on COMMON_CLK_MT8189 + default COMMON_CLK_MT8189 + help + Enable this configuration option to support the clock framework for + MediaTek MT8189 SoC bus clocks. It includes the necessary clock + management for bus-related peripherals and interconnects within the + MT8189 chipset, ensuring that all bus-related components receive the + correct clock signals for optimal performance. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -125,6 +125,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \ clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o +obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-bus.c new file +200 -0
200 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 14/18 clk: mediatek: Add MT8189 dbgao clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 dbgao clock controller, which provides clock gate control for debug-system.
--- drivers/clk/mediatek/Kconfig | 10 ++++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-dbgao.c | 98 +++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+)
drivers/clk/mediatek/Kconfig +10 -0
@@ -839,6 +839,16 @@ config COMMON_CLK_MT8189_BUS MT8189 chipset, ensuring that all bus-related components receive the correct clock signals for optimal performance. +config COMMON_CLK_MT8189_DBGAO + tristate "Clock driver for MediaTek MT8189 debug ao" + depends on COMMON_CLK_MT8189 + default COMMON_CLK_MT8189 + help + Enable this to support the clock management for the debug function + on MediaTek MT8189 SoCs. This includes enabling and disabling + vcore debug system clocks. If you want to control its clocks, say Y or M + to include this driver in your kernel build. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -126,6 +126,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \ clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o +obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-dbgao.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 15/18 clk: mediatek: Add MT8189 dvfsrc clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 dvfsrc clock controller, which provides clock gate control for dram dvfs.
--- drivers/clk/mediatek/Kconfig | 10 ++++++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-dvfsrc.c | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+)
drivers/clk/mediatek/Kconfig +10 -0
@@ -849,6 +849,16 @@ config COMMON_CLK_MT8189_DBGAO vcore debug system clocks. If you want to control its clocks, say Y or M to include this driver in your kernel build. +config COMMON_CLK_MT8189_DVFSRC + tristate "Clock driver for MediaTek MT8189 dvfsrc" + depends on COMMON_CLK_MT8189 + default COMMON_CLK_MT8189 + help + Enable this to support the clock management for the dvfsrc + on MediaTek MT8189 SoCs. This includes enabling and disabling + vcore dvfs clocks. If you want to control its clocks, say Y or M + to include this driver in your kernel build. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -127,6 +127,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o +obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-dvfsrc.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 15/18] clk: mediatek: Add MT8189 dvfsrc clock support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free in __mtk_clk_simple_probe error path due to missing of_clk_del_provider(). --
--- Patch [15]: [PATCH v2 15/18] clk: mediatek: Add MT8189 dvfsrc clock support --- commit 5ea7dacd6f8e27b2d8c56bae31053477a67a2318
Author: Louis-Alexis Eyraud <[email protected]>
clk: mediatek: Add MT8189 dvfsrc clock support
This patch adds support for the MT8189 dvfsrc clock controller. This controller provides clock gate control for DRAM DVFS.
Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-dvfsrc.c new file +0
-0
[ ... ]
drivers/clk/mediatek/clk-mt8189-dvfsrc.c line 48
Quoted 2 lines
drivers/clk/mediatek/clk-mt8189-dvfsrc.c new file +2
-0+static struct platform_driver clk_mt8189_dvfsrc_drv = { + .probe = mtk_clk_simple_probe,
[Severity: High]
This is a pre-existing issue, but does the error path in __mtk_clk_simple_probe() leave a dangling pointer?
When mtk_clk_simple_probe() is called, it wraps __mtk_clk_simple_probe(). If the clock provider is successfully added, but resetting the controller fails:
drivers/clk/mediatek/clk-mtk.c:__mtk_clk_simple_probe() {
...
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r)
goto unregister_clks;
platform_set_drvdata(pdev, clk_data);
if (mcd->rst_desc) {
r = mtk_register_reset_controller_with_dev(&pdev->dev,
mcd->rst_desc);
if (r)
goto unregister_clks;
}...
It jumps to unregister_clks which eventually frees the clk_data:
unregister_clks:
...free_data:
mtk_free_clk_data(clk_data);
...
}
Since of_clk_del_provider() is never called in this error path, doesn't this leave a freed clk_data pointer in the global of_clk_providers list, leading to a use-after-free on the next clock lookup?
Quoted 7 lines
drivers/clk/mediatek/clk-mt8189-dvfsrc.c new file +7
-0+ .remove = mtk_clk_simple_remove, + .driver = { + .name = "clk-mt8189-dvfsrc", + .of_match_table = of_match_clk_mt8189_dvfsrc, + }, +}; +module_platform_driver (clk_mt8189_dvfsrc_drv);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=15
PATCH v2 16/18 clk: mediatek: Add MT8189 i2c clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 i2c clock controller,
which provides clock gate control for i2c.
--- drivers/clk/mediatek/Kconfig | 13 ++++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-iic.c | 122 ++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+)
drivers/clk/mediatek/Kconfig +13 -0
@@ -859,6 +859,19 @@ config COMMON_CLK_MT8189_DVFSRC vcore dvfs clocks. If you want to control its clocks, say Y or M to include this driver in your kernel build. +config COMMON_CLK_MT8189_IIC + tristate "Clock driver for MediaTek MT8189 iic" + depends on COMMON_CLK_MT8189 + default COMMON_CLK_MT8189 + help + Enable this option to support the clock framework for MediaTek MT8189 + integrated circuits (iic). This driver is responsible for managing + clock sources, dividers, and gates specifically designed for MT8189 + SoCs. Enabling this driver ensures that the system can correctly + manage clock frequencies and power for various components within + the MT8189 chipset, improving the overall performance and power + efficiency of the device. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -128,6 +128,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o +obj-$(CONFIG_COMMON_CLK_MT8189_IIC) += clk-mt8189-iic.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-iic.c new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 17/18 clk: mediatek: Add MT8189 scp clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 scp clock controller, which provides clock gate control for System Control Processor.
--- drivers/clk/mediatek/Kconfig | 10 +++++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-scp.c | 77 +++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+)
drivers/clk/mediatek/Kconfig +10 -0
@@ -872,6 +872,16 @@ config COMMON_CLK_MT8189_IIC the MT8189 chipset, improving the overall performance and power efficiency of the device. +config COMMON_CLK_MT8189_SCP + tristate "Clock driver for MediaTek MT8189 scp" + depends on COMMON_CLK_MT8189 + default COMMON_CLK_MT8189 + help + Enable this to support the clock framework for the System Control + Processor (SCP) in the MediaTek MT8189 SoC. This includes clock + management for SCP-related features, ensuring proper clock + distribution and gating for power efficiency and functionality. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -129,6 +129,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o obj-$(CONFIG_COMMON_CLK_MT8189_IIC) += clk-mt8189-iic.o +obj-$(CONFIG_COMMON_CLK_MT8189_SCP) += clk-mt8189-scp.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-scp.c new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 17/18] clk: mediatek: Add MT8189 scp clock support
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Incorrect sta_ofs in scp_cg_regs causes clock state tracking failures.
Pre-existing issues:
- [High] Missing of_clk_del_provider() in the error path of __mtk_clk_simple_probe() leads to a dangling clock provider and subsequent Use-After-Free.
- [Medium] Memory leak of the struct mtk_clk_gate allocation in mtk_clk_register_gate().
--
--- Patch [17]: [PATCH v2 17/18] clk: mediatek: Add MT8189 scp clock support --- commit 622c7d611c5de5d2297fc568f0bb3702456cb016
Author: Louis-Alexis Eyraud <[email protected]>
clk: mediatek: Add MT8189 scp clock support
This commit adds support for the MT8189 scp clock controller. It provides clock gate control for the System Control Processor by defining the necessary gate clocks and registering them with the common clock framework.
Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-scp.c new file +0
-0@@ -0,0 +1,77 @@
[ ... ]
drivers/clk/mediatek/clk-mt8189-scp.c line 25
Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-scp.c new file +5
-0+static const struct mtk_gate_regs scp_cg_regs = { + .set_ofs =0x4 , + .clr_ofs =0x8 , + .sta_ofs =0x4 , +};
[Severity: High]
Is this sta_ofs correct? Most other MediaTek clock drivers with differing set and clr registers use 0x0 for the sta register. If reading from offset 0x4 returns garbage or write-only trigger values, could this break the common clock framework's is_enabled checks and cause incorrect reference counting?
[ ... ]
This is a pre-existing issue, but there appears to be a dangling clock provider in the error path of __mtk_clk_simple_probe():
drivers/clk/mediatek/clk-mtk.c:__mtk_clk_simple_probe() {
...
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r)
goto unregister_clks;
platform_set_drvdata(pdev, clk_data);
if (mcd->rst_desc) {
r = mtk_register_reset_controller_with_dev(&pdev->dev,
mcd->rst_desc);
if (r)
goto unregister_clks;
...
unregister_clks:
if (mcd->clks)
mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
...
}[Severity: High]
If mtk_register_reset_controller_with_dev() fails, we jump to unregister_clks, which unregisters the clocks and frees clk_data. Does this leave the device node registered as a clock provider pointing to freed memory, since of_clk_del_provider(node) is never called in this error path? Could this lead to a use-after-free when another driver attempts to get a clock?
This is another pre-existing issue, but there appears to be a memory leak in mtk_clk_register_gate():
drivers/clk/mediatek/clk-gate.c:mtk_clk_register_gate() {
...
cg = kzalloc_obj(*cg);
if (!cg)
return ERR_PTR(-ENOMEM);
init.name = gate->name;
init.flags = gate->flags | CLK_SET_RATE_PARENT;
init.parent_names = gate->parent_name ? &gate->parent_name : NULL;
init.num_parents = gate->parent_name ? 1 : 0;
init.ops = gate->ops;
if (mtk_cg_uses_hwv(init.ops) && !regmap_hwv)
return dev_err_ptr_probe(
dev, -ENXIO,
"regmap not found for hardware voter clocks\n");
...
}[Severity: Medium]
If a clock gate requires a hardware voter regmap but none was found, the function early-returns an error. Are we leaking the newly allocated cg structure here by returning directly without freeing it?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=17
PATCH v2 18/18 clk: mediatek: Add MT8189 ufs clock support
In reply to Louis-Alexis EyraudAdd support for the MT8189 ufs clock controller, which provides clock gate control for Universal Flash Storage.
--- drivers/clk/mediatek/Kconfig | 12 +++ drivers/clk/mediatek/Makefile | 1 + drivers/clk/mediatek/clk-mt8189-ufs.c | 133 ++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+)
drivers/clk/mediatek/Kconfig +12 -0
@@ -882,6 +882,18 @@ config COMMON_CLK_MT8189_SCP management for SCP-related features, ensuring proper clock distribution and gating for power efficiency and functionality. +config COMMON_CLK_MT8189_UFS + tristate "Clock driver for MediaTek MT8189 ufs" + depends on COMMON_CLK_MT8189 + default COMMON_CLK_MT8189 + help + Enable this to support the clock management for the Universal Flash + Storage (UFS) interface on MediaTek MT8189 SoCs. This includes + clock sources, dividers, and gates that are specific to the UFS + feature of the MT8189 platform. It is recommended to enable this + option if the system includes a UFS device that relies on the MT8189 + SoC for clock management. + config COMMON_CLK_MT8192 tristate "Clock driver for MediaTek MT8192" depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
@@ -130,6 +130,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o obj-$(CONFIG_COMMON_CLK_MT8189_IIC) += clk-mt8189-iic.o obj-$(CONFIG_COMMON_CLK_MT8189_SCP) += clk-mt8189-scp.o +obj-$(CONFIG_COMMON_CLK_MT8189_UFS) += clk-mt8189-ufs.o obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8189-ufs.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 18/18] clk: mediatek: Add MT8189 ufs clock support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing of_clk_del_provider() in the error path of __mtk_clk_simple_probe() leaves a dangling clock provider pointer, leading to a potential use-after-free. --
--- Patch [18]: [PATCH v2 18/18] clk: mediatek: Add MT8189 ufs clock support --- commit 9858e88b79ed61ffe0a3b2d09755d7d4f94f084e
Author: Louis-Alexis Eyraud <[email protected]>
clk: mediatek: Add MT8189 ufs clock support
This commit adds support for the MT8189 UFS clock controller, providing clock gate control for Universal Flash Storage. It introduces a new driver handling clock sources, dividers, and gates specific to the MT8189 platform.
Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-ufs.c new file +0
-0
[ ... ]
drivers/clk/mediatek/clk-mt8189-ufs.c line 68
Quoted 12 lines
drivers/clk/mediatek/clk-mt8189-ufs.c new file +12
-0+static const struct mtk_clk_rst_desc ufscfg_ao_rst_desc = { + .version =MTK_RST_SET_CLR , + .rst_bank_ofs = ufscfg_ao_rst_ofs, + .rst_bank_nr =ARRAY_SIZE (ufscfg_ao_rst_ofs), + .rst_idx_map = ufscfg_ao_rst_idx_map, + .rst_idx_map_nr =ARRAY_SIZE (ufscfg_ao_rst_idx_map), +}; + +static const struct mtk_clk_desc ufscfg_ao_reg_mcd = { + .clks = ufscfg_ao_reg_clks, + .num_clks =ARRAY_SIZE (ufscfg_ao_reg_clks), + .rst_desc = &ufscfg_ao_rst_desc,
[Severity: High]
This is a pre-existing issue, but does setting .rst_desc here expose a potential use-after-free in the probe error path?
Looking at __mtk_clk_simple_probe() in drivers/clk/mediatek/clk-mtk.c:
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r)
goto unregister_clks;
platform_set_drvdata(pdev, clk_data);
if (mcd->rst_desc) {
r = mtk_register_reset_controller_with_dev(&pdev->dev,
mcd->rst_desc);
if (r)
goto unregister_clks;
}If mtk_register_reset_controller_with_dev() fails, the code jumps to unregister_clks, which frees clk_data without calling of_clk_del_provider(). Any subsequent attempt to resolve a clock from this node could trigger a use-after-free on the freed clock provider pointer.
Should __mtk_clk_simple_probe() be fixed to cleanly unregister the provider before this new driver uses .rst_desc?
Quoted 1 line
+};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=18