From: "Nuno Sá" <nuno.sa@analog.com>
To: Lee Jones <lee@kernel.org>
Cc: "Michael Hennerich" <michael.hennerich@analog.com>,
"Trevor Gamblin" <tgamblin@baylibre.com>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Sergiu Cuciurean" <sergiu.cuciurean@analog.com>,
"Drew Fustini" <dfustini@baylibre.com>,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 4/8] pwm: axi-pwmgen: Enable clocks before accessing hardware registers in probe()
Date: Fri, 6 Nov 2026 13:01:48 +0000 [thread overview]
Message-ID: <au3O-Fwf3XEMol43@nsa> (raw)
In-Reply-To: <20261105143847.2559586-5-lee@kernel.org>
On Thu, Nov 05, 2026 at 02:38:06PM +0000, Lee Jones wrote:
> axi_pwmgen_probe() calls axi_pwmgen_setup(), which reads and writes MMIO
> registers to verify the IP core version and determine the channel count,
> before acquiring and enabling axi_clk. If the bootloader leaves the AXI
> peripheral clock gated, accessing the registers causes an unclocked bus
> access fault.
>
> Acquire and enable the clocks before calling axi_pwmgen_setup().
>
> Fixes: 41814fe5c782 ("pwm: Add driver for AXI PWM generator")
> Closes: https://sashiko.dev/#/bug/linux-bc988dbc-7b12-4785-a164-b6dcab29b86a
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
FWIW, I think this is a valid fix. Likely never happens because the AXI
clock is mostly "assumed enabled" but we already had some edge cases in
other cores related to not having the clock enabled. Anyways, LGTM:
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/pwm/pwm-axi-pwmgen.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pwm/pwm-axi-pwmgen.c b/drivers/pwm/pwm-axi-pwmgen.c
> index b40522f01002..7c1b38124787 100644
> --- a/drivers/pwm/pwm-axi-pwmgen.c
> +++ b/drivers/pwm/pwm-axi-pwmgen.c
> @@ -270,16 +270,6 @@ static int axi_pwmgen_probe(struct platform_device *pdev)
> return dev_err_probe(dev, PTR_ERR(regmap),
> "failed to init register map\n");
>
> - ret = axi_pwmgen_setup(regmap, dev);
> - if (ret < 0)
> - return ret;
> -
> - chip = devm_pwmchip_alloc(dev, ret, sizeof(*ddata));
> - if (IS_ERR(chip))
> - return PTR_ERR(chip);
> - ddata = pwmchip_get_drvdata(chip);
> - ddata->regmap = regmap;
> -
> /*
> * Using NULL here instead of "axi" for backwards compatibility. There
> * are some dtbs that don't give clock-names and have the "ext" clock
> @@ -305,6 +295,16 @@ static int axi_pwmgen_probe(struct platform_device *pdev)
> if (ret)
> return dev_err_probe(dev, ret, "failed to get exclusive rate\n");
>
> + ret = axi_pwmgen_setup(regmap, dev);
> + if (ret < 0)
> + return ret;
> +
> + chip = devm_pwmchip_alloc(dev, ret, sizeof(*ddata));
> + if (IS_ERR(chip))
> + return PTR_ERR(chip);
> + ddata = pwmchip_get_drvdata(chip);
> + ddata->regmap = regmap;
> +
> ddata->clk_rate_hz = clk_get_rate(clk);
> if (!ddata->clk_rate_hz || ddata->clk_rate_hz > NSEC_PER_SEC)
> return dev_err_probe(dev, -EINVAL,
> Cc: Drew Fustini <dfustini@baylibre.com>
> --
> 2.56.0.398.g882cbad275-goog
>
next prev parent reply other threads:[~2026-11-06 13:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 14:38 [PATCH 0/8] pwm: Fix various bugs reported by Sashiko Lee Jones
2026-11-05 14:38 ` [PATCH 1/8] pwm: tegra: Prevent 32-bit period truncation and division by zero Lee Jones
2026-11-05 15:46 ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 2/8] pwm: mxs: Return early when disabling and fix error-path clock leak Lee Jones
2026-11-05 16:50 ` Frank Li
2026-11-05 14:38 ` [PATCH 3/8] pwm: loongson: Fix 32-bit control register truncation in pwm_loongson_set_polarity() Lee Jones
2026-11-05 14:38 ` [PATCH 4/8] pwm: axi-pwmgen: Enable clocks before accessing hardware registers in probe() Lee Jones
2026-11-05 15:48 ` Uwe Kleine-König
2026-11-05 18:26 ` Lee Jones
2026-11-05 18:26 ` Lee Jones
2026-11-06 13:01 ` Nuno Sá [this message]
2026-11-05 14:38 ` [PATCH 5/8] pwm: fsl-ftm: Enable ipg_clk around regcache_sync() during resume Lee Jones
2026-11-05 14:38 ` [PATCH 6/8] pwm: omap-dmtimer: Handle negative error codes from get_pwm_status() Lee Jones
2026-11-05 14:38 ` [PATCH 7/8] pwm: tiehrpwm: Enable runtime PM before registering PWM chip Lee Jones
2026-11-05 14:38 ` [PATCH 8/8] pwm: img: Unregister PWM chip before disabling runtime PM and clocks Lee Jones
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=au3O-Fwf3XEMol43@nsa \
--to=nuno.sa@analog.com \
--cc=dfustini@baylibre.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=sergiu.cuciurean@analog.com \
--cc=stable@vger.kernel.org \
--cc=tgamblin@baylibre.com \
--cc=ukleinek@kernel.org \
/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
all inboxes | Powered by JetHome®