From: Justin Yeh <justin.yeh@mediatek.com>
To: Sean Wang <sean.wang@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: <Project_Global_Chrome_Upstream_Group@mediatek.com>,
<linux-mediatek@lists.infradead.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
Justin Yeh <justin.yeh@mediatek.com>
Subject: [PATCH v6 0/5] pinctrl: mediatek: Enable module build support
Date: Mon, 13 Jul 2026 16:37:52 +0800 [thread overview]
Message-ID: <20260713083808.168957-1-justin.yeh@mediatek.com> (raw)
This series lets the MediaTek pinctrl drivers be built as loadable
kernel modules. This is required for Android GKI + vendor_dlkm
deployments, where vendor-specific drivers must be kept separate from
the GKI vmlinux and loaded as modules from the vendor partition.
Enabling the individual SoC drivers as modules is a single logical step,
but it has a few prerequisites, so the series is:
1. Fix a pre-existing GPIO chip lifecycle bug. The gpio_chip lives in
device-managed memory but is registered with the non-managed
gpiochip_add_data(). While the drivers were built-in only this was
harmless, but once they can be unbound/rmmod'd, devm frees the
backing memory while the chip is still registered (use-after-free).
Switch to devm_gpiochip_add_data() in the shared probe/init paths.
2. Fix a pre-existing EINT resource leak on unbind. mtk_eint_do_init()
creates an IRQ domain, an interrupt mapping per EINT line and a
chained handler on the parent interrupt, none of which were ever
released. Once the drivers can be unbound/rmmod'd this leaves a
dangling IRQ domain, mappings whose chip data points at freed
memory, and a chained handler still firing into that freed data.
Tear them down with a device-managed action, matching the devm
lifecycle used for the gpio_chip.
3. Make the shared common code modular. The SoC drivers link against
pinctrl-mtk-common.c (v1), pinctrl-moore.c and pinctrl-mtmips.c,
whose Kconfig symbols were bool and which exported nothing. Without
this, selecting a SoC driver as =m forces the common symbol to =y
and the module fails to link against the unexported entry points.
Convert PINCTRL_MTK, PINCTRL_MTK_MOORE and PINCTRL_MTK_MTMIPS to
tristate, export the entry points, and add MODULE_LICENSE()/
MODULE_DESCRIPTION(). The already-modular v2 common code
additionally needs mtk_rmw() exported, since it is called directly
by SoC drivers such as mt7623. The shared symbols are exported in
the "MTK_PINCTRL" symbol namespace (EXPORT_SYMBOL_NS_GPL()), and
each SoC driver that uses them declares MODULE_IMPORT_NS().
4. Convert the MT7986 driver to a single initcall. It registers two
platform drivers (mt7986a/mt7986b) and used to call arch_initcall()
twice. A module has only one module_init(), so two arch_initcall()s
break the module build with a redefinition of
init_module()/__inittest(). Fold both drivers into one
platform_register_drivers() call from a single initcall. No
functional change when built-in.
5. Flip every SoC driver's Kconfig from bool to tristate and add the
module metadata.
The series builds cleanly under allmodconfig on arm64 (all SoC drivers
as =m).
Changes in v6:
- Export the shared common symbols in the "MTK_PINCTRL" namespace using
EXPORT_SYMBOL_NS_GPL() instead of the global EXPORT_SYMBOL_GPL(), and
add MODULE_IMPORT_NS("MTK_PINCTRL") to every SoC driver that consumes
them, as suggested by Chen-Yu Tsai while reviewing the common-driver
patch (patch 3/5).
- Added a new patch, "pinctrl: mediatek: free EINT resources on unbind"
(patch 2/5). Chen-Yu Tsai pointed out that the manual cleanup removed
in patch 1/5 also used to cover mtk_eint_init(), and that converting
to devm without an EINT counterpart would leave a dangling IRQ domain
and an active-but-stale chained handler on rmmod/unbind. As suggested,
this is a separate patch rather than folded into patch 1/5.
- Added Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> to patch 1/5
(devm_gpiochip_add_data) and patch 4/5 (mt7986 single initcall).
Review status: patches 1/5 and 4/5 carry Chen-Yu Tsai's Reviewed-by;
patch 5/5 carries AngeloGioacchino Del Regno's Reviewed-by (from the
per-driver patches reviewed in v4, preserved across the squash). Patches
2/5 and 3/5 have not been reviewed yet.
Justin Yeh (5):
pinctrl: mediatek: use devm_gpiochip_add_data() for GPIO chip
pinctrl: mediatek: free EINT resources on unbind
pinctrl: mediatek: allow common drivers to be built as modules
pinctrl: mediatek: mt7986: register both platform drivers from a
single initcall
pinctrl: mediatek: enable module build support for all SoC drivers
drivers/pinctrl/mediatek/Kconfig | 70 +++++++++----------
drivers/pinctrl/mediatek/mtk-eint.c | 21 +++++-
drivers/pinctrl/mediatek/pinctrl-moore.c | 11 +--
drivers/pinctrl/mediatek/pinctrl-mt2701.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt2712.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt6397.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt6795.c | 3 +
drivers/pinctrl/mediatek/pinctrl-mt6797.c | 3 +
drivers/pinctrl/mediatek/pinctrl-mt6878.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mt6893.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mt7620.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt7621.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt7622.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt7623.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt7629.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt76x8.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt7981.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 19 ++---
drivers/pinctrl/mediatek/pinctrl-mt7988.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt8127.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt8135.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt8167.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt8173.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-mt8183.c | 3 +
drivers/pinctrl/mediatek/pinctrl-mt8186.c | 3 +
drivers/pinctrl/mediatek/pinctrl-mt8188.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mt8189.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mt8192.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mt8195.c | 3 +
drivers/pinctrl/mediatek/pinctrl-mt8196.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mt8365.c | 2 +
drivers/pinctrl/mediatek/pinctrl-mt8516.c | 4 ++
.../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 1 +
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 22 +++---
drivers/pinctrl/mediatek/pinctrl-mtmips.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-paris.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-rt2880.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-rt305x.c | 4 ++
drivers/pinctrl/mediatek/pinctrl-rt3883.c | 4 ++
39 files changed, 190 insertions(+), 59 deletions(-)
base-commit: bee763d5f341b99cf472afeb508d4988f62a6ca1
--
2.45.2
next reply other threads:[~2026-07-13 8:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 8:37 Justin Yeh [this message]
2026-07-13 8:37 ` [PATCH v6 1/5] pinctrl: mediatek: use devm_gpiochip_add_data() for GPIO chip Justin Yeh
2026-07-13 8:37 ` [PATCH v6 2/5] pinctrl: mediatek: free EINT resources on unbind Justin Yeh
2026-07-13 8:37 ` [PATCH v6 3/5] pinctrl: mediatek: allow common drivers to be built as modules Justin Yeh
2026-07-13 8:37 ` [PATCH v6 4/5] pinctrl: mediatek: mt7986: register both platform drivers from a single initcall Justin Yeh
2026-07-13 8:37 ` [PATCH v6 5/5] pinctrl: mediatek: enable module build support for all SoC drivers Justin Yeh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260713083808.168957-1-justin.yeh@mediatek.com \
--to=justin.yeh@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=sean.wang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox