Linux-i3c Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Akhil R <akhilrajeev@nvidia.com>
To: <sashiko-bot@kernel.org>
Cc: <Frank.Li@kernel.org>, <akhilrajeev@nvidia.com>,
	<alexandre.belloni@bootlin.com>, <conor+dt@kernel.org>,
	<devicetree@vger.kernel.org>, <linux-hwmon@vger.kernel.org>,
	<linux-i3c@lists.infradead.org>, <robh@kernel.org>,
	<sashiko-reviews@lists.linux.dev>
Subject: Re: [PATCH v6 08/12] i3c: dw-i3c-master: Add ACPI core clock frequency quirk
Date: Mon, 27 Jul 2026 14:41:12 +0000	[thread overview]
Message-ID: <20260727144112.177391-1-akhilrajeev@nvidia.com> (raw)
In-Reply-To: <20260721042615.E38721F000E9@smtp.kernel.org>

On Tue, 21 Jul 2026 04:26:15 +0000, Sashiko AI review <sashiko-bot@kernel.org> wrote:
> commit f3333de342eb1c266eb94909516ea27afe8378d5
> Author: Akhil R <akhilrajeev@nvidia.com>
>
> i3c: dw-i3c-master: Add ACPI core clock frequency quirk
>
> Some ACPI-enumerated devices like Tegra410 do not expose the controller
> core clock through the clk framework. Unlike device tree, ACPI on Arm does
> not model clock providers. The hardware is expected to have its clocks
> enabled by firmware before the OS takes over.
>
> > diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c
> > index 29030fd9594aa..3ec3ab1c13b4c 100644
> > --- a/drivers/i3c/master/dw-i3c-master.c
> > +++ b/drivers/i3c/master/dw-i3c-master.c
>
> [ ... ]
>
> > @@ -556,13 +557,33 @@ static void dw_i3c_master_set_intr_regs(struct dw_i3c_master *master)
> > +static unsigned long dw_i3c_master_get_core_rate(struct dw_i3c_master *master)
> > +{
> > +	unsigned int core_rate_prop;
> > +
> > +	if (master->core_clk)
> > +		return clk_get_rate(master->core_clk);
> > +
> > +	if (!(master->quirks & DW_I3C_ACPI_SKIP_CLK_RST)) {
> > +		dev_err(master->dev, "missing core clock\n");
> > +		return 0;
> > +	}
>
> [Severity: Low]
> Is this check reachable?
>
> During initialization in dw_i3c_common_probe(), if the core clock is missing
> and DW_I3C_ACPI_SKIP_CLK_RST is not set, probe immediately aborts with -EINVAL.
>
> By the time dw_i3c_master_get_core_rate() is executed, it seems guaranteed
> that if core_clk is missing, the DW_I3C_ACPI_SKIP_CLK_RST quirk is already
> set, making this fallback check dead code.

The check is defensive and is harmless. I believe it adds to readability,
but can be cleaned up if preferred.

> > +
> > +	if (device_property_read_u32(master->dev, "clock-frequency", &core_rate_prop)) {
> > +		dev_err(master->dev, "missing clock-frequency property\n");
> > +		return 0;
> > +	}
> > +
> > +	return core_rate_prop;
> > +}
>
> [ ... ]
>
> > @@ -1573,14 +1594,28 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
> > +	if (has_acpi_companion(&pdev->dev)) {
> > +		quirks = (unsigned long)device_get_match_data(&pdev->dev);
> > +	} else if (pdev->dev.of_node) {
>
> [Severity: High]
> This isn't a bug introduced by this patch, but since this block was
> relocated, I noticed a potential issue for devices using ACPI PRP0001.
>
> If the device is instantiated via ACPI using the PRP0001 HID,
> device_get_match_data() correctly falls back to the OF match table and
> returns a pointer to struct dw_i3c_drvdata.
>
> Does casting this pointer to an unsigned long and assigning it to
> master->quirks cause random kernel pointers to be used as a quirk bitmask?
> Depending on the kernel layout, this might cause erratic driver behavior such
> as missing PM operations.

> > +		drvdata = device_get_match_data(&pdev->dev);
> > +		if (drvdata)
> > +			quirks = drvdata->flags;
> > +	}
> > +	master->quirks = quirks;
>
> [ ... ]
>
> > @@ -1636,15 +1671,6 @@ int dw_i3c_common_probe(struct dw_i3c_master *master,
> > -	if (has_acpi_companion(&pdev->dev)) {
> > -		quirks = (unsigned long)device_get_match_data(&pdev->dev);
> > -	} else if (pdev->dev.of_node) {
> > -		drvdata = device_get_match_data(&pdev->dev);
> > -		if (drvdata)
> > -			quirks = drvdata->flags;
> > -	}
> > -	master->quirks = quirks;
> > -
>
> [Severity: High]
> This is a pre-existing issue, but I noticed a potential problem in the device
> removal path regarding runtime PM state.
>
> When the driver is unbound, dw_i3c_common_remove() calls
> i3c_master_unregister(), which internally calls dw_i3c_master_bus_cleanup().
> The dw_i3c_master_bus_cleanup() function accesses the DEVICE_CTRL MMIO
> register. Because the driver does not wake the device via
> pm_runtime_get_sync() before unregistration, the device may be in a
> runtime-suspended state with its core clocks disabled.
>
> Could this cause a fatal bus fault on platforms like ARM due to unclocked MMIO
> accesses? Additionally, if the device remains suspended, will the subsequent
> devres cleanup attempt to disable the already-disabled clocks, causing a clock
> enable counter underflow warning?

These are existing issues in the driver. It would be better to address them
separately.

Best Regards,
Akhil

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  reply	other threads:[~2026-07-27 14:41 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  4:07 [PATCH v6 00/12] Support ACPI and SETAASA device discovery Akhil R
2026-07-21  4:07 ` [PATCH v6 01/12] dt-bindings: i3c: Add mipi-i3c-static-method to support SETAASA Akhil R
2026-07-21  4:16   ` sashiko-bot
2026-07-21  4:07 ` [PATCH v6 02/12] i3c: master: Use unified device property interface Akhil R
2026-07-21  4:25   ` sashiko-bot
2026-07-22 10:38   ` Adrian Hunter
2026-07-27  8:26     ` Akhil R
2026-07-27 16:07       ` Frank Li
2026-07-21  4:07 ` [PATCH v6 03/12] i3c: master: Support ACPI enumeration of child devices Akhil R
2026-07-21  4:32   ` sashiko-bot
2026-07-21  4:07 ` [PATCH v6 04/12] i3c: master: Add support for devices using SETAASA Akhil R
2026-07-21  4:30   ` sashiko-bot
2026-07-27 12:57     ` Akhil R
2026-07-27 16:12       ` Frank Li
2026-07-28  5:47         ` Akhil R
2026-07-21  4:07 ` [PATCH v6 05/12] i3c: master: Add support for devices without PID Akhil R
2026-07-21  4:26   ` sashiko-bot
2026-07-27 14:12     ` Akhil R
2026-07-27 16:14       ` Frank Li
2026-07-21  4:07 ` [PATCH v6 06/12] i3c: master: match I3C device through DT and ACPI Akhil R
2026-07-21  4:25   ` sashiko-bot
2026-07-27 14:39     ` Akhil R
2026-07-27 16:16       ` Frank Li
2026-07-21  4:07 ` [PATCH v6 07/12] i3c: dw-i3c-master: Add SETAASA as supported CCC Akhil R
2026-07-21  4:24   ` sashiko-bot
2026-07-21  4:07 ` [PATCH v6 08/12] i3c: dw-i3c-master: Add ACPI core clock frequency quirk Akhil R
2026-07-21  4:26   ` sashiko-bot
2026-07-27 14:41     ` Akhil R [this message]
2026-07-27 16:19       ` Frank Li
2026-07-21  4:07 ` [PATCH v6 09/12] i3c: dw-i3c-master: Add ACPI ID for Tegra410 Akhil R
2026-07-21  4:22   ` sashiko-bot
2026-07-27 14:42     ` Akhil R
2026-07-21  4:07 ` [PATCH v6 10/12] hwmon: spd5118: Remove 16-bit addressing Akhil R
2026-07-21  4:25   ` sashiko-bot
2026-07-21  4:07 ` [PATCH v6 11/12] hwmon: spd5118: Add I3C support Akhil R
2026-07-21  4:35   ` sashiko-bot
2026-07-21  4:08 ` [PATCH v6 12/12] arm64: defconfig: Enable I3C and SPD5118 hwmon Akhil R
2026-07-21  4:28   ` sashiko-bot
2026-07-21 16:52 ` [PATCH v6 00/12] Support ACPI and SETAASA device discovery Frank Li
2026-07-27 14:52   ` Akhil R

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=20260727144112.177391-1-akhilrajeev@nvidia.com \
    --to=akhilrajeev@nvidia.com \
    --cc=Frank.Li@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-i3c@lists.infradead.org \
    --cc=robh@kernel.org \
    --cc=sashiko-bot@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox