mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Grisdale <bengris32@protonmail.ch>
To: Echo Zhang <echo.zhang@mediatek.com>
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	MMDVFS Team <linux-mediatek@lists.infradead.org>,
	kyrie.wu@mediatek.com, ming-fan.chen@mediatek.com,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH 4/7] soc: mediatek: mmdvfs: add VCP backend
Date: Wed, 25 Nov 2026 14:32:54 +0000	[thread overview]
Message-ID: <20261125143248.237422bc@ben-desktop> (raw)
In-Reply-To: <20261125060037.649659-5-echo.zhang@mediatek.com>

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


  parent reply	other threads:[~2026-11-25 14:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20261125143248.237422bc@ben-desktop \
    --to=bengris32@protonmail.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bmasney+clk@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=echo.zhang@mediatek.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=justinstitt@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=kyrie.wu@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=matthias.bgg@gmail.com \
    --cc=ming-fan.chen@mediatek.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=robh@kernel.org \
    --cc=sboyd@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

all inboxes | Powered by JetHome®