Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ryan Chen" <ryan_chen@aspeedtech.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v32 2/5] i2c: aspeed: Read clock-frequency via i2c_parse_fw_timings()
Date: Thu, 11 Jun 2026 05:40:48 +0000	[thread overview]
Message-ID: <20260611054049.0D0C71F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611-upstream_i2c-v32-2-b66eba921d01@aspeedtech.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] I2C adapter is removed after asserting hardware reset, preventing I2C transfers during device unbind.
- [High] Zero value in `bus-frequency` DT property leads to a divide-by-zero exception.
--

commit 92481335123f99873954906861adc75752062695
Author: Ryan Chen <ryan_chen@aspeedtech.com>

i2c: aspeed: Read clock-frequency via i2c_parse_fw_timings()

Use i2c_parse_fw_timings() to read the standard "clock-frequency"
property, and fall back to "bus-frequency" only when the standard
property is absent.

> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index a26b74c712061..f00bd779146e7 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
[ ... ]
> @@ -1025,12 +1026,18 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
>  	}
>  	reset_control_deassert(bus->rst);
>  
> -	ret = of_property_read_u32(pdev->dev.of_node,
> -				   "bus-frequency", &bus->bus_frequency);
> -	if (ret < 0) {
> -		dev_err(&pdev->dev,
> -			"Could not read bus-frequency property\n");
> -		bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
> +	i2c_parse_fw_timings(&pdev->dev, &timings, false);
> +	if (timings.bus_freq_hz) {
> +		bus->bus_frequency = timings.bus_freq_hz;
> +	} else {
> +		ret = of_property_read_u32(pdev->dev.of_node,
> +					   "bus-frequency",
> +					   &bus->bus_frequency);
> +		if (ret < 0) {
> +			dev_err(&pdev->dev,
> +				"Could not read clock-frequency or bus-frequency property\n");
> +			bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
> +		}
>  	}

[Severity: High]
This is a pre-existing issue, but can this code cause a divide-by-zero
exception if the device tree sets "bus-frequency" to 0?

If the property is present and set to 0, of_property_read_u32() succeeds
and leaves bus->bus_frequency as 0. Later, in aspeed_i2c_init_clk(), it
is used as a divisor:

drivers/i2c/busses/i2c-aspeed.c:aspeed_i2c_init_clk() {
    ...
    divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency);
    ...
}

Does the driver need to validate that the read frequency is strictly
positive to prevent a kernel panic here?


[Severity: High]
This is a pre-existing issue, but does aspeed_i2c_remove_bus() prevent
I2C transfers during device unbind by asserting hardware reset too early?

In drivers/i2c/busses/i2c-aspeed.c:aspeed_i2c_remove_bus(), the code does:

    /* Disable everything. */
    writel(0, bus->base + ASPEED_I2C_FUN_CTRL_REG);
    writel(0, bus->base + ASPEED_I2C_INTR_CTRL_REG);

    spin_unlock_irqrestore(&bus->lock, flags);

    reset_control_assert(bus->rst);

    i2c_del_adapter(&bus->adap);

When i2c_del_adapter() unregisters child I2C devices, their remove
callbacks may attempt I2C transfers to cleanly shut down the peripherals.

Because the hardware controller is already disabled and in reset, will these
transfers silently fail, timeout, or cause external aborts when the CPU
tries to access the registers?

Should i2c_del_adapter() be called before disabling the hardware and
asserting reset?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260611-upstream_i2c-v32-0-b66eba921d01@aspeedtech.com?part=2

  reply	other threads:[~2026-06-11  5:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  5:31 [PATCH v32 0/5] Add ASPEED AST2600 I2C controller driver Ryan Chen
2026-06-11  5:31 ` [PATCH v32 1/5] dt-bindings: i2c: Split AST2600 binding into a new YAML Ryan Chen
2026-06-11  5:31 ` [PATCH v32 2/5] i2c: aspeed: Read clock-frequency via i2c_parse_fw_timings() Ryan Chen
2026-06-11  5:40   ` sashiko-bot [this message]
2026-06-11  5:31 ` [PATCH v32 3/5] dt-bindings: i2c: ast2600-i2c.yaml: Add global-regs properties Ryan Chen
2026-06-11  5:31 ` [PATCH v32 4/5] i2c: ast2600: Add controller driver for AST2600 new register set Ryan Chen
2026-06-11  5:46   ` sashiko-bot
2026-06-11  5:31 ` [PATCH v32 5/5] i2c: ast2600: Add target mode support Ryan Chen
2026-06-11  5:46   ` sashiko-bot
2026-06-11  8:42 ` [PATCH v32 0/5] Add ASPEED AST2600 I2C controller driver Ryan Chen

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=20260611054049.0D0C71F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=ryan_chen@aspeedtech.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox