From: sashiko-bot@kernel.org
To: "Junyi Zhao" <junyi.zhao@amlogic.com>
Cc: linux-i3c@lists.infradead.org, devicetree@vger.kernel.org,
linux-amlogic@lists.infradead.org, imx@lists.linux.dev,
robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org,
neil.armstrong@linaro.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v5 2/2] i3c: master: svc: Add amlogic a9 support
Date: Thu, 19 Nov 2026 04:35:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-222447@kernel.org> (raw)
In-Reply-To: <20261119-a9_i3c-v5-2-6ec51f8fb59d@amlogic.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] i3c: master: svc: clocks left enabled in
svc_i3c_master_remove()
--
commit 3c43a1b9aa9bf261826430f4095843da1b45b5e2
Author: Junyi Zhao <junyi.zhao@amlogic.com>
i3c: master: svc: Add amlogic a9 support
This commit adds Amlogic A9 EE-domain and AO-domain I3C controller support
to the Silvaco I3C master driver, registering the AO variant's internal
fast_clk divider chain with the common clock framework and configuring the
fast_clk rate during probe.
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index e700392f0801f..d7381710657e2 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
[ ... ]
> @@ -2163,9 +2229,214 @@ static const struct svc_i3c_drvdata npcm845_drvdata = {
>
> static const struct svc_i3c_drvdata svc_default_drvdata = {};
>
> +/**
> + * struct aml_i3c_ao_clk - container for the AO variant's internal fast clock
> + * @div_en: enables the internal divider
> + * @div: bus clock divider
> + * @gate: output gate of the generated fast clock
> + * @lock: spinlock shared by the gate and divider register operations
> + *
> + * The clock HW structures are registered with the clock framework and must
> + * stay alive for the whole driver lifetime, so they are kept along with the
> + * shared lock used by their gate/divider operations.
> + */
> +struct aml_i3c_ao_clk {
> + struct clk_gate div_en;
> + struct clk_divider div;
> + struct clk_gate gate;
> + spinlock_t lock;
> +};
> +
> +/**
> + * aml_ao_i3c_tail_clocks - register the AO variant's internal fast clock
> + * @master: I3C master controller
> + * @parent: parent clock of the internal divider chain; must be "pclk", the
> + * only clock the AO variant exposes (see silvaco,i3c-master.yaml)
> + *
> + * Register the internal divider chain that produces the AO variant's
> + * fast_clk and append it to the clk bulk array as "fast_clk". The caller
> + * must run with the clocks enabled since the divider registers are
> + * accessed during registration. The appended clock is prepared and
> + * enabled here as well, because clk_bulk_prepare_enable() already ran
> + * in the probe with the original clock list.
> + *
> + * Return: 0 on success, or a negative error code.
> + */
> +static int aml_ao_i3c_tail_clocks(struct svc_i3c_master *master, struct clk *parent)
> +{
> + struct device *dev = master->dev;
> + struct clk_bulk_data *new_clks;
> + struct clk_init_data init = {};
> + struct aml_i3c_ao_clk *ao;
> + struct clk *fclk;
> + char name[64];
> + int ret;
[ ... ]
> + ret = devm_clk_hw_register(dev, &ao->gate.hw);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to register %s\n", name);
> +
> + fclk = devm_clk_hw_get_clk(dev, &ao->gate.hw, NULL);
> + if (IS_ERR(fclk))
> + return dev_err_probe(dev, PTR_ERR(fclk),
> + "tail i3c fast clock failed\n");
> +
> + /*
> + * Keep the clk bulk state balanced for the following
> + * clk_bulk_disable_unprepare() calls (error paths and runtime PM).
> + */
> + ret = clk_prepare_enable(fclk);
> + if (ret)
> + return dev_err_probe(dev, ret, "can't enable fast_clk\n");
> +
> + new_clks = devm_kcalloc(dev, master->num_clks + 1, sizeof(*new_clks),
> + GFP_KERNEL);
> + if (!new_clks) {
> + clk_disable_unprepare(fclk);
> + return -ENOMEM;
> + }
> +
> + memcpy(new_clks, master->clks,
> + master->num_clks * sizeof(*master->clks));
> + new_clks[master->num_clks].id = "fast_clk";
> + new_clks[master->num_clks].clk = fclk;
> + master->clks = new_clks;
> + master->num_clks++;
> +
> + return 0;
> +}
[Severity: Medium]
Can this leave the internal divider clocks prepared and enabled when the
driver is unbound while the device is not runtime-suspended?
drivers/i3c/master/svc-i3c-master.c:svc_i3c_master_remove() {
struct svc_i3c_master *master = platform_get_drvdata(pdev);
i3c_master_unregister(&master->base);
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
svc_i3c_master_remove() relies on svc_i3c_runtime_suspend() to disable
master->clks. If the device is still active when removed (for example when
CONFIG_PM is disabled, runtime PM is set to "on" in sysfs, or hotjoin held
a runtime PM reference), devres unregisters ao->gate.hw, ao->div.hw and
ao->div_en.hw while fclk is still prepared and enabled, triggering a
WARNING in clk_unregister() and leaking the prepare/enable count on pclk.
Calling clk_bulk_disable_unprepare() in svc_i3c_master_remove() when
!pm_runtime_status_suspended(&pdev->dev) would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-a9_i3c-v5-0-6ec51f8fb59d@amlogic.com?part=2
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Junyi Zhao" <junyi.zhao@amlogic.com>
Cc: linux-i3c@lists.infradead.org, devicetree@vger.kernel.org,
linux-amlogic@lists.infradead.org, imx@lists.linux.dev,
robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org,
neil.armstrong@linaro.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v5 2/2] i3c: master: svc: Add amlogic a9 support
Date: Thu, 19 Nov 2026 04:35:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-222447@kernel.org> (raw)
In-Reply-To: <20261119-a9_i3c-v5-2-6ec51f8fb59d@amlogic.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] i3c: master: svc: clocks left enabled in
svc_i3c_master_remove()
--
commit 3c43a1b9aa9bf261826430f4095843da1b45b5e2
Author: Junyi Zhao <junyi.zhao@amlogic.com>
i3c: master: svc: Add amlogic a9 support
This commit adds Amlogic A9 EE-domain and AO-domain I3C controller support
to the Silvaco I3C master driver, registering the AO variant's internal
fast_clk divider chain with the common clock framework and configuring the
fast_clk rate during probe.
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index e700392f0801f..d7381710657e2 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
[ ... ]
> @@ -2163,9 +2229,214 @@ static const struct svc_i3c_drvdata npcm845_drvdata = {
>
> static const struct svc_i3c_drvdata svc_default_drvdata = {};
>
> +/**
> + * struct aml_i3c_ao_clk - container for the AO variant's internal fast clock
> + * @div_en: enables the internal divider
> + * @div: bus clock divider
> + * @gate: output gate of the generated fast clock
> + * @lock: spinlock shared by the gate and divider register operations
> + *
> + * The clock HW structures are registered with the clock framework and must
> + * stay alive for the whole driver lifetime, so they are kept along with the
> + * shared lock used by their gate/divider operations.
> + */
> +struct aml_i3c_ao_clk {
> + struct clk_gate div_en;
> + struct clk_divider div;
> + struct clk_gate gate;
> + spinlock_t lock;
> +};
> +
> +/**
> + * aml_ao_i3c_tail_clocks - register the AO variant's internal fast clock
> + * @master: I3C master controller
> + * @parent: parent clock of the internal divider chain; must be "pclk", the
> + * only clock the AO variant exposes (see silvaco,i3c-master.yaml)
> + *
> + * Register the internal divider chain that produces the AO variant's
> + * fast_clk and append it to the clk bulk array as "fast_clk". The caller
> + * must run with the clocks enabled since the divider registers are
> + * accessed during registration. The appended clock is prepared and
> + * enabled here as well, because clk_bulk_prepare_enable() already ran
> + * in the probe with the original clock list.
> + *
> + * Return: 0 on success, or a negative error code.
> + */
> +static int aml_ao_i3c_tail_clocks(struct svc_i3c_master *master, struct clk *parent)
> +{
> + struct device *dev = master->dev;
> + struct clk_bulk_data *new_clks;
> + struct clk_init_data init = {};
> + struct aml_i3c_ao_clk *ao;
> + struct clk *fclk;
> + char name[64];
> + int ret;
[ ... ]
> + ret = devm_clk_hw_register(dev, &ao->gate.hw);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to register %s\n", name);
> +
> + fclk = devm_clk_hw_get_clk(dev, &ao->gate.hw, NULL);
> + if (IS_ERR(fclk))
> + return dev_err_probe(dev, PTR_ERR(fclk),
> + "tail i3c fast clock failed\n");
> +
> + /*
> + * Keep the clk bulk state balanced for the following
> + * clk_bulk_disable_unprepare() calls (error paths and runtime PM).
> + */
> + ret = clk_prepare_enable(fclk);
> + if (ret)
> + return dev_err_probe(dev, ret, "can't enable fast_clk\n");
> +
> + new_clks = devm_kcalloc(dev, master->num_clks + 1, sizeof(*new_clks),
> + GFP_KERNEL);
> + if (!new_clks) {
> + clk_disable_unprepare(fclk);
> + return -ENOMEM;
> + }
> +
> + memcpy(new_clks, master->clks,
> + master->num_clks * sizeof(*master->clks));
> + new_clks[master->num_clks].id = "fast_clk";
> + new_clks[master->num_clks].clk = fclk;
> + master->clks = new_clks;
> + master->num_clks++;
> +
> + return 0;
> +}
[Severity: Medium]
Can this leave the internal divider clocks prepared and enabled when the
driver is unbound while the device is not runtime-suspended?
drivers/i3c/master/svc-i3c-master.c:svc_i3c_master_remove() {
struct svc_i3c_master *master = platform_get_drvdata(pdev);
i3c_master_unregister(&master->base);
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
svc_i3c_master_remove() relies on svc_i3c_runtime_suspend() to disable
master->clks. If the device is still active when removed (for example when
CONFIG_PM is disabled, runtime PM is set to "on" in sysfs, or hotjoin held
a runtime PM reference), devres unregisters ao->gate.hw, ao->div.hw and
ao->div_en.hw while fclk is still prepared and enabled, triggering a
WARNING in clk_unregister() and leaking the prepare/enable count on pclk.
Calling clk_bulk_disable_unprepare() in svc_i3c_master_remove() when
!pm_runtime_status_suspended(&pdev->dev) would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-a9_i3c-v5-0-6ec51f8fb59d@amlogic.com?part=2
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Junyi Zhao" <junyi.zhao@amlogic.com>
Cc: linux-i3c@lists.infradead.org, devicetree@vger.kernel.org,
linux-amlogic@lists.infradead.org, imx@lists.linux.dev,
robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org,
neil.armstrong@linaro.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v5 2/2] i3c: master: svc: Add amlogic a9 support
Date: Thu, 19 Nov 2026 04:35:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-222447@kernel.org> (raw)
In-Reply-To: <20261119-a9_i3c-v5-2-6ec51f8fb59d@amlogic.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] i3c: master: svc: clocks left enabled in
svc_i3c_master_remove()
--
commit 3c43a1b9aa9bf261826430f4095843da1b45b5e2
Author: Junyi Zhao <junyi.zhao@amlogic.com>
i3c: master: svc: Add amlogic a9 support
This commit adds Amlogic A9 EE-domain and AO-domain I3C controller support
to the Silvaco I3C master driver, registering the AO variant's internal
fast_clk divider chain with the common clock framework and configuring the
fast_clk rate during probe.
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index e700392f0801f..d7381710657e2 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
[ ... ]
> @@ -2163,9 +2229,214 @@ static const struct svc_i3c_drvdata npcm845_drvdata = {
>
> static const struct svc_i3c_drvdata svc_default_drvdata = {};
>
> +/**
> + * struct aml_i3c_ao_clk - container for the AO variant's internal fast clock
> + * @div_en: enables the internal divider
> + * @div: bus clock divider
> + * @gate: output gate of the generated fast clock
> + * @lock: spinlock shared by the gate and divider register operations
> + *
> + * The clock HW structures are registered with the clock framework and must
> + * stay alive for the whole driver lifetime, so they are kept along with the
> + * shared lock used by their gate/divider operations.
> + */
> +struct aml_i3c_ao_clk {
> + struct clk_gate div_en;
> + struct clk_divider div;
> + struct clk_gate gate;
> + spinlock_t lock;
> +};
> +
> +/**
> + * aml_ao_i3c_tail_clocks - register the AO variant's internal fast clock
> + * @master: I3C master controller
> + * @parent: parent clock of the internal divider chain; must be "pclk", the
> + * only clock the AO variant exposes (see silvaco,i3c-master.yaml)
> + *
> + * Register the internal divider chain that produces the AO variant's
> + * fast_clk and append it to the clk bulk array as "fast_clk". The caller
> + * must run with the clocks enabled since the divider registers are
> + * accessed during registration. The appended clock is prepared and
> + * enabled here as well, because clk_bulk_prepare_enable() already ran
> + * in the probe with the original clock list.
> + *
> + * Return: 0 on success, or a negative error code.
> + */
> +static int aml_ao_i3c_tail_clocks(struct svc_i3c_master *master, struct clk *parent)
> +{
> + struct device *dev = master->dev;
> + struct clk_bulk_data *new_clks;
> + struct clk_init_data init = {};
> + struct aml_i3c_ao_clk *ao;
> + struct clk *fclk;
> + char name[64];
> + int ret;
[ ... ]
> + ret = devm_clk_hw_register(dev, &ao->gate.hw);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to register %s\n", name);
> +
> + fclk = devm_clk_hw_get_clk(dev, &ao->gate.hw, NULL);
> + if (IS_ERR(fclk))
> + return dev_err_probe(dev, PTR_ERR(fclk),
> + "tail i3c fast clock failed\n");
> +
> + /*
> + * Keep the clk bulk state balanced for the following
> + * clk_bulk_disable_unprepare() calls (error paths and runtime PM).
> + */
> + ret = clk_prepare_enable(fclk);
> + if (ret)
> + return dev_err_probe(dev, ret, "can't enable fast_clk\n");
> +
> + new_clks = devm_kcalloc(dev, master->num_clks + 1, sizeof(*new_clks),
> + GFP_KERNEL);
> + if (!new_clks) {
> + clk_disable_unprepare(fclk);
> + return -ENOMEM;
> + }
> +
> + memcpy(new_clks, master->clks,
> + master->num_clks * sizeof(*master->clks));
> + new_clks[master->num_clks].id = "fast_clk";
> + new_clks[master->num_clks].clk = fclk;
> + master->clks = new_clks;
> + master->num_clks++;
> +
> + return 0;
> +}
[Severity: Medium]
Can this leave the internal divider clocks prepared and enabled when the
driver is unbound while the device is not runtime-suspended?
drivers/i3c/master/svc-i3c-master.c:svc_i3c_master_remove() {
struct svc_i3c_master *master = platform_get_drvdata(pdev);
i3c_master_unregister(&master->base);
pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
svc_i3c_master_remove() relies on svc_i3c_runtime_suspend() to disable
master->clks. If the device is still active when removed (for example when
CONFIG_PM is disabled, runtime PM is set to "on" in sysfs, or hotjoin held
a runtime PM reference), devres unregisters ao->gate.hw, ao->div.hw and
ao->div_en.hw while fclk is still prepared and enabled, triggering a
WARNING in clk_unregister() and leaking the prepare/enable count on pclk.
Calling clk_bulk_disable_unprepare() in svc_i3c_master_remove() when
!pm_runtime_status_suspended(&pdev->dev) would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-a9_i3c-v5-0-6ec51f8fb59d@amlogic.com?part=2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-11-19 4:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 4:22 [PATCH v5 0/2] Add Amlogic A9 I3C support Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao
2026-11-19 4:22 ` [PATCH v5 1/2] dt-bindings: i3c: silvaco,i3c-master: Add Amlogic A9 support Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao
2026-11-19 4:22 ` [PATCH v5 2/2] i3c: master: svc: Add amlogic a9 support Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao via B4 Relay
2026-11-19 4:22 ` Junyi Zhao
2026-11-19 4:35 ` sashiko-bot [this message]
2026-11-19 4:35 ` sashiko-bot
2026-11-19 4:35 ` 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=sashiko-outbox-222447@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=junyi.zhao@amlogic.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-i3c@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--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.