Re: [PATCH 4/7] soc: mediatek: mmdvfs: add VCP backend

From: Echo Zhang (张玉)

Date: Thu Nov 26 2026 - 04:16:11 EST


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@xxxxxxxxxxxx> 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@xxxxxxxxxxxx>
> > ---
>
> ...
>
> > 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