The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/7] soc: mediatek: add MMDVFS support for MT8196
@ 2026-11-25  6:00 Echo Zhang
  2026-11-25  6:00 ` [PATCH 1/7] dt-bindings: clock: mediatek: add MT8196 MMDVFS clock IDs Echo Zhang
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Echo Zhang @ 2026-11-25  6:00 UTC (permalink / raw)
  To: Echo Zhang, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, Stephen Boyd,
	Brian Masney, Jerome Brunet, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, MMDVFS Team, kyrie.wu, ming-fan.chen,
	devicetree, linux-kernel, linux-arm-kernel, linux-clk, llvm

This series adds support for the MediaTek Multimedia Dynamic Voltage and
Frequency Scaling (MMDVFS) controller on MT8196. The controller provides
virtual clocks for multimedia hardware blocks and coordinates their
performance requests with platform voltage resources. The driver
aggregates consumer rate requests and programs the MT8196 hardware clock
control fabric (HWCCF) voter. Its VCP/MMUP backend coordinates shared
memory and IPI communication with firmware.

The series introduces the clock IDs and device tree bindings, followed by
the common clock provider, VCP backend and MT8196 topology and voting
data. It also adds a read-only debugfs status view and a MAINTAINERS entry.

This series depends on Xiangzhi Tang's MediaTek VCP remoteproc series,
which provides the public VCP API used by MMDVFS:
https://lore.kernel.org/r/20260427111446.22955-1-xiangzhi.tang@mediatek.com

Patch layout:
  1/7: Define the MT8196 MMDVFS clock IDs used by DT consumers.
  2/7: Document the common MMDVFS and MT8196 DT bindings.
  3/7: Add the common driver, virtual clock provider and vote handling.
  4/7: Add the VCP/MMUP shared-memory and IPI backend.
  5/7: Add MT8196 topology data and HWCCF voting operations.
  6/7: Add a read-only debugfs status view.
  7/7: Add the MMDVFS files and contacts to MAINTAINERS.

Validation: the two MMDVFS bindings passed dt_binding_check. Each driver
commit built cumulatively with arm64 Clang on top of the VCP dependency.
The production changes were also ported to the MT8196 sapphire validation
tree, retaining its older VCP API compatibility and separate internal test
hooks. Its full package build and board boot passed. The status interface
reported initialization with three resource controllers, seven muxes. The
user, vote_step and force_step test completed with zero functional failures;

Echo Zhang (7):
  dt-bindings: clock: mediatek: add MT8196 MMDVFS clock IDs
  dt-bindings: soc: mediatek: add MMDVFS binding
  soc: mediatek: add MMDVFS core driver
  soc: mediatek: mmdvfs: add VCP backend
  soc: mediatek: mmdvfs: add MT8196 support
  soc: mediatek: mmdvfs: add read-only status debug
  MAINTAINERS: add MediaTek MMDVFS entry

 .../soc/mediatek/mediatek,mmdvfs.yaml         |   60 +
 .../soc/mediatek/mediatek,mt8196-mmdvfs.yaml  |   87 ++
 MAINTAINERS                                   |   11 +
 drivers/soc/mediatek/Kconfig                  |   19 +
 drivers/soc/mediatek/Makefile                 |    1 +
 drivers/soc/mediatek/mmdvfs/Makefile          |   10 +
 drivers/soc/mediatek/mmdvfs/mmdvfs-clk.c      |  447 +++++++
 drivers/soc/mediatek/mmdvfs/mmdvfs-core.c     |  651 ++++++++++
 drivers/soc/mediatek/mmdvfs/mmdvfs-debug.c    |  200 +++
 drivers/soc/mediatek/mmdvfs/mmdvfs-internal.h |  361 ++++++
 drivers/soc/mediatek/mmdvfs/mmdvfs-mt8196.c   |  637 ++++++++++
 drivers/soc/mediatek/mmdvfs/mmdvfs-up-priv.h  |   57 +
 drivers/soc/mediatek/mmdvfs/mmdvfs-up.c       |  275 +++++
 .../soc/mediatek/mmdvfs/mmdvfs-vcp-memory.h   |  104 ++
 drivers/soc/mediatek/mmdvfs/mmdvfs-vcp.c      | 1075 +++++++++++++++++
 .../clock/mediatek,mt8196-mmdvfs.h            |   74 ++
 include/soc/mediatek/mmdvfs.h                 |   90 ++
 17 files changed, 4159 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mmdvfs.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt8196-mmdvfs.yaml
 create mode 100644 drivers/soc/mediatek/mmdvfs/Makefile
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-clk.c
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-core.c
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-debug.c
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-internal.h
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-mt8196.c
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-up-priv.h
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-up.c
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-vcp-memory.h
 create mode 100644 drivers/soc/mediatek/mmdvfs/mmdvfs-vcp.c
 create mode 100644 include/dt-bindings/clock/mediatek,mt8196-mmdvfs.h
 create mode 100644 include/soc/mediatek/mmdvfs.h

-- 
2.45.2


^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: [PATCH 4/7] soc: mediatek: mmdvfs: add VCP backend
@ 2026-11-26  9:03 Echo Zhang (张玉)
  0 siblings, 0 replies; 20+ messages in thread
From: Echo Zhang (张玉) @ 2026-11-26  9:03 UTC (permalink / raw)
  To: Ben Grisdale
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Stephen Boyd, Brian Masney,
	Jerome Brunet, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, MMDVFS Team, Kyrie Wu (吴晗),
	Ming-Fan Chen (陳明汎),
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	llvm@lists.linux.dev

Hi Ben,

  Thank you for the detailed review. I agree that reading the
  Android-specific atag,boot property and using it to skip IPI
  transactions in recovery mode does not belong in this driver. That
  behavior came from the downstream implementation and should not have
  been carried into this series.

  In v2, I will remove mmdvfs_get_bootmode(), the RECOVERY_BOOT check
in
  mmdvfs_vcp_send_ipi_impl(), and the associated bootmode state. I will
  also rework the VCP readiness and error paths so that unavailable
  firmware is handled through normal driver mechanisms, without a
  bootmode check. Whether the device is enabled or the module is loaded
  for a particular environment belongs in platform configuration.

Thanks,
Echo

On 三, 2026-11-25 at 14:32 +0000, Ben Grisdale wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On Wed, 25 Nov 2026 14:00:09 +0800 "Echo Zhang"
> <echo.zhang@mediatek.com> wrote:
> 
> > Add the VCP transport used by MMDVFS to map AP and firmware shared
> > memory, manage feature power references and send IPI commands.
> > 
> > Wait for VCP readiness and handle the selected MMUP or VCP READY
> > notification to initialize firmware after boot and resume.
> > Serialize
> > IPI transactions while shared memory and acknowledgment state are
> > in
> > use.
> 
> [...]
> 
> > +static void mmdvfs_get_bootmode(void)
> > +{
> > +     struct device_node *np_chosen;
> > +     struct tag_bootmode {
> > +             u32 size;
> > +             u32 tag;
> > +             u32 bootmode;
> > +             u32 boottype;
> > +     } *tag;
> > +
> > +     if (bootmode < UNKNOWN_BOOT)
> > +             return;
> > +
> > +     np_chosen = of_find_node_by_path("/chosen");
> > +     if (!np_chosen) {
> > +             bootmode = NORMAL_BOOT;
> > +             return;
> > +     }
> > +
> > +     tag = (struct tag_bootmode *)of_get_property(np_chosen,
> > "atag,boot", NULL);
> > +     of_node_put(np_chosen);
> > +
> > +     if (tag)
> > +             bootmode = tag->bootmode;
> > +     else
> > +             bootmode = NORMAL_BOOT;
> > +}
> > +
> 
> [...]
> 
> > +static int
> > +mmdvfs_vcp_send_ipi_impl(struct mmdvfs_device *mmdvfs, void *data,
> > u32 len,
> > +                      const bool vcp)
> > +{
> [...]
> > +     mmdvfs_get_bootmode();
> > +     if (bootmode == RECOVERY_BOOT) {
> > +             mmdvfs_err(mmdvfs->dev, "IPI skipped: bootmode=%d\n",
> > bootmode);
> > +             return -EACCES;
> > +     }
> > +
> 
> Allow me to give my two cents here, even if I am a nobody :)
> 
> Android bootmodes. Whilst I do respect the reason for Android
> bootmodes
> existing, what I do not like to see is people checking for the
> *Android*
> bootmode in their drivers.
> 
> Android kernels these days are *modular* thanks to GKI. I *do not*
> understand why people still check for bootmodes in their drivers when
> there is a much better option of *not loading them* if they are not
> wanted in the current bootmode.
> 
> Having your driver depend on the behaviour of one specific userspace
> is
> terrible. And tracking it in firmware (given that this code is
> checking
> for an "atag,boot" property presumably added by the bootloader) is
> even
> worse.
> 
> Aside from enabling these questionable bootmode checks in the
> drivers,
> I have no idea why the bootloader needs to get involved with putting
> non-standard state / boot info inside of /chosen (i.e. that
> "atag,boot"
> property), when Android solved this problem by using bootargs, and
> more
> recently, bootconfig.
> 
> I will acknowledge that "just not loading modules" does get a bit
> more
> nuanced if you bring something like udev / Android init into the mix,
> but there are still better solutions to this problem: either
> gracefully
> handling the state where the hardware isn't ready in your driver,
> making
> your bootloader set status = "disabled"; on the relavent DT node, or
> blocklisting the module from userspace in boot modes where it can't
> work.
> 
> Inter-driver dependencies are not a good excuse either (e.g. a core
> clock driver depending on some DVFS driver that is a no-op in
> recovery,
> forcing you to load it ANYWAY, even if the bootloader doesn't start
> the
> required firmware on recovery boot). If that is the case, then there
> is
> some serious refactoring work to do.
> 
> First I began seeing these sorts of checks in vendor touch screen
> drivers, but now it seems to be infecting SoC side drivers as well.
> 
> *Kernel* drivers should work the same regardless of what *userspace*
> environment is running (with the only real exception being the
> absence
> of firmware or explicit configurations from userspace). And in
> situations
> where they genuinely can't work, they should not be loaded at all.
> 
> There should be no such thing as "kernel drivers designed for
> Android",
> only "kernel drivers designed for Linux".
> 
> Best regards,
> Ben Grisdale
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: [PATCH 4/7] soc: mediatek: mmdvfs: add VCP backend
@ 2026-11-26  9:15 Echo Zhang (张玉)
  0 siblings, 0 replies; 20+ messages in thread
From: Echo Zhang (张玉) @ 2026-11-26  9:15 UTC (permalink / raw)
  To: Roman Vivchar
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Stephen Boyd, Brian Masney,
	Jerome Brunet, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
	Justin Stitt, MMDVFS Team, Kyrie Wu (吴晗),
	Ming-Fan Chen (陳明汎),
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	llvm@lists.linux.dev

On 三, 2026-11-25 at 08:38 +0000, Roman Vivchar wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On Wednesday, November 25th, 2026 at 8:01 AM, Echo Zhang
> <echo.zhang@mediatek.com> wrote:
> 
> > Add the VCP transport used by MMDVFS to map AP and firmware shared
> > memory, manage feature power references and send IPI commands.
> > 
> > Wait for VCP readiness and handle the selected MMUP or VCP READY
> > notification to initialize firmware after boot and resume.
> > Serialize
> > IPI transactions while shared memory and acknowledgment state are
> > in
> > use.
> > 
> > Signed-off-by: Echo Zhang <echo.zhang@mediatek.com>
> > ---
> 
> ...
> 
> > diff --git a/drivers/soc/mediatek/mmdvfs/mmdvfs-core.c
> > b/drivers/soc/mediatek/mmdvfs/mmdvfs-core.c
> > index c32fa11557af..3388a5a3a145 100644
> > --- a/drivers/soc/mediatek/mmdvfs/mmdvfs-core.c
> > +++ b/drivers/soc/mediatek/mmdvfs/mmdvfs-core.c
> > @@ -7,22 +7,23 @@
> > 
> >  #include <linux/atomic.h>
> >  #include <linux/clk-provider.h>
> > +#include <linux/delay.h>
> >  #include <linux/device.h>
> >  #include <linux/err.h>
> >  #include <linux/io.h>
> > +#include <linux/kthread.h>
> >  #include <linux/module.h>
> >  #include <linux/mutex.h>
> > -#include <linux/notifier.h>
> >  #include <linux/of.h>
> >  #include <linux/of_address.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/remoteproc/mtk_vcp_public.h>
> >  #include <linux/sched/clock.h>
> >  #include <linux/slab.h>
> >  #include <linux/string.h>
> > -#include <linux/suspend.h>
> > -#include <linux/workqueue.h>
> > 
> >  #include "mmdvfs-internal.h"
> > +#include "mmdvfs-up-priv.h"
> > 
> >  static int mmdvfs_register_device(struct mmdvfs_device *mmdvfs);
> >  static void mmdvfs_unregister_device(struct mmdvfs_device
> > *mmdvfs);
> > @@ -34,14 +35,13 @@ struct mmdvfs_device
> > *mmdvfs_find_device_any(void)
> >  {
> >       return
> > mmdvfs_find_device_by_version(MMDVFS_VERSION_HWCCF_DVFS_VOTER);
> >  }
> > -EXPORT_SYMBOL_GPL(mmdvfs_find_device_any);
> > 
> >  /**
> >   * mmdvfs_get_version - Get MMDVFS voting mechanism type
> >   *
> >   * Return:
> >   *   0 - No hardware voter
> > - *   1 - HWCCF DVFS voter
> > + *   1 - HWCCF DVFS voter (VCP IPI with MMUP SRAM)
> >   */
> >  u32 mmdvfs_get_version(void)
> >  {
> > @@ -96,7 +96,8 @@ static int mmdvfs_validate_topology(struct
> > mmdvfs_device *mmdvfs)
> >                       return -EINVAL;
> >               }
> > 
> > -             if (mux->freq_num == 0 || mux->freq_num >
> > MMDVFS_MAX_LEVELS) {
> > +             if (mux->freq_num == 0 || mux->freq_num > rc-
> > >level_num ||
> > +                 mux->freq_num > MMDVFS_MAX_LEVELS) {
> >                       mmdvfs_err(mmdvfs->dev,
> >                                  "MUX %d (%s): invalid freq_num:
> > %d\n",
> >                                  i, mux->name, mux->freq_num);
> > @@ -112,10 +113,11 @@ static int mmdvfs_validate_topology(struct
> > mmdvfs_device *mmdvfs)
> >                       }
> > 
> >                       if (j > 0 && mux->freq[j] <= mux->freq[j -
> > 1]) {
> > -                             mmdvfs_warn(mmdvfs->dev,
> > -                                         "MUX %d (%s): freq not
> > ascending: freq[%d]=%llu <= freq[%d]=%llu\n",
> > -                                         i, mux->name, j, mux-
> > >freq[j],
> > -                                         j - 1, mux->freq[j - 1]);
> > +                             mmdvfs_err(mmdvfs->dev,
> > +                                        "MUX %d (%s): freq not
> > ascending: freq[%d]=%llu <= freq[%d]=%llu\n",
> > +                                        i, mux->name, j, mux-
> > >freq[j],
> > +                                        j - 1, mux->freq[j - 1]);
> > +                             return -EINVAL;
> 
> Why this can't be in the previous patch?
> 
> ...
> 
> > diff --git a/drivers/soc/mediatek/mmdvfs/mmdvfs-vcp.c
> > b/drivers/soc/mediatek/mmdvfs/mmdvfs-vcp.c
> > new file mode 100644
> > index 000000000000..fc6db1c89294
> > --- /dev/null
> > +++ b/drivers/soc/mediatek/mmdvfs/mmdvfs-vcp.c
> 
> ...
> 
> > +/*
> > + * mmdvfs_get_bootmode - Get system boot mode
> > + *
> > + * Query boot mode from device tree /chosen node
> > + */
> > +static void mmdvfs_get_bootmode(void)
> > +{
> > +     struct device_node *np_chosen;
> > +     struct tag_bootmode {
> > +             u32 size;
> > +             u32 tag;
> > +             u32 bootmode;
> > +             u32 boottype;
> > +     } *tag;
> > +
> > +     if (bootmode < UNKNOWN_BOOT)
> > +             return;
> > +
> > +     np_chosen = of_find_node_by_path("/chosen");
> > +     if (!np_chosen) {
> > +             bootmode = NORMAL_BOOT;
> > +             return;
> > +     }
> > +
> > +     tag = (struct tag_bootmode *)of_get_property(np_chosen,
> > "atag,boot", NULL);
> > +     of_node_put(np_chosen);
> > +
> > +     if (tag)
> > +             bootmode = tag->bootmode;
> > +     else
> > +             bootmode = NORMAL_BOOT;
> > +}
> 
> No. Please don't add your downstream code.
> 
> I'll stop here. This patch modifies too many things from the previous
> one, and the series overall needs more cleanup.
> 
> Best regards,
> Roman

Hi Roman,

Agreed. The topology validation correction belongs in the patch that
first adds the validation code. I will move it there in v2 instead of
adding code in one patch and fixing it in the next.

I will also remove the downstream bootmode handling, including the
atag,boot lookup and the recovery-mode IPI shortcut. The VCP backend
patch changes too much of the preceding core patch; I will rework the
split and remove downstream-specific code before resubmitting.

Thanks,
Echo

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-11-26  9:15 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  6:00 [PATCH 0/7] soc: mediatek: add MMDVFS support for MT8196 Echo Zhang
2026-11-25  6:00 ` [PATCH 1/7] dt-bindings: clock: mediatek: add MT8196 MMDVFS clock IDs Echo Zhang
2026-11-25 10:55   ` Krzysztof Kozlowski
2026-11-25  6:00 ` [PATCH 2/7] dt-bindings: soc: mediatek: add MMDVFS binding Echo Zhang
2026-11-25  8:32   ` Roman Vivchar
2026-11-25 10:58   ` Krzysztof Kozlowski
2026-11-25 11:58   ` Krzysztof Kozlowski
2026-11-25  6:00 ` [PATCH 3/7] soc: mediatek: add MMDVFS core driver Echo Zhang
2026-11-25  8:35   ` Roman Vivchar
2026-11-25 10:54   ` Krzysztof Kozlowski
2026-11-25  6:00 ` [PATCH 4/7] soc: mediatek: mmdvfs: add VCP backend Echo Zhang
2026-11-25  8:38   ` Roman Vivchar
2026-11-25 10:59   ` Krzysztof Kozlowski
2026-11-25 11:00   ` Krzysztof Kozlowski
2026-11-25 14:32   ` Ben Grisdale
2026-11-25  6:00 ` [PATCH 5/7] soc: mediatek: mmdvfs: add MT8196 support Echo Zhang
2026-11-25  6:00 ` [PATCH 6/7] soc: mediatek: mmdvfs: add read-only status debug Echo Zhang
2026-11-25  6:00 ` [PATCH 7/7] MAINTAINERS: add MediaTek MMDVFS entry Echo Zhang
  -- strict thread matches above, loose matches on Subject: below --
2026-11-26  9:03 [PATCH 4/7] soc: mediatek: mmdvfs: add VCP backend Echo Zhang (张玉)
2026-11-26  9:15 Echo Zhang (张玉)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox