All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luca Leonardo Scorcia" <l.scorcia@gmail.com>
Cc: mfd@lists.linux.dev, conor+dt@kernel.org,
	devicetree@vger.kernel.org, dmitry.torokhov@gmail.com,
	linux-input@vger.kernel.org, lee@kernel.org, robh@kernel.org
Subject: Re: [PATCH v9 8/9] regulator: Add MediaTek MT6392 regulator
Date: Thu, 20 Aug 2026 12:40:08 +0000	[thread overview]
Message-ID: <20260820124008.CDB421F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260820122242.120039-9-l.scorcia@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The driver mutates the statically allocated global array `mt6392_regulators` during probe, causing data races and breaking support for multiple PMIC instances.
--

--- Patch [8]: [PATCH v9 8/9] regulator: Add MediaTek MT6392 regulator ---
commit 942bc64d63d9355df7d6368a340ca5b124e3e738
Author: Fabien Parent <parent.f@gmail.com>

regulator: Add MediaTek MT6392 regulator

This patch introduces a new regulator driver for the MediaTek MT6392 PMIC.
It provides support for various power rails, including buck and LDO
regulators, controlled via regmap.

> diff --git a/drivers/regulator/mt6392-regulator.c b/drivers/regulator/mt6392-regulator.c
> new file mode 100644
> index 0000000000000..93fe887709c3b
> --- /dev/null
> +++ b/drivers/regulator/mt6392-regulator.c

[ ... ]

> +static int mt6392_set_buck_vsel_reg(struct platform_device *pdev)
> +{
> +	struct mt6397_chip *mt6392 = dev_get_drvdata(pdev->dev.parent);
> +	int i;
> +	u32 regval;
> +
> +	for (i = 0; i < MT6392_MAX_REGULATOR; i++) {
> +		if (mt6392_regulators[i].vselctrl_reg) {
> +			// Read the vselctrl_reg register
> +			if (regmap_read(mt6392->regmap,
> +					mt6392_regulators[i].vselctrl_reg,
> +					&regval) < 0) {
> +				dev_err(&pdev->dev,
> +					"Failed to read buck ctrl\n");
> +				return -EIO;
> +			}
> +
> +			// vselctrl_reg[vselctrl_mask] defines the mode
> +			if (regval & mt6392_regulators[i].vselctrl_mask) {
> +				// Regulator in Normal mode
> +				mt6392_regulators[i].desc.vsel_reg =
> +					mt6392_regulators[i].vsel_normal_mode_reg;
> +				mt6392_regulators[i].desc.vsel_mask =
> +					mt6392_regulators[i].vsel_normal_mode_mask;

[Severity: Medium]
Will this corrupt the configuration for previously registered devices if
multiple MT6392 PMIC instances are present?

This modifies the statically allocated global array mt6392_regulators based on
per-instance hardware state. Because the regulator core keeps a pointer to the
provided desc, mutating it here affects all instances of the PMIC in the
system.

> +			} else {
> +				// Regulator in Register mode
> +				mt6392_regulators[i].desc.vsel_reg =
> +					mt6392_regulators[i].vsel_reg_mode_reg;
> +				mt6392_regulators[i].desc.vsel_mask =
> +					mt6392_regulators[i].vsel_reg_mode_mask;
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}

[ ... ]

> +static struct platform_driver mt6392_regulator_driver = {
> +	.driver = {
> +		.name = "mt6392-regulator",
> +		.probe_type = PROBE_PREFER_ASYNCHRONOUS,

[Severity: Medium]
Does enabling asynchronous probing introduce a data race with the global array
modifications above?

If multiple PMIC instances are probed concurrently, they will race to overwrite
the vsel_reg and vsel_mask fields of the shared global mt6392_regulators array
in mt6392_set_buck_vsel_reg().

> +	},
> +	.probe = mt6392_regulator_probe,
> +	.id_table = mt6392_platform_ids,
> +};

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260820122242.120039-1-l.scorcia@gmail.com?part=8

  reply	other threads:[~2026-08-20 12:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 12:19 [PATCH RESEND v9 0/9] Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-08-20 12:19 ` [PATCH v9 1/9] dt-bindings: mfd: mt6397: Add " Luca Leonardo Scorcia
2026-08-20 12:40   ` sashiko-bot
2026-08-20 16:23   ` Luca Leonardo Scorcia
2026-08-20 12:20 ` [PATCH v9 2/9] dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys Luca Leonardo Scorcia
2026-08-20 12:44   ` sashiko-bot
2026-08-20 12:20 ` [PATCH v9 3/9] regulator: dt-bindings: Add MediaTek MT6392 PMIC Luca Leonardo Scorcia
2026-08-20 12:39   ` sashiko-bot
2026-08-20 12:20 ` [PATCH v9 4/9] mfd: mt6397: Use MFD_CELL_* to describe sub-devices Luca Leonardo Scorcia
2026-08-20 12:47   ` sashiko-bot
2026-08-20 12:20 ` [PATCH v9 5/9] mfd: mt6397: Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-08-20 12:49   ` sashiko-bot
2026-08-20 12:20 ` [PATCH v9 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support Luca Leonardo Scorcia
2026-08-20 12:43   ` sashiko-bot
2026-08-20 12:20 ` [PATCH v9 7/9] pinctrl: mediatek: mt6397: Add MediaTek MT6392 Luca Leonardo Scorcia
2026-08-20 12:51   ` sashiko-bot
2026-08-20 12:20 ` [PATCH v9 8/9] regulator: Add MediaTek MT6392 regulator Luca Leonardo Scorcia
2026-08-20 12:40   ` sashiko-bot [this message]
2026-08-20 12:20 ` [PATCH v9 9/9] arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi Luca Leonardo Scorcia
2026-08-20 12:58   ` sashiko-bot
2026-08-20 16:22   ` Luca Leonardo Scorcia
  -- strict thread matches above, loose matches on Subject: below --
2026-06-21  8:13 [PATCH v9 0/9] Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-06-21  8:13 ` [PATCH v9 8/9] regulator: Add MediaTek MT6392 regulator Luca Leonardo Scorcia
2026-06-21  8:30   ` sashiko-bot

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=20260820124008.CDB421F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=l.scorcia@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.