From: sashiko-bot@kernel.org
To: "Ben Zong-You Xie" <ben717@andestech.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 2/3] pwm: add Andes PWM driver support
Date: Wed, 12 Aug 2026 03:34:27 +0000 [thread overview]
Message-ID: <20260812033427.BA6271F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812-andes-pwm-v7-2-a806da8185d1@andestech.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver fails to update the inactive output state (PARK bit) when disabling the PWM channel, ignoring polarity changes and leaving the output at the active level if previously at 100% duty cycle.
- [High] Emulating 0% or 100% duty cycles leaves RELOAD registers stale and breaks `pwm_get_state` reporting by corrupting polarity, enabled status, and duty cycle calculations.
--
--- Patch [2]: [PATCH v7 2/3] pwm: add Andes PWM driver support ---
commit 76e1cbe61be3ddd82abebdaef695376f3fc6a571
Author: Ben Zong-You Xie <ben717@andestech.com>
pwm: add Andes PWM driver support
Add a driver for the PWM controller found in Andes AE350 platforms and
QiLai SoCs.
> diff --git a/drivers/pwm/pwm-andes.c b/drivers/pwm/pwm-andes.c
> new file mode 100644
> index 0000000000000..8dafce7c467c1
> --- /dev/null
> +++ b/drivers/pwm/pwm-andes.c
[ ... ]
> +static int andes_pwm_config(struct pwm_chip *chip, unsigned int channel,
> + const struct pwm_state *state)
> +{
[ ... ]
> + /*
> + * A zero-length phase means a 0% or 100% relative duty cycle, which the
> + * hardware cannot run. Emit the matching constant level by parking the
> + * channel: high_cycles == 0 stays low, low_cycles == 0 stays high.
> + */
> + if (!high_cycles)
> + return andes_pwm_park(chip, channel, false);
> + if (!low_cycles)
> + return andes_pwm_park(chip, channel, true);
[Severity: High]
Does using the PARK bit to emulate 100% and 0% duty cycles cause incorrect
states to be reported by andes_pwm_get_state() later?
If a channel is emulating a 100% duty cycle, andes_pwm_park() modifies the
PARK bit and disables the channel without updating the RELOAD registers.
When andes_pwm_get_state() is later called, it uses the PARK bit to deduce
polarity, which incorrectly evaluates to PWM_POLARITY_INVERSED. Additionally,
the enabled status will be evaluated as false since the channel was physically
disabled, and the unupdated RELOAD register will cause stale period and duty
cycle values to be returned.
[ ... ]
> +static int andes_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> + const struct pwm_state *state)
> +{
> + unsigned int channel = pwm->hwpwm;
> +
> + if (!state->enabled) {
> + if (pwm->state.enabled)
> + andes_pwm_enable(chip, channel, false);
> +
> + return 0;
> + }
[Severity: High]
When disabling the PWM channel, does the driver need to update the PARK bit
to ensure the output goes to the correct inactive state based on polarity?
If a channel is configured to a 100% duty cycle with NORMAL polarity,
andes_pwm_config() will have set the PARK bit to 1. If the PWM is
subsequently disabled, andes_pwm_apply() clears the PWM enable bit but does
not reset the PARK bit.
Since a disabled channel continues to drive the PARK level, might this leave
the disabled channel driving the active state (HIGH) instead of the expected
inactive state (LOW)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812-andes-pwm-v7-0-a806da8185d1@andestech.com?part=2
next prev parent reply other threads:[~2026-08-12 3:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 3:24 [PATCH v7 0/3] pwm: add support for Andes platform Ben Zong-You Xie via B4 Relay
2026-08-12 3:24 ` [PATCH v7 1/3] dt-bindings: pwm: add support for AE350 PWM controller Ben Zong-You Xie via B4 Relay
2026-08-12 3:24 ` [PATCH v7 2/3] pwm: add Andes PWM driver support Ben Zong-You Xie via B4 Relay
2026-08-12 3:34 ` sashiko-bot [this message]
2026-08-12 3:24 ` [PATCH v7 3/3] MAINTAINERS: add an entry for Andes PWM driver Ben Zong-You Xie via B4 Relay
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=20260812033427.BA6271F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ben717@andestech.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox