Devicetree
 help / color / mirror / Atom feed
* Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
       [not found] ` <20260626074820.2537772-2-peter.wang@mediatek.com>
@ 2026-06-26  7:53   ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-06-26  7:53 UTC (permalink / raw)
  To: peter.wang; +Cc: robh, conor+dt, devicetree

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The YAML binding schema is missing the mandatory `$id` field.
--

commit 010ce9609c338d8282471debb7c3cd606956e201
Author: Peter Wang <peter.wang@mediatek.com>

Documentation: dt: reset: add mediatek,syscon-reset binding

This commit adds Device Tree binding documentation for the MediaTek SYSCON 
reset controller. The binding describes a reset controller that is part of 
a MediaTek SYSCON MFD block and manages multiple reset lines via the 
mediatek,reset-bits property.

> diff --git a/Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml b/Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml
> new file mode 100644
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml
> @@ -0,0 +1,93 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$schema: http://devicetree.org/meta-schemas/core.yaml#

[Severity: Medium]
Is the mandatory $id field missing from this schema definition?

Without the $id field, the schema cross-reference system ($ref resolution)
can break, and dt_binding_check might silently skip validation or report
misleading errors. Should it be added to the top-level schema header?

> +
> +title: MediaTek SYSCON Reset Controller

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626074820.2537772-1-peter.wang@mediatek.com?part=1

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

* Re: [PATCH v1 2/2] reset: mediatek: add syscon-based reset controller driver
       [not found] ` <20260626074820.2537772-3-peter.wang@mediatek.com>
@ 2026-06-26  8:00   ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-06-26  8:00 UTC (permalink / raw)
  To: peter.wang; +Cc: devicetree, robh, conor+dt

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

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

end of thread, other threads:[~2026-06-26  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260626074820.2537772-1-peter.wang@mediatek.com>
     [not found] ` <20260626074820.2537772-2-peter.wang@mediatek.com>
2026-06-26  7:53   ` [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding sashiko-bot
     [not found] ` <20260626074820.2537772-3-peter.wang@mediatek.com>
2026-06-26  8:00   ` [PATCH v1 2/2] reset: mediatek: add syscon-based reset controller driver sashiko-bot

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