From: sashiko-bot@kernel.org
To: peter.wang@mediatek.com
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v1 2/2] reset: mediatek: add syscon-based reset controller driver
Date: Fri, 26 Jun 2026 08:00:11 +0000 [thread overview]
Message-ID: <20260626080011.C593F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626074820.2537772-3-peter.wang@mediatek.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver incorrectly uses read-modify-write operations (`regmap_write_bits`) on dedicated set/clear registers, causing spurious resets or clear operations on unrelated hardware lines.
- [Medium] The temporary array `arr` is allocated with `devm_kcalloc`, permanently wasting memory for the lifetime of the device.
--
commit 51d3326953762868e035e2bcec526fcc8e9e6083
Author: Peter Wang <peter.wang@mediatek.com>
reset: mediatek: add syscon-based reset controller driver
Add a new reset controller driver for MediaTek SoCs that expose reset
lines through memory-mapped registers managed by a syscon node. The
driver reads reset configurations from the mediatek,reset-bits property.
> diff --git a/drivers/reset/reset-mediatek-syscon.c b/drivers/reset/reset-mediatek-syscon.c
> new file mode 100644
> index 0000000000000..da8aa646cee76
> --- /dev/null
> +++ b/drivers/reset/reset-mediatek-syscon.c
[ ... ]
> +static int mediatek_syscon_reset_assert(struct reset_controller_dev *rcdev,
> + unsigned long id)
> +{
> + struct mediatek_syscon_reset_data *data =
> + container_of(rcdev, struct mediatek_syscon_reset_data, rcdev);
> + struct mediatek_syscon_reset_control *rstc = &data->mrstc[id];
> + unsigned int val = BIT(rstc->assert_bit);
> +
> + return regmap_write_bits(data->regmap, rstc->assert_offset, val, val);
[Severity: High]
Since the hardware uses separate set and clear registers, could using
regmap_write_bits() here cause an unintended read-modify-write cycle?
If the register is Write-1-to-Set, reading it might return the current
status, and writing that back will unintentionally write '1' to other
active lines in the same register. Should this use a direct regmap_write()
instead?
> +}
> +
> +/**
> + * mediatek_syscon_reset_deassert() - Deassert a specific reset line.
[ ... ]
> + */
> +static int mediatek_syscon_reset_deassert(struct reset_controller_dev *rcdev,
> + unsigned long id)
> +{
> + struct mediatek_syscon_reset_data *data =
> + container_of(rcdev, struct mediatek_syscon_reset_data, rcdev);
> + struct mediatek_syscon_reset_control *rstc = &data->mrstc[id];
> + unsigned int val = BIT(rstc->deassert_bit);
> +
> + return regmap_write_bits(data->regmap, rstc->deassert_offset, val, val);
[Severity: High]
Similarly, for the deassert (Write-1-to-Clear) register, does using a
read-modify-write operation here risk unintentionally clearing other
unrelated reset lines that happen to read back as '1'?
> +}
[ ... ]
> +static int mediatek_syscon_reset_probe(struct platform_device *pdev)
> +{
[ ... ]
> + if (count % 5 != 0) {
> + dev_err(dev, "mediatek,reset-bits count (%d) must be a multiple of 5\n", count);
> + return -EINVAL;
> + }
> +
> + nr_resets = count / 5;
> +
> + arr = devm_kcalloc(dev, count, sizeof(u32), GFP_KERNEL);
[Severity: Medium]
Since arr is only used temporarily during probe to parse the device tree
properties and is not needed afterwards, does using devm_kcalloc()
unnecessarily keep this memory allocated for the lifetime of the device?
Would a standard kcalloc() followed by a kfree() at the end of the function
be more appropriate?
> + if (!arr)
> + return -ENOMEM;
> +
> + ret = of_property_read_u32_array(np, "mediatek,reset-bits", arr, count);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260626074820.2537772-1-peter.wang@mediatek.com?part=2
prev parent reply other threads:[~2026-06-26 8:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 7:46 [PATCH v1 0/2] reset: mediatek: add syscon-based reset controller peter.wang
2026-06-26 7:46 ` [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding peter.wang
2026-06-26 7:53 ` sashiko-bot
2026-06-26 8:33 ` Philipp Zabel
2026-06-26 15:53 ` Conor Dooley
2026-07-01 6:36 ` Peter Wang (王信友)
2026-07-01 6:35 ` Peter Wang (王信友)
2026-07-01 16:57 ` Conor Dooley
2026-07-02 8:52 ` Peter Wang (王信友)
2026-07-02 18:44 ` Conor Dooley
2026-07-02 8:55 ` AngeloGioacchino Del Regno
2026-07-02 9:39 ` Peter Wang (王信友)
2026-07-03 9:21 ` Philipp Zabel
2026-07-06 12:53 ` Peter Wang (王信友)
2026-06-26 7:46 ` [PATCH v1 2/2] reset: mediatek: add syscon-based reset controller driver peter.wang
2026-06-26 8:00 ` sashiko-bot [this message]
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=20260626080011.C593F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=peter.wang@mediatek.com \
--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.