[PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks

Akari Tsuyukusa posted 32 patches 1 month, 4 weeks ago
drivers/clk/mediatek/Kconfig                 |  34 +--
drivers/clk/mediatek/clk-mt2701-aud.c        |  35 +--
drivers/clk/mediatek/clk-mt2701.c            | 233 +++++--------------
drivers/clk/mediatek/clk-mt2712-apmixedsys.c |  48 +---
drivers/clk/mediatek/clk-mt6735-apmixedsys.c |  48 +---
drivers/clk/mediatek/clk-mt6735-imgsys.c     |   1 +
drivers/clk/mediatek/clk-mt6735-mfgcfg.c     |   1 +
drivers/clk/mediatek/clk-mt6735-vdecsys.c    |   1 +
drivers/clk/mediatek/clk-mt6735-vencsys.c    |   1 +
drivers/clk/mediatek/clk-mt6779.c            | 124 ++--------
drivers/clk/mediatek/clk-mt6795-apmixedsys.c |   2 +
drivers/clk/mediatek/clk-mt6795-infracfg.c   |  70 +-----
drivers/clk/mediatek/clk-mt6795-pericfg.c    |  71 +-----
drivers/clk/mediatek/clk-mt6797.c            | 140 ++---------
drivers/clk/mediatek/clk-mt7622-apmixedsys.c |  60 +----
drivers/clk/mediatek/clk-mt7622-aud.c        |  35 +--
drivers/clk/mediatek/clk-mt7622-infracfg.c   |  70 +-----
drivers/clk/mediatek/clk-mt7981-apmixed.c    |  37 +--
drivers/clk/mediatek/clk-mt7986-apmixed.c    |  37 +--
drivers/clk/mediatek/clk-mt7988-apmixed.c    |  40 +---
drivers/clk/mediatek/clk-mt8135-apmixedsys.c |  48 +---
drivers/clk/mediatek/clk-mt8167-apmixedsys.c |  50 +---
drivers/clk/mediatek/clk-mt8173-apmixedsys.c |   2 +
drivers/clk/mediatek/clk-mt8173-infracfg.c   |  98 ++------
drivers/clk/mediatek/clk-mt8183-apmixedsys.c |  51 +---
drivers/clk/mediatek/clk-mt8183-audio.c      |  26 +--
drivers/clk/mediatek/clk-mt8186-apmixedsys.c |  59 +----
drivers/clk/mediatek/clk-mt8188-apmixedsys.c |  60 +----
drivers/clk/mediatek/clk-mt8192-apmixedsys.c |  67 ++----
drivers/clk/mediatek/clk-mt8192-aud.c        |  26 +--
drivers/clk/mediatek/clk-mt8195-apmixedsys.c |  67 +-----
drivers/clk/mediatek/clk-mt8195-apusys_pll.c |  49 +---
drivers/clk/mediatek/clk-mt8196-apmixedsys.c |  67 +-----
drivers/clk/mediatek/clk-mt8196-mcu.c        |  96 +++-----
drivers/clk/mediatek/clk-mt8196-mfg.c        |  84 ++-----
drivers/clk/mediatek/clk-mt8516-apmixedsys.c |  42 +---
drivers/clk/mediatek/clk-mtk.c               |  76 +++++-
drivers/clk/mediatek/clk-mtk.h               |  12 +
38 files changed, 472 insertions(+), 1596 deletions(-)
[PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks
Posted by Akari Tsuyukusa 1 month, 4 weeks ago
This series migrates most MediaTek clock drivers to the common
probe/remove helpers provided by the MTK clock framework.

Key changes:
- Fix memory leaks on module removal caused by missing
  platform_set_drvdata() calls (patches 1-6).
- Add missing MODULE_DEVICE_TABLE() (patches 7, 8).
- Add missing support for cpumux, PLL, pllfh, and sub-device
  auto-population to the common helpers (patches 9-12).
- Convert all compatible clock drivers to use struct mtk_clk_desc
  and mtk_clk_simple_probe/remove (patches 13-32).

The memory leak and MODULE_DEVICE_TABLE() fixes are split from the
migration patches to allow backporting to stable.

Drivers not converted:
- MT6765 apmixedsys: requires direct register init.
- MT6795 apmixedsys: uses mtk_clk_register_ref2usb_tx().
- MT7629 eth/sgmiisys: uses a hacked probe sequence (multi-instance
  sgmii gates).
- MT8173 apmixedsys: uses mtk_clk_register_ref2usb_tx() and custom
  divider registration.
- MT8188/MT8195 topckgen: call devm_clk_hw_register_mux() and register
  a notifier.
- MT8196 vlpckgen: requires direct register init.
- MT8365 apmixedsys: uses devm_clk_hw_register_gate().

Patches 1-6 are based on
"[PATCH v2 0/6] clk: mediatek: fix memory leak on module removal"
(In addition fixed a compilation error in mt8173-infracfg)
https://lore.kernel.org/linux-mediatek/20260707074839.240676-1-akkun11.open@gmail.com/

Patch 9 is based on
"[PATCH 1/3] clk: mediatek: clk-mtk: Add cpumux support to common probe/remove helpers"
https://lore.kernel.org/lkml/20260304181024.738391-1-akkun11.open@gmail.com/

Akari Tsuyukusa (32):
  clk: mediatek: mt2712: fix memory leak on module removal
  clk: mediatek: mt6795: fix memory leak on module removal
  clk: mediatek: mt7622: fix memory leak on module removal
  clk: mediatek: mt8135: fix memory leak on module removal
  clk: mediatek: mt8173: fix memory leak on module removal
  clk: mediatek: mt8192: fix memory leak on module removal
  clk: mediatek: mt6735: Add missing MODULE_DEVICE_TABLE()
  clk: mediatek: mt7988-apmixed: Add missing MODULE_DEVICE_TABLE()
  clk: mediatek: Add cpumux support to common probe/remove helpers
  clk: mediatek: Add PLL support to common probe/remove helpers
  clk: mediatek: Add auto-population of sub-devices support in simple
    probe
  clk: mediatek: Add pllfh support to common probe/remove helpers
  clk: mediatek: mt2701: Switch to common probe/remove helpers
  clk: mediatek: mt2712-apmixedsys: Switch to common probe/remove
    helpers
  clk: mediatek: mt6735-apmixedsys: Switch to common probe/remove
    helpers
  clk: mediatek: mt6779: Switch to common probe/remove helpers
  clk: mediatek: mt6795: Switch to common probe/remove helpers
  clk: mediatek: mt6797: Switch to common probe/remove helpers
  clk: mediatek: mt7622: Switch to common probe/remove helpers
  clk: mediatek: mt7981-apmixed: Switch to common probe/remove helpers
  clk: mediatek: mt7986-apmixed: Switch to common probe/remove helpers
  clk: mediatek: mt7988-apmixed: Switch to common probe/remove helpers
  clk: mediatek: mt8135-apmixedsys: Switch to common probe/remove
    helpers
  clk: mediatek: mt8167-apmixedsys: Switch to common probe/remove
    helpers
  clk: mediatek: mt8173-infracfg: Switch to common probe/remove helpers
  clk: mediatek: mt8183: Switch to common probe/remove helpers
  clk: mediatek: mt8186-apmixedsys: Switch to common probe/remove
    helpers
  clk: mediatek: mt8188-apmixedsys: Switch to common probe/remove
    helpers
  clk: mediatek: mt8192: Switch to common probe/remove helpers
  clk: mediatek: mt8195: Switch to common probe/remove helpers
  clk: mediatek: mt8196: Switch to common probe/remove helpers
  clk: mediatek: mt8516-apmixedsys: Switch to common probe/remove
    helpers

 drivers/clk/mediatek/Kconfig                 |  34 +--
 drivers/clk/mediatek/clk-mt2701-aud.c        |  35 +--
 drivers/clk/mediatek/clk-mt2701.c            | 233 +++++--------------
 drivers/clk/mediatek/clk-mt2712-apmixedsys.c |  48 +---
 drivers/clk/mediatek/clk-mt6735-apmixedsys.c |  48 +---
 drivers/clk/mediatek/clk-mt6735-imgsys.c     |   1 +
 drivers/clk/mediatek/clk-mt6735-mfgcfg.c     |   1 +
 drivers/clk/mediatek/clk-mt6735-vdecsys.c    |   1 +
 drivers/clk/mediatek/clk-mt6735-vencsys.c    |   1 +
 drivers/clk/mediatek/clk-mt6779.c            | 124 ++--------
 drivers/clk/mediatek/clk-mt6795-apmixedsys.c |   2 +
 drivers/clk/mediatek/clk-mt6795-infracfg.c   |  70 +-----
 drivers/clk/mediatek/clk-mt6795-pericfg.c    |  71 +-----
 drivers/clk/mediatek/clk-mt6797.c            | 140 ++---------
 drivers/clk/mediatek/clk-mt7622-apmixedsys.c |  60 +----
 drivers/clk/mediatek/clk-mt7622-aud.c        |  35 +--
 drivers/clk/mediatek/clk-mt7622-infracfg.c   |  70 +-----
 drivers/clk/mediatek/clk-mt7981-apmixed.c    |  37 +--
 drivers/clk/mediatek/clk-mt7986-apmixed.c    |  37 +--
 drivers/clk/mediatek/clk-mt7988-apmixed.c    |  40 +---
 drivers/clk/mediatek/clk-mt8135-apmixedsys.c |  48 +---
 drivers/clk/mediatek/clk-mt8167-apmixedsys.c |  50 +---
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c |   2 +
 drivers/clk/mediatek/clk-mt8173-infracfg.c   |  98 ++------
 drivers/clk/mediatek/clk-mt8183-apmixedsys.c |  51 +---
 drivers/clk/mediatek/clk-mt8183-audio.c      |  26 +--
 drivers/clk/mediatek/clk-mt8186-apmixedsys.c |  59 +----
 drivers/clk/mediatek/clk-mt8188-apmixedsys.c |  60 +----
 drivers/clk/mediatek/clk-mt8192-apmixedsys.c |  67 ++----
 drivers/clk/mediatek/clk-mt8192-aud.c        |  26 +--
 drivers/clk/mediatek/clk-mt8195-apmixedsys.c |  67 +-----
 drivers/clk/mediatek/clk-mt8195-apusys_pll.c |  49 +---
 drivers/clk/mediatek/clk-mt8196-apmixedsys.c |  67 +-----
 drivers/clk/mediatek/clk-mt8196-mcu.c        |  96 +++-----
 drivers/clk/mediatek/clk-mt8196-mfg.c        |  84 ++-----
 drivers/clk/mediatek/clk-mt8516-apmixedsys.c |  42 +---
 drivers/clk/mediatek/clk-mtk.c               |  76 +++++-
 drivers/clk/mediatek/clk-mtk.h               |  12 +
 38 files changed, 472 insertions(+), 1596 deletions(-)

-- 
2.55.0
Re: [PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks
Posted by Jakub Kicinski 1 month, 4 weeks ago
On Mon,  3 Aug 2026 23:16:27 +0900 Akari Tsuyukusa wrote:
> This series migrates most MediaTek clock drivers to the common
> probe/remove helpers provided by the MTK clock framework.

Why are you CCing netdev on this? None of it touches networking
Re: [PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks
Posted by Brian Masney 1 month, 4 weeks ago
Hi Jakub,

On Mon, Aug 03, 2026 at 12:50:34PM -0700, Jakub Kicinski wrote:
> On Mon,  3 Aug 2026 23:16:27 +0900 Akari Tsuyukusa wrote:
> > This series migrates most MediaTek clock drivers to the common
> > probe/remove helpers provided by the MTK clock framework.
> 
> Why are you CCing netdev on this? None of it touches networking

I saw that message from you about two different mediatek patch series
from different submitters. This series has 38 files, all under
drivers/clk/mediatek/. If I run get_maintainers.pl on each file path
individuall like this:

  $ cat filelist | awk '{print $1}' | \
  	xargs -iblah echo ./scripts/get_maintainer.pl blah

Then netdev list doesn't show up.

However, if I look at it as a whole, then it shows up:

    $ b4 am 20260803141659.559129-1-akkun11.open@gmail.com
    $ ./scripts/get_maintainer.pl \
    	./20260803_akkun11_open_clk_mediatek_migrate_to_common_probe_remove_helpers_and_fix_memory_leaks.mbx

    ...
    netdev@vger.kernel.org (open list:PTP HARDWARE CLOCK SUPPORT:Keyword:(?:\b|_)ptp(?:\b|_))

I think it's matching on this entry in MAINTAINERS:

PTP HARDWARE CLOCK SUPPORT
M:      Richard Cochran <richardcochran@gmail.com>
L:      netdev@vger.kernel.org
S:      Maintained
W:      http://linuxptp.sourceforge.net/
F:      Documentation/ABI/testing/sysfs-ptp
F:      Documentation/driver-api/ptp.rst
F:      drivers/net/phy/dp83640*
F:      drivers/ptp/*
F:      include/linux/ptp_cl*
K:      (?:\b|_)ptp(?:\b|_)

I think it's the K: for the ptp that's matching.

$ grep ptp 20260803_akkun11_open_clk_mediatek_migrate_to_common_probe_remove_helpers_and_fix_memory_leaks.mbx
-static const struct mtk_pll_data ptp_plls[] = {
-	PLL(CLK_PTPPLL, "ptppll", PTPPLL_CON0, PTPPLL_CON0, 0, 0, PLL_AO,
+static const struct mtk_clk_desc ptp_plls = {
+		PLL(CLK_PTPPLL, "ptppll", PTPPLL_CON0, PTPPLL_CON0, 0, 0, PLL_AO,

Brian
Re: [PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks
Posted by Jakub Kicinski 1 month, 4 weeks ago
On Mon, 3 Aug 2026 16:28:07 -0400 Brian Masney wrote:
> Hi Jakub,
> 
> On Mon, Aug 03, 2026 at 12:50:34PM -0700, Jakub Kicinski wrote:
> > On Mon,  3 Aug 2026 23:16:27 +0900 Akari Tsuyukusa wrote:  
> > > This series migrates most MediaTek clock drivers to the common
> > > probe/remove helpers provided by the MTK clock framework.  
> > 
> > Why are you CCing netdev on this? None of it touches networking  
> 
> I saw that message from you about two different mediatek patch series
> from different submitters. This series has 38 files, all under
> drivers/clk/mediatek/. If I run get_maintainers.pl on each file path
> individuall like this:
> 
>   $ cat filelist | awk '{print $1}' | \
>   	xargs -iblah echo ./scripts/get_maintainer.pl blah
> 
> Then netdev list doesn't show up.
> 
> However, if I look at it as a whole, then it shows up:
> 
>     $ b4 am 20260803141659.559129-1-akkun11.open@gmail.com
>     $ ./scripts/get_maintainer.pl \
>     	./20260803_akkun11_open_clk_mediatek_migrate_to_common_probe_remove_helpers_and_fix_memory_leaks.mbx
> 
>     ...
>     netdev@vger.kernel.org (open list:PTP HARDWARE CLOCK SUPPORT:Keyword:(?:\b|_)ptp(?:\b|_))
> 
> I think it's matching on this entry in MAINTAINERS:
> 
> PTP HARDWARE CLOCK SUPPORT
> M:      Richard Cochran <richardcochran@gmail.com>
> L:      netdev@vger.kernel.org
> S:      Maintained
> W:      http://linuxptp.sourceforge.net/
> F:      Documentation/ABI/testing/sysfs-ptp
> F:      Documentation/driver-api/ptp.rst
> F:      drivers/net/phy/dp83640*
> F:      drivers/ptp/*
> F:      include/linux/ptp_cl*
> K:      (?:\b|_)ptp(?:\b|_)
> 
> I think it's the K: for the ptp that's matching.
> 
> $ grep ptp 20260803_akkun11_open_clk_mediatek_migrate_to_common_probe_remove_helpers_and_fix_memory_leaks.mbx
> -static const struct mtk_pll_data ptp_plls[] = {
> -	PLL(CLK_PTPPLL, "ptppll", PTPPLL_CON0, PTPPLL_CON0, 0, 0, PLL_AO,
> +static const struct mtk_clk_desc ptp_plls = {
> +		PLL(CLK_PTPPLL, "ptppll", PTPPLL_CON0, PTPPLL_CON0, 0, 0, PLL_AO,
> 

I see, thanks for digging thru this!

Patchwork matching rules must be missing the PTP side because none of
the patches end up assigned to netdev. No big deal but going forward
I think you can drop this extra CC.