Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Petar Stepanovic" <pstepanovic@axiado.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 2/2] pwm: add Axiado AX3000 PWM driver
Date: Mon, 21 Sep 2026 07:29:33 +0000	[thread overview]
Message-ID: <20260921072933.8AC481F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921-axiado-ax3000-pwm-v5-2-202aad28e129@axiado.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pwm: axiado: misinterprets constant-high hardware state as 0% duty on readback
--

commit 0be6bd48e49f4eaed6639766408acd48c1985d0f
Author: Petar Stepanovic <pstepanovic@axiado.com>

pwm: add Axiado AX3000 PWM driver

The Axiado AX3000 and AX3005 SoCs include a single-channel PWM
controller. Add a driver supporting period, duty-cycle, and enable-state
configuration through the Linux PWM framework.

> diff --git a/drivers/pwm/pwm-axiado.c b/drivers/pwm/pwm-axiado.c
> new file mode 100644
> index 0000000000000..781053e255f03
> --- /dev/null
> +++ b/drivers/pwm/pwm-axiado.c
[ ... ]
> +static int
> +axiado_pwm_round_waveform_fromhw(struct pwm_chip *chip,
> +				 struct pwm_device *pwm,
> +				 const void *_wfhw,
> +				 struct pwm_waveform *wf)
> +{
> +	struct axiado_pwm_chip *axpwm = pwmchip_get_drvdata(chip);
> +	const struct axiado_pwm_waveform *wfhw = _wfhw;
> +	u32 period = wfhw->period;
> +	u32 duty = wfhw->duty;
> +
> +	if (!wfhw->enabled) {
> +		*wf = (struct pwm_waveform) {
> +			.period_length_ns = 0,
> +		};
> +
> +		return 0;
> +	}
> +
> +	/*
> +	 * The constant low encoding doesn't hold a period. Report the
> +	 * shortest one, the output is low for all of it either way.
> +	 */
> +	if (period == AXIADO_PWM_PERIOD_CONST_LOW) {
> +		period = 1;
> +		duty = 0;
> +	} else if (duty > period) {
> +		duty = period;
> +	}

[Severity: High]
Does this logic misinterpret a constant-high hardware state as a 0% duty
cycle on readback?

The driver's comments indicate that a zero high time is interpreted by the
hardware as a constant high output (100% duty cycle). However, if the
hardware is already programmed with a zero high time (e.g., by the
bootloader), axiado_pwm_read_waveform() will read duty = 0.

When this state is processed here in axiado_pwm_round_waveform_fromhw(),
it fails to map duty = 0 to duty = period, returning a duty_length_ns
of 0 instead of 100% duty as documented by the hardware behavior.

This could cause an abrupt output flip from 100% duty (constant high) to
0% duty (constant low) when a consumer driver probes and inherits the
initial PWM state. If the PWM controls a voltage regulator, this drops the
voltage to 0, which could cause a system crash. For a backlight, the
screen could turn black.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921-axiado-ax3000-pwm-v5-0-202aad28e129@axiado.com?part=2

  reply	other threads:[~2026-09-21  7:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  7:21 [PATCH v5 0/2] pwm: add Axiado AX3000 PWM support Petar Stepanovic
2026-09-21  7:21 ` [PATCH v5 1/2] dt-bindings: pwm: add Axiado AX3000 PWM Petar Stepanovic
2026-09-21 14:35   ` Uwe Kleine-König
2026-09-23 10:25     ` Petar Stepanovic
2026-09-21  7:21 ` [PATCH v5 2/2] pwm: add Axiado AX3000 PWM driver Petar Stepanovic
2026-09-21  7:29   ` sashiko-bot [this message]
2026-09-21 14:48   ` Uwe Kleine-König
2026-09-23 10:28     ` Petar Stepanovic

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=20260921072933.8AC481F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=pstepanovic@axiado.com \
    --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